display logo gfx, misc gfx related helpers
This commit is contained in:
32
utils/bin2asm.c
Normal file
32
utils/bin2asm.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
size_t count;
|
||||
|
||||
if(argc<1) {
|
||||
fprintf(stderr, "Usage: %s <infile> \n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
FILE* in;
|
||||
if((in=fopen(argv[1], "rb"))==NULL) {
|
||||
perror("could not open input file");
|
||||
return 1;
|
||||
}
|
||||
printf("chgme ");
|
||||
count=0;
|
||||
while(1) {
|
||||
uint8_t c = fgetc(in);
|
||||
if(feof(in)) break;
|
||||
if(!(count%8)) {
|
||||
if(count) printf("\n ");
|
||||
printf(".byt $%02x", c);
|
||||
} else {
|
||||
printf(", $%02x", c);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
fclose(in);
|
||||
return 0;
|
||||
|
||||
}
|
||||
78
utils/chili2chr.c
Normal file
78
utils/chili2chr.c
Normal file
@@ -0,0 +1,78 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if(argc<2) {
|
||||
printf("Usage: %s <input> <output>\nCurrently only 4-to-2-bit supported\n", argv[0]);
|
||||
}
|
||||
FILE *in, *out;
|
||||
size_t in_off = 0, out_off = 0;
|
||||
uint8_t pixperbyte, mask_shift, mask, depth, planeidx;
|
||||
uint8_t current_pixel, current_in_tile;
|
||||
int i,j;
|
||||
if((in=fopen(argv[1], "rb"))==NULL) {
|
||||
perror("Could not open input file");
|
||||
return 1;
|
||||
}
|
||||
if((out=fopen(argv[2], "wb"))==NULL) {
|
||||
perror("Could not open output file");
|
||||
return 1;
|
||||
}
|
||||
size_t fsize, dsize;
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
fsize = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
// pixperbyte = 2;
|
||||
// mask_shift = 4;
|
||||
// mask = 0x03;
|
||||
// depth = 2;
|
||||
// 4->2
|
||||
|
||||
pixperbyte = 1;
|
||||
mask_shift = 0;
|
||||
mask = 0xff;
|
||||
depth = 8;
|
||||
// 8->8
|
||||
|
||||
dsize = fsize / pixperbyte;
|
||||
uint16_t *obuf;
|
||||
|
||||
if((obuf=malloc(dsize))==NULL) {
|
||||
perror("Could not reserve memory");
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
return 1;
|
||||
}
|
||||
memset(obuf, 0, dsize);
|
||||
while (!feof(in)) {
|
||||
uint8_t chunk = fgetc(in);
|
||||
printf("%lX\n", out_off);
|
||||
for(i=0; i<pixperbyte; i++) {
|
||||
|
||||
current_pixel = (in_off*pixperbyte+i)%8;
|
||||
current_in_tile = (in_off*pixperbyte+i)%64;
|
||||
if(!current_pixel && in_off) { // after 8 pixels:
|
||||
out_off++;
|
||||
}
|
||||
if(!current_in_tile && in_off) { // after 64 pixels:
|
||||
out_off += (depth/2-1) * 8;
|
||||
}
|
||||
uint8_t bits = (chunk&mask);
|
||||
chunk >>= mask_shift;
|
||||
for(planeidx=0; planeidx < depth/2; planeidx++) {
|
||||
for(j=0; j<2; j++) {
|
||||
obuf[out_off+planeidx*8] |= ((bits & (1<<(j+2*planeidx))) >> (j+2*planeidx) << ((8*j+7)-current_pixel));
|
||||
}
|
||||
}
|
||||
}
|
||||
in_off++;
|
||||
}
|
||||
free(obuf);
|
||||
fwrite(obuf, dsize, 1, out);
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
}
|
||||
23
utils/gentilemap.c
Normal file
23
utils/gentilemap.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(void) {
|
||||
uint16_t tile=64;
|
||||
uint16_t pad=0xa+64;
|
||||
int i,j;
|
||||
FILE *out;
|
||||
if((out=fopen("tilemap", "wb"))==NULL) {
|
||||
perror("Could not open output file 'tilemap'");
|
||||
return 1;
|
||||
}
|
||||
for(i=0; i<12; i++) {
|
||||
for(j=0; j<25; j++) {
|
||||
fwrite(&tile, 2, 1, out);
|
||||
tile++;
|
||||
}
|
||||
for(j=25; j<32; j++) {
|
||||
fwrite(&pad, 2, 1, out);
|
||||
}
|
||||
}
|
||||
fclose(out);
|
||||
}
|
||||
29
utils/palremap.c
Normal file
29
utils/palremap.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if(argc<3) {
|
||||
fprintf(stderr, "Usage: %s <infile> <outfile>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
FILE *in, *out;
|
||||
if((in=fopen(argv[1], "rb"))==NULL) {
|
||||
perror("Could not open input file");
|
||||
return 1;
|
||||
}
|
||||
if((out=fopen(argv[2], "wb"))==NULL) {
|
||||
perror("Could not open output file");
|
||||
return 1;
|
||||
}
|
||||
while(1) {
|
||||
uint8_t c=fgetc(in);
|
||||
if(feof(in))break;
|
||||
if(c>=1 && c<=43) {
|
||||
c+=212;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user