#include "vdp.h"
#include "pad.h"
#include "parts.h"
+#include "debug.h"
+
+#define BGTILES_OFFS 1
+#define FGTILES_OFFS 4
extern uint16_t simbabg_data[], simbabg_data_end[];
extern unsigned char simbabg_cmap[], simbabg_cmap_end[];
extern uint16_t simbabg_tmap[], simbabg_tmap_end[];
+extern uint16_t simbafg_data[], simbafg_data_end[];
+extern unsigned char simbafg_cmap[], simbafg_cmap_end[];
+extern uint16_t simbafg_tmap[], simbafg_tmap_end[];
-static int scroll;
+static short scroll;
void simba_init(void)
{
/* upload tiles */
src = simbabg_data;
- vdp_setup_addr(VDP_VRAM, 32); /* start from tile 1 32 bytes on */
+ vdp_setup_addr(VDP_VRAM, BGTILES_OFFS * 32); /* start from tile 1 32 bytes on */
while(src < simbabg_data_end) {
VDP_DATA = *src++;
}
+
+ src = simbafg_data;
+ vdp_setup_addr(VDP_VRAM, FGTILES_OFFS * 32);
+ while(src < simbafg_data_end) {
+ VDP_DATA = *src++;
+ }
}
void simba_start(void)
unsigned char *cptr;
/* setup tilemaps */
+ src = simbafg_tmap;
+ vdp_setup_addr(VDP_VRAM, 0xc000); /* nametable A */
+ while(src < simbafg_tmap_end) {
+ VDP_DATA = VDP_TILENAME(*src++ + FGTILES_OFFS, 3, 0);
+ }
src = simbabg_tmap;
vdp_setup_addr(VDP_VRAM, 0xe000); /* nametable B */
while(src < simbabg_tmap_end) {
- VDP_DATA = VDP_TILENAME(*src++ + 1, 2, 0);
+ VDP_DATA = VDP_TILENAME(*src++ + BGTILES_OFFS, 2, 0);
}
/* setup colormaps */
vdp_setcolor(2, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
cptr += 3;
}
+ cptr = simbafg_cmap;
+ for(i=0; i<16; i++) {
+ vdp_setcolor(3, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
+ cptr += 3;
+ }
/* set scrolling to whole screen */
vdp_setreg(VDP_REG_MODE3, 0);
+ scroll = 0;
+ vdp_setup_addr(VDP_VRAM, 0xf000); /* hscroll table is at f000, see vdp.S */
+ VDP_DATA = 0;
+ VDP_DATA = 0;
}
void simba_update(void)
{
if(bnstate & PAD_LEFT) {
- if(scroll > 0) scroll--;
+ if(scroll < 0) scroll++;
} else if(bnstate & PAD_RIGHT) {
- if(scroll < 511) scroll++;
+ if(scroll > -192) scroll--;
}
+ dbgval[0] = scroll;
}
void simba_vblank(void)
{
vdp_setup_addr(VDP_VRAM, 0xf000); /* hscroll table is at f000, see vdp.S */
- VDP_DATA = 0;
VDP_DATA = scroll;
+ VDP_DATA = scroll >> 1;
}