Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - The pause button does WHAT?

Reply to topic
Author Message
  • Joined: 07 Nov 2018
  • Posts: 42
  • Location: Brazil
Reply with quote
The pause button does WHAT?
Post Posted: Fri May 26, 2023 3:34 pm
Hi! I just got done reading the official Mark 3 development manual, and... uuh...

NMI
The NMI pin is connected to the console "PAUSE" button. Pressing this button causes the Z80 to
execute a Restart instruction at location $66. This acts as a simple subroutine call: the PC is pushed
onto the stack and a jump to $0066 is performed.
This interrupt is "edge-triggered", which means that if the PAUSE button is held down, you will get a
single interrupt only.
NOTE: The last instruction of your NMI routine must be "RETN", Return from Non-Maskable
Interrupt.
The PAUSE button is for the exclusive use of your program; you must set up the transfer of control at
$0066 to your PAUSE routine.
The most common PAUSE routine will toggle a software "pause" flag and turn off the sounds if this
flag has just been set. The INT routine, which is periodically activated, then checks the condition of
the pause flag and does no processing if it is set (it loops on the pause flag).
This method allows the pause feature to be implemented without turning the interrupts off and on
(with a DI and later an EI instruction). This DI-EI combination can cause a spurious interrupt in the
Z80.
The NMI cannot be inhibited.

Wow. Now that is something else, isn't it? I thought the pause button would just be, you know... a button! A bit that flips while you hold it, you know?
I was wondering if I would be able to make games pause with the Mega Drive controller's start button, but I'm pretty sure that would be a really hard hack, that is, if it's possible at all.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14734
  • Location: London
Reply with quote
Post Posted: Fri May 26, 2023 4:15 pm
It’s perplexing that reset is a regular button but pause is NMI. To hook up a MD controller you’d need to patch out the controller reads to a full MD controller reader function, and then call $66 if Start is pressed.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Dec 2019
  • Posts: 56
  • Location: USA
Reply with quote
Post Posted: Fri May 26, 2023 5:54 pm
One of my demos goes the other way. Have $66 run a routine that sets a wPauseTime variable to 5. Then add the MD controller reader function, and if wPauseTime is nonzero, decrement it and OR in the bit for Start.

One thing that makes NMI-on-Pause inconvenient is that it makes using pop bc as a fast autoincrementing read less safe. If the stack is in ROM, the CPU will try to write PC to ROM, and then retn will pop PC from ROM.

In addition, if a game is set up to save to the game's flash chip instead of battery RAM, it can cause serious problems if the player presses Pause while the game is saving, because there'll be nothing to respond to instruction fetches from $0066. (During sector erase and byte program operations, reading the chip produces a status value instead of ROM contents.)
  View user's profile Send private message Visit poster's website
  • Joined: 07 Nov 2018
  • Posts: 42
  • Location: Brazil
Reply with quote
Post Posted: Fri May 26, 2023 7:51 pm
Maxim wrote
It’s perplexing that reset is a regular button but pause is NMI. To hook up a MD controller you’d need to patch out the controller reads to a full MD controller reader function, and then call $66 if Start is pressed.


I know, right? Wouldn't it make much more sense for pause to be a button and reset to clear ram or something?
Anyway, thanks for the clarification. That is WAY beyond my league
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14734
  • Location: London
Reply with quote
Post Posted: Sat May 27, 2023 7:22 am
I guess that means by extension, pressing pause during BIOS startup checksum time means it will execute the game’s pause routine and potentially corrupt the memory state. It might be interesting to hide something in there that would make the BIOS jump to a secret/debug screen in the game - but maintaining compatibility with all the BIOS variants would be a challenge.
  View user's profile Send private message Visit poster's website
  • Joined: 07 Apr 2021
  • Posts: 20
Reply with quote
Post Posted: Sun May 28, 2023 7:21 pm
Maxim wrote
It’s perplexing that reset is a regular button but pause is NMI. To hook up a MD controller you’d need to patch out the controller reads to a full MD controller reader function, and then call $66 if Start is pressed.


Is the reset button on the Genesis/MD also just treated like a controller read? I've never read the specs, but I do recall there was one game where at a certain point, it said "Reset the computer" and you were supposed to actually reset your console to progress in the game.
  View user's profile Send private message
  • Joined: 14 Oct 2008
  • Posts: 510
Reply with quote
Post Posted: Mon May 29, 2023 2:11 pm
That was X-Men.
I'm not very familiar with that game, but I thought I read once there was another way to complete that part, but that pushing the Reset button was the easier solution.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!