From d7882d311b686312a2b6788e10dfc12b49e3ac10 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 17 Jan 2013 21:46:29 -0500 Subject: [PATCH] snes: make pcx_to_tiles_8bpp take argument Now it takes a parameter for the label names --- tb_snes/Makefile | 7 ++- tb_snes/title_screen.s | 4 +- tb_snes/tools/pcx_to_tiles_8bpp.c | 78 ++++++++++++++++--------------- 3 files changed, 48 insertions(+), 41 deletions(-) diff --git a/tb_snes/Makefile b/tb_snes/Makefile index 411221b..78091e7 100644 --- a/tb_snes/Makefile +++ b/tb_snes/Makefile @@ -9,11 +9,14 @@ tb1_snes.sfc: tb1_snes.o snes-hirom.cfg $(LD) -o tb1_snes.sfc --config snes-hirom.cfg --obj tb1_snes.o tb1_snes.o: tb1_snes.s snes_init.s title_screen.s \ - tb1_title.tiles + tb1_title.tiles tb1_opening.tiles $(AS) -t none -o tb1_snes.o -l tb1_snes.lst -c tb1_snes.s +tb1_opening.tiles: graphics/vmw_logo.pcx ./tools/pcx_to_tiles_8bpp + ./tools/pcx_to_tiles_8bpp vmw_logo < graphics/vmw_logo.pcx > tb1_opening.tiles + tb1_title.tiles: graphics/tb1_title.pcx ./tools/pcx_to_tiles_8bpp - ./tools/pcx_to_tiles_8bpp < graphics/tb1_title.pcx > tb1_title.tiles + ./tools/pcx_to_tiles_8bpp title_screen < graphics/tb1_title.pcx > tb1_title.tiles checksum.inc: ./tools/snes_checksum tb1_snes.sfc ./tools/snes_checksum < tb1_snes.sfc > checksum.inc diff --git a/tb_snes/title_screen.s b/tb_snes/title_screen.s index 53a6b4a..1bd11ab 100644 --- a/tb_snes/title_screen.s +++ b/tb_snes/title_screen.s @@ -54,7 +54,7 @@ display_title: ldx #$0000 ; pointer copypal: - lda f:tile_palette, x ; load byte of palette + lda f:title_screen_palette, x ; load byte of palette sta $2122 ; store to color generator inx dey @@ -82,7 +82,7 @@ copypal: ldx #$0000 copy_tile_data: - lda f:tile_data, x + lda f:title_screen_tile_data, x sta $2118 ; write the data inx ; increment by 2 (16-bits) inx diff --git a/tb_snes/tools/pcx_to_tiles_8bpp.c b/tb_snes/tools/pcx_to_tiles_8bpp.c index 77c1130..fb12a6b 100644 --- a/tb_snes/tools/pcx_to_tiles_8bpp.c +++ b/tb_snes/tools/pcx_to_tiles_8bpp.c @@ -8,22 +8,23 @@ #include /* exit() */ /* Convert to 15-bpp bgr */ -int rgb2bgr(int r,int g, int b) { +static int rgb2bgr(int r,int g, int b) { int r2,g2,b2,bgr; r2=(r>>3)&0x1f; g2=(g>>3)&0x1f; b2=(b>>3)&0x1f; - + bgr=(b2<<10)|(g2<<5)|r2; - + return bgr; } +static char symbol_name[BUFSIZ]="temp"; /* File already open */ -int vmwLoadPCX(int pcx_fd) { - +static int vmwLoadPCX(int pcx_fd) { + int debug=1,bpp; int x,y; int i,numacross,planes=0; @@ -31,26 +32,26 @@ int vmwLoadPCX(int pcx_fd) { int xmin,ymin,xmax,ymax,version; unsigned char pcx_header[128]; unsigned char temp_byte; - + /*************** DECODE THE HEADER *************************/ - + read(pcx_fd,&pcx_header,128); - + xmin=(pcx_header[5]<<8)+pcx_header[4]; ymin=(pcx_header[7]<<8)+pcx_header[6]; - + xmax=(pcx_header[9]<<8)+pcx_header[8]; ymax=(pcx_header[11]<<8)+pcx_header[10]; version=pcx_header[1]; bpp=pcx_header[3]; - + if (debug) { - + fprintf(stderr,"Manufacturer: "); if (pcx_header[0]==10) fprintf(stderr,"Zsoft\n"); else fprintf(stderr,"Unknown %i\n",pcx_header[0]); - + fprintf(stderr,"Version: "); switch(version) { @@ -64,19 +65,19 @@ int vmwLoadPCX(int pcx_fd) { fprintf(stderr,"Encoding: "); if (pcx_header[2]==1) fprintf(stderr,"RLE\n"); else fprintf(stderr,"Unknown %i\n",pcx_header[2]); - + fprintf(stderr,"BitsPerPixelPerPlane: %i\n",bpp); fprintf(stderr,"File goes from %i,%i to %i,%i\n",xmin,ymin,xmax,ymax); - + fprintf(stderr,"Horizontal DPI: %i\n",(pcx_header[13]<<8)+pcx_header[12]); fprintf(stderr,"Vertical DPI: %i\n",(pcx_header[15]<<8)+pcx_header[14]); - + fprintf(stderr,"Number of colored planes: %i\n",pcx_header[65]); fprintf(stderr,"Bytes per line: %i\n",(pcx_header[67]<<8)+pcx_header[66]); fprintf(stderr,"Palette Type: %i\n",(pcx_header[69]<<8)+pcx_header[68]); fprintf(stderr,"Hscreen Size: %i\n",(pcx_header[71]<<8)+pcx_header[70]); fprintf(stderr,"Vscreen Size: %i\n",(pcx_header[73]<<8)+pcx_header[72]); - + } planes=pcx_header[65]; @@ -84,15 +85,15 @@ int vmwLoadPCX(int pcx_fd) { ysize=((ymax-ymin)+1); char *output; - + output=calloc((xsize*ysize),sizeof(unsigned int)); if (output==NULL) return -1; x=0; y=0; - while(y>1); } printf("\t.word $%02x%02x\n",plane1,plane0); } - + printf("\t; Plane 2 Plane 3\n"); for(y=0;y>4); plane5|=(((output[offset])&32)>>5); } printf("\t.word $%02x%02x\n",plane5,plane4); } - + printf("\t; Plane 6 Plane 7\n"); for(y=0;y1) { + strncpy(symbol_name,argv[1],BUFSIZ); + } + /* read from stdin */ result=vmwLoadPCX(fileno(stdin)); - + if (result<0) { fprintf(stderr,"Error reading PCX from stdin\n"); exit(1); } - + return 0; }