Need guidance with nes to snes.

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

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

Re: Need guidance with nes to snes.

Post by infidelity » Fri Mar 19, 2021 8:03 am

I'm thinking once I get all the bank ids logged, I'm going to do the following.
  • Set up each snes bank with 4 levels
  • Store new loading address for each bank in ram, instead of doing a hard load from B800, there will be ones for 9800/B800/D800/F800

infidelity
Posts: 449
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity » Sat Mar 20, 2021 6:29 pm

Sooo, I keep running into a new issue being in SNES mode, that I keep loading data from the wrong bank. I'll be in the 02 bank for all my code, but when I want to load code in the current bank I'm in with the $E000 region, it keeps loading from the 00 bank, I swear I looked up and down through the internet, but I can figure out how to set the data bank register?

lidnariq
Posts: 10463
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Need guidance with nes to snes.

Post by lidnariq » Sat Mar 20, 2021 6:34 pm

PLB, MVN, MVP are the only instructions that set the DBR.

infidelity
Posts: 449
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity » Sat Mar 20, 2021 6:53 pm

So for me to just set the data bank to 02, I'd do,

540202

Correct?

lidnariq
Posts: 10463
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Need guidance with nes to snes.

Post by lidnariq » Sat Mar 20, 2021 7:03 pm

Probably not, because MVP and MVN will most likely do something else you don't want. (Namely, copy A bytes from [X] to [Y]). The only self-contained way to set the DBR is PEA #blahblah / PLB / PLB

93143
Posts: 1344
Joined: Fri Jul 04, 2014 9:31 pm

Re: Need guidance with nes to snes.

Post by 93143 » Sat Mar 20, 2021 7:10 pm

infidelity wrote:
Sat Mar 20, 2021 6:53 pm
So for me to just set the data bank to 02, I'd do,

540202

Correct?
No, that's going to transfer A bytes from $02:X to $02:Y.

What you want is phk; plb to change the data bank to the current value of the program bank.

If you want a different bank, load a register with the bank number you want, push that register on the stack, and plb.

You could also use the method lidnariq recommends, which is pea #$0202; plb; plb. A bit wasteful in some senses, but it doesn't destroy the contents of any registers, which may be more important.

infidelity
Posts: 449
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity » Sat Mar 20, 2021 7:24 pm

93143 wrote:
Sat Mar 20, 2021 7:10 pm
infidelity wrote:
Sat Mar 20, 2021 6:53 pm
So for me to just set the data bank to 02, I'd do,

540202

Correct?
No, that's going to transfer A bytes from $02:X to $02:Y.

What you want is phk; plb to change the data bank to the current value of the program bank.

If you want a different bank, load a register with the bank number you want, push that register on the stack, and plb.

You could also use the method lidnariq recommends, which is pea #$0202; plb; plb. A bit wasteful in some senses, but it doesn't destroy the contents of any registers, which may be more important.
Ok thank you, and everyone else as well, thank you.

infidelity
Posts: 449
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity » Sat Mar 20, 2021 8:04 pm

Ok new issue with the data banks. I was able to load A as 02, I used phk then plb, and I noticed that the data bank loaded as 02, which is the same as the current program bank.

But now I want to stay in program bank 02, and load data from bank 1E.

Code: Select all

lda #$00
sta $01
phy 
lda #$02
phk
plb
stz $7d
lda $f6
ldy #$00
cmp $ecb3'y
beq $ec7d
iny
jmp $ec74
lda $ecc8,y
sta $7f

;here I tried simply adding phk/plb, since at this point A is 1E, but 1E never got placed into the DB register. So I tried loading $7F with 1E, phk/plb, still no DB change.

lda $7f
phk
plb
lda $ecdd,y
sta $7e
ply
jmp $d2a7
I also tried phb/plb, and it didn't change either.

Thinking I need to push a value to the stack, manipulate it from the stack, and pull that manipulated value from the stack to the DB register.

lidnariq
Posts: 10463
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Need guidance with nes to snes.

Post by lidnariq » Sat Mar 20, 2021 8:26 pm

infidelity wrote:
Sat Mar 20, 2021 8:04 pm
load A as 02, I used phk then plb
Hold on, phk pushes the program bank register. (K = kode?) So A is unrelated there.

If A is 8-bit, then you can lda #2 / pha / plb, or one byte smaller and 4 cycles faster than pea #0202 / plb / plb

infidelity
Posts: 449
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity » Sat Mar 20, 2021 8:27 pm

That's why I added the side note after my code window, cause I caught on that phk, meaning kode. Thanks again for your help! Simply pushing the value as A and pulling it to the DB register is flawless. :)

tepples
Posts: 22335
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Need guidance with nes to snes.

Post by tepples » Sun Mar 21, 2021 5:55 am

If I can predict the next two values that I want in DBR, I push both of them with pea then pull one at a time.

93143
Posts: 1344
Joined: Fri Jul 04, 2014 9:31 pm

Re: Need guidance with nes to snes.

Post by 93143 » Sun Mar 21, 2021 11:35 am

I always thought the K in phk stood for "banK". As opposed to "Bank" in phb/plb.

Wouldn't be the dumbest thing I've seen in computer science...

Pokun
Posts: 1825
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Need guidance with nes to snes.

Post by Pokun » Mon Mar 22, 2021 11:34 am

Yeah me too. 65816 introduces a lot of seemingly strange and conflicting abbreviations. I guess many of them are for making good mnemonics though.

creaothceann
Posts: 308
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Need guidance with nes to snes.

Post by creaothceann » Mon Mar 22, 2021 3:47 pm

They should've just gone the x86 route and disregard the "3 characters per mnemonic" convention.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10

infidelity
Posts: 449
Joined: Fri Mar 01, 2013 4:46 am

Re: Need guidance with nes to snes.

Post by infidelity » Tue Mar 23, 2021 2:44 pm

Update - I have reached the point where the nes game begins to draw to the Nametable. It has a vram buffer, and draws the tiles vertically, (at least for the copyright screen, that's where I am now) I've only stepped through the code for the first set of tiles to see it in action with FCEUX's debugger.

I've been busy creating routines for indirect addressing, since this game always loads stage data through A000-BFFF, and I have stage data located in $8000/$A000/$C000/$E000.

So now I really need to come up with a gameplan for how to do the tilemap.

I've setup my port to use my BG1 tilemap to reside at $2000. I'm contemplating on the following...
  • whether to just keep the original vram buffer location where it is, or,
  • relocate it in a different part of the snes wram, and modify it to allow 2 byte word addressing, or,
  • keeping the vram buffer the way it is, then have a separate routine to load the palette value for the recently written tiles, but with this one, I'd probably have to copy the vram buffered tiles, paste them somewhere in snes wram, have every tile indexed by 1, so that I can place the palette value for each tile.
The other thing I'll need to tackle, is deciphering how I want to go about pulling the palette id's from the games original attribute data, and setting it up in wram for proper usage.

Lots of stuff I gotta consider.

Then, there's the issue of the game only being 30 pixels tall, and has vertical scrolling. This is 2nd to last on my list. I made sure to build my poet around using Mode 2.

That's all for now.

Post Reply