Mercurial > repos > blastem
annotate sms.c @ 2468:0ca78837e4d2
Implement ext instruction in new 68K core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 24 Feb 2024 22:54:36 -0800 |
parents | 767ec72acca7 |
children | d44fe974fb85 |
rev | line source |
---|---|
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <string.h> |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdlib.h> |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include <stddef.h> |
2202
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
4 #include "config.h" |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "sms.h" |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #include "blastem.h" |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include "render.h" |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include "util.h" |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1126
diff
changeset
|
9 #include "debug.h" |
1478
da1dce39e846
Refactored save slot related logic to reduce duplication and allow reuse in new UI. Get state loading/saving mostly working in new UI
Michael Pavone <pavone@retrodev.com>
parents:
1433
diff
changeset
|
10 #include "saves.h" |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
11 #include "bindings.h" |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
13 #ifdef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
14 #define Z80_CYCLE cycles |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
15 #define Z80_OPTS opts |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
16 #define z80_handle_code_write(...) |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
17 #else |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
18 #define Z80_CYCLE current_cycle |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
19 #define Z80_OPTS options |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
20 #endif |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
21 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 static void *memory_io_write(uint32_t location, void *vcontext, uint8_t value) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 z80_context *z80 = vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 sms_context *sms = z80->system; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 if (location & 1) { |
1154
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
27 uint8_t fuzzy_ctrl_0 = sms->io.ports[0].control, fuzzy_ctrl_1 = sms->io.ports[1].control; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
28 io_control_write(sms->io.ports, (~value) << 5 & 0x60, z80->Z80_CYCLE); |
1154
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
29 fuzzy_ctrl_0 |= sms->io.ports[0].control; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
30 io_control_write(sms->io.ports+1, (~value) << 3 & 0x60, z80->Z80_CYCLE); |
1154
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
31 fuzzy_ctrl_1 |= sms->io.ports[1].control; |
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
32 if ( |
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
33 (fuzzy_ctrl_0 & 0x40 & (sms->io.ports[0].output ^ (value << 1)) & (value << 1)) |
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
34 || (fuzzy_ctrl_0 & 0x40 & (sms->io.ports[1].output ^ (value >> 1)) & (value >> 1)) |
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
35 ) { |
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
36 //TH is an output and it went from 0 -> 1 |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
37 vdp_run_context(sms->vdp, z80->Z80_CYCLE); |
1154
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
38 vdp_latch_hv(sms->vdp); |
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
39 } |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
40 io_data_write(sms->io.ports, value << 1, z80->Z80_CYCLE); |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
41 io_data_write(sms->io.ports + 1, value >> 1, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 } else { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 //TODO: memory control write |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 return vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 static uint8_t hv_read(uint32_t location, void *vcontext) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 z80_context *z80 = vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 sms_context *sms = z80->system; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
52 vdp_run_context(sms->vdp, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 uint16_t hv = vdp_hv_counter_read(sms->vdp); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 if (location & 1) { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 return hv; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 } else { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 return hv >> 8; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 static void *sms_psg_write(uint32_t location, void *vcontext, uint8_t value) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 z80_context *z80 = vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 sms_context *sms = z80->system; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
65 psg_run(sms->psg, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 psg_write(sms->psg, value); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 return vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 static void update_interrupts(sms_context *sms) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 uint32_t vint = vdp_next_vint(sms->vdp); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 uint32_t hint = vdp_next_hint(sms->vdp); |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
74 #ifdef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
75 sms->z80->int_cycle = vint < hint ? vint : hint; |
1759
6e4faa10f9ee
Store sync_cycle in context rather than in a local in CPU DSL. Fix the timing of a number of instructions in new Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
1752
diff
changeset
|
76 z80_sync_cycle(sms->z80, sms->z80->sync_cycle); |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
77 #else |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 sms->z80->int_pulse_start = vint < hint ? vint : hint; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
79 #endif |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 static uint8_t vdp_read(uint32_t location, void *vcontext) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 z80_context *z80 = vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 sms_context *sms = z80->system; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
86 vdp_run_context(sms->vdp, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 if (location & 1) { |
1126
63cd87d910cc
Clear interrupt status flags after getting the status register value rather than before
Michael Pavone <pavone@retrodev.com>
parents:
1120
diff
changeset
|
88 uint8_t ret = vdp_control_port_read(sms->vdp); |
1119
55ea7f9a4e92
Fix clearing of interrupt pending flags on control port read in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
89 sms->vdp->flags2 &= ~(FLAG2_VINT_PENDING|FLAG2_HINT_PENDING); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 update_interrupts(sms); |
1126
63cd87d910cc
Clear interrupt status flags after getting the status register value rather than before
Michael Pavone <pavone@retrodev.com>
parents:
1120
diff
changeset
|
91 return ret; |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 } else { |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
93 return vdp_data_port_read_pbc(sms->vdp); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 static void *vdp_write(uint32_t location, void *vcontext, uint8_t value) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 z80_context *z80 = vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 sms_context *sms = z80->system; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 if (location & 1) { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
102 vdp_run_context_full(sms->vdp, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 vdp_control_port_write_pbc(sms->vdp, value); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 update_interrupts(sms); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 } else { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
106 vdp_run_context(sms->vdp, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 vdp_data_port_write_pbc(sms->vdp, value); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 return vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 static uint8_t io_read(uint32_t location, void *vcontext) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 z80_context *z80 = vcontext; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 sms_context *sms = z80->system; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 if (location == 0xC0 || location == 0xDC) { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
117 uint8_t port_a = io_data_read(sms->io.ports, z80->Z80_CYCLE); |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
118 uint8_t port_b = io_data_read(sms->io.ports+1, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 return (port_a & 0x3F) | (port_b << 6); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 if (location == 0xC1 || location == 0xDD) { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
122 uint8_t port_a = io_data_read(sms->io.ports, z80->Z80_CYCLE); |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
123 uint8_t port_b = io_data_read(sms->io.ports+1, z80->Z80_CYCLE); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 return (port_a & 0x40) | (port_b >> 2 & 0xF) | (port_b << 1 & 0x80) | 0x10; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 return 0xFF; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
129 static void update_mem_map(uint32_t location, sms_context *sms, uint8_t value) |
1141
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
130 { |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
131 z80_context *z80 = sms->z80; |
1142
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
132 void *old_value; |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
133 if (location) { |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
134 uint32_t idx = location - 1; |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
135 old_value = z80->mem_pointers[idx]; |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
136 z80->mem_pointers[idx] = sms->rom + (value << 14 & (sms->rom_size-1)); |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
137 if (old_value != z80->mem_pointers[idx]) { |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
138 //invalidate any code we translated for the relevant bank |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
139 z80_invalidate_code_range(z80, idx ? idx * 0x4000 : 0x400, idx * 0x4000 + 0x4000); |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
140 } |
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1141
diff
changeset
|
141 } else { |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
142 old_value = z80->mem_pointers[2]; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
143 if (value & 8) { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
144 //cartridge RAM is enabled |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
145 z80->mem_pointers[2] = sms->cart_ram + (value & 4 ? (SMS_CART_RAM_SIZE/2) : 0); |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
146 } else { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
147 //cartridge RAM is disabled |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
148 z80->mem_pointers[2] = sms->rom + (sms->bank_regs[3] << 14 & (sms->rom_size-1)); |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
149 } |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
150 if (old_value != z80->mem_pointers[2]) { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
151 //invalidate any code we translated for the relevant bank |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
152 z80_invalidate_code_range(z80, 0x8000, 0xC000); |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
153 } |
1141
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
154 } |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
155 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
156 |
2320
8016dbb0fcde
Initial work on ROM DB support for SMS/GG games
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
157 void *sms_sega_mapper_write(uint32_t location, void *vcontext, uint8_t value) |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
158 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
159 z80_context *z80 = vcontext; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
160 sms_context *sms = z80->system; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
161 location &= 3; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
162 sms->ram[0x1FFC + location] = value; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
163 sms->bank_regs[location] = value; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
164 update_mem_map(location, sms, value); |
1141
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
165 return vcontext; |
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
166 } |
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
167 |
2321
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
168 void *sms_cart_ram_write(uint32_t location, void *vcontext, uint8_t value) |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
169 { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
170 z80_context *z80 = vcontext; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
171 sms_context *sms = z80->system; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
172 if (sms->bank_regs[0] & 8) { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
173 //cartridge RAM is enabled |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
174 location &= 0x3FFF; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
175 z80->mem_pointers[2][location] = value; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
176 z80_handle_code_write(0x8000 + location, z80); |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
177 } |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
178 return vcontext; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
179 } |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
180 |
2325
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
181 static z80_context *codemasters_write(uint8_t bank, z80_context *z80, uint8_t value) |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
182 { |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
183 sms_context *sms = z80->system; |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
184 if (value != sms->bank_regs[bank]) { |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
185 sms->bank_regs[bank] = value; |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
186 value &= 0x7F; |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
187 z80->mem_pointers[bank] = sms->rom + (value << 14 & (sms->rom_size-1)); |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
188 z80_invalidate_code_range(z80, bank * 0x4000, bank * 0x4000 + 0x4000); |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
189 } |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
190 return z80; |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
191 } |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
192 |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
193 void *sms_codemasters_bank0_write(uint32_t location, void *vcontext, uint8_t value) |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
194 { |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
195 return codemasters_write(0, vcontext, value); |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
196 } |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
197 |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
198 void *sms_codemasters_bank1_write(uint32_t location, void *vcontext, uint8_t value) |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
199 { |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
200 return codemasters_write(1, vcontext, value); |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
201 } |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
202 |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
203 void *sms_codemasters_bank2_write(uint32_t location, void *vcontext, uint8_t value) |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
204 { |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
205 //TODO: Handle Ernie Els Golf cart RAM |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
206 return codemasters_write(2, vcontext, value); |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
207 } |
26597f9805b4
Initial Codemasters mapper support
Michael Pavone <pavone@retrodev.com>
parents:
2321
diff
changeset
|
208 |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
209 uint8_t debug_commands(system_header *system, char *input_buf) |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
210 { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
211 sms_context *sms = (sms_context *)system; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
212 switch(input_buf[0]) |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
213 { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
214 case 'v': |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
215 if (input_buf[1] == 'r') { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
216 vdp_print_reg_explain(sms->vdp); |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
217 } else if (input_buf[1] == 's') { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
218 vdp_print_sprite_table(sms->vdp); |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
219 } else { |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
220 return 0; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
221 } |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
222 break; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
223 } |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
224 return 1; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
225 } |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1148
diff
changeset
|
226 |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
227 static uint8_t gg_io_read(uint32_t location, void *vcontext) |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
228 { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
229 z80_context *z80 = vcontext; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
230 sms_context *sms = z80->system; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
231 if (!location) { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
232 return sms->start_button_region; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
233 } else { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
234 //TODO: implement link port |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
235 return 0xFF; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
236 } |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
237 } |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
238 |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
239 static void *gg_io_write(uint32_t location, void *vcontext, uint8_t value) |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
240 { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
241 //TODO: implement link port |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
242 return vcontext; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
243 } |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
244 static void *psg_pan_write(uint32_t location, void *vcontext, uint8_t value) |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
245 { |
2196
2648081f3100
Implement Game Gear PSG panning
Michael Pavone <pavone@retrodev.com>
parents:
2195
diff
changeset
|
246 z80_context *z80 = vcontext; |
2648081f3100
Implement Game Gear PSG panning
Michael Pavone <pavone@retrodev.com>
parents:
2195
diff
changeset
|
247 sms_context *sms = z80->system; |
2648081f3100
Implement Game Gear PSG panning
Michael Pavone <pavone@retrodev.com>
parents:
2195
diff
changeset
|
248 psg_run(sms->psg, z80->Z80_CYCLE); |
2648081f3100
Implement Game Gear PSG panning
Michael Pavone <pavone@retrodev.com>
parents:
2195
diff
changeset
|
249 sms->psg->pan = value; |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
250 return vcontext; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
251 } |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 static memmap_chunk io_map[] = { |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
253 {0x00, 0x40, 0xFF, .write_8 = memory_io_write}, |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
254 {0x40, 0x80, 0xFF, .read_8 = hv_read, .write_8 = sms_psg_write}, |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
255 {0x80, 0xC0, 0xFF, .read_8 = vdp_read, .write_8 = vdp_write}, |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
256 {0xC0, 0x100,0xFF, .read_8 = io_read} |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 }; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
259 static memmap_chunk io_gg[] = { |
2197
74b92e20e2ef
Fix off by one in PSG pan register mapping
Michael Pavone <pavone@retrodev.com>
parents:
2196
diff
changeset
|
260 {0x00, 0x06, 0xFF, .read_8 = gg_io_read, .write_8 = gg_io_write}, |
74b92e20e2ef
Fix off by one in PSG pan register mapping
Michael Pavone <pavone@retrodev.com>
parents:
2196
diff
changeset
|
261 {0x06, 0x07, 0xFF, .write_8 = psg_pan_write}, |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
262 {0x08, 0x40, 0xFF, .write_8 = memory_io_write}, |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
263 {0x40, 0x80, 0xFF, .read_8 = hv_read, .write_8 = sms_psg_write}, |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
264 {0x80, 0xC0, 0xFF, .read_8 = vdp_read, .write_8 = vdp_write}, |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
265 {0xC0, 0x100,0xFF, .read_8 = io_read} |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
266 }; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
267 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 static void set_speed_percent(system_header * system, uint32_t percent) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 sms_context *context = (sms_context *)system; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 uint32_t old_clock = context->master_clock; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 context->master_clock = ((uint64_t)context->normal_clock * (uint64_t)percent) / 100; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 psg_adjust_master_clock(context->psg, context->master_clock); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
277 void sms_serialize(sms_context *sms, serialize_buffer *buf) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
278 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
279 start_section(buf, SECTION_Z80); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
280 z80_serialize(sms->z80, buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
281 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
282 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
283 start_section(buf, SECTION_VDP); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
284 vdp_serialize(sms->vdp, buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
285 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
286 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
287 start_section(buf, SECTION_PSG); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
288 psg_serialize(sms->psg, buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
289 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
290 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
291 start_section(buf, SECTION_SEGA_IO_1); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
292 io_serialize(sms->io.ports, buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
293 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
294 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
295 start_section(buf, SECTION_SEGA_IO_2); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
296 io_serialize(sms->io.ports + 1, buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
297 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
298 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
299 start_section(buf, SECTION_MAIN_RAM); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
300 save_int8(buf, sizeof(sms->ram) / 1024); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
301 save_buffer8(buf, sms->ram, sizeof(sms->ram)); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
302 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
303 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
304 start_section(buf, SECTION_MAPPER); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
305 save_int8(buf, 1);//mapper type, 1 for Sega mapper |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
306 save_buffer8(buf, sms->bank_regs, sizeof(sms->bank_regs)); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
307 end_section(buf); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
308 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
309 start_section(buf, SECTION_CART_RAM); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
310 save_int8(buf, SMS_CART_RAM_SIZE / 1024); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
311 save_buffer8(buf, sms->cart_ram, SMS_CART_RAM_SIZE); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
312 end_section(buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
313 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
314 |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
315 static uint8_t *serialize(system_header *sys, size_t *size_out) |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
316 { |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
317 sms_context *sms = (sms_context *)sys; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
318 serialize_buffer state; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
319 init_serialize(&state); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
320 sms_serialize(sms, &state); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
321 if (size_out) { |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
322 *size_out = state.size; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
323 } |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
324 return state.data; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
325 } |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
326 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
327 static void ram_deserialize(deserialize_buffer *buf, void *vsms) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
328 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
329 sms_context *sms = vsms; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
330 uint32_t ram_size = load_int8(buf) * 1024; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
331 if (ram_size > sizeof(sms->ram)) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
332 fatal_error("State has a RAM size of %d bytes", ram_size); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
333 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
334 load_buffer8(buf, sms->ram, ram_size); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
335 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
336 |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
337 static void cart_ram_deserialize(deserialize_buffer *buf, void *vsms) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
338 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
339 sms_context *sms = vsms; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
340 uint32_t ram_size = load_int8(buf) * 1024; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
341 if (ram_size > SMS_CART_RAM_SIZE) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
342 fatal_error("State has a cart RAM size of %d bytes", ram_size); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
343 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
344 load_buffer8(buf, sms->cart_ram, ram_size); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
345 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
346 |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
347 static void mapper_deserialize(deserialize_buffer *buf, void *vsms) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
348 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
349 sms_context *sms = vsms; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
350 uint8_t mapper_type = load_int8(buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
351 if (mapper_type != 1) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
352 warning("State contains an unrecognized mapper type %d, it may be from a newer version of BlastEm\n", mapper_type); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
353 return; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
354 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
355 for (int i = 0; i < sizeof(sms->bank_regs); i++) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
356 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
357 sms->bank_regs[i] = load_int8(buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
358 update_mem_map(i, sms, sms->bank_regs[i]); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
359 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
360 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
361 |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
362 void sms_deserialize(deserialize_buffer *buf, sms_context *sms) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
363 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
364 register_section_handler(buf, (section_handler){.fun = z80_deserialize, .data = sms->z80}, SECTION_Z80); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
365 register_section_handler(buf, (section_handler){.fun = vdp_deserialize, .data = sms->vdp}, SECTION_VDP); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
366 register_section_handler(buf, (section_handler){.fun = psg_deserialize, .data = sms->psg}, SECTION_PSG); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
367 register_section_handler(buf, (section_handler){.fun = io_deserialize, .data = sms->io.ports}, SECTION_SEGA_IO_1); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
368 register_section_handler(buf, (section_handler){.fun = io_deserialize, .data = sms->io.ports + 1}, SECTION_SEGA_IO_2); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
369 register_section_handler(buf, (section_handler){.fun = ram_deserialize, .data = sms}, SECTION_MAIN_RAM); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
370 register_section_handler(buf, (section_handler){.fun = mapper_deserialize, .data = sms}, SECTION_MAPPER); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
371 register_section_handler(buf, (section_handler){.fun = cart_ram_deserialize, .data = sms}, SECTION_CART_RAM); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
372 //TODO: cart RAM |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
373 while (buf->cur_pos < buf->size) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
374 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
375 load_section(buf); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
376 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
377 z80_invalidate_code_range(sms->z80, 0xC000, 0x10000); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
378 if (sms->bank_regs[0] & 8) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
379 //cart RAM is enabled, invalidate the region in case there is any code there |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
380 z80_invalidate_code_range(sms->z80, 0x8000, 0xC000); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
381 } |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
382 free(buf->handlers); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
383 buf->handlers = NULL; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
384 } |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
385 |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
386 static void deserialize(system_header *sys, uint8_t *data, size_t size) |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
387 { |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
388 sms_context *sms = (sms_context *)sys; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
389 deserialize_buffer buffer; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
390 init_deserialize(&buffer, data, size); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
391 sms_deserialize(&buffer, sms); |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
392 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
393 |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
394 static void save_state(sms_context *sms, uint8_t slot) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
395 { |
1478
da1dce39e846
Refactored save slot related logic to reduce duplication and allow reuse in new UI. Get state loading/saving mostly working in new UI
Michael Pavone <pavone@retrodev.com>
parents:
1433
diff
changeset
|
396 char *save_path = get_slot_name(&sms->header, slot, "state"); |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
397 serialize_buffer state; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
398 init_serialize(&state); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
399 sms_serialize(sms, &state); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
400 save_to_file(&state, save_path); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
401 printf("Saved state to %s\n", save_path); |
1478
da1dce39e846
Refactored save slot related logic to reduce duplication and allow reuse in new UI. Get state loading/saving mostly working in new UI
Michael Pavone <pavone@retrodev.com>
parents:
1433
diff
changeset
|
402 free(save_path); |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
403 free(state.data); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
404 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
405 |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
406 static uint8_t load_state_path(sms_context *sms, char *path) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
407 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
408 deserialize_buffer state; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
409 uint8_t ret; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
410 if ((ret = load_from_file(&state, path))) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
411 sms_deserialize(&state, sms); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
412 free(state.data); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
413 printf("Loaded %s\n", path); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
414 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
415 return ret; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
416 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
417 |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
418 static uint8_t load_state(system_header *system, uint8_t slot) |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
419 { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
420 sms_context *sms = (sms_context *)system; |
1480
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
421 char *statepath = get_slot_name(system, slot, "state"); |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
422 uint8_t ret; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
423 #ifndef NEW_CORE |
1480
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
424 if (!sms->z80->native_pc) { |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
425 ret = get_modification_time(statepath) != 0; |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
426 if (ret) { |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
427 system->delayed_load_slot = slot + 1; |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
428 } |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
429 goto done; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
430 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
431 } |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
432 #endif |
1480
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
433 ret = load_state_path(sms, statepath); |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
434 done: |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
435 free(statepath); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
436 return ret; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
437 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
438 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
439 static void run_sms(system_header *system) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
441 sms_context *sms = (sms_context *)system; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
442 uint32_t target_cycle = sms->z80->Z80_CYCLE + 3420*16; |
1184
b1147418254a
Overscan is now configurable
Michael Pavone <pavone@retrodev.com>
parents:
1162
diff
changeset
|
443 //TODO: PAL support |
2200
f11f4399d64b
Crop display in game gear mode
Michael Pavone <pavone@retrodev.com>
parents:
2197
diff
changeset
|
444 if (sms->vdp->type == VDP_GAMEGEAR) { |
f11f4399d64b
Crop display in game gear mode
Michael Pavone <pavone@retrodev.com>
parents:
2197
diff
changeset
|
445 render_set_video_standard(VID_GAMEGEAR); |
f11f4399d64b
Crop display in game gear mode
Michael Pavone <pavone@retrodev.com>
parents:
2197
diff
changeset
|
446 } else { |
f11f4399d64b
Crop display in game gear mode
Michael Pavone <pavone@retrodev.com>
parents:
2197
diff
changeset
|
447 render_set_video_standard(VID_NTSC); |
f11f4399d64b
Crop display in game gear mode
Michael Pavone <pavone@retrodev.com>
parents:
2197
diff
changeset
|
448 } |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
449 while (!sms->should_return) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
450 { |
1480
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
451 if (system->delayed_load_slot) { |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
452 load_state(system, system->delayed_load_slot - 1); |
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
453 system->delayed_load_slot = 0; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
454 |
1480
8464a3f09b94
Get SMS savestates working in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1478
diff
changeset
|
455 } |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
456 if (sms->vdp->frame != sms->last_frame) { |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
457 #ifndef IS_LIB |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
458 if (sms->psg->scope) { |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
459 scope_render(sms->psg->scope); |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
460 } |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
461 #endif |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
462 uint32_t elapsed = sms->vdp->frame - sms->last_frame; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
463 sms->last_frame = sms->vdp->frame; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
464 if (system->enter_debugger_frames) { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
465 if (elapsed >= system->enter_debugger_frames) { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
466 system->enter_debugger_frames = 0; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
467 system->enter_debugger = 1; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
468 } else { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
469 system->enter_debugger_frames -= elapsed; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
470 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
471 } |
2194
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2179
diff
changeset
|
472 |
2179
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
473 if(exit_after){ |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
474 if (elapsed >= exit_after) { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
475 exit(0); |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
476 } else { |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
477 exit_after -= elapsed; |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
478 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
479 } |
9a8dd4ba2753
Implement frame advance debugger command
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
480 } |
2424
767ec72acca7
Avoid conflicts between watchpoints and normal debugger entry
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
481 if ((system->enter_debugger || sms->z80->wp_hit) && sms->z80->pc) { |
767ec72acca7
Avoid conflicts between watchpoints and normal debugger entry
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
482 if (!sms->z80->wp_hit) { |
767ec72acca7
Avoid conflicts between watchpoints and normal debugger entry
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
483 system->enter_debugger = 0; |
767ec72acca7
Avoid conflicts between watchpoints and normal debugger entry
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
484 } |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
485 #ifndef IS_LIB |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1126
diff
changeset
|
486 zdebugger(sms->z80, sms->z80->pc); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
487 #endif |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1126
diff
changeset
|
488 } |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
489 #ifdef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
490 if (sms->z80->nmi_cycle == CYCLE_NEVER) { |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
491 #else |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
492 if (sms->z80->nmi_start == CYCLE_NEVER) { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
493 #endif |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
494 uint32_t nmi = vdp_next_nmi(sms->vdp); |
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
495 if (nmi != CYCLE_NEVER) { |
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
496 z80_assert_nmi(sms->z80, nmi); |
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
497 } |
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
498 } |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2384
diff
changeset
|
499 |
2424
767ec72acca7
Avoid conflicts between watchpoints and normal debugger entry
Michael Pavone <pavone@retrodev.com>
parents:
2400
diff
changeset
|
500 if (system->enter_debugger || sms->z80->wp_hit) { |
2400
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2384
diff
changeset
|
501 target_cycle = sms->z80->Z80_CYCLE + 1; |
c97609fe8315
Implement watchpoints in Z80 debugger
Michael Pavone <pavone@retrodev.com>
parents:
2384
diff
changeset
|
502 } |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
503 z80_run(sms->z80, target_cycle); |
1209
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
504 if (sms->z80->reset) { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
505 z80_clear_reset(sms->z80, sms->z80->Z80_CYCLE + 128*15); |
1209
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
506 } |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
507 target_cycle = sms->z80->Z80_CYCLE; |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
508 vdp_run_context(sms->vdp, target_cycle); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
509 psg_run(sms->psg, target_cycle); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
510 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
511 if (system->save_state) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
512 while (!sms->z80->pc) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
513 //advance Z80 to an instruction boundary |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
514 z80_run(sms->z80, sms->z80->Z80_CYCLE + 1); |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
515 } |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
516 save_state(sms, system->save_state - 1); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
517 system->save_state = 0; |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
518 } |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
519 |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
520 target_cycle += 3420*16; |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 if (target_cycle > 0x10000000) { |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
522 uint32_t adjust = sms->z80->Z80_CYCLE - 3420*262*2; |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
523 io_adjust_cycles(sms->io.ports, sms->z80->Z80_CYCLE, adjust); |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
524 io_adjust_cycles(sms->io.ports+1, sms->z80->Z80_CYCLE, adjust); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
525 z80_adjust_cycles(sms->z80, adjust); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
526 vdp_adjust_cycles(sms->vdp, adjust); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
527 sms->psg->cycles -= adjust; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 target_cycle -= adjust; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
530 } |
1980
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1932
diff
changeset
|
531 if (sms->header.force_release || render_should_release_on_exit()) { |
1932
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
532 bindings_release_capture(); |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
533 vdp_release_framebuffer(sms->vdp); |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
534 render_pause_source(sms->psg->audio); |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
535 } |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
536 sms->should_return = 0; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
537 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
538 |
1401
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
539 static void resume_sms(system_header *system) |
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
540 { |
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
541 sms_context *sms = (sms_context *)system; |
1980
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1932
diff
changeset
|
542 if (sms->header.force_release || render_should_release_on_exit()) { |
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1932
diff
changeset
|
543 sms->header.force_release = 0; |
1932
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
544 bindings_reacquire_capture(); |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
545 vdp_reacquire_framebuffer(sms->vdp); |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
546 render_resume_source(sms->psg->audio); |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
547 } |
1401
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
548 run_sms(system); |
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
549 } |
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
550 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
551 static void start_sms(system_header *system, char *statefile) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
552 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
553 sms_context *sms = (sms_context *)system; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
554 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
555 z80_assert_reset(sms->z80, 0); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
556 z80_clear_reset(sms->z80, 128*15); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
557 |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
558 if (statefile) { |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
559 load_state_path(sms, statefile); |
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
560 } |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
561 |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1126
diff
changeset
|
562 if (system->enter_debugger) { |
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1126
diff
changeset
|
563 system->enter_debugger = 0; |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
564 #ifndef IS_LIB |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
565 zinsert_breakpoint(sms->z80, sms->z80->pc, (uint8_t *)zdebugger); |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
566 #endif |
1129
6b5c92b6205c
Enabled Z80 debugger in PBC mode
Michael Pavone <pavone@retrodev.com>
parents:
1126
diff
changeset
|
567 } |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
568 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
569 run_sms(system); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
570 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
571 |
1209
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
572 static void soft_reset(system_header *system) |
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
573 { |
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
574 sms_context *sms = (sms_context *)system; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
575 z80_assert_reset(sms->z80, sms->z80->Z80_CYCLE); |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
576 #ifndef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
577 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->Z80_CYCLE; |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
578 #endif |
1209
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
579 } |
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
580 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
581 static void free_sms(system_header *system) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
582 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
583 sms_context *sms = (sms_context *)system; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
584 vdp_free(sms->vdp); |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
585 z80_options_free(sms->z80->Z80_OPTS); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
586 free(sms->z80); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
587 psg_free(sms->psg); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
588 free(sms); |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
589 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
590 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
591 static uint16_t get_open_bus_value(system_header *system) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
592 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
593 return 0xFFFF; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
594 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
595 |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
596 static void request_exit(system_header *system) |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
597 { |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
598 sms_context *sms = (sms_context *)system; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
599 sms->should_return = 1; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
600 #ifndef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
601 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->Z80_CYCLE; |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
602 #endif |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
603 } |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
604 |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1119
diff
changeset
|
605 static void inc_debug_mode(system_header *system) |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1119
diff
changeset
|
606 { |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1119
diff
changeset
|
607 sms_context *sms = (sms_context *)system; |
1643
6909c5d0bbb5
Removed old VDP debug functionality
Michael Pavone <pavone@retrodev.com>
parents:
1640
diff
changeset
|
608 vdp_inc_debug_mode(sms->vdp); |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1119
diff
changeset
|
609 } |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1119
diff
changeset
|
610 |
1384
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
611 static void load_save(system_header *system) |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
612 { |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
613 //TODO: Implement me |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
614 } |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
615 |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
616 static void persist_save(system_header *system) |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
617 { |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
618 //TODO: Implement me |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
619 } |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
620 |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
621 static void gamepad_down(system_header *system, uint8_t gamepad_num, uint8_t button) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
622 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
623 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
624 if (gamepad_num == GAMEPAD_MAIN_UNIT) { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
625 if (button == MAIN_UNIT_PAUSE) { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
626 vdp_pbc_pause(sms->vdp); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
627 } |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
628 } else if (sms->vdp->type == VDP_GAMEGEAR && gamepad_num == 1 && button == BUTTON_START) { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
629 sms->start_button_region &= 0x7F; |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
630 } else { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
631 io_gamepad_down(&sms->io, gamepad_num, button); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
632 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
633 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
634 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
635 static void gamepad_up(system_header *system, uint8_t gamepad_num, uint8_t button) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
636 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
637 sms_context *sms = (sms_context *)system; |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
638 if (sms->vdp->type == VDP_GAMEGEAR && gamepad_num == 1 && button == BUTTON_START) { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
639 sms->start_button_region |= 0x80; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
640 } else { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
641 io_gamepad_up(&sms->io, gamepad_num, button); |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
642 } |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
643 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
644 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
645 static void mouse_down(system_header *system, uint8_t mouse_num, uint8_t button) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
646 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
647 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
648 io_mouse_down(&sms->io, mouse_num, button); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
649 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
650 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
651 static void mouse_up(system_header *system, uint8_t mouse_num, uint8_t button) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
652 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
653 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
654 io_mouse_up(&sms->io, mouse_num, button); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
655 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
656 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
657 static void mouse_motion_absolute(system_header *system, uint8_t mouse_num, uint16_t x, uint16_t y) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
658 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
659 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
660 io_mouse_motion_absolute(&sms->io, mouse_num, x, y); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
661 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
662 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
663 static void mouse_motion_relative(system_header *system, uint8_t mouse_num, int32_t x, int32_t y) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
664 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
665 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
666 io_mouse_motion_relative(&sms->io, mouse_num, x, y); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
667 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
668 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
669 static void keyboard_down(system_header *system, uint8_t scancode) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
670 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
671 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
672 io_keyboard_down(&sms->io, scancode); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
673 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
674 |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
675 static void keyboard_up(system_header *system, uint8_t scancode) |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
676 { |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
677 sms_context *sms = (sms_context *)system; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
678 io_keyboard_up(&sms->io, scancode); |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
679 } |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
680 |
1796
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
681 static void set_gain_config(sms_context *sms) |
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
682 { |
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
683 char *config_gain; |
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
684 config_gain = tern_find_path(config, "audio\0psg_gain\0", TVAL_PTR).ptrval; |
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
685 render_audio_source_gaindb(sms->psg->audio, config_gain ? atof(config_gain) : 0.0f); |
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
686 } |
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
687 |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
688 static void config_updated(system_header *system) |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
689 { |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
690 sms_context *sms = (sms_context *)system; |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
691 setup_io_devices(config, &system->info, &sms->io); |
2384
03e6ac327ba0
Handle changes to sample rate while content is running
Michael Pavone <pavone@retrodev.com>
parents:
2325
diff
changeset
|
692 //sample rate may have changed |
03e6ac327ba0
Handle changes to sample rate while content is running
Michael Pavone <pavone@retrodev.com>
parents:
2325
diff
changeset
|
693 psg_adjust_master_clock(sms->psg, sms->master_clock); |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
694 } |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
695 |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
696 static void toggle_debug_view(system_header *system, uint8_t debug_view) |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
697 { |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
698 #ifndef IS_LIB |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
699 sms_context *sms = (sms_context *)system; |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
700 if (debug_view < DEBUG_OSCILLOSCOPE) { |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
701 vdp_toggle_debug_view(sms->vdp, debug_view); |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
702 } else if (debug_view == DEBUG_OSCILLOSCOPE) { |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
703 if (sms->psg->scope) { |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
704 oscilloscope *scope = sms->psg->scope; |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
705 sms->psg->scope = NULL; |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
706 scope_close(scope); |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
707 } else { |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
708 oscilloscope *scope = create_oscilloscope(); |
2256
cbe1ba70c247
Fix build after scope clock fix
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
709 psg_enable_scope(sms->psg, scope, sms->normal_clock); |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
710 } |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
711 } |
2302
0343f0d5add0
Fix libretro build for real
Michael Pavone <pavone@retrodev.com>
parents:
2293
diff
changeset
|
712 #endif |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
713 } |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
714 |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
715 sms_context *alloc_configure_sms(system_media *media, uint32_t opts, uint8_t force_region) |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
716 { |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
717 sms_context *sms = calloc(1, sizeof(sms_context)); |
2320
8016dbb0fcde
Initial work on ROM DB support for SMS/GG games
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
718 tern_node *rom_db = get_rom_db(); |
8016dbb0fcde
Initial work on ROM DB support for SMS/GG games
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
719 const memmap_chunk base_map[] = { |
8016dbb0fcde
Initial work on ROM DB support for SMS/GG games
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
720 {0xC000, 0x10000, sizeof(sms->ram)-1, .flags = MMAP_READ|MMAP_WRITE|MMAP_CODE, .buffer = sms->ram} |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
721 }; |
2320
8016dbb0fcde
Initial work on ROM DB support for SMS/GG games
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
722 sms->header.info = configure_rom_sms(rom_db, media->buffer, media->size, base_map, sizeof(base_map)/sizeof(base_map[0])); |
8016dbb0fcde
Initial work on ROM DB support for SMS/GG games
Michael Pavone <pavone@retrodev.com>
parents:
2302
diff
changeset
|
723 uint32_t rom_size = sms->header.info.rom_size; |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
724 z80_options *zopts = malloc(sizeof(z80_options)); |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
725 tern_node *model_def; |
2202
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
726 uint8_t is_gamegear = !strcasecmp(media->extension, "gg"); |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
727 if (is_gamegear) { |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
728 model_def = tern_find_node(get_systems_config(), "gg"); |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
729 } else if (!strcasecmp(media->extension, "sg")) { |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
730 model_def = tern_find_node(get_systems_config(), "sg1000"); |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
731 } else { |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
732 model_def = get_model(config, SYSTEM_SMS); |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2256
diff
changeset
|
733 } |
2202
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
734 char *vdp_str = tern_find_ptr(model_def, "vdp"); |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
735 uint8_t vdp_type = is_gamegear ? VDP_GENESIS : VDP_GAMEGEAR; |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
736 if (vdp_str) { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
737 if (!strcmp(vdp_str, "sms1")) { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
738 vdp_type = VDP_SMS; |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
739 } else if (!strcmp(vdp_str, "sms2")) { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
740 vdp_type = VDP_SMS2; |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
741 } else if (!strcmp(vdp_str, "tms9918a")) { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
742 vdp_type = VDP_TMS9918A; |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
743 } else if (!strcmp(vdp_str, "gamegear")) { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
744 vdp_type = VDP_GAMEGEAR; |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
745 } else if (!strcmp(vdp_str, "genesis")) { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
746 vdp_type = VDP_GENESIS; |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
747 } else { |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
748 warning("Unrecognized VDP type %s\n", vdp_str); |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
749 } |
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
750 } |
2321
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
751 for (uint32_t i = 0; i < sms->header.info.map_chunks; i++) |
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
752 { |
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
753 memmap_chunk *chunk = sms->header.info.map + i; |
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
754 if ((chunk->flags == MMAP_READ) && !chunk->buffer && chunk->start > 0xC000) { |
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
755 chunk->buffer = sms->ram + ((chunk->start - 0xC000) & 0x1FFF); |
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
756 } |
2eda5f81f91e
More fully baked ROM db support for SMS
Michael Pavone <pavone@retrodev.com>
parents:
2320
diff
changeset
|
757 } |
2202
ee6d30c56eeb
Add separate model/IO selection settings for SMS/GG
Michael Pavone <pavone@retrodev.com>
parents:
2200
diff
changeset
|
758 if (is_gamegear) { |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
759 init_z80_opts(zopts, sms->header.info.map, sms->header.info.map_chunks, io_gg, 6, 15, 0xFF); |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
760 sms->start_button_region = 0xC0; |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
761 } else { |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
762 init_z80_opts(zopts, sms->header.info.map, sms->header.info.map_chunks, io_map, 4, 15, 0xFF); |
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
763 } |
1130
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1129
diff
changeset
|
764 sms->z80 = init_z80_context(zopts); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
765 sms->z80->system = sms; |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
766 sms->z80->Z80_OPTS->gen.debug_cmd_handler = debug_commands; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
767 |
1201
aee2177a1630
Use filename for game title in SMS mode
Michael Pavone <pavone@retrodev.com>
parents:
1184
diff
changeset
|
768 sms->rom = media->buffer; |
1141
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
769 sms->rom_size = rom_size; |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
770 if (sms->header.info.map_chunks > 2) { |
1141
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
771 sms->z80->mem_pointers[0] = sms->rom; |
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
772 sms->z80->mem_pointers[1] = sms->rom + 0x4000; |
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
773 sms->z80->mem_pointers[2] = sms->rom + 0x8000; |
1162
c4ea535cf57e
Forgot that the expansion to 32-bit values for 16-bit addresses is not done when calling a C function to handle a memory operation. Mask on location in mapper_write was needed afterall
Michael Pavone <pavone@retrodev.com>
parents:
1154
diff
changeset
|
774 sms->bank_regs[1] = 0; |
c4ea535cf57e
Forgot that the expansion to 32-bit values for 16-bit addresses is not done when calling a C function to handle a memory operation. Mask on location in mapper_write was needed afterall
Michael Pavone <pavone@retrodev.com>
parents:
1154
diff
changeset
|
775 sms->bank_regs[2] = 0x4000 >> 14; |
c4ea535cf57e
Forgot that the expansion to 32-bit values for 16-bit addresses is not done when calling a C function to handle a memory operation. Mask on location in mapper_write was needed afterall
Michael Pavone <pavone@retrodev.com>
parents:
1154
diff
changeset
|
776 sms->bank_regs[3] = 0x8000 >> 14; |
1141
7e199bebde2f
Initial support for Sega's family of SMS mappers
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
777 } |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
778 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
779 //TODO: Detect region and pick master clock based off of that |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
780 sms->normal_clock = sms->master_clock = 53693175; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
781 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
782 sms->psg = malloc(sizeof(psg_context)); |
1555
6ce36c3f250b
More audio refactoring in preparation for allowing proper sync to video with dynamic audio rate control
Michael Pavone <pavone@retrodev.com>
parents:
1551
diff
changeset
|
783 psg_init(sms->psg, sms->master_clock, 15*16); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
784 |
1796
51417bb557b6
Configurable gain for overall output and individual components
Michael Pavone <pavone@retrodev.com>
parents:
1759
diff
changeset
|
785 set_gain_config(sms); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
786 |
2195
40290a923886
Implement Game Gear start button and region register
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
787 sms->vdp = init_vdp_context(0, 0, vdp_type); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
788 sms->vdp->system = &sms->header; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
789 |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
790 sms->header.info.save_type = SAVE_NONE; |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
791 sms->header.info.name = strdup(media->name); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
792 |
2293
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
793 tern_node *io_config_root = config; |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
794 tern_node *sms_root = tern_find_node(config, "sms"); |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
795 if (sms_root) { |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
796 tern_node *io = tern_find_node(sms_root, "io"); |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
797 if (io) { |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
798 io_config_root = sms_root; |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
799 } |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
800 } |
3e0d463eb9b3
Actually use SMS specific controller config
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
801 setup_io_devices(io_config_root, &sms->header.info, &sms->io); |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
802 sms->header.has_keyboard = io_has_keyboard(&sms->io); |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
803 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
804 sms->header.set_speed_percent = set_speed_percent; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
805 sms->header.start_context = start_sms; |
1401
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1384
diff
changeset
|
806 sms->header.resume_context = resume_sms; |
1384
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
807 sms->header.load_save = load_save; |
1df16f5985f3
Added stub load_save and persist_save functions to SMS system so that we don't crash when switching games via the menu
Michael Pavone <pavone@retrodev.com>
parents:
1379
diff
changeset
|
808 sms->header.persist_save = persist_save; |
1433
c886c54d8cf1
Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
809 sms->header.load_state = load_state; |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
810 sms->header.free_context = free_sms; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
811 sms->header.get_open_bus_value = get_open_bus_value; |
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
812 sms->header.request_exit = request_exit; |
1209
5ee6b6345ea9
Implement SMS hardware soft reset (note only available on real hardware on the Genesis in PBC mode)
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
813 sms->header.soft_reset = soft_reset; |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1119
diff
changeset
|
814 sms->header.inc_debug_mode = inc_debug_mode; |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
815 sms->header.gamepad_down = gamepad_down; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
816 sms->header.gamepad_up = gamepad_up; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
817 sms->header.mouse_down = mouse_down; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
818 sms->header.mouse_up = mouse_up; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
819 sms->header.mouse_motion_absolute = mouse_motion_absolute; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
820 sms->header.mouse_motion_relative = mouse_motion_relative; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
821 sms->header.keyboard_down = keyboard_down; |
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1555
diff
changeset
|
822 sms->header.keyboard_up = keyboard_up; |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
823 sms->header.config_updated = config_updated; |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
824 sms->header.serialize = serialize; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
825 sms->header.deserialize = deserialize; |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2202
diff
changeset
|
826 sms->header.toggle_debug_view = toggle_debug_view; |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
827 sms->header.type = SYSTEM_SMS; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
828 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
829 return sms; |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
830 } |