make a Soft Reset with Gendev
Moderator: Stef
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
make a Soft Reset with Gendev
Hi,
i search a way to do a Soft Reset( just Soft not an Hard) with Gendev but it seems no have function for it, and i don't know the ASM...
.
but i can enter piece of ASM code directly with Gendev so if anyone of you can write me just a simple code wich can do that
Thanks
i search a way to do a Soft Reset( just Soft not an Hard) with Gendev but it seems no have function for it, and i don't know the ASM...
.
but i can enter piece of ASM code directly with Gendev so if anyone of you can write me just a simple code wich can do that
Thanks
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
same thing as the Reset button of the console.
i have build a multigame cartridge with Reset function ( with a counter) , if you press reset button it will change the game ( i have make a topic and another thanks for the people who helped me).
but i would add a screen selection menu which make the reset:
-for exemple:
-if you press start with the game 1 selected the console make one reset and it launch the game.
-start with the second game : two reset
ect...
i have build a multigame cartridge with Reset function ( with a counter) , if you press reset button it will change the game ( i have make a topic and another thanks for the people who helped me).
but i would add a screen selection menu which make the reset:
-for exemple:
-if you press start with the game 1 selected the console make one reset and it launch the game.
-start with the second game : two reset
ect...
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
The long at address 4 is the reset vector. It points to where the MD should start when you push the reset button.
In assembly
and in C
In assembly
Code: Select all
movea.l 4.w,a0
jmp (a0)
Code: Select all
(*(int*)4)();
-
- Very interested
- Posts: 2443
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
To differentiate between Soft and Hard reset, games read controller ports to see if they're initialized or not. Soft reset does not alter controller port config, but Hard Reset puts them into default values.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
thanks you very much Chilly Willy but i have wrote this :
and Gendev tells me " called object is not a function "
Code: Select all
if( jeu==1 && start) // lancement du jeu 1 on fait un reset
{
(*(int*)4)(); // pointage sur le vecteur 4
}
-
- Very interested
- Posts: 746
- Joined: Sat Dec 15, 2007 7:49 am
- Location: Kazakhstan, Pavlodar
M68K can push the reset button (actually, make VRES signal active) for prepare own hardware. There are "RESET" opcode (0x4E70), wich does things:
ASM inline can be used, does it?
But, I don't know for sure, affects this opcode on MegaDrive hardware or not. But VRES is directly connected to RESET pin of M68K, so cartrige hardware can be reset this way.
I think it usefull to use this opcode before jump to inital vector. So, do it this way:Description: Asserts the RSTO signal for 512 (124 for MC68000, MC68EC000, MC68HC000, MC68HC001, MC68008, MC68010, and MC68302) clock periods, resetting all external devices. The processor state, other than the program counter, is unaffected, and execution continues with the next instruction.
Code: Select all
reset
movea.w (4),a0
jmp (a0)
Code: Select all
0x4E70, 0x2078, 0x0004, 0x4ED0
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
i have try to write this but no effect:
if have not "%" don't works.
Code: Select all
if( jeu==1 && start) // lancement du jeu 1 on fait un reset
{
asm ("movea.l 4, %a0");
asm ("jmp (%a0)");
}
Note, if you want to do a proper soft reset, you'll need to reset the stack pointer.
This should work:
This should work:
Code: Select all
asm volatile ( "move #0x2700,%sr\n\t"
"move.l 0,%a7\n\t"
"move.l 4,%a0\n\t"
"jmp (%a0)" );
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
I just released version SGDK v0.7, i internally implemented a correct soft reset method (just called "reset()") which keep some internals states unchanged as ram which wasn't the case before.
You can also detect it in our main() method which now accept one parameter : main(u16 param)
(param != 0) --> hard reset
(param == 0) --> soft reset
See in the dedicated topic
You can also detect it in our main() method which now accept one parameter : main(u16 param)
(param != 0) --> hard reset
(param == 0) --> soft reset
See in the dedicated topic