.include "macros.inc"
.section .text, "ax"
.global DBClose
DBClose:
blr
.global DBOpen
DBOpen:
blr
.global DBWrite
DBWrite:
mflr r0
stw r0, 4(r1)
stwu r1, -0x78(r1)
stmw r24, 0x58(r1)
addi r26, r3, 0
addi r27, r4, 0
bl OSDisableInterrupts
addi r28, r3, 0
lis r25, 0xCC006828@ha
lis r31, 0x4000
lbl_800AE590:
lwz r0, 0xCC006828@l(r25)
addi r30, r25, 0x6800
addi r3, r1, 0x50
andi. r0, r0, 0x405
li r4, 2
li r5, 1
ori r0, r0, 0xc0
stwu r0, 0x28(r30)
stw r31, 0x50(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r24, r0, 5
lbl_800AE5C0:
addi r29, r25, 0x6800
lwzu r0, 0x34(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE5C0
addi r3, r1, 0x54
li r4, 4
li r5, 0
bl DBGEXIImm
lbl_800AE5E0:
lwz r0, 0(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE5E0
lwz r0, 0(r30)
andi. r0, r0, 0x405
stw r0, 0(r30)
lwz r0, 0x54(r1)
rlwinm. r0, r0, 0, 0x1e, 0x1e
bne lbl_800AE590
lbz r3, SendCount@sda21(r13)
addi r0, r3, 1
stb r0, SendCount@sda21(r13)
lbz r0, SendCount@sda21(r13)
clrlwi. r0, r0, 0x1f
beq lbl_800AE624
li r3, 0x1000
b lbl_800AE628
lbl_800AE624:
li r3, 0
lbl_800AE628:
addi r0, r27, 3
oris r25, r3, 1
rlwinm r24, r0, 0, 0, 0x1d
ori r25, r25, 0xc000
lbl_800AE638:
addi r3, r25, 0
addi r4, r26, 0
addi r5, r24, 0
bl DBGWrite
cmpwi r3, 0
beq lbl_800AE638
lis r31, 0x4000
lbl_800AE654:
lwz r0, 0(r30)
addi r3, r1, 0x4c
li r4, 2
andi. r0, r0, 0x405
li r5, 1
ori r0, r0, 0xc0
stw r0, 0(r30)
stw r31, 0x4c(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r26, r0, 5
lbl_800AE680:
lwz r0, 0(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE680
addi r3, r1, 0x54
li r4, 4
li r5, 0
bl DBGEXIImm
lbl_800AE69C:
lwz r0, 0(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE69C
lwz r0, 0(r30)
andi. r0, r0, 0x405
stw r0, 0(r30)
lwz r0, 0x54(r1)
rlwinm. r0, r0, 0, 0x1e, 0x1e
bne lbl_800AE654
lbz r0, SendCount@sda21(r13)
slwi r0, r0, 0x10
oris r0, r0, 0x1f00
or r0, r0, r27
clrlwi r0, r0, 3
oris r24, r0, 0xc000
lbl_800AE6D8:
lwz r0, 0(r30)
addi r3, r1, 0x44
li r4, 4
andi. r0, r0, 0x405
li r5, 1
ori r0, r0, 0xc0
stw r0, 0(r30)
stw r24, 0x44(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r3, r0, 5
lbl_800AE704:
lwz r0, 0(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE704
lwz r0, 0(r30)
andi. r0, r0, 0x405
cmpwi r3, 0
stw r0, 0(r30)
bne lbl_800AE6D8
lis r27, 0x4000
lbl_800AE728:
lwz r0, 0(r30)
addi r3, r1, 0x3c
li r4, 2
andi. r0, r0, 0x405
li r5, 1
ori r0, r0, 0xc0
stw r0, 0(r30)
stw r27, 0x3c(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r26, r0, 5
lbl_800AE754:
lwz r0, 0(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE754
addi r3, r1, 0x54
li r4, 4
li r5, 0
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
or r3, r26, r0
lbl_800AE77C:
lwz r0, 0(r29)
clrlwi. r0, r0, 0x1f
bne lbl_800AE77C
lwz r0, 0(r30)
andi. r0, r0, 0x405
cmpwi r3, 0
stw r0, 0(r30)
bne lbl_800AE728
lwz r0, 0x54(r1)
rlwinm. r0, r0, 0, 0x1e, 0x1e
bne lbl_800AE728
mr r3, r28
bl OSRestoreInterrupts
lmw r24, 0x58(r1)
li r3, 0
lwz r0, 0x7c(r1)
addi r1, r1, 0x78
mtlr r0
blr
.global DBRead
DBRead:
mflr r0
stw r0, 4(r1)
stwu r1, -0x20(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
addi r30, r4, 0
stw r29, 0x14(r1)
addi r29, r3, 0
bl OSDisableInterrupts
lwz r0, SendMailData@sda21(r13)
addi r31, r3, 0
rlwinm. r0, r0, 0, 0xf, 0xf
beq lbl_800AE804
li r3, 0x1000
b lbl_800AE808
lbl_800AE804:
li r3, 0
lbl_800AE808:
addis r3, r3, 2
addi r0, r30, 3
addi r4, r29, 0
rlwinm r5, r0, 0, 0, 0x1d
addi r3, r3, -8192
bl DBGRead
li r0, 0
stw r0, RecvDataLeng@sda21(r13)
mr r3, r31
stb r0, EXIInputFlag@sda21(r13)
bl OSRestoreInterrupts
lwz r0, 0x24(r1)
li r3, 0
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
addi r1, r1, 0x20
mtlr r0
blr
.global DBQueryData
DBQueryData:
mflr r0
li r3, 0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
lwz r0, RecvDataLeng@sda21(r13)
stb r3, EXIInputFlag@sda21(r13)
cmpwi r0, 0
bne lbl_800AE8D8
bl OSDisableInterrupts
addi r31, r3, 0
addi r3, r1, 8
bl DBGReadStatus
lwz r0, 8(r1)
clrlwi. r0, r0, 0x1f
beq lbl_800AE8D0
addi r3, r1, 8
bl DBGReadMailbox
lwz r0, 8(r1)
clrlwi r0, r0, 3
stw r0, 8(r1)
lwz r4, 8(r1)
rlwinm r3, r4, 0, 3, 7
addis r0, r3, 0xe100
cmplwi r0, 0
bne lbl_800AE8D0
clrlwi r3, r4, 0x11
stw r4, SendMailData@sda21(r13)
li r0, 1
stw r3, RecvDataLeng@sda21(r13)
stb r0, EXIInputFlag@sda21(r13)
lbl_800AE8D0:
mr r3, r31
bl OSRestoreInterrupts
lbl_800AE8D8:
lwz r3, RecvDataLeng@sda21(r13)
lwz r0, 0x1c(r1)
lwz r31, 0x14(r1)
addi r1, r1, 0x18
mtlr r0
blr
.global DBInitInterrupts
DBInitInterrupts:
mflr r0
lis r3, 0x00018000@ha
stw r0, 4(r1)
addi r3, r3, 0x00018000@l
stwu r1, -8(r1)
bl __OSMaskInterrupts
li r3, 0x40
bl __OSMaskInterrupts
lis r3, MWCallback@ha
addi r0, r3, MWCallback@l
lis r3, DBGHandler@ha
stw r0, DBGCallback@sda21(r13)
addi r4, r3, DBGHandler@l
li r3, 0x19
bl __OSSetInterruptHandler
li r3, 0x40
bl __OSUnmaskInterrupts
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global DBInitComm
DBInitComm:
mflr r0
stw r0, 4(r1)
stwu r1, -0x20(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
addi r30, r4, 0
stw r29, 0x14(r1)
addi r29, r3, 0
bl OSDisableInterrupts
addi r0, r13, EXIInputFlag@sda21
stw r0, pEXIInputFlag@sda21(r13)
lis r4, 0x00018000@ha
addi r31, r3, 0
lwz r0, pEXIInputFlag@sda21(r13)
addi r3, r4, 0x00018000@l
stw r0, 0(r29)
stw r30, MTRCallback@sda21(r13)
bl __OSMaskInterrupts
lis r3, 0xCC006828@ha
li r0, 0
stw r0, 0xCC006828@l(r3)
mr r3, r31
bl OSRestoreInterrupts
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
addi r1, r1, 0x20
mtlr r0
blr
.global DBGHandler
DBGHandler:
mflr r0
lis r5, 0xCC003000@ha
stw r0, 4(r1)
li r0, 0x1000
stwu r1, -8(r1)
lwz r12, DBGCallback@sda21(r13)
stw r0, 0xCC003000@l(r5)
cmplwi r12, 0
beq lbl_800AE9EC
mtlr r12
extsh r3, r3
blrl
lbl_800AE9EC:
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global MWCallback
MWCallback:
mflr r0
stw r0, 4(r1)
li r0, 1
stwu r1, -8(r1)
lwz r12, MTRCallback@sda21(r13)
stb r0, EXIInputFlag@sda21(r13)
cmplwi r12, 0
beq lbl_800AEA28
mtlr r12
li r3, 0
blrl
lbl_800AEA28:
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global DBGReadStatus
DBGReadStatus:
mflr r0
li r4, 2
stw r0, 4(r1)
lis r0, 0x4000
stwu r1, -0x38(r1)
stmw r27, 0x24(r1)
lis r30, 0xCC006800@ha
addi r27, r3, 0
addi r29, r30, 0xCC006800@l
addi r3, r1, 0x18
lwz r5, 0x6828(r30)
andi. r5, r5, 0x405
ori r5, r5, 0xc0
stwu r5, 0x28(r29)
li r5, 1
stw r0, 0x18(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r31, r0, 5
lbl_800AEA84:
addi r28, r30, 0x6800
lwzu r0, 0x34(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AEA84
addi r3, r27, 0
li r4, 4
li r5, 0
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
or r3, r31, r0
lbl_800AEAB0:
lwz r0, 0(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AEAB0
lwz r4, 0(r29)
cntlzw r0, r3
srwi r3, r0, 5
andi. r0, r4, 0x405
stw r0, 0(r29)
lmw r27, 0x24(r1)
lwz r0, 0x3c(r1)
addi r1, r1, 0x38
mtlr r0
blr
.global DBGWrite
DBGWrite:
mflr r0
stw r0, 4(r1)
rlwinm r0, r3, 8, 7, 0x15
oris r0, r0, 0xa000
stwu r1, -0x40(r1)
stmw r26, 0x28(r1)
lis r29, 0xCC006800@ha
addi r30, r5, 0
addi r26, r4, 0
addi r31, r29, 0xCC006800@l
addi r3, r1, 0x24
li r4, 4
li r5, 1
lwz r6, 0x6828(r29)
andi. r6, r6, 0x405
ori r6, r6, 0xc0
stwu r6, 0x28(r31)
stw r0, 0x24(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
mr r27, r0
lbl_800AEB3C:
addi r28, r29, 0x6800
lwzu r0, 0x34(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AEB3C
b lbl_800AEB90
lbl_800AEB50:
lwz r0, 0(r26)
addi r3, r1, 0x20
li r4, 4
stw r0, 0x20(r1)
li r5, 1
addi r26, r26, 4
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
or r27, r27, r0
lbl_800AEB78:
lwz r0, 0(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AEB78
addic. r30, r30, -4
bge lbl_800AEB90
li r30, 0
lbl_800AEB90:
cmpwi r30, 0
bne lbl_800AEB50
lwz r4, 0(r31)
cntlzw r0, r27
srwi r3, r0, 5
andi. r0, r4, 0x405
stw r0, 0(r31)
lmw r26, 0x28(r1)
lwz r0, 0x44(r1)
addi r1, r1, 0x40
mtlr r0
blr
.global DBGRead
DBGRead:
mflr r0
stw r0, 4(r1)
rlwinm r0, r3, 8, 7, 0x15
oris r0, r0, 0x2000
stwu r1, -0x40(r1)
stmw r26, 0x28(r1)
lis r29, 0xCC006800@ha
addi r30, r5, 0
addi r26, r4, 0
addi r31, r29, 0xCC006800@l
addi r3, r1, 0x24
li r4, 4
li r5, 1
lwz r6, 0x6828(r29)
andi. r6, r6, 0x405
ori r6, r6, 0xc0
stwu r6, 0x28(r31)
stw r0, 0x24(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
mr r27, r0
lbl_800AEC18:
addi r28, r29, 0x6800
lwzu r0, 0x34(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AEC18
b lbl_800AEC6C
lbl_800AEC2C:
addi r3, r1, 0x20
li r4, 4
li r5, 0
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
or r27, r27, r0
lbl_800AEC48:
lwz r0, 0(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AEC48
lwz r0, 0x20(r1)
addic. r30, r30, -4
stw r0, 0(r26)
addi r26, r26, 4
bge lbl_800AEC6C
li r30, 0
lbl_800AEC6C:
cmpwi r30, 0
bne lbl_800AEC2C
lwz r4, 0(r31)
cntlzw r0, r27
srwi r3, r0, 5
andi. r0, r4, 0x405
stw r0, 0(r31)
lmw r26, 0x28(r1)
lwz r0, 0x44(r1)
addi r1, r1, 0x40
mtlr r0
blr
.global DBGReadMailbox
DBGReadMailbox:
mflr r0
li r4, 2
stw r0, 4(r1)
lis r0, 0x6000
stwu r1, -0x38(r1)
stmw r27, 0x24(r1)
lis r30, 0xCC006800@ha
addi r27, r3, 0
addi r29, r30, 0xCC006800@l
addi r3, r1, 0x18
lwz r5, 0x6828(r30)
andi. r5, r5, 0x405
ori r5, r5, 0xc0
stwu r5, 0x28(r29)
li r5, 1
stw r0, 0x18(r1)
bl DBGEXIImm
cntlzw r0, r3
srwi r31, r0, 5
lbl_800AECE8:
addi r28, r30, 0x6800
lwzu r0, 0x34(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AECE8
addi r3, r27, 0
li r4, 4
li r5, 0
bl DBGEXIImm
cntlzw r0, r3
srwi r0, r0, 5
or r3, r31, r0
lbl_800AED14:
lwz r0, 0(r28)
clrlwi. r0, r0, 0x1f
bne lbl_800AED14
lwz r4, 0(r29)
cntlzw r0, r3
srwi r3, r0, 5
andi. r0, r4, 0x405
stw r0, 0(r29)
lmw r27, 0x24(r1)
lwz r0, 0x3c(r1)
addi r1, r1, 0x38
mtlr r0
blr
.global DBGEXIImm
DBGEXIImm:
stwu r1, -0x48(r1)
cmplwi r5, 0
stmw r22, 0x20(r1)
beq lbl_800AEE8C
li r29, 0
cmpw r29, r4
li r30, 0
bge lbl_800AEE84
cmpwi r4, 8
addi r6, r4, -8
ble lbl_800AEFCC
addi r0, r6, 7
srwi r0, r0, 3
cmpwi r6, 0
mtctr r0
addi r31, r3, 0
ble lbl_800AEFCC
lbl_800AED8C:
subfic r6, r29, 3
lbz r12, 0(r31)
addi r0, r29, 1
lbz r11, 1(r31)
slwi r10, r6, 3
lbz r9, 2(r31)
subfic r8, r0, 3
lbz r7, 3(r31)
addi r6, r29, 2
lbz r0, 4(r31)
slw r12, r12, r10
lbz r23, 5(r31)
slwi r10, r8, 3
lbz r25, 6(r31)
subfic r6, r6, 3
lbz r27, 7(r31)
slwi r8, r6, 3
neg r6, r29
addi r22, r29, 4
slwi r6, r6, 3
subfic r22, r22, 3
addi r24, r29, 5
slwi r22, r22, 3
subfic r24, r24, 3
addi r26, r29, 6
slwi r24, r24, 3
subfic r26, r26, 3
addi r28, r29, 7
slwi r26, r26, 3
subfic r28, r28, 3
slwi r28, r28, 3
or r30, r30, r12
slw r10, r11, r10
or r30, r30, r10
slw r8, r9, r8
or r30, r30, r8
slw r6, r7, r6
or r30, r30, r6
slw r0, r0, r22
or r30, r30, r0
slw r0, r23, r24
or r30, r30, r0
slw r0, r25, r26
or r30, r30, r0
slw r0, r27, r28
or r30, r30, r0
addi r31, r31, 8
addi r29, r29, 8
bdnz lbl_800AED8C
b lbl_800AEFCC
lbl_800AEE54:
subf r0, r29, r4
cmpw r29, r4
mtctr r0
bge lbl_800AEE84
lbl_800AEE64:
subfic r0, r29, 3
lbz r6, 0(r7)
slwi r0, r0, 3
slw r0, r6, r0
or r30, r30, r0
addi r7, r7, 1
addi r29, r29, 1
bdnz lbl_800AEE64
lbl_800AEE84:
lis r6, 0xCC006838@ha
stw r30, 0xCC006838@l(r6)
lbl_800AEE8C:
addi r0, r4, -1
lis r6, 0xCC006800@ha
slwi r7, r5, 2
addi r8, r6, 0xCC006800@l
ori r6, r7, 1
slwi r0, r0, 4
or r0, r6, r0
stwu r0, 0x34(r8)
lbl_800AEEAC:
lwz r0, 0(r8)
clrlwi. r0, r0, 0x1f
bne lbl_800AEEAC
cmplwi r5, 0
bne lbl_800AEFC4
li r5, 0
lis r6, 0xCC006838@ha
cmpw r5, r4
lwz r0, 0xCC006838@l(r6)
bge lbl_800AEFC4
cmpwi r4, 8
addi r7, r4, -8
ble lbl_800AEF98
addi r6, r7, 7
srwi r6, r6, 3
cmpwi r7, 0
mtctr r6
ble lbl_800AEF98
lbl_800AEEF4:
subfic r6, r5, 3
slwi r7, r6, 3
addi r6, r5, 1
srw r8, r0, r7
subfic r6, r6, 3
stb r8, 0(r3)
slwi r7, r6, 3
addi r6, r5, 2
srw r12, r0, r7
subfic r6, r6, 3
stb r12, 1(r3)
slwi r6, r6, 3
srw r11, r0, r6
neg r6, r5
stb r11, 2(r3)
slwi r7, r6, 3
addi r6, r5, 4
srw r10, r0, r7
subfic r6, r6, 3
stb r10, 3(r3)
slwi r7, r6, 3
addi r6, r5, 5
srw r9, r0, r7
subfic r6, r6, 3
stb r9, 4(r3)
slwi r7, r6, 3
srw r8, r0, r7
addi r6, r5, 6
stb r8, 5(r3)
subfic r7, r6, 3
addi r6, r5, 7
slwi r7, r7, 3
srw r7, r0, r7
subfic r6, r6, 3
stb r7, 6(r3)
slwi r6, r6, 3
srw r6, r0, r6
stb r6, 7(r3)
addi r3, r3, 8
addi r5, r5, 8
bdnz lbl_800AEEF4
lbl_800AEF98:
subf r6, r5, r4
cmpw r5, r4
mtctr r6
bge lbl_800AEFC4
lbl_800AEFA8:
subfic r4, r5, 3
slwi r4, r4, 3
srw r4, r0, r4
stb r4, 0(r3)
addi r3, r3, 1
addi r5, r5, 1
bdnz lbl_800AEFA8
lbl_800AEFC4:
li r3, 1
b lbl_800AEFD4
lbl_800AEFCC:
add r7, r3, r29
b lbl_800AEE54
lbl_800AEFD4:
lmw r22, 0x20(r1)
addi r1, r1, 0x48
blr
.section .sdata, "wa"
SendCount:
.4byte 0x80000000
.4byte 0
.section .sbss, "wa"
MTRCallback:
.skip 0x4
DBGCallback:
.skip 0x4
SendMailData:
.skip 0x4
RecvDataLeng:
.skip 0x4
pEXIInputFlag:
.skip 0x4
EXIInputFlag:
.skip 0x4