nuclear@6: #include nuclear@6: #include "vdp.h" nuclear@6: #include "io.h" nuclear@6: #include "misc.h" nuclear@6: nuclear@6: static void *tilemap_ptr[3]; nuclear@6: nuclear@6: int vdp_init(void) nuclear@6: { nuclear@6: unsigned int mode1_flags = VDP_REG1_DISP_BIT; nuclear@6: nuclear@6: if(mdg_ispal()) { nuclear@6: mode1_flags |= VDP_REG1_30CELL_BIT; nuclear@6: } nuclear@6: nuclear@6: VDP_SET_REG(0, VDP_REG0_BASE); nuclear@6: VDP_SET_REG(1, VDP_REG1_BASE | mode1_flags); nuclear@6: nuclear@6: return 0; nuclear@6: } nuclear@6: nuclear@6: void vdp_set_tilemap_slot(int plane, int slot) nuclear@6: { nuclear@6: switch(plane) { nuclear@6: case VDP_PLANE_A: nuclear@6: VDP_SET_REG(VDP_REG_PADDR_A, (slot & 7) << 3); nuclear@6: tilemap_ptr[VDP_PLANE_A] = (void*)((uint32_t)slot << 13); nuclear@6: break; nuclear@6: nuclear@6: case VDP_PLANE_WIN: nuclear@6: VDP_SET_REG(VDP_REG_PADDR_WIN, (slot & 0x1f) << 1); nuclear@6: tilemap_ptr[VDP_PLANE_WIN] = (void*)((uint32_t)slot << 11); nuclear@6: break; nuclear@6: nuclear@6: case VDP_PLANE_B: nuclear@6: VDP_SET_REG(VDP_REG_PADDR_B, slot & 7); nuclear@6: tilemap_ptr[VDP_PLANE_B] = (void*)((uint32_t)slot << 13); nuclear@6: break; nuclear@6: } nuclear@6: } nuclear@6: nuclear@6: void *vdp_tilemap_ptr(int plane) nuclear@6: { nuclear@6: return tilemap_ptr[plane]; nuclear@6: } nuclear@6: nuclear@6: void vdp_setpal_rgb24(int idx, int r, int g, int b) nuclear@6: { nuclear@6: VDP_SET_CRAM_ADDR(idx); nuclear@6: VDP_SET_CRAM_RGB24(r, g, b); nuclear@6: } nuclear@6: nuclear@6: void vdp_setpal(int idx0, int count, unsigned char *pal) nuclear@6: { nuclear@6: int i; nuclear@6: nuclear@6: VDP_SET_CRAM_ADDR(idx0); nuclear@6: for(i=0; i>= 6; \ nuclear@6: break; \ nuclear@6: case 128: \ nuclear@6: (x) = 3; \ nuclear@6: break; \ nuclear@6: default: \ nuclear@6: panic("invalid argument to %s: %d\n", (x), __func__); \ nuclear@6: } \ nuclear@6: } while(0) nuclear@6: nuclear@6: void vdp_set_scroll_size(int xtiles, int ytiles) nuclear@6: { nuclear@6: SCROLLSIZE(xtiles); nuclear@6: SCROLLSIZE(ytiles); nuclear@6: nuclear@6: VDP_SET_REG(VDP_REG_SCROLL_SIZE, (ytiles << 4) | xtiles); nuclear@6: }