keen: update map to be more rectangular

also work on actual mars map
This commit is contained in:
Vince Weaver 2024-04-10 01:44:01 -04:00
parent 1a5d7a09f0
commit 1b549d860c
5 changed files with 30 additions and 19 deletions

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -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 <stdio.h>
#include <stdlib.h>
@ -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 {

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

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