Gameboy Development Forum

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.

Ads

#1 2020-12-06 16:10:01

Ricardo
New member
Registered: 2020-12-06
Posts: 1

reset game

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

 

#2 2020-12-07 10:25:30

Ardis
Member
From: USA
Registered: 2019-06-06
Posts: 60
Website

Re: reset game

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)


Also known as Arvex in other places.

Interceptor (Demo)
https://arvex.itch.io/interceptor

Offline

 

#3 2021-01-27 19:07:46

kalt
New member
Registered: 2021-01-26
Posts: 7

Re: reset game

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:

Code:

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:

Code:

#define RESET_GB() __asm__("RST 0")

which you can then call any time like so:

Code:

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

 

#4 2021-01-29 05:57:11

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: reset game

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 smile 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

 

#5 2021-01-29 10:45:11

kalt
New member
Registered: 2021-01-26
Posts: 7

Re: reset game

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

 

#6 2021-01-30 05:58:50

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: reset game

Why do you give suggestions then?

Offline

 

#7 2021-01-31 13:00:04

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: reset game

Because the OP didn't specify it was in GBDK, or which version of GBDK.

Last edited by AntonioND (2021-01-31 13:02:01)

Offline

 

#8 2021-02-01 03:44:17

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: reset game

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

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson