nuclear@1: #include nuclear@0: #include "vdp.h" nuclear@0: nuclear@4: uint32_t pat0[] = { nuclear@4: 0x00000000, nuclear@4: 0x00000000, nuclear@4: 0x00000000, nuclear@4: 0x00010000, nuclear@4: 0x00000000, nuclear@4: 0x00000000, nuclear@4: 0x00000000, nuclear@4: 0x00000000 nuclear@4: }; nuclear@4: nuclear@4: uint32_t pat1[] = { nuclear@4: 0x11111111, nuclear@4: 0x11000011, nuclear@4: 0x10100101, nuclear@4: 0x10011001, nuclear@4: 0x10011001, nuclear@4: 0x10100101, nuclear@4: 0x11000011, nuclear@4: 0x11111111 nuclear@4: }; nuclear@4: nuclear@4: uint32_t pat2[] = { nuclear@4: 0x11111111, nuclear@4: 0x10011001, nuclear@4: 0x10011001, nuclear@4: 0x11111111, nuclear@4: 0x11111111, nuclear@4: 0x10011001, nuclear@4: 0x10011001, nuclear@4: 0x11111111 nuclear@4: }; nuclear@4: nuclear@4: void load_pattern(int idx, void *data); nuclear@4: void set_tile(int x, int y, int tile_idx, int palidx); nuclear@4: nuclear@0: int main(void) nuclear@0: { nuclear@4: int i, j; nuclear@4: nuclear@0: vdp_init(); nuclear@0: nuclear@1: vdp_set_pal_entry(0, 0, 0, 0, 0); nuclear@4: vdp_set_pal_entry(0, 1, 7, 1, 3); nuclear@4: vdp_set_bgcolor(0, 0); nuclear@0: nuclear@4: load_pattern(0, pat0); nuclear@4: load_pattern(1, pat1); nuclear@4: load_pattern(2, pat2); nuclear@4: nuclear@4: vdp_set_nametab_idx(VDP_PLANE_A, 6); nuclear@4: nuclear@4: for(i=0; i<20; i++) { nuclear@4: for(j=0; j<20; j++) { nuclear@4: set_tile(j, i, 1, 0); nuclear@4: } nuclear@4: } nuclear@4: nuclear@4: //vdp_enable_hintr(12); nuclear@4: //vdp_enable_vintr(); nuclear@1: nuclear@0: for(;;); nuclear@0: nuclear@0: return 0; nuclear@0: } nuclear@1: nuclear@4: /* nuclear@1: uint16_t testcol = 0x00c0; nuclear@1: nuclear@1: void vblank_handler(void) nuclear@1: { nuclear@1: testcol = 0x00c0; nuclear@1: } nuclear@4: */ nuclear@4: nuclear@4: void load_pattern(int idx, void *data) nuclear@4: { nuclear@4: int i; nuclear@4: uint32_t *ptr = data; nuclear@4: uint16_t addr = idx << 5; nuclear@4: vdp_setup_access(addr, VDP_MEM_WRITE, VDP_MEM_VRAM); nuclear@4: nuclear@4: for(i=0; i<16; i++) { nuclear@4: VDP_PORT_DATA32 = *ptr++; nuclear@4: } nuclear@4: } nuclear@4: nuclear@4: void set_tile(int x, int y, int tile_idx, int palidx) nuclear@4: { nuclear@4: uint16_t tile_ent, addr; nuclear@4: nuclear@4: tile_ent = vdp_nametab_entry(tile_idx, palidx, VDP_TILE_LOW_PRIO); nuclear@4: nuclear@4: addr = vdp_nametab_addr(6) + (y * 64 + x) * 2; nuclear@4: vdp_setup_access(addr, VDP_MEM_WRITE, VDP_MEM_VRAM); nuclear@4: VDP_PORT_DATA = tile_ent; nuclear@4: }