ToToTEK.COM Forum Index ToToTEK.COM
Help & Support Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SNES n00b help

 
Post new topic   Reply to topic    ToToTEK.COM Forum Index -> SNES Software/Hardware Development
View previous topic :: View next topic  
Author Message
Nagrazar



Joined: 15 Jun 2008
Posts: 1

PostPosted: Sun Jun 15, 2008 5:59 pm    Post subject: SNES n00b help Reply with quote

Hey. Sorry to bother everyone, but I've been trying to learn how to write homebrew code for the SNES and I'm kind of stuck at even getting a sprite loaded on screen. I've been mucking with this small program for the past week on and off and I'm just at the point where I have to admit I've hit a brick wall.

The code thus far:

Code:
.include "Header.inc"
.include "Snes_Init.asm"
.16bit
 
; Needed to satisfy interrupt definition in "Header.inc".
VBlank:
  RTI

.bank 0
.section "MainCode"

Start:
   Snes_Init
   sep #$20  ; registers sep = 8bit/ rep = 16bit
   rep #$10  ; accumulator ''
   lda #$0080 ; Force vblank
   sta $2100  ; ''
   sei
   clc
   xce       ; 16 bit mode
   
   jmp FUN_TILESET_LOAD
   jmp FUN_PALETTE_LOAD
   jmp FUN_SPRITE_LOAD
   
   sep #$10
   lda #$10
   sta $212c
   
   rep #$10
   lda #$000f  ; end vblank, brightness 15
   sta $2100     
   
Main_Loop:
   nop
   jmp Main_Loop
   
FUN_TILESET_LOAD:
   stz $2115 ; VRAM incr +1 on write
   rep #$20
   sep #$10
   lda #$0000  ; set vram address
   sta $2116  ; ''
   ldx #$0000  ; for x = 0, etc
   TS_LOOP:
      lda Tileset1, x  ; load first tile
      sta $2118        ; write to vram
      inx              ; x += 2
      inx              ;
      cpx $0400        ; x <= ...
   bne TS_LOOP
rts
   
FUN_PALETTE_LOAD:
   rep #$10
   stz $2116   ; set cgram address
   lda #$7FFF   ; color 1 = white
   sta $2122
   lda #$0000  ; color 2 = black
   sta $2122
   lda #$3de0  ; color 3 = blue/green (I like it)
   sta $2122
   lda #$001f  ; color 4 = red
   sta $2122
rts

FUN_SPRITE_LOAD:
   rep #$20
   stz $2102   ; set OAM address
   sep #$20
   lda #$10  ; xcord = 16
   sta $2104
   sta $2104   ; ycord = 16
   lda #$03  ; Tile #3 should be something...
   sta $2104
   lda #$02  ; attributes
   sta $2104
rts

Tileset1:
   .incbin "easytype.smc" FSIZE 8192
   
.ends


AFAIK this should work. I've loaded a tileset (specifically the font from FFIV US), loaded a palette, and set up a sprite. Yet nothing happens when I run it in an emulator, and vsnes shows nothing...?

At this point my main and only goal is to write some sort of simple terminal that will allow me to make the SNES talk back to me. I figure that if I get that done then I'll be at a much better place in trying to figure this box out. But I can't even get a freakin' tile to show on screen...? :/
Back to top
View user's profile Send private message
MottZilla



Joined: 08 Sep 2004
Posts: 765

PostPosted: Mon Aug 03, 2009 10:16 pm    Post subject: Reply with quote

Sorry that this is so late but your problem is you are using JMP to a routine and then using RTS at the end of it. You need to use JSR not JMP. JMP = Jump. JSR = Jump SubRoutine, which you can use RTS to return to where you jumped from. Hope that helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ToToTEK.COM Forum Index -> SNES Software/Hardware Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group