home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 13 Oct 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>StdGfx1.c<< 29 Jan 1997 13:28:53 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/Ex/StdGfx1 p:pLib/StartCode.o p:/pOS_RKRM/pGraphics/StdGfx1.c p:pLib/StdIO.o -l pOSStub -l pOS
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- /*\
- *** Example:
- ***
- \*/
-
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:pExec/Types.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/DosErrors.h"
- #include "p:pGadget/Gadget.h"
- #include "p:pGfx/StdGMap.h"
- #include "p:pGfx/StdCMap.h"
- #include "p:pGfx/GfxTags.h"
- #include "p:pGFX/RastPort.h"
- #include "p:pScreen/ScrTags.h"
- #include "p:pScreen/Window.h"
- #include "p:pScreen/Screen.h"
- #include "p:pIntui/IntuMsg.h"
- #include "p:pIntui/Tags.h"
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
- #include "p:proto/pIntui2.h"
- #include "p:proto/pGFX2.h"
-
- #ifdef _____ME_____
- #include "grund/inc_string.h"
- #include "grund/inc_stdio.h"
- #else
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <string.h>
- #include <stdio.h>
- #ifdef __cplusplus
- }
- #endif
- #endif
-
-
- const CHAR *HelpText=
- ""
- ;
-
- const CHAR *PrgHeader=
- "";
-
- const CHAR *PrgVerText=
- "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
-
-
-
- VOID DrawA(pOS_RastPort*,const pOS_IBox*);
- VOID DrawB(pOS_RastPort*,const pOS_IBox*);
- VOID DrawC(pOS_RastPort*,const pOS_IBox*);
- VOID DrawD(pOS_RastPort*,const pOS_IBox*);
- VOID DrawE(pOS_RastPort*,const pOS_IBox*);
-
-
-
-
- struct pOS_IntuiDevice *gb_IntuiBase;
- struct pOS_GfxBase *gb_GfxBase;
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- UWORD Err=0; //
- ULONG Ops[1]={0};
-
- gb_IntuiBase=(pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
- gb_GfxBase=(pOS_GfxBase*)pOS_OpenLibrary("pgraphics.library",0);
-
- Args=pOS_ReadDosArgs(
- // 0
- "NUM/N",
- Ops,sizeof(Ops)/sizeof(ULONG),
-
- ARGTAG_PrgHeaderText, (ULONG)PrgHeader, /* kurze Programm-Beschreibung */
- ARGTAG_HelpText, (ULONG)HelpText, /* Help-Texte */
- ARGTAG_PrgVerText, (ULONG)PrgVerText, /* VER-String */
- TAG_END);
-
-
- if(Args) {
- static const CHAR *WinNames[]={
- "(struct pOS_StdRGB8GfxMap*) - Test",
- "(struct pOS_StdChunky8GfxMap*) - Test",
- "(struct pOS_StdChunky8GfxMap*)+(struct pOS_StdRLColorMap*) - Test",
- "(struct pOS_StdChunky8GfxMap*)+(struct pOS_StdRLColorMap*) + TempMap - Test",
- "(struct pOS_StdRGB8GfxMap*) + TempMap - Test",
- };
- ULONG Num=Ops[0] ? *((ULONG*)Ops[0]) : 0;
- struct pOS_Window *Win;
-
- if(Num>4) Num=4;
-
- Win=pOS_OpenWindow(
- SCRTAG_Title, (ULONG)WinNames[Num],
- SCRTAG_PubName, (ULONG)"Workbench",
- SCRTAG_Flags, WINFLGF_DepthGadget | WINFLGF_SimpleRefresh |
- WINFLGF_SizeGadget | WINFLGF_Activate |
- WINFLGF_CloseGadget | WINFLGF_Dragbar |
- WINFLGF_SizeBBottom,
- SCRTAG_IDCMP, IDCMP_CloseWindow | IDCMP_StdSysMsg |
- IDCMP_RefreshWindow | IDCMP_NewSize,
- SCRTAG_ZipGadget,TRUE,
- TAG_DONE);
- if(Win) {
- struct pOS_IntuiMessage *Msg;
- struct pOS_IBox Box;
- BOOL Ende=FALSE;
-
- pOS_GetWindowIBox(Win,&Box,NULL);
-
- while(!Ende) {
- if(DOSSIGF_CTRL_C & pOS_WaitSignal((1<<Win->win_UserPort->mp_SigBit) | DOSSIGF_CTRL_C)) break;
-
- while(Msg=(pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
-
- switch(Msg->im_Class) {
-
- case IDCMP_RefreshWindow:
- if(pOS_BeginRefresh(Win,NULL)) {
- switch(Num) {
- case 0: DrawA(Win->win_RastPort,&Box); break;
- case 1: DrawB(Win->win_RastPort,&Box); break;
- case 2: DrawC(Win->win_RastPort,&Box); break;
- case 3: DrawD(Win->win_RastPort,&Box); break;
- case 4: DrawE(Win->win_RastPort,&Box); break;
- }
- pOS_EndRefresh(Win,TRUE);
- }
- break;
-
- case IDCMP_NewSize:
- pOS_GetWindowIBox(Win,&Box,NULL);
- break;
-
- case IDCMP_CloseWindow: Ende=TRUE; break;
-
- default:
- if(pOS_SysIMessage(Msg)) Msg=NULL;
- }
- if(Msg) pOS_ReplyMsg(&Msg->im_Message);
- }
- }
- pOS_CloseWindow(Win);
- }
- else printf("Cannot open window\n");
-
- pOS_DeleteDosArgs(Args); /* Args freigeben */
- }
- else Err=DOSFAIL_FAIL; /* vollkommen fehlgeschlagen */
-
- pOS_SetShellFail(Err);
-
- pOS_CloseLibrary((pOS_Library*)gb_IntuiBase);
- pOS_CloseLibrary((pOS_Library*)gb_GfxBase);
- }
-
-
- VOID DrawA(pOS_RastPort* rp,const pOS_IBox *box)
- {
- pOS_StdRGB8GfxMap *GfxMap;
-
- GfxMap=(pOS_StdRGB8GfxMap*)pOS_AllocGfxMap(NULL,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_GfxType, GFXMAPTYP_StdRGB8,
- TAG_END);
- if(GfxMap) {
- ULONG x;
- for(x=0; x<box->Width; ++x) GfxMap->rgbgm_R[x]=x;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->rgbgm_R[x*box->Width],GfxMap->rgbgm_R,box->Width);
-
- for(x=0; x<box->Width; ++x) GfxMap->rgbgm_G[x]=255-x*2;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->rgbgm_G[x*box->Width],GfxMap->rgbgm_G,box->Width);
-
- for(x=0; x<box->Width; ++x) GfxMap->rgbgm_B[x]=x*4;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->rgbgm_B[x*box->Width],GfxMap->rgbgm_B,box->Width);
-
- pOS_WriteStdGfxMapRastPort(&GfxMap->rgbgm_Gfx,0,0,
- rp,box->Left,box->Top,box->Width,box->Height,0);
- pOS_FreeGfxMap(&GfxMap->rgbgm_Gfx);
- }
- }
-
-
- VOID DrawB(pOS_RastPort* rp,const pOS_IBox *box)
- {
- pOS_StdChunky8GfxMap *GfxMap;
-
- GfxMap=(pOS_StdChunky8GfxMap*)pOS_AllocGfxMap(NULL,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_GfxType, GFXMAPTYP_StdChunky8,
- TAG_END);
- if(GfxMap) {
- ULONG x;
- for(x=0; x<box->Width; ++x) GfxMap->ckgm_Chunky[x]=x/4;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->ckgm_Chunky[x*box->Width],GfxMap->ckgm_Chunky,box->Width);
-
- pOS_WriteStdGfxMapRastPort(&GfxMap->ckgm_Gfx,0,0,
- rp,box->Left,box->Top,box->Width,box->Height,0);
- pOS_FreeGfxMap(&GfxMap->ckgm_Gfx);
- }
- }
-
-
- VOID DrawC(pOS_RastPort* rp,const pOS_IBox *box)
- {
- pOS_StdChunky8GfxMap *GfxMap;
- pOS_StdRLColorMap *ColorMap;
-
- ColorMap=(pOS_StdRLColorMap*)pOS_AllocColorMap(NULL,
- GFXTAG_ColorType, COLMAPTYP_StdRLut,
- GFXTAG_Colors, 256,
- TAG_END);
-
- GfxMap=(pOS_StdChunky8GfxMap*)pOS_AllocGfxMap(NULL,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_GfxType, GFXMAPTYP_StdChunky8,
- GFXTAG_CrtGfxMapEx, TRUE,
- GFXTAG_ColorMap, (ULONG)ColorMap,
- TAG_END);
-
-
- if(GfxMap && ColorMap) {
- ULONG x;
-
- for(x=0; x<256; ++x) {
- ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_R=x;
- ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_G=x;
- ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_B=x;
- }
-
- for(x=0; x<box->Width; ++x) GfxMap->ckgm_Chunky[x]=x/2;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->ckgm_Chunky[x*box->Width],GfxMap->ckgm_Chunky,box->Width);
-
- pOS_WriteStdGfxMapRastPort(&GfxMap->ckgm_Gfx,0,0,
- rp,box->Left,box->Top,box->Width,box->Height,0);
- }
- if(GfxMap) pOS_FreeGfxMap(&GfxMap->ckgm_Gfx);
- if(ColorMap) pOS_FreeColorMap(&ColorMap->rlcm_CM);
- }
-
-
-
- VOID DrawD(pOS_RastPort* rp,const pOS_IBox *box)
- {
- pOS_StdChunky8GfxMap *GfxMap;
- pOS_GfxMap *TempMap;
- pOS_StdRLColorMap *ColorMap;
-
- ColorMap=(pOS_StdRLColorMap*)pOS_AllocColorMap(NULL,
- GFXTAG_ColorType, COLMAPTYP_StdRLut,
- GFXTAG_Colors, 256,
- TAG_END);
-
- GfxMap=(pOS_StdChunky8GfxMap*)pOS_AllocGfxMap(NULL,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_GfxType, GFXMAPTYP_StdChunky8,
- GFXTAG_CrtGfxMapEx, TRUE,
- GFXTAG_ColorMap, (ULONG)ColorMap,
- TAG_END);
-
- TempMap=pOS_AllocGfxMap(rp->rp_Base,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_CrtGfxMapEx, TRUE,
- GFXTAG_FriendGfxMap,rp->rp_GfxMap,
- TAG_DONE);
-
- if(ColorMap && GfxMap && TempMap) {
- ULONG x;
-
- for(x=0; x<256; ++x) {
- ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_R=x;
- ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_G=x;
- ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_B=x;
- }
-
- for(x=0; x<box->Width; ++x) GfxMap->ckgm_Chunky[x]=x/2;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->ckgm_Chunky[x*box->Width],GfxMap->ckgm_Chunky,box->Width);
-
- pOS_WriteStdGfxMap(&GfxMap->ckgm_Gfx,0,0,TempMap,0,0,box->Width,box->Height,0,NULL);
- pOS_BltGfxMapRastPort(TempMap,0,0,rp,box->Left,box->Top,box->Width,box->Height,BLTMINT_Copy);
- }
- if(GfxMap) pOS_FreeGfxMap(&GfxMap->ckgm_Gfx);
- if(TempMap) pOS_FreeGfxMap(TempMap);
- if(ColorMap) pOS_FreeColorMap(&ColorMap->rlcm_CM);
- }
-
-
- VOID DrawE(pOS_RastPort* rp,const pOS_IBox *box)
- {
- pOS_StdRGB8GfxMap *GfxMap;
- pOS_GfxMap *TempMap;
-
- GfxMap=(pOS_StdRGB8GfxMap*)pOS_AllocGfxMap(NULL,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_GfxType, GFXMAPTYP_StdRGB8,
- TAG_END);
-
- TempMap=pOS_AllocGfxMap(rp->rp_Base,
- GFXTAG_Width, box->Width,
- GFXTAG_Height, box->Height,
- GFXTAG_CrtGfxMapEx, TRUE,
- GFXTAG_FriendGfxMap,rp->rp_GfxMap,
- TAG_DONE);
-
- if(GfxMap && TempMap) {
- ULONG x;
- for(x=0; x<box->Width; ++x) GfxMap->rgbgm_R[x]=x;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->rgbgm_R[x*box->Width],GfxMap->rgbgm_R,box->Width);
-
- for(x=0; x<box->Width; ++x) GfxMap->rgbgm_G[x]=255-x*2;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->rgbgm_G[x*box->Width],GfxMap->rgbgm_G,box->Width);
-
- for(x=0; x<box->Width; ++x) GfxMap->rgbgm_B[x]=x*4;
- for(x=1; x<box->Height; ++x) memcpy(&GfxMap->rgbgm_B[x*box->Width],GfxMap->rgbgm_B,box->Width);
-
- pOS_WriteStdGfxMap(&GfxMap->rgbgm_Gfx,0,0,TempMap,0,0,box->Width,box->Height,0,NULL);
- pOS_BltGfxMapRastPort(TempMap,0,0,rp,box->Left,box->Top,box->Width,box->Height,BLTMINT_Copy);
- }
- if(GfxMap) pOS_FreeGfxMap(&GfxMap->rgbgm_Gfx);
- if(TempMap) pOS_FreeGfxMap(TempMap);
- }
-
-