Help with my First NES actual ROM (a multicart menu...)

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
Fumarumota
Posts: 45
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

Help with my First NES actual ROM (a multicart menu...)

Post by Fumarumota » Thu Nov 17, 2016 2:02 pm

Hi guys,

I've managed to build my first ROM, which is a 7 in 1 multi-cart menu. (I followed Nerdy Nights tutorial to get started).

So far, I have everything already implemented; the graphics are shown correctly and the indicator sprite moves up and down the correct amount of pixels when the corresponding button is pressed. I have one problem though; I want to add a delay so the sprite moves at a constant, controlled rate and not as quickly as it can (I hope I'm being clear), just as in the 64-in-1 cart and similar.

I tried maintaining a frame counter in memory so the sprite doesn't move if say, 4 frames have not passed since the last move... (I guess this is not the right way to do it). The sprite movement is delayed but the responsiveness is quite bad...

I have my controller polling routine in the NMI handler so it polls buttons once every frame.

Can you suggest me a better / optimal strategy to follow here?

Thanks in advance!
*** O-Nes-Sama emulator team ***

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

Re: Help with my First NES actual ROM (a multicart menu...)

Post by tepples » Thu Nov 17, 2016 3:12 pm

What you want to do is detect that Up or Down is pressed this frame and was not pressed the previous frame. The controller reading code in my NES project template demonstrates this. The relevant code:

Code: Select all

  lda lastFrameKeys,x   ; A = keys that were down last frame
  eor #$FF              ; A = keys that were up last frame
  and cur_keys,x        ; A = keys down now and up last frame
  sta new_keys,x

User avatar
Fumarumota
Posts: 45
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

Re: Help with my First NES actual ROM (a multicart menu...)

Post by Fumarumota » Tue Dec 18, 2018 4:06 pm

Hi Nesdev, long time no see.

I'm back to work on this project. I got the key presses working all right. Thank you @Tepples.

In fact I've almost finished the multicart. Now I'm looking for a way to make the cartridge go back to the menu on reset.

The current behavior is that when I push reset, it's the selected game that is reset instead of going back to menu, which makes sense since the interrupt vectors are switched along with the selected game (currently using GxROM mapper 66, which switches 32K of prg_rom). Menu is at the first bank of rom, followed by another 7 32K prg / 8K chr games.

My question is: do you guys know how to make the cart go back to menu on soft reset instead of having to power off, then on, to get back to it? Is there a way to detect reset by software, or will I have to add extra circuitry to my cart when I build it in a board?

Thank you in advance!
*** O-Nes-Sama emulator team ***

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

Re: Help with my First NES actual ROM (a multicart menu...)

Post by lidnariq » Tue Dec 18, 2018 4:21 pm

Fumarumota wrote:Is there a way to detect reset by software
The reset vector?

Do you mean without modifying other games? No, by definition that's what the reset vector is: the first things executed by the CPU after released from reset.

User avatar
tokumaru
Posts: 11466
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Help with my First NES actual ROM (a multicart menu...)

Post by tokumaru » Tue Dec 18, 2018 4:27 pm

You can hack each game with code to switch back to the menu, and point their reset vectors to that. The menu will not be able to boot the games using their reset vectors with an indirect JMP anymore, you'll have to hardcode each game's start address.

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Help with my First NES actual ROM (a multicart menu...)

Post by Memblers » Tue Dec 18, 2018 7:46 pm

I didn't think GNROM would be guaranteed to power up in the first bank. What is connected to the /clear line on the 74xx161? You would probably want this, for a power-on reset as much as the reset button: viewtopic.php?p=99137#p99137

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

Re: Help with my First NES actual ROM (a multicart menu...)

Post by tepples » Tue Dec 18, 2018 8:00 pm

tokumaru wrote:You can hack each game with code to switch back to the menu, and point their reset vectors to that.
A lot of the complexity of the ROM builder in the Action 53 multicart engine is related to semi-automatically patching all included ROMs with exit code suitable for each ROM's mapper and available space.

User avatar
Fumarumota
Posts: 45
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

Re: Help with my First NES actual ROM (a multicart menu...)

Post by Fumarumota » Wed Dec 19, 2018 1:18 pm

tokumaru wrote:You can hack each game with code to switch back to the menu, and point their reset vectors to that. The menu will not be able to boot the games using their reset vectors with an indirect JMP anymore, you'll have to hardcode each game's start address.
I ended up hacking each game to point to the menu's reset vector and with code to jump to that on reset and it worked like a charm, at least in FCEUX and Nestopia.
Memblers wrote:I didn't think GNROM would be guaranteed to power up in the first bank. What is connected to the /clear line on the 74xx161? You would probably want this, for a power-on reset as much as the reset button: viewtopic.php?p=99137#p99137
Completely missed that :S. Interesting stuff in that thread, definitely. I guess i'll have to take care of this when I build it in hardware, so that it always powers up in bank 0.

Thanks guys!
*** O-Nes-Sama emulator team ***

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

Re: Help with my First NES actual ROM (a multicart menu...)

Post by lidnariq » Wed Dec 19, 2018 1:38 pm

You only have to add that if you don't modify the games to switch back to the bank with the menu.

If you've modified the games to go back to the menu on a reset, you don't need extra hardware in the cart.

User avatar
Fumarumota
Posts: 45
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

Re: Help with my First NES actual ROM (a multicart menu...)

Post by Fumarumota » Mon Jan 14, 2019 10:54 pm

Finally implemented a 7 in 1 multi-cart (only NROM games) with my custom menu in a breadboard using a single 74ls161, since I only needed parallel bank numbers for both PRG ROM and CHR ROM. One thing that really gave me some headaches is bus conflicts (I took me a while to figure out that being the problem); I had to come up with a table with the expected values to be in ROM at the time of the bank switch but other than that it worked great.

Thank you again, guys!

https://drive.google.com/file/d/0B5Fznb ... sp=sharing
https://drive.google.com/file/d/0B5Fznb ... sp=sharing
*** O-Nes-Sama emulator team ***

Post Reply