Giter Club home page Giter Club logo

Comments (5)

andres-asm avatar andres-asm commented on May 18, 2024

I debuged the sizes (total from retro_serialize_size and the independent sizes for each GB) and the sizes are correct

from sameboy.

andres-asm avatar andres-asm commented on May 18, 2024

I just realized my state code for 2 gbs has an error

bool retro_serialize(void *data, size_t size)
{

    if (!initialized)
        return false;


    void* save_data[2];
    size_t state_size[2];

    for (int i = 0; i < emulated_devices; i++)
    {
        state_size[i] = GB_get_save_state_size(&gameboy[i]);
        save_data[i] = (uint8_t*)malloc(state_size[i]);
        GB_save_state_to_buffer(&gameboy[i], (uint8_t*) save_data[i]);
        memcpy(data + (state_size[i] * i), save_data[i], state_size[i]);
        free(save_data[i]);
    }

    if (data)
        return true;
    else
        return false;
}

memcpy(data + (state_size[i] * i), save_data[i], state_size[i]);
Would offset based on the next state size, so I fixed that now like this:

bool retro_serialize(void *data, size_t size)
{

    if (!initialized)
        return false;

    void* save_data[2];
    size_t state_size[2];
    size_t offset = 0;

    for (int i = 0; i < emulated_devices; i++)
    {
        state_size[i] = GB_get_save_state_size(&gameboy[i]);
        save_data[i] = (uint8_t*)malloc(state_size[i]);
        GB_save_state_to_buffer(&gameboy[i], (uint8_t*) save_data[i]);
        memcpy(data + offset, save_data[i], state_size[i]);
        offset += state_size[i];
        free(save_data[i]);
    }

    if (data)
        return true;
    else
        return false;
}```

Seems better at least but the crash persists.

from sameboy.

LIJI32 avatar LIJI32 commented on May 18, 2024

I've noticed this before and forgot to fix it :( I'll have a look when I'm back from work.

from sameboy.

LIJI32 avatar LIJI32 commented on May 18, 2024

Can't reproduce this on macOS, even with libgmalloc. Can you test again with the latest code, and attach the new crashlog along side with the crashing SameBoy DLL?

from sameboy.

andres-asm avatar andres-asm commented on May 18, 2024

Nope, the latest changes fixed it!

Still crashes on rewinding but that's probably separate and related to the change you reported in RA

from sameboy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.