From 42e7203de5f29a58047ef7f944100e7e5727ec00 Mon Sep 17 00:00:00 2001 From: Wei-ju Wu Date: Wed, 15 Jun 2016 17:18:24 -0700 Subject: [PATCH] refactored to correctly include xylimited xylimited changes are respected --- scrolling_tricks/.gitignore | 3 +++ scrolling_tricks/common.c | 14 +++++++------- scrolling_tricks/common.h | 4 ++-- scrolling_tricks/global_defs.h | 3 --- scrolling_tricks/xlimited.c | 7 +++++-- scrolling_tricks/xunlimited.c | 7 +++++-- scrolling_tricks/xylimited.c | 7 +++++-- 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/scrolling_tricks/.gitignore b/scrolling_tricks/.gitignore index 4970a3a..00dc32a 100644 --- a/scrolling_tricks/.gitignore +++ b/scrolling_tricks/.gitignore @@ -1,2 +1,5 @@ xunlimited xlimited +xylimited +xyunlimited +xyunlimited2 diff --git a/scrolling_tricks/common.c b/scrolling_tricks/common.c index d36f267..f09c288 100644 --- a/scrolling_tricks/common.c +++ b/scrolling_tricks/common.c @@ -70,13 +70,13 @@ BOOL get_arguments(struct PrgOptions *options, char *s) return TRUE; } -BOOL read_level_map(struct LevelMap *level_map, char *s) +BOOL read_level_map(const char *path, struct LevelMap *level_map, char *s) { LONG l; BPTR fhandle; struct RawMap *raw_map; - if (!(fhandle = Open(MAPNAME, MODE_OLDFILE))) + if (!(fhandle = Open(path, MODE_OLDFILE))) { Fault(IoErr(), 0, s, 255); return FALSE; @@ -105,14 +105,14 @@ BOOL read_level_map(struct LevelMap *level_map, char *s) return TRUE; } -struct BitMap *read_blocks(UWORD *colors, char *s) +struct BitMap *read_blocks(UWORD *colors, char *s, int blocks_width, int blocks_height) { LONG l; struct BitMap *bitmap; BPTR fhandle; - if (!(bitmap = AllocBitMap(BLOCKSWIDTH, - BLOCKSHEIGHT, + if (!(bitmap = AllocBitMap(blocks_width, + blocks_height, BLOCKSDEPTH, BMF_STANDARD | BMF_INTERLEAVED, 0))) { @@ -120,7 +120,7 @@ struct BitMap *read_blocks(UWORD *colors, char *s) return NULL; } - if (!(fhandle = Open(BLOCKSNAME,MODE_OLDFILE))) { + if (!(fhandle = Open(BLOCKSNAME, MODE_OLDFILE))) { Fault(IoErr(), 0, s, 255); FreeBitMap(bitmap); return NULL; @@ -133,7 +133,7 @@ struct BitMap *read_blocks(UWORD *colors, char *s) return NULL; } - l = BLOCKSWIDTH * BLOCKSHEIGHT * BLOCKSDEPTH / 8; + l = blocks_width * blocks_height * BLOCKSDEPTH / 8; if (Read(fhandle, bitmap->Planes[0], l) != l) { Fault(IoErr(), 0, s, 255); diff --git a/scrolling_tricks/common.h b/scrolling_tricks/common.h index 8eacba3..db3e161 100644 --- a/scrolling_tricks/common.h +++ b/scrolling_tricks/common.h @@ -38,7 +38,7 @@ struct LevelMap { extern ULONG get_mode_id(BOOL option_how, BOOL option_ntsc); extern BOOL get_arguments(struct PrgOptions *options, char *s); -extern BOOL read_level_map(struct LevelMap *level_map, char *s); -extern struct BitMap *read_blocks(UWORD *colors, char *s); +extern BOOL read_level_map(const char * path, struct LevelMap *level_map, char *s); +extern struct BitMap *read_blocks(UWORD *colors, char *s, int blocks_width, int blocks_height); #endif /* __COMMON_H__ */ diff --git a/scrolling_tricks/global_defs.h b/scrolling_tricks/global_defs.h index c5cccfa..fccfe80 100644 --- a/scrolling_tricks/global_defs.h +++ b/scrolling_tricks/global_defs.h @@ -10,7 +10,6 @@ #define ARG_FMODE 4 #define NUM_ARGS 5 -#define MAPNAME "maps/large.raw" #define BLOCKSNAME "blocks/demoblocks.raw" #define SCREENWIDTH 320 @@ -22,8 +21,6 @@ #define BLOCKWIDTH 16 #define BLOCKHEIGHT 16 -#define BLOCKSBYTESPERROW (BLOCKSWIDTH / 8) -#define BLOCKSPERROW (BLOCKSWIDTH / BLOCKWIDTH) #define NUMSTEPS BLOCKWIDTH diff --git a/scrolling_tricks/xlimited.c b/scrolling_tricks/xlimited.c index dcd9b36..5591296 100644 --- a/scrolling_tricks/xlimited.c +++ b/scrolling_tricks/xlimited.c @@ -19,6 +19,7 @@ #include "global_defs.h" #include "common.h" +#define MAPNAME "maps/large.raw" #define EXTRAWIDTH 32 #define BITMAPWIDTH (SCREENWIDTH + EXTRAWIDTH) @@ -27,6 +28,8 @@ #define BLOCKSWIDTH 320 #define BLOCKSHEIGHT 256 +#define BLOCKSBYTESPERROW (BLOCKSWIDTH / 8) +#define BLOCKSPERROW (BLOCKSWIDTH / BLOCKWIDTH) #define BITMAPBLOCKSPERROW (BITMAPWIDTH / BLOCKWIDTH) #define BITMAPBLOCKSPERCOL (BITMAPHEIGHT / BLOCKHEIGHT) @@ -414,10 +417,10 @@ int main(int argc, char **argv) { BOOL res = get_arguments(&options, s); if (!res) Cleanup(s); - res = read_level_map(&level_map, s); + res = read_level_map(MAPNAME, &level_map, s); if (!res) Cleanup(s); - BlocksBitmap = read_blocks(colors, s); + BlocksBitmap = read_blocks(colors, s, BLOCKSWIDTH, BLOCKSHEIGHT); if (!BlocksBitmap) Cleanup(s); blocksbuffer = BlocksBitmap->Planes[0]; diff --git a/scrolling_tricks/xunlimited.c b/scrolling_tricks/xunlimited.c index 2e7d609..a4c5c25 100644 --- a/scrolling_tricks/xunlimited.c +++ b/scrolling_tricks/xunlimited.c @@ -19,6 +19,7 @@ #include "global_defs.h" #include "common.h" +#define MAPNAME "maps/large.raw" #define EXTRAWIDTH 32 #define BITMAPWIDTH ((SCREENWIDTH + EXTRAWIDTH) * 2) @@ -29,6 +30,8 @@ #define BLOCKSWIDTH 320 #define BLOCKSHEIGHT 256 +#define BLOCKSBYTESPERROW (BLOCKSWIDTH / 8) +#define BLOCKSPERROW (BLOCKSWIDTH / BLOCKWIDTH) #define BITMAPBLOCKSPERROW (BITMAPWIDTH / BLOCKWIDTH) #define HALFBITMAPBLOCKSPERROW (BITMAPBLOCKSPERROW / 2) @@ -354,10 +357,10 @@ int main(int argc, char **argv) { BOOL res = get_arguments(&options, s); if (!res) Cleanup(s); - res = read_level_map(&level_map, s); + res = read_level_map(MAPNAME, &level_map, s); if (!res) Cleanup(s); - BlocksBitmap = read_blocks(colors, s); + BlocksBitmap = read_blocks(colors, s, BLOCKSWIDTH, BLOCKSHEIGHT); if (!BlocksBitmap) Cleanup(s); blocksbuffer = BlocksBitmap->Planes[0]; diff --git a/scrolling_tricks/xylimited.c b/scrolling_tricks/xylimited.c index e6c7840..5bb6406 100644 --- a/scrolling_tricks/xylimited.c +++ b/scrolling_tricks/xylimited.c @@ -19,6 +19,7 @@ #include "global_defs.h" #include "common.h" +#define MAPNAME "maps/Scroller.raw" #define EXTRAWIDTH 64 #define EXTRAHEIGHT 32 @@ -28,6 +29,8 @@ #define BLOCKSWIDTH 320 #define BLOCKSHEIGHT 200 +#define BLOCKSBYTESPERROW (BLOCKSWIDTH / 8) +#define BLOCKSPERROW (BLOCKSWIDTH / BLOCKWIDTH) #define NUMSTEPS_X BLOCKWIDTH #define NUMSTEPS_Y BLOCKHEIGHT @@ -780,10 +783,10 @@ int main(int argc, char **argv) { BOOL res = get_arguments(&options, s); if (!res) Cleanup(s); - res = read_level_map(&level_map, s); + res = read_level_map(MAPNAME, &level_map, s); if (!res) Cleanup(s); - BlocksBitmap = read_blocks(colors, s); + BlocksBitmap = read_blocks(colors, s, BLOCKSWIDTH, BLOCKSHEIGHT); if (!BlocksBitmap) Cleanup(s); blocksbuffer = BlocksBitmap->Planes[0];