Cd read retry

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

00020a64: 27bdffd8 addiu r29,r29,0xffd8
00020a68: afb1001c sw r17,0x001c(r29)
00020a6c: 00808821 addu r17,r4,r0
00020a70: 00002021 addu r4,r0,r0
00020a74: afbf0020 sw r31,0x0020(r29)
00020a78: 0c007ad6 jal 0x0001eb58                CdSyncCallback
00020a7c: afb00018 sw r16,0x0018(r29)
00020a80: 0c007adc jal 0x0001eb70                CdReadyCallback
00020a84: 00002021 addu r4,r0,r0
00020a88: 0c007a73 jal 0x0001e9cc                CdStatus
00020a8c: 00000000 nop
00020a90: 30420010 andi r2,r2,0x0010
00020a94: 10400017 beq r2,r0,0x00020af4          branch if shell closed
00020a98: 00000000 nop
00020a9c: 0c0076ea jal 0x0001dba8                VSync
00020aa0: 2404ffff addiu r4,r0,0xffff
00020aa4: 3042003f andi r2,r2,0x003f
00020aa8: 14400006 bne r2,r0,0x00020ac4          branch if, vsync is a multiple of 40?
00020aac: 34040001 ori r4,r0,0x0001
00020ab0: 3c048001 lui r4,0x8001
00020ab4: 24840438 addiu r4,r4,0x0438
00020ab8: 0c0088a3 jal 0x0002228c                Write String to Terminal "CdRead: Shell open...\n"
00020abc: 00000000 nop
00020ac0: 34040001 ori r4,r0,0x0001              issue NOP to CDrom
00020ac4: 0c007b30 jal 0x0001ecc0                CdControlF NOP
00020ac8: 00002821 addu r5,r0,r0
00020acc: 0c0076ea jal 0x0001dba8                VSync
00020ad0: 2404ffff addiu r4,r0,0xffff
00020ad4: 3c038003 lui r3,0x8003
00020ad8: 24631ba8 addiu r3,r3,0x1ba8            absolute time after program boot
00020adc: ac620000 sw r2,0x0000(r3)
00020ae0: 2402ffff addiu r2,r0,0xffff
00020ae4: 3c018003 lui r1,0x8003
00020ae8: ac221ba0 sw r2,0x1ba0(r1)              command failed?
00020aec: 08008307 j 0x00020c1c                  end
00020af0: 00000000 nop

closed shell

00020af4: 12200017 beq r17,r0,0x00020b54         if input 0, skip
00020af8: 00000000 nop
00020afc: 3c048001 lui r4,0x8001
00020b00: 24840450 addiu r4,r4,0x0450
00020b04: 0c0088a3 jal 0x0002228c                Write String to Terminal "CdRead: retry...\n"
00020b08: 00000000 nop
00020b0c: 34040009 ori r4,r0,0x0009              pause CD
00020b10: 00002821 addu r5,r0,r0
00020b14: 0c007ae2 jal 0x0001eb88                CdControl
00020b18: 00003021 addu r6,r0,r0
00020b1c: 0c007a7f jal 0x0001e9fc                CdLastPos
00020b20: 00000000 nop
00020b24: 34040002 ori r4,r0,0x0002              set seek target position
00020b28: 00402821 addu r5,r2,r0                 pointer to last CDpos CDlLoc
00020b2c: 0c007ae2 jal 0x0001eb88                CdControl
00020b30: 00003021 addu r6,r0,r0
00020b34: 14400007 bne r2,r0,0x00020b54          branch if command issued successfully
00020b38: 2403ffff addiu r3,r0,0xffff
00020b3c: 3c028003 lui r2,0x8003
00020b40: 24421ba0 addiu r2,r2,0x1ba0            command failed?
00020b44: ac430000 sw r3,0x0000(r2)              
00020b48: 8c420000 lw r2,0x0000(r2)
00020b4c: 08008309 j 0x00020c24                  return -1
00020b50: 00000000 nop

p1 = 0:

00020b54: 0c007a9e jal 0x0001ea78                CdFlush
00020b58: 00000000 nop
00020b5c: 3c028003 lui r2,0x8003
00020b60: 24421b98 addiu r2,r2,0x1b98
00020b64: 8c500000 lw r16,0x0000(r2)             CDRom subsystem mode
00020b68: 00000000 nop
00020b6c: a3b00010 sb r16,0x0010(r29)            
00020b70: 0c007a77 jal 0x0001e9dc                CdMode
00020b74: 321000ff andi r16,r16,0x00ff
00020b78: 16020003 bne r16,r2,0x00020b88         branch if they don't match
00020b7c: 3404000e ori r4,r0,0x000e              set mode
00020b80: 1220000a beq r17,r0,0x00020bac         branch if 0
00020b84: 00000000 nop
00020b88: 27a50010 addiu r5,r29,0x0010
00020b8c: 0c007ae2 jal 0x0001eb88                CdControl manually reset CD mode to intended value?
00020b90: 00003021 addu r6,r0,r0
00020b94: 14400005 bne r2,r0,0x00020bac          branch if successful
00020b98: 2402ffff addiu r2,r0,0xffff
00020b9c: 3c018003 lui r1,0x8003
00020ba0: ac221ba0 sw r2,0x1ba0(r1)              unsuccessful
00020ba4: 08008307 j 0x00020c1c                  end
00020ba8: 00000000 nop
00020bac: 0c007a7f jal 0x0001e9fc                CdLastPos
00020bb0: 00000000 nop
00020bb4: 0c007c30 jal 0x0001f0c0                CdPosToInt
00020bb8: 00402021 addu r4,r2,r0
00020bbc: 3c048002 lui r4,0x8002
00020bc0: 24840840 addiu r4,r4,0x0840            cb_read
00020bc4: 3c038003 lui r3,0x8003
00020bc8: 24631bac addiu r3,r3,0x1bac
00020bcc: ac620000 sw r2,0x0000(r3)              store LBA of last attempt at reading file
00020bd0: 0c007adc jal 0x0001eb70                CdReadyCallback initiate with cb_read on CD load
00020bd4: 00000000 nop
00020bd8: 34040006 ori r4,r0,0x0006              start data read
00020bdc: 3c028003 lui r2,0x8003
00020be0: 8c421b90 lw r2,0x1b90(r2)              load buffer address
00020be4: 00002821 addu r5,r0,r0
00020be8: 3c018003 lui r1,0x8003
00020bec: ac221b94 sw r2,0x1b94(r1)              store buffer address
00020bf0: 0c007b30 jal 0x0001ecc0                CdControlF
00020bf4: 00000000 nop
00020bf8: 3c028003 lui r2,0x8003
00020bfc: 8c421b8c lw r2,0x1b8c(r2)              load sector count
00020c00: 2404ffff addiu r4,r0,0xffff
00020c04: 3c018003 lui r1,0x8003
00020c08: ac221ba0 sw r2,0x1ba0(r1)              store sector count at cdread failstate?
00020c0c: 0c0076ea jal 0x0001dba8                VSync
00020c10: 00000000 nop
00020c14: 3c018003 lui r1,0x8003
00020c18: ac221ba4 sw r2,0x1ba4(r1)              store total vsync count since opening 

End

00020c1c: 3c028003 lui r2,0x8003
00020c20: 8c421ba0 lw r2,0x1ba0(r2)
00020c24: 8fbf0020 lw r31,0x0020(r29)
00020c28: 8fb1001c lw r17,0x001c(r29)
00020c2c: 8fb00018 lw r16,0x0018(r29)
00020c30: 27bd0028 addiu r29,r29,0x0028
00020c34: 03e00008 jr r31
00020c38: 00000000 nop