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 - Turning off or hard reset or soft reset of the Master System from code

Reply to topic
Author Message
  • Joined: 28 Jan 2017
  • Posts: 556
  • Location: Málaga, Spain
Reply with quote
Turning off or hard reset or soft reset of the Master System from code
Post Posted: Wed Jan 04, 2023 3:44 pm
Well... that is the question.

It can be done? how? From ansi c? are there some dedicated functions in smslib? should be ???

These are important questions for me and my current project, now.

Happy year everyone!!! :D
  View user's profile Send private message
  • Joined: 06 Mar 2022
  • Posts: 670
  • Location: London, UK
Reply with quote
Post Posted: Wed Jan 04, 2023 5:01 pm
The soft reset button on the SMS 1 triggered an NMI, which causes a jump to $0066 at the next opportunity. So you should be able to simulate an NMI in code by just executing call $0066 I think.

Otherwise there's no way that I know of to electrically simulate resetting the CPU itself or a power cycle, or forcing a reset of the other hardware.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Wed Jan 04, 2023 6:31 pm
The reset button does not trigger NMI. To soft reset your game you just need to jump to address 0; to “harder” reset you would need to jump to the BIOS via code in RAM.
  View user's profile Send private message Visit poster's website
  • Joined: 31 Dec 2022
  • Posts: 30
Reply with quote
Post Posted: Wed Jan 04, 2023 6:36 pm
Last edited by Jolene on Wed Jan 04, 2023 6:47 pm; edited 1 time in total
You can definitely electrically do a hard reset (i.e.
turn the master system off then on) if you are
willing got build a circuit.

It can be turned from software if you are willing to build a circuit
that will connect to one of the joystick/paddle 9 pin ports (there is a pin on the 9 pin joystick port that can be used as an output pin),

"These are important questions for me and my current project, now. "

Building a circuit depends on if it suits your situation
of course. The circuit would be activated from the output
pin on the joystick port and the circuit would be something
like a timed relay controlled by a transistor; the
timed relay would turn off the power to the master system
then after some time go back to its normal state (turn
on the master system).
For example you could use a cheap 2n551 transistor
to tap the signal from the master system to the
circuit. That's the outline of the timer relay circuit it not the
exact details of it.

"It can be done? how? From ansi c? are there some dedicated functions in smslib? should be ??? "
In software it would basically be a bit toggle to the
relevant pin on one of the joystick. That is what
the software side boils down to-not the exact details of it.
  View user's profile Send private message
  • Joined: 06 Mar 2022
  • Posts: 670
  • Location: London, UK
Reply with quote
Post Posted: Wed Jan 04, 2023 6:43 pm
Maxim wrote
The reset button does not trigger NMI. To soft reset your game you just need to jump to address 0; to “harder” reset you would need to jump to the BIOS via code in RAM.

Ah right you are, I was having a senior moment and got reset and pause confused 😕
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 556
  • Location: Málaga, Spain
Reply with quote
Post Posted: Wed Jan 04, 2023 7:55 pm
Interesting theme, I see.

No, seriously, I only want to reset the game from software, which, I though after post this query, can be simulated without hassle, as it it like return to the main "mikgames" screen when I need it, maybe, with some nice effect to simulate a hardware "troublematic" fault.

... other thing would be if I could turn off the master from the game code... but We will have to wait to the MiniSMS, or the SMS3 xD
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Wed Jan 04, 2023 8:28 pm
I think easiest would be to hack in some assembly to jump to address 0, although that will run the CRT pre-main code again and will reset all state. Alternatively I guess returning to the menu would be a transition in your state machine that you’d handle like any other.

Powering off the system might require a robotic arm to reach out from the cartridge and slide the power switch on the console, which I guess would be quite complicated.
  View user's profile Send private message Visit poster's website
  • Joined: 31 Dec 2022
  • Posts: 30
Reply with quote
Post Posted: Wed Jan 04, 2023 9:16 pm
Maxim wrote
I think easiest would be to hack in some assembly to jump to address 0, although that will run the CRT pre-main code again and will reset all state. Alternatively I guess returning to the menu would be a transition in your state machine that you’d handle like any other.

Powering off the system might require a robotic arm to reach out from the cartridge and slide the power switch on the console, which I guess would be quite complicated.


A robotic arm is doable because 8bit chess playing computers exist that use a robotic arm-but it would be simpler just to use a relay+switching transistor+some resistors where the relay NC is connected to the power input to the master system;but the OP says he does not want to use a hardware based solution (If I understood him correctly).
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Jan 05, 2023 8:17 am
eruiz00 wrote
are there some dedicated functions in smslib? should be ???


in SMSlib there are functions to check if the reset button (which is missing on SMS IIs...) is pressed, like any other button on the pads (yes, this is not on the pad...) and you can program your game to do whatever you want when it's pressed.

But, well, there's no SMSlib function to reset the console - I didn't think it would ever be needed. If just restarting the ROM from the beginning is fine, you could do that with a single asm instruction, for instance:

__asm
    rst #0
__endasm;


getting the console to restart from the same situation after the switch has been turned on is more complex, but still doable if you need that.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 556
  • Location: Málaga, Spain
Reply with quote
Post Posted: Thu Jan 05, 2023 8:53 am
Thanks Sverx, the jmp to #0 is what I need...

... although I am thinking _seriously_ in implement the mechanic arm instead of a poor software line of code xD could be great !!!!!!

pd. if someone make a yabyum clone... it could be doable some mech extension? (could open a new thread about this) xxxxD
  View user's profile Send private message
  • Joined: 09 Aug 2021
  • Posts: 131
Reply with quote
Post Posted: Thu Jan 05, 2023 10:27 am
sverx wrote
If just restarting the ROM from the beginning is fine, you could do that with a single asm instruction, for instance:

in ansi C you:
void (*reset)() = 0;
reset();
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 556
  • Location: Málaga, Spain
Reply with quote
Post Posted: Thu Jan 05, 2023 10:30 am
toxa wrote
sverx wrote
If just restarting the ROM from the beginning is fine, you could do that with a single asm instruction, for instance:

in ansi C you

    void (*reset)() = 0;
    reset();


Interesting function declaration.. that's the kind of things why I love ansi c so much.
  View user's profile Send private message
  • Joined: 09 Aug 2021
  • Posts: 131
Reply with quote
Post Posted: Thu Jan 05, 2023 10:31 am
Maxim wrote
to “harder” reset you would need to jump to the BIOS via code in RAM.

oh, BTW, is there any example?
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Thu Jan 05, 2023 11:02 am
I have no idea how to express it in C, but in assembly I’d write (position-independent) code that writes to port $3e to disable the cartridge and enable the BIOS, then jump to address 0; then in cartridge ROM, copy that code to RAM and jump to it. I guess you should also disable interrupts and maybe turn the screen off.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Jan 05, 2023 5:35 pm
toxa wrote
Maxim wrote
to “harder” reset you would need to jump to the BIOS via code in RAM.

oh, BTW, is there any example?


it's not that hard to write if needed, the sources of SMS Test Suite already contains code running from RAM and accessing BIOS so you could start from there.
  View user's profile Send private message Visit poster's website
  • Joined: 09 Aug 2021
  • Posts: 131
Reply with quote
Post Posted: Sat Jan 07, 2023 7:50 am
sverx wrote
it's not that hard to write if needed, the sources of SMS Test Suite already contains code running from RAM and accessing BIOS so you could start from there.

Oh, you got me wrong. I don’t have any problems with placing or executing code from RAM. I was asking how to switch on the bios, and what are the known bios routines other than the entry point (if any).
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Sat Jan 07, 2023 8:20 am
The BIOS is really an IPL and has no API or callable routines that are stable across versions.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sun Jan 08, 2023 2:23 pm
toxa wrote
Oh, you got me wrong. I don’t have any problems with placing or executing code from RAM. I was asking how to switch on the bios, and what are the known bios routines other than the entry point (if any).


I know you know how to run code from RAM, I was simply suggesting you where you could look at some openly available code to see how to enable BIOS.

Also, as Maxim said, BIOS isn't probably the correct term - 'IPL ROM' is probably a better definition, but I guess we're going to keep on calling that BIOS anyway.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!