diff --git a/NTSC-J 1.0/QFST.txt b/NTSC-J 1.0/QFST.txt new file mode 100644 index 0000000..85e4610 --- /dev/null +++ b/NTSC-J 1.0/QFST.txt @@ -0,0 +1,34 @@ +$ QF Segment Timer (v0.1.0, 2022/10/22) [sup39] +040F9DD0 496FDE78 +042069D0 495F128C +077F7C48 000000F0 +3BA00000 3C60817F +93A37C40 93A37C44 +4A90217C 38610E90 +4A83D5C9 3821FFE0 +BF81000C 3C60817F +3BE37C00 83C37C40 +3BA00096 80C300BC +2C060000 41A2002C +808300B8 80A37C44 +7C042800 40A1001C +7C052050 57CC16BA +7C1F612E 90837C44 +3BDE0001 93C37C40 +3B9EFFF0 2C1E0010 +40800008 3B800000 +7C1CF000 41A00014 +BB81000C 38210020 +3C60803B 4AA0ED00 +578316BA 7C1F182E +1C0003E9 39600078 +7D405B96 396003E8 +7D2A5B96 1D6903E8 +7D4B5050 38600214 +7FA4EB78 38A0000D +38C0FFFF 7CC73378 +48000011 2532642E +25303364 00000000 +7D0802A6 4CC63182 +4BFF8511 3B9C0001 +3BBD000D 4BFFFF8C diff --git a/src/QFST.ld b/src/QFST.ld new file mode 100644 index 0000000..f01fc11 --- /dev/null +++ b/src/QFST.ld @@ -0,0 +1,12 @@ +/* @ha MUST be 0x817f */ +$QFST.ts = 0x817f7c00; +$QFST.cnt = 0x817f7c40; +$QFST.t0 = 0x817f7c44; +$$ = 0x817f7c48; + +$QFT.tFreeze = 0x817f00b8; +$QFT.freezeDur = 0x817f00bc; + +$b$.QFST.reset = 0x800f9dd0; +$b$.QFST.render = 0x802069d0; +drawText = 0x817f0238; diff --git a/src/QFST.s b/src/QFST.s new file mode 100644 index 0000000..0135af9 --- /dev/null +++ b/src/QFST.s @@ -0,0 +1,116 @@ +.set x, 532 +.set y, 150 +.set fontSize, 13 +.set colorTop, 0xffffffff +.set colorBot, 0xffffffff +.set logN, 4 + +.set aBase, 0x817f<<16 +.QFST.reset: + 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 + +.set rmw, r28 +.set rmwOff, 0xC +.set rmwAdd, 0x20 +.set rTArr, r31 +.set rCnt, r30 +.set rY, r29 +.set rIdx, r28 +.QFST.render: +.QFST.render.setup: + addi r3, r1, 0xE90 + bl J2DGrafContext.setup2D +## 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 +.QFST.render.update: +### check is QFT frozen +### r6 = freeze duration + lwz r6, $QFT.freezeDur-aBase(r3) + cmpwi 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) + cmpw r4, r5 + ble+ .QFST.render.update.done +### store diff + sub r0, r4, r5 # diff + rlwinm r12, rCnt, 2, 30-logN, 29 + stwx r0, rTArr, r12 +### update t0 = tFreeze + stw r4, $QFST.t0-aBase(r3) +### update cnt + addi rCnt, rCnt, 1 + stw rCnt, $QFST.cnt-aBase(r3) +.QFST.render.update.done: +.QFST.render.preDraw: +### idx = max(0, cnt-N) + subi rIdx, rCnt, 1< 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 +### params + li r3, x + mr r4, rY + li r5, fontSize +.if colorTop < 0x8000 || colorTop >= 0xffff8000 + li r6, colorTop@l +.else + lis r6, colorTop@h + ori r6, r6, colorTop@l +.endif +.if colorTop == colorBot + mr r7, r6 +.elseif colorBot < 0x8000 || colorBot >= 0xffff8000 + li r7, colorBot@l +.else + lis r7, colorBot@h + ori r7, r7, colorBot@l +.endif + bl .draw2D.fmt + .string "%2d.%03d" + .align 2 +.draw2D.fmt: + mflr r8 + crclr 6 + bl drawText +## next + addi rIdx, rIdx, 1 + addi rY, rY, fontSize + b .QFST.render.loop