|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
|
Turning off or hard reset or soft reset of the Master System from code
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 |
|
|
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. |
|
|
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. | |
|
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. |
|
|
Posted: Wed Jan 04, 2023 6:43 pm |
Ah right you are, I was having a senior moment and got reset and pause confused 😕 |
|
|
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 |
|
|
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. |
|
|
Posted: Wed Jan 04, 2023 9:16 pm |
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). |
|
|
Posted: Thu Jan 05, 2023 8:17 am |
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. |
|
|
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 |
|
|
Posted: Thu Jan 05, 2023 10:27 am |
in ansi C you: void (*reset)() = 0;
reset(); |
|
|
Posted: Thu Jan 05, 2023 10:30 am |
Interesting function declaration.. that's the kind of things why I love ansi c so much. |
|
|
Posted: Thu Jan 05, 2023 10:31 am |
oh, BTW, is there any example? |
|
|
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. | |
|
Posted: Thu Jan 05, 2023 5:35 pm |
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. |
|
|
Posted: Sat Jan 07, 2023 7:50 am |
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). |
|
|
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. | |
|
Posted: Sun Jan 08, 2023 2:23 pm |
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. |
|