home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 22 Oct 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>ScreenBF.c<< 29 Jan 1997 13:32:25 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/Ex/ScreenBF p:pLib/StartCode.o p:/pOS_RKRM/pLayer/ScreenBF.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
-
- #include "p:pExec/Types.h"
- #include "p:pExec/Callback.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/DosErrors.h"
- #include "p:pGFX/GfxMap.h"
- #include "p:pGFX/GfxTags.h"
- #include "p:pGFX/RastPort.h"
- #include "p:pGadget/Gadget.h"
- #include "p:pScreen/ScrTags.h"
- #include "p:pScreen/Screen.h"
- #include "p:pDtType/DtTags.h"
- #include "p:pDtType/Picture.h"
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
- #include "p:proto/pIntui2.h"
- #include "p:proto/pLayer2.h"
- #include "p:proto/pGFX2.h"
- #include "p:proto/pDtType2.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
-
- #ifndef MIN
- #define MIN(a,b) ( (a) > (b) ? (b) : (a) )
- #endif
-
-
-
- const CHAR *HelpText=
- ""
- ;
-
- const CHAR *PrgHeader=
- "";
-
- const CHAR *PrgVerText=
- "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
-
-
- struct pOS_IntuiDevice *gb_IntuiBase;
- struct pOS_LayerBase *gb_LayerBase;
- struct pOS_GfxBase *gb_GfxBase;
- struct pOS_DataTypeBase *gb_DtTypeBase;
-
-
- /*----------------------------------
- -----------------------------------*/
- BOOL CallBack_func(_R_A0 const struct pOS_Callback* cb,
- _R_A1 struct pOS_LayerHookData* data)
- {
- const struct pOS_GfxMap *const PMap=(struct pOS_GfxMap*)cb->cb_UserData[0];
- const struct pOS_Screen *const Scr=(struct pOS_Screen*)cb->cb_UserData[1];
- struct pOS_GfxMap *const GM=data->lyhd_LayerInfo->li_GfxMap;
- struct pOS_GfxLibrary *const Lib=GM->gm_Base;
-
- SLONG SX=data->lyhd_Bounds.MinX-data->lyhd_OriginX;
- SLONG SY=data->lyhd_Bounds.MinY-data->lyhd_OriginY;
- ULONG Width,Height,X,Y,PX,PY;
-
- if(SY>=Scr->scr_BarHeight)
- SY-=Scr->scr_BarHeight;
- else SY =PMap->gm_Height-Scr->scr_BarHeight;
-
- SX %= PMap->gm_Width;
- SY %= PMap->gm_Height;
-
- for(PY=SY, Y=data->lyhd_Bounds.MinY; Y<=data->lyhd_Bounds.MaxY; Y+=Height) {
- Height=MIN( data->lyhd_Bounds.MaxY-Y+1, PMap->gm_Height-PY);
- if(Height>0) {
-
- for(PX=SX, X=data->lyhd_Bounds.MinX; X<=data->lyhd_Bounds.MaxX; X+=Width) {
- Width=MIN( data->lyhd_Bounds.MaxX-X+1, PMap->gm_Width-PX);
- if(Width>0) {
- pOS_BltGfxMap(PMap,PX,PY,GM,X,Y,Width,Height,BLTMINT_Copy);
- }
- PX=0;
- }
- }
- PY=0;
- }
- return(TRUE); // *** keinen weiteren CB aufrufen
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- UWORD Err=0;
- ULONG Ops[1]={0};
-
- gb_IntuiBase=(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
- gb_LayerBase=(struct pOS_LayerBase*)pOS_OpenLibrary("pLayer.library",0);
- gb_GfxBase=(struct pOS_GfxBase*)pOS_OpenLibrary("pGraphics.library",0);
- gb_DtTypeBase=(struct pOS_DataTypeBase*)pOS_OpenLibrary("pDtType.library",0);
-
- Args=pOS_ReadDosArgs(
- // 0
- "FILE/A",
- 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) {
- struct pOS_Screen* Scr;
-
- if(Scr=pOS_LockPubScreen("Workbench")) {
- struct pOS_Callback CB;
- struct pOS_DataType *DT;
- struct pOS_GfxMap *BgFillMap=NULL;
-
- DT=pOS_CreateFHDTObject(NULL,(dosname_t*)Ops[0],pOS_DTFORM_PICTURE,NULL,
- DCLTAG_Remap, TRUE, // remap erlauben
- PICTURETAG_GfxMapPtr, (ULONG)&BgFillMap, // result
- PICTURETAG_RemapMode, 0, // Mode => friend
- PICTURETAG_FriendGfxMap, (ULONG)Scr->scr_RastPort->rp_GfxMap,
- TAG_END);
- if(DT) pOS_DeleteDTObject(DT);
- else pOS_PrintDosErr(NULL,(CHAR*)Ops[0],0);
-
- if(BgFillMap) {
- ww_InitNode(&CB.cb_Node); // only in debug-mode
- CB.cb_Code=( ULONG(*)(_R_A0 const pOS_Callback*,_R_A1 APTR) ) CallBack_func;
- CB.cb_UserData[0]=(ULONG)BgFillMap;
- CB.cb_UserData[1]=(ULONG)Scr;
-
- pOS_AddLayerInfoHook(Scr->scr_LayerInfo,&CB,TRUE);
- printf("Installed ... (Abort CTRL-C) ");
- pOS_WaitSignal(DOSSIGF_CTRL_C);
- pOS_RemLayerInfoHook(Scr->scr_LayerInfo,&CB,TRUE);
- printf("... removed\n");
- pOS_FreeGfxMap(BgFillMap);
- }
- pOS_UnlockPubScreen(Scr);
- }
- else printf("Cannot lock PubScreen\n");
- pOS_DeleteDosArgs(Args); /* Args freigeben */
- }
- else Err=DOSFAIL_FAIL; /* vollkommen fehlgeschlagen */
-
- pOS_SetShellFail(Err);
-
- pOS_CloseLibrary((struct pOS_Library*)gb_IntuiBase);
- pOS_CloseLibrary((struct pOS_Library*)gb_LayerBase);
- pOS_CloseLibrary((struct pOS_Library*)gb_GfxBase);
- pOS_CloseLibrary((struct pOS_Library*)gb_DtTypeBase);
- }
-