sovereignx/asm/dma3_manager.s

559 lines
8.2 KiB
ArmAsm
Raw Normal View History

thumb_func_start ClearDma3Requests
2015-10-10 11:12:48 +01:00
; void ClearDma3Requests()
ClearDma3Requests: ; 8000BB8
2015-10-06 13:46:30 +01:00
push {lr}
2015-10-10 18:22:31 +01:00
ldr r2, =gDma3ManagerLocked
2015-10-06 13:46:30 +01:00
movs r0, 0x1
strb r0, [r2]
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3RequestCursor
2015-10-06 13:46:30 +01:00
movs r0, 0
strb r0, [r1]
movs r3, 0
2015-10-10 18:22:31 +01:00
ldr r0, =gDma3Requests
2015-10-06 13:46:30 +01:00
movs r1, 0x7F
2015-10-10 11:12:48 +01:00
@loop:
2015-10-06 13:46:30 +01:00
strh r3, [r0, 0x8]
str r3, [r0]
str r3, [r0, 0x4]
adds r0, 0x10
subs r1, 0x1
cmp r1, 0
2015-10-10 11:12:48 +01:00
bge @loop
2015-10-06 13:46:30 +01:00
movs r0, 0
strb r0, [r2]
pop {r0}
bx r0
.align 2, 0
.pool
thumb_func_end ClearDma3Requests
2015-10-06 13:46:30 +01:00
thumb_func_start ProcessDma3Requests
2015-10-10 11:12:48 +01:00
; void ProcessDma3Requests()
ProcessDma3Requests: ; 8000BF0
2015-10-06 13:46:30 +01:00
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
2015-10-10 18:22:31 +01:00
ldr r0, =gDma3ManagerLocked
2015-10-06 13:46:30 +01:00
ldrb r0, [r0]
cmp r0, 0
2015-10-10 11:12:48 +01:00
beq @08000C06
b @08000E46
@08000C06:
2015-10-06 13:46:30 +01:00
movs r0, 0
str r0, [sp, 0x8]
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3Requests
ldr r2, =gDma3RequestCursor
2015-10-06 13:46:30 +01:00
ldrb r0, [r2]
lsls r0, 4
adds r0, r1
ldrh r0, [r0, 0x8]
mov r12, r2
cmp r0, 0
2015-10-10 11:12:48 +01:00
bne @08000C1E
b @08000E46
@08000C1E:
2015-10-06 13:46:30 +01:00
mov r8, r1
adds r1, 0x4
mov r10, r1
movs r6, 0x80
lsls r6, 5
2015-10-10 18:28:00 +01:00
ldr r7, =REG_DMA3
2015-10-06 13:46:30 +01:00
movs r2, 0
mov r9, r2
2015-10-10 11:12:48 +01:00
@08000C2E:
2015-10-06 13:46:30 +01:00
mov r3, r12
ldrb r0, [r3]
lsls r5, r0, 4
mov r0, r8
adds r1, r5, r0
ldrh r0, [r1, 0x8]
ldr r2, [sp, 0x8]
adds r0, r2, r0
lsls r0, 16
lsrs r0, 16
str r0, [sp, 0x8]
movs r0, 0xA0
lsls r0, 8
ldr r3, [sp, 0x8]
cmp r3, r0
2015-10-10 11:12:48 +01:00
bls @08000C50
b @08000E46
@08000C50:
2015-10-10 18:28:00 +01:00
ldr r0, =REG_VCOUNT
2015-10-06 13:46:30 +01:00
ldrb r0, [r0]
cmp r0, 0xE0
2015-10-10 11:12:48 +01:00
bls @08000C5A
b @08000E46
@08000C5A:
2015-10-06 13:46:30 +01:00
ldrh r0, [r1, 0xA]
cmp r0, 0x2
2015-10-10 11:12:48 +01:00
beq @08000CD0
2015-10-06 13:46:30 +01:00
cmp r0, 0x2
2015-10-10 11:12:48 +01:00
bgt @08000C80
2015-10-06 13:46:30 +01:00
cmp r0, 0x1
2015-10-10 11:12:48 +01:00
beq @08000C8C
b @08000DF0
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000C80:
2015-10-06 13:46:30 +01:00
cmp r0, 0x3
2015-10-10 11:12:48 +01:00
beq @08000D3C
2015-10-06 13:46:30 +01:00
cmp r0, 0x4
2015-10-10 11:12:48 +01:00
bne @08000C8A
b @08000D88
@08000C8A:
b @08000DF0
@08000C8C:
2015-10-06 13:46:30 +01:00
ldr r3, [r1]
mov r2, r10
adds r0, r5, r2
ldr r2, [r0]
ldrh r1, [r1, 0x8]
cmp r1, r6
2015-10-10 11:12:48 +01:00
bhi @08000CA6
2015-10-06 13:46:30 +01:00
str r3, [r7]
str r2, [r7, 0x4]
lsrs r0, r1, 2
movs r1, 0x84
lsls r1, 24
2015-10-10 11:12:48 +01:00
b @08000DAA
@08000CA6:
2015-10-10 18:28:00 +01:00
ldr r4, =REG_DMA3
2015-10-06 13:46:30 +01:00
str r3, [r4]
str r2, [r4, 0x4]
ldr r0, =0x84000400
str r0, [r4, 0x8]
ldr r0, [r4, 0x8]
adds r3, r6
adds r2, r6
subs r1, r6
cmp r1, r6
2015-10-10 11:12:48 +01:00
bhi @08000CA6
2015-10-06 13:46:30 +01:00
str r3, [r4]
str r2, [r4, 0x4]
lsrs r0, r1, 2
movs r1, 0x84
lsls r1, 24
2015-10-10 11:12:48 +01:00
b @08000D76
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000CD0:
2015-10-06 13:46:30 +01:00
mov r3, r10
adds r0, r5, r3
ldr r4, [r0]
ldrh r1, [r1, 0x8]
cmp r1, r6
2015-10-10 11:12:48 +01:00
bhi @08000CF4
2015-10-06 13:46:30 +01:00
mov r0, r8
adds r0, 0xC
adds r0, r5, r0
ldr r0, [r0]
str r0, [sp]
mov r5, sp
str r5, [r7]
str r4, [r7, 0x4]
lsrs r0, r1, 2
movs r1, 0x85
lsls r1, 24
2015-10-10 11:12:48 +01:00
b @08000DAA
@08000CF4:
2015-10-06 13:46:30 +01:00
mov r2, r12
ldrb r0, [r2]
lsls r0, 4
mov r5, r8
adds r5, 0xC
adds r0, r5
ldr r0, [r0]
str r0, [sp]
2015-10-10 18:28:00 +01:00
ldr r3, =REG_DMA3
2015-10-06 13:46:30 +01:00
mov r0, sp
str r0, [r3]
str r4, [r3, 0x4]
ldr r0, =0x85000400
str r0, [r3, 0x8]
ldr r0, [r3, 0x8]
adds r4, r6
subs r1, r6
cmp r1, r6
2015-10-10 11:12:48 +01:00
bhi @08000CF4
2015-10-06 13:46:30 +01:00
ldrb r0, [r2]
lsls r0, 4
adds r0, r5
ldr r0, [r0]
str r0, [sp]
mov r2, sp
str r2, [r3]
str r4, [r3, 0x4]
lsrs r0, r1, 2
movs r1, 0x85
lsls r1, 24
2015-10-10 11:12:48 +01:00
b @08000DEA
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000D3C:
2015-10-06 13:46:30 +01:00
ldr r3, [r1]
mov r2, r10
adds r0, r5, r2
ldr r2, [r0]
ldrh r1, [r1, 0x8]
cmp r1, r6
2015-10-10 11:12:48 +01:00
bhi @08000D56
2015-10-06 13:46:30 +01:00
str r3, [r7]
str r2, [r7, 0x4]
lsrs r0, r1, 1
movs r1, 0x80
lsls r1, 24
2015-10-10 11:12:48 +01:00
b @08000DAA
@08000D56:
2015-10-10 18:28:00 +01:00
ldr r4, =REG_DMA3
2015-10-06 13:46:30 +01:00
str r3, [r4]
str r2, [r4, 0x4]
ldr r0, =0x80000800
str r0, [r4, 0x8]
ldr r0, [r4, 0x8]
adds r3, r6
adds r2, r6
subs r1, r6
cmp r1, r6
2015-10-10 11:12:48 +01:00
bhi @08000D56
2015-10-06 13:46:30 +01:00
str r3, [r4]
str r2, [r4, 0x4]
lsrs r0, r1, 1
movs r1, 0x80
lsls r1, 24
2015-10-10 11:12:48 +01:00
@08000D76:
2015-10-06 13:46:30 +01:00
orrs r0, r1
str r0, [r4, 0x8]
ldr r0, [r4, 0x8]
2015-10-10 11:12:48 +01:00
b @08000DF0
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000D88:
2015-10-06 13:46:30 +01:00
mov r3, r10
adds r0, r5, r3
ldr r2, [r0]
ldrh r4, [r1, 0x8]
add r1, sp, 0x4
cmp r4, r6
2015-10-10 11:12:48 +01:00
bhi @08000DB2
2015-10-06 13:46:30 +01:00
mov r0, r8
adds r0, 0xC
adds r0, r5, r0
ldr r0, [r0]
strh r0, [r1]
str r1, [r7]
str r2, [r7, 0x4]
lsrs r0, r4, 1
movs r1, 0x81
lsls r1, 24
2015-10-10 11:12:48 +01:00
@08000DAA:
2015-10-06 13:46:30 +01:00
orrs r0, r1
str r0, [r7, 0x8]
ldr r0, [r7, 0x8]
2015-10-10 11:12:48 +01:00
b @08000DF0
@08000DB2:
2015-10-06 13:46:30 +01:00
mov r5, r12
ldrb r0, [r5]
lsls r0, 4
ldr r3, =0x0300001c
adds r0, r3
ldr r0, [r0]
strh r0, [r1]
2015-10-10 18:28:00 +01:00
ldr r3, =REG_DMA3
2015-10-06 13:46:30 +01:00
str r1, [r3]
str r2, [r3, 0x4]
ldr r0, =0x81000800
str r0, [r3, 0x8]
ldr r0, [r3, 0x8]
adds r2, r6
subs r4, r6
cmp r4, r6
2015-10-10 11:12:48 +01:00
bhi @08000DB2
2015-10-06 13:46:30 +01:00
ldrb r0, [r5]
lsls r0, 4
ldr r5, =0x0300001c
adds r0, r5
ldr r0, [r0]
strh r0, [r1]
str r1, [r3]
str r2, [r3, 0x4]
lsrs r0, r4, 1
movs r1, 0x81
lsls r1, 24
2015-10-10 11:12:48 +01:00
@08000DEA:
2015-10-06 13:46:30 +01:00
orrs r0, r1
str r0, [r3, 0x8]
ldr r0, [r3, 0x8]
2015-10-10 11:12:48 +01:00
@08000DF0:
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3Requests
2015-10-06 13:46:30 +01:00
mov r3, r12
ldrb r0, [r3]
lsls r0, 4
adds r0, r1
mov r2, r9
str r2, [r0]
ldrb r0, [r3]
lsls r0, 4
add r0, r10
str r2, [r0]
ldrb r0, [r3]
lsls r0, 4
adds r0, r1
movs r4, 0
strh r2, [r0, 0x8]
ldrb r0, [r3]
lsls r0, 4
adds r0, r1
mov r5, r9
strh r5, [r0, 0xA]
ldrb r0, [r3]
lsls r0, 4
adds r1, 0xC
adds r0, r1
mov r1, r9
str r1, [r0]
ldrb r0, [r3]
adds r0, 0x1
strb r0, [r3]
lsls r0, 24
cmp r0, 0
2015-10-10 11:12:48 +01:00
bge @08000E34
2015-10-06 13:46:30 +01:00
strb r4, [r3]
2015-10-10 11:12:48 +01:00
@08000E34:
2015-10-06 13:46:30 +01:00
mov r2, r12
ldrb r0, [r2]
lsls r0, 4
2015-10-10 18:22:31 +01:00
ldr r3, =gDma3Requests
2015-10-06 13:46:30 +01:00
adds r0, r3
ldrh r0, [r0, 0x8]
cmp r0, 0
2015-10-10 11:12:48 +01:00
beq @08000E46
b @08000C2E
@08000E46:
2015-10-06 13:46:30 +01:00
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
.pool
thumb_func_end ProcessDma3Requests
2015-10-06 13:46:30 +01:00
thumb_func_start RequestDma3Copy
2015-10-10 11:12:48 +01:00
; int RequestDma3Copy(void *src, void *dest, u16 size, u8 mode)
RequestDma3Copy: ; 8000E68
2015-10-06 13:46:30 +01:00
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
mov r12, r0
mov r8, r1
lsls r2, 16
lsrs r7, r2, 16
lsls r3, 24
lsrs r4, r3, 24
movs r5, 0
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3ManagerLocked
2015-10-06 13:46:30 +01:00
movs r0, 0x1
strb r0, [r1]
2015-10-10 18:22:31 +01:00
ldr r0, =gDma3RequestCursor
2015-10-06 13:46:30 +01:00
ldrb r2, [r0]
mov r10, r1
2015-10-10 18:22:31 +01:00
ldr r6, =gDma3Requests
2015-10-06 13:46:30 +01:00
mov r9, r6
lsls r0, r2, 4
adds r1, r0, r6
2015-10-10 11:12:48 +01:00
@08000E94:
2015-10-06 13:46:30 +01:00
lsls r3, r2, 4
ldrh r0, [r1, 0x8]
cmp r0, 0
2015-10-10 11:12:48 +01:00
bne @08000ED4
2015-10-06 13:46:30 +01:00
mov r0, r12
str r0, [r1]
mov r0, r9
adds r0, 0x4
adds r0, r3, r0
mov r3, r8
str r3, [r0]
strh r7, [r1, 0x8]
cmp r4, 0x1
2015-10-10 11:12:48 +01:00
bne @08000EC0
2015-10-06 13:46:30 +01:00
strh r4, [r1, 0xA]
2015-10-10 11:12:48 +01:00
b @08000EC4
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000EC0:
2015-10-06 13:46:30 +01:00
movs r0, 0x3
strh r0, [r1, 0xA]
2015-10-10 11:12:48 +01:00
@08000EC4:
2015-10-06 13:46:30 +01:00
movs r0, 0
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3ManagerLocked
2015-10-06 13:46:30 +01:00
strb r0, [r1]
lsls r0, r2, 16
asrs r0, 16
2015-10-10 11:12:48 +01:00
b @08000EF0
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000ED4:
2015-10-06 13:46:30 +01:00
adds r1, 0x10
adds r2, 0x1
cmp r2, 0x7F
2015-10-10 11:12:48 +01:00
ble @08000EE0
2015-10-06 13:46:30 +01:00
adds r1, r6, 0
movs r2, 0
2015-10-10 11:12:48 +01:00
@08000EE0:
2015-10-06 13:46:30 +01:00
adds r5, 0x1
cmp r5, 0x7F
2015-10-10 11:12:48 +01:00
ble @08000E94
2015-10-06 13:46:30 +01:00
movs r0, 0
mov r3, r10
strb r0, [r3]
movs r0, 0x1
negs r0, r0
2015-10-10 11:12:48 +01:00
@08000EF0:
2015-10-06 13:46:30 +01:00
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end RequestDma3Copy
2015-10-06 13:46:30 +01:00
thumb_func_start RequestDma3Fill
2015-10-10 11:12:48 +01:00
; int RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode)
RequestDma3Fill: ; 8000F00
2015-10-06 13:46:30 +01:00
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
mov r9, r0
mov r8, r1
lsls r2, 16
lsrs r7, r2, 16
lsls r3, 24
lsrs r5, r3, 24
movs r6, 0
2015-10-10 18:22:31 +01:00
ldr r0, =gDma3RequestCursor
2015-10-06 13:46:30 +01:00
ldrb r2, [r0]
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3ManagerLocked
2015-10-06 13:46:30 +01:00
movs r0, 0x1
strb r0, [r1]
mov r10, r1
2015-10-10 18:22:31 +01:00
ldr r0, =gDma3Requests
2015-10-06 13:46:30 +01:00
mov r12, r0
mov r4, r12
lsls r0, r2, 4
adds r0, 0x8
adds r1, r0, r4
2015-10-10 11:12:48 +01:00
@loop:
2015-10-06 13:46:30 +01:00
lsls r3, r2, 4
ldrh r0, [r1]
cmp r0, 0
2015-10-10 11:12:48 +01:00
bne @08000F78
2015-10-06 13:46:30 +01:00
adds r0, r4, 0x4
adds r0, r3, r0
mov r6, r8
str r6, [r0]
strh r7, [r1]
strh r5, [r1, 0x2]
adds r0, r4, 0
adds r0, 0xC
adds r0, r3, r0
mov r3, r9
str r3, [r0]
cmp r5, 0x1
2015-10-10 11:12:48 +01:00
bne @08000F64
2015-10-06 13:46:30 +01:00
movs r0, 0x2
2015-10-10 11:12:48 +01:00
b @08000F66
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000F64:
2015-10-06 13:46:30 +01:00
movs r0, 0x4
2015-10-10 11:12:48 +01:00
@08000F66:
2015-10-06 13:46:30 +01:00
strh r0, [r1, 0x2]
movs r0, 0
2015-10-10 18:22:31 +01:00
ldr r6, =gDma3ManagerLocked
2015-10-06 13:46:30 +01:00
strb r0, [r6]
lsls r0, r2, 16
asrs r0, 16
2015-10-10 11:12:48 +01:00
b @08000F96
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000F78:
2015-10-06 13:46:30 +01:00
adds r1, 0x10
adds r2, 0x1
cmp r2, 0x7F
2015-10-10 11:12:48 +01:00
ble @08000F86
2015-10-06 13:46:30 +01:00
mov r1, r12
adds r1, 0x8
movs r2, 0
2015-10-10 11:12:48 +01:00
@08000F86:
2015-10-06 13:46:30 +01:00
adds r6, 0x1
cmp r6, 0x7F
2015-10-10 11:12:48 +01:00
ble @loop
2015-10-06 13:46:30 +01:00
movs r0, 0
mov r1, r10
strb r0, [r1]
movs r0, 0x1
negs r0, r0
2015-10-10 11:12:48 +01:00
@08000F96:
2015-10-06 13:46:30 +01:00
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end RequestDma3Fill
2015-10-06 13:46:30 +01:00
thumb_func_start CheckForSpaceForDma3Request
2015-10-10 11:12:48 +01:00
; int CheckForSpaceForDma3Request(s16 index)
CheckForSpaceForDma3Request: ; 8000FA4
2015-10-06 13:46:30 +01:00
push {lr}
movs r2, 0
lsls r0, 16
asrs r1, r0, 16
movs r3, 0x1
negs r3, r3
cmp r1, r3
2015-10-10 11:12:48 +01:00
bne @08000FCC
2015-10-10 18:22:31 +01:00
ldr r1, =gDma3Requests
2015-10-10 11:12:48 +01:00
@08000FB6:
2015-10-06 13:46:30 +01:00
ldrh r0, [r1, 0x8]
cmp r0, 0
2015-10-10 11:12:48 +01:00
bne @08000FD8
2015-10-06 13:46:30 +01:00
adds r1, 0x10
adds r2, 0x1
cmp r2, 0x7F
2015-10-10 11:12:48 +01:00
ble @08000FB6
@08000FC4:
2015-10-06 13:46:30 +01:00
movs r0, 0
2015-10-10 11:12:48 +01:00
b @08000FDC
2015-10-06 13:46:30 +01:00
.align 2, 0
.pool
2015-10-10 11:12:48 +01:00
@08000FCC:
2015-10-10 18:22:31 +01:00
ldr r0, =gDma3Requests
2015-10-06 13:46:30 +01:00
lsls r1, 4
adds r1, r0
ldrh r0, [r1, 0x8]
cmp r0, 0
2015-10-10 11:12:48 +01:00
beq @08000FC4
@08000FD8:
2015-10-06 13:46:30 +01:00
movs r0, 0x1
negs r0, r0
2015-10-10 11:12:48 +01:00
@08000FDC:
2015-10-06 13:46:30 +01:00
pop {r1}
bx r1
.align 2, 0
.pool
thumb_func_end CheckForSpaceForDma3Request