Banner
The Overworld Design Contest ends in
6 DAYS, 6 HOURS, 49 MINUTES AND 30 SECONDS
Views: 905,564,209
Time:
15 users online: Anas, AppleBoy54321, Bench-kun, BOB66, BootaNoBijuu, buggy789, DJLocks, Maw, Nirv, Nowieso, PlagueofDoom,  Teyla, Ultima, WoxicTaste, yoshi9429 - Guests: 59 - Bots: 81 Users: 50,758 (2,067 active)
Latest: Florian1996
Tip: Use the Iggy/Larry Battle Tools to edit Iggy/Larry's platform.
Not logged in.
Posts by Mr. Red
Mr. Red's Profile - Posts by Mr. Red
Pages: « 1 »
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                     ; /
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.
Ah, it worked now. Thanks (I can't believe I didn't think of that myself.)
(restricted)
I tried porting a song, but it doesn't seem to work correctly. It skips over the intro part, and then the channels play out of sync. I haven't looped it yet, because that only made it sound worse, and I'm only using placeholder instruments until I get some samples.

File
Found a midi off some website.-File-
Ah, figured it out. The channels were to short because there weren't any rests at the end of them and one got out of sync because it had unnecessary rests. And I guess I forgot to use channel 0. Thanks!
(restricted)
Pages: « 1 »
Mr. Red's Profile - Posts by Mr. Red

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