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 > Need some creative ideas

#25783 - ProblemBaby - Sat Aug 28, 2004 2:15 pm

Hi

Iam woring on a SlaveBoot program that is sended to the slaves and then waiting for the master to send a program the layout is simple I just send a function Word by Word.
Ive succeeded to send a function that fills the screen to red.

My plan is to send until it sees a BX lr command.
But Ive no good ideas how to do it more advanced like sending nestled functions and global variables and constant data well
my Ideas for know is to if the function calls another function then the address should be saved and when the function is written the program continue to send the next function from that address (and also change the address in the slave so it is correct) but for data it is harder cause I dont know the size of how much to copy!

Hope you understood!
If you have any good ideas! they are welcome!

#25787 - tepples - Sat Aug 28, 2004 5:05 pm

The typical procedure that commercial games such as Kirby and Mario Kart use involves two .mb programs: a booter and the actual client program. The booter draws a splash screen with a progress bar, copies itself to IWRAM (e.g. main.iwram.o), and receives the actual client program from the server over a normal mode broadcast. Then it passes control to the actual client program. The server sends the booter using BIOS MultiBoot and then sends the actual client program using a normal mode broadcast.

To know how much to copy for each of the client programs, store the size of each program along with the program itself. This is straightforward whether you use b2x, objcopy, or GBFS. Ask if you don't understand.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25790 - ProblemBaby - Sat Aug 28, 2004 5:25 pm

Yeah I understand but I dont want multiple games in my game.
For example I want it to play different music depending of which level the master choose and to do that Ive to make a lot of different client programs. I want in somehow use the functions and data I already got in the main ROM to be used by the slave.

And.. How is the best way to copy something all code to IWRAM
all branches have to be changed, right?

#25794 - tepples - Sat Aug 28, 2004 6:27 pm

What you want to do is send assets to an existing client program. For that, Mario Kart and friends do something like this:
  • Server tells clients it is about to start a new map.
  • Clients switch into normal mode to receive a broadcast.
  • Server switches to normal mode and sends the maps, music data, etc. to clients.
  • All machines switch back to MP mode and start the map.

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25796 - ProblemBaby - Sat Aug 28, 2004 6:55 pm

Do you know how that is done exactly? is the code already loaded and then the data is placed in special locations. Like the map is always putted in 0x2010000 for example and the music is always putted in 0x2020000

#25799 - sgeos - Sat Aug 28, 2004 7:13 pm

ProblemBaby wrote:
Do you know how that is done exactly? is the code already loaded and then the data is placed in special locations. Like the map is always putted in 0x2010000 for example and the music is always putted in 0x2020000


That is basically how it will work. You will not care what the actual addresses end up being. Global or module level arrays sound like the way to do things to me. You could allocate memory instead.

Code:
map_data_t map[MAX_MAP_SIZE];  // load map data into this
music_data_t map[MAX_MUSIC_SIZE];  // load music data into this
...


-Brendan

#25801 - ProblemBaby - Sat Aug 28, 2004 7:51 pm

ok but what about the code?
is the code transmitted from the Master during the booting or under the NM-transmission?

#25803 - tepples - Sat Aug 28, 2004 8:42 pm

If "the code" is what I think you're thinking of, the program that runs on the multibooted clients during a gameplay session, then that's what I called the "actual client program".
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25806 - ProblemBaby - Sat Aug 28, 2004 9:00 pm

But when I make the client program (the actual game)
How do I program the code when it should load graphics and sound??
Cause if I understood you correctly that stuff should be transmitted from the master separatly

#25809 - tepples - Sat Aug 28, 2004 10:36 pm

The client program will look like this:
Code:
int main(void)
{
  init_all();
  while(1)
  {
    int done = 0;
    wait_for_master();
    sio_normal_mode();
    receive_assets();
    sio_mp_mode();
    init_level();
    while(!done)
    {
      done = game_loop();
    }
  }
}

Or do you want to know the details of how server's send_assets() and clients' receive_assets() work?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25812 - ProblemBaby - Sat Aug 28, 2004 11:24 pm

Yeah I will I dont really understand how everything should be worked out.

#25813 - tepples - Sat Aug 28, 2004 11:36 pm

How are you currently including files into your program? Are you using b2x, objcopy, GBFS, or something else?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25814 - ProblemBaby - Sat Aug 28, 2004 11:42 pm

hm if you mean graphics and sound and such stuff I use incbin. I dont know if that is what you call GBFS

#25835 - tepples - Sun Aug 29, 2004 5:49 am

Incbin is close enough explanation-wise to b2x. You'll need to save the size of each file you include. Then for each asset file you want to send to the other machines, you send the size, then the CRC, then the data itself.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25840 - ProblemBaby - Sun Aug 29, 2004 11:47 am

what is CRC?
and where should it be placed?
for example if I send a map
should I ALWAYS put it in the same memory location?
so the code always work for the slave or how do you mean?

#25843 - Krakken - Sun Aug 29, 2004 1:58 pm

CRC is a nuber that checks the integrity of the data. It can be done in a number of ways, such as taking each byte of the data and adding it to a char variable then you do the same at the other side and see if the numbers match.