1
0
Fork 0

rewrote QFST with C2

This commit is contained in:
sup39 2023-02-01 03:01:45 +09:00
parent 62cd98deb6
commit b798226c14
2 changed files with 88 additions and 102 deletions

View file

@ -1,12 +1,22 @@
/* @ha MUST be 0x817f */
$QFST.ts = 0x817f7c00;
$QFST.cnt = 0x817f7c40;
$QFST.t0 = 0x817f7c44;
$$ = 0x817f7c48;
$$ = 0;
/* size = 0x14 */
$QFST.fillRectOpt = 0x817f039c;
/* 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.freezeDur = 0x817f00bc;
$b$.QFST.reset = 0x800f9dd0;
$b$.QFST.render = 0x802069d0;
$C2$.QFST.reset = TApplication.proc + 0x34;
$C2$.QFST.render = drawWater - 0x1c;
drawText = 0x817f0238;

View file

@ -1,55 +1,50 @@
.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
.draw2D.fmt: .string "%2d.%03d"
.draw2D.fmt2: .string "[%02d]"
.align 2
.set aBase, 0x817f<<16
.QFST.reset:
## set cnt = 0, -t0 = -4
lis r3, 0x817F
li r29, 4
stw r29, $QFST.t0@l(r3)
li r29, 0 # orig
lis r3, aBase@h
stw r29, $QFST.cnt-aBase(r3)
stw r29, $QFST.t0-aBase(r3)
b 4+$b$.QFST.reset
sth r29, $QFST.cnt@l(r3)
/**********************************/
.QFST.render:
.set rmw, 28
.set rmwOff, 0xC
.set rmwAdd, 0x20
.set rTArr, 31
.set rCnt, 30
.set rY, 29
.set rIdx, 28
.QFST.render:
.QFST.render.setup:
addi r3, r1, 0xE90
bl J2DGrafContext.setup2D
.set rY0, 28
.set rIdx, 27
.set rFontSize, 26
.set r817F, 25
.set rmw, 25
.set rmwOff, 0x8
.set rmwAdd, 0x30
## prepare
addi r1, r1, -rmwAdd
stmw rmw, rmwOff(r1)
lis r3, aBase@h
la rTArr, $QFST.ts-aBase(r3)
lwz rCnt, $QFST.cnt-aBase(r3)
li rY, y
lis r817F, 0x817F
lha rY0, $QFST.drawTextOpt+2@l(r817F)
la rTArr, $QFST.ts@l(r817F)
lhz rCnt, $QFST.cnt@l(r817F)
mr rY, rY0
lwz rFontSize, $QFST.drawTextOpt+4@l(r817F)
.QFST.render.update:
### check is QFT frozen
### r6 = freeze duration
lwz r6, $QFT.freezeDur-aBase(r3)
cmpwi r6, 0
lwz r6, $QFT.freezeDur@l(r817F)
cmplwi r6, 0
beq+ .QFST.render.update.done
### check is new frozen time
### r4 = tFreeze = QFT display time when freezed
### r5 = t0
lwz r4, $QFT.tFreeze-aBase(r3)
lwz r5, $QFST.t0-aBase(r3)
lwz r4, $QFT.tFreeze@l(r817F)
lwz r5, $QFST.t0@l(r817F)
cmpw r4, r5
ble+ .QFST.render.update.done
### store diff
@ -57,78 +52,59 @@
rlwinm r12, rCnt, 2, 30-logN, 29
stwx r0, rTArr, r12
### update t0 = tFreeze
stw r4, $QFST.t0-aBase(r3)
stw r4, $QFST.t0@l(r817F)
### update cnt
addi rCnt, rCnt, 1
stw rCnt, $QFST.cnt-aBase(r3)
sth rCnt, $QFST.cnt@l(r817F)
.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:
### 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
cmpwi rCnt, 1<<logN
bge .QFST.render.preDraw.L1
li rIdx, 0
.QFST.render.preDraw.L1:
.QFST.render.preDraw.done:
.QFST.render.loop:
cmpw rIdx, rCnt
blt+ .QFST.render.loop.body
.QFST.render.done:
lmw rmw, rmwOff(r1)
addi r1, r1, rmwAdd
## orig
lis r3, 0x803b
b 4+$b$.QFST.render
cmplw rIdx, rCnt
bge- .QFST.render.done
.QFST.render.loop.body:
### QF -> s
rlwinm r3, rIdx, 2, 30-logN, 29 # offset
lwzx r0, rTArr, r3
#### r0 = dQF*1001
mulli r0, r0, 1001
#### r10 = dQF*1001/120 = ms
li r11, 120
divwu r10, r0, r11
#### r9 = ms/1000 = s
li r11, 1000
divwu r9, r10, r11
#### r10 = ms-s*1000 = ms%1000
mulli r11, r9, 1000
sub r10, r10, r11
#### r11 = dQF*1001
mulli r11, r0, 1001
#### r11 = dQF*1001/120 = ms
li r0, 120
divwu r11, r11, r0
#### r5 = ms/1000 = s
li r0, 1000
divwu r5, r11, r0
#### r6 = ms-s*1000 = ms%1000
mulli r0, r5, 1000
sub r6, r11, r0
### params
li r3, x
mr r4, rY
li r5, fontSize
liDX r6, colorTop
.if colorTop == colorBot
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
la r3, $QFST.drawTextOpt@l(r817F)
la r4, $QFST.fmt@l(r817F)
la r12, drawText@l(r817F)
mtlr r12
blrl
## next
#addi rIdx, rIdx, 1 # already added
.endif
addi rY, rY, fontSize
add rY, rY, rFontSize
addi rIdx, rIdx, 1
sth rY, $QFST.drawTextOpt+2@l(r817F)
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