Difference between revisions of "VSync call"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
 +
Hsync/Hcount?
 
  0001dba8: 3c028003 lui r2,0x8003
 
  0001dba8: 3c028003 lui r2,0x8003
  0001dbac: 8c4206ec lw r2,0x06ec(r2)
+
  0001dbac: 8c4206ec lw r2,0x06ec(r2)         # GPU control pointer
 
  0001dbb0: 3c038003 lui r3,0x8003
 
  0001dbb0: 3c038003 lui r3,0x8003
  0001dbb4: 8c6306f0 lw r3,0x06f0(r3)
+
  0001dbb4: 8c6306f0 lw r3,0x06f0(r3)         # timer 1 horizontal retrace
 
  0001dbb8: 27bdffe0 addiu r29,r29,0xffe0
 
  0001dbb8: 27bdffe0 addiu r29,r29,0xffe0
 
  0001dbbc: afbf0018 sw r31,0x0018(r29)
 
  0001dbbc: afbf0018 sw r31,0x0018(r29)
 
  0001dbc0: afb10014 sw r17,0x0014(r29)
 
  0001dbc0: afb10014 sw r17,0x0014(r29)
 
  0001dbc4: afb00010 sw r16,0x0010(r29)
 
  0001dbc4: afb00010 sw r16,0x0010(r29)
  0001dbc8: 8c500000 lw r16,0x0000(r2)
+
  0001dbc8: 8c500000 lw r16,0x0000(r2)       # read GPU Status
  0001dbcc: 8c620000 lw r2,0x0000(r3)
+
  0001dbcc: 8c620000 lw r2,0x0000(r3)         # horizontal retrace timer 1 result
 
  0001dbd0: 3c038003 lui r3,0x8003
 
  0001dbd0: 3c038003 lui r3,0x8003
  0001dbd4: 8c6306f4 lw r3,0x06f4(r3)
+
  0001dbd4: 8c6306f4 lw r3,0x06f4(r3)         # horz. retrace count?
 
  0001dbd8: 00000000 nop
 
  0001dbd8: 00000000 nop
  0001dbdc: 00431023 subu r2,r2,r3
+
  0001dbdc: 00431023 subu r2,r2,r3           #
 
  0001dbe0: 04810005 bgez r4,0x0001dbf8
 
  0001dbe0: 04810005 bgez r4,0x0001dbf8
 
  0001dbe4: 3051ffff andi r17,r2,0xffff
 
  0001dbe4: 3051ffff andi r17,r2,0xffff
 
  0001dbe8: 3c028003 lui r2,0x8003
 
  0001dbe8: 3c028003 lui r2,0x8003
  0001dbec: 8c4217b8 lw r2,0x17b8(r2)
+
  0001dbec: 8c4217b8 lw r2,0x17b8(r2)         # ... vcount?
 
  0001dbf0: 08007736 j 0x0001dcd8
 
  0001dbf0: 08007736 j 0x0001dcd8
 
  0001dbf4: 00000000 nop
 
  0001dbf4: 00000000 nop
 +
p1 > 1
 
  0001dbf8: 34020001 ori r2,r0,0x0001
 
  0001dbf8: 34020001 ori r2,r0,0x0001
  0001dbfc: 10820036 beq r4,r2,0x0001dcd8
+
  0001dbfc: 10820036 beq r4,r2,0x0001dcd8     # end if p1 = 1
 
  0001dc00: 02201021 addu r2,r17,r0
 
  0001dc00: 02201021 addu r2,r17,r0
 
  0001dc04: 18800007 blez r4,0x0001dc24
 
  0001dc04: 18800007 blez r4,0x0001dc24
 
  0001dc08: 00000000 nop
 
  0001dc08: 00000000 nop
 
  0001dc0c: 3c028003 lui r2,0x8003
 
  0001dc0c: 3c028003 lui r2,0x8003
  0001dc10: 8c4206f8 lw r2,0x06f8(r2)
+
  0001dc10: 8c4206f8 lw r2,0x06f8(r2)         # Vcount?
 
  0001dc14: 00000000 nop
 
  0001dc14: 00000000 nop
  0001dc18: 2442ffff addiu r2,r2,0xffff
+
  0001dc18: 2442ffff addiu r2,r2,0xffff       # i--
 
  0001dc1c: 0800770b j 0x0001dc2c
 
  0001dc1c: 0800770b j 0x0001dc2c
  0001dc20: 00441021 addu r2,r2,r4
+
  0001dc20: 00441021 addu r2,r2,r4           # Vcount? + p1
 +
p1 = 0
 
  0001dc24: 3c028003 lui r2,0x8003
 
  0001dc24: 3c028003 lui r2,0x8003
  0001dc28: 8c4206f8 lw r2,0x06f8(r2)
+
  0001dc28: 8c4206f8 lw r2,0x06f8(r2)         # Vcount?
 +
 
  0001dc2c: 18800002 blez r4,0x0001dc38
 
  0001dc2c: 18800002 blez r4,0x0001dc38
  0001dc30: 00002821 addu r5,r0,r0
+
  0001dc30: 00002821 addu r5,r0,r0           # if p1 = 0
  0001dc34: 2485ffff addiu r5,r4,0xffff
+
  0001dc34: 2485ffff addiu r5,r4,0xffff       # if p1 = 1
  0001dc38: 0c00773c jal 0x0001dcf0
+
  0001dc38: 0c00773c jal 0x0001dcf0           # [[Wait for Vertical Sync]] Vsync(Vcount, -1)
  0001dc3c: 00402021 addu r4,r2,r0
+
  0001dc3c: 00402021 addu r4,r2,r0           #
 
  0001dc40: 3c028003 lui r2,0x8003
 
  0001dc40: 3c028003 lui r2,0x8003
  0001dc44: 8c4206ec lw r2,0x06ec(r2)
+
  0001dc44: 8c4206ec lw r2,0x06ec(r2)         # GPU CTRL
 
  0001dc48: 00000000 nop
 
  0001dc48: 00000000 nop
  0001dc4c: 8c500000 lw r16,0x0000(r2)
+
  0001dc4c: 8c500000 lw r16,0x0000(r2)       # GPU STAT
 
  0001dc50: 3c048003 lui r4,0x8003
 
  0001dc50: 3c048003 lui r4,0x8003
  0001dc54: 8c8417b8 lw r4,0x17b8(r4)
+
  0001dc54: 8c8417b8 lw r4,0x17b8(r4)         # vcount?
 
  0001dc58: 34050001 ori r5,r0,0x0001
 
  0001dc58: 34050001 ori r5,r0,0x0001
  0001dc5c: 0c00773c jal 0x0001dcf0
+
  0001dc5c: 0c00773c jal 0x0001dcf0           # [[Wait for Vertical Sync]] Vsync(Vcount + 1, 1)
 
  0001dc60: 24840001 addiu r4,r4,0x0001
 
  0001dc60: 24840001 addiu r4,r4,0x0001
 
  0001dc64: 3c020008 lui r2,0x0008
 
  0001dc64: 3c020008 lui r2,0x0008
  0001dc68: 02021024 and r2,r16,r2
+
  0001dc68: 02021024 and r2,r16,r2           # ask GPU for vertical resolution
  0001dc6c: 10400010 beq r2,r0,0x0001dcb0
+
  0001dc6c: 10400010 beq r2,r0,0x0001dcb0     # branch if vres = 240p
 
  0001dc70: 00000000 nop
 
  0001dc70: 00000000 nop
 +
 +
vertical resolution = 480p
 
  0001dc74: 3c038003 lui r3,0x8003
 
  0001dc74: 3c038003 lui r3,0x8003
 
  0001dc78: 8c6306ec lw r3,0x06ec(r3)
 
  0001dc78: 8c6306ec lw r3,0x06ec(r3)
 
  0001dc7c: 00000000 nop
 
  0001dc7c: 00000000 nop
  0001dc80: 8c620000 lw r2,0x0000(r3)
+
  0001dc80: 8c620000 lw r2,0x0000(r3)         # GPU STAT
 
  0001dc84: 00000000 nop
 
  0001dc84: 00000000 nop
  0001dc88: 02021026 xor r2,r16,r2
+
  0001dc88: 02021026 xor r2,r16,r2           # if gpu status has changed since it was last asked for
  0001dc8c: 04400008 bltz r2,0x0001dcb0
+
  0001dc8c: 04400008 bltz r2,0x0001dcb0       # branch check if interlace line even/oddness has changed
 
  0001dc90: 00000000 nop
 
  0001dc90: 00000000 nop
 
  0001dc94: 3c048000 lui r4,0x8000
 
  0001dc94: 3c048000 lui r4,0x8000
  0001dc98: 8c620000 lw r2,0x0000(r3)
+
  0001dc98: 8c620000 lw r2,0x0000(r3)         # GPU STAT
 
  0001dc9c: 00000000 nop
 
  0001dc9c: 00000000 nop
  0001dca0: 02021026 xor r2,r16,r2
+
  0001dca0: 02021026 xor r2,r16,r2           # if gpu status has changed since it was last asked for
  0001dca4: 00441024 and r2,r2,r4
+
  0001dca4: 00441024 and r2,r2,r4             #
  0001dca8: 1040fffb beq r2,r0,0x0001dc98
+
  0001dca8: 1040fffb beq r2,r0,0x0001dc98     # wait until interlace even/oddness has changed
 
  0001dcac: 00000000 nop
 
  0001dcac: 00000000 nop
 +
 +
vertical resolution = 240p
 
  0001dcb0: 3c028003 lui r2,0x8003
 
  0001dcb0: 3c028003 lui r2,0x8003
  0001dcb4: 8c4217b8 lw r2,0x17b8(r2)
+
  0001dcb4: 8c4217b8 lw r2,0x17b8(r2)         # vcount?
 
  0001dcb8: 3c038003 lui r3,0x8003
 
  0001dcb8: 3c038003 lui r3,0x8003
  0001dcbc: 8c6306f0 lw r3,0x06f0(r3)
+
  0001dcbc: 8c6306f0 lw r3,0x06f0(r3)         # timer 1 horizontal retrace
 
  0001dcc0: 3c018003 lui r1,0x8003
 
  0001dcc0: 3c018003 lui r1,0x8003
  0001dcc4: ac2206f8 sw r2,0x06f8(r1)
+
  0001dcc4: ac2206f8 sw r2,0x06f8(r1)         # store new Vcount
  0001dcc8: 8c630000 lw r3,0x0000(r3)
+
  0001dcc8: 8c630000 lw r3,0x0000(r3)         #
  0001dccc: 02201021 addu r2,r17,r0
+
  0001dccc: 02201021 addu r2,r17,r0           #
 
  0001dcd0: 3c018003 lui r1,0x8003
 
  0001dcd0: 3c018003 lui r1,0x8003
  0001dcd4: ac2306f4 sw r3,0x06f4(r1)
+
  0001dcd4: ac2306f4 sw r3,0x06f4(r1)         # store new horizontal retrace
 +
return
 
  0001dcd8: 8fbf0018 lw r31,0x0018(r29)
 
  0001dcd8: 8fbf0018 lw r31,0x0018(r29)
 
  0001dcdc: 8fb10014 lw r17,0x0014(r29)
 
  0001dcdc: 8fb10014 lw r17,0x0014(r29)

Latest revision as of 10:25, 16 May 2024

Hsync/Hcount?

0001dba8: 3c028003 lui r2,0x8003
0001dbac: 8c4206ec lw r2,0x06ec(r2)         # GPU control pointer
0001dbb0: 3c038003 lui r3,0x8003
0001dbb4: 8c6306f0 lw r3,0x06f0(r3)         # timer 1 horizontal retrace
0001dbb8: 27bdffe0 addiu r29,r29,0xffe0
0001dbbc: afbf0018 sw r31,0x0018(r29)
0001dbc0: afb10014 sw r17,0x0014(r29)
0001dbc4: afb00010 sw r16,0x0010(r29)
0001dbc8: 8c500000 lw r16,0x0000(r2)        # read GPU Status
0001dbcc: 8c620000 lw r2,0x0000(r3)         # horizontal retrace timer 1 result
0001dbd0: 3c038003 lui r3,0x8003
0001dbd4: 8c6306f4 lw r3,0x06f4(r3)         # horz. retrace count?
0001dbd8: 00000000 nop
0001dbdc: 00431023 subu r2,r2,r3            # 
0001dbe0: 04810005 bgez r4,0x0001dbf8
0001dbe4: 3051ffff andi r17,r2,0xffff
0001dbe8: 3c028003 lui r2,0x8003
0001dbec: 8c4217b8 lw r2,0x17b8(r2)         # ... vcount?
0001dbf0: 08007736 j 0x0001dcd8
0001dbf4: 00000000 nop

p1 > 1

0001dbf8: 34020001 ori r2,r0,0x0001
0001dbfc: 10820036 beq r4,r2,0x0001dcd8     # end if p1 = 1
0001dc00: 02201021 addu r2,r17,r0
0001dc04: 18800007 blez r4,0x0001dc24
0001dc08: 00000000 nop
0001dc0c: 3c028003 lui r2,0x8003
0001dc10: 8c4206f8 lw r2,0x06f8(r2)         # Vcount?
0001dc14: 00000000 nop
0001dc18: 2442ffff addiu r2,r2,0xffff       # i--
0001dc1c: 0800770b j 0x0001dc2c
0001dc20: 00441021 addu r2,r2,r4            # Vcount? + p1

p1 = 0

0001dc24: 3c028003 lui r2,0x8003
0001dc28: 8c4206f8 lw r2,0x06f8(r2)         # Vcount?

0001dc2c: 18800002 blez r4,0x0001dc38
0001dc30: 00002821 addu r5,r0,r0            # if p1 = 0
0001dc34: 2485ffff addiu r5,r4,0xffff       # if p1 = 1
0001dc38: 0c00773c jal 0x0001dcf0           # Wait for Vertical Sync Vsync(Vcount, -1)
0001dc3c: 00402021 addu r4,r2,r0            # 
0001dc40: 3c028003 lui r2,0x8003
0001dc44: 8c4206ec lw r2,0x06ec(r2)         # GPU CTRL
0001dc48: 00000000 nop
0001dc4c: 8c500000 lw r16,0x0000(r2)        # GPU STAT
0001dc50: 3c048003 lui r4,0x8003
0001dc54: 8c8417b8 lw r4,0x17b8(r4)         # vcount?
0001dc58: 34050001 ori r5,r0,0x0001
0001dc5c: 0c00773c jal 0x0001dcf0           # Wait for Vertical Sync Vsync(Vcount + 1, 1)
0001dc60: 24840001 addiu r4,r4,0x0001
0001dc64: 3c020008 lui r2,0x0008
0001dc68: 02021024 and r2,r16,r2            # ask GPU for vertical resolution
0001dc6c: 10400010 beq r2,r0,0x0001dcb0     # branch if vres = 240p
0001dc70: 00000000 nop

vertical resolution = 480p

0001dc74: 3c038003 lui r3,0x8003
0001dc78: 8c6306ec lw r3,0x06ec(r3)
0001dc7c: 00000000 nop
0001dc80: 8c620000 lw r2,0x0000(r3)         # GPU STAT
0001dc84: 00000000 nop
0001dc88: 02021026 xor r2,r16,r2            # if gpu status has changed since it was last asked for
0001dc8c: 04400008 bltz r2,0x0001dcb0       # branch check if interlace line even/oddness has changed
0001dc90: 00000000 nop
0001dc94: 3c048000 lui r4,0x8000
0001dc98: 8c620000 lw r2,0x0000(r3)         # GPU STAT
0001dc9c: 00000000 nop
0001dca0: 02021026 xor r2,r16,r2            # if gpu status has changed since it was last asked for
0001dca4: 00441024 and r2,r2,r4             # 
0001dca8: 1040fffb beq r2,r0,0x0001dc98     # wait until interlace even/oddness has changed
0001dcac: 00000000 nop

vertical resolution = 240p

0001dcb0: 3c028003 lui r2,0x8003
0001dcb4: 8c4217b8 lw r2,0x17b8(r2)         # vcount?
0001dcb8: 3c038003 lui r3,0x8003
0001dcbc: 8c6306f0 lw r3,0x06f0(r3)         # timer 1 horizontal retrace
0001dcc0: 3c018003 lui r1,0x8003
0001dcc4: ac2206f8 sw r2,0x06f8(r1)         # store new Vcount
0001dcc8: 8c630000 lw r3,0x0000(r3)         # 
0001dccc: 02201021 addu r2,r17,r0           # 
0001dcd0: 3c018003 lui r1,0x8003
0001dcd4: ac2306f4 sw r3,0x06f4(r1)         # store new horizontal retrace

return

0001dcd8: 8fbf0018 lw r31,0x0018(r29)
0001dcdc: 8fb10014 lw r17,0x0014(r29)
0001dce0: 8fb00010 lw r16,0x0010(r29)
0001dce4: 27bd0020 addiu r29,r29,0x0020
0001dce8: 03e00008 jr r31
0001dcec: 00000000 nop

Return Locations

Battle.bin 
00193e74: Main AI action setup