Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
sorry if this is a stupid question im a beginner
im making a game and I want to reset the game when you lose idk how to do this;
Offline
A full reset of the Game Boy? Just reset() will do the trick (if you're using GBDK, anyways.)
Last edited by Ardis (2020-12-07 10:25:57)
Offline
it depends how you want to reset. if you want to jump back to the boot rom, you need to pull the reset line low using whatever mechanism for that that is available on your cartridge. otherwise just jump to address 0. which you can do in many ways. one way to do it in assembly is:
RST 0
if you are using C with the GBDK-N compiler, then you should be able to define a reset macro like this in a header file:
#define RESET_GB() __asm__("RST 0")
which you can then call any time like so:
RESET_GB();
of course I don't think that the non N build of gbdk supports inline assembly so if you are using that you probably have to write an assembly function that calls reset in a separate file and link it.
Offline
RST 0 won't work.
in GBDK-n it will simply do nothing because of this: https://github.com/andreasjhkarlsson/gb … .s#L11-L12
and in GBDK-2020 there is no vector by default, and there appears a vector when you #include <gb/crash_handler.h> but that is a crash handler, not reset it must be there in case you are calling a null pointer or calling 0xffff (uninitialized pointer from ROM).
you also don't need to invent any functions of the kind, because there is already reset() in gb.h! in any version of GBDK!
ps: and there is no sense in using GBDK-N at all.
pps: game boy entry point is at 0x150, not 0.
Last edited by toxa (2021-01-29 06:19:23)
Offline
I didnt realize that in gbdk, I have used it before but not much. i usually hand write the reset vector in assembly. and include a jump to the end of the rom header there
Offline
Why do you give suggestions then?
Offline
That won’t work in any gbdk (except 2020 with custom crash handler, then solution is incomplete), and that is incomplete solution, assuming it is asm.
Offline