diff --git a/games/keen/maps/Makefile b/games/keen/maps/Makefile index 3f82e710..f3d27f2c 100644 --- a/games/keen/maps/Makefile +++ b/games/keen/maps/Makefile @@ -5,7 +5,7 @@ ZX02 = ~/research/6502_compression/zx02.git/build/zx02 -f PNG2GR = ../../../utils/gr-utils/png2gr -all: level1_map.zx02 png2map mars_map.gr.zx02 +all: level1_map.zx02 png2map mars_map.gr.zx02 mars_new.zx02 ### @@ -16,6 +16,15 @@ level1_map.inc: level1_map.png png2map ./png2map level1_map.png level1_map.inc +### + +mars_new.zx02: mars_new.inc + $(ZX02) mars_new.inc mars_new.zx02 + +mars_new.inc: mars_new.png png2map + ./png2map mars_new.png mars_new.inc + + ### mars_map.gr.zx02: mars_map.gr diff --git a/games/keen/maps/level1_map.png b/games/keen/maps/level1_map.png index 85c46907..2b9b96a3 100644 Binary files a/games/keen/maps/level1_map.png and b/games/keen/maps/level1_map.png differ diff --git a/games/keen/maps/loadpng.c b/games/keen/maps/loadpng.c index dae7fbaa..13fb38a4 100644 --- a/games/keen/maps/loadpng.c +++ b/games/keen/maps/loadpng.c @@ -1,7 +1,4 @@ -/* Loads a 80x48 (or 40x48) PNG image into a 40x48 Apple II layout */ -/* It's not interleaved like an actual Apple II */ -/* But the top/bottom are pre-packed into a naive 40x24 array */ - +/* loads png for png2map */ #include #include @@ -46,7 +43,7 @@ static int convert_color(int color, char *filename) { return c; } -/* expects a PNG where the xsize is either 1280x200 */ +/* expects a PNG that is 660x336 */ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize, int png_type) { @@ -102,8 +99,8 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize, width = png_get_image_width(png_ptr, info_ptr); height = png_get_image_height(png_ptr, info_ptr); - if (width==1280) { - *xsize=1280; + if (width==660) { + *xsize=660; xadd=1; } else { diff --git a/games/keen/maps/mars_new.png b/games/keen/maps/mars_new.png new file mode 100644 index 00000000..c9281cd3 Binary files /dev/null and b/games/keen/maps/mars_new.png differ diff --git a/games/keen/maps/png2map.c b/games/keen/maps/png2map.c index 37ff27ba..2ccd04a7 100644 --- a/games/keen/maps/png2map.c +++ b/games/keen/maps/png2map.c @@ -9,15 +9,14 @@ #include "loadpng.h" +/* converts a png of map to format for our keen engine */ -/* converts a png of map to format by our duke engine */ - -/* 1280x200 image */ +/* 660x336 image */ /* 256 sprites of size 2x4 in a 16x16 grid at 8,4 */ static unsigned char tiles[256][2][4]; -static unsigned char tilemap[256][40]; +static unsigned char tilemap[128][80]; static unsigned char temp_tile[2][4]; static int ascii_output=0; @@ -30,6 +29,7 @@ int main(int argc, char **argv) { unsigned char *image; int xsize,ysize; FILE *outfile; + int unknown_tiles=0; if (argc<3) { fprintf(stderr,"Usage:\t%s INFILE OUTFILE\n\n",argv[0]); @@ -112,8 +112,10 @@ int main(int argc, char **argv) { /* starts at 80,12 */ - for(x=0;x<256;x++) { - for(y=0;y<40;y++) { + /* 128 * 80 */ + + for(x=0;x<128;x++) { + for(y=0;y<80;y++) { /* get temp tile */ temp_tile[0][0]=image[((y*4+12)*xsize)+80+(x*4)]; temp_tile[1][0]=image[((y*4+12)*xsize)+80+(x*4)+2]; @@ -157,6 +159,7 @@ int main(int argc, char **argv) { if (found_tile==-1) { printf("Error! Unknown tile at %d,%d\n", 80+(x*4),12+(y*4)); + unknown_tiles++; } } } @@ -164,11 +167,11 @@ int main(int argc, char **argv) { if (ascii_output) { fprintf(outfile,"tilemap:\n"); - for(j=0;j<40;j++) { + for(j=0;j<80;j++) { fprintf(outfile,"\t.byte "); - for(i=0;i<256;i++) { + for(i=0;i<128;i++) { fprintf(outfile,"$%02x",tilemap[i][j]); - if (i!=255) fprintf(outfile,","); + if (i!=127) fprintf(outfile,","); } fprintf(outfile,"\n"); } @@ -176,13 +179,15 @@ int main(int argc, char **argv) { fprintf(outfile,"\n"); } else { - for(j=0;j<40;j++) { - for(i=0;i<256;i++) { + for(j=0;j<80;j++) { + for(i=0;i<128;i++) { fputc(tilemap[i][j],outfile); } } } fclose(outfile); + fprintf(stderr,"%d Unknown tiles\n",unknown_tiles); + return 0; }