RAM not cleared on reset

SGDK only sub forum

Moderator: Stef

Post Reply
cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

RAM not cleared on reset

Post by cero » Thu Apr 28, 2016 5:04 pm

I want a soft-reset to be exactly the same as a hard reset. I see sgdk currently doesn't zero anything on a soft reset. How do I change it? Where is the reset vector set up?

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Re: RAM not cleared on reset

Post by Moon-Watcher » Thu Apr 28, 2016 6:55 pm

I experienced the same issue.

Got this piece of code:

Code: Select all

static struct vram *_list;

void vram_init ( u16 base )
{
	while ( _list )
	{
		struct vram *aux = _list->next;

		MEM_free ( _list );
		_list = aux;
	}

	_list  = NULL;
	_base  = base;
	_count = 0;
}
After resetting, "_list" var isn't NULL, so it enters in the loop and then fails in MEM_free()

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Re: RAM not cleared on reset

Post by Moon-Watcher » Thu Apr 28, 2016 7:44 pm

Code: Select all

static struct vram *_list = NULL;
Should I?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: RAM not cleared on reset

Post by Stef » Thu Apr 28, 2016 9:38 pm

Actually that is wanted, so you can preserve some information (as hi score) on soft-reset.
But i can understand it can be problematic...

You have a way to detect it so you can reset some variables.
If you declare the main method like this :

Code: Select all

int main(int param)
{
  ...
}
the param value can be used to detect if you are on hard or soft reset.
1 = hard reset
0 = soft reset.

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: RAM not cleared on reset

Post by cero » Fri Apr 29, 2016 8:18 am

I'd like a way to disable it completely. Any game with a high score would use SRAM.

Would it be enough to edit boot/sega.s, such that "bne.s SkipSetup" became "bne.s Continue"?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: RAM not cleared on reset

Post by Stef » Fri Apr 29, 2016 8:30 am

Yeah, you can do that to bypass it :)
Many games (any vs fighting as SF2 comes in mind) retains high-score even after soft reset without using SRAM, it would have be a shame to spent SRAM just for that...

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: RAM not cleared on reset

Post by cero » Fri Apr 29, 2016 11:52 am

Sure, but in 2016 that costs about 0.15 cents :P

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: RAM not cleared on reset

Post by Sik » Sat Apr 30, 2016 1:03 am

Um, no?

Looked up. SRAM costs like $1-$2 (closer to $2), and you need to add the battery to that - at which point EEPROM becomes a much better alternative. And then you need to add more logic to act as a mapper (to split the address ranges taken by the ROM and the save memory). So now we're closer to like $4-$5. Besides soldering materials (I guess that doesn't make that much difference though). And this assumes you're building it yourself - cartridges aren't mass produced because they don't sell that much, so they're soldered by hand, and more parts to solder means more work and if you're getting somebody else to do it (which you will want to do if you have more than a few dozen cartridges) then that's even more cost. So huh yeah avoid it when possible.

Also, sooner or later your game will have to go back to the title screen and will have to set up everything again. You don't gain anything by having the code trying to assume everything is ready.

EDIT: also wtf 32KB of SRAM is cheaper than 8KB?
32KB ($1.85): http://www.jameco.com/1/1/25287-62256lp ... emory.html
8KB ($2.25): http://www.jameco.com/1/1/25289-6264lp- ... emory.html
Sik is pronounced as "seek", not as "sick".

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: RAM not cleared on reset

Post by cero » Sat Apr 30, 2016 8:43 am

Yes, they most certainly are made in quantity. Even if you care about singles pricing:

32kb, single pricing at 4 UK cents:
http://uk.rs-online.com/web/p/sram-memo ... s/0538142/

(it's been a while since I did electronics, so no guarantee that chip is straight Gen compatible. Just to show the general SRAM pricing)

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Re: RAM not cleared on reset

Post by elusive » Tue Jun 28, 2016 8:20 pm

Sik wrote: And this assumes you're building it yourself - cartridges aren't mass produced because they don't sell that much, so they're soldered by hand, and more parts to solder means more work and if you're getting somebody else to do it (which you will want to do if you have more than a few dozen cartridges) then that's even more cost. So huh yeah avoid it when possible.
Not really true anymore. I offer brand new SRAM and non-SRAM (http://www.second-dimension.com/), so you can essentially build your own cartridge for $10 or so, as long as you have an EPROM programmer (or have buyicnow write the image to the eprom) and can solder the parts yourself, and I have links to the parts on Digikey, so there's no second guessing what parts work and what don't :)

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: RAM not cleared on reset

Post by Sik » Wed Jun 29, 2016 5:44 am

You're talking about the wrong problem, I didn't even factor in broken parts =P

I was talking about how much time it takes to make a cartridge in the first place and how much that factors into the cost. The more parts you add, the more time is spent soldering, and you need a relatively long run to get anybody accept automating it with a machine instead.
Sik is pronounced as "seek", not as "sick".

Post Reply