initial commit
[megatris] / src / vdp.c
1 #include "vdp.h"
2
3 void vdp_init(void)
4 {
5         int i;
6
7         vdp_setreg(VDP_REG_MODE1, VDP_MODE1_BASE);
8         vdp_setreg(VDP_REG_MODE2, VDP_MODE2_BASE | VDP_MODE2_DISP);
9
10         vdp_set_nametab_addr(VDP_PLANE_A, 0xc000);
11         vdp_set_nametab_addr(VDP_PLANE_B, 0xe000);
12         vdp_disable_layer(VDP_PLANE_WIN);
13         vdp_set_scroll_table(0xd000);
14         vdp_set_sprite_table(0xd400);
15
16         vdp_setreg(VDP_REG_MODE3, VDP_MODE3_BASE);
17         vdp_setreg(VDP_REG_MODE4, VDP_MODE4_BASE | VDP_MODE4_H40CELL);
18         vdp_setreg(VDP_REG_SCROLL_SIZE, VDP_SCROLL_H64 | VDP_SCROLL_V32);
19
20         vdp_set_autoinc(2);
21         vdp_set_bgcolor(0, 0);
22
23         vdp_setreg(VDP_REG_HINTR, 0);
24         vdp_setreg(VDP_REG_WIN_XPOS, 0);
25         vdp_setreg(VDP_REG_WIN_YPOS, 0);
26
27         /* clear vmem at the planes A/B name tables, scroll table, and sprite table */
28         vdp_setup_access(0xd000, VDP_MEM_WRITE, VDP_MEM_VRAM);
29         for(i=0xd000; i<65536; i++) {
30                 VDP_PORT_DATA = 0;
31         }
32 }