.include "macros.inc"
.section .text, "ax"
.global TRKSuppAccessFile
TRKSuppAccessFile:
mflr r0
stw r0, 4(r1)
stwu r1, -0x48(r1)
stmw r21, 0x1c(r1)
or. r27, r4, r4
addi r25, r3, 0
addi r23, r5, 0
addi r26, r6, 0
addi r22, r7, 0
addi r30, r8, 0
beq lbl_80089E08
lwz r0, 0(r23)
cmplwi r0, 0
bne lbl_80089E10
lbl_80089E08:
li r3, 2
b lbl_8008A094
lbl_80089E10:
li r0, 0
stb r0, 0(r26)
li r24, 0
li r28, 0
li r21, 0
b lbl_8008A064
lbl_80089E28:
subf r0, r28, r3
cmplwi r0, 0x800
ble lbl_80089E3C
li r31, 0x800
b lbl_80089E40
lbl_80089E3C:
mr r31, r0
lbl_80089E40:
addi r3, r1, 0xc
addi r4, r1, 0x10
bl TRKGetFreeBuffer
or. r21, r3, r3
bne lbl_80089EA8
lwz r7, 0x10(r1)
lwz r0, 0xc(r7)
cmplwi r0, 0x880
blt lbl_80089E6C
li r5, 0x301
b lbl_80089EA4
lbl_80089E6C:
cmpwi r30, 0
beq lbl_80089E7C
li r6, 0xd1
b lbl_80089E80
lbl_80089E7C:
li r6, 0xd0
lbl_80089E80:
lwz r4, 0xc(r7)
li r5, 0
addi r3, r4, 1
addi r0, r4, 0x10
stw r3, 0xc(r7)
stbx r6, r7, r0
lwz r3, 8(r7)
addi r0, r3, 1
stw r0, 8(r7)
lbl_80089EA4:
mr r21, r5
lbl_80089EA8:
cmpwi r21, 0
bne lbl_80089EC0
lwz r3, 0x10(r1)
mr r4, r25
bl TRKAppendBuffer1_ui32
mr r21, r3
lbl_80089EC0:
cmpwi r21, 0
bne lbl_80089ED8
lwz r3, 0x10(r1)
clrlwi r4, r31, 0x10
bl TRKAppendBuffer1_ui16
mr r21, r3
lbl_80089ED8:
cmpwi r30, 0
bne lbl_80089EFC
cmpwi r21, 0
bne lbl_80089EFC
lwz r3, 0x10(r1)
addi r5, r31, 0
add r4, r27, r28
bl TRKAppendBuffer_ui8
mr r21, r3
lbl_80089EFC:
cmpwi r21, 0
bne lbl_8008A058
cmpwi r22, 0
beq lbl_8008A04C
li r0, 0
cmpwi r30, 0
sth r0, 0xa(r1)
stb r0, 8(r1)
beq lbl_80089F2C
cmplwi r25, 0
bne lbl_80089F2C
li r0, 1
lbl_80089F2C:
cmpwi r30, 0
beq lbl_80089F3C
li r5, 5
b lbl_80089F40
lbl_80089F3C:
li r5, 5
lbl_80089F40:
cntlzw r0, r0
lwz r3, 0x10(r1)
srwi r7, r0, 5
addi r4, r1, 0x14
li r6, 3
bl TRKRequestSend
or. r21, r3, r3
bne lbl_80089F74
lwz r3, 0x14(r1)
bl TRKGetBuffer
addi r29, r3, 0
li r4, 2
bl TRKSetBufferPosition
lbl_80089F74:
cmpwi r21, 0
bne lbl_80089F8C
addi r3, r29, 0
addi r4, r1, 8
bl TRKReadBuffer1_ui8
mr r21, r3
lbl_80089F8C:
cmpwi r21, 0
bne lbl_80089FA4
addi r3, r29, 0
addi r4, r1, 0xa
bl TRKReadBuffer1_ui16
mr r21, r3
lbl_80089FA4:
cmpwi r30, 0
beq lbl_8008A000
cmpwi r21, 0
bne lbl_8008A000
lhz r3, 0xa(r1)
lwz r4, 8(r29)
addi r0, r3, 5
cmplw r4, r0
beq lbl_80089FE4
lbz r0, 8(r1)
addi r3, r4, -5
sth r3, 0xa(r1)
cmplwi r0, 0
bne lbl_80089FE4
li r0, 1
stb r0, 8(r1)
lbl_80089FE4:
lhz r5, 0xa(r1)
cmplw r5, r31
bgt lbl_8008A000
addi r3, r29, 0
add r4, r27, r28
bl TRKReadBuffer_ui8
mr r21, r3
lbl_8008A000:
lhz r3, 0xa(r1)
cmplw r3, r31
beq lbl_8008A038
cmpwi r30, 0
beq lbl_8008A01C
cmplw r3, r31
blt lbl_8008A030
lbl_8008A01C:
lbz r0, 8(r1)
cmplwi r0, 0
bne lbl_8008A030
li r0, 1
stb r0, 8(r1)
lbl_8008A030:
addi r31, r3, 0
li r24, 1
lbl_8008A038:
lbz r0, 8(r1)
stb r0, 0(r26)
lwz r3, 0x14(r1)
bl TRKReleaseBuffer
b lbl_8008A058
lbl_8008A04C:
lwz r3, 0x10(r1)
bl TRKMessageSend
mr r21, r3
lbl_8008A058:
lwz r3, 0xc(r1)
bl TRKReleaseBuffer
add r28, r28, r31
lbl_8008A064:
cmpwi r24, 0
bne lbl_8008A08C
lwz r3, 0(r23)
cmplw r28, r3
bge lbl_8008A08C
cmpwi r21, 0
bne lbl_8008A08C
lbz r0, 0(r26)
cmplwi r0, 0
beq lbl_80089E28
lbl_8008A08C:
stw r28, 0(r23)
mr r3, r21
lbl_8008A094:
lmw r21, 0x1c(r1)
addi r1, r1, 0x48
lwz r0, 4(r1)
mtlr r0
blr
.global TRKRequestSend
TRKRequestSend:
mflr r0
stw r0, 4(r1)
li r0, -1
stwu r1, -0x38(r1)
stmw r22, 0x10(r1)
addi r23, r4, 0
lis r4, 0x04C4B3EC@ha
addi r27, r6, 1
addi r22, r3, 0
addi r31, r4, 0x04C4B3EC@l
addi r24, r5, 0
addi r25, r7, 0
li r30, 0
li r26, 1
stw r0, 0(r23)
b lbl_8008A208
lbl_8008A0E8:
mr r3, r22
bl TRKMessageSend
or. r30, r3, r3
bne lbl_8008A204
cmpwi r25, 0
beq lbl_8008A104
li r28, 0
lbl_8008A104:
bl TRKTestForPacket
stw r3, 0(r23)
lwz r3, 0(r23)
cmpwi r3, -1
bne lbl_8008A12C
cmpwi r25, 0
beq lbl_8008A104
addi r28, r28, 1
cmplw r28, r31
blt lbl_8008A104
lbl_8008A12C:
cmpwi r3, -1
beq lbl_8008A17C
li r26, 0
bl TRKGetBuffer
addi r29, r3, 0
li r4, 0
bl TRKSetBufferPosition
addi r3, r29, 0
addi r4, r1, 8
bl TRKReadBuffer1_ui8
or. r30, r3, r3
bne lbl_8008A17C
lbz r0, 8(r1)
cmplwi r0, 0x80
bge lbl_8008A17C
lwz r3, 0(r23)
bl TRKProcessInput
li r0, -1
stw r0, 0(r23)
b lbl_8008A104
lbl_8008A17C:
lwz r0, 0(r23)
cmpwi r0, -1
beq lbl_8008A204
lwz r0, 8(r29)
cmplw r0, r24
bge lbl_8008A198
li r26, 1
lbl_8008A198:
cmpwi r30, 0
bne lbl_8008A1B8
cmpwi r26, 0
bne lbl_8008A1B8
addi r3, r29, 0
addi r4, r1, 9
bl TRKReadBuffer1_ui8
mr r30, r3
lbl_8008A1B8:
cmpwi r30, 0
bne lbl_8008A1E4
cmpwi r26, 0
bne lbl_8008A1E4
lbz r0, 8(r1)
cmplwi r0, 0x80
bne lbl_8008A1E0
lbz r0, 9(r1)
cmplwi r0, 0
beq lbl_8008A1E4
lbl_8008A1E0:
li r26, 1
lbl_8008A1E4:
cmpwi r30, 0
bne lbl_8008A1F4
cmpwi r26, 0
beq lbl_8008A204
lbl_8008A1F4:
lwz r3, 0(r23)
bl TRKReleaseBuffer
li r0, -1
stw r0, 0(r23)
lbl_8008A204:
addi r27, r27, -1
lbl_8008A208:
cmpwi r27, 0
beq lbl_8008A224
lwz r0, 0(r23)
cmpwi r0, -1
bne lbl_8008A224
cmpwi r30, 0
beq lbl_8008A0E8
lbl_8008A224:
lwz r0, 0(r23)
cmpwi r0, -1
bne lbl_8008A234
li r30, 0x800
lbl_8008A234:
mr r3, r30
lmw r22, 0x10(r1)
addi r1, r1, 0x38
lwz r0, 4(r1)
mtlr r0
blr