summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io.c16
-rw-r--r--vdp.c15
-rw-r--r--vdp.h7
3 files changed, 32 insertions, 6 deletions
diff --git a/io.c b/io.c
index c83f756..7fce711 100644
--- a/io.c
+++ b/io.c
@@ -147,6 +147,16 @@ void bind_ui(int keycode, ui_action action, uint8_t param)
bind_key(keycode, BIND_UI, action, 0, param);
}
+void bind_button_ui(int joystick, int joybutton, ui_action action, uint8_t param)
+{
+ bind_button(joystick, joybutton, BIND_UI, action, 0, param);
+}
+
+void bind_dpad_ui(int joystick, int dpad, uint8_t direction, ui_action action, uint8_t param)
+{
+ bind_dpad(joystick, dpad, direction, BIND_UI, action, 0, param);
+}
+
void handle_binding_down(keybinding * binding)
{
switch(binding->bind_type)
@@ -487,8 +497,9 @@ void set_keybindings()
int bindtype = parse_binding_target(target, padbuttons, &ui_func, &padnum, &button);
if (bindtype == 1) {
bind_dpad_gamepad(i, dpad, dirnums[dir], padnum, button);
+ } else if (bindtype == 2) {
+ bind_dpad_ui(i, dpad, dirnums[dir], ui_func, button);
}
- //TODO: Handle UI bindings
}
}
}
@@ -508,8 +519,9 @@ void set_keybindings()
int bindtype = parse_binding_target(target, padbuttons, &ui_func, &padnum, &button);
if (bindtype == 1) {
bind_button_gamepad(i, but, padnum, button);
+ } else if (bindtype == 2) {
+ bind_button_ui(i, but, ui_func, button);
}
- //TODO: Handle UI bindings
}
}
}
diff --git a/vdp.c b/vdp.c
index e962a67..87a752b 100644
--- a/vdp.c
+++ b/vdp.c
@@ -159,10 +159,16 @@ void render_sprite_cells(vdp_context * context)
context->cur_slot--;
for (uint16_t address = d->address; address != ((d->address+4) & 0xFFFF); address++) {
if (x >= 0 && x < 320 && !(context->linebuf[x] & 0xF)) {
+ if (context->linebuf[x] && (context->vdpmem[address] >> 4)) {
+ context->flags2 |= FLAG2_SPRITE_COLLIDE;
+ }
context->linebuf[x] = (context->vdpmem[address] >> 4) | d->pal_priority;
}
x += dir;
if (x >= 0 && x < 320 && !(context->linebuf[x] & 0xF)) {
+ if (context->linebuf[x] && (context->vdpmem[address] & 0xF)) {
+ context->flags2 |= FLAG2_SPRITE_COLLIDE;
+ }
context->linebuf[x] = (context->vdpmem[address] & 0xF) | d->pal_priority;
}
x += dir;
@@ -1542,6 +1548,14 @@ uint16_t vdp_control_port_read(vdp_context * context)
if (context->flags2 & FLAG2_VINT_PENDING) {
value |= 0x80;
}
+ if (context->flags & FLAG_DOT_OFLOW) {
+ value |= 0x40;
+ }
+ if (context->flags2 & FLAG2_SPRITE_COLLIDE) {
+ value |= 0x20;
+ //TODO: Test when this is actually cleared
+ context->flags2 &= ~FLAG2_SPRITE_COLLIDE;
+ }
if ((context->regs[REG_MODE_4] & BIT_INTERLACE) && context->framebuf == context->oddbuf) {
value |= 0x10;
}
@@ -1560,7 +1574,6 @@ uint16_t vdp_control_port_read(vdp_context * context)
value |= 0x1;
}
//printf("status read at cycle %d returned %X\n", context->cycles, value);
- //TODO: Sprite overflow, sprite collision, odd frame flag
return value;
}
diff --git a/vdp.h b/vdp.h
index 9b99b97..830aa5a 100644
--- a/vdp.h
+++ b/vdp.h
@@ -45,9 +45,10 @@
#define FLAG_DMA_RUN 0x40
#define FLAG_DMA_PROG 0x80
-#define FLAG2_VINT_PENDING 0x01
-#define FLAG2_HINT_PENDING 0x02
-#define FLAG2_READ_PENDING 0x04
+#define FLAG2_VINT_PENDING 0x01
+#define FLAG2_HINT_PENDING 0x02
+#define FLAG2_READ_PENDING 0x04
+#define FLAG2_SPRITE_COLLIDE 0x08
#define DISPLAY_ENABLE 0x40