It is currently Mon Jun 17, 2019 10:45 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Thu Nov 17, 2016 2:02 pm 
Offline
User avatar

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


Top
 Profile  
 
PostPosted: Thu Nov 17, 2016 3:12 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21440
Location: NE Indiana, USA (NTSC)
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:
  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

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
PostPosted: Tue Dec 18, 2018 4:06 pm 
Offline
User avatar

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


Top
 Profile  
 
PostPosted: Tue Dec 18, 2018 4:21 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8379
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Tue Dec 18, 2018 4:27 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11369
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Tue Dec 18, 2018 7:46 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3689
Location: Indianapolis
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: http://forums.nesdev.com/viewtopic.php?p=99137#p99137


Top
 Profile  
 
PostPosted: Tue Dec 18, 2018 8:00 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21440
Location: NE Indiana, USA (NTSC)
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.

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
PostPosted: Wed Dec 19, 2018 1:18 pm 
Offline
User avatar

Joined: Wed Nov 19, 2014 9:00 am
Posts: 45
Location: Mexico
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: http://forums.nesdev.com/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 ***


Top
 Profile  
 
PostPosted: Wed Dec 19, 2018 1:38 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8379
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Mon Jan 14, 2019 10:54 pm 
Offline
User avatar

Joined: Wed Nov 19, 2014 9:00 am
Posts: 45
Location: Mexico
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/0B5FznbU3cAL-RTZ4aHk0R1hsR3ZEdGRscWIzdXVCY1Z4NzFZ/view?usp=sharing
https://drive.google.com/file/d/0B5FznbU3cAL-c0xlT3VUMF9YSmVtdnJtQ3NLV3hxcVR4ekJn/view?usp=sharing

_________________
*** O-Nes-Sama emulator team ***


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group