Need guidance with nes to snes. UPDATE: Port Complete of Mega Man IV + MSU-1
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
Re: Need guidance with nes to snes.
What do you mean by "splits the screen from left to right"? Do you mean that there's a region on the left and a region on the right, separated by a vertical line?
Or do you mean there's a region on top and one on the bottom, separated by a horizontal line?
If the former, my guess is that it has nothing to do with the IRQ, and is just done with sprites or something. If the latter, you want a V-IRQ or HV-IRQ to accomplish that, or perhaps HDMA.
The port I'm working on (from a more powerful platform, not the NES) has a left-right split of the former type. BG mode, scroll, mosaic and colour math settings all get changed within an H-IRQ, and then changed back by HDMA. The thing is, the H-IRQ fires on every scanline, so this process eats something like 2/3 of my total compute time on the S-CPU. If I weren't using a Super FX it would be virtually impossible to justify this.
Or do you mean there's a region on top and one on the bottom, separated by a horizontal line?
If the former, my guess is that it has nothing to do with the IRQ, and is just done with sprites or something. If the latter, you want a V-IRQ or HV-IRQ to accomplish that, or perhaps HDMA.
The port I'm working on (from a more powerful platform, not the NES) has a left-right split of the former type. BG mode, scroll, mosaic and colour math settings all get changed within an H-IRQ, and then changed back by HDMA. The thing is, the H-IRQ fires on every scanline, so this process eats something like 2/3 of my total compute time on the S-CPU. If I weren't using a Super FX it would be virtually impossible to justify this.
-
- Posts: 490
- Joined: Fri Mar 01, 2013 4:46 am
Re: Need guidance with nes to snes.
I'm thinking that's what's happening, every scanline it feels like it gets initiated. I'm very certain I have the been irq snes addresses setup incorrectly, and now that I'm re-editing certain things its throwing off other things, like I noticed my dialog repeated twice at one point.dougeff wrote: ↑Mon Apr 12, 2021 5:39 pm SEI prevents IRQs (for when you don't need IRQs at all)
If you have $4200 incorrect, you could get an IRQ every scanline that the PPU is drawing the screen. That would result in IRQs firing rapidly.
Edit, I reread your post...
THAT is incorrect. You want either V timer, or H and V timer. Easiest would be just the V timer, which should work the same as MMC3 scanline IRQ, plus or minus a few pixels.But i only need the Horizontal [IRQ timer]
.
Edit 2
Another thought. If all you are doing is some split screen with H scroll changes, consider using HDMA instead. That would allow you to avoid IRQs altogether.
At some point today I'll upload the original mmc3 irq routine, and then I'll add what I used as equivalents.
Use HDMA? I'm unfamiliar with using that, I read it uses the same addresses as DMA, but has a different initiate address, is that correct? The original nes game will have some irq's that split part of the current background, other irq have the main screen as plain background, while the lower Nametable gets used to display a large boss/enemy/on that plain background.
Yeah I word things awful, my apologies, it splits the screen starting at the far edge of the left screen and goes to the far edge of the right screen, like in Super Mario Bros 3, where you can freely move the desired amount at the top half, and where the bottom stays stationary.93143 wrote: ↑Mon Apr 12, 2021 7:39 pm What do you mean by "splits the screen from left to right"? Do you mean that there's a region on the left and a region on the right, separated by a vertical line?
Or do you mean there's a region on top and one on the bottom, separated by a horizontal line?
If the former, my guess is that it has nothing to do with the IRQ, and is just done with sprites or something. If the latter, you want a V-IRQ or HV-IRQ to accomplish that, or perhaps HDMA.
Here is the original games mmc3 irq setups
Prepping irq at beginning of NMI
Code: Select all
LDA $5C ;how many scanlines before irq start
STA $C000 ;irq latch
STA $C001 ;irq reload
LDX $9B ;if 01, enable scanline irq
STA $E000,X :irq enable since x is 01, if 00 it would be stored to $E000 exactly
Code: Select all
PHP
PHA
TXA
PHA
TYA
PHA
STA $E000 ;irq disable
STA $E001 ;irq enable
JMP ($009C) ;indirect jump to location of irq
Code: Select all
LDA $2002 ;PPU_STATUS
LDA $FF ;contains values for PPU_CTRL at $2000
STA $2000 ;PPU_CTRL, this sets the Nametable at $2000_ppu
LDA #$00
STA $2005 ;force x position as 00
STA $2005 ;force y position as 00
STA $E000 ;irq disable
PLA
TAY
PLA
TAX
PLA
PLP
RTI
At the start of the rom, I have the following at $4200 set to TRUE in bsnes, NMI Enable, H-Count IRQ Enable V-Count IRQ Enable, Auto Joypad Poll
Prepping irq at beginning of NMI
Code: Select all
LDA $5C ;how many scanlines before irq start
STA $4209 ;VTIMEL
STA $420A ;VTIMEH
LDA $9B ;if 01, enable scanline irq
BNE $D892
LDA #$30 ;bits 2 & 1/H & V irq
TRB $72 ;reset bits for $4200
LDA $72
STA $4200
;from BNE $D892
LDA #$30 ;bits 2 & 1/H & V irq
TSB $72 ;set bits for $4200
LDA $72
STA $4200
Code: Select all
PHP
PHA
TXA
PHA
TYA
PHA
LDA $4211
LDA $4211
JMP ($009C) ;indirect jump to location of irq
Code: Select all
LDA $4211
PLA
TAY
PLA
TAX
PLA
PLP
RTI
I'm feeling worried that it could be from all my conversion tables for setting/resetting $4200.
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Need guidance with nes to snes.
Code: Select all
PHP
PHA
TXA
PHA
TYA
PHA
LDA $4211
LDA $4211
JMP ($009C) ;indirect jump to location of irq
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Need guidance with nes to snes.
also are you in 65816 mode or 6502 mode, if 6502 mode an IRQ will fire on a BRK which tend to just keep happening.
-
- Posts: 490
- Joined: Fri Mar 01, 2013 4:46 am
Re: Need guidance with nes to snes.
A,X,Y are 8-bitOziphantom wrote: ↑Tue Apr 13, 2021 6:59 amwhat size are A,X and Y. What data bank is this in? Are those LDA $4211 actually reading PPU 4211?Code: Select all
PHP PHA TXA PHA TYA PHA LDA $4211 LDA $4211 JMP ($009C) ;indirect jump to location of irq
I'll force DB to be 00 at the start of irq vector like you suggested yesterday.
Hmm, that I'm not sure on. Which address is for those vectors again? I can pause the emulator, reload a save state, step once, and I'll be able to tell exactly which bytes are loader in the vectors, I just forget which is native and which is 6502.Oziphantom wrote: ↑Tue Apr 13, 2021 7:19 am also are you in 65816 mode or 6502 mode, if 6502 mode an IRQ will fire on a BRK which tend to just keep happening.
update
I just modified my code again to make sure the DB is set to 00, when I'm writing to any of the SNES's IRA addresses.
Re: Need guidance with nes to snes.
$00FFFE/$00FFFF for IRQ or BRK in emulation mode (6502 mode)
$00FFFA/$00FFFB for NMI in emulation mode (6502 mode)
$00FFEE/$00FFEF for IRQ in native mode (65816 mode)
$00FFE6/$00FFE7 for BRK in native mode (65816 mode)
$00FFEA/$00FFEB for NMI in native mode (65816 mode)
An easier method to check in which mode you are would be to check the E status flag in the debugger. (0=>native mode, 1=>emulation mode)
$00FFFA/$00FFFB for NMI in emulation mode (6502 mode)
$00FFEE/$00FFEF for IRQ in native mode (65816 mode)
$00FFE6/$00FFE7 for BRK in native mode (65816 mode)
$00FFEA/$00FFEB for NMI in native mode (65816 mode)
An easier method to check in which mode you are would be to check the E status flag in the debugger. (0=>native mode, 1=>emulation mode)
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Need guidance with nes to snes.
6502 vectors start at 00:FFF4
65816 vectors start at 00:FFE4
65816 vectors start at 00:FFE4
-
- Posts: 490
- Joined: Fri Mar 01, 2013 4:46 am
Re: Need guidance with nes to snes.
I'm native according to the E flagDartan wrote: ↑Tue Apr 13, 2021 8:15 am $00FFFE/$00FFFF for IRQ or BRK in emulation mode (6502 mode)
$00FFFA/$00FFFB for NMI in emulation mode (6502 mode)
$00FFEE/$00FFEF for IRQ in native mode (65816 mode)
$00FFE6/$00FFE7 for BRK in native mode (65816 mode)
$00FFEA/$00FFEB for NMI in native mode (65816 mode)
An easier method to check in which mode you are would be to check the E status flag in the debugger. (0=>native mode, 1=>emulation mode)
Thank you!Oziphantom wrote: ↑Tue Apr 13, 2021 8:15 am 6502 vectors start at 00:FFF4
65816 vectors start at 00:FFE4
Last edited by infidelity on Tue Apr 13, 2021 9:17 am, edited 1 time in total.
-
- Posts: 490
- Joined: Fri Mar 01, 2013 4:46 am
Re: Need guidance with nes to snes.
OOOOOH IM SO CLOSE!!!!! Setting the DB to 00 for these snes address writes are making things happen! Glitchy, but I'm getting there!!!
Sometimes it works, other times it is not correct, cant nail it down. Ive tried On the fly editing twith with memory viewer in bsnes, editing the 4207/4208 addresses to either 09/0A, forcing 00 in the high address, trying multiple things, just cant get it right?
For mmc3 style split scroll, which snes addresses should I use?
Sometimes it works, other times it is not correct, cant nail it down. Ive tried On the fly editing twith with memory viewer in bsnes, editing the 4207/4208 addresses to either 09/0A, forcing 00 in the high address, trying multiple things, just cant get it right?
For mmc3 style split scroll, which snes addresses should I use?
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Need guidance with nes to snes.
Code: Select all
LDA $5C ;how many scanlines before irq start
STA $4209 ;VTIMEL
STA $420A ;VTIMEH
LDA $9B ;if 01, enable scanline irq
BNE $D892
LDA #$30 ;bits 2 & 1/H & V irq
TRB $72 ;reset bits for $4200
LDA $72
STA $4200
What is here to stop the code bellow happening, which will enable it even if you chose not too?
;from BNE $D892
LDA #$30 ;bits 2 & 1/H & V irq
TSB $72 ;set bits for $4200
LDA $72
STA $4200
-
- Posts: 490
- Joined: Fri Mar 01, 2013 4:46 am
Re: Need guidance with nes to snes.
For mmc3 style split scroll, which snes addresses should I use?
Re: Need guidance with nes to snes.
The "horizontal" in H-IRQ refers to the position at which it fires. It uses a dot position within a scanline as its trigger, so as to fire at the same horizontal coordinate every line (roughly - there's some jitter due to instruction execution having to finish before the IRQ actually happens). When used to do a scroll split, this will result in a (possibly glitchy-looking) vertical split from top to bottom, with the differently-scrolled regions being on the left and on the right.
The "vertical" in V-IRQ (or HV-IRQ) also refers to the position at which it fires. It uses the scanline number to determine when to fire. In an HV-IRQ, you get to also specify where in that specific scanline you want the IRQ to trigger, whereas a V-IRQ just triggers at the beginning of the line. When used to do a scroll split, this will result in a horizontal split from left to right, with the differently-scrolled regions being above and below the split.
The "vertical" in V-IRQ (or HV-IRQ) also refers to the position at which it fires. It uses the scanline number to determine when to fire. In an HV-IRQ, you get to also specify where in that specific scanline you want the IRQ to trigger, whereas a V-IRQ just triggers at the beginning of the line. When used to do a scroll split, this will result in a horizontal split from left to right, with the differently-scrolled regions being above and below the split.
Last edited by 93143 on Tue Apr 13, 2021 10:36 pm, edited 1 time in total.
-
- Posts: 490
- Joined: Fri Mar 01, 2013 4:46 am
Re: Need guidance with nes to snes.
I have a BRA there, I just didnt list it, my bad.Oziphantom wrote: ↑Tue Apr 13, 2021 9:43 amCode: Select all
LDA $5C ;how many scanlines before irq start STA $4209 ;VTIMEL STA $420A ;VTIMEH LDA $9B ;if 01, enable scanline irq BNE $D892 LDA #$30 ;bits 2 & 1/H & V irq TRB $72 ;reset bits for $4200 LDA $72 STA $4200 What is here to stop the code bellow happening, which will enable it even if you chose not too? ;from BNE $D892 LDA #$30 ;bits 2 & 1/H & V irq TSB $72 ;set bits for $4200 LDA $72 STA $4200
Still not getting the irq to actually split. The address for the irq fires up when its supposed to, the top half of the screen scrolls while the lower portion is still. I've tried setting $4200 to only having the vertical irq enabled, but that ends up screwing up everything, when I have both H & V enabled in $4200, I get no screwups but again the irq doesnt do what it's supposed to do I've tried setting $4207-$420A with different variations, no luck. Something isn't right, I'll try again tomorrow morning.
Re: Need guidance with nes to snes.
What do you want it to do instead?the top half of the screen scrolls while the lower portion is still.
...oh, wait. I remember. This game is vertically scrolling, across 2 screens, and you are skipping 16 pixels because SNES screens are 32 tiles high and NES screens are 30 tiles high. Right?
So, in the IRQ handler, you will be writing to both the H scroll and the V scroll registers, are you doing that?
nesdoug.com -- blog/tutorial on programming for the NES
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Need guidance with nes to snes.
post the entire IRQ code. When dealing with H and V you must be very very very careful. As I point out in my second video. Make sure you only write to them as bytes, and you write each register 2 times, or you will get an Odd/Even then Even/Odd updates which will glitch badly.