diff --git a/scrolling_tricks/Makefile b/scrolling_tricks/Makefile index 808860e..b467958 100644 --- a/scrolling_tricks/Makefile +++ b/scrolling_tricks/Makefile @@ -16,9 +16,9 @@ cop.o: cop.asm .c.o: $(CC) $(CFLAGS) -c -o $@ $^ -xunlimited: hardware.o cop.o xunlimited.o +xunlimited: hardware.o cop.o common.o xunlimited.o $(CC) -o $@ $^ -lamiga -lauto -xlimited: hardware.o cop.o xlimited.o +xlimited: hardware.o cop.o common.o xlimited.o $(CC) -o $@ $^ -lamiga -lauto diff --git a/scrolling_tricks/global_defs.h b/scrolling_tricks/global_defs.h index 9f08fac..09cf7cd 100644 --- a/scrolling_tricks/global_defs.h +++ b/scrolling_tricks/global_defs.h @@ -38,4 +38,7 @@ #define PALSIZE (BLOCKSCOLORS * 2) +#define IS_BITMAP_INTERLEAVED(bitmap) ((GetBitMapAttr(bitmap, BMA_FLAGS) & BMF_INTERLEAVED) == BMF_INTERLEAVED) +#define ROUND2BLOCKWIDTH(x) ((x) & ~(BLOCKWIDTH - 1)) + #endif /* __GLOBAL_DEFS_H__ */ diff --git a/scrolling_tricks/xlimited.c b/scrolling_tricks/xlimited.c index 4d8ba6a..284b463 100644 --- a/scrolling_tricks/xlimited.c +++ b/scrolling_tricks/xlimited.c @@ -19,6 +19,7 @@ #include "map.h" #include "global_defs.h" +#include "common.h" #define BITMAPWIDTH (SCREENWIDTH + EXTRAWIDTH) @@ -80,14 +81,7 @@ char s[256]; #endif -struct FetchInfo -{ - WORD ddfstart; - WORD ddfstop; - WORD modulooffset; - WORD bitmapoffset; - WORD scrollpixels; -} fetchinfo [] = +struct FetchInfo fetchinfo [] = { {0x30,0xD0,2,0,16}, /* normal */ {0x28,0xC8,4,16,32}, /* BPL32 */ @@ -95,10 +89,6 @@ struct FetchInfo {0x18,0xB8,8,48,64} /* BPL32 + BPAGEM */ }; -/********************* MACROS ***********************/ - -#define ROUND2BLOCKWIDTH(x) ((x) & ~(BLOCKWIDTH - 1)) - /************* SETUP/CLEANUP ROUTINES ***************/ static void Cleanup (char *msg) @@ -203,50 +193,41 @@ static void OpenBlocks(void) LONG l; if (!(BlocksBitmap = AllocBitMap(BLOCKSWIDTH, - BLOCKSHEIGHT, - BLOCKSDEPTH, - BMF_STANDARD | BMF_INTERLEAVED, - 0))) - { + BLOCKSHEIGHT, + BLOCKSDEPTH, + BMF_STANDARD | BMF_INTERLEAVED, + 0))) { Cleanup("Can't alloc blocks bitmap!"); } - if (!(MyHandle = Open(BLOCKSNAME,MODE_OLDFILE))) - { + if (!(MyHandle = Open(BLOCKSNAME,MODE_OLDFILE))) { Fault(IoErr(),0,s,255); Cleanup(s); } - if (Read(MyHandle,colors,PALSIZE) != PALSIZE) - { + if (Read(MyHandle,colors,PALSIZE) != PALSIZE) { Fault(IoErr(),0,s,255); Cleanup(s); } l = BLOCKSWIDTH * BLOCKSHEIGHT * BLOCKSDEPTH / 8; - if (Read(MyHandle,BlocksBitmap->Planes[0],l) != l) - { + if (Read(MyHandle,BlocksBitmap->Planes[0],l) != l) { Fault(IoErr(),0,s,255); Cleanup(s); } - - Close(MyHandle);MyHandle = 0; - + Close(MyHandle); + MyHandle = 0; blocksbuffer = BlocksBitmap->Planes[0]; } static void OpenDisplay(void) -{ - struct DimensionInfo diminfo; - DisplayInfoHandle dih; +{ ULONG modeid; - LONG l; - + bitmapheight = BITMAPHEIGHT + (mapwidth / BITMAPBLOCKSPERROW / BLOCKSDEPTH) + 1 + 3; - if (!(ScreenBitmap = AllocBitMap(BITMAPWIDTH,bitmapheight,BLOCKSDEPTH,BMF_STANDARD | BMF_INTERLEAVED | BMF_CLEAR,0))) { @@ -261,42 +242,11 @@ static void OpenDisplay(void) Cleanup("Screen bitmap is not in CHIP RAM!?? If you have a gfx card try disabling \"planes to fast\" or similiar options in your RTG system!"); } - l = GetBitMapAttr(ScreenBitmap,BMA_FLAGS); - - if (!(GetBitMapAttr(ScreenBitmap,BMA_FLAGS) & BMF_INTERLEAVED)) - { + if (!IS_BITMAP_INTERLEAVED(ScreenBitmap)) { Cleanup("Screen bitmap is not in interleaved format!??"); } - - if (option_how) - { - modeid = INVALID_ID; - - if ((dih = FindDisplayInfo(VGAPRODUCT_KEY))) - { - if (GetDisplayInfoData(dih,(APTR)&diminfo,sizeof(diminfo),DTAG_DIMS,0)) - { - if (diminfo.MaxDepth >= BLOCKSDEPTH) modeid = VGAPRODUCT_KEY; - } - } - if (modeid == INVALID_ID) - { - if (option_ntsc) - { - modeid = NTSC_MONITOR_ID | HIRESLACE_KEY; - } else { - modeid = PAL_MONITOR_ID | HIRESLACE_KEY; - } - } - } else { - if (option_ntsc) - { - modeid = NTSC_MONITOR_ID; - } else { - modeid = PAL_MONITOR_ID; - } - } + modeid = get_mode_id(option_how, option_ntsc); if (!(scr = OpenScreenTags(0,SA_Width,BITMAPWIDTH, SA_Height,bitmapheight, SA_Depth,BLOCKSDEPTH, diff --git a/scrolling_tricks/xunlimited.c b/scrolling_tricks/xunlimited.c index 56d8786..219b91e 100644 --- a/scrolling_tricks/xunlimited.c +++ b/scrolling_tricks/xunlimited.c @@ -18,6 +18,7 @@ #include "cop.h" #include "map.h" #include "global_defs.h" +#include "common.h" #define BITMAPWIDTH ((SCREENWIDTH + EXTRAWIDTH) * 2) @@ -47,21 +48,14 @@ UBYTE *mapdata; UWORD colors[BLOCKSCOLORS]; LONG Args[NUM_ARGS]; +struct PrgOptions options; BOOL option_ntsc,option_how,option_speed,option_sky; WORD option_fetchmode; BPTR MyHandle; char s[256]; -struct FetchInfo -{ - WORD ddfstart; - WORD ddfstop; - WORD modulooffset; - WORD bitmapoffset; - WORD scrollpixels; - -} fetchinfo [] = +struct FetchInfo fetchinfo [] = { {0x30,0xD0,2,0,16}, /* normal */ {0x28,0xC8,4,16,32}, /* BPL32 */ @@ -69,49 +63,6 @@ struct FetchInfo {0x18,0xB8,8,48,64} /* BPL32 + BPAGEM */ }; -/********************* MACROS ***********************/ - -#define ROUND2BLOCKWIDTH(x) ((x) & ~(BLOCKWIDTH - 1)) - -/********************* COMPATIBILITY ***********************/ - -ULONG is_bitmap_interleaved(struct BitMap *bitmap) -{ - return (GetBitMapAttr(bitmap, BMA_FLAGS) & BMF_INTERLEAVED) == BMF_INTERLEAVED; -} - -static ULONG get_mode_id_os3(void) -{ - ULONG modeid = INVALID_ID; - struct DimensionInfo diminfo; - DisplayInfoHandle dih; - - if ((dih = FindDisplayInfo(VGAPRODUCT_KEY))) { - if (GetDisplayInfoData(dih,(APTR)&diminfo,sizeof(diminfo),DTAG_DIMS,0)) { - if (diminfo.MaxDepth >= BLOCKSDEPTH) modeid = VGAPRODUCT_KEY; - } - } - return modeid; -} - -ULONG get_mode_id(void) -{ - ULONG modeid; - - if (option_how) { - modeid = get_mode_id_os3(); - - if (modeid == INVALID_ID) { - if (option_ntsc) modeid = NTSC_MONITOR_ID | HIRESLACE_KEY; - else modeid = PAL_MONITOR_ID | HIRESLACE_KEY; - } - } else { - if (option_ntsc) modeid = NTSC_MONITOR_ID; - else modeid = PAL_MONITOR_ID; - } - return modeid; -} - /************* SETUP/CLEANUP ROUTINES ***************/ static void Cleanup(char *msg) @@ -140,7 +91,7 @@ static void Cleanup(char *msg) exit(rc); } -static void GetArguments(void) +static void GetArguments(struct PrgOptions *options) { struct RDArgs *MyArgs; @@ -203,7 +154,7 @@ static void OpenBlocks(void) BLOCKSHEIGHT, BLOCKSDEPTH, BMF_STANDARD | BMF_INTERLEAVED, - 0))) { + 0))) { Cleanup("Can't alloc blocks bitmap!"); } @@ -223,7 +174,8 @@ static void OpenBlocks(void) Fault(IoErr(),0,s,255); Cleanup(s); } - Close(MyHandle);MyHandle = 0; + Close(MyHandle); + MyHandle = 0; blocksbuffer = BlocksBitmap->Planes[0]; } @@ -243,10 +195,10 @@ static void OpenDisplay(void) Cleanup("Screen bitmap is not in CHIP RAM!?? If you have a gfx card try disabling \"planes to fast\" or similiar options in your RTG system!"); } - if (!is_bitmap_interleaved(ScreenBitmap)) { + if (!IS_BITMAP_INTERLEAVED(ScreenBitmap)) { Cleanup("Screen bitmap is not in interleaved format!??"); } - modeid = get_mode_id(); + modeid = get_mode_id(option_how, option_ntsc); if (!(scr = OpenScreenTags(0,SA_Width,BITMAPWIDTH, SA_Height,BITMAPHEIGHT + 3, @@ -490,7 +442,7 @@ static void MainLoop(void) int main(int argc, char **argv) { - GetArguments(); + GetArguments(&options); OpenMap(); OpenBlocks(); OpenDisplay();