From 87c45ef8c82a3925719cbf2024e5932208b244ce Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Thu, 26 Jul 2018 03:03:25 +0300 Subject: [PATCH] convert external image for test tile and blit hardcoded grid --- .gitignore | 2 ++ Makefile.amiga | 3 +- src/data.h | 7 ++++ src/data.s | 9 ++++++ src/game.c | 93 ++++++++++++++++------------------------------------- tools/conv_gimp | 13 ++++++++ tools/conv_gimp.c | 71 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 132 insertions(+), 66 deletions(-) create mode 100644 src/data.h create mode 100644 src/data.s create mode 100755 tools/conv_gimp create mode 100644 tools/conv_gimp.c diff --git a/.gitignore b/.gitignore index 52d0701..825ef7d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ *.bin *.elf link.map +*.img +*.pal diff --git a/Makefile.amiga b/Makefile.amiga index 89a02c3..c6fbfbd 100644 --- a/Makefile.amiga +++ b/Makefile.amiga @@ -1,6 +1,7 @@ src = $(wildcard src/*.c) \ $(wildcard src/amiga/*.c) -asrc = $(wildcard src/amiga/*.s) \ +asrc = $(wildcard src/*.s) \ + $(wildcard src/amiga/*.s) \ $(wildcard src/amiga/libc/*.s) obj = $(src:.c=.o) $(asrc:.s=.o) dep = $(src:.c=.d) diff --git a/src/data.h b/src/data.h new file mode 100644 index 0000000..7cb952a --- /dev/null +++ b/src/data.h @@ -0,0 +1,7 @@ +#ifndef DATA_H_ +#define DATA_H_ + +extern unsigned char test_tile[]; +extern unsigned char test_tile_mask[]; + +#endif /* DATA_H_ */ diff --git a/src/data.s b/src/data.s new file mode 100644 index 0000000..5a6f27a --- /dev/null +++ b/src/data.s @@ -0,0 +1,9 @@ + .data + + .global test_tile +test_tile: + .incbin "data/test_tile.img" + + .global test_tile_mask +test_tile_mask: + .incbin "data/test_tile_mask.img" diff --git a/src/game.c b/src/game.c index a4dc4c7..97c1895 100644 --- a/src/game.c +++ b/src/game.c @@ -1,40 +1,54 @@ #include #include "game.h" -#include "data_test.h" #include "gfx.h" +#include "data.h" #include "hwregs.h" /* XXX */ -#define TILE_W 32 -#define TILE_H 16 +#define TILE_W 64 +#define TILE_H 32 void draw_tile(int tid, int x, int y, int light); -void convert_tile_data(unsigned char *dest, const char *src); -static unsigned char test_tiles[2][TILE_W * TILE_H / 8 * NBPL]; -static unsigned char tile_mask[TILE_W * TILE_H / 8 * NBPL]; int game_init(void) { - int i; + REG_COLOR0 = 0x221; + REG_COLOR1 = 0x222; + REG_COLOR2 = 0x332; + REG_COLOR3 = 0x433; + REG_COLOR4 = 0x543; + REG_COLOR5 = 0x554; + REG_COLOR6 = 0x654; + REG_COLOR7 = 0x765; - for(i=0; i<2; i++) { - convert_tile_data(test_tiles[i], test_tiles_cpix[i][0]); - } - convert_tile_data(tile_mask, tile_mask_cpix[0]); return 0; } +#define XTILES 5 +#define YTILES 13 + void game_draw(void) { - draw_tile(0, 32, 16, 0); + int i, j, xoffs, yoffs, ntiles; + + yoffs = 0; + for(i=0; i>= 1; - - if((j & 7) == 7) { - bptr[k]++; - } - } - } - - for(j=0; j +#include +#include + +#include HDRFILE + +#define NBPL 5 + +int main(int argc, char **argv) +{ + int i, j, k, palsz; + FILE *fp; + char *buf; + unsigned char *src; + + if(!argv[1]) { + fprintf(stderr, "missing argument: output name\n"); + return 1; + } + + if(!(buf = malloc(strlen(argv[1]) + 4))) { + perror("malloc failed"); + return 1; + } + sprintf(buf, "%s.img", argv[1]); + + if(!(fp = fopen(buf, "wb"))) { + perror("failed to open output file"); + return 1; + } + + src = header_data; + + printf("image: %dx%d\n", width, height); + for(i=0; i> bit) & 1); + if((k & 7) == 7) { + fputc(out, fp); + } + } + } + src += width; + } + fclose(fp); + + sprintf(buf, "%s.pal", argv[1]); + if(!(fp = fopen(buf, "wb"))) { + perror("failed to open palette output file"); + return 1; + } + + palsz = 1 << NBPL; + + printf("palette:\n"); + for(i=0; i> 4; + int g = header_data_cmap[i][1] >> 4; + int b = header_data_cmap[i][2] >> 4; + unsigned int col = ((r & 0xf) << 8) | ((g & 0xf) << 4) | (b & 0xf); + printf("0x%03x\n", col); + fputc(col >> 8, fp); + fputc(col, fp); + } + fclose(fp); + + return 0; +} -- 1.7.10.4