Difference between revisions of "Wait for Vertical Sync"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:
 
  0001dcf8: afa50010 sw r5,0x0010(r29)
 
  0001dcf8: afa50010 sw r5,0x0010(r29)
 
  0001dcfc: 3c028003 lui r2,0x8003
 
  0001dcfc: 3c028003 lui r2,0x8003
  0001dd00: 8c4217b8 lw r2,0x17b8(r2)            #  RAM_WORD[0x800317b8]
+
  0001dd00: 8c4217b8 lw r2,0x17b8(r2)            #  RAM_WORD[0x800317b8] (Vcount?)
 
  0001dd04: 00000000 nop
 
  0001dd04: 00000000 nop
 
  0001dd08: 0044102a slt r2,r2,r4                 
 
  0001dd08: 0044102a slt r2,r2,r4                 
  0001dd0c: 1040001b beq r2,r0,0x0001dd7c        #  if (RAM_WORD[0x800317b8] >= r4), return (exit the routine)
+
  0001dd0c: 1040001b beq r2,r0,0x0001dd7c        #  if (RAM_WORD[0x800317b8] >= r4), return (exit the routine) <-- if already past requested vertical line, exit
 
  0001dd10: afbf0018 sw r31,0x0018(r29)
 
  0001dd10: afbf0018 sw r31,0x0018(r29)
 
  0001dd14: 2403ffff addiu r3,r0,0xffff          #  -1
 
  0001dd14: 2403ffff addiu r3,r0,0xffff          #  -1
 
   
 
   
 
                                                 #  do {
 
                                                 #  do {
  0001dd18: 8fa20010 lw r2,0x0010(r29)
+
  0001dd18: 8fa20010 lw r2,0x0010(r29) #r26 seems to point to this address (or below) during idle periods
 
  0001dd1c: 00000000 nop
 
  0001dd1c: 00000000 nop
 
  0001dd20: 2442ffff addiu r2,r2,0xffff          #      [Iterations remaining] = [Iterations remaining] - 1
 
  0001dd20: 2442ffff addiu r2,r2,0xffff          #      [Iterations remaining] = [Iterations remaining] - 1
Line 35: Line 35:
 
  0001dd5c: 0800775f j 0x0001dd7c                #          Return (exit the routine)
 
  0001dd5c: 0800775f j 0x0001dd7c                #          Return (exit the routine)
 
  0001dd60: 00000000 nop                          #      }
 
  0001dd60: 00000000 nop                          #      }
  0001dd64: 3c028003 lui r2,0x8003
+
  0001dd64: 3c028003 lui r2,0x8003 #r26 seems to point to this address (or above) during idle periods
  0001dd68: 8c4217b8 lw r2,0x17b8(r2)            #      RAM_WORD[0x800317b8]
+
  0001dd68: 8c4217b8 lw r2,0x17b8(r2)            #      RAM_WORD[0x800317b8] // seems to be current frame? like, total. ever.
 
  0001dd6c: 00000000 nop
 
  0001dd6c: 00000000 nop
 
  0001dd70: 0044102a slt r2,r2,r4
 
  0001dd70: 0044102a slt r2,r2,r4
  0001dd74: 1440ffe8 bne r2,r0,0x0001dd18        #  } while (RAM_WORD[0x800317b8] < r4)
+
  0001dd74: 1440ffe8 bne r2,r0,0x0001dd18        #  } while (RAM_WORD[0x800317b8] < r4) //loop while current frame still is not next frame? <-- actually loop while still waiting for vertical line p1?
 
  0001dd78: 00000000 nop
 
  0001dd78: 00000000 nop
 
  0001dd7c: 8fbf0018 lw r31,0x0018(r29)
 
  0001dd7c: 8fbf0018 lw r31,0x0018(r29)

Latest revision as of 10:25, 16 May 2024

#   ROUTINE: WAIT FOR VERTICAL SYNC
#   Parameters:
#       r4 = Value to wait for
#       r5 = Amount of time to wait?
0001dcf0: 27bdffe0 addiu r29,r29,0xffe0
0001dcf4: 00052bc0 sll r5,r5,0x0f               #   [Iterations remaining] = r5 * 32768
0001dcf8: afa50010 sw r5,0x0010(r29)
0001dcfc: 3c028003 lui r2,0x8003
0001dd00: 8c4217b8 lw r2,0x17b8(r2)             #   RAM_WORD[0x800317b8] (Vcount?)
0001dd04: 00000000 nop
0001dd08: 0044102a slt r2,r2,r4                 
0001dd0c: 1040001b beq r2,r0,0x0001dd7c         #   if (RAM_WORD[0x800317b8] >= r4), return (exit the routine) <-- if already past requested vertical line, exit
0001dd10: afbf0018 sw r31,0x0018(r29)
0001dd14: 2403ffff addiu r3,r0,0xffff           #   -1

                                                #   do {
0001dd18: 8fa20010 lw r2,0x0010(r29)		 #r26 seems to point to this address (or below) during idle periods
0001dd1c: 00000000 nop
0001dd20: 2442ffff addiu r2,r2,0xffff           #       [Iterations remaining] = [Iterations remaining] - 1
0001dd24: afa20010 sw r2,0x0010(r29)            
0001dd28: 8fa20010 lw r2,0x0010(r29)
0001dd2c: 00000000 nop
0001dd30: 1443000c bne r2,r3,0x0001dd64         #       if ([Iterations remaining] == -1) {
0001dd34: 00000000 nop
0001dd38: 3c048001 lui r4,0x8001
0001dd3c: 24840108 addiu r4,r4,0x0108           #           0x80010108: "VSync: timeout" (Comes from address 0x908 in SCUS_942.21)
0001dd40: 0c0088a3 jal 0x0002228c               #           PSX kernel function call: std_out_puts("VSync: timeout") - Writes message to terminal
0001dd44: 00000000 nop
0001dd48: 0c00883d jal 0x000220f4               #           PSX kernel function call: ChangeClearPad(0)
0001dd4c: 00002021 addu r4,r0,r0                       
0001dd50: 34040003 ori r4,r0,0x0003
0001dd54: 0c008841 jal 0x00022104               #           PSX kernel function call: ChangeClearRCnt(3, 0)
0001dd58: 00002821 addu r5,r0,r0                
0001dd5c: 0800775f j 0x0001dd7c                 #           Return (exit the routine)
0001dd60: 00000000 nop                          #       }
0001dd64: 3c028003 lui r2,0x8003		 #r26 seems to point to this address (or above) during idle periods
0001dd68: 8c4217b8 lw r2,0x17b8(r2)             #       RAM_WORD[0x800317b8] // seems to be current frame? like, total. ever.
0001dd6c: 00000000 nop
0001dd70: 0044102a slt r2,r2,r4
0001dd74: 1440ffe8 bne r2,r0,0x0001dd18         #   } while (RAM_WORD[0x800317b8] < r4) //loop while current frame still is not next frame? <-- actually loop while still waiting for vertical line p1?
0001dd78: 00000000 nop
0001dd7c: 8fbf0018 lw r31,0x0018(r29)
0001dd80: 27bd0020 addiu r29,r29,0x0020
0001dd84: 03e00008 jr r31
0001dd88: 00000000 nop