Same-Boy

 view release on metacpan or  search on metacpan

Boy.xs  view on Meta::CPAN

        GB_set_turbo_mode(&sb_from_sv(aTHX_ self)->gb, on, no_frame_skip);
        RETVAL = SvREFCNT_inc(self);
    OUTPUT:
        RETVAL

SV *
set_rtc_mode(self, mode)
    SV         *self
    const char *mode
    CODE:
        GB_set_rtc_mode(&sb_from_sv(aTHX_ self)->gb,
                        (GB_rtc_mode_t)sb_rtc_mode_id(aTHX_ mode));
        RETVAL = SvREFCNT_inc(self);
    OUTPUT:
        RETVAL

# ---- introspection ------------------------------------------------------

int
is_cgb(self)
    SV *self
    CODE:
        RETVAL = GB_is_cgb(&sb_from_sv(aTHX_ self)->gb) ? 1 : 0;
    OUTPUT:
        RETVAL

int
is_sgb(self)
    SV *self
    CODE:
        RETVAL = GB_is_sgb(&sb_from_sv(aTHX_ self)->gb) ? 1 : 0;
    OUTPUT:
        RETVAL

SV *
rom_title(self)
    SV *self
    CODE:
    {
        char title[17];
        memset(title, 0, sizeof(title));
        GB_get_rom_title(&sb_from_sv(aTHX_ self)->gb, title);
        RETVAL = newSVpv(title, 0);
    }
    OUTPUT:
        RETVAL

UV
rom_crc32(self)
    SV *self
    CODE:
        RETVAL = (UV)GB_get_rom_crc32(&sb_from_sv(aTHX_ self)->gb);
    OUTPUT:
        RETVAL

# ---- screen -------------------------------------------------------------

void
dimensions(self)
    SV *self
    PPCODE:
    {
        sb_t *s = sb_from_sv(aTHX_ self);
        EXTEND(SP, 2);
        mPUSHu(GB_get_screen_width(&s->gb));
        mPUSHu(GB_get_screen_height(&s->gb));
    }

SV *
pixels(self)
    SV *self
    CODE:
    {
        sb_t    *s = sb_from_sv(aTHX_ self);
        unsigned w = GB_get_screen_width(&s->gb);
        unsigned h = GB_get_screen_height(&s->gb);
        RETVAL = newSVpvn((const char *)s->fb,
                          (STRLEN)w * h * sizeof(uint32_t));
    }
    OUTPUT:
        RETVAL

# Canvas-ready pixels: tightly packed R,G,B,A (A=255) bytes, w*h*4 of them,
# suitable for a JS ImageData buffer.
SV *
pixels_rgba(self)
    SV *self
    CODE:
    {
        sb_t          *s = sb_from_sv(aTHX_ self);
        unsigned       w = GB_get_screen_width(&s->gb);
        unsigned       h = GB_get_screen_height(&s->gb);
        STRLEN         n = (STRLEN)w * h;
        STRLEN         i;
        unsigned char *out;
        RETVAL = newSV(n * 4 + 1);
        SvPOK_on(RETVAL);
        SvCUR_set(RETVAL, n * 4);
        out = (unsigned char *)SvPVX(RETVAL);
        for (i = 0; i < n; i++) {
            uint32_t px = s->fb[i];        /* 0x00RRGGBB */
            out[i*4+0] = (px >> 16) & 0xFF;
            out[i*4+1] = (px >> 8)  & 0xFF;
            out[i*4+2] =  px        & 0xFF;
            out[i*4+3] = 0xFF;
        }
        SvPVX(RETVAL)[n * 4] = '\0';
    }
    OUTPUT:
        RETVAL

SV *
set_color_correction(self, mode)
    SV         *self
    const char *mode
    CODE:
        GB_set_color_correction_mode(&sb_from_sv(aTHX_ self)->gb,
            (GB_color_correction_mode_t)sb_color_correction(aTHX_ mode));
        RETVAL = SvREFCNT_inc(self);
    OUTPUT:
        RETVAL



( run in 1.207 second using v1.01-cache-2.11-cpan-4e7a2411597 )