MEM_alloc
Moderator: Stef
Re: MEM_alloc
Did you call MEM_init() before you called MEM_alloc() ?
Re: MEM_alloc
not sure, i guess not will try thanks
Re: MEM_alloc
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
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:
The behavior would be as if you run the program for the first time whenever you push the reset button.
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
}
Re: MEM_alloc
I havent SYS_hardReset in my sgdk version, will upgrade later.
Demo mainly works now, but reset still broken, not a problem...
Demo mainly works now, but reset still broken, not a problem...
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Re: MEM_alloc
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
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.
Code: Select all
short init_flag = 0; // start not initialized
...
if (!init_flag)
{
// do init
...
init_flag = 1;
}