Page 1 of 1
MEM_alloc
Posted: Mon Apr 22, 2019 9:21 am
by bioloid
Hello,
I've a MEM_alloc which is failing but my project is nearly empty, is there some build option I could have broken or something ?
Re: MEM_alloc
Posted: Mon Apr 22, 2019 10:00 am
by hotrodx
Did you call MEM_init() before you called MEM_alloc() ?
Re: MEM_alloc
Posted: Mon Apr 22, 2019 10:51 am
by bioloid
not sure, i guess not will try thanks
Re: MEM_alloc
Posted: Mon Apr 22, 2019 7:15 pm
by bioloid
hey, burning the vdp here, it works fine of Fusion but got stuck in real genny, trying VDP-Init but does not work, cleaver way to reset the thing ? need i call wait dma completion ?
Re: MEM_alloc
Posted: Mon Apr 22, 2019 7:48 pm
by hotrodx
I'm trying to decipher what you mean. If you were trying to push reset on the Genny, that's the equivalent of a Soft Reset. Variables are not re-initialized on soft resets.
To do a "hard reset", replace you main function like this:
Code: Select all
int main(u16 hard) {
if (!hard) {
SYS_hardReset();
}
// rest of the code here
}
The behavior would be as if you run the program for the first time whenever you push the reset button.
Re: MEM_alloc
Posted: Tue Apr 23, 2019 10:52 am
by bioloid
I havent SYS_hardReset in my sgdk version, will upgrade later.
Demo mainly works now, but reset still broken, not a problem...
Re: MEM_alloc
Posted: Tue Apr 23, 2019 3:46 pm
by Chilly Willy
In SGDK, a hard reset clears the work ram, then copies the data segment from rom into work ram (taking care of all those preset variables). A soft reset skips both those steps, so preset variables won't have their preset value, and the rest of memory won't be clear. Calling SYS_hardReset() forces a hard reset, thus clearing ram and setting all preset vars. So if your game uses something like
Code: Select all
short init_flag = 0; // start not initialized
...
if (!init_flag)
{
// do init
...
init_flag = 1;
}
then it won't work on a soft reset since init_flag will already be 1. A hard reset would set it back to 0 and then the init routine would run again.
Re: MEM_alloc
Posted: Wed Apr 24, 2019 5:14 pm
by bioloid
ok thanks.