+.endm
+
+ari_read_io8:
+ ari_read_io ldrb, tab_read8, 2
+
+ari_read_io16:
+ ari_read_io ldrh, tab_read16, 1
+
+ari_read_io32:
+ ari_read_io ldr, tab_read32, 0
+
+.macro ari_write_io_old tab_shift
+.if \tab_shift == 0
+ b psxHwWrite32
+.endif
+.if \tab_shift == 1
+ b psxHwWrite16
+.endif
+.if \tab_shift == 2
+ b psxHwWrite8
+.endif
+.endm
+
+.macro ari_write_io pf var mem_tab tab_shift
+ ldr r0, [fp, #address-dynarec_local]
+ ldr\pf r1, [fp, #\var-dynarec_local]
+.if \tab_shift == 0
+ bic r0, r0, #3
+.endif
+.if \tab_shift == 1
+ bic r0, r0, #1
+.endif
+ bic r2, r0, #0x1f800000
+ ldr r12,[fp, #\mem_tab-dynarec_local]
+ subs r3, r2, #0x1000
+ blo 0f
+@ ari_write_io_old \tab_shift
+ cmp r3, #0x880
+ bhs 1f
+ ldr r12,[r12, r3, lsl #\tab_shift]
+ mov r0, r1
+ tst r12,r12
+ bxne r12
+0:
+ ldr r3, [fp, #psxH_ptr-dynarec_local]
+ str\pf r1, [r2, r3]
+ mov pc, lr
+1:
+.if \tab_shift == 1 @ write16
+ cmp r2, #0x1c00
+ blo 0b
+ cmp r2, #0x1e00
+ ldrlo pc, [fp, #spu_writef-dynarec_local]
+ nop
+.endif
+ b 0b
+.endm
+
+ari_write_io8:
+ @ PCSX always writes to psxH, so do we for consistency
+ ldr r0, [fp, #address-dynarec_local]
+ ldr r3, [fp, #psxH_ptr-dynarec_local]
+ ldrb r1, [fp, #byte-dynarec_local]
+ bic r2, r0, #0x1f800000
+ ldr r12,[fp, #tab_write8-dynarec_local]
+ strb r1, [r2, r3]
+ subs r3, r2, #0x1000
+ movlo pc, lr
+@ ari_write_io_old 2
+ cmp r3, #0x880
+ movhs pc, lr
+ ldr r12,[r12, r3, lsl #2]
+ mov r0, r1
+ tst r12,r12
+ bxne r12