png2gr: fix to work again

hopefully I didn't break anything that depended on the old behavior
This commit is contained in:
Vince Weaver 2018-09-27 20:43:47 -04:00
parent b9e04f6605
commit cdcd274923
2 changed files with 17 additions and 26 deletions

View File

@ -1,3 +1,8 @@
/* Loads a 80x48 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 */
#include <stdio.h>
#include <stdlib.h>

View File

@ -19,6 +19,7 @@ int main(int argc, char **argv) {
int col=0;
int enough=0;
int x;
unsigned char out_buffer[1024];
unsigned char *image;
int xsize,ysize;
@ -42,36 +43,21 @@ int main(int argc, char **argv) {
printf("Loaded image %d by %d\n",xsize,ysize);
x=0;
while(1) {
fputc( image[col+(row*xsize)] |
(image[col+(row+1)*xsize]<<4),outfile);
x++;
if (x>0x3f8) break;
enough++;
if (enough>119) {
/* screen hole */
/* We should never BLOAD this image */
/* as we can corrupt important state here */
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);
enough=0;
}
short gr_offsets[]={
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,
0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0,
};
col++;
if (col>39) {
col=0;
row+=16;
if (row>47) row-=46;
memset(out_buffer,0,1024);
for(row=0;row<24;row++) {
for(col=0;col<40;col++) {
out_buffer[(gr_offsets[row]-0x400)+col]=image[row*xsize+col];
}
}
for(x=0;x<1024;x++) fputc( out_buffer[x],outfile);
fclose(outfile);
return 0;