Guest User

SMA2YoshiBlockSA1

a guest
Nov 14th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. !base1 = $0000
  2.  
  3. !15F6 = $15F6
  4. !1602 = $1602
  5. !154C = $154C
  6. !151C = $151C
  7.  
  8.  
  9. if read1($00ffd5) == $23
  10. sa1rom
  11. !base1 = $6000
  12.  
  13. !15F6 = $33B8
  14. !1602 = $33CE
  15. !154C = $32DC
  16. !151C = $3284
  17.  
  18.  
  19. endif
  20.  
  21.  
  22.  
  23. ;=======================================================================
  24. ; SMA2-Styled Yoshi Blocks
  25. ; By Erik557
  26. ;
  27. ; Makes the Yoshi question blocks act similar to Super Mario Advance 2,
  28. ; giving you a different yoshi color based on powerup status and wheter
  29. ; the Yoshi has been obtained.
  30. ;=======================================================================
  31.  
  32. !freeRAM = $1F2C+!base1 ; Must be backed up in SRAM!
  33. ; Format: ----1rby
  34. ; - = unused
  35. ; 1 = green yoshi, always set
  36. ; rby = colored yoshi, set to 1 when acquired
  37.  
  38. ; Notes:
  39. ; A colored yoshi only sets the flag when it gets fully grown.
  40. ; Small and big always give a random colored yoshi, as long as you have already picked them and grown them once.
  41. ; Flower and feather give red and blue yoshis respectively, UNLESS you have not got that specific yoshi color.
  42. ; In that case, the color gets picked randomly between unlocked yoshis.
  43. ; Green is unlocked by default, else what? Transparent?
  44.  
  45. org $01A2E6 ; store yoshi of specific color in free RAM
  46. autoclean JSL saveObtainedYoshi
  47. NOP
  48.  
  49. org $009AB9 ; allow any color of yoshi to be displayed on the title screen
  50. autoclean JML saveTS
  51.  
  52. org $009E56 ; set green yoshi as set on file load
  53. autoclean JML saveLoad
  54.  
  55. org $01F86C ; fix spawned yoshi always being green
  56. LDA !15F6,x
  57. autoclean JML growCorrectly
  58.  
  59. org $028A18 ; main hijack
  60. autoclean JML yoshiSpawn
  61.  
  62. freecode
  63.  
  64. saveObtainedYoshi:
  65. AND #$0E ; lowest bit is already clear wHATEVER
  66. LSR ;\
  67. TAX ; | shift and store
  68. LDA.l $009E7C,x ; | bitmask table minus two
  69. TSB !freeRAM ;/
  70. LDX $15E9+!base1 ; restore index
  71. LDA #$0C ;\ restore
  72. STA !1602,x ;/
  73. RTL
  74.  
  75. saveTS:
  76. LDA #$12 ;\ restore
  77. STA $44 ;/
  78. LDA #$0F ;\ set all yoshies as obtained
  79. STA !freeRAM ;/
  80. JML $009ABD ; return
  81.  
  82. saveLoad:
  83. STZ $0F36+!base1 ;\ restore
  84. STZ $0F39+!base1 ;/
  85. LDA #$08 ;\ set green yoshi as obtained
  86. TSB !freeRAM ;/
  87. JML $009E5C ; return
  88.  
  89. yoshiSpawn:
  90. STA $AA,x ;\
  91. LDA #$2C ; | restore
  92. STA !154C,x ;/
  93. CMP $9E,x ;\ ok what a coincidence the value was set to the sprite value of the egg.
  94. BNE .return ;/ return if not egg
  95. LDA !151C,x ;\
  96. CMP #$78 ; | return if egg will spawn an 1-up
  97. BEQ .return ;/
  98. PHX ; preserve the index (not stored to 15E9 here)
  99. LDX $19 ;\
  100. CPX #$02 ; | branch if fiery or caped
  101. BCS .fireFeather ;/
  102. .getRandom
  103. JSL $01ACF9 ;\ get random number between 0 and 3
  104. AND #$03 ;/
  105. TAX ; use it to index
  106. .fireFeather
  107. LDA.l eggColorMask,x ; obtain values for specific colored yoshi
  108. AND !freeRAM ;\ if that color has not been obtained, get a random one
  109. BEQ .getRandom ;/
  110. LDA.l props,x ; get color properties
  111. PLX ; restore index
  112. STA !15F6,x ; store
  113. .return
  114. JML $028A1F ; return
  115.  
  116. growCorrectly:
  117. PHA ; preserve palette
  118. JSL $07F7D2 ; reset sprite tables
  119. PLA ;\ restore palette
  120. STA !15F6,x ;/
  121. JML $01A2B5 ; return
  122.  
  123. eggColorMask:
  124. db $01,$08,$02,$04
  125. props:
  126. db $05,$0B,$07,$09
Advertisement
Add Comment
Please, Sign In to add comment