parts[0].update = dna_update;
parts[1].start = simba_start;
parts[1].update = simba_update;
+ parts[1].vblank = simba_vblank;
part = parts;
part->start();
part->update();
vdp_wait_vblank();
+ if(part->vblank) part->vblank();
spr_submit();
bnstate = pad_read(0);
bndiff = bnstate ^ bnprev;
#include <stdio.h>
#include <stdint.h>
#include "vdp.h"
+#include "pad.h"
#include "parts.h"
extern uint16_t simbabg_data[], simbabg_data_end[];
extern unsigned char simbabg_cmap[], simbabg_cmap_end[];
extern uint16_t simbabg_tmap[], simbabg_tmap_end[];
+static int scroll;
+
void simba_init(void)
{
uint16_t *src;
/* upload tiles */
src = simbabg_data;
- vdp_setup_addr(VDP_VRAM, 0);
+ vdp_setup_addr(VDP_VRAM, 32); /* start from tile 1 32 bytes on */
while(src < simbabg_data_end) {
VDP_DATA = *src++;
}
src = simbabg_tmap;
vdp_setup_addr(VDP_VRAM, 0xe000); /* nametable B */
while(src < simbabg_tmap_end) {
- VDP_DATA = VDP_TILENAME(*src++, 2, 0);
+ VDP_DATA = VDP_TILENAME(*src++ + 1, 2, 0);
}
/* setup colormaps */
vdp_setcolor(2, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
cptr += 3;
}
+
+ /* set scrolling to whole screen */
+ vdp_setreg(VDP_REG_MODE3, 0);
}
void simba_update(void)
{
+ if(bnstate & PAD_LEFT) {
+ if(scroll > 0) scroll--;
+ } else if(bnstate & PAD_RIGHT) {
+ if(scroll < 511) 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;
}