*.json
*.png
data/
+*.img
+*.tmap
+*.cmap
disasm: $(elf)
$(OBJDUMP) -D $< >$@
-src/data-asm.o: src/data.s data/font8x8.img data/cellspr.img
+src/data-asm.o: src/data.s data/font8x8.img data/cellspr.img data/lifebg.tiles \
+ data/lifefg.tiles
src/z80prog-asm.o: src/z80prog.s $(z80bin)
data/cellspr.img: data/cellspr.png
$(PNGDUMP): tools/pngdump/main.c tools/pngdump/image.c tools/pngdump/quant.c
$(MAKE) -C tools/pngdump
+%.tiles: %.png $(PNGDUMP)
+ $(PNGDUMP) -o $@ -oc $(@:.tiles=.cmap) -om $(@:.tiles=.tmap) -T 8x8 -D $<
+
%.img: %.png $(PNGDUMP)
$(PNGDUMP) -o $@ -oc $(@:.img=.cmap) -T 8x8 $<
c000 nametable A (64x32 * 2 = 4096)
d000 nametable B
e000 sprite table (?)
+f000 horiz.scroll table
ffff
.globl cellspr_cmap_end
.globl lifebg_data
.globl lifebg_data_end
- .globl lifefg_data
- .globl lifefg_data_end
+ .globl lifebg_cmap
+ .globl lifebg_cmap_end
+ .globl lifebg_tmap
+ .globl lifebg_tmap_end
+ .globl lifefg_cmap
+ .globl lifefg_cmap_end
+ .globl lifefg_tmap
+ .globl lifefg_tmap_end
font8x8_data:
.incbin "data/font8x8.img"
font8x8_data_end:
.align 2
lifebg_data:
- .incbin "data/lifebg.img"
+ .incbin "data/lifebg.tiles"
lifebg_data_end:
-
.align 2
lifebg_cmap:
.incbin "data/lifebg.cmap"
lifebg_cmap_end:
+ .align 2
+lifebg_tmap:
+ .incbin "data/lifebg.tmap"
+lifebg_tmap_end:
.align 2
lifefg_data:
- .incbin "data/lifefg.img"
+ .incbin "data/lifefg.tiles"
lifefg_data_end:
-
.align 2
lifefg_cmap:
.incbin "data/lifefg.cmap"
lifefg_cmap_end:
+ .align 2
+lifefg_tmap:
+ .incbin "data/lifefg.tmap"
+lifefg_tmap_end:
--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include "vdp.h"
+#include "parts.h"
+
+extern uint16_t lifebg_data[], lifebg_data_end[];
+extern unsigned char lifebg_cmap[], lifebg_cmap_end[];
+extern uint16_t lifebg_tmap[], lifebg_tmap_end[];
+
+void life_init(void)
+{
+ uint16_t *src;
+
+ /* upload tiles */
+ src = lifebg_data;
+ vdp_setup_addr(VDP_VRAM, 0);
+ while(src < lifebg_data_end) {
+ VDP_DATA = *src++;
+ }
+}
+
+void life_start(void)
+{
+ int i;
+ uint16_t *src;
+ unsigned char *cptr;
+
+ /* setup tilemaps */
+ src = lifebg_tmap;
+ vdp_setup_addr(VDP_VRAM, 0xd000); /* nametable B */
+ while(src < lifebg_tmap_end) {
+ VDP_DATA = VDP_TILENAME(*src++, 2, 0);
+ }
+
+ /* setup colormaps */
+ cptr = lifebg_cmap;
+ for(i=0; i<16; i++) {
+ vdp_setcolor(2, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
+ cptr += 3;
+ }
+}
}
}
- if(!dedup || (tid = matchtile(img, tileoffs, th)) == -1) {
- tmap->map[tileno] = tileno;
- tileoffs += th; /* destination Y offset, inc by th for every tile */
+ if(dedup) {
+ if((tid = matchtile(img, tileoffs, th)) == -1) {
+ if(tmap) {
+ tmap->map[tileno++] = tileoffs / th;
+ }
+ tileoffs += th; /* destination Y offset, inc by th for every tile */
+ } else {
+ if(tmap) {
+ tmap->map[tileno++] = tid;
+ }
+ }
} else {
- tmap->map[tileno] = tid;
+ tileoffs += th; /* destination Y offset, inc by th for every tile */
}
- tileno++;
x += tw;
}
y += th;
}
+ if(dedup) {
+ putchar('\n');
+ img->height = tileoffs;
+ }
+
free(orig.pixels);
return 0;
}
tilesz = img->pitch * th;
pa = (unsigned char*)img->pixels;
- pb = (unsigned char*)img->pixels + toffs * tilesz;
+ pb = (unsigned char*)img->pixels + toffs * img->pitch;
for(i=0; i<ntiles; i++) {
if(memcmp(pa, pb, tilesz) == 0) {