mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-10-09 11:54:59 +00:00
gr-utils: fix the RLE code
was having edge-of-screen wrap issues
This commit is contained in:
parent
bd2598bc8a
commit
a3d5057560
@ -50,19 +50,18 @@ static unsigned char worldmap_rle[]=
|
|||||||
|
|
||||||
static unsigned char landing_rle[]=
|
static unsigned char landing_rle[]=
|
||||||
{ 0x28,0x28,
|
{ 0x28,0x28,
|
||||||
0x03,0x66,0x01,0x56,
|
0x03,0x66, 0x01,0x56,
|
||||||
0x27,0x66,0x01,0x55,0x01,0xF5,
|
0x27,0x66, 0x01,0x55, 0x01,0xF5,
|
||||||
0x26,0x66,0x01,0x55,0x01,0xFF,0x01,0xF5,
|
0x26,0x66, 0x01,0x55, 0x01,0xFF, 0x01,0xF5,
|
||||||
0x25,0x66,0x01,0x55,0x02,0xFF,0x01,0xF5,
|
0x25,0x66, 0x01,0x55, 0x02,0xFF, 0x01,0xF5,
|
||||||
0x24,0x66,0x01,0x55,0x03,0xFF,0x01,0xF5,0x20,0x66,
|
0x24,0x66, 0x01,0x55, 0x03,0xFF, 0x01,0xF5, 0x20,0x66,
|
||||||
0x01,0x46,0x01,0x24,0x01,0x44,0x01,0x55,0x0F,0xF5,0x04,0x22,
|
0x01,0x44, 0x01,0x24, 0x01,0x44, 0x01,0x55, 0x0F,0xF5, 0x04,0x22,
|
||||||
0x12,0x44,0x01,0x62,0x01,0x22,0x01,0x55,0x01,0xFF,0x03,0x11,0x01,0x44,0x03,0x22,0x01,0x44,0x03,0x22,0x03,0xFF,0x05,0x22,
|
0x12,0x44, 0x01,0x62, 0x01,0x22, 0x01,0x55, 0x01,0xFF, 0x03,0x11, 0x01,0x44, 0x03,0x22, 0x01,0x44, 0x03,0x22, 0x03,0xFF, 0x05,0x22,
|
||||||
0x11,0x44,0x01,0x22,0x01,0x26,0x01,0x55,0x02,0xFF,0x01,0x11,0x03,0x44,0x01,0x22,0x03,0x44,0x01,0x22,0x04,0xFF,0x06,0x22,
|
0x11,0x44, 0x01,0x22, 0x01,0x26, 0x01,0x55, 0x02,0xFF, 0x01,0x11, 0x03,0x44, 0x01,0x22, 0x03,0x44, 0x01,0x22, 0x04,0xFF, 0x06,0x22,
|
||||||
0x10,0x44,0x02,0x26,0x01,0x55,0x02,0xFF,0x01,0xF1,0x03,0xF4,0x01,0xF2,0x03,0xF4,0x01,0xF2,0x01,0xFF,0x02,0x8F,0x01,0xFF,0x07,0x22,
|
0x10,0x44, 0x02,0x26, 0x01,0x55, 0x02,0xFF, 0x01,0xF1, 0x03,0xF4, 0x01,0xF2, 0x03,0xF4, 0x01,0xF2, 0x01,0xFF, 0x02,0x8F, 0x01,0xFF, 0x07,0x22,
|
||||||
0x0F,0x44,0x01,0x62,0x01,0x26,0x01,0x55,0x0A,0x5F,0x02,0xFF,0x02,0x88,0x01,0xFF,0x08,0x22,
|
0x0F,0x44, 0x01,0x62, 0x01,0x26, 0x01,0x55, 0x0A,0x5F, 0x02,0xFF, 0x02,0x88, 0x01,0xFF, 0x08,0x22,
|
||||||
0x0E,0x44,0x01,0x22,0x01,0x42,0x01,0x55,0x09,0xFF,0x01,0x55,0x02,0xFF,0x02,0x88,0x0A,0xFF,
|
0x0E,0x44, 0x01,0x22, 0x01,0x42, 0x01,0x55, 0x09,0xFF, 0x01,0x55, 0x02,0xFF, 0x02,0x88, 0x0A,0xFF,
|
||||||
0x0F,0x44,0x03,0x45,0x01,0x85,0x09,0x45,0x02,0x85,0x04,0x45,0x01,0x85,0x05,0x45,
|
0x0F,0x44, 0x03,0x45, 0x01,0x85, 0x09,0x45, 0x02,0x85, 0x04,0x45, 0x01,0x85, 0x05,0x45,
|
||||||
0x11,0x44,0x01,0x48,0x09,0x44,0x04,0x85,0x04,0x44,0x01,0x48,
|
0x11,0x44, 0x01,0x48, 0x09,0x44, 0x04,0x85, 0x04,0x44, 0x01,0x48,
|
||||||
0x1E,0x44,0x06,0x85,
|
0x1E,0x44, 0x06,0x85,
|
||||||
0x104,0x44,
|
0xFE,0x44, 0x06,0x44, 0xFF,0xFF,};
|
||||||
0xff,0xff,};
|
|
||||||
|
@ -671,16 +671,22 @@ int grsim_unrle(unsigned char *rle_data, int address) {
|
|||||||
y=0;
|
y=0;
|
||||||
|
|
||||||
ram[BASL]=address&0xff;
|
ram[BASL]=address&0xff;
|
||||||
ram[BASH]=address>>8;
|
ram[BASH]=(address>>8)&0xff;
|
||||||
|
|
||||||
ram[CV]=0;
|
ram[CV]=0;
|
||||||
|
|
||||||
|
/* CH = xsize */
|
||||||
ram[CH]=rle_data[y_indirect(GBASL,y)];
|
ram[CH]=rle_data[y_indirect(GBASL,y)];
|
||||||
y++;
|
y++;
|
||||||
// ysize=rle_data[1];
|
|
||||||
|
/* Skip ysize */
|
||||||
y++;
|
y++;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
/* Get run length into a */
|
||||||
a=rle_data[y_indirect(GBASL,y)];
|
a=rle_data[y_indirect(GBASL,y)];
|
||||||
|
|
||||||
|
/* 0xff is a special value meaning end */
|
||||||
if (a==0xff) break;
|
if (a==0xff) break;
|
||||||
ram[TEMP]=a;
|
ram[TEMP]=a;
|
||||||
|
|
||||||
|
22
gr-sim/tfv.c
22
gr-sim/tfv.c
@ -462,6 +462,8 @@ static void print_byte(unsigned char value) {
|
|||||||
basic_print(temp);
|
basic_print(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enemies: */
|
||||||
|
/* Killer Crab, Big Fish, Procrastinon */
|
||||||
|
|
||||||
static int do_battle(void) {
|
static int do_battle(void) {
|
||||||
|
|
||||||
@ -542,6 +544,23 @@ static int do_battle(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* In Town */
|
||||||
|
|
||||||
|
|
||||||
|
/* Puzzle Room */
|
||||||
|
/* Get through office */
|
||||||
|
/* Have to run away? What happens if die? No save game? Code? */
|
||||||
|
|
||||||
|
/* Construct the LED circuit */
|
||||||
|
/* Zaps through cloud */
|
||||||
|
/* Susie joins your party */
|
||||||
|
|
||||||
|
/* Final Battle */
|
||||||
|
/* Play music, lightning effects? */
|
||||||
|
/* TFV only hit for one damage, susie for 100 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Map
|
Map
|
||||||
@ -558,9 +577,6 @@ static int do_battle(void) {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int world_map(void) {
|
static int world_map(void) {
|
||||||
|
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -9,6 +9,36 @@
|
|||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
|
||||||
|
|
||||||
|
static int convert_color(int color) {
|
||||||
|
|
||||||
|
int c=0;
|
||||||
|
|
||||||
|
switch(color) {
|
||||||
|
case 0x000000: c=0; break; /* black */
|
||||||
|
case 0xe31e60: c=1; break; /* magenta */
|
||||||
|
case 0x604ebd: c=2; break; /* dark blue */
|
||||||
|
case 0xff44fd: c=3; break; /* purple */
|
||||||
|
case 0x00a360: c=4; break; /* dark green */
|
||||||
|
case 0x9c9c9c: c=5; break; /* grey 1 */
|
||||||
|
case 0x14cffd: c=6; break; /* medium blue */
|
||||||
|
case 0xd0c3ff: c=7; break; /* light blue */
|
||||||
|
case 0x607203: c=8; break; /* brown */
|
||||||
|
case 0xff6a3c: c=9; break; /* orange */
|
||||||
|
case 0x9d9d9d: c=10; break; /* grey 2 */
|
||||||
|
case 0xffa0d0: c=11; break; /* pink */
|
||||||
|
case 0x14f53c: c=12; break; /* bright green */
|
||||||
|
case 0xd0dd8d: c=13; break; /* yellow */
|
||||||
|
case 0x72ffd0: c=14; break; /* aqua */
|
||||||
|
case 0xffffff: c=15; break; /* white */
|
||||||
|
default:
|
||||||
|
printf("Unknown color %x\n",color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
/* expects a PNG where the xsize is *2 */
|
/* expects a PNG where the xsize is *2 */
|
||||||
int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) {
|
int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) {
|
||||||
|
|
||||||
@ -16,8 +46,9 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) {
|
|||||||
int color;
|
int color;
|
||||||
FILE *infile;
|
FILE *infile;
|
||||||
int debug=0;
|
int debug=0;
|
||||||
unsigned char *image;
|
unsigned char *image,*out_ptr;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
int a2_color;
|
||||||
|
|
||||||
png_byte bit_depth;
|
png_byte bit_depth;
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
@ -84,63 +115,38 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) {
|
|||||||
|
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
|
||||||
image=calloc(width*height,sizeof(unsigned char));
|
image=calloc(width*height/2,sizeof(unsigned char));
|
||||||
if (image==NULL) {
|
if (image==NULL) {
|
||||||
fprintf(stderr,"Memory error!\n");
|
fprintf(stderr,"Memory error!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
out_ptr=image;
|
||||||
|
|
||||||
for(y=0;y<height;y++) {
|
for(y=0;y<height;y+=2) {
|
||||||
for(x=0;x<width/2;x++) {
|
for(x=0;x<width/2;x++) {
|
||||||
|
|
||||||
|
/* top color */
|
||||||
color= (row_pointers[y][x*2*4]<<16)+
|
color= (row_pointers[y][x*2*4]<<16)+
|
||||||
(row_pointers[y][x*2*4+1]<<8)+
|
(row_pointers[y][x*2*4+1]<<8)+
|
||||||
(row_pointers[y][x*2*4+2]);
|
(row_pointers[y][x*2*4+2]);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("%x ",color);
|
printf("%x ",color);
|
||||||
// printf("(%x,%x,%x,%x) ",
|
|
||||||
// row_pointers[y][x*2*4],
|
|
||||||
// row_pointers[y][x*2*4+1],
|
|
||||||
// row_pointers[y][x*2*4+2],
|
|
||||||
// row_pointers[y][x*2*4+3]);
|
|
||||||
}
|
}
|
||||||
switch(color) {
|
|
||||||
case 0: image[(y*width/2)+x]=0; /* black */
|
|
||||||
break;
|
|
||||||
case 0xe31e60: image[(y*width/2)+x]=1; /* magenta */
|
|
||||||
break;
|
|
||||||
case 0x604ebd: image[(y*width/2)+x]=2; /* dark blue */
|
|
||||||
break;
|
|
||||||
case 0xff44fd: image[(y*width/2)+x]=3; /* purple */
|
|
||||||
break;
|
|
||||||
case 0xa360: image[(y*width/2)+x]=4; /* dark green */
|
|
||||||
break;
|
|
||||||
case 0x9c9c9c: image[(y*width/2)+x]=5; /* grey 1 */
|
|
||||||
break;
|
|
||||||
case 0x14cffd: image[(y*width/2)+x]=6; /* medium blue */
|
|
||||||
break;
|
|
||||||
case 0xd0c3ff: image[(y*width/2)+x]=7; /* light blue */
|
|
||||||
break;
|
|
||||||
case 0x607203: image[(y*width/2)+x]=8; /* brown */
|
|
||||||
break;
|
|
||||||
case 0xff6a3c: image[(y*width/2)+x]=9; /* orange */
|
|
||||||
break;
|
|
||||||
case 0x9d9d9d: image[(y*width/2)+x]=10; /* grey 2 */
|
|
||||||
break;
|
|
||||||
case 0xffa0d0: image[(y*width/2)+x]=11; /* pink */
|
|
||||||
break;
|
|
||||||
case 0x14f53c: image[(y*width/2)+x]=12; /* bright green */
|
|
||||||
break;
|
|
||||||
case 0xd0dd8d: image[(y*width/2)+x]=13; /* yellow */
|
|
||||||
break;
|
|
||||||
case 0x72ffd0: image[(y*width/2)+x]=14; /* aqua */
|
|
||||||
break;
|
|
||||||
case 0xffffff: image[(y*width/2)+x]=15; /* white */
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
a2_color=convert_color(color);
|
||||||
printf("Unknown color %x\n",color);
|
|
||||||
image[(y*width/2)+x]=0; break;
|
/* bottom color */
|
||||||
|
color= (row_pointers[y+1][x*2*4]<<16)+
|
||||||
|
(row_pointers[y+1][x*2*4+1]<<8)+
|
||||||
|
(row_pointers[y+1][x*2*4+2]);
|
||||||
|
if (debug) {
|
||||||
|
printf("%x ",color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a2_color|=(convert_color(color)<<4);
|
||||||
|
|
||||||
|
*out_ptr=a2_color;
|
||||||
|
out_ptr++;
|
||||||
}
|
}
|
||||||
if (debug) printf("\n");
|
if (debug) printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,34 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
x=0;
|
x=0;
|
||||||
enough=0;
|
enough=0;
|
||||||
fprintf(outfile,"{ 0x%X,0x%x,\n",xsize,ysize);
|
|
||||||
|
/* Write out xsize and ysize */
|
||||||
|
|
||||||
|
fprintf(outfile,"{ 0x%X,0x%X,\n",xsize,ysize);
|
||||||
size+=2;
|
size+=2;
|
||||||
|
|
||||||
last=image[x] | (image[x+xsize]<<4);
|
/* Get first top/bottom color pair */
|
||||||
|
last=image[x];
|
||||||
run++;
|
run++;
|
||||||
x++;
|
x++;
|
||||||
while(1) {
|
|
||||||
next=image[x] | (image[x+xsize]<<4);
|
|
||||||
|
|
||||||
if (next!=last) {
|
while(1) {
|
||||||
fprintf(outfile,"0x%02X,0x%02X,",run,last);
|
|
||||||
|
/* get next top/bottom color pair */
|
||||||
|
next=image[x];
|
||||||
|
|
||||||
|
// printf("x=%d, next=%x image[%d]=%x\n",
|
||||||
|
// x,next,
|
||||||
|
// x,image[x]);
|
||||||
|
|
||||||
|
|
||||||
|
/* If color change (or too big) then output our run */
|
||||||
|
/* Note 0xff for run length is special case meaning "finished" */
|
||||||
|
if ((next!=last) || (run>253)) {
|
||||||
|
fprintf(outfile,"0x%02X,0x%02X, ",run,last);
|
||||||
|
|
||||||
|
// printf("%x,%x\n",run,last);
|
||||||
|
|
||||||
size+=2;
|
size+=2;
|
||||||
run=0;
|
run=0;
|
||||||
last=next;
|
last=next;
|
||||||
@ -59,19 +76,19 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
|
/* Split up per-line */
|
||||||
enough++;
|
enough++;
|
||||||
if (enough>=xsize) {
|
if (enough>=xsize) {
|
||||||
enough=0;
|
enough=0;
|
||||||
x+=xsize;
|
|
||||||
fprintf(outfile,"\n");
|
fprintf(outfile,"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we reach the end */
|
||||||
if (x>=xsize*ysize) {
|
if (x>=xsize*(ysize/2)) {
|
||||||
|
run++;
|
||||||
/* print tailing value */
|
/* print tailing value */
|
||||||
if (run!=0) {
|
if (run!=0) {
|
||||||
fprintf(outfile,"0x%02X,0x%02X,",run,last);
|
fprintf(outfile,"0x%02X,0x%02X, ",run,last);
|
||||||
size+=2;
|
size+=2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -81,7 +98,10 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
fprintf(outfile,"0xff,0xff,");
|
|
||||||
|
/* Print closing marker */
|
||||||
|
|
||||||
|
fprintf(outfile,"0xFF,0xFF,");
|
||||||
size+=2;
|
size+=2;
|
||||||
fprintf(outfile,"};\n");
|
fprintf(outfile,"};\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user