From 63ea676e0e6140d6ad69c5e7357ae343894f2ed1 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 24 Aug 2018 15:52:20 -0400 Subject: [PATCH] png2hgr: fill all the bits now --- hgr-utils/png2hgr.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/hgr-utils/png2hgr.c b/hgr-utils/png2hgr.c index 5cc581a6..d4ab431d 100644 --- a/hgr-utils/png2hgr.c +++ b/hgr-utils/png2hgr.c @@ -258,14 +258,24 @@ static int hgr_offset(int y) { return address; } +void colors_to_bytes(unsigned char colors[7], + unsigned char *byte1, + unsigned char *byte2) { + + *byte1=0xff; + *byte2=0x55; + +} + + static unsigned char apple2_image[8192]; int main(int argc, char **argv) { int xsize=0,ysize=0; - int c,x,y; + int c,x,y,z,color1,color2; unsigned char *image; - unsigned char byte1,byte2; + unsigned char byte1,byte2,colors[7]; char *filename; @@ -305,8 +315,20 @@ int main(int argc, char **argv) { for(y=0;y<192;y++) { for(x=0;x<20;x++) { - byte1=0xff; - apple2_image[hgr_offset(y)]=byte1; + for(z=0;z<7;z++) { + color1=image[y*280+x*14+z*2]; + color2=image[y*280+x*14+z*2+1]; + if (color1!=color2) { + fprintf(stderr,"Error, color at %d x %d doesn't match\n", + x*14+z*2,y); + + } + colors[z]=color1; + } + colors_to_bytes(colors,&byte1,&byte2); + + apple2_image[hgr_offset(y)+(x*2)+0]=byte1; + apple2_image[hgr_offset(y)+(x*2)+1]=byte2; } }