Load file into RAM

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

Actually BIOS 2 CD_GetSector? doesn't load file according to documentation - transfers file from "buffer" to main ram in the background. I have been wrong before

00020650: 3c028003 lui r2,0x8003
00020654: 8c421b40 lw r2,0x1b40(r2)                # CDREG0
00020658: 3c060002 lui r6,0x0002
0002065c: a0400000 sb r0,0x0000(r2)                # store 0 at CDREG0
00020660: 3c038003 lui r3,0x8003
00020664: 8c631b4c lw r3,0x1b4c(r3)                # CDREG3
00020668: 34020080 ori r2,r0,0x0080                # CDREG0 && 0x80
0002066c: a0620000 sb r2,0x0000(r3)                # store unknown? in CDREG3
00020670: 3c028003 lui r2,0x8003
00020674: 8c421b74 lw r2,0x1b74(r2)                # hardware register address
00020678: 34c60943 ori r6,r6,0x0943                # r6 = 0x00020943
0002067c: ac460000 sw r6,0x0000(r2)                # ?
00020680: 3c038003 lui r3,0x8003
00020684: 8c631b50 lw r3,0x1b50(r3)
00020688: 34021323 ori r2,r0,0x1323
0002068c: ac620000 sw r2,0x0000(r3)                # 1323 into hardware address
00020690: 3c038003 lui r3,0x8003
00020694: 8c631b78 lw r3,0x1b78(r3)
00020698: 00000000 nop
0002069c: 8c620000 lw r2,0x0000(r3)
000206a0: 00000000 nop
000206a4: 34428000 ori r2,r2,0x8000
000206a8: ac620000 sw r2,0x0000(r3)                #
000206ac: 3c028003 lui r2,0x8003
000206b0: 8c421b7c lw r2,0x1b7c(r2)              # load hardware pointer for file -> ram address
000206b4: 00000000 nop
000206b8: ac440000 sw r4,0x0000(r2)              # store input 1 (memory address to store file into ram?)
000206bc: 3c020001 lui r2,0x0001
000206c0: 3c038003 lui r3,0x8003
000206c4: 8c631b80 lw r3,0x1b80(r3)              # no ref
000206c8: 00a22825 or r5,r5,r2                   # file size (?) OR 0x00010000 (not sure what this accomplishes. stores it to what I assume communicates with the CD-ROM reader)
000206cc: ac650000 sw r5,0x0000(r3)
000206d0: 3c038003 lui r3,0x8003
000206d4: 8c631b40 lw r3,0x1b40(r3)              # CDREG0
000206d8: 00000000 nop
000206dc: 90620000 lbu r2,0x0000(r3)             # 
000206e0: 00000000 nop
000206e4: 30420040 andi r2,r2,0x0040
000206e8: 1040fffb beq r2,r0,0x000206d8          # check if command is still being processed (loop here until finished)
000206ec: 3c021100 lui r2,0x1100
000206f0: 3c038003 lui r3,0x8003
000206f4: 8c631b84 lw r3,0x1b84(r3)              # no ref
000206f8: 00000000 nop
000206fc: ac620000 sw r2,0x0000(r3)
00020700: 3c048003 lui r4,0x8003
00020704: 8c841b84 lw r4,0x1b84(r4)
00020708: 00000000 nop
0002070c: 8c820000 lw r2,0x0000(r4)
00020710: 3c030100 lui r3,0x0100
00020714: 00431024 and r2,r2,r3
00020718: 10400007 beq r2,r0,0x00020738          #
0002071c: 00801821 addu r3,r4,r0
00020720: 3c040100 lui r4,0x0100
00020724: 8c620000 lw r2,0x0000(r3)
00020728: 00000000 nop
0002072c: 00441024 and r2,r2,r4
00020730: 1440fffc bne r2,r0,0x00020724
00020734: 00000000 nop
00020738: 3c038003 lui r3,0x8003
0002073c: 8c631b50 lw r3,0x1b50(r3)
00020740: 34021325 ori r2,r0,0x1325
00020744: ac620000 sw r2,0x0000(r3)              #store 1b501325 as hardware register address 
00020748: 03e00008 jr r31
0002074c: 00001021 addu r2,r0,r0                 # always return 0 (maybe it's not CDGetsector? but it could be an older version...)