rewrote QFST with C2
This commit is contained in:
parent
62cd98deb6
commit
b798226c14
2 changed files with 88 additions and 102 deletions
24
src/QFST.ld
24
src/QFST.ld
|
@ -1,12 +1,22 @@
|
||||||
/* @ha MUST be 0x817f */
|
$$ = 0;
|
||||||
$QFST.ts = 0x817f7c00;
|
|
||||||
$QFST.cnt = 0x817f7c40;
|
/* size = 0x14 */
|
||||||
$QFST.t0 = 0x817f7c44;
|
$QFST.fillRectOpt = 0x817f039c;
|
||||||
$$ = 0x817f7c48;
|
/* size = 0x10 */
|
||||||
|
$QFST.drawTextOpt = 0x817f03b0;
|
||||||
|
/* size = 0x09 */
|
||||||
|
$QFST.fmt = 0x817f03c0;
|
||||||
|
/* size = 0x02 (u16) */
|
||||||
|
$QFST.cnt = 0x817f03ca;
|
||||||
|
/* size = 0x04 (u32) */
|
||||||
|
$QFST.t0 = 0x817f03cc;
|
||||||
|
/* size = 0x40 (u32[0x10]) */
|
||||||
|
$QFST.ts = 0x817f03d0;
|
||||||
|
|
||||||
|
|
||||||
$QFT.tFreeze = 0x817f00b8;
|
$QFT.tFreeze = 0x817f00b8;
|
||||||
$QFT.freezeDur = 0x817f00bc;
|
$QFT.freezeDur = 0x817f00bc;
|
||||||
|
|
||||||
$b$.QFST.reset = 0x800f9dd0;
|
$C2$.QFST.reset = TApplication.proc + 0x34;
|
||||||
$b$.QFST.render = 0x802069d0;
|
$C2$.QFST.render = drawWater - 0x1c;
|
||||||
drawText = 0x817f0238;
|
drawText = 0x817f0238;
|
||||||
|
|
166
src/QFST.s
166
src/QFST.s
|
@ -1,55 +1,50 @@
|
||||||
.include "./macros.s"
|
.include "./macros.s"
|
||||||
.set $drawIndex$, 1
|
|
||||||
|
|
||||||
.set x, 532
|
|
||||||
.set x2, 488
|
|
||||||
.set y, 150
|
|
||||||
.set fontSize, 13
|
|
||||||
.set colorTop, 0xffffffff
|
|
||||||
.set colorBot, 0xffffffff
|
|
||||||
.set logN, 4
|
.set logN, 4
|
||||||
|
|
||||||
.draw2D.fmt: .string "%2d.%03d"
|
|
||||||
.draw2D.fmt2: .string "[%02d]"
|
|
||||||
.align 2
|
|
||||||
|
|
||||||
.set aBase, 0x817f<<16
|
|
||||||
.QFST.reset:
|
.QFST.reset:
|
||||||
|
## set cnt = 0, -t0 = -4
|
||||||
|
lis r3, 0x817F
|
||||||
|
li r29, 4
|
||||||
|
stw r29, $QFST.t0@l(r3)
|
||||||
li r29, 0 # orig
|
li r29, 0 # orig
|
||||||
lis r3, aBase@h
|
sth r29, $QFST.cnt@l(r3)
|
||||||
stw r29, $QFST.cnt-aBase(r3)
|
|
||||||
stw r29, $QFST.t0-aBase(r3)
|
/**********************************/
|
||||||
b 4+$b$.QFST.reset
|
.QFST.render:
|
||||||
|
|
||||||
.set rmw, 28
|
|
||||||
.set rmwOff, 0xC
|
|
||||||
.set rmwAdd, 0x20
|
|
||||||
.set rTArr, 31
|
.set rTArr, 31
|
||||||
.set rCnt, 30
|
.set rCnt, 30
|
||||||
.set rY, 29
|
.set rY, 29
|
||||||
.set rIdx, 28
|
.set rY0, 28
|
||||||
.QFST.render:
|
.set rIdx, 27
|
||||||
.QFST.render.setup:
|
.set rFontSize, 26
|
||||||
addi r3, r1, 0xE90
|
.set r817F, 25
|
||||||
bl J2DGrafContext.setup2D
|
|
||||||
|
.set rmw, 25
|
||||||
|
.set rmwOff, 0x8
|
||||||
|
.set rmwAdd, 0x30
|
||||||
|
|
||||||
## prepare
|
## prepare
|
||||||
addi r1, r1, -rmwAdd
|
addi r1, r1, -rmwAdd
|
||||||
stmw rmw, rmwOff(r1)
|
stmw rmw, rmwOff(r1)
|
||||||
lis r3, aBase@h
|
lis r817F, 0x817F
|
||||||
la rTArr, $QFST.ts-aBase(r3)
|
lha rY0, $QFST.drawTextOpt+2@l(r817F)
|
||||||
lwz rCnt, $QFST.cnt-aBase(r3)
|
la rTArr, $QFST.ts@l(r817F)
|
||||||
li rY, y
|
lhz rCnt, $QFST.cnt@l(r817F)
|
||||||
|
mr rY, rY0
|
||||||
|
lwz rFontSize, $QFST.drawTextOpt+4@l(r817F)
|
||||||
|
|
||||||
.QFST.render.update:
|
.QFST.render.update:
|
||||||
### check is QFT frozen
|
### check is QFT frozen
|
||||||
### r6 = freeze duration
|
### r6 = freeze duration
|
||||||
lwz r6, $QFT.freezeDur-aBase(r3)
|
lwz r6, $QFT.freezeDur@l(r817F)
|
||||||
cmpwi r6, 0
|
cmplwi r6, 0
|
||||||
beq+ .QFST.render.update.done
|
beq+ .QFST.render.update.done
|
||||||
### check is new frozen time
|
### check is new frozen time
|
||||||
### r4 = tFreeze = QFT display time when freezed
|
### r4 = tFreeze = QFT display time when freezed
|
||||||
### r5 = t0
|
### r5 = t0
|
||||||
lwz r4, $QFT.tFreeze-aBase(r3)
|
lwz r4, $QFT.tFreeze@l(r817F)
|
||||||
lwz r5, $QFST.t0-aBase(r3)
|
lwz r5, $QFST.t0@l(r817F)
|
||||||
cmpw r4, r5
|
cmpw r4, r5
|
||||||
ble+ .QFST.render.update.done
|
ble+ .QFST.render.update.done
|
||||||
### store diff
|
### store diff
|
||||||
|
@ -57,78 +52,59 @@
|
||||||
rlwinm r12, rCnt, 2, 30-logN, 29
|
rlwinm r12, rCnt, 2, 30-logN, 29
|
||||||
stwx r0, rTArr, r12
|
stwx r0, rTArr, r12
|
||||||
### update t0 = tFreeze
|
### update t0 = tFreeze
|
||||||
stw r4, $QFST.t0-aBase(r3)
|
stw r4, $QFST.t0@l(r817F)
|
||||||
### update cnt
|
### update cnt
|
||||||
addi rCnt, rCnt, 1
|
addi rCnt, rCnt, 1
|
||||||
stw rCnt, $QFST.cnt-aBase(r3)
|
sth rCnt, $QFST.cnt@l(r817F)
|
||||||
.QFST.render.update.done:
|
.QFST.render.update.done:
|
||||||
|
|
||||||
|
.QFST.render.bg:
|
||||||
|
la r3, $QFST.fillRectOpt@l(r817F)
|
||||||
|
la r4, $QFST.fillRectOpt+0x10@l(r817F)
|
||||||
|
lis r12, fill_rect@ha
|
||||||
|
la r12, fill_rect@l(r12)
|
||||||
|
mtlr r12
|
||||||
|
blrl
|
||||||
|
|
||||||
.QFST.render.preDraw:
|
.QFST.render.preDraw:
|
||||||
### idx = max(0, cnt-N)
|
### idx = cnt < N ? 0 : cnt-N
|
||||||
|
srwi. rIdx, rCnt, logN
|
||||||
|
beq .QFST.render.preDraw.done # idx = 0 if cnt>>logN == 0
|
||||||
subi rIdx, rCnt, 1<<logN
|
subi rIdx, rCnt, 1<<logN
|
||||||
cmpwi rCnt, 1<<logN
|
.QFST.render.preDraw.done:
|
||||||
bge .QFST.render.preDraw.L1
|
|
||||||
li rIdx, 0
|
|
||||||
.QFST.render.preDraw.L1:
|
|
||||||
.QFST.render.loop:
|
.QFST.render.loop:
|
||||||
cmpw rIdx, rCnt
|
cmplw rIdx, rCnt
|
||||||
blt+ .QFST.render.loop.body
|
bge- .QFST.render.done
|
||||||
.QFST.render.done:
|
|
||||||
lmw rmw, rmwOff(r1)
|
|
||||||
addi r1, r1, rmwAdd
|
|
||||||
## orig
|
|
||||||
lis r3, 0x803b
|
|
||||||
b 4+$b$.QFST.render
|
|
||||||
.QFST.render.loop.body:
|
.QFST.render.loop.body:
|
||||||
### QF -> s
|
### QF -> s
|
||||||
rlwinm r3, rIdx, 2, 30-logN, 29 # offset
|
rlwinm r3, rIdx, 2, 30-logN, 29 # offset
|
||||||
lwzx r0, rTArr, r3
|
lwzx r0, rTArr, r3
|
||||||
#### r0 = dQF*1001
|
#### r11 = dQF*1001
|
||||||
mulli r0, r0, 1001
|
mulli r11, r0, 1001
|
||||||
#### r10 = dQF*1001/120 = ms
|
#### r11 = dQF*1001/120 = ms
|
||||||
li r11, 120
|
li r0, 120
|
||||||
divwu r10, r0, r11
|
divwu r11, r11, r0
|
||||||
#### r9 = ms/1000 = s
|
#### r5 = ms/1000 = s
|
||||||
li r11, 1000
|
li r0, 1000
|
||||||
divwu r9, r10, r11
|
divwu r5, r11, r0
|
||||||
#### r10 = ms-s*1000 = ms%1000
|
#### r6 = ms-s*1000 = ms%1000
|
||||||
mulli r11, r9, 1000
|
mulli r0, r5, 1000
|
||||||
sub r10, r10, r11
|
sub r6, r11, r0
|
||||||
### params
|
### params
|
||||||
li r3, x
|
la r3, $QFST.drawTextOpt@l(r817F)
|
||||||
mr r4, rY
|
la r4, $QFST.fmt@l(r817F)
|
||||||
li r5, fontSize
|
la r12, drawText@l(r817F)
|
||||||
liDX r6, colorTop
|
mtlr r12
|
||||||
.if colorTop == colorBot
|
blrl
|
||||||
mr r7, r6
|
|
||||||
.else
|
|
||||||
liDX r7, colorBot
|
|
||||||
.endif
|
|
||||||
li32 r8 .draw2D.fmt
|
|
||||||
crclr 6
|
|
||||||
bl drawText
|
|
||||||
## draw index
|
|
||||||
### r9 = (idx+1)%100
|
|
||||||
addi rIdx, rIdx, 1
|
|
||||||
.if $drawIndex$
|
|
||||||
li r0, 100
|
|
||||||
divwu r9, rIdx, r0
|
|
||||||
mullw r9, r9, r0
|
|
||||||
sub r9, rIdx, r9
|
|
||||||
### params
|
|
||||||
li32 r8 .draw2D.fmt2
|
|
||||||
li r3, x2
|
|
||||||
mr r4, rY
|
|
||||||
li r5, fontSize
|
|
||||||
liDX r6, colorTop
|
|
||||||
.if colorTop == colorBot
|
|
||||||
mr r7, r6
|
|
||||||
.else
|
|
||||||
liDX r7, colorBot
|
|
||||||
.endif
|
|
||||||
crclr 6
|
|
||||||
bl drawText
|
|
||||||
## next
|
## next
|
||||||
#addi rIdx, rIdx, 1 # already added
|
add rY, rY, rFontSize
|
||||||
.endif
|
addi rIdx, rIdx, 1
|
||||||
addi rY, rY, fontSize
|
sth rY, $QFST.drawTextOpt+2@l(r817F)
|
||||||
b .QFST.render.loop
|
b .QFST.render.loop
|
||||||
|
|
||||||
|
.QFST.render.done:
|
||||||
|
## restore y
|
||||||
|
sth rY0, $QFST.drawTextOpt+2@l(r817F)
|
||||||
|
## destroy stack frame
|
||||||
|
lmw rmw, rmwOff(r1)
|
||||||
|
addi r1, r1, rmwAdd
|
||||||
|
|
Loading…
Reference in a new issue