mirror of
https://github.com/deater/tb1.git
synced 2025-01-04 20:31:37 +00:00
snes: pcx_to_tiles_4bpp
clean up code, add command line argument for label name
This commit is contained in:
parent
2687dfe6a2
commit
8e77643bb4
@ -7,8 +7,10 @@
|
|||||||
#include <sys/stat.h> /* for file modes */
|
#include <sys/stat.h> /* for file modes */
|
||||||
#include <stdlib.h> /* exit() */
|
#include <stdlib.h> /* exit() */
|
||||||
|
|
||||||
|
char label_prefix[BUFSIZ]="tile";
|
||||||
|
|
||||||
/* Convert to 15-bpp bgr */
|
/* 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;
|
int r2,g2,b2,bgr;
|
||||||
|
|
||||||
r2=(r>>3)&0x1f;
|
r2=(r>>3)&0x1f;
|
||||||
@ -21,7 +23,7 @@ int rgb2bgr(int r,int g, int b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int vmwLoadPCX(int pcx_fd) {
|
static int vmwLoadPCX(int pcx_fd) {
|
||||||
|
|
||||||
int debug=1,bpp;
|
int debug=1,bpp;
|
||||||
int x,y;
|
int x,y;
|
||||||
@ -31,14 +33,6 @@ int vmwLoadPCX(int pcx_fd) {
|
|||||||
unsigned char pcx_header[128];
|
unsigned char pcx_header[128];
|
||||||
unsigned char temp_byte;
|
unsigned char temp_byte;
|
||||||
|
|
||||||
/* Open the file */
|
|
||||||
// pcx_fd=open(filename,O_RDONLY);
|
|
||||||
|
|
||||||
//if (pcx_fd<0) {
|
|
||||||
// printf("ERROR! File \"%s\" not found!\n",filename);
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*************** DECODE THE HEADER *************************/
|
/*************** DECODE THE HEADER *************************/
|
||||||
|
|
||||||
// lseek(pcx_fd,0,SEEK_SET);
|
// lseek(pcx_fd,0,SEEK_SET);
|
||||||
@ -136,7 +130,7 @@ int vmwLoadPCX(int pcx_fd) {
|
|||||||
|
|
||||||
unsigned int plane0,plane1,plane2,plane3,offset;
|
unsigned int plane0,plane1,plane2,plane3,offset;
|
||||||
|
|
||||||
printf("tile_data:\n");
|
printf("%s_data:\n",label_prefix);
|
||||||
int ychunk,xchunk;
|
int ychunk,xchunk;
|
||||||
for(ychunk=0;ychunk<ysize/Y_CHUNKSIZE;ychunk++) {
|
for(ychunk=0;ychunk<ysize/Y_CHUNKSIZE;ychunk++) {
|
||||||
for(xchunk=0;xchunk<xsize/X_CHUNKSIZE;xchunk++) {
|
for(xchunk=0;xchunk<xsize/X_CHUNKSIZE;xchunk++) {
|
||||||
@ -171,13 +165,7 @@ int vmwLoadPCX(int pcx_fd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%s_palette:\n",label_prefix);
|
||||||
|
|
||||||
// for(i=0;i<1008;i++) {
|
|
||||||
// printf("\t.word $ffff\n");
|
|
||||||
// }
|
|
||||||
|
|
||||||
printf("tile_palette:\n");
|
|
||||||
|
|
||||||
/* read in palette */
|
/* read in palette */
|
||||||
read(pcx_fd,&temp_byte,1);
|
read(pcx_fd,&temp_byte,1);
|
||||||
@ -205,24 +193,15 @@ int vmwLoadPCX(int pcx_fd) {
|
|||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
int result;//,x,y;
|
int result;
|
||||||
// FILE *fff;
|
|
||||||
|
|
||||||
//char filename[]="butterfinger.pcx";
|
|
||||||
|
|
||||||
/* read from stdin */
|
/* read from stdin */
|
||||||
|
|
||||||
result=vmwLoadPCX(fileno(stdin));
|
result=vmwLoadPCX(fileno(stdin));
|
||||||
|
|
||||||
if (result<0) {
|
if (result<0) {
|
||||||
fprintf(stderr,"Error reading PCX from stdin\n");
|
fprintf(stderr,"Error reading PCX from stdin\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fff=fopen("input.bin","w");
|
|
||||||
//if (fff==NULL) exit(1);
|
|
||||||
|
|
||||||
// fwrite(buffer,sizeof(unsigned int),buffer[0]*buffer[1]+2,stdout);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user