.include "macros.inc"
.section .text, "ax"
.global TRKTestForPacket
TRKTestForPacket:
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
stw r30, 0x10(r1)
bl TRKPollUART
or. r30, r3, r3
ble lbl_8008896C
addi r3, r1, 8
addi r4, r1, 0xc
bl TRKGetFreeBuffer
cmpwi r30, 0x880
ble lbl_80088944
b lbl_80088928
lbl_80088900:
cmpwi r30, 0x880
ble lbl_80088910
li r31, 0x880
b lbl_80088914
lbl_80088910:
mr r31, r30
lbl_80088914:
lwz r3, 0xc(r1)
addi r4, r31, 0
addi r3, r3, 0x10
bl TRKReadUARTN
subf r30, r31, r30
lbl_80088928:
cmpwi r30, 0
bgt lbl_80088900
lwz r3, 0xc(r1)
li r4, 0xff
li r5, 6
bl TRKStandardACK
b lbl_8008896C
lbl_80088944:
lwz r3, 0xc(r1)
addi r4, r30, 0
addi r3, r3, 0x10
bl TRKReadUARTN
cmpwi r3, 0
bne lbl_8008896C
lwz r3, 0xc(r1)
stw r30, 8(r3)
lwz r3, 8(r1)
b lbl_80088980
lbl_8008896C:
lwz r3, 8(r1)
cmpwi r3, -1
beq lbl_8008897C
bl TRKReleaseBuffer
lbl_8008897C:
li r3, -1
lbl_80088980:
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKGetInput
TRKGetInput:
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
stw r30, 0x10(r1)
bl TRKTestForPacket
addi r30, r3, 0
cmpwi r30, -1
beq lbl_800889FC
mr r3, r30
bl TRKGetBuffer
addi r31, r3, 0
li r4, 0
bl TRKSetBufferPosition
addi r3, r31, 0
addi r4, r1, 8
bl TRKReadBuffer1_ui8
lbz r0, 8(r1)
cmplwi r0, 0x80
bge lbl_800889F4
mr r3, r30
bl TRKProcessInput
b lbl_800889FC
lbl_800889F4:
mr r3, r30
bl TRKReleaseBuffer
lbl_800889FC:
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKProcessInput
TRKProcessInput:
mflr r0
li r4, 2
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
addi r31, r3, 0
addi r3, r1, 8
bl TRKConstructEvent
lis r3, gTRKFramingState@ha
stw r31, 0x10(r1)
addi r4, r3, gTRKFramingState@l
addi r3, r1, 8
li r0, -1
stw r0, 0(r4)
bl TRKPostEvent
lwz r31, 0x14(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKInitializeSerialHandler
TRKInitializeSerialHandler:
lis r3, gTRKFramingState@ha
addi r4, r3, gTRKFramingState@l
li r0, -1
stw r0, 0(r4)
li r0, 0
li r3, 0
stb r0, 8(r4)
stw r0, 0xc(r4)
blr
.global TRKTerminateSerialHandler
TRKTerminateSerialHandler:
li r3, 0
blr
.section .bss, "wa"
.global gTRKFramingState
gTRKFramingState:
.skip 0x14
.global gTRKInputPendingPtr
gTRKInputPendingPtr:
.skip 0x4