Language…
13 users online: Burning Loaf, Cloverzin, dotCoockie, Gasterus155, Hank_Sinatra, Ice Man, Jackhilo, JeepySol, Mauro Games 80, MegaSonic1999, TheSpreee333, underway, WONIU - Guests: 417 - Bots: 132
Users: 67,658 (1,991 active)
Latest user: FlowerHeart

Posts by Majora252

Majora252's Profile → Posts

MORE...ASM...PROBLEMS!!!! Now the sprite crashes on screen. Help?

Code
dcb "INIT"
RTL

dcb "MAIN"
PHB
PHK
PLB
JSR SpriteCode
PLB
RTL


SpriteCode:
JSR Graphics
JSL $01A7DC
BCC NoContact
LDA #$6C
STA $13E0
LDA #$FF
STA $1493
LDA #$0B      
STA $1DFB
DEC $13C6
RTS

NoContact:
RTL

;===================================
; GRAPHICS ROUTINE HERE
;===================================

Graphics:
JSR GET_DRAW_INFO
LDA $00
STA $0300,y

LDA $01
STA $0301,y

PHX
LDA $13
AND #$07
TAX
LDA TILEMAP,x
STA $0302,y
PLX

LDA #%00000000
ORA $64
STA $0303,y

INY
INY
INY
INY

LDY #$02 ; This means the tile drawn is 16x16.
LDA #$00 ; The number of tiles I wrote - 1.
JSL $01B7B3
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine.  It sets off screen flags, and sets up
; variables.  It will return with the following:
;
;       Y = index to sprite OAM ($300)
;       $00 = sprite x position relative to screen boarder
;       $01 = sprite y position relative to screen boarder  
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPR_T1:              db $0C,$1C
SPR_T2:             db $01,$02

GET_DRAW_INFO:       STZ $186C,x             ; reset sprite offscreen flag, vertical
                    STZ $15A0,x             ; reset sprite offscreen flag, horizontal
                    LDA $E4,x               ; \
                    CMP $1A                 ;  | set horizontal offscreen if necessary
                    LDA $14E0,x             ;  |
                    SBC $1B                 ;  |
                    BEQ ON_SCREEN_X         ;  |
                    INC $15A0,x             ; /

ON_SCREEN_X:         LDA $14E0,x             ; \
                    XBA                     ;  |
                    LDA $E4,x               ;  |
                    REP #$20                ;  |
                    SEC                     ;  |
                    SBC $1A                 ;  | mark sprite invalid if far enough off screen
                    CLC                     ;  |
                    ADC #$0040            ;  |
                    CMP #$0180            ;  |
                    SEP #$20                ;  |
                    ROL A                   ;  |
                    AND #$01                ;  |
                    STA $15C4,x             ; / 
                    BNE INVALID             ; 
                    
                    LDY #$00                ; \ set up loop:
                    LDA $1662,x             ;  | 
                    AND #$20                ;  | if not smushed (1662 & 0x20), go through loop twice
                    BEQ ON_SCREEN_LOOP      ;  | else, go through loop once
                    INY                     ; / 
ON_SCREEN_LOOP:      LDA $D8,x               ; \ 
                    CLC                     ;  | set vertical offscreen if necessary
                    ADC SPR_T1,y            ;  |
                    PHP                     ;  |
                    CMP $1C                 ;  | (vert screen boundry)
                    ROL $00                 ;  |
                    PLP                     ;  |
                    LDA $14D4,x             ;  | 
                    ADC #$00                ;  |
                    LSR $00                 ;  |
                    SBC $1D                 ;  |
                    BEQ ON_SCREEN_Y         ;  |
                    LDA $186C,x             ;  | (vert offscreen)
                    ORA SPR_T2,y            ;  |
                    STA $186C,x             ;  |
ON_SCREEN_Y:         DEY                     ;  |
                    BPL ON_SCREEN_LOOP      ; /

                    LDY $15EA,x             ; get offset to sprite OAM
                    LDA $E4,x               ; \ 
                    SEC                     ;  | 
                    SBC $1A                 ;  | $00 = sprite x position relative to screen boarder
                    STA $00                 ; / 
                    LDA $D8,x               ; \ 
                    SEC                     ;  | 
                    SBC $1C                 ;  | $01 = sprite y position relative to screen boarder
                    STA $01                 ; / 
                    RTS                     ; return

INVALID:             PLA                     ; \ return from *main gfx routine* subroutine...
                    PLA                     ;  |    ...(not just this subroutine)
                    RTS                     ; /


TILEMAP: dcb $00,$02,$04,$06.$08,$0A,$0E,$40

Your layout has been removed.
Originally posted by Kaijyuu
Code
NoContact: 
RTL

Change to RTS.



Thanks. I really need to stop putting the wrong return codes.

Offtopic: What does RTL stand for? RTS is ReTurn from Subroutine, but I don't know what rtl stands for. And I'm too lazy to look it up.
Your layout has been removed.
If you want a goal point in your inventory its pretty simple. Just load a value for it (don't know the value) and store it to the item box. And return of course. About the cloud spawning a key, you'd probably have to get a dissasembly and then edit the sprite it spawns.
Your layout has been removed.
Dang it. The sprite still crashes the game.

Code
dcb "INIT"
RTL

dcb "MAIN"
PHB
PHK
PLB
JSR SpriteCode
PLB
RTL


SpriteCode:
JSR Graphics
JSL $01A7DC
BCC NoContact
LDA #$6C
STA $13E0
LDA #$FF
STA $1493
LDA #$0B      
STA $1DFB
DEC $13C6
RTS

NoContact:
RTS

;===================================
; GRAPHICS ROUTINE HERE
;===================================

Graphics:
JSR GET_DRAW_INFO
LDA $00
STA $0300,y

LDA $01
STA $0301,y

PHX
LDA $13
AND #$07
TAX
LDA TILEMAP,x
STA $0302,y
PLX

LDA #%00000000
ORA $64
STA $0303,y

INY
INY
INY
INY

LDY #$02 ; This means the tile drawn is 16x16.
LDA #$00 ; The number of tiles I wrote - 1.
JSL $01B7B3
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine.  It sets off screen flags, and sets up
; variables.  It will return with the following:
;
;       Y = index to sprite OAM ($300)
;       $00 = sprite x position relative to screen boarder
;       $01 = sprite y position relative to screen boarder  
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPR_T1:              db $0C,$1C
SPR_T2:             db $01,$02

GET_DRAW_INFO:       STZ $186C,x             ; reset sprite offscreen flag, vertical
                    STZ $15A0,x             ; reset sprite offscreen flag, horizontal
                    LDA $E4,x               ; \
                    CMP $1A                 ;  | set horizontal offscreen if necessary
                    LDA $14E0,x             ;  |
                    SBC $1B                 ;  |
                    BEQ ON_SCREEN_X         ;  |
                    INC $15A0,x             ; /

ON_SCREEN_X:         LDA $14E0,x             ; \
                    XBA                     ;  |
                    LDA $E4,x               ;  |
                    REP #$20                ;  |
                    SEC                     ;  |
                    SBC $1A                 ;  | mark sprite invalid if far enough off screen
                    CLC                     ;  |
                    ADC #$0040            ;  |
                    CMP #$0180            ;  |
                    SEP #$20                ;  |
                    ROL A                   ;  |
                    AND #$01                ;  |
                    STA $15C4,x             ; / 
                    BNE INVALID             ; 
                    
                    LDY #$00                ; \ set up loop:
                    LDA $1662,x             ;  | 
                    AND #$20                ;  | if not smushed (1662 & 0x20), go through loop twice
                    BEQ ON_SCREEN_LOOP      ;  | else, go through loop once
                    INY                     ; / 
ON_SCREEN_LOOP:      LDA $D8,x               ; \ 
                    CLC                     ;  | set vertical offscreen if necessary
                    ADC SPR_T1,y            ;  |
                    PHP                     ;  |
                    CMP $1C                 ;  | (vert screen boundry)
                    ROL $00                 ;  |
                    PLP                     ;  |
                    LDA $14D4,x             ;  | 
                    ADC #$00                ;  |
                    LSR $00                 ;  |
                    SBC $1D                 ;  |
                    BEQ ON_SCREEN_Y         ;  |
                    LDA $186C,x             ;  | (vert offscreen)
                    ORA SPR_T2,y            ;  |
                    STA $186C,x             ;  |
ON_SCREEN_Y:         DEY                     ;  |
                    BPL ON_SCREEN_LOOP      ; /

                    LDY $15EA,x             ; get offset to sprite OAM
                    LDA $E4,x               ; \ 
                    SEC                     ;  | 
                    SBC $1A                 ;  | $00 = sprite x position relative to screen boarder
                    STA $00                 ; / 
                    LDA $D8,x               ; \ 
                    SEC                     ;  | 
                    SBC $1C                 ;  | $01 = sprite y position relative to screen boarder
                    STA $01                 ; / 
                    RTS                     ; return

INVALID:             PLA                     ; \ return from *main gfx routine* subroutine...
                    PLA                     ;  |    ...(not just this subroutine)
                    RTS                     ; /


TILEMAP: dcb $00,$02,$04,$06.$08,$0A,$0E,$40

Your layout has been removed.
(restricted)
The sprite worked, but it animated using the wrong GFX. (Yes, it was set to use pg 1, and the exgfx was in sp slot 1). I edited it a bit, and now it says there's an error assembling it.

Code
dcb "INIT"
RTL

dcb "MAIN"
PHB
PHK
PLB
JSR SpriteCode

PLB
RTL

SpriteCode:
JSR Graphics
JSL $018032
JSL $01A7DC
BCC NoContact
LDA #$6C
STA $13E0
LDA #$FF
STA $1493
LDA #$0B      
STA $1DFB
DEC $13C6
LDA #$ 08
STA $14C8,x
RTS

NoContact:
RTS

RETURN:
RTS
;===================================
; GRAPHICS ROUTINE HERE
;===================================

TILEMAP: dcb $00,$02,$04,$06.$08,$0A,$0E,$40

Graphics:
JSR GET_DRAW_INFO
LDA $00
STA $0300,y

LDA $01
STA $0301,y

PHX
LDA $13
LSR
LSR
LSR
AND #$07
TAX
LDA TILEMAP,x
STA $0302,y
PLX

LDA $15F6,x;#%00000000
ORA $64
STA $0303,y

INY
INY
INY
INY

LDY #$02 ; This means the tile drawn is 16x16.
LDA #$00 ; The number of tiles I wrote - 1.
JSL $01B7B3
RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine.  It sets off screen flags, and 

sets up
; variables.  It will return with the following:
;
;       Y = index to sprite OAM ($300)
;       $00 = sprite x position relative to screen boarder
;       $01 = sprite y position relative to screen boarder  
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPR_T1              dcb $0C,$1C
SPR_T2              dcb $01,$02

GET_DRAW_INFO       STZ $186C,x             ; reset sprite offscreen 

flag, vertical
	STZ $15A0,x             ; reset sprite offscreen flag, horizontal
	LDA $E4,x               ; \
	CMP $1A                 ;  | set horizontal offscreen if necessary
	LDA $14E0,x             ;  |
	SBC $1B                 ;  |
	BEQ ON_SCREEN_X         ;  |
	INC $15A0,x             ; /

ON_SCREEN_X         LDA $14E0,x             ; \
	XBA	 ;  |
	LDA $E4,x               ;  |
	REP #$20                ;  |
	SEC	 ;  |
	SBC $1A                 ;  | mark sprite invalid if far enough off 

screen
	CLC	 ;  |
	ADC.W #$0040            ;  |
	CMP.W #$0180            ;  |
; IF YOU READ THIS, YOU WIN A COOKIE! PM ME AND I'LL GIVE 

YOU A FREE ASM HACK WOOHOO!
	SEP #$20                ;  |
	ROL A                   ;  |
	AND #$01                ;  |
	STA $15C4,x             ; / 
	BNE INVALID             ; 
	
	LDY #$00                ; \ set up loop:
	LDA $1662,x             ;  | 
	AND #$20                ;  | if not smushed (1662 & 0x20), go 

through loop twice
	BEQ ON_SCREEN_LOOP      ;  | else, go through loop once
	INY	 ; / 
ON_SCREEN_LOOP      LDA $D8,x               ; \ 
	CLC	 ;  | set vertical offscreen if necessary
	ADC SPR_T1,y            ;  |
	PHP	 ;  |
	CMP $1C                 ;  | (vert screen boundry)
	ROL $00                 ;  |
	PLP	 ;  |
	LDA $14D4,x             ;  | 
	ADC #$00                ;  |
	LSR $00                 ;  |
	SBC $1D                 ;  |
	BEQ ON_SCREEN_Y         ;  |
	LDA $186C,x             ;  | (vert offscreen)
	ORA SPR_T2,y            ;  |
	STA $186C,x             ;  |
ON_SCREEN_Y         DEY	 ;  |
	BPL ON_SCREEN_LOOP      ; /

	LDY $15EA,x             ; get offset to sprite OAM
	LDA $E4,x               ; \ 
	SEC	 ;  | 
	SBC $1A                 ;  | $00 = sprite x position relative to 

screen boarder
	STA $00                 ; / 
	LDA $D8,x               ; \ 
	SEC	 ;  | 
	SBC $1C                 ;  | $01 = sprite y position relative to 

screen boarder
	STA $01                 ; / 
	RTS	 ; return

INVALID             PLA	 ; \ return from *main gfx routine* 

subroutine...
	PLA	 ;  |    ...(not just this subroutine)
	RTS	 ; /


This is what it says in temp.log

Code
65816 Tricks Assembler Version 1.11   (C)opyright 1994 1000 Miles [Tricks]
Internet: [email protected], IRC: minus

Memory available: 2147483647
Starting address defined as $92FE4C

Pass 1
Error in 26.1/23: Too many fields in statement

Pass 2
Error in 26.1/23: Too many fields in statement

Pass 3
Error in 26.1/23: Too many fields in statement
 
Source code assembled.

Although the source code was assembled, the program may not run
properly due to errors detected during the assembling process.

[$92FE4C-$92FF31]
Lines=150
Statements=132
Symbols=12
Errors=1

Your layout has been removed.
You'd have to edit the ASM file and uncheck "Takes 5 Fireballs To Kill" in the .cfg file. I hope you know asm, because fireball hp is not easy to configure.
Your layout has been removed.
Originally posted by ninja boy

Code
JMP Return : JMP Return :JMP Return : JMP Sprite : JMP Sprite : JMP Return : JMP Return

Sprite:
LDA #$02      ;\ make Mario have a cape
STA $19         ;/

Return:
RTL            ; return



You forgot to put an RTL at the end of the "Sprite" label. Also if you need to know some more values, here are some:

Originally posted by RAM map
For all flags:
00=False; 01=True

$7E:0015
Controller data 1
01=Right, 02=Left, 04=Down, 08=Up, 10=Start, 20=Select, 00=R and L, 40=Y and X, 80=B and A

$7E:0016
Controller data 1 (one frame)
Same values as above.

$7E:0017
Controller data 2
00=Right, 00=Left, 00=Down, 00=Up, 00=Start, 00=Select, 10=R, 20=L, 00=Y, 40=X, 00=B, 80=A

$7E:0018
Controller data 2 (one frame)
Same values as above.

$7E:0019
Powerup
00=Small Mario; 01=Super Mario; 02=Cape Mario; 03=Fire Mario

$7E:0076
Mario's Direction
00=Left; 01=Right

$7E:007B
Mario's X speed
This value is relative to $00D345, $00D347, $00D349, $00D34A and all other values that effect Mario's X speed. +/-15 is fully walking, +/-30 is fully running. 00-7F is right, 80-FF is left.

$7E:007D
Mario's Y speed
This value is relative to $00D7A5, $00D7A6 and all other values that effect Mario's Y speed. 15 is falling at mid-speed, 30 is falling at max-speed, EB is jumping at mid-speed and D0 is jumping at full speed.

$7E:0100
Game Mode
00 Load Nintendo Presents
01 Nintendo Presents
02 Fade to Title Screen
03 Load Title Screen
04 Prepare Title Screen
05 Title Screen: Fade in
06 Title Screen: Circle effect
07 Title Screen
08 Title Screen: File select
09 Title Screen: File delete
0A Title Screen: Player select
0B Fade to Overworld
0C Load Overworld
0D Overworld: Fade in
0E Overworld
0F Fade to Level
10 Fade to Level (black)
11 Load Level (Mario Start!)
12 Prepare Level
13 Level: Fade in
14 Level
15 Fade to Game Over
16 Fade to Game Over?
17 Game Over
18 Load Credits/Cutscene?
19 Load Credits/Cutscene?
1A Load Credits/Cutscene?
1B Ending: Credits / Cutscene
1C Fade to Yoshi's House
1D Fade to Yoshi's House (black)
1E Ending: Yoshi's House: Fade in
1F Ending: Yoshi's House
20 Fade to Enemies
21 Fade to Enemies (black)
22 Fade to Enemies?
23 Fade to Enemies (black)?
24 Ending: Enemies: Fade in
25 Ending: Enemies
26 Fade to The End / Go to 22
27 Fade to The End (black)
28 Ending: The End: Fade in
29 Ending: The End

$7E:0DC2
Reserved Item(current player)
02 = Fire Flower, 03 = Star, 04 = Cape

$7E:0DB3
Character
00=Mario; 01=Luigi

$7E:0DBC
Mario's Item Box
00=Nothing; 01=Mushroom; 02=Cape; 03=Fire Flower

$7E:0DBD
Luigi's Item Box
00=Nothing; 01=Mushroom; 02=Cape; 03=Fire Flower

$7E:0DC2
Reserved Item (current player)
#$00=None; #$01=Mushroom; #$02=Fire Flower; #$03=Star; #$04=Cape

$7E:0F30
Timer Frame Counter
After this reaches $00, then the game decrements the timer

$7E:0F31
Timer, hundreds' digit ($00 through $09)

$7E:0F32
Timer, tens' digit ($00 through $09)

$7E:0F33
Timer, ones' digit ($00 through $09)

$7E:0F34
Mario Score
1 here = 10 points, because the game draws an extra 0 after the score

$7E:0F37
Luigi Score
Same as above

$7E:14C8 - $7E:14D3
Sprite Status Table
00=Non-existant
01=Initial
02=Killed, falling off screen
03=Smushed
04=Spinjumped
05=Sinking in lava
06=Turn into coin at lvl end
07=Stay in Yoshi's mouth
08=Normal routines
09=Stationary
0A=Kicked
0B=Carried
0C=Powerup from being carried past goaltape.

$7E:17C0 - $7E:17C3 - Smoke images.
00=Nothing
01=Puff of smoke
02=Contact graphic
03=Smoke when Mario turns around abruptly
04=None
05=Glitter sprite

$7E:17F0 - $7E:17FB
Minor Extended Sprites type
00=None
01=Piece of brick block
02=Small star
03=Cracked shell (Yoshi egg)
04=Fireball from Podoboo
05=Small star?
06=Rip van Fish Z tile
07=Water splash
08=Rip van Fish Z tile (unused)
09=Rip van Fish Z tile (unused)
0A=Boo Stream tile
0B=Unused Yoshi smoke

$7E:185C
Mario no ground contact flag
00 = No effect; 01 = Mario falls through all solid objects

$7E:18FD
Whistling Chuck Flag </pre>

Unexpected end tag (</pre>) at 4406, expected </div>
Tag (div) was not closed.
Your layout has been removed.
Yanama, how close are you to being finished on the OW for world 1?

OffTopic: Hasn't been an update for a while, so I might as well whip up a level or something...
Your layout has been removed.
(restricted)
(restricted)
(restricted)

Code
JMP MarioBelow : JMP MarioAbove : JMP MarioSide : JMP Return : JMP Return : JMP MarioCape : JMP MarioFireBall

MarioBelow:
MarioAbove:
MarioSide:
LDA #$02 ;\ make Mario have a cape 
STA $19 ;/
RTL

MarioCape
MarioFireBall:
Return: 
RTL ; return


Fixed your code. You forgot to specify what happens when the block is hit with the cape. (In other words, you didn't put down the "MarioCape" and "MarioFireBall" labels.
Your layout has been removed.
Originally posted by ninja boy
I know I'm no were advanced enough in ASM to do this but using the Custom Powerups that are based on the original SMW ones is it possible to make them say give Mario a fireflower when touched but when mario is on yoshi makes yoshi red?


It should be possible.
Code
JMP Main : JMP Main : JMP Main : JMP Return : JMP Return JMP Return : JMP Return

LDA $187A       ;Load Yoshi Flag
BCS ChangeColor ;If riding Yoshi, branch to ColorChange
LDA #$03        ;If not, than load Fire Mario
STA $19         ;And store it to powerup status
RTL             ;And then return

ChangeColor:
LDA $0DBA       ;Load Mario Yoshi color into "A"
LDX $0DBB       ;Load Luigi Yoshi color into "X"
STA #$xx        ;Store color value (don't know them)
STX #$xx
RTL             ;Return

Return:
RTL             ;Return


Something similar to that. I havn't tested it, but it should work.
Your layout has been removed.
Well, there's a cheat that lets you wavedash in Brawl...
Your layout has been removed.
I'm trying to code a "Shine Sprite" from the game Super Mario Sunshine, and it has a very weird glitch. Whenever I touch it, it just kills Mario. I tried replacing the code after the contact check with "LDA #$02
STA $19" to see if it was the code that was wrong, but its not. It also animates between sprites I didn't even put in the table. If anyone wants to download it to see it for themselves, then here's the file. If your trying to help, then remember to check the .cfg file (with cfg editor) to see if anything's wrong with it. The file has the exgfx I'm using and the asm and cfg files. Thanks!

Sprite Download

And here's my code.
Code
dcb "INIT"
RTL

dcb "MAIN"
PHB
PHK
PLB
JSR SpriteCode

PLB
RTL
RTL

SpriteCode:
JSR Graphics
JSL $01A7DC
BCC NoContact
LDA #$6C
STA $13E0
LDA #$FF
STA $9D	
LDA #$FF
STA $1493
LDA #$0B
STA $1DFB
DEC $13C6
RTS

NoContact:
RTS

RETURN:
RTS
;===================================
; GRAPHICS ROUTINE HERE
;===================================

TILEMAP: dcb $00,$02,$04,$06.$08,$0A,$0E,$40

Graphics:
JSR GET_DRAW_INFO
LDA $00
STA $0300,y

LDA $01
STA $0301,y

PHX
LDA $13
LSR
LSR
LSR
AND #$07
TAX
LDA TILEMAP,x
STA $0302,y
PLX

LDA $15F6,x;#%00000000
ORA $64
STA $0303,y

INY
INY
INY
INY

LDY #$02 ; This means the tile drawn is 16x16.
LDA #$00 ; The number of tiles I wrote - 1.
JSL $01B7B3
RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine.  It sets off screen flags, and sets up
; variables.  It will return with the following:
;
;       Y = index to sprite OAM ($300)
;       $00 = sprite x position relative to screen boarder
;       $01 = sprite y position relative to screen boarder  
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPR_T1              dcb $0C,$1C
SPR_T2              dcb $01,$02

GET_DRAW_INFO       STZ $186C,x             ; reset sprite offscreen flag, vertical
	STZ $15A0,x             ; reset sprite offscreen flag, horizontal
	LDA $E4,x               ; \
	CMP $1A                 ;  | set horizontal offscreen if necessary
	LDA $14E0,x             ;  |
	SBC $1B                 ;  |
	BEQ ON_SCREEN_X         ;  |
	INC $15A0,x             ; /

ON_SCREEN_X         LDA $14E0,x             ; \
	XBA	 ;  |
	LDA $E4,x               ;  |
	REP #$20                ;  |
	SEC	 ;  |
	SBC $1A                 ;  | mark sprite invalid if far enough off screen
	CLC	 ;  |
	ADC.W #$0040            ;  |
	CMP.W #$0180            ;  |
; IF YOU READ THIS, YOU WIN A COOKIE! PM ME AND I'LL GIVE YOU A FREE ASM HACK WOOHOO!
	SEP #$20                ;  |
	ROL A                   ;  |
	AND #$01                ;  |
	STA $15C4,x             ; / 
	BNE INVALID             ; 
	
	LDY #$00                ; \ set up loop:
	LDA $1662,x             ;  | 
	AND #$20                ;  | if not smushed (1662 & 0x20), go through loop twice
	BEQ ON_SCREEN_LOOP      ;  | else, go through loop once
	INY	 ; / 
ON_SCREEN_LOOP      LDA $D8,x               ; \ 
	CLC	 ;  | set vertical offscreen if necessary
	ADC SPR_T1,y            ;  |
	PHP	 ;  |
	CMP $1C                 ;  | (vert screen boundry)
	ROL $00                 ;  |
	PLP	 ;  |
	LDA $14D4,x             ;  | 
	ADC #$00                ;  |
	LSR $00                 ;  |
	SBC $1D                 ;  |
	BEQ ON_SCREEN_Y         ;  |
	LDA $186C,x             ;  | (vert offscreen)
	ORA SPR_T2,y            ;  |
	STA $186C,x             ;  |
ON_SCREEN_Y         DEY	 ;  |
	BPL ON_SCREEN_LOOP      ; /

	LDY $15EA,x             ; get offset to sprite OAM
	LDA $E4,x               ; \ 
	SEC	 ;  | 
	SBC $1A                 ;  | $00 = sprite x position relative to screen boarder
	STA $00                 ; / 
	LDA $D8,x               ; \ 
	SEC	 ;  | 
	SBC $1C                 ;  | $01 = sprite y position relative to screen boarder
	STA $01                 ; / 
	RTS	 ; return

INVALID             PLA	 ; \ return from *main gfx routine* subroutine...
	PLA	 ;  |    ...(not just this subroutine)
	RTS	 ; /

Your layout has been removed.
OK, it works now. That was a lot simpler than I though. By the way, what code would I add to make it appear above your head one you touch it?

EDIT: It still has one wrong frame. The first one is the chargin chucks hand tile. And how would you make it so that mario stays in his victory pose untill the level ends?
Your layout has been removed.
You can make the code shorter by a lot. Anyways, there's already one made. Good job coding though. And welcome to the site!

Here is the simple code, which is already submitted (by Maxx):

Code
JMP Main : JMP return : JMP return : JMP return : JMP return : JMP return : JMP return

Main:
LDA $0DB3
EOR #$01
STA $0DB3
return:
RTL

Your layout has been removed.
(restricted)