Advertisement
luckytyphlosion

GS VC ACE Bootstrap code v0.2

Nov 29th, 2017
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. hChecksumPrint EQU $ffe9
  2.  
  3. IF 0
  4. ld a, [wJumptableIndex]
  5. push af
  6. callw _Bootstrap
  7. pop af
  8. ld [wJumptableIndex], a
  9. ret
  10. ENDC
  11.  
  12. _Bootstrap:
  13. ld hl, wBoxNames
  14. ld a, [hli]
  15. ld b, a
  16. callw DecodeCharPairPointer
  17. ld h, d
  18. ld l, e ; hl = bootstrap dest or execute src
  19. ld a, b
  20. and "-"
  21. cp "-"
  22. jr nz, .notDirectExecute
  23. jp hl
  24. .notDirectExecute
  25. bit 2, b
  26. jr z, .bootstrap
  27. ld a, b
  28. and $3
  29. call OpenSRAM
  30. ld a, [hli]
  31. ld b, a
  32. ld a, [hli]
  33. ld c, a
  34. ld a, [hli]
  35. ld e, a
  36. ld a, [hli]
  37. ld d, a
  38. push de ; execute dest
  39. call CopyBytes
  40. call jp_de + 1 ; skip push de as de is already pushed
  41. jr .closeSRAM
  42. .bootstrap
  43. push bc ; save flags for later
  44. push de ; save dest for later
  45. bit 3, b
  46. ld de, wOverworldMap + $55 ; mail buffer dest
  47. ld hl, wBoxNames + 9
  48. callw nz, DecodeCharPairPointer
  49. push de ; save mail buffer dest for later
  50. .getBootstrapCharsLoop
  51. push de
  52. callba $4, _ComposeMailMessage
  53. pop hl
  54. push de
  55. ld bc, 0
  56. .checksumMsgLoop
  57. callw CharPairDecode
  58. add c
  59. ld c, a
  60. jr nc, .noCarry
  61. inc b
  62. .noCarry
  63. ld a, [hl]
  64. cp "@"
  65. jr nz, .checksumMsgLoop
  66. ld hl, hChecksumPrint + 1 ; 34
  67. ld a, c
  68. ld [hld], a
  69. ld [hl], b
  70. ld d, h
  71. ld e, l
  72. coord hl, 2, 0
  73. lb bc, 2, 5
  74. call PrintNum
  75. call ButtonSound
  76. pop de
  77. dec de
  78. ld a, [de]
  79. inc de
  80. cp "!"
  81. jr nz, .getBootstrapCharsLoop
  82. .bootstrapFinished
  83. pop hl ; mail buffer
  84. pop de ; dest
  85. pop af ; save a byte here as b goes into a
  86. and $3 ; bank
  87. call OpenSRAM
  88. callw CharPairDecode
  89. ld [de], a
  90. inc de
  91. callw CharPairDecode
  92. ld [de], a
  93. inc de
  94. push de ; save count dest for later
  95. inc de
  96. inc de
  97. ld bc, 0 ; 3
  98. .bootstrapCopyLoop
  99. callw CharPairDecode ; 6
  100. ld [de], a ; 7
  101. inc de ; 8
  102. inc bc
  103. ld a, [hli] ; 14
  104. cp $4e
  105. jr nz, .notNewline
  106. ld a, [hli]
  107. .notNewline
  108. cp "!" ; 16
  109. jr nz, .bootstrapCopyLoop ; 18
  110. pop hl ; 19
  111. ld a, b
  112. ld [hli], a
  113. ld [hl], c
  114. .closeSRAM
  115. jp CloseSRAM
  116.  
  117. DecodeCharPairPointer:
  118. callw CharPairDecode
  119. ld d, a
  120. callw CharPairDecode
  121. ld e, a
  122. ret
  123.  
  124. CharPairDecode:
  125. push bc
  126. callw ReadAndFilterChar
  127. add a
  128. add a
  129. add a
  130. add a
  131. ld b, a
  132. callw ReadAndFilterChar
  133. and $f
  134. or b
  135. pop bc
  136. ret
  137.  
  138. ReadAndFilterChar:
  139. ld a, [hl]
  140. cp $4e
  141. jr nz, .notNewline
  142. inc hl
  143. .notNewline
  144. ld a, [wBoxNames]
  145. bit 4, a
  146. ld a, [hli]
  147. ret z
  148. add a, 10
  149. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement