VMU save/loading

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
lerabot
Insane DCEmu
Insane DCEmu
Posts: 134
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Nov 01, 2015 8:25 pm
Has thanked: 2 times
Been thanked: 19 times

VMU save/loading

Post by lerabot »

I'm trying to get this tutorial from 2008 to work and I'm wondering if there's a more modern way to do this?

Instead of trying to get a file on the VMU, I'm making a struct that contains all the data I need for a save. I'm trying to store that in pkg.data but I'm not sure if what I'm doing is right.

Code: Select all

int VMU_saveGame() {
    vmu_pkg_t   	pkg;
    player_data 	p;
    uint8       		data[4096], *pkg_out;
    int         		pkg_size;
    int        		i;
    file_t      		f;

    strcpy(pkg.desc_short, "Test_VMU");
    strcpy(pkg.desc_long, "This is a test VMU file");
    strcpy(pkg.app_id, "Reaperi Cycle");
    pkg.icon_cnt = 0;
    pkg.icon_anim_speed = 0;
    pkg.eyecatch_type = VMUPKG_EC_NONE;

    if (!VMU_packData(p)) //this is a function that just get all the player data and puts it into a strucs
      return(0);

    pkg.data_len = 4096;
    pkg.data = &p;

    vmu_pkg_build(&pkg, &pkg_out, &pkg_size);

    fs_unlink("/vmu/a1/REAPERI");
    f = fs_open("/vmu/a1/REAPERI", O_WRONLY);

    if(!f) {
      return(0);
    }

    setParam(5, "Saved File!");
    fs_write(f, pkg_out, pkg_size);
    fs_close(f);
    return(1);
}
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5659
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: VMU save/loading

Post by BlueCrab »

I'm not sure what you'd mean by a more modern way of doing it, but that seems relatively sane to me as you have it there. My only concerns would be that huge "data" array you're allocating on the stack and never using and if the player_data struct is actually exactly 4096 bytes long, as you've said it is with the data_len field of pkg.
Post Reply