Banner
The Questionable Level Design Contest ends in…
14 DAYS, 20 HOURS, 41 MINUTES AND 50 SECONDS
Views: 913,962,679
Time:
20 users online:  Anorakun, Bench-kun, crocodileman94, Dark Prince, Dr Ocelot, h.carrell, Hwailaluta, idealiter, MarioSonic4life, miguel, Mohamad20ZX,  Noivern, odym82, OrangeBronzeDaisy, Paithus, RZRider, SKJyannick, SuperMegaNick, TickTockClock, UwU - Guests: 140 - Bots: 81 Users: 51,192 (2,256 active)
Latest: Pink
Tip: Keep track of ALL patches and hex edits in case you need to transfer your data to a new ROM. It's definitely worth the trouble.
Not logged in.
ASM Tutorial Problem.
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - ASM Tutorial Problem.
Pages: « 1 » Link
I was looking up how to create custom sprites, and found this tutorial:
http://www.smwcentral.net/?p=thread&id=24824&page=0
I was going through it, and once I got to the "16x16 static sprite", I started getting confused, so I started following step-by-step, and once I finished, when I inserted it, the level turned black and crashed.
I messed around with it for a bit, and when this time it ruined the BG and froze once I got to the same screen (didn't get to the sprite though). I think someone said there was a problem with the "get draw info" code, but I don't know. What should I fix?

Code
dcb "INIT"
RTL

dcb "MAIN"

JSR Graphics
RTL


Graphics:	    
	JSR GET_DRAW_INFO


	LDA $00
	STA $0300,y

	LDA $01
	STA $0301,y


	LDA #$24
	STA $0302,y

	LDA #$06
	ORA $64
	STA $0303,y


	INY
	INY
	INY
	INY

	LDY #$02
	LDA #$00


	JSL $01B7B3
	RTS

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                     ; /
I'm not sure if this is the problem or not, but either way, you should probably add a PHB, a PHK, and a PLB at the beginning of the MAIN code, and then another PLB at the end of it. Essentially, change this:

Code
dcb "MAIN"

JSR Graphics
RTL


to this:

Code
dcb "MAIN"
PHB
PHK
PLB
JSR Graphics
PLB
RTL


These adjustments will allow your code to access tables in the code. I don't know if that's your problem, but it's definitely worth a shot.

--------------------
Now with extra girl and extra hacker
Nope, still didn't work, but thanks for the tip though.
Anyway, unless someone actually wants to go through the code, I'll go ahead and re-do it someday later. I was doing this at around 4 a.m. and probably screwed something up.
The problem most likely has to be get_draw_info.
Try re-ripping it from the Sprite_Tool library.

--------------------
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Ah, it worked now. Thanks (I can't believe I didn't think of that myself.)
Pages: « 1 » Link
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - ASM Tutorial Problem.

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2021 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy
  • sm64romhacks