refactored to correctly include xylimited

xylimited changes are respected
This commit is contained in:
Wei-ju Wu 2016-06-15 17:18:24 -07:00
parent a11f22ab0c
commit 42e7203de5
7 changed files with 27 additions and 18 deletions

View File

@ -1,2 +1,5 @@
xunlimited
xlimited
xylimited
xyunlimited
xyunlimited2

View File

@ -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);

View File

@ -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__ */

View File

@ -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

View File

@ -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];

View File

@ -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];

View File

@ -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];