Dwedit's Board

Enjoy the board

You are not logged in.

Announcement

Welcome, fellow visitors from other websites!
Whenever you download a file, I'd appreciate it if you posted a nice "Thank You" message, then tell me which site you came from. Thanks.
- Dwedit

#1 2017-12-17 6:15:04 pm

Shinrai
Ungurait
Ungurait
Registered: 2017-12-17
Posts: 12

Saving configurations to the SRAM

Hey, I've been starting to use this emulator.  It works amazingly well, I didn't even know this was possible to do on a GBA.  I do have a question about it though.  I'm not able to save the emulator's configuration (palette settings, display settings, gamma, etc.).

I've taken a look at the source code, and there are functions for reading and writing data to and from the SRAM.  So saving the config is possible, but I guess I'm doing something wrong.  Can I get some help with this?

Offline

#2 2017-12-18 6:43:11 am

Dwedit
Alex Trebek (Administrator)
From: Chicago
Registered: 2004-12-12
Posts: 981
Website

Re: Saving configurations to the SRAM

Hello.  You haven't mentioned which emulator it was (Goomba Color, PocketNES, SMSAdvance, etc...), or which flash cartridge you have.

The emulators are programmed to assume you have a flash cartridge that provides a flat 64K size battery-backed save, and will assume that launching the emulator will provide the same 64K again.  Obviously, not all of them do that, hence problems.


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

#3 2017-12-18 7:24:56 am

Shinrai
Ungurait
Ungurait
Registered: 2017-12-17
Posts: 12

Re: Saving configurations to the SRAM

Thanks for the reply.  I'm using Goomba Color, but I was completely unaware about the assumed 64k saves, so I was just testing it using the VBA emulator.  I'm waiting on an EZ Flash Reform, would it save fine with the 2.04 client?

Offline

#4 2017-12-18 8:17:22 am

Dwedit
Alex Trebek (Administrator)
From: Chicago
Registered: 2004-12-12
Posts: 981
Website

Re: Saving configurations to the SRAM

Oh yeah, for Goomba Color, I never got around to putting many settings into the configuration file, or doing per-game configuration.  Most settings will reset the next time you run it.

I know that the settings people really want to save are pretty much which palette gets used for which GB game, whether to use SGB mode or not, and possibly speedhack settings.

With the newer version, the "Wario Blast" palette pretty much became the default palette for every game upon startup, since that's what a real GBC would use if the GBC wouldn't give that game another palette.


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

#5 2017-12-18 9:30:20 am

Shinrai
Ungurait
Ungurait
Registered: 2017-12-17
Posts: 12

Re: Saving configurations to the SRAM

Ah ok.  Would it be possible for me to change some default settings in the source code and try to recompile from that?

Offline

#6 2017-12-18 10:50:53 am

Dwedit
Alex Trebek (Administrator)
From: Chicago
Registered: 2004-12-12
Posts: 981
Website

Re: Saving configurations to the SRAM

Which settings are you interested in?  Disabling Palette detection for GB games that picks Wario Blast?  Disabling SGB mode?


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

#7 2017-12-18 12:41:45 pm

Shinrai
Ungurait
Ungurait
Registered: 2017-12-17
Posts: 12

Re: Saving configurations to the SRAM

Both actually.  I'm guessing that it's just not a basic variable change right?  Do you think you can give me some pointers as to what I should be changing and how I can compile it?  I have some experience with C and know the basic workarounds of assembly, but I have no idea how a GBA rom is compiled.

Edit: I figured out how to get the source compiled.  Just need to figure out what needs to be changed.

Last edited by Shinrai (2017-12-18 2:14:01 pm)

Offline

#8 2017-12-18 7:09:38 pm

Dwedit
Alex Trebek (Administrator)
From: Chicago
Registered: 2004-12-12
Posts: 981
Website

Re: Saving configurations to the SRAM

some snippets:

lcd.s:

@----------------------------------------------------------------------------
GFX_reset:	@called with CPU reset
@----------------------------------------------------------------------------
	stmfd sp!,{r3,addy,lr}

	ldrb_ r0,gbcmode
	movs r0,r0
	bne 1f
	
	@get GBC palette
	ldr_ r0,memmap_tbl
	blx_long GetGbcPaletteNumber
	@if zero, pick Wario Blast palette
	cmp r0,#0
	moveq r0,#74
	ldr r1,=palettebank
	strb r0,[r1]
	bl paletteinit
1:

Function it calls is defined in gbcgamedetect.c.

If you want to always pick a specific palette, you can comment out the call to blx_long GetGbcPaletteNumber, and the cmp and moveq instructions, then just use "mov r0, #SOME_NUMBER" instead.

Or if you remove the strb r0,[r1] instruction, it will simply not change the palette when a rom is loaded.


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

#9 2017-12-18 8:00:19 pm

Shinrai
Ungurait
Ungurait
Registered: 2017-12-17
Posts: 12

Re: Saving configurations to the SRAM

Awesome, that works great!  Turns out changing whether the SGB border is on is a pretty simple change as well.

sgb.s

auto_border:
	.byte 1	@autoborder
_autoborderstate:
	.byte 0	@autoborderstate
	.byte 0	@borderpartsadded

Changing auto_border from 1 to 0 seemed to do the trick.  Thanks again for all your help on this.

Offline

#10 2019-06-24 2:42:04 pm

Floob
Slime
Slime
From: UK
Registered: 2016-09-03
Posts: 3

Re: Saving configurations to the SRAM

Is it possible to provide a compiled file where .gb games on Goomba Colour default to Grayscale?

Offline

#11 2019-11-12 10:12:42 pm

karl_oz
Guest

Re: Saving configurations to the SRAM

Floob wrote:

Is it possible to provide a compiled file where .gb games on Goomba Colour default to Grayscale?

I second this. Grayscale as a default for non-color games would be way better than the "Wario Blast" palette. Could this be done? Maybe as an optional second release or so?

#12 2020-01-18 12:57:56 pm

sgb
Guest

Re: Saving configurations to the SRAM

Changing auto_border to 0 doesn't work here, it does work to make the option default to OFF in the settings, but regardless of whether the option is on or off, the sgb border always shows up for games that support it. I have to set the games to GB mode to get rid of the border.

On a related note, would it be possible to have options for gb mode that take SGB out of the equation entirely? The coloring in SGB mode doesn't work properly, so I don't want to run games in SGB mode ever. So it would be useful if there could be options to "Prefer GB over GBC" and "Prefer GBC over GB", that way games would run in either GB or GBC mode depending on preference, and never pick SGB mode.

This would be useful, because I changed the default to GB mode so I could avoid SGB, but when it's set up that way, games that require gbc mode require me to go into the settings and change it to one of the GBC modes, then hit Restart, whenever I play them. It's not that much of a hassle, it takes 5 seconds and it works, but it would be really useful to have the option so it'd do it automatically.

#13 2020-02-28 7:38:33 pm

autosleep
Guest

Re: Saving configurations to the SRAM

Also, correct me if I'm wrong, but... is it possible that the reason why autosleep settings don't save correctly, is because only the stime variable gets saved to the config in sram, while the sleeptime variable doesn't?

According to the code, in ui.c, scrolling through the autosleep settings between 5min-10min-30min-OFF in the menu updates the stime and sleeptime variables together. stime being used by ui.c to figure out which text string to display, and sleeptime being used by timeout.s to know how much time has to pass without any input before putting the game in sleep mode. So when you change the settings, the changes work fine, while you still have the game running.

Then when you update the config in sram, the stime variable gets stored, and when you turn off the system, come back later, and load the emulator again, the stime variable gets loaded, so the menu remembers it and it appears like it saved fine. But the sleeptime variable isn't saved, so that doesn't get restored, and in the end it defaults to 5*60*60 as defined by timeout.s, until you go in the menu and scroll through the autosleep setting to force it to re-update.

Fairly certain this is the cause, though... I've added extra code to readconfig() which sets the value of sleeptime according to the value of stime that was loaded from config, using an if/else statement just like ui.c does, and this totally solved my issue. Maybe not the most efficient way of doing it, but I'm not knowledgeable enough about how C works to add sleeptime directly to the saved config, and this works, so eh.

#14 2020-05-23 2:45:57 pm

Moonfall_Prince
Guest

Re: Saving configurations to the SRAM

Noob question: is it possible to permanently set the GoombaColor settings to always default to GBC+SGB mode?

#15 2020-05-23 3:18:32 pm

Dwedit
Alex Trebek (Administrator)
From: Chicago
Registered: 2004-12-12
Posts: 981
Website

Re: Saving configurations to the SRAM

GBC+SGB is a weird hybrid mode that doesn't reflect any real hardware.  Prefer GBC over SGB with Initial SGB Border is a better idea most of the time.

There are very few games that can use GBC+SGB mode without glitches, but when they work, they will have full color, and will change the SGB border.


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

#16 2020-05-25 3:13:10 pm

Moonfall_Prince
Guest

Re: Saving configurations to the SRAM

Dwedit wrote:

GBC+SGB is a weird hybrid mode that doesn't reflect any real hardware.  Prefer GBC over SGB with Initial SGB Border is a better idea most of the time.

There are very few games that can use GBC+SGB mode without glitches, but when they work, they will have full color, and will change the SGB border.

Ah, gotcha. That makes sense. I wasn't sure if one was better for what I was trying to go for.

Even though the SGB color palettes aren't 100% accurate, I love the novelty of having the borders and additional colors on my GBA.

Thanks for the reply and for the awesome emulator!

Quick reply

Write your message and submit

Board footer

Powered by FluxBB