It is currently Mon Jun 18, 2018 4:59 am

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Loading data to VRAM
PostPosted: Wed Jun 13, 2018 2:46 am 
Offline

Joined: Wed Jun 13, 2018 2:39 am
Posts: 2
Hello, I'm new to this forum and to SNES programming in general, but not new to 6502/65816.

So I was writing a pong game and in the meantime I accidentally deleted some important files, and thus I was forced to rewrite the entire source code. However, I seem to have hit a very big wall.

I followed the superfamicom.org wiki for loading data to VRAM. It was working just fine in the previous code, but now it simply won't load data to VRAM at all, despite all arguments being correct.

I have a file called initdma.asm which contains this code:
Code:
.macro LoadSprites
   lda #$80
   sta $2115  ; Increment VRAM word after writing to $2119.
   ldx #\2
   stx $2116  ; Set initial VRAM word address.
   lda #:\1
   ldx #\1
   ldy #\3
   jsr LoadSpritesRoutine
.endm

LoadSpritesRoutine:
   php

   stx $4302
   sta $4304   ; Set DMA source address and bank

   sty $4305   ; Set DMA transfer size in bytes
   
   lda #1
   sta $4300   ; Set transfer mode to 1-word

   lda #$18
   sta $4301   ; Set DMA destination to $2118

   lda #1
   sta $420B   ; Begin DMA transfer

   plp
   rts


And in the main file, I call it using:
Code:
LoadSprites sprite, $0000, $0800    ; sprite is located at $01:8000. Set initial VRAM address to $0000, transfer size is 2kB.


Is there something really obvious that I'm missing? Every single debugger says the VRAM is completely empty after calling this macro.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Loading data to VRAM
PostPosted: Wed Jun 13, 2018 5:36 am 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 154
The code seems correct to me.

A few things I'd check:
1. Are you sure that A is 8-bit and X/Y are 16-bit here?
2. Are you sure that the DMA is happening during vblank or forced blank? VRAM is inaccessible during rendering.
3. Have you tried something simpler in place of the DMA, like setting the background color, just to make sure the program as a whole is working?


Top
 Profile  
 
 Post subject: Re: Loading data to VRAM
PostPosted: Wed Jun 13, 2018 6:14 am 
Offline

Joined: Wed Jun 13, 2018 2:39 am
Posts: 2
Indeed changing the background color works. I have written a color palette to CGRAM prior to this. I did not know the VBLANK part though! Worth a try.

Edit: Turning the screen off prior to DMA did the trick. Thanks a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group