Skip to content

Commit

Permalink
fix retroarch core running too fast under certain conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
joyrider3774 committed Jul 31, 2024
1 parent 49e6303 commit 218019a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions runtimes/native/src/backend/main_libretro.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -31,7 +32,7 @@ static int16_t audio_output[2*AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME];
static w4_Disk disk = { 0 };

static int hold_in_start_value = 10;

static uint32_t destframe[160*160];
#if !defined(PSP) && !defined(PS2)
static void audio_set_state (bool enable) {
}
Expand Down Expand Up @@ -479,15 +480,20 @@ void retro_run () {
w4_runtimeSetMouse(80+80*mouseX/0x7fff, 80+80*mouseY/0x7fff, mouseButtons);

w4_runtimeUpdate();


if (pixel_format == RETRO_PIXEL_FORMAT_RGB565)
video_cb(destframe, 160, 160, 160*sizeof(uint16_t));
else
video_cb(destframe, 160, 160, 160*sizeof(uint32_t));

if (!use_audio_callback) {
w4_apuWriteSamples(audio_output, AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME);
audio_batch_cb(audio_output, AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME);
}
}

#define do_composite(type, palette) { \
type* out = (type *)dest; \
type* out = (type *)destframe; \
for (int n = 0; n < 160*160/4; ++n) { \
uint8_t quartet = framebuffer[n]; \
int color1 = (quartet & 0x03) >> 0; \
Expand All @@ -500,7 +506,6 @@ void retro_run () {
*out++ = palette[color3]; \
*out++ = palette[color4]; \
} \
video_cb(dest, 160, 160, 160*sizeof(type)); \
}

void w4_windowComposite (const uint32_t* palette, const uint8_t* framebuffer) {
Expand All @@ -524,7 +529,7 @@ void w4_windowComposite (const uint32_t* palette, const uint8_t* framebuffer) {
// dest = local;
// }

static uint32_t dest[160*160];


// Convert indexed 2bpp framebuffer to XRGB output
if (pixel_format == RETRO_PIXEL_FORMAT_RGB565) {
Expand Down

0 comments on commit 218019a

Please sign in to comment.