Advertisement
Bond697

GameFreak Heap Allocation Gen 5

Mar 4th, 2012
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RAM_ARM9:0203A228             ; =============== S U B R O U T I N E =======================================
  2. RAM_ARM9:0203A228
  3. RAM_ARM9:0203A228
  4. RAM_ARM9:0203A228             ; void *__fastcall allocateBlockFromExpHeap(int blkGroupID, u32 blockLength, bool clearBlock, const char *pSourceFile, int marker)
  5. RAM_ARM9:0203A228             allocateBlockFromExpHeap                ; CODE XREF: setupMainGFSystems+EEp
  6. RAM_ARM9:0203A228                                                     ; setupMainGFSystems+108p ...
  7. RAM_ARM9:0203A228
  8. RAM_ARM9:0203A228             pSourceSrc      = -0x18
  9. RAM_ARM9:0203A228             marker          =  0
  10. RAM_ARM9:0203A228
  11. RAM_ARM9:0203A228 F8 B5                       PUSH    {R3-R7,LR}
  12. RAM_ARM9:0203A22A 06 1C                       MOVS    R6, R0
  13. RAM_ARM9:0203A22C 0D 1C                       MOVS    R5, R1
  14. RAM_ARM9:0203A22E 17 1C                       MOVS    R7, R2
  15. RAM_ARM9:0203A230 00 93                       STR     R3, [SP,#0x18+pSourceSrc]
  16. RAM_ARM9:0203A232 FF F7 C9 FD                 BL      getNewBlockFromHeapNum
  17. RAM_ARM9:0203A236 04 1C                       MOVS    R4, R0
  18. RAM_ARM9:0203A238 0B D1                       BNE     loc_203A252
  19. RAM_ARM9:0203A23A FF F7 43 FF                 BL      getAllocatorStatus
  20. RAM_ARM9:0203A23E 06 AB                       ADD     R3, SP, #0x18+marker
  21. RAM_ARM9:0203A240 1B 88                       LDRH    R3, [R3]
  22. RAM_ARM9:0203A242 00 9A                       LDR     R2, [SP,#0x18+pSourceSrc]
  23. RAM_ARM9:0203A244 30 1C                       MOVS    R0, R6          ; blkGroupID
  24. RAM_ARM9:0203A246 29 1C                       MOVS    R1, R5          ; blockLength
  25. RAM_ARM9:0203A248 00 F0 9A F8                 BL      abortIfBlockIsAllocatedWrong
  26. RAM_ARM9:0203A24C             ; ---------------------------------------------------------------------------
  27. RAM_ARM9:0203A24C 42 F0 A8 FA                 BL      OS_Panic
  28. RAM_ARM9:0203A250 10 E0                       B       loc_203A274
  29. RAM_ARM9:0203A252             ; ---------------------------------------------------------------------------
  30. RAM_ARM9:0203A252
  31. RAM_ARM9:0203A252             loc_203A252                             ; CODE XREF: allocateBlockFromExpHeap+10j
  32. RAM_ARM9:0203A252 06 AA                       ADD     R2, SP, #0x18
  33. RAM_ARM9:0203A254 12 88                       LDRH    R2, [R2]        ; marker
  34. RAM_ARM9:0203A256 00 99                       LDR     R1, [SP,#0x18+pSourceSrc] ; pSourceSrc
  35. RAM_ARM9:0203A258 00 F0 58 F8                 BL      copySourceFileToAllocatedBlock
  36. RAM_ARM9:0203A25C 30 1C                       MOVS    R0, R6          ; blkGroupID
  37. RAM_ARM9:0203A25E 21 1C                       MOVS    R1, R4          ; pBlk
  38. RAM_ARM9:0203A260 2A 1C                       MOVS    R2, R5
  39. RAM_ARM9:0203A262 00 F0 C9 F8                 BL      verifySysBlkGroup
  40. RAM_ARM9:0203A266 00 2F                       CMP     R7, #0
  41. RAM_ARM9:0203A268 04 D0                       BEQ     loc_203A274
  42. RAM_ARM9:0203A26A 00 20                       MOVS    R0, #0          ; data
  43. RAM_ARM9:0203A26C 21 1C                       MOVS    R1, R4          ; pSrc
  44. RAM_ARM9:0203A26E 2A 1C                       MOVS    R2, R5          ; dataSize
  45. RAM_ARM9:0203A270 3E F0 08 EA                 BLX     MIi_CpuClear32
  46. RAM_ARM9:0203A274
  47. RAM_ARM9:0203A274             loc_203A274                             ; CODE XREF: allocateBlockFromExpHeap+28j
  48. RAM_ARM9:0203A274                                                     ; allocateBlockFromExpHeap+40j
  49. RAM_ARM9:0203A274 20 1C                       MOVS    R0, R4
  50. RAM_ARM9:0203A276 F8 BD                       POP     {R3-R7,PC}
  51. RAM_ARM9:0203A276             ; End of function allocateBlockFromExpHeap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement