Register - Login
Views: 99407861
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
04-24-22 08:35:52 PM
Jul - General Game/ROM Hacking - Exploding Sprite Routine data in SMW (Warning: long post) New poll - New thread - New reply
Next newer thread | Next older thread
Drake
Member
Level: 32


Posts: 3/199
EXP: 202474
For next: 3968

Since: 01-26-08


Since last post: 10.2 years
Last activity: 10.2 years

Posted on 02-29-08 04:16:02 AM Link | Quote
I was curious about the exploding routine (JSL $028086) that the bom-ombs and some custom sprites use, so I decided to disassemble it. There's still some parts of the code that I'm not familiar with and might be labeled wrong.

Here it is:



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Exploding Sprite Routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


HORZ_DISP dcb $00,$08,$06,$FA,$F8,$06,$08,$00,$F8,$FA
VERT_DISP dcb $F8,$FE,$06,$06,$FE,$FA,$02,$08,$02,$FA


EXPLODING_ROUTINE STZ $1656,x ; clear settings
LDA #$11 ; \ set sprite clipping field
STA $1662,x ; /

JSR GET_DRAW_INFO ; after: Y = index to sprite tile map ($300)
; $00 = sprite x position relative to screen boarder
; $01 = sprite y position relative to screen boarder

LDA $9D ; \ if it's locked...
BNE SET_TIMER ; /

INC $1570,x ; increment number of frames the sprite has been on screen
SET_TIMER LDA $1540,x ; \ if the timer is set...
BNE NOT_KILLED ; /
STZ $14C8,x ; disappear the sprite
RTS

NOT_KILLED LDA $1540,x ; \ if the timer is set...
LSR A ; |
AND #$03 ; |
CMP #$03 ; |
BNE SKIP_INTERACTION ; / ...skip interaction

JSR SPRITE_INTERACT ; sprite interaction routine
LDA $1540,x ; \ if the timer is set...
SEC ; |
SBC #$10 ; |
CMP #$20 ; |
BCS SKIP_INTERACTION ; / ...skip Mario/sprite contact

JSL $01A7DC ; check for Mario/sprite contact

SKIP_INTERACTION LDY #$04
STY $0F

LOOP_START LDA $1540,x
LSR A
PHA
AND #$03
STA $02

LDA $E4,x ; \ set x position
SEC ; |
SBC $1A ; |
CLC ; |
ADC #$04 ; |
STA $00 ; /

LDA $D8,x ; \ set y position
SEC ; |
SBC $1C ; |
CLC ; |
ADC #$04 ; |
STA $01 ; /

LDY $0F
PLA
AND #$04
BEQ SET_HORZ_DISP
TYA
CLC
ADC #$05
TAY

SET_HORZ_DISP LDA $00 ; \ x position for the star tiles
CLC ; |
ADC HORZ_DISP,y ; |
STA $00 ; /

LDA $01 ; \ y position for the star tiles
CLC ; |
ADC VERT_DISP,y ; |
STA $01 ; /

DEC $02
BPL SET_HORZ_DISP
LDA $0F
ASL A
ASL A
ADC $15EA,x
TAY

LDA $00 ; \ tile x position
STA $0300,y ; /

LDA $01 ; \ tile y position
STA $0301,y ; /

LDA #$BC ; \ store star tile
STA $0302,y ; /

LDA $13 ; \ calculate which frame to show palette
LSR A ; |
LSR A ; |
AND #$03 ; | number of frames/flashing palettes
SEC ; |
ROL A ; |
ORA $64 ; |
STA $0303,y ; / store palettes

TYA ; \ get index to sprite property map ($460)...
LSR A ; |
LSR A ; |
TAY ; |
LDA #$00 ; | else show a 8x8 tile
STA $0460,y ; /

DEC $0F
BPL LOOP_START

LDY #$00 ; \ 460 &= 0 8x8 tiles maintained
LDA #$04 ; | A = number of tiles drawn - 1
JSL $01B7B3 ; / don't draw if offscreen
RTS ; return

SPRITE_INTERACT LDY #$09
INTERACT_LOOP CPY $15E9
BEQ NEXT_SPRITE
PHY
LDA $14C8,y ; \ if the sprite status is...
CMP #$08 ; | ...alive
BCC DONT_PROCESS_SPRITE ; /
JSR PROCESS_SPRITE
DONT_PROCESS_SPRITE PLY
NEXT_SPRITE DEY
BPL INTERACT_LOOP
RTS

PROCESS_SPRITE PHX
TYX
JSL $03B6E5 ; get sprite clipping B routine
PLX
JSL $03B69F ; get sprite clipping A routine
JSL $03B72B ; check for contact routine
BCC RETURN ; return if no contact

LDA $167A,y ; \ if invincible to star/cape/fire/bouncing bricks...
AND #$02 ; |
BNE RETURN3 ; / ...return
LDA #$02 ; \ status = 2 (being killed by star)
STA $14C8,y ; /
LDA #$C0 ; \ set y speed
STA $00AA,y ; /
LDA #$00 ; \ no x speed
STA $00B6,y ; /
RETURN RTS

Next newer thread | Next older thread
Jul - General Game/ROM Hacking - Exploding Sprite Routine data in SMW (Warning: long post) New poll - New thread - New reply


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

26 database queries.
Query execution time:  0.088968 seconds
Script execution time:  0.003765 seconds
Total render time:  0.092733 seconds


TidyHTML vomit below
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 119 column 11 - Warning: <form> isn't allowed in <table> elements
line 118 column 10 - Info: <table> previously mentioned
line 120 column 11 - Warning: missing <tr>
line 120 column 119 - Warning: missing </font> before </td>
line 124 column 16 - Warning: plain text isn't allowed in <tr> elements
line 120 column 11 - Info: <tr> previously mentioned
line 125 column 68 - Warning: missing </nobr> before </td>
line 141 column 68 - Warning: missing </nobr> before <tr>
line 147 column 35 - Warning: missing <tr>
line 147 column 50 - Warning: missing </font> before </td>
line 148 column 37 - Warning: unescaped & or unknown entity "&id"
line 147 column 230 - Warning: missing </font> before </table>
line 149 column 35 - Warning: missing <tr>
line 149 column 50 - Warning: missing </font> before </td>
line 149 column 91 - Warning: missing </font> before </table>
line 156 column 9 - Warning: <div> isn't allowed in <table> elements
line 152 column 17 - Info: <table> previously mentioned
line 158 column 9 - Warning: missing <tr>
line 176 column 13 - Warning: missing <tr>
line 177 column 99 - Warning: unescaped & or unknown entity "&postid"
line 183 column 330 - Warning: missing </pre> before <hr>
line 339 column 7140 - Warning: inserting implicit <pre>
line 342 column 17 - Warning: missing <tr>
line 342 column 17 - Warning: discarding unexpected <table>
line 345 column 35 - Warning: missing <tr>
line 345 column 50 - Warning: missing </font> before </td>
line 345 column 91 - Warning: missing </font> before </table>
line 347 column 35 - Warning: missing <tr>
line 347 column 50 - Warning: missing </font> before </td>
line 348 column 37 - Warning: unescaped & or unknown entity "&id"
line 347 column 230 - Warning: missing </font> before </table>
line 349 column 17 - Warning: discarding unexpected </textarea>
line 349 column 28 - Warning: discarding unexpected </form>
line 349 column 35 - Warning: discarding unexpected </embed>
line 349 column 43 - Warning: discarding unexpected </noembed>
line 349 column 53 - Warning: discarding unexpected </noscript>
line 349 column 64 - Warning: discarding unexpected </noembed>
line 349 column 74 - Warning: discarding unexpected </embed>
line 349 column 82 - Warning: discarding unexpected </table>
line 349 column 90 - Warning: discarding unexpected </table>
line 351 column 9 - Warning: missing </font> before <table>
line 363 column 25 - Warning: discarding unexpected </font>
line 372 column 37 - Warning: discarding unexpected </font>
line 350 column 1 - Warning: missing </center>
line 120 column 63 - Warning: <img> lacks "alt" attribute
line 125 column 19 - Warning: <td> attribute "width" has invalid value "120px"
line 125 column 93 - Warning: <img> lacks "alt" attribute
line 141 column 19 - Warning: <td> attribute "width" has invalid value "120px"
line 141 column 98 - Warning: <img> lacks "alt" attribute
line 148 column 44 - Warning: <img> proprietary attribute value "absmiddle"
line 148 column 142 - Warning: <img> proprietary attribute value "absmiddle"
line 148 column 245 - Warning: <img> proprietary attribute value "absmiddle"
line 161 column 22 - Warning: <img> lacks "alt" attribute
line 161 column 63 - Warning: <img> lacks "alt" attribute
line 161 column 112 - Warning: <img> lacks "alt" attribute
line 161 column 162 - Warning: <img> lacks "alt" attribute
line 172 column 15 - Warning: <img> lacks "alt" attribute
line 348 column 44 - Warning: <img> proprietary attribute value "absmiddle"
line 348 column 142 - Warning: <img> proprietary attribute value "absmiddle"
line 348 column 245 - Warning: <img> proprietary attribute value "absmiddle"
line 357 column 25 - Warning: <img> lacks "alt" attribute
line 362 column 267 - Warning: <img> lacks "alt" attribute
line 149 column 50 - Warning: trimming empty <font>
line 339 column 7140 - Warning: trimming empty <pre>
line 342 column 17 - Warning: trimming empty <tr>
line 345 column 50 - Warning: trimming empty <font>
line 125 column 68 - Warning: <nobr> is not approved by W3C
line 141 column 68 - Warning: <nobr> is not approved by W3C
line 177 column 27 - Warning: <nobr> is not approved by W3C
Info: Document content looks like HTML5
Info: No system identifier in emitted doctype
Tidy found 67 warnings and 0 errors!


The alt attribute should be used to give a short description
of an image; longer descriptions should be given with the
longdesc attribute which takes a URL linked to the description.
These measures are needed for people using non-graphical browsers.

For further advice on how to make your pages accessible
see http://www.w3.org/WAI/GL.
You are recommended to use CSS to specify the font and
properties such as its size and color. This will reduce
the size of HTML files and make them easier to maintain
compared with using <FONT> elements.

You are recommended to use CSS to control line wrapping.
Use "white-space: nowrap" to inhibit wrapping in place
of inserting <NOBR>...</NOBR> into the markup.

About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
Latest HTML specification: http://dev.w3.org/html5/spec-author-view/
Validate your HTML documents: http://validator.w3.org/nu/
Lobby your company to join the W3C: http://www.w3.org/Consortium

Do you speak a language other than English, or a different variant of
English? Consider helping us to localize HTML Tidy. For details please see
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md