Advertisement
Guest User

Untitled

a guest
Sep 28th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. ;minimalist status bar
  2. ;top version
  3.  
  4. !sa1 = 0
  5. !base = $0000
  6. if read1($00FFD5) == $23
  7. sa1rom
  8. !sa1 = 1
  9. !base = $6000
  10. endif
  11.  
  12.  
  13. !bgcolor = $0000 ;status bar background color (default=black)
  14.  
  15. !NULL = $FC ;fill tile in GFX28/29 (used for replacing leading zeroes)
  16.  
  17.  
  18. ;SMB3 and SMW differ in which counters keep leading zeros and which replace them
  19. ;with spaces. the below defines are defaulted to SMB3 behavior
  20. ;0 = false (no leading zeroes, replace with spaces)
  21. ;1 = true (keep the leading zeroes)
  22.  
  23. !ZERO_coins = 0
  24. !ZERO_lives = 0
  25. !ZERO_score = 1
  26. !ZERO_time = 1
  27. !ZERO_bonus = 0
  28.  
  29.  
  30. ;dont edit
  31. !status_tile = $0B05|!base
  32. !status_prop = $0B45|!base
  33. !status_palette = $0B85|!base ;status bar palette is here (64 bytes max)
  34. !l1y_mirror = $0BC5|!base
  35.  
  36.  
  37. ;below = location of counters in status bar. only change the added value
  38. ;if you want the counter disabled, set it equal to 0
  39. ;note that disabling a counter only affects the display, not the functionality
  40.  
  41. !player = !status_tile+$1
  42. !time = !status_tile+$17
  43. !lives = !status_tile+$3
  44. !itembox = 0
  45. !coins = !status_tile+$1D
  46. !yicoins = !status_tile+$B
  47. !bonus = !status_tile+$8
  48. !score = 0
  49.  
  50.  
  51. org $008292
  52. LDY #$08 ;IRQ starts on this scanline
  53.  
  54. org $0082A4 ;NMI hijack
  55. autoclean JML PreStatusBar
  56. NOP #2
  57.  
  58. org $00838F ;IRQ hijack
  59. autoclean JML PostStatusBar
  60. NOP
  61.  
  62.  
  63. org $008CFF ;Status Bar upload routine
  64. StatusHijack:
  65. LDX #$1F
  66. -
  67. LDA .StatusTiles,x
  68. STA !status_tile,x
  69. LDA .StatusProps,x
  70. STA !status_prop,x
  71. LDA .StatusPal,x
  72. STA !status_palette,x
  73. DEX : BPL -
  74.  
  75. LDA #$28
  76. STA $0F30|!base
  77. RTS
  78.  
  79. .StatusTiles
  80. db $FC
  81. db $7C,$26,$27,$27 ;lives
  82. db $FC
  83. db $64,$26,$27,$27 ;bonus stars
  84. db $FC
  85. db $FC,$FC,$FC,$FC,$FC ;yoshi coins
  86. db $FC
  87. db $FC,$FC,$FC ;item box
  88. db $FC
  89. db $76,$77,$27,$27,$27 ;time
  90. db $FC
  91. db $2E,$26,$27,$27 ;coins
  92. db $FC
  93.  
  94. .StatusProps
  95. db $20
  96. db $29,$20,$20,$20 ;lives
  97. db $20
  98. db $28,$20,$20,$20 ;bonus stars
  99. db $20
  100. db $24,$24,$24,$24,$24 ;yoshi coins
  101. db $20
  102. db $20,$28,$20 ;item box
  103. db $20
  104. db $20,$20,$24,$24,$24 ;time
  105. db $20
  106. db $24,$20,$20,$20 ;coins
  107. db $20
  108.  
  109. .StatusPal
  110. dw !bgcolor,$0000,$7AAB,$7FFF
  111. dw $7393,$0000,$1E9B,$3B7F
  112. dw $7393,$0000,$0CFB,$2FEB
  113. dw $7393,$0000,$7FDD,$2D7F
  114. warnpc $008DF5
  115.  
  116.  
  117. org $0082E8
  118. BRA $01 : NOP
  119. org $0081F4
  120. BRA $01 : NOP
  121.  
  122.  
  123. org $028052
  124. db $78 ;item box X drop ($78)
  125.  
  126. org $028060
  127. db $09 ;item box Y drop ($0F)
  128.  
  129.  
  130. ;multiple status bar edits
  131.  
  132. org $008E6F ;Time hijack
  133. if !time
  134. LDA $0F31|!base
  135. STA !time
  136. LDA $0F32|!base
  137. STA !time+$1
  138. LDA $0F33|!base
  139. STA !time+$2
  140. if !ZERO_time
  141. BRA + ;[Time] dont convert leading zero to space (like SMB3)
  142. else
  143. BVS +
  144. endif
  145. LDY #$00
  146. -
  147. LDA $0F31|!base,y
  148. BNE +
  149. LDA #!NULL
  150. STA !time,y
  151. INY
  152. CPY #$02
  153. BNE -
  154. NOP
  155. +
  156. warnpc $008E95
  157. else
  158. BRA +
  159. org $008E95
  160. +
  161. endif
  162.  
  163. org $008F51 ;Lives hijack
  164. if !lives
  165. if !ZERO_lives
  166. BRA +
  167. else
  168. BNE +
  169. endif
  170. LDX #!NULL
  171. +
  172. STX !lives
  173. STA !lives+$1
  174. else
  175. BRA +
  176. org $008F5B
  177. +
  178. endif
  179.  
  180. org $008F7A ;Coins hijack
  181. if !coins
  182. if !ZERO_coins
  183. BRA +
  184. else
  185. BNE +
  186. endif
  187. LDX #!NULL
  188. +
  189. STA !coins+$1
  190. STX !coins
  191. else
  192. BRA +
  193. org $008F84
  194. +
  195. endif
  196.  
  197. org $008EE0 ;Score hijacks
  198. LDA !score,x
  199. org $008F0E
  200. LDA !score,x
  201. org $008EE7
  202. if !score
  203. STA !score,x
  204. else
  205. NOP #3
  206. endif
  207. org $008F15
  208. if !score
  209. STA !score,x
  210. else
  211. NOP #3
  212. endif
  213. org $008ED7
  214. LDX #$00
  215. org $008F05
  216. LDX #$00
  217. org $009014
  218. if !score
  219. STZ !score,x
  220. else
  221. NOP #3
  222. endif
  223. org $009034
  224. if !score
  225. INC !score,x
  226. else
  227. NOP #3
  228. endif
  229.  
  230. org $008EE5
  231. LDA #!NULL
  232.  
  233. org $008F13
  234. LDA #!NULL
  235.  
  236. org $008EDE
  237. if !ZERO_score
  238. BRA + ;[Mario score] dont convert leading zero to space (like SMB3)
  239. else
  240. LDX #$00
  241. endif
  242. org $008EEF
  243. +
  244.  
  245. org $008F0C
  246. if !ZERO_score
  247. BRA + ;[Luigi score] dont convert leading zero to space (like SMB3)
  248. else
  249. LDX #$00
  250. endif
  251. org $008F1D
  252. +
  253.  
  254.  
  255. org $008F86 ;near end of status bar routine, let's overwrite everything
  256.  
  257. if !itembox
  258. LDX $0DC2|!base ;Item Box Item
  259. LDA .statuspowerup,x
  260. STA !itembox
  261. endif
  262.  
  263. if !player
  264. LDX $0DB3|!base
  265. LDA .playertable,x ;Current Player
  266. STA !player
  267. endif
  268.  
  269. if !bonus
  270. LDX $0DB3|!base
  271. LDA $0F48|!base,x ;Bonus Stars
  272. PHK
  273. PEA.w .jslrtsreturn-1
  274. PEA.w $0084CF-1
  275. JML $009045
  276. .jslrtsreturn
  277. if !ZERO_bonus
  278. BRA +
  279. else
  280. TXY : BNE +
  281. LDX #!NULL
  282. endif
  283. +
  284. STX !bonus
  285. STA !bonus+$1
  286. endif
  287.  
  288. if !yicoins
  289. LDX #$00 ;Yoshi Coins
  290. LDA $1422|!base
  291. DEC A : STA $00
  292. -
  293. LDA #$2E ;full yoshi coin tile
  294. LDY $00 : BPL +
  295. LDA #!NULL ;blank yoshi coin tile
  296. +
  297. STA !yicoins,x
  298. DEC $00 : INX
  299. CPX #$05 : BCC - ;# of yoshi coins needed to stop display
  300. endif
  301.  
  302. RTS
  303.  
  304. .statuspowerup
  305. db $FC,$95,$97,$96,$28
  306. ;none, mushroom, flower, star, feather
  307.  
  308. .playertable
  309. db $7C,$0B ;Mario tile, Luigi tile
  310.  
  311. warnpc $008FF5
  312.  
  313.  
  314.  
  315. freecode
  316. -
  317. LDA #$53 : STA $2109
  318. STZ $2111
  319. STZ $2111
  320. STZ $2112
  321. STZ $2112
  322. if !sa1
  323. STZ $1D04 ;clear these just to be safe
  324. STZ $1D05
  325. STZ $1D06
  326. STZ $1D02
  327. endif
  328. JML $0082B0
  329.  
  330. PreStatusBar:
  331. LDA $0D9B|!base
  332. BNE -
  333. LDA $0100|!base
  334. CMP #$04 ;this makes it so the title screen has correct $212C-$212F values
  335. BEQ -
  336. CMP #$05
  337. BEQ -
  338. STZ $2115
  339. STZ $4314
  340. REP #$21
  341. LDA $1C
  342. ADC #$00F0
  343. AND #$00F8
  344. ASL #2
  345. ORA #$3000
  346. STA !l1y_mirror
  347. STA $2116
  348. LDA #$1800 : STA $4310
  349. LDA.w #!status_tile : STA $4312
  350. LDA #$0020 : STA $4315
  351. LDX #$02 : STX $420B
  352. LDY #$80 : STY $2115
  353. STA $4315
  354. LDA !l1y_mirror : STA $2116
  355. LDA #$1900 : STA $4310
  356. LDA.w #!status_prop : STA $4312
  357. STX $420B
  358. SEP #$20
  359.  
  360. LDA #$30 : STA $2109
  361. STZ $2111 ;static layer 3
  362. STZ $2111
  363. LDA $1C : AND #$F8 : CLC : ADC #$EF : STA $2112
  364. STZ $2112
  365. LDA #$04 : STA $212C ;layer 3 on main+sub
  366. STZ $212E
  367. STZ $2130
  368. STZ $2131
  369. STZ $2121
  370. REP #$20
  371. LDA #$2202 : STA $4310
  372. LDA.w #!status_palette : STA $4312
  373. LDA #$0020 : STA $4315
  374. STX $420B
  375. SEP #$20
  376.  
  377. LDA #$09 : STA $2105 ;gfx mode 1 + layer 3 priority
  378.  
  379. if !sa1
  380. ;code for setting up a custom sa-1 irq
  381. LDA.b #PostStatusBar
  382. STA $1D04
  383. LDA.b #PostStatusBar>>8
  384. STA $1D05
  385. LDA.b #PostStatusBar>>16
  386. STA $1D06
  387. INC $1D02
  388. LDX #$A1
  389. endif
  390. JML $0082B0
  391.  
  392. PostStatusBar:
  393. BIT $4212 : BVC $FB ;wait for h-blank
  394. LDA #$80 : STA $2100 ;f-blank the scanline
  395. LDA #$53 : STA $2109
  396. LDA $22 : STA $2111
  397. LDA $23 : STA $2111
  398. LDA $24 : STA $2112
  399. LDA $25 : STA $2112
  400. LDA $3E : STA $2105
  401. LDA $0D9D|!base : STA $212C ;main screen
  402. STA $212E
  403. LDA $0D9E|!base : STA $212D ;sub screen
  404. STA $212F
  405. LDA $40 : STA $2131 ;color math
  406. LDA $44 : STA $2130
  407. STZ $2121
  408. LDA $0703|!base : STA $2122
  409. LDA $0704|!base : STA $2122
  410. STZ $4314
  411. REP #$20
  412. LDA #$0907|!base : STA $4312
  413. LDA #$001E : STA $4315
  414. LDA #$2202 : STA $4310
  415. TAX : STX $420B
  416. SEP #$20
  417. BIT $4212 : BVC $FB ;wait for h-blank again
  418. LDA $0DAE|!base : STA $2100 ;restore brightness
  419.  
  420. if !sa1
  421. STZ $1D04 ;clear these just to be safe
  422. STZ $1D05
  423. STZ $1D06
  424. STZ $1D02
  425. RTL ;return to the irq handler
  426. else
  427. JML $0083B2
  428. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement