8 .global ssp_block_table
9 .global ssp_block_table_iram
11 .global flush_inval_caches
14 .global ssp_drc_next_patch
18 .global ssp_hle_07_030
19 .global ssp_hle_07_036
20 .global ssp_hle_07_6d6
21 .global ssp_hle_11_12c
22 .global ssp_hle_11_384
23 .global ssp_hle_11_38a
25 @ translation cache buffer + pointer table
28 .size tcache, SSP_TCACHE_SIZE
29 .size ssp_block_table, SSP_BLOCKTAB_SIZE
30 .size ssp_block_table_iram, SSP_BLOCKTAB_IRAM_SIZE
32 .space SSP_TCACHE_SIZE
34 .space SSP_BLOCKTAB_SIZE
36 .space SSP_BLOCKTAB_IRAM_SIZE
37 .space SSP_BLOCKTAB_ALIGN_SIZE
45 mov r2, #0x0 @ must be 0
50 @ SSP_GR0, SSP_X, SSP_Y, SSP_A,
51 @ SSP_ST, SSP_STACK, SSP_PC, SSP_P,
52 @ SSP_PM0, SSP_PM1, SSP_PM2, SSP_XST,
53 @ SSP_PM4, SSP_gr13, SSP_PMC, SSP_AL
58 @ r6: STACK and emu flags: sss0 * .uu. .lll NZCV (NZCV is PSR bits from ARM)
66 #define SSP_OFFS_GR 0x400
71 #define SSP_OFFS_PM_WRITE 0x46c // pmac_write[]
72 #define SSP_OFFS_EMUSTAT 0x484 // emu_status
73 #define SSP_OFFS_IRAM_ROM 0x48c // ptr_iram_rom
74 #define SSP_OFFS_DRAM 0x490 // ptr_dram
75 #define SSP_OFFS_IRAM_DIRTY 0x494
76 #define SSP_OFFS_IRAM_CTX 0x498 // iram_context
77 #define SSP_OFFS_BLTAB 0x49c // block_table
78 #define SSP_OFFS_BLTAB_IRAM 0x4a0
79 #define SSP_OFFS_TMP0 0x4a4 // for entry PC
80 #define SSP_OFFS_TMP1 0x4a8
81 #define SSP_OFFS_TMP2 0x4ac
82 #define SSP_WAIT_PM0 0x2000
85 .macro ssp_drc_do_next patch_jump=0
87 str lr, [r7, #SSP_OFFS_TMP2] @ jump instr. (actually call) address + 4
91 str r0, [r7, #SSP_OFFS_TMP0]
95 ldr r2, [r7, #SSP_OFFS_BLTAB]
96 ldr r2, [r2, r0, lsl #2]
103 bl ssp_translate_block
105 ldr r0, [r7, #SSP_OFFS_TMP0] @ entry PC
106 ldr r1, [r7, #SSP_OFFS_BLTAB]
107 str r2, [r1, r0, lsl #2]
115 ldr r1, [r7, #SSP_OFFS_IRAM_DIRTY]
117 ldreq r1, [r7, #SSP_OFFS_IRAM_CTX]
118 beq 1f @ ssp_de_iram_ctx
120 bl ssp_get_iram_context
122 str r1, [r7, #SSP_OFFS_IRAM_DIRTY]
124 str r1, [r7, #SSP_OFFS_IRAM_CTX]
125 ldr r0, [r7, #SSP_OFFS_TMP0] @ entry PC
127 1: @ ssp_de_iram_ctx:
128 ldr r2, [r7, #SSP_OFFS_BLTAB_IRAM]
129 add r2, r2, r1, lsl #12 @ block_tab_iram + iram_context * 0x800/2*4
130 add r1, r2, r0, lsl #2
138 str r1, [r7, #SSP_OFFS_TMP1]
139 bl ssp_translate_block
141 ldr r0, [r7, #SSP_OFFS_TMP0] @ entry PC
142 ldr r1, [r7, #SSP_OFFS_TMP1] @ &block_table_iram[iram_context][rPC]
149 .endm @ ssp_drc_do_next
153 stmfd sp!, {r4-r11, lr}
160 ldmia r2, {r3,r4,r5,r6,r8}
163 orr r4, r3, r4, lsr #16 @ XXYY
165 and r8, r8, #0x0f0000
166 mov r8, r8, lsl #13 @ sss0 *
167 and r9, r6, #0x670000
171 orrne r8, r8, #0x4 @ sss0 * NZ..
172 orr r6, r8, r9, lsr #12 @ sss0 * .uu. .lll NZ..
174 ldr r8, [r7, #0x440] @ r0-r2
175 ldr r9, [r7, #0x444] @ r4-r6
176 ldr r10,[r7, #(0x400+SSP_P*4)] @ P
178 ldr r0, [r7, #(SSP_OFFS_GR+SSP_PC*4)]
190 ldr r1, [r7, #SSP_OFFS_TMP2] @ jump instr. (actually call) address + 4
192 moveq r3, #0xe1000000
193 orreq r3, r3, #0x00a00000 @ nop
200 streq r3, [r1, #-4] @ move the other cond up
201 moveq r3, #0xe1000000
202 orreq r3, r3, #0x00a00000
203 streq r3, [r1] @ fill it's place with nop
209 bic r3, r3, #1 @ L bit
210 orr r3, r3, r12,lsl #6
211 mov r3, r3, ror #8 @ patched branch instruction
215 str r2, [r7, #SSP_OFFS_TMP1]
218 bl flush_inval_caches
219 ldr r2, [r7, #SSP_OFFS_TMP1]
220 ldr r0, [r7, #SSP_OFFS_TMP0]
226 str r0, [r7, #(SSP_OFFS_GR+SSP_PC*4)]
229 str r10,[r7, #(0x400+SSP_P*4)] @ P
230 str r8, [r7, #0x440] @ r0-r2
231 str r9, [r7, #0x444] @ r4-r6
234 and r9, r9, #(7<<16) @ STACK
236 msr cpsr_flg, r3 @ to to ARM PSR
239 orrmi r6, r6, #0x80000000 @ N
240 orreq r6, r6, #0x20000000 @ Z
242 mov r3, r4, lsl #16 @ Y
244 mov r2, r2, lsl #16 @ X
247 stmia r8, {r2,r3,r5,r6,r9}
250 ldmfd sp!, {r4-r11, lr}
259 ldr r0, [r7, #(SSP_OFFS_GR+SSP_PM0*4)]
260 ldr r1, [r7, #SSP_OFFS_EMUSTAT]
262 orreq r1, r1, #SSP_WAIT_PM0
264 streq r1, [r7, #SSP_OFFS_EMUSTAT]
271 .macro hle_flushflags
274 orr r6, r6, r1, lsr #28
278 sub r6, r6, #0x20000000
280 add r1, r1, #0x048 @ stack
281 add r1, r1, r6, lsr #28
291 ldr r3, [r7, #SSP_OFFS_IRAM_ROM]
292 add r2, r3, r0, lsl #1 @ (r7|00)
297 add r3, r3, r0, lsl #1 @ IRAM dest
298 ldrh r12,[r2], #2 @ length
299 bic r3, r3, #3 @ always seen aligned
300 @ orr r5, r5, #0x08000000
301 @ orr r5, r5, #0x00880000
302 @ sub r5, r5, r12, lsl #16
306 str r0, [r7, #SSP_OFFS_IRAM_DIRTY]
307 sub r11,r11,r12,lsl #1
308 sub r11,r11,r12 @ -= length*3
314 orr r0, r0, r1, lsl #16
322 ldr r0, [r7, #SSP_OFFS_IRAM_ROM]
326 strh r2, [r1] @ (r7|00)
330 orr r0, r0, #0x08000000
331 orr r0, r0, #0x001c8000
332 str r0, [r7, #(SSP_OFFS_GR+SSP_PMC*4)]
333 str r0, [r7, #(SSP_OFFS_PM_WRITE+4*4)]
336 subs r11,r11,#16 @ timeslice is likely to end
341 @ this one is car rendering related
342 .macro hle_11_12c_mla offs_in
343 ldrsh r5, [r7, #(\offs_in+0)]
344 ldrsh r0, [r7, #(\offs_in+2)]
345 ldrsh r1, [r7, #(\offs_in+4)]
347 ldrsh r12,[r7, #(\offs_in+6)]
350 add r5, r5, r12,lsl #11
353 add r1, r7, r8, lsr #23
374 mov r2, r2, asr #15 @ (r7|00) << 1
376 mov r3, r3, asr #15 @ (r7|01) << 1
378 mov r4, r4, asr #15 @ (r7|10) << 1
406 mov r2, #0 @ EFh, EEh
408 add r0, r7, #0x1c0 @ r0 (based)
414 eor r5, r5, r5, asr #31
415 add r5, r5, r5, lsr #31 @ abs(r5)
417 orrpl r2, r2, r1,lsl #16 @ EFh |= r4
422 orrpl r2, r2, r1,lsl #16 @ EFh |= r4
432 bpl ssp_hle_11_38x_loop
437 orr r8, r8, r0, lsr #1
443 sub r11,r11,#(9+30*4)
452 and r0, r8, #0xff @ assuming alignment
453 add r0, r7, r0, lsl #1
455 mov r1, r1, lsl #16 @ 106h << 16
456 mov r2, r2, lsl #16 @ 107h << 16
461 bmi ssp_hle_07_6d6_end
467 bmi ssp_hle_07_6d6_loop
469 b ssp_hle_07_6d6_loop
476 orr r1, r2, r1, lsr #16
486 orr r0, r0, r0, lsr #16
491 ldr r1, [r7, #0x1e0] @ F1h F0h
492 rsb r5, r1, r1, lsr #16
493 mov r5, r5, lsl #16 @ AL not needed
496 bmi hle_07_036_ending2
497 ldr r1, [r7, #0x1dc] @ EEh
504 strh r0, [r1, #0xea] @ F5h
505 ldr r0, [r7, #0x1e0] @ F0h
507 strh r0, [r1, #0xf0] @ F8h
508 add r2, r0, #0xc0 @ r2
509 add r2, r7, r2, lsl #1
515 @ will handle PMC later
516 ldr r0, [r7, #0x1e8] @ F5h << 16
517 ldr r1, [r7, #0x1f0] @ F8h
518 ldr r2, [r7, #0x1d4] @ EAh
520 add r0, r0, r1, lsl #16
521 sub r0, r2, r0, asr #18
523 rsbs r0, r0, #0x78 @ length
524 ble hle_07_036_ending1
529 ldr r1, [r7, #(SSP_OFFS_GR+SSP_PMC*4)]
530 ldr r2, [r7, #SSP_OFFS_DRAM]
532 add r1, r2, r1, lsr #15 @ addr (based)
533 ldrh r2, [r7, #0] @ pattern
534 ldrh r3, [r7, #6] @ mode
539 subnes r12,r12,#0x0400
542 orr r2, r2, r2, lsl #16
548 strneh r2, [r1], #0x3e @ align
561 strne r2, [r1], #0x40
564 b hle_07_036_end_copy
568 orreq r12,r12,#0x000f
570 orreq r12,r12,#0x00f0
572 orreq r12,r12,#0x0f00
574 orreq r12,r12,#0xf000
575 orrs r12,r12,r12,lsl #16
576 beq hle_07_036_no_ovrwr
583 strh r3, [r1], #0x3e @ align
606 ldr r2, [r7, #SSP_OFFS_DRAM]
608 sub r0, r1, r2 @ new addr
610 strh r0, [r3, #(0x6c+4*4)] @ SSP_OFFS_PM_WRITE+4*4 (low)
613 ldr r0, [r7, #0x1e0] @ F1h << 16
616 add r0, r0, #(0xc4<<16)
617 bic r8, r8, #0xff0000
619 add r0, r7, r0, lsr #15
625 ldr r1, [r7, #4] @ new mode
627 strh r1, [r2, #(0x6c+4*4+2)] @ SSP_OFFS_PM_WRITE+4*4 (high)
641 b ssp_drc_next @ let the dispatcher finish this