gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Save/load struct in Cart RAM

#14589 - doudou - Fri Jan 09, 2004 1:07 am

I want to save a struct in the Cart RAM, I thought this would work :


#define GAMEPAK_RAM ((u8*)0x0E000000)
u8* pSaveMem = GAMEPAK_RAM;

for (i = 0 ; i < sizeof(my_struct) ; i++)
pSaveMem[i] = *((u8*) (&my_struct + i));


but it does not. Why ?

#14591 - LOst? - Fri Jan 09, 2004 1:17 am

Oh, does this work, just by writing to a memory location?

#14592 - ampz - Fri Jan 09, 2004 1:30 am

How about this?

pSaveMem[i] = *((u8*)my_struct + i);

#14594 - dagamer34 - Fri Jan 09, 2004 2:07 am

I posted about this earlier and have a nice, simple solution to it. Just follow this link. (you really should search for stuff before you post)

http://forum.gbadev.org/viewtopic.php?t=2550

Pretty simple to use. Just make sure you don't overwrite your own stuff, might create a big problem. It's kinda slow (SRAM has a 5 wait-state period, so don't do it every frame) but no one complains.

Your welcome!!
_________________
Little kids and Playstation 2's don't mix. :(

#14597 - doudou - Fri Jan 09, 2004 2:43 am

thank you dagamer. By the way, i searched (maybe not that much) before my post. By another way, i think your code is right and a memcpy could not be used since SRAM is only accessible 8 bits at a time.

#14602 - Miked0801 - Fri Jan 09, 2004 3:34 am

What? You guys don't like working with EEPROM memory? :P

#14607 - sajiimori - Fri Jan 09, 2004 7:07 am

Yeah, I made a boo-boo in that thread. Please disregard.

#14622 - dagamer34 - Fri Jan 09, 2004 11:49 pm

Boo-boo?? lol. That's funny!!

Now, I'm working on sound and multiplayer. I think I can get sound to work, but multiplayer is *insert curse word here*!!!!

Maybe that's why there are few multiplayer games and even fewer that use 4-players. Why is that?
_________________
Little kids and Playstation 2's don't mix. :(

#14631 - tepples - Sat Jan 10, 2004 1:10 am

Few commercial games have multiplayer because few families have $400 to spend on GBA SP systems and $120 to spend on a game.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14648 - dagamer34 - Sat Jan 10, 2004 4:18 am

Well, not really the family in general, more like your friends. I mean, I do have 4 friends who have GBA/GBA-SPs but I haven't met them all at the same time.

Besides, I was going to focus more on 2-player gameplay.
_________________
Little kids and Playstation 2's don't mix. :(

#14665 - ampz - Sat Jan 10, 2004 12:37 pm

I'd like to see more 4-player multiboot titles.

dagamer34: For 2-player gameplay you should use the UART mode for communications. Check out my keyboard software, it might help you get started.
http://www.brolinembedded.se/projects/index5.html

#14683 - dagamer34 - Sun Jan 11, 2004 3:38 am

Why should I use UART mode? Why not multiplayer?

Anyway, I finally found a decent demo that shows something to do with multiplayer. Its a step in the right direction!
_________________
Little kids and Playstation 2's don't mix. :(

#14709 - Miked0801 - Sun Jan 11, 2004 10:09 pm

I'm not sure, but I believe that the UART communications doesn't use the standard cable that Nintendo sells. Feel free to correct me though...

#14716 - dagamer34 - Sun Jan 11, 2004 11:37 pm

Well, I want to use the standard Nintendo cable.
_________________
Little kids and Playstation 2's don't mix. :(

#14727 - yaustar - Mon Jan 12, 2004 1:12 am

Can you show the source of he demo? The only one I found was from Down to You...
_________________
[Blog] [Portfolio]