.include "macros.inc"
.section .text, "ax"
.global TRKInitializeEventQueue
TRKInitializeEventQueue:
mflr r0
lis r3, gTRKEventQueue@ha
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
addi r31, r3, gTRKEventQueue@l
addi r3, r31, 0
bl TRKInitializeMutex
mr r3, r31
bl TRKAcquireMutex
li r3, 0
stw r3, 4(r31)
li r0, 0x100
stw r3, 8(r31)
mr r3, r31
stw r0, 0x24(r31)
bl TRKReleaseMutex
li r3, 0
lwz r31, 0xc(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKCopyEvent
TRKCopyEvent:
mflr r0
li r5, 0xc
stw r0, 4(r1)
stwu r1, -8(r1)
bl TRK_memcpy
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKGetNextEvent
TRKGetNextEvent:
mflr r0
lis r4, gTRKEventQueue@ha
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
addi r31, r4, gTRKEventQueue@l
stw r30, 0x10(r1)
stw r29, 0xc(r1)
li r29, 0
stw r28, 8(r1)
addi r28, r3, 0
addi r3, r31, 0
bl TRKAcquireMutex
addi r30, r31, 4
lwz r0, 4(r31)
cmpwi r0, 0
ble lbl_80087D78
addi r29, r31, 8
lwz r0, 8(r31)
addi r3, r28, 0
mulli r0, r0, 0xc
add r4, r31, r0
addi r4, r4, 0xc
bl TRKCopyEvent
lwz r3, 0(r30)
addi r0, r3, -1
stw r0, 0(r30)
lwz r3, 0(r29)
addi r0, r3, 1
stw r0, 0(r29)
lwz r0, 0(r29)
cmpwi r0, 2
bne lbl_80087D74
li r0, 0
stw r0, 0(r29)
lbl_80087D74:
li r29, 1
lbl_80087D78:
lis r3, gTRKEventQueue@ha
addi r3, r3, gTRKEventQueue@l
bl TRKReleaseMutex
mr r3, r29
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
lwz r29, 0xc(r1)
lwz r28, 8(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKPostEvent
TRKPostEvent:
mflr r0
lis r4, gTRKEventQueue@ha
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
addi r31, r3, 0
stw r30, 0x10(r1)
addi r30, r4, gTRKEventQueue@l
addi r3, r30, 0
stw r29, 0xc(r1)
stw r28, 8(r1)
li r28, 0
bl TRKAcquireMutex
addi r29, r30, 4
lwz r3, 4(r30)
cmpwi r3, 2
bne lbl_80087DF4
li r28, 0x100
b lbl_80087E58
lbl_80087DF4:
lwz r0, 8(r30)
addi r4, r31, 0
add r0, r0, r3
srawi r3, r0, 1
addze r3, r3
slwi r3, r3, 1
subfc r3, r3, r0
mulli r0, r3, 0xc
add r31, r30, r0
addi r3, r31, 0xc
bl TRKCopyEvent
addi r4, r30, 0x24
lwz r0, 0x24(r30)
stw r0, 0x10(r31)
lwz r3, 0x24(r30)
addi r0, r3, 1
stw r0, 0x24(r30)
lwz r0, 0x24(r30)
cmplwi r0, 0x100
bge lbl_80087E4C
li r0, 0x100
stw r0, 0(r4)
lbl_80087E4C:
lwz r3, 0(r29)
addi r0, r3, 1
stw r0, 0(r29)
lbl_80087E58:
lis r3, gTRKEventQueue@ha
addi r3, r3, gTRKEventQueue@l
bl TRKReleaseMutex
mr r3, r28
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
lwz r29, 0xc(r1)
lwz r28, 8(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKConstructEvent
TRKConstructEvent:
stb r4, 0(r3)
li r4, 0
li r0, -1
stw r4, 4(r3)
stw r0, 8(r3)
blr
.global TRKDestructEvent
TRKDestructEvent:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lwz r3, 8(r3)
bl TRKReleaseBuffer
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.section .bss, "wa"
.global gTRKEventQueue
gTRKEventQueue:
.skip 0x28