Advertisement
fastman92

GTA LCS: loadSaveSubsegmentUnknown

Dec 8th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 00300C10      # =============== S U B R O U T I N E =======================================
  2. .text:00300C10
  3. .text:00300C10
  4. .text:00300C10     _loadSaveSubsegmentUnknown:              # CODE XREF: _loadSaveGame+120p
  5. .text:00300C10
  6. .text:00300C10     var_30          = -0x30
  7. .text:00300C10     var_28          = -0x28
  8. .text:00300C10     var_20          = -0x20
  9. .text:00300C10     var_18          = -0x18
  10. .text:00300C10     var_10          = -0x10
  11. .text:00300C10
  12. .text:00300C10 000                 addiu   $sp, -0x30
  13. .text:00300C14 030                 sd      $s1, 0x30+var_28($sp)
  14. .text:00300C18 030                 sd      $s0, 0x30+var_30($sp)
  15. .text:00300C1C 030                 addiu   $s1, $a0, 8
  16. .text:00300C20 030                 sd      $s3, 0x30+var_18($sp)
  17. .text:00300C24 030                 sd      $ra, 0x30+var_10($sp)
  18. .text:00300C28 030                 sd      $s2, 0x30+var_20($sp)
  19. .text:00300C2C 030                 lw      $a0, CTheScripts__pScriptSpace
  20. .text:00300C34 030                 lw      $s2, 0($s1)      # __int32 s2 = *(__int32*)(*char*)a0 + 8
  21. .text:00300C38 030                 addiu   $s1, 4           # s1 = a0 + 12, pScriptSpace[0] is supposed to be equal to *(BYTE*)s1
  22. .text:00300C3C 030                 lbu     $v1, 0($a0)      # char v1 = pScriptSpace[0];
  23. .text:00300C40 030                 lbu     $v0, 0($s1)      # char s1 = *(char*)a0 + 0xC
  24. .text:00300C44 030                 bnel    $v1, $v0, SaveGameMismatch  # branch if (v1 != v0)
  25. .text:00300C48 030                 lui     $a0, 0x3C
  26. .text:00300C4C 030                 lbu     $v1, a41m30m5mwarningWarningAnAttemptWasMadeToUseTheDe+0x54  # 0x6E ('n') value
  27. .text:00300C50 030                 lbu     $v0, 4($s1)      # BYTE v0 = *(BYTE*)a0 + 16
  28. .text:00300C54 030                 beq     $v1, $v0, Process  # branch if (v0 == 'n')
  29. .text:00300C58 030                 lui     $a0, 0x3C
  30. .text:00300C5C
  31. .text:00300C5C     SaveGameMismatch:                        # CODE XREF: _loadSaveSubsegmentUnknown+34j
  32. .text:00300C5C 030                 jal     _ShowLoadingTextures
  33. .text:00300C60 030                 addiu   $a0, (aSaveGameM - 0x3C0000)  # "\n======================================"...
  34. .text:00300C64 030                 b       return
  35. .text:00300C68 030                 move    $v0, $zero
  36. .text:00300C6C      # ---------------------------------------------------------------------------
  37. .text:00300C6C
  38. .text:00300C6C     Process:                                 # CODE XREF: _loadSaveSubsegmentUnknown+44j
  39. .text:00300C6C 030                 beqz    $s2, returnTrue
  40. .text:00300C70 030                 move    $s0, $zero       # s0 = 0
  41. .text:00300C74 030                 li      $s3, 0xFFFFFFFF  # s3 = -1, index undefined
  42. .text:00300C78     Variables now:
  43. .text:00300C78     s0 = 0
  44. .text:00300C78     s3 = -1
  45. .text:00300C78     s1 = a0 + 12, pScriptSpace[0] is supposed to be equal to *(BYTE*)s1
  46. .text:00300C78     s2 = max offset of global variables, must have been loaded from save
  47. .text:00300C78
  48. .text:00300C78     loc_300C78:                              # CODE XREF: _loadSaveSubsegmentUnknown+BCj
  49. .text:00300C78 030                 sltiu   $v0, $s0, 8      # v0 = s0 < 8;  example v0 = 4 < 8 = 1; v0 = 8 < 8 = 0;
  50. .text:00300C7C 030                 bnez    $v0, PutValueFromSave  # v0 = &CTheScripts::pScriptSpace[s0]
  51. .text:00300C80 030                 lw      $v0, -0x7DFC($gp)  # points to 0x3CF0F4 - CTheScripts::pScriptSpace
  52. .text:00300C84     Continue here only if s0 >= 8
  53. .text:00300C84 030                 jal     _getIndexOfVariableIDInSegmentOfSavedVariables  # returned values with standard main.scm: (24) = 0, (28) = 1, (32) = 2...
  54. .text:00300C88 030                 move    $a0, $s0
  55. .text:00300C8C 030                 beq     $v0, $s3, PutZeroValue
  56. .text:00300C90 030                 lw      $v0, -0x7DFC($gp)  # points to 0x3CF0F4 - CTheScripts::pScriptSpace
  57. .text:00300C94
  58. .text:00300C94     PutValueFromSave:                        # CODE XREF: _loadSaveSubsegmentUnknown+6Cj
  59. .text:00300C94 030                 addu    $v0, $s0         # v0 = &CTheScripts::pScriptSpace[s0]
  60. .text:00300C98 030                 lwl     $v1, 3($s1)
  61. .text:00300C9C 030                 lwr     $v1, 0($s1)      # v1 = value from save
  62. .text:00300CA0 030                 swl     $v1, 3($v0)
  63. .text:00300CA4 030                 b       LoopContinue
  64. .text:00300CA8 030                 swr     $v1, 0($v0)      # put value from save into MAIN.scm script space
  65. .text:00300CAC      # ---------------------------------------------------------------------------
  66. .text:00300CAC
  67. .text:00300CAC     PutZeroValue:                            # CODE XREF: _loadSaveSubsegmentUnknown+7Cj
  68. .text:00300CAC 030                 lw      $a0, CTheScripts__pScriptSpace
  69. .text:00300CB4 030                 move    $a1, $zero       # value
  70. .text:00300CB8 030                 li      $a2, 4           # num
  71. .text:00300CBC 030                 jal     memset
  72. .text:00300CC0 030                 addu    $a0, $s0
  73. .text:00300CC4
  74. .text:00300CC4     LoopContinue:                            # CODE XREF: _loadSaveSubsegmentUnknown+94j
  75. .text:00300CC4 030                 addiu   $s0, 4
  76. .text:00300CC8 030                 sltu    $v0, $s0, $s2
  77. .text:00300CCC 030                 bnez    $v0, loc_300C78
  78. .text:00300CD0 030                 addiu   $s1, 4
  79. .text:00300CD4
  80. .text:00300CD4     returnTrue:                              # CODE XREF: _loadSaveSubsegmentUnknown:Processj
  81. .text:00300CD4 030                 li      $v0, 1
  82. .text:00300CD8
  83. .text:00300CD8     return:                                  # CODE XREF: _loadSaveSubsegmentUnknown+54j
  84. .text:00300CD8 030                 ld      $s0, 0x30+var_30($sp)
  85. .text:00300CDC 030                 ld      $s1, 0x30+var_28($sp)
  86. .text:00300CE0 030                 ld      $s2, 0x30+var_20($sp)
  87. .text:00300CE4 030                 ld      $s3, 0x30+var_18($sp)
  88. .text:00300CE8 030                 ld      $ra, 0x30+var_10($sp)
  89. .text:00300CEC 030                 jr      $ra
  90. .text:00300CF0 030                 addiu   $sp, 0x30
  91. .text:00300CF0      # End of function _loadSaveSubsegmentUnknown
  92. .text:00300CF0
  93. .text:00300CF0      # ---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement