platform ps2, handle audio similar to psp
[picodrive.git] / m68kif_cyclone.s
... / ...
CommitLineData
1@ vim:filetype=armasm
2
3.equ M68K_MEM_SHIFT, 16
4
5.global cyclone_checkpc
6.global cyclone_fetch8
7.global cyclone_fetch16
8.global cyclone_fetch32
9.global cyclone_read8
10.global cyclone_read16
11.global cyclone_read32
12.global cyclone_write8
13.global cyclone_write16
14.global cyclone_write32
15
16@ Warning: here we abuse the fact that we are only called
17@ from Cyclone, and assume that r7 contains context pointer.
18cyclone_checkpc:
19 ldr r1, [r7, #0x60] @ membase
20 sub r0, r0, r1
21 bic r0, r0, #0xff000000
22 bics r0, r0, #1
23 beq crashed
24
25 ldr r1, [r7, #0x6c] @ read16 map
26 mov r2, r0, lsr #M68K_MEM_SHIFT
27 ldr r1, [r1, r2, lsl #2]
28 movs r1, r1, lsl #1
29 bcs crashed
30
31 str r1, [r7, #0x60] @ membase
32 add r0, r0, r1
33 bx lr
34
35crashed:
36 stmfd sp!,{lr}
37 mov r1, r7
38 bl cyclone_crashed
39 ldr r0, [r7, #0x40] @ reload PC + membase
40 ldmfd sp!,{pc}
41
42
43cyclone_read8: @ u32 a
44cyclone_fetch8:
45 bic r0, r0, #0xff000000
46 ldr r1, [r7, #0x68] @ read8 map
47 mov r2, r0, lsr #M68K_MEM_SHIFT
48 ldr r1, [r1, r2, lsl #2]
49 eor r2, r0, #1
50 movs r1, r1, lsl #1
51 ldrccb r0, [r1, r2]
52 bxcc lr
53 bx r1
54
55
56cyclone_read16: @ u32 a
57cyclone_fetch16:
58 bic r0, r0, #0xff000000
59 ldr r1, [r7, #0x6c] @ read16 map
60 mov r2, r0, lsr #M68K_MEM_SHIFT
61 ldr r1, [r1, r2, lsl #2]
62 bic r0, r0, #1
63 movs r1, r1, lsl #1
64 ldrcch r0, [r1, r0]
65 bxcc lr
66 bx r1
67
68
69cyclone_read32: @ u32 a
70cyclone_fetch32:
71 bic r0, r0, #0xff000000
72 ldr r1, [r7, #0x6c] @ read16 map
73 mov r2, r0, lsr #M68K_MEM_SHIFT
74 ldr r1, [r1, r2, lsl #2]
75 bic r0, r0, #1
76 movs r1, r1, lsl #1
77 ldrcch r0, [r1, r0]!
78 ldrcch r1, [r1, #2]
79 orrcc r0, r1, r0, lsl #16
80 bxcc lr
81
82 stmfd sp!,{r0,r1,lr}
83 mov lr, pc
84 bx r1
85 mov r2, r0, lsl #16
86 ldmia sp, {r0,r1}
87 str r2, [sp]
88 add r0, r0, #2
89 mov lr, pc
90 bx r1
91 ldr r1, [sp]
92 mov r0, r0, lsl #16
93 orr r0, r1, r0, lsr #16
94 ldmfd sp!,{r1,r2,pc}
95
96
97cyclone_write8: @ u32 a, u8 d
98 bic r0, r0, #0xff000000
99 ldr r2, [r7, #0x74] @ write8 map
100 mov r3, r0, lsr #M68K_MEM_SHIFT
101 ldr r2, [r2, r3, lsl #2]
102 eor r3, r0, #1
103 movs r2, r2, lsl #1
104 strccb r1, [r2, r3]
105 bxcc lr
106 bx r2
107
108
109cyclone_write16: @ u32 a, u16 d
110 bic r0, r0, #0xff000000
111 ldr r2, [r7, #0x78] @ write16 map
112 mov r3, r0, lsr #M68K_MEM_SHIFT
113 ldr r2, [r2, r3, lsl #2]
114 bic r0, r0, #1
115 movs r2, r2, lsl #1
116 strcch r1, [r2, r0]
117 bxcc lr
118 bx r2
119
120
121cyclone_write32: @ u32 a, u32 d
122 bic r0, r0, #0xff000000
123 ldr r2, [r7, #0x78] @ write16 map
124 mov r3, r0, lsr #M68K_MEM_SHIFT
125 ldr r2, [r2, r3, lsl #2]
126 bic r0, r0, #1
127 movs r2, r2, lsl #1
128 movcc r3, r1, lsr #16
129 strcch r3, [r2, r0]!
130 strcch r1, [r2, #2]
131 bxcc lr
132
133 stmfd sp!,{r0-r2,lr}
134 mov r1, r1, lsr #16
135 mov lr, pc
136 bx r2
137 ldmfd sp!,{r0-r2,lr}
138 add r0, r0, #2
139 bx r2
140