finished the tile deduplication and tilemap generation in pngdump
[mdlife] / src / part_life.c
1 #include <stdio.h>
2 #include <stdint.h>
3 #include "vdp.h"
4 #include "parts.h"
5
6 extern uint16_t lifebg_data[], lifebg_data_end[];
7 extern unsigned char lifebg_cmap[], lifebg_cmap_end[];
8 extern uint16_t lifebg_tmap[], lifebg_tmap_end[];
9
10 void life_init(void)
11 {
12         uint16_t *src;
13
14         /* upload tiles */
15         src = lifebg_data;
16         vdp_setup_addr(VDP_VRAM, 0);
17         while(src < lifebg_data_end) {
18                 VDP_DATA = *src++;
19         }
20 }
21
22 void life_start(void)
23 {
24         int i;
25         uint16_t *src;
26         unsigned char *cptr;
27
28         /* setup tilemaps */
29         src = lifebg_tmap;
30         vdp_setup_addr(VDP_VRAM, 0xd000);       /* nametable B */
31         while(src < lifebg_tmap_end) {
32                 VDP_DATA = VDP_TILENAME(*src++, 2, 0);
33         }
34
35         /* setup colormaps */
36         cptr = lifebg_cmap;
37         for(i=0; i<16; i++) {
38                 vdp_setcolor(2, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
39                 cptr += 3;
40         }
41 }