Need guidance with nes to snes. UPDATE: Port Complete of Mega Man IV + MSU-1

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

Ok, I was trying to do a tilemap test, to see my tile get drawn, but nothing is drawn and I see nothing in hex via the memory viewer of the vram.

Code: Select all

rep #$18 ;xy 16bit
lda #$80
sta $2115
ldx #$2000 ;vram destination address 
stx $2116
lda #$00 ;bank id with vram data
ldx #$c1c0 ;vram data location address
ldy #$0002 ;load 2 bytes
stx $4302
sta $4304
sty $4305
lda #$01
sta $4300
lda #$18
sta $4301
lda #$01
sta $420b
sep #$30
jmp $c160 ;jmp back to routine for step through testing
With that I get nothing drawn to $2000 in vram, my tilemap is set to $2000 as well, I made sure.

Also, im going to need to figure out how to make this routine draw vertically, but for now I'm simply just trying to get a tile drawn. Its strange since I can write to CGRAM and have written chr to the vram with no issue?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Need guidance with nes to snes.

Post by dougeff »

Keep in mind that VRAM address $2000 will be the $4000 byte, and may show up at $4000 in a hex editor.

Why are you only transferring 2 bytes? Just to test it?
Last edited by dougeff on Sat Mar 27, 2021 8:48 am, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

Damn it... that was it. I'll never get this right with vram addresses.

I just looked at 4000, there's my tile.

And yes im only 2 bytes as a test.

So I set the address as $0000, even though my tilemap is $2000-$2FFE?

I set the vram target address as 1000, and I got my tile drawn to $2000 in vram.

Is there some sort of table I can go by? Cause now I gotta convert my nes addresses...
Last edited by infidelity on Sat Mar 27, 2021 8:57 am, edited 1 time in total.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Need guidance with nes to snes.

Post by dougeff »

I don't understand the last question. The SNES has no preference where things are located in VRAM. You put things where you want, then you tell it where they are.
nesdoug.com -- blog/tutorial on programming for the NES
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

All I need to know is how to set the target address correctly for my tilemap. My tilemap starts at vram $2000. I set the target address to $2000 in my DMA routine, but it stored the tile at $4000.

I changed 2000, to 1000, and the dma routine stored the tile correctly at $2000 vram.

So now I need to figure out how to properly write to $2000-$2FFE vram.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Need guidance with nes to snes.

Post by dougeff »

If the NES is using PPU $2000 (for nametable #0), you should use VRAM address $2000, so you don't have to change anything. It only looks like $4000 in a hex editor, but the SNES considers this as $2000.

Unrelated note. Instead of LDA #$00, STA address, use STZ address, and skip the LDA part.
STZ stores 1 or 2 bytes of zero, depending on the size of the A register.
nesdoug.com -- blog/tutorial on programming for the NES
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

dougeff wrote: Sat Mar 27, 2021 9:16 amIt only looks like $4000 in a hex editor, but the SNES considers this as $2000.
My tilemap said 2000, but it never got the chr tile written there. It was written at $4000

My plan was to use snes vram $2000 as my tilemap, I based everything around that, but now i need to relocate my BG1 tilemap to vram $4000, in order to not have to modify my hi byte address from the nes game, and then my oam i got to reshift now since that is actually at vram $4000, and I'll have to change my routines that load chr to there.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Need guidance with nes to snes.

Post by dougeff »

I think we are misunderstanding each other. But it doesn't much matter. You can load the tile map anywhere you want. Just as long as you tell the SNES where the maps are. (registers 2107-210a)
nesdoug.com -- blog/tutorial on programming for the NES
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

Yeah I think we are.

I already have my maps pointing to where I want them. I keep forgetting writing the address for the DMA is not the same as simply writing 2000 to it, thinking that in itself will store my tile exactly at 2000 in the snes vram.

I'm going to keep everything the way it is, I know what needs to be done now. Thanks for the info.

update - having success drawing to the tilemap now, I'm not going to DMA since the original nes game checks for a specific value to stop reading the vram routine. The game stores the tiles in a buffer, and sometimes at the end of the amount of bytes needed for that string of gfx, the chr data will insert itself over the FF, which signifies to exit the vram routine.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Need guidance with nes to snes.

Post by 93143 »

You do remember that VRAM addresses are word addresses, right? If you write $2000 to $2116/7, it targets a byte offset of $4000.
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

93143 wrote: Sat Mar 27, 2021 12:55 pm You do remember that VRAM addresses are word addresses, right? If you write $2000 to $2116/7, it targets a byte offset of $4000.
I do, I forgot about that earlier and looked up my conversion table when I was successful with injecting the chr data to the vram.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Need guidance with nes to snes.

Post by creaothceann »

Just keep in mind that VRAM consists of 2 RAM chips (one for the even-numbered bytes and one for the odd-numbered bytes) (simplified) that share the same address bus lines but have separate data bus lines, so that the PPUs can instantly fetch 16 bits of data when they render the screen. The VRAM address that you set via $2116/$2117 appears on each chip's address bus pins.
infidelity wrote: Sat Mar 27, 2021 9:57 am My tilemap said word $2000, it was written to byte $4000
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

Just made huge progress, got the copyright screen to appear!

Only in the tilemap though.

I cant get it to appear on the bsnes emulator screen, but i can see the tilemap and it's palettes clear as day, idk if im missing an address to set?

edit - ok made sure $2100 was set with 0F, copyright screen appears on the emulator screen!
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity »

Ok, now I'm having an issue with getting sprite data uploaded to the OAM. The NES game sets up the OAMADDR within the beginnings of the NMI as,

Code: Select all

LDA #$00 ;lo byte to $200 ram
STA $2003 ;oamaddl
LDA #$02 ;hi byte to $200 ram
STA $4014 ;oamdma
Do I need to use oamwrite $2104 with DMA in order to upload my $200-$2FF ram region to oam?

update - got it :)

Code: Select all

PHX
PHY
REP #$18 ;x,y 16-bit
LDA #$80
STA $2115
LDX #$0200 ;oam dma buffer location
STX $2102 :oamaddl
LDA #$7E ;ram bank location
LDY #$0200 ;copy 200 bytes
STX $4302
STY $4305
STZ $4300
LDA #$04 ;low byte to oamwrite $2104
STA $4301
LDA #$01 ;initiate dma transfer 
STA $420B
SEP #$30 ;a,x,y 8-bit
PLY
PLX
RTL
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Need guidance with nes to snes.

Post by Pokun »

Yes normally you use DMA with $2104, but you don't strictly have to unlike on the NES (there is no OAM decay on SNES).

Nitpick: $2003 on the NES isn't oamaddl, it's the full destination OAM address. The NES' OAM only uses 8-bit addresses.
Post Reply