1 @ vim:filetype=armasm
\r
3 @ (c) Copyright 2006-2009, Grazvydas "notaz" Ignotas
\r
4 @ All Rights Reserved
\r
7 @@ .include "port_config.s"
\r
9 .equ SRR_MAPPED, (1 << 0)
\r
10 .equ SRR_READONLY, (1 << 1)
\r
11 .equ SRF_EEPROM, (1 << 1)
\r
12 .equ POPT_6BTN_PAD, (1 << 5)
\r
13 .equ POPT_EN_32X, (1 << 20)
\r
18 .global PicoRead8_sram
\r
19 .global PicoRead8_io
\r
20 .global PicoRead16_sram
\r
21 .global PicoRead16_io
\r
22 .global PicoWrite8_io
\r
23 .global PicoWrite16_io
\r
25 PicoRead8_sram: @ u32 a, u32 d
\r
27 ldr r3, =(Pico+0x22200)
\r
28 ldr r1, [r2, #8] @ SRam.end
\r
31 ldr r1, [r2, #4] @ SRam.start
\r
34 ldrb r1, [r3, #0x11] @ Pico.m.sram_reg
\r
40 ldr r1, [r2, #4] @ SRam.start
\r
41 ldr r2, [r2] @ SRam.data
\r
48 ldr r1, [r3, #4] @ romsize
\r
51 bxgt lr @ bad location
\r
52 @ XXX: banking unfriendly
\r
63 moveq r0, r0, lsr #8
\r
67 PicoRead8_io: @ u32 a, u32 d
\r
68 bic r2, r0, #0x001f @ most commonly we get i/o port read,
\r
69 cmp r2, #0xa10000 @ so check for it first
\r
74 beq m_read8_misc_hwreg
\r
79 ldr r3, =(Pico+0x22000)
\r
80 mov r0, r0, lsr #1 @ other IO ports (Pico.ioports[a])
\r
85 ldr r3, =(Pico+0x22200)
\r
86 ldrb r0, [r3, #0x0f] @ Pico.m.hardware
\r
94 ldr r3, =(Pico+0x22200)
\r
96 ldr r0, [r3, #8] @ Pico.m.rotate
\r
99 eor r0, r0, r0, lsl #6
\r
102 bxne lr @ odd addr -> open bus
\r
103 bic r0, r0, #1 @ bit0 defined in this area
\r
104 and r2, r1, #0xff00
\r
106 bxne lr @ not busreq
\r
108 ldrb r1, [r3, #(8+0x01)] @ Pico.m.z80Run
\r
109 ldrb r2, [r3, #(8+0x0f)] @ Pico.m.z80_reset
\r
117 tst r2, #POPT_EN_32X
\r
122 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
124 PicoRead16_sram: @ u32 a, u32 d
\r
126 ldr r3, =(Pico+0x22200)
\r
127 ldr r1, [r2, #8] @ SRam.end
\r
129 bgt m_read16_nosram
\r
130 ldr r1, [r2, #4] @ SRam.start
\r
132 blt m_read16_nosram
\r
133 ldrb r1, [r3, #0x11] @ Pico.m.sram_reg
\r
134 tst r1, #SRR_MAPPED
\r
135 beq m_read16_nosram
\r
136 ldr r1, [r2, #0x0c]
\r
137 tst r1, #SRF_EEPROM
\r
139 ldr r1, [r2, #4] @ SRam.start
\r
140 ldr r2, [r2] @ SRam.data
\r
145 orr r0, r0, r1, lsl #8
\r
149 ldr r1, [r3, #4] @ romsize
\r
152 bxgt lr @ bad location
\r
153 @ XXX: banking unfriendly
\r
159 PicoRead16_io: @ u32 a, u32 d
\r
160 bic r2, r0, #0x001f @ most commonly we get i/o port read,
\r
161 cmp r2, #0xa10000 @ so check for it first
\r
162 bne m_read16_not_io
\r
164 bl m_read8_misc_io @ same as read8
\r
165 orr r0, r0, r0, lsl #8 @ only has bytes mirrored
\r
169 and r2, r0, #0xfc00
\r
171 bne m_read16_not_brq
\r
173 ldr r3, =(Pico+0x22200)
\r
174 and r2, r0, #0xff00
\r
175 ldr r0, [r3, #8] @ Pico.m.rotate
\r
178 eor r0, r0, r0, lsl #5
\r
179 eor r0, r0, r0, lsl #8
\r
180 bic r0, r0, #0x100 @ bit8 defined in this area
\r
182 bxne lr @ not busreq
\r
184 ldrb r1, [r3, #(8+0x01)] @ Pico.m.z80Run
\r
185 ldrb r2, [r3, #(8+0x0f)] @ Pico.m.z80_reset
\r
186 orr r0, r0, r1, lsl #8
\r
187 orr r0, r0, r2, lsl #8
\r
193 tst r2, #POPT_EN_32X
\r
198 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
200 PicoWrite8_io: @ u32 a, u32 d
\r
201 bic r2, r0, #0x1e @ most commonly we get i/o port write,
\r
202 eor r2, r2, #0xa10000 @ so check for it first
\r
204 bne m_write8_not_io
\r
210 ldr r3, =(Pico+0x22000) @ Pico.ioports
\r
211 tst r2, #POPT_6BTN_PAD
\r
212 beq m_write8_io_done
\r
215 bne m_write8_io_done @ not likely to happen
\r
216 add r2, r3, #0x200 @ Pico+0x22200
\r
219 streqb r12,[r2,#0x18]
\r
220 strneb r12,[r2,#0x19] @ Pico.m.padDelay[i] = 0
\r
222 beq m_write8_io_done
\r
223 ldrb r12,[r3, r0, lsr #1]
\r
225 bne m_write8_io_done
\r
227 ldreqb r12,[r2,#0x0a]
\r
228 ldrneb r12,[r2,#0x0b] @ Pico.m.padTHPhase
\r
230 streqb r12,[r2,#0x0a]
\r
231 strneb r12,[r2,#0x0b] @ Pico.m.padTHPhase
\r
233 strb r1, [r3, r0, lsr #1]
\r
238 bne m_write8_not_z80ctl @ even addrs only
\r
239 and r2, r0, #0xff00
\r
242 beq ctl_write_z80busreq
\r
245 beq ctl_write_z80reset
\r
247 m_write8_not_z80ctl:
\r
249 eor r2, r0, #0xa10000
\r
250 eor r2, r2, #0x003000
\r
251 eors r2, r2, #0x0000f1
\r
252 bne m_write8_not_sreg
\r
253 ldr r3, =(Pico+0x22200)
\r
254 ldrb r2, [r3, #(8+9)] @ Pico.m.sram_reg
\r
255 and r1, r1, #(SRR_MAPPED|SRR_READONLY)
\r
256 bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
\r
258 strb r2, [r3, #(8+9)]
\r
264 tst r2, #POPT_EN_32X
\r
268 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
270 PicoWrite16_io: @ u32 a, u32 d
\r
271 bic r2, r0, #0x1f @ most commonly we get i/o port write,
\r
272 cmp r2, #0xa10000 @ so check for it first
\r
276 and r2, r0, #0xff00
\r
278 moveq r0, r1, lsr #8
\r
279 beq ctl_write_z80busreq
\r
281 moveq r0, r1, lsr #8
\r
282 beq ctl_write_z80reset
\r
284 m_write16_not_z80ctl:
\r
286 eor r2, r0, #0xa10000
\r
287 eor r2, r2, #0x003000
\r
288 eors r2, r2, #0x0000f0
\r
289 bne m_write16_not_sreg
\r
290 ldr r3, =(Pico+0x22200)
\r
291 ldrb r2, [r3, #(8+9)] @ Pico.m.sram_reg
\r
292 and r1, r1, #(SRR_MAPPED|SRR_READONLY)
\r
293 bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
\r
295 strb r2, [r3, #(8+9)]
\r
298 m_write16_not_sreg:
\r
301 tst r2, #POPT_EN_32X
\r
302 bne PicoWrite16_32x
\r