@@ -96,7 +96,7 @@ static void __attribute__((section(".ramtext"))) padAbort(int pad) {
96
96
padBuffer [0 ] = 0xff ;
97
97
98
98
if (s_disable_slotChangeOnAbort ) {
99
- SIOS [0 ].ctrl = pad ? 0x2002 : 0x0002 ;
99
+ SIOS [0 ].ctrl = SIO_CTRL_DTR | ( pad ? SIO_CTRL_PORTSEL : 0x0000 ) ;
100
100
busyloop (10 );
101
101
}
102
102
SIOS [0 ].ctrl = 0 ;
@@ -106,21 +106,21 @@ static uint32_t __attribute__((section(".ramtext"))) readPad(int pad) {
106
106
uint8_t * * padBufferPtr = & s_padBufferPtrs [pad ];
107
107
uint8_t * padBuffer = * padBufferPtr ;
108
108
padBuffer [0 ] = 0xff ;
109
- uint16_t mask = pad == 0 ? 0x0000 : 0x2000 ;
110
- SIOS [0 ].ctrl = mask | 2 ;
109
+ uint16_t mask = pad == 0 ? 0x0000 : SIO_CTRL_PORTSEL ;
110
+ SIOS [0 ].ctrl = mask | SIO_CTRL_DTR ;
111
111
uint8_t * padOutputBuffer = s_padOutputBuffers [pad ]; // always NULL
112
112
// this test is reversed in retail; first dereference, then test for NULL
113
113
int doPadOutput = padOutputBuffer && * padOutputBuffer ? -1 : 0 ;
114
114
SIOS [0 ].fifo ; // throw away
115
115
busyloop (40 );
116
- SIOS [0 ].ctrl = mask | 0x1003 ;
117
- while (!(SIOS [0 ].stat & 1 ));
116
+ SIOS [0 ].ctrl = mask | SIO_CTRL_TXEN | SIO_CTRL_DTR | SIO_CTRL_ACKIRQEN ;
117
+ while (!(SIOS [0 ].stat & SIO_STAT_TXRDY ));
118
118
g_sio0Mask = mask ;
119
119
SIOS [0 ].fifo = 1 ;
120
120
busyloop (20 );
121
- SIOS [0 ].ctrl |= 0x10 ;
121
+ SIOS [0 ].ctrl |= SIO_CTRL_ERRRES ;
122
122
IREG = ~IRQ_CONTROLLER ;
123
- while (!(SIOS [0 ].stat & 2 ));
123
+ while (!(SIOS [0 ].stat & SIO_STAT_RXRDY ));
124
124
SIOS [0 ].fifo ; // throw away
125
125
busyloop (40 );
126
126
@@ -134,10 +134,10 @@ static uint32_t __attribute__((section(".ramtext"))) readPad(int pad) {
134
134
135
135
SIOS [0 ].fifo = 0x42 ;
136
136
busyloop (25 );
137
- SIOS [0 ].ctrl |= 0x10 ;
137
+ SIOS [0 ].ctrl |= SIO_CTRL_ERRRES ;
138
138
IREG = ~IRQ_CONTROLLER ;
139
139
140
- while (!(SIOS [0 ].stat & 2 ));
140
+ while (!(SIOS [0 ].stat & SIO_STAT_RXRDY ));
141
141
uint32_t fifoBytes = SIOS [0 ].fifo ;
142
142
padBuffer [1 ] = fifoBytes & 0xff ;
143
143
fifoBytes &= 0x0f ;
@@ -154,10 +154,10 @@ static uint32_t __attribute__((section(".ramtext"))) readPad(int pad) {
154
154
SIOS [0 ].fifo = 0 ;
155
155
busyloop (20 );
156
156
157
- SIOS [0 ].ctrl |= 0x10 ;
157
+ SIOS [0 ].ctrl |= SIO_CTRL_ERRRES ;
158
158
IREG = ~IRQ_CONTROLLER ;
159
159
160
- while (!(SIOS [0 ].stat & 2 ));
160
+ while (!(SIOS [0 ].stat & SIO_STAT_RXRDY ));
161
161
162
162
if (SIOS [0 ].fifo != 0x5a ) {
163
163
padAbort (pad );
@@ -177,13 +177,13 @@ static uint32_t __attribute__((section(".ramtext"))) readPad(int pad) {
177
177
SIOS [0 ].fifo = s_send_pad ? doPadOutput & padOutputBuffer [1 ] : doPadOutput && padOutputBuffer [1 ];
178
178
padOutputBuffer += 2 ;
179
179
busyloop (10 );
180
- SIOS [0 ].ctrl |= 0x10 ;
180
+ SIOS [0 ].ctrl |= SIO_CTRL_ERRRES ;
181
181
IREG = ~IRQ_CONTROLLER ;
182
182
183
183
cyclesWaited = 0 ;
184
- while (!(SIOS [0 ].stat & 2 )) {
184
+ while (!(SIOS [0 ].stat & SIO_STAT_RXRDY )) {
185
185
if (!(IREG & IRQ_CONTROLLER )) continue ;
186
- while (!(SIOS [0 ].stat & 2 ));
186
+ while (!(SIOS [0 ].stat & SIO_STAT_RXRDY ));
187
187
padAbort (pad );
188
188
return 0xffff ;
189
189
}
@@ -202,10 +202,10 @@ static uint32_t __attribute__((section(".ramtext"))) readPad(int pad) {
202
202
SIOS [0 ].fifo = s_send_pad ? doPadOutput & padOutputBuffer [0 ] : doPadOutput && padOutputBuffer [0 ];
203
203
busyloop (10 );
204
204
205
- SIOS [0 ].ctrl |= 0x10 ;
205
+ SIOS [0 ].ctrl |= SIO_CTRL_ERRRES ;
206
206
IREG = ~IRQ_CONTROLLER ;
207
207
208
- while (!(SIOS [0 ].stat & 2 ));
208
+ while (!(SIOS [0 ].stat & SIO_STAT_RXRDY ));
209
209
210
210
padBuffer [3 ] = SIOS [0 ].fifo ;
211
211
padBuffer += 2 ;
@@ -252,7 +252,7 @@ static void __attribute__((section(".ramtext"))) mcHandler(int v) {
252
252
g_sio0Mask = 0x2000 ;
253
253
}
254
254
255
- SIOS [0 ].ctrl |= g_sio0Mask | 0x0012 ;
255
+ SIOS [0 ].ctrl |= g_sio0Mask | SIO_CTRL_ERRRES | SIO_CTRL_DTR ;
256
256
int delay = g_mcHandlerDelayPatch ;
257
257
for (unsigned i = 0 ; i < delay ; i ++ ) __asm__ __volatile__("" );
258
258
@@ -316,9 +316,9 @@ static void __attribute__((section(".ramtext"))) firstStageCardAction() {
316
316
syscall_buLowLevelOpError2 ();
317
317
deliverEvent (EVENT_CARD , 0x0100 );
318
318
sysDeqIntRP (1 , & g_mcHandlerInfo );
319
- SIOS [0 ].ctrl = 0x40 ;
320
- SIOS [0 ].baudRate = 0x88 ;
321
- SIOS [0 ].mode = 13 ;
319
+ SIOS [0 ].ctrl = SIO_CTRL_IR ;
320
+ SIOS [0 ].baudRate = 2073600 / 15200 ;
321
+ SIOS [0 ].mode = 13 ; // MUL1, 8bit, no parity, normal polarity
322
322
SIOS [0 ].ctrl = 0 ;
323
323
return ;
324
324
}
@@ -378,14 +378,14 @@ int __attribute__((section(".ramtext"))) initPad(uint8_t* pad1Buffer, size_t pad
378
378
}
379
379
380
380
static void __attribute__((section (".ramtext" ))) setupSIO0 () {
381
- SIOS [0 ].ctrl = 0x40 ;
382
- SIOS [0 ].baudRate = 0x88 ;
381
+ SIOS [0 ].ctrl = SIO_CTRL_IR ;
382
+ SIOS [0 ].baudRate = 2073600 / 15200 ;
383
383
SIOS [0 ].mode = 13 ;
384
384
SIOS [0 ].ctrl = 0 ;
385
385
busyloop (10 );
386
- SIOS [0 ].ctrl = 2 ;
386
+ SIOS [0 ].ctrl = SIO_CTRL_DTR ;
387
387
busyloop (10 );
388
- SIOS [0 ].ctrl = 0x2002 ;
388
+ SIOS [0 ].ctrl = SIO_CTRL_PORTSEL | SIO_CTRL_DTR ;
389
389
busyloop (10 );
390
390
SIOS [0 ].ctrl = 0 ;
391
391
g_skipErrorOnNewCard = 0 ;
0 commit comments