What are the latest variables used by Wii Message Board in latest devkitPPC/libOGC?

SaulFabre

I like Yoshis and the Wii/Wii U scene.
OP
Member
Joined
Feb 6, 2019
Messages
3,234
Trophies
2
Age
25
Location
Ecuador
Website
saulfabreg-wiivc.blogspot.com
XP
8,057
Country
Ecuador
Hello!!!

So i was tinkering a bit with the stuff of adding Wii Message Board support to homebrew apps, for be able to write the info of the time played in a game, if launched from a Wii forwarder channel (for example, my custom Single ROM Loaders).

Like @SuperrSonic did it with RA-SS / RA-HEXAeco and WiiMC-SSLC, with a piece of code made by users Marc, @tueidj, @dimok and SuSo.

I'm taking this commit as reference for add Wii Message Board support to homebrew apps: https://github.com/SuperrSonic/WiiMC-SSLC/commit/74286512
The files for Wii Message Board stuff i'm taking from RA-SS: https://github.com/SuperrSonic/RA-SS

BUT...

I've encountered into a problem. (Maybe @Wiimpathy can help me with this?)

The code shown here only works on old devkitPPC versions (until devkitPPC r29-1 i guess since i applied this to WiiStation and it works fine).

WMBPlaylog.c

Code:
/*
    WMBPlaylog.c
    This code allows to modify play_rec.dat in order to store the
    game time in Wii's log correctly.
    by Marc
    Thanks to tueidj for giving me some hints on how to do it :)
    Most of the code was taken from here:
    http://forum.wiibrew.org/read.php?27,22130
    Modified by Dimok and SuSo
*/

#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include <malloc.h>

#define ALIGN32(x) (((x) + 31) & ~31)

#define SECONDS_TO_2000 946684800LL
#define TICKS_PER_SECOND 60750000LL

//! Should be 32 byte aligned
static const char PLAYRECPATH[] ATTRIBUTE_ALIGN(32) = "/title/00000001/00000002/data/play_rec.dat";

typedef struct _PlayRec
{
    u32 checksum;
    union
    {
        u32 data[31];
        struct
        {
            u16 name[42];
            u64 ticks_boot;
            u64 ticks_last;
            char title_id[6];
            char unknown[18];
        } ATTRIBUTE_PACKED;
    };
} PlayRec;

static u64 getWiiTime(void)
{
    time_t uTime = time(NULL);
    return TICKS_PER_SECOND * (uTime - SECONDS_TO_2000);
}

int Playlog_Exit(void)
{
    s32 res = -1;
    u32 sum = 0;
    u8 i;

    //Open play_rec.dat
    s32 fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
    if(fd < 0)
        return fd;

    PlayRec * playrec_buf = memalign(32, ALIGN32(sizeof(PlayRec)));
    if(!playrec_buf)
        goto cleanup;

    //Read play_rec.dat
    if(IOS_Read(fd, playrec_buf, sizeof(PlayRec)) != sizeof(PlayRec))
        goto cleanup;

    if(IOS_Seek(fd, 0, 0) < 0)
        goto cleanup;

    // update exit time
    u64 stime = getWiiTime();
    playrec_buf->ticks_last = stime;

    //Calculate and update checksum
    for(i = 0; i < 31; i++)
        sum += playrec_buf->data[i];

    playrec_buf->checksum = sum;

    if(IOS_Write(fd, playrec_buf, sizeof(PlayRec)) != sizeof(PlayRec))
        goto cleanup;

    res = 0;

cleanup:
    free(playrec_buf);
    IOS_Close(fd);
    return res;
}

WMBPlaylog.h

Code:
#ifndef WMBPLAYLOG_H_
#define WMBPLAYLOG_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <gctypes.h>

int Playlog_Exit(void);

#ifdef __cplusplus
}
#endif

#endif

When i tried to implement this on updated homebrew (FCEUGX, Snes9xGX, VBAGX, Genesis Plus GX, etc.), while it compiled fine i couldn't get the Wii Message Board write support to work, maybe because libOGC doesn't recognize them anymore on latest versions.

Can anyone tell me how i can fix these pieces of code for make homebrew compatible with writing playlog on Wii Message Board with latest devkitPPC/libOGC?

Thanks a lot ;)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    PandaPandel @ PandaPandel: lmao goodness