mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-05-31 21:41:32 +00:00
keen: update map to be more rectangular
also work on actual mars map
This commit is contained in:
parent
1a5d7a09f0
commit
1b549d860c
|
@ -5,7 +5,7 @@ ZX02 = ~/research/6502_compression/zx02.git/build/zx02 -f
|
||||||
PNG2GR = ../../../utils/gr-utils/png2gr
|
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
|
./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
|
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 |
|
@ -1,7 +1,4 @@
|
||||||
/* Loads a 80x48 (or 40x48) PNG image into a 40x48 Apple II layout */
|
/* loads png for png2map */
|
||||||
/* It's not interleaved like an actual Apple II */
|
|
||||||
/* But the top/bottom are pre-packed into a naive 40x24 array */
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -46,7 +43,7 @@ static int convert_color(int color, char *filename) {
|
||||||
return c;
|
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 loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize,
|
||||||
int png_type) {
|
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);
|
width = png_get_image_width(png_ptr, info_ptr);
|
||||||
height = png_get_image_height(png_ptr, info_ptr);
|
height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
|
||||||
if (width==1280) {
|
if (width==660) {
|
||||||
*xsize=1280;
|
*xsize=660;
|
||||||
xadd=1;
|
xadd=1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
BIN
games/keen/maps/mars_new.png
Normal file
BIN
games/keen/maps/mars_new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -9,15 +9,14 @@
|
||||||
|
|
||||||
#include "loadpng.h"
|
#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 */
|
/* 660x336 image */
|
||||||
|
|
||||||
/* 1280x200 image */
|
|
||||||
/* 256 sprites of size 2x4 in a 16x16 grid at 8,4 */
|
/* 256 sprites of size 2x4 in a 16x16 grid at 8,4 */
|
||||||
|
|
||||||
|
|
||||||
static unsigned char tiles[256][2][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 unsigned char temp_tile[2][4];
|
||||||
|
|
||||||
static int ascii_output=0;
|
static int ascii_output=0;
|
||||||
|
@ -30,6 +29,7 @@ int main(int argc, char **argv) {
|
||||||
unsigned char *image;
|
unsigned char *image;
|
||||||
int xsize,ysize;
|
int xsize,ysize;
|
||||||
FILE *outfile;
|
FILE *outfile;
|
||||||
|
int unknown_tiles=0;
|
||||||
|
|
||||||
if (argc<3) {
|
if (argc<3) {
|
||||||
fprintf(stderr,"Usage:\t%s INFILE OUTFILE\n\n",argv[0]);
|
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 */
|
/* starts at 80,12 */
|
||||||
|
|
||||||
for(x=0;x<256;x++) {
|
/* 128 * 80 */
|
||||||
for(y=0;y<40;y++) {
|
|
||||||
|
for(x=0;x<128;x++) {
|
||||||
|
for(y=0;y<80;y++) {
|
||||||
/* get temp tile */
|
/* get temp tile */
|
||||||
temp_tile[0][0]=image[((y*4+12)*xsize)+80+(x*4)];
|
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];
|
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) {
|
if (found_tile==-1) {
|
||||||
printf("Error! Unknown tile at %d,%d\n",
|
printf("Error! Unknown tile at %d,%d\n",
|
||||||
80+(x*4),12+(y*4));
|
80+(x*4),12+(y*4));
|
||||||
|
unknown_tiles++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,11 +167,11 @@ int main(int argc, char **argv) {
|
||||||
if (ascii_output) {
|
if (ascii_output) {
|
||||||
fprintf(outfile,"tilemap:\n");
|
fprintf(outfile,"tilemap:\n");
|
||||||
|
|
||||||
for(j=0;j<40;j++) {
|
for(j=0;j<80;j++) {
|
||||||
fprintf(outfile,"\t.byte ");
|
fprintf(outfile,"\t.byte ");
|
||||||
for(i=0;i<256;i++) {
|
for(i=0;i<128;i++) {
|
||||||
fprintf(outfile,"$%02x",tilemap[i][j]);
|
fprintf(outfile,"$%02x",tilemap[i][j]);
|
||||||
if (i!=255) fprintf(outfile,",");
|
if (i!=127) fprintf(outfile,",");
|
||||||
}
|
}
|
||||||
fprintf(outfile,"\n");
|
fprintf(outfile,"\n");
|
||||||
}
|
}
|
||||||
|
@ -176,13 +179,15 @@ int main(int argc, char **argv) {
|
||||||
fprintf(outfile,"\n");
|
fprintf(outfile,"\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(j=0;j<40;j++) {
|
for(j=0;j<80;j++) {
|
||||||
for(i=0;i<256;i++) {
|
for(i=0;i<128;i++) {
|
||||||
fputc(tilemap[i][j],outfile);
|
fputc(tilemap[i][j],outfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(outfile);
|
fclose(outfile);
|
||||||
|
|
||||||
|
fprintf(stderr,"%d Unknown tiles\n",unknown_tiles);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user