Mercurial > repos > blastem
annotate jcart.c @ 1921:5d028088e320
Added help commands to debugger
author | Eric Fry <yuv422@users.noreply.github.com> |
---|---|
date | Fri, 10 Apr 2020 13:30:16 +1000 |
parents | 395f684c5379 |
children | d74d3998482c |
rev | line source |
---|---|
1688
395f684c5379
Fixed the most glaring issues in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1612
diff
changeset
|
1 #include <stdlib.h> |
1610 | 2 #include "genesis.h" |
3 | |
4 static io_port *get_ports(m68k_context *m68k) | |
5 { | |
6 genesis_context *gen = m68k->system; | |
7 if (!gen->extra) { | |
8 io_port *ports = calloc(2, sizeof(io_port)); | |
9 ports[0].device_type = IO_GAMEPAD3; | |
10 ports[0].device.pad.gamepad_num = 3; | |
11 ports[1].device_type = IO_GAMEPAD3; | |
12 ports[1].device.pad.gamepad_num = 4; | |
13 io_control_write(ports, 0x40, 0); | |
14 io_control_write(ports + 1, 0x40, 0); | |
15 gen->extra = ports; | |
16 } | |
17 | |
18 return gen->extra; | |
19 } | |
20 | |
21 void *jcart_write_w(uint32_t address, void *context, uint16_t value) | |
22 { | |
23 m68k_context *m68k= context; | |
24 io_port *ports = get_ports(m68k); | |
25 value = value << 6 & 0x40; | |
26 io_data_write(ports, value, m68k->current_cycle); | |
27 io_data_write(ports + 1, value, m68k->current_cycle); | |
28 return context; | |
29 } | |
30 | |
31 void *jcart_write_b(uint32_t address, void *context, uint8_t value) | |
32 { | |
33 if (address & 1) { | |
34 return jcart_write_w(address, context, value); | |
35 } | |
36 return context; | |
37 } | |
38 | |
39 uint16_t jcart_read_w(uint32_t address, void *context) | |
40 { | |
41 m68k_context *m68k= context; | |
42 io_port *ports = get_ports(m68k); | |
43 //according to Eke, bit 14 is forced low, at least on the Micro Machines 2 cart | |
44 //TODO: Test behavior of actual cart | |
1612
28ec17387be5
Remove stray / in jcart.c
Michael Pavone <pavone@retrodev.com>
parents:
1610
diff
changeset
|
45 uint16_t value = io_data_read(ports, m68k->current_cycle) << 8; |
1610 | 46 value |= io_data_read(ports + 1, m68k->current_cycle); |
47 return value; | |
48 } | |
49 | |
50 uint8_t jcart_read_b(uint32_t address, void *context) | |
51 { | |
52 m68k_context *m68k= context; | |
53 io_port *ports = get_ports(m68k); | |
54 return io_data_read(ports + (address & 1), m68k->current_cycle); | |
55 } | |
56 | |
57 void jcart_adjust_cycles(genesis_context *context, uint32_t deduction) | |
58 { | |
59 io_port *ports = get_ports(context->m68k); | |
60 io_adjust_cycles(ports, context->m68k->current_cycle, deduction); | |
61 io_adjust_cycles(ports + 1, context->m68k->current_cycle, deduction); | |
62 } | |
63 | |
64 void jcart_gamepad_down(genesis_context *context, uint8_t gamepad_num, uint8_t button) | |
65 { | |
66 io_port *ports = get_ports(context->m68k); | |
67 if (gamepad_num == ports[1].device.pad.gamepad_num) { | |
68 ports++; | |
69 } else if (gamepad_num != ports[0].device.pad.gamepad_num) { | |
70 ports = NULL; | |
71 } | |
72 if (ports) { | |
73 io_port_gamepad_down(ports, button); | |
74 } | |
75 } | |
76 | |
77 void jcart_gamepad_up(genesis_context *context, uint8_t gamepad_num, uint8_t button) | |
78 { | |
79 io_port *ports = get_ports(context->m68k); | |
80 if (gamepad_num == ports[1].device.pad.gamepad_num) { | |
81 ports++; | |
82 } else if (gamepad_num != ports[0].device.pad.gamepad_num) { | |
83 ports = NULL; | |
84 } | |
85 if (ports) { | |
86 io_port_gamepad_up(ports, button); | |
87 } | |
88 } |