Mercurial > repos > blastem
annotate lc8951.c @ 2457:9da3de58410d
Fix libretro build
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 21 Feb 2024 20:25:06 -0800 |
parents | 0871f555eff6 |
children |
rev | line source |
---|---|
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "lc8951.h" |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
2 #include "backend.h" |
2342
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
3 #include "cdimage.h" |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 enum { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 COMIN, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 IFSTAT, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 DBCL, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 DBCH, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 HEAD0, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 HEAD1, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 HEAD2, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 HEAD3, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 PTL, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 PTH, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 WAL, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 WAH, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 STAT0, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 STAT1, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 STAT2, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 STAT3, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 SBOUT = COMIN, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 IFCTRL = IFSTAT, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 DACL = HEAD0, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 DACH = HEAD1, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 DTTRG = HEAD2, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 DTACK = HEAD3, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 WAL_WRITE = PTL, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 WAH_WRITE = PTH, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 CTRL0 = WAL, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 CTRL1 = WAH, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 PTL_WRITE = STAT0, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 PTH_WRITE = STAT1, |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 RESET = STAT3 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 }; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 //IFCTRL |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 #define BIT_CMDIEN 0x80 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 #define BIT_DTEIEN 0x40 |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
41 #define BIT_DECIEN 0x20 |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 #define BIT_CMDBK 0x10 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 #define BIT_DTWAI 0x08 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 #define BIT_STWAI 0x04 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 #define BIT_DOUTEN 0x02 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 #define BIT_SOUTEN 0x01 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 //IFSTAT |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 #define BIT_CMDI 0x80 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 #define BIT_DTEI 0x40 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 #define BIT_DECI 0x20 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 #define BIT_DTBSY 0x08 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 #define BIT_STBSY 0x04 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 #define BIT_DTEN 0x02 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 #define BIT_STEN 0x01 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
57 //CTRL0 |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
58 #define BIT_DECEN 0x80 |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
59 #define BIT_EDCRQ 0x40 |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
60 #define BIT_WRRQ 0x04 |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
61 #define BIT_ORQ 0x02 |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
62 #define BIT_PRQ 0x01 |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
63 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
64 //CTRL1 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
65 #define BIT_SYIEN 0x80 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
66 #define BIT_SYDEN 0x40 |
2342
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
67 #define BIT_DSCREN 0x20 |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
68 |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
69 //STAT0 |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
70 #define BIT_CRCOK 0x80 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
71 #define BIT_ILSYNC 0x40 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
72 #define BIT_NOSYNC 0x20 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
73 #define BIT_LBLK 0x10 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
74 #define BIT_SBLK 0x04 |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
75 #define BIT_UCEBLK 0x01 |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
76 |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
77 //STAT3 |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
78 #define BIT_VALST 0x80 |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
79 #define BIT_WLONG 0x40 |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
80 |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 //datasheet timing info |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 //3 cycles for memory operation |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 //6 cycles min for DMA-mode host transfer |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
85 void lc8951_init(lc8951 *context, lcd8951_byte_recv_fun byte_handler, void *handler_data) |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 //This seems to vary somewhat between Sega CD models |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 //unclear if the difference is in the lc8951 or gate array |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 context->regs[IFSTAT] = 0xFF; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 context->ar_mask = 0x1F; |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
91 context->clock_step = (2 + 2); // external divider, internal divider |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
92 context->cycles_per_byte = context->clock_step * 6; |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
93 context->byte_handler = byte_handler; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
94 context->handler_data = handler_data; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
95 context->decode_end = CYCLE_NEVER; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
96 context->transfer_end = CYCLE_NEVER; |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
97 context->next_byte_cycle = CYCLE_NEVER; |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
98 } |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
99 |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
100 void lc8951_set_dma_multiple(lc8951 *context, uint32_t multiple) |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
101 { |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
102 context->cycles_per_byte = context->clock_step * multiple; |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
103 if (context->transfer_end != CYCLE_NEVER) { |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
104 uint16_t transfer_size = context->regs[DBCL] | (context->regs[DBCH] << 8); |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
105 context->transfer_end = context->next_byte_cycle + transfer_size * context->cycles_per_byte; |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
106 } |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 void lc8951_reg_write(lc8951 *context, uint8_t value) |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 switch (context->ar) |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 case SBOUT: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 context->regs[context->ar] = value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 if (context->ifctrl & BIT_SOUTEN) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 context->regs[IFSTAT] &= ~BIT_STBSY; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 case IFCTRL: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 context->ifctrl = value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 if (!(value & BIT_SOUTEN)) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 context->regs[IFSTAT] |= BIT_STBSY; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 if (!(value & BIT_DOUTEN)) { |
2066
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
125 context->regs[IFSTAT] |= BIT_DTBSY|BIT_DTEI; |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
126 context->transfer_end = CYCLE_NEVER; |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 case DBCL: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 context->regs[context->ar] = value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 case DBCH: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 context->regs[context->ar] = value & 0xF; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 case DACL: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 context->dac &= 0xFF00; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 context->dac |= value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 case DACH: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 context->dac &= 0xFF; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 context->dac |= value << 8; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 case DTTRG: |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
144 if (context->ifctrl & BIT_DOUTEN) { |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 context->regs[IFSTAT] &= ~BIT_DTBSY; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
146 uint16_t transfer_size = context->regs[DBCL] | (context->regs[DBCH] << 8); |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
147 context->transfer_end = context->cycle + transfer_size * context->cycles_per_byte; |
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
148 context->next_byte_cycle = context->cycle; |
2231
8e6fb2c06024
Fix CDC transfer regression
Michael Pavone <pavone@retrodev.com>
parents:
2153
diff
changeset
|
149 context->triggered = 1; |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
150 printf("DTTRG: size %u, cycle %u, end %u\n", transfer_size, context->cycle, context->transfer_end); |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 case DTACK: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 context->regs[IFSTAT] |= BIT_DTEI; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 case WAL_WRITE: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 context->regs[WAL] = value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 case WAH_WRITE: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 context->regs[WAH] = value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 break; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
162 case CTRL0: |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
163 context->ctrl0 = value; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
164 break; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
165 case CTRL1: |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
166 context->ctrl1 = value; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
167 break; |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 case PTL_WRITE: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 context->regs[PTL] = value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 case PTH_WRITE: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 context->regs[PTH] = value; |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
173 //TODO: Datasheet says any write to PT triggers a decode, but initial tests suggest that's not the case |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
174 //Need to do more tests with other CTRL0/CTRL1 settings |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
175 //context->decode_end = context->cycle + 2352 * context->clock_step * 4; |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 case RESET: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 context->comin_count = 0; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 context->regs[IFSTAT] = 0xFF; |
2080 | 180 context->ifctrl = 0; |
181 context->ctrl0 = 0; | |
182 context->ctrl1 = 0; | |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 default: |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 break; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 if (context->ar != SBOUT) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 context->ar++; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 context->ar &= context->ar_mask; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 uint8_t lc8951_reg_read(lc8951 *context) |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 uint8_t value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 if (context->ar == COMIN) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 if (!context->comin_count) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 return 0xFF; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 value = context->comin[(context->comin_write - context->comin_count)&sizeof(context->comin)]; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 context->comin_count--; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 if (!context->comin_count) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 context->regs[IFSTAT] |= BIT_CMDI; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 return value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 if (context->ar == STAT3) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 context->regs[IFSTAT] |= BIT_DECI; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 if (context->ar >= sizeof(context->regs)) { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 value = 0xFF; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 } else { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 value = context->regs[context->ar]; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 } |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
215 printf("CDC read %X: %X\n", context->ar, value); |
2058
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 context->ar++; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 context->ar &= context->ar_mask; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 return value; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 } |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 void lc8951_ar_write(lc8951 *context, uint8_t value) |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 { |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 context->ar = value & context->ar_mask; |
70260f6051dd
Initial work on CDC emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 } |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
225 |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
226 //25 MHz clock input (1/2 SCD MCLK) |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
227 //internal /2 divider |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
228 //3 cycles for each SRAM access (though might be crystal frequency rather than internal frequency) |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
229 //6 cycle period for DMA transfer out |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
230 // |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
231 |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
232 void lc8951_run(lc8951 *context, uint32_t cycle) |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
233 { |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
234 for(; context->cycle < cycle; context->cycle += context->clock_step) |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
235 { |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
236 if (context->cycle >= context->decode_end) { |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
237 context->decode_end = CYCLE_NEVER; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
238 context->regs[IFSTAT] &= ~BIT_DECI; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
239 context->regs[STAT3] &= ~BIT_VALST; |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
240 if (context->ctrl0 & BIT_WRRQ) { |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
241 uint16_t block_start = (context->regs[PTL] | (context->regs[PTH] << 8)) & (sizeof(context->buffer)-1); |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
242 for (int reg = HEAD0; reg < PTL; reg++) |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
243 { |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
244 printf("Setting header reg %X to %X: %X\n", reg, block_start, context->buffer[block_start]); |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
245 context->regs[reg] =context->buffer[block_start++]; |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
246 block_start &= (sizeof(context->buffer)-1); |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
247 } |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
248 } |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
249 printf("Decode done %X:%X:%X mode %X @ %u\n", context->regs[HEAD0], context->regs[HEAD1], context->regs[HEAD2], context->regs[HEAD3], context->cycle); |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
250 // This check is a hack until I properly implement error detection |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
251 if (context->regs[HEAD0] < 0x74 && (context->regs[HEAD0] & 0xF) < 0xA |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
252 && context->regs[HEAD1] < 0x60 && (context->regs[HEAD1] & 0xF) < 0xA |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
253 && context->regs[HEAD2] < 0x75 && (context->regs[HEAD2] & 0xF) < 0xA |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
254 && context->regs[HEAD3] < 3 && !(context->regs[STAT0] & (BIT_NOSYNC|BIT_ILSYNC)) |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
255 ) { |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
256 |
2153 | 257 if (context->ctrl0 & (BIT_WRRQ|BIT_ORQ|BIT_PRQ)) { |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
258 context->regs[STAT0] |= BIT_CRCOK; |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
259 } |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
260 context->regs[STAT1] = 0; |
2153 | 261 context->regs[STAT2] = 0x10; |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
262 } else { |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
263 if (context->ctrl0 & (BIT_EDCRQ|BIT_ORQ|BIT_PRQ)) { |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
264 context->regs[STAT0] |= BIT_UCEBLK; |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
265 } |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
266 context->regs[STAT1] = 0xFF; |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
267 context->regs[STAT2] = 0xF2; |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
268 } |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
269 context->regs[STAT3] |= BIT_WLONG; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
270 } |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
271 if (context->cycle >= context->next_byte_cycle) { |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
272 if (context->byte_handler(context->handler_data, context->buffer[context->dac & (sizeof(context->buffer)-1)])) { |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
273 context->next_byte_cycle += context->cycles_per_byte; |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
274 context->dac++; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
275 context->regs[DBCL]--; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
276 if (context->regs[DBCL] == 0xFF) { |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
277 context->regs[DBCH]--; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
278 if (context->regs[DBCH] == 0xFF) { |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
279 context->regs[IFSTAT] &= ~BIT_DTEI; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
280 context->regs[IFSTAT] |= BIT_DTBSY; |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
281 if (context->cycle != context->transfer_end) { |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
282 printf("Expected transfer end at %u but ended at %u\n", context->transfer_end, context->cycle); |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
283 } |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
284 context->transfer_end = CYCLE_NEVER; |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
285 context->next_byte_cycle = CYCLE_NEVER; |
2231
8e6fb2c06024
Fix CDC transfer regression
Michael Pavone <pavone@retrodev.com>
parents:
2153
diff
changeset
|
286 context->triggered = 0; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
287 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
288 } |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
289 } else { |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
290 // pause transfer |
2144
10e4439d8f13
Fix speed of CDC to PCM RAM DMA
Michael Pavone <pavone@retrodev.com>
parents:
2142
diff
changeset
|
291 context->next_byte_cycle = CYCLE_NEVER; |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
292 context->transfer_end = CYCLE_NEVER; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
293 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
294 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
295 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
296 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
297 |
2350
f8b5142c06aa
Allow 68K to return mid-instruction. Adjust how 68K interrupt ack works so int2 busy flag timing is more correct. Fix some other SCD timing issues
Michael Pavone <pavone@retrodev.com>
parents:
2342
diff
changeset
|
298 void lc8951_resume_transfer(lc8951 *context) |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
299 { |
2231
8e6fb2c06024
Fix CDC transfer regression
Michael Pavone <pavone@retrodev.com>
parents:
2153
diff
changeset
|
300 if (context->triggered && context->transfer_end == CYCLE_NEVER && (context->ifctrl & BIT_DOUTEN)) { |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
301 uint16_t transfer_size = context->regs[DBCL] | (context->regs[DBCH] << 8); |
2231
8e6fb2c06024
Fix CDC transfer regression
Michael Pavone <pavone@retrodev.com>
parents:
2153
diff
changeset
|
302 context->transfer_end = context->cycle + transfer_size * context->cycles_per_byte; |
8e6fb2c06024
Fix CDC transfer regression
Michael Pavone <pavone@retrodev.com>
parents:
2153
diff
changeset
|
303 context->next_byte_cycle = context->cycle; |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
304 } |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
305 } |
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
306 |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
307 void lc8951_write_byte(lc8951 *context, uint32_t cycle, int sector_offset, uint8_t byte) |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
308 { |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
309 lc8951_run(context, cycle); |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
310 uint16_t current_write_addr = context->regs[WAL] | (context->regs[WAH] << 8); |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
311 |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
312 uint8_t sync_detected = 0, sync_ignored = 0; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
313 if (byte == 0) { |
2342
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
314 if (context->sync_counter == 11) { |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
315 if (context->ctrl1 & BIT_SYDEN) { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
316 sync_detected = 1; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
317 } else { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
318 sync_ignored = 1; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
319 } |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
320 context->sync_counter = 0; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
321 } else { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
322 context->sync_counter = 1; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
323 } |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
324 } else if (byte == 0xFF && context->sync_counter) { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
325 context->sync_counter++; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
326 } else { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
327 context->sync_counter = 0; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
328 } |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
329 |
2342
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
330 //TODO: figure out if chip tries to avoid descrambling sync signal |
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
331 if (context->ctrl1 & BIT_DSCREN) { |
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
332 byte = cdrom_scramble(&context->scrambler_lsfr, byte); |
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
333 } |
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
334 |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
335 uint8_t sync_inserted = 0; |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
336 if (context->ctrl1 & BIT_SYIEN && context->sector_counter == 2351) { |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
337 sync_inserted = 1; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
338 } |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
339 |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
340 |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
341 if (context->sector_counter < 4) { |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
342 //TODO: Handle SHDREN = 1 |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
343 if ((context->ctrl0 & (BIT_DECEN|BIT_WRRQ)) == (BIT_DECEN)) { |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
344 //monitor only mode |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
345 context->regs[HEAD0 + context->sector_counter] = byte; |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
346 if (context->sector_counter == 3) { |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
347 printf("Monitoring sector %02d:%02d:%02d\n", context->regs[HEAD0], context->regs[HEAD1], context->regs[HEAD2]); |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
348 } |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
349 } else { |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
350 if (context->sector_counter == 3) { |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
351 printf("Writing sector %02d:%02d:%02d @ %u\n", |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
352 context->buffer[(current_write_addr - 3) & (sizeof(context->buffer)-1)], |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
353 context->buffer[(current_write_addr - 2) & (sizeof(context->buffer)-1)], |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
354 context->buffer[(current_write_addr - 1) & (sizeof(context->buffer)-1)], |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
355 context->cycle); |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
356 } |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
357 } |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
358 |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
359 } |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
360 |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
361 if (sync_detected || sync_inserted) { |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
362 //we've recevied the sync pattern for the next block |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
363 context->regs[STAT0] &= ~(BIT_ILSYNC | BIT_NOSYNC | BIT_LBLK | BIT_SBLK); |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
364 if (sync_inserted && !(sync_detected || sync_ignored)) { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
365 context->regs[STAT0] |= BIT_NOSYNC; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
366 } |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
367 if (sync_detected && context->sector_counter != 2351) { |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
368 context->regs[STAT0] |= BIT_ILSYNC; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
369 } |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
370 context->sector_counter = 0; |
2342
9f0c67e5c50a
Implement CD-ROM data sector scrambling/descrambling
Michael Pavone <pavone@retrodev.com>
parents:
2280
diff
changeset
|
371 context->scrambler_lsfr = 1; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
372 |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
373 //header/status regs no longer considered "valid" |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
374 context->regs[STAT3] |= BIT_VALST; |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
375 //!DECI is set inactive at the same time as !VALST |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
376 context->regs[IFSTAT] |= BIT_DECI; |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
377 //clear error detection status bits |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
378 context->regs[STAT0] &= ~(BIT_CRCOK|BIT_UCEBLK); |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
379 context->regs[STAT3] &= ~BIT_WLONG; |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
380 if (context->ctrl0 & BIT_DECEN) { |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
381 if (context->ctrl0 & BIT_WRRQ) { |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
382 uint16_t block_start = current_write_addr + 1 - 2352; |
2067
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
383 context->regs[PTL] = block_start; |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
384 context->regs[PTH] = block_start >> 8; |
f22e04b69272
More CDC/CDD improvements
Michael Pavone <pavone@retrodev.com>
parents:
2066
diff
changeset
|
385 } |
2419
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
386 printf("Decoding block starting at %X (WRRQ: %d, sector_offset: %X), current write address: %X @ %u\n", context->regs[PTL] | (context->regs[PTH] << 8), !!(context->ctrl0 & BIT_WRRQ), sector_offset, current_write_addr, context->cycle); |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
387 //Based on mcd-verificator results on an MCD2 with LC89515 |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
388 //value seems to be between ~132500 and ~133500 |
0871f555eff6
Fix some CD-ROM emulation issues and make timing better match my MCD2. Seems to fix or at least improve video playback in Iron Helix and Power Rangers
Michael Pavone <pavone@retrodev.com>
parents:
2350
diff
changeset
|
389 context->decode_end = context->cycle + 133000 * context->clock_step; |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
390 } |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
391 } else { |
2142
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
392 context->sector_counter++; |
d9151d0894c7
Fix some CD-ROM emulation issues
Michael Pavone <pavone@retrodev.com>
parents:
2131
diff
changeset
|
393 context->sector_counter &= 0xFFF; |
2130
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
394 if (sync_ignored) { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
395 context->regs[STAT0] |= BIT_SBLK; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
396 } |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
397 if (context->sector_counter == 2352) { |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
398 context->regs[STAT0] |= BIT_LBLK; |
28b6453cf7e3
Emulate CDC sync detection and sync insertion rather than relying on external knowledge about sector offset
Michael Pavone <pavone@retrodev.com>
parents:
2122
diff
changeset
|
399 } |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
400 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
401 if ((context->ctrl0 & (BIT_DECEN|BIT_WRRQ)) == (BIT_DECEN|BIT_WRRQ)) { |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
402 context->buffer[current_write_addr & (sizeof(context->buffer)-1)] = byte; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
403 context->regs[WAL]++; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
404 if (!context->regs[WAL]) { |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
405 context->regs[WAH]++; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
406 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
407 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
408 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
409 |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
410 uint32_t lc8951_next_interrupt(lc8951 *context) |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
411 { |
2065
02a9846668d1
Implement transfer of data from CDC to elsewhere. Other miscellaneous CDD/CDC improvements
Michael Pavone <pavone@retrodev.com>
parents:
2062
diff
changeset
|
412 if ((~context->regs[IFSTAT]) & context->ifctrl & (BIT_CMDI|BIT_DTEI|BIT_DECI)) { |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
413 //interrupt already pending |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
414 return context->cycle; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
415 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
416 uint32_t deci_cycle = CYCLE_NEVER; |
2131
d90d92ce5cab
Improve CDC decode timing accuracy
Michael Pavone <pavone@retrodev.com>
parents:
2130
diff
changeset
|
417 if (context->ifctrl & BIT_DECIEN) { |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
418 deci_cycle = context->decode_end; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
419 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
420 uint32_t dtei_cycle = CYCLE_NEVER; |
2131
d90d92ce5cab
Improve CDC decode timing accuracy
Michael Pavone <pavone@retrodev.com>
parents:
2130
diff
changeset
|
421 if (context->ifctrl & BIT_DTEIEN) { |
2062
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
422 dtei_cycle = context->transfer_end; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
423 } |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
424 return deci_cycle < dtei_cycle ? deci_cycle : dtei_cycle; |
07ed42bd7b4c
Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents:
2058
diff
changeset
|
425 } |
2066
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
426 |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
427 void lc8951_adjust_cycles(lc8951 *context, uint32_t deduction) |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
428 { |
2073
c69e42444f96
Fix some cycle adjustment stuff and an off-by one on hte TOCT response
Michael Pavone <pavone@retrodev.com>
parents:
2067
diff
changeset
|
429 printf("CDC deduction of %u cycles @ %u, ", deduction, context->cycle); |
c69e42444f96
Fix some cycle adjustment stuff and an off-by one on hte TOCT response
Michael Pavone <pavone@retrodev.com>
parents:
2067
diff
changeset
|
430 context->cycle -= deduction; |
2066
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
431 if (context->decode_end != CYCLE_NEVER) { |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
432 context->decode_end -= deduction; |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
433 } |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
434 if (context->transfer_end != CYCLE_NEVER) { |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
435 context->transfer_end -= deduction; |
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
436 } |
2147
4cd60eecb0b1
Fix LC8951 cycle adjustment for data transfer next byte tracking
Michael Pavone <pavone@retrodev.com>
parents:
2144
diff
changeset
|
437 if (context->next_byte_cycle != CYCLE_NEVER) { |
4cd60eecb0b1
Fix LC8951 cycle adjustment for data transfer next byte tracking
Michael Pavone <pavone@retrodev.com>
parents:
2144
diff
changeset
|
438 context->next_byte_cycle -= deduction; |
4cd60eecb0b1
Fix LC8951 cycle adjustment for data transfer next byte tracking
Michael Pavone <pavone@retrodev.com>
parents:
2144
diff
changeset
|
439 } |
2073
c69e42444f96
Fix some cycle adjustment stuff and an off-by one on hte TOCT response
Michael Pavone <pavone@retrodev.com>
parents:
2067
diff
changeset
|
440 printf("cycle is now %u, decode_end %u, transfer_end %u\n", context->cycle, context->decode_end, context->transfer_end); |
2066
a61a8a87410c
Fix a bunch of CDC/CDD related mcd-verificator failures
Michael Pavone <pavone@retrodev.com>
parents:
2065
diff
changeset
|
441 } |
2280
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
442 |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
443 void lc8951_serialize(lc8951 *context, serialize_buffer *buf) |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
444 { |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
445 save_int32(buf, context->cycle); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
446 save_int32(buf, context->decode_end); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
447 save_int32(buf, context->transfer_end); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
448 save_int32(buf, context->next_byte_cycle); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
449 save_int16(buf, context->sector_counter); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
450 save_buffer8(buf, context->buffer, sizeof(context->buffer)); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
451 save_buffer8(buf, context->regs, sizeof(context->regs)); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
452 save_buffer8(buf, context->comin, sizeof(context->comin)); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
453 save_int16(buf, context->dac); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
454 save_int8(buf, context->comin_write); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
455 save_int8(buf, context->comin_count); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
456 save_int8(buf, context->ifctrl); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
457 save_int8(buf, context->ctrl0); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
458 save_int8(buf, context->ctrl1); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
459 save_int8(buf, context->ar); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
460 save_int8(buf, context->ar_mask); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
461 save_int8(buf, context->triggered); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
462 save_int8(buf, context->sync_counter); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
463 } |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
464 |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
465 void lc8951_deserialize(deserialize_buffer *buf, void *vcontext) |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
466 { |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
467 lc8951 *context = vcontext; |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
468 context->cycle = load_int32(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
469 context->decode_end = load_int32(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
470 context->transfer_end = load_int32(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
471 context->next_byte_cycle = load_int32(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
472 context->sector_counter = load_int16(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
473 load_buffer8(buf, context->buffer, sizeof(context->buffer)); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
474 load_buffer8(buf, context->regs, sizeof(context->regs)); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
475 load_buffer8(buf, context->comin, sizeof(context->comin)); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
476 context->dac = load_int16(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
477 context->comin_write = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
478 context->comin_count = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
479 context->ifctrl = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
480 context->ctrl0 = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
481 context->ctrl1 = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
482 context->ar = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
483 context->ar_mask = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
484 context->triggered = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
485 context->sync_counter = load_int8(buf); |
9ead0fe69d9b
Implement savestate support for Sega CD
Michael Pavone <pavone@retrodev.com>
parents:
2265
diff
changeset
|
486 } |