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: 49
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

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

Post by Fumarumota »

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: 22708
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 »

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: 49
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

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

Post by Fumarumota »

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: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post by lidnariq »

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: 12427
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 »

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: 4044
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 »

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: 22708
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 »

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: 49
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

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

Post by Fumarumota »

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: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post by lidnariq »

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: 49
Joined: Wed Nov 19, 2014 9:00 am
Location: Mexico

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

Post by Fumarumota »

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