New turbo related APIs, Quick Look no longer requires GB_INTERNAL
This commit is contained in:
parent
a925ef130d
commit
3feaeb153e
@ -172,7 +172,7 @@
|
|||||||
handled = true;
|
handled = true;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case GBTurbo:
|
case GBTurbo:
|
||||||
GB_set_turbo_mode(_gb, true);
|
GB_set_turbo_mode(_gb, true, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -198,7 +198,7 @@
|
|||||||
handled = true;
|
handled = true;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case GBTurbo:
|
case GBTurbo:
|
||||||
GB_set_turbo_mode(_gb, false);
|
GB_set_turbo_mode(_gb, false, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -54,6 +54,7 @@ typedef struct
|
|||||||
GB_apu_channel_t wave_channels[4];
|
GB_apu_channel_t wave_channels[4];
|
||||||
} GB_apu_t;
|
} GB_apu_t;
|
||||||
|
|
||||||
|
void GB_set_sample_rate(GB_gameboy_t *gb, unsigned int sample_rate);
|
||||||
void GB_apu_copy_buffer(GB_gameboy_t *gb, GB_sample_t *dest, unsigned int count);
|
void GB_apu_copy_buffer(GB_gameboy_t *gb, GB_sample_t *dest, unsigned int count);
|
||||||
|
|
||||||
#ifdef GB_INTERNAL
|
#ifdef GB_INTERNAL
|
||||||
|
@ -239,29 +239,10 @@ void display_vblank(GB_gameboy_t *gb)
|
|||||||
}
|
}
|
||||||
gb->last_vblank = nanoseconds;
|
gb->last_vblank = nanoseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (!gb->disable_rendering && (!(gb->io_registers[GB_IO_LCDC] & 0x80) || gb->stopped)) {
|
||||||
static long start = 0;
|
|
||||||
static long last = 0;
|
|
||||||
static long frames = 0;
|
|
||||||
|
|
||||||
if (last == 0) {
|
|
||||||
last = time(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (last != time(NULL)) {
|
|
||||||
last = time(NULL);
|
|
||||||
if (start == 0) {
|
|
||||||
start = last;
|
|
||||||
frames = 0;
|
|
||||||
}
|
|
||||||
printf("Average FPS: %f\n", frames / (double)(last - start));
|
|
||||||
}
|
|
||||||
frames++;
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!(gb->io_registers[GB_IO_LCDC] & 0x80) || gb->stopped) {
|
|
||||||
/* LCD is off, memset screen to white */
|
/* LCD is off, memset screen to white */
|
||||||
|
/* Todo: use RGB callback */
|
||||||
memset(gb->screen, 0xFF, WIDTH * LINES * 4);
|
memset(gb->screen, 0xFF, WIDTH * LINES * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,9 +540,15 @@ bool GB_is_inited(GB_gameboy_t *gb)
|
|||||||
return gb->magic == 'SAME';
|
return gb->magic == 'SAME';
|
||||||
}
|
}
|
||||||
|
|
||||||
void GB_set_turbo_mode(GB_gameboy_t *gb, bool on)
|
void GB_set_turbo_mode(GB_gameboy_t *gb, bool on, bool no_frame_skip)
|
||||||
{
|
{
|
||||||
gb->turbo = on;
|
gb->turbo = on;
|
||||||
|
gb->turbo_dont_skip = no_frame_skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GB_set_rendering_disabled(GB_gameboy_t *gb, bool disabled)
|
||||||
|
{
|
||||||
|
gb->disable_rendering = disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *GB_get_user_data(GB_gameboy_t *gb)
|
void *GB_get_user_data(GB_gameboy_t *gb)
|
||||||
|
37
Core/gb.h
37
Core/gb.h
@ -480,28 +480,41 @@ __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
|
|||||||
|
|
||||||
void GB_init(GB_gameboy_t *gb);
|
void GB_init(GB_gameboy_t *gb);
|
||||||
void GB_init_cgb(GB_gameboy_t *gb);
|
void GB_init_cgb(GB_gameboy_t *gb);
|
||||||
|
bool GB_is_inited(GB_gameboy_t *gb);
|
||||||
void GB_free(GB_gameboy_t *gb);
|
void GB_free(GB_gameboy_t *gb);
|
||||||
void GB_reset(GB_gameboy_t *gb);
|
void GB_reset(GB_gameboy_t *gb);
|
||||||
void GB_switch_model_and_reset(GB_gameboy_t *gb, bool is_cgb);
|
void GB_switch_model_and_reset(GB_gameboy_t *gb, bool is_cgb);
|
||||||
|
void GB_run(GB_gameboy_t *gb);
|
||||||
|
|
||||||
|
void *GB_get_user_data(GB_gameboy_t *gb);
|
||||||
|
void GB_set_user_data(GB_gameboy_t *gb, void *data);
|
||||||
|
|
||||||
int GB_load_boot_rom(GB_gameboy_t *gb, const char *path);
|
int GB_load_boot_rom(GB_gameboy_t *gb, const char *path);
|
||||||
int GB_load_rom(GB_gameboy_t *gb, const char *path);
|
int GB_load_rom(GB_gameboy_t *gb, const char *path);
|
||||||
|
|
||||||
int GB_save_battery(GB_gameboy_t *gb, const char *path);
|
int GB_save_battery(GB_gameboy_t *gb, const char *path);
|
||||||
void GB_load_battery(GB_gameboy_t *gb, const char *path);
|
void GB_load_battery(GB_gameboy_t *gb, const char *path);
|
||||||
|
|
||||||
int GB_save_state(GB_gameboy_t *gb, const char *path);
|
int GB_save_state(GB_gameboy_t *gb, const char *path);
|
||||||
int GB_load_state(GB_gameboy_t *gb, const char *path);
|
int GB_load_state(GB_gameboy_t *gb, const char *path);
|
||||||
void GB_run(GB_gameboy_t *gb);
|
|
||||||
void GB_set_pixels_output(GB_gameboy_t *gb, uint32_t *output);
|
void GB_set_turbo_mode(GB_gameboy_t *gb, bool on, bool no_frame_skip);
|
||||||
void GB_set_vblank_callback(GB_gameboy_t *gb, GB_vblank_callback_t callback);
|
void GB_set_rendering_disabled(GB_gameboy_t *gb, bool disabled);
|
||||||
void GB_set_log_callback(GB_gameboy_t *gb, GB_log_callback_t callback);
|
|
||||||
void GB_log(GB_gameboy_t *gb, const char *fmt, ...) __printflike(2, 3);
|
void GB_log(GB_gameboy_t *gb, const char *fmt, ...) __printflike(2, 3);
|
||||||
void GB_attributed_log(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, ...) __printflike(3, 4);
|
void GB_attributed_log(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, ...) __printflike(3, 4);
|
||||||
void GB_set_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback);
|
|
||||||
void GB_set_async_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback);
|
void GB_set_pixels_output(GB_gameboy_t *gb, uint32_t *output);
|
||||||
void GB_set_sample_rate(GB_gameboy_t *gb, unsigned int sample_rate);
|
|
||||||
void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callback);
|
|
||||||
void GB_set_infrared_callback(GB_gameboy_t *gb, GB_infrared_callback_t callback);
|
|
||||||
void GB_set_infrared_input(GB_gameboy_t *gb, bool state);
|
void GB_set_infrared_input(GB_gameboy_t *gb, bool state);
|
||||||
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, long cycles_after_previous_change);
|
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, long cycles_after_previous_change);
|
||||||
|
|
||||||
|
void GB_set_vblank_callback(GB_gameboy_t *gb, GB_vblank_callback_t callback);
|
||||||
|
void GB_set_log_callback(GB_gameboy_t *gb, GB_log_callback_t callback);
|
||||||
|
void GB_set_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback);
|
||||||
|
void GB_set_async_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback);
|
||||||
|
void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callback);
|
||||||
|
void GB_set_infrared_callback(GB_gameboy_t *gb, GB_infrared_callback_t callback);
|
||||||
void GB_set_rumble_callback(GB_gameboy_t *gb, GB_rumble_callback_t callback);
|
void GB_set_rumble_callback(GB_gameboy_t *gb, GB_rumble_callback_t callback);
|
||||||
|
|
||||||
/* These APIs are used when using internal clock */
|
/* These APIs are used when using internal clock */
|
||||||
@ -511,11 +524,7 @@ void GB_set_serial_transfer_end_callback(GB_gameboy_t *gb, GB_serial_transfer_en
|
|||||||
/* These APIs are used when using external clock */
|
/* These APIs are used when using external clock */
|
||||||
uint8_t GB_serial_get_data(GB_gameboy_t *gb);
|
uint8_t GB_serial_get_data(GB_gameboy_t *gb);
|
||||||
void GB_serial_set_data(GB_gameboy_t *gb, uint8_t data);
|
void GB_serial_set_data(GB_gameboy_t *gb, uint8_t data);
|
||||||
|
|
||||||
void GB_disconnect_serial(GB_gameboy_t *gb);
|
void GB_disconnect_serial(GB_gameboy_t *gb);
|
||||||
|
|
||||||
bool GB_is_inited(GB_gameboy_t *gb);
|
|
||||||
void GB_set_turbo_mode(GB_gameboy_t *gb, bool on);
|
|
||||||
void *GB_get_user_data(GB_gameboy_t *gb);
|
|
||||||
void GB_set_user_data(GB_gameboy_t *gb, void *data);
|
|
||||||
#endif /* GB_h */
|
#endif /* GB_h */
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#define GB_INTERNAL // Todo: This file runs SameBoy in a special configuration
|
|
||||||
// of the turbo mode, which is not available without direct
|
|
||||||
// struct access
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -36,7 +33,7 @@ static void vblank(GB_gameboy_t *gb)
|
|||||||
local_data->running = false;
|
local_data->running = false;
|
||||||
}
|
}
|
||||||
else if (local_data->frames == LENGTH - 1) {
|
else if (local_data->frames == LENGTH - 1) {
|
||||||
gb->disable_rendering = false;
|
GB_set_rendering_disabled(gb, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
local_data->frames++;
|
local_data->frames++;
|
||||||
@ -72,13 +69,16 @@ int get_image_for_rom(const char *filename, const char *boot_path, uint32_t *out
|
|||||||
GB_set_user_data(&gb, &local_data);
|
GB_set_user_data(&gb, &local_data);
|
||||||
local_data.running = true;
|
local_data.running = true;
|
||||||
local_data.frames = 0;
|
local_data.frames = 0;
|
||||||
gb.turbo = gb.turbo_dont_skip = gb.disable_rendering = true;
|
GB_set_rendering_disabled(&gb, true);
|
||||||
|
GB_set_turbo_mode(&gb, true, true);
|
||||||
|
|
||||||
|
*cgb_flag = GB_read_memory(&gb, 0x143) & 0xC0;
|
||||||
|
|
||||||
|
|
||||||
while (local_data.running) {
|
while (local_data.running) {
|
||||||
GB_run(&gb);
|
GB_run(&gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
*cgb_flag = gb.rom[0x143] & 0xC0;
|
|
||||||
|
|
||||||
GB_free(&gb);
|
GB_free(&gb);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -63,7 +63,7 @@ static void GB_update_keys_status(GB_gameboy_t *gb)
|
|||||||
GB_set_key_state(gb, GB_KEY_START, event.type == SDL_KEYDOWN);
|
GB_set_key_state(gb, GB_KEY_START, event.type == SDL_KEYDOWN);
|
||||||
break;
|
break;
|
||||||
case SDLK_SPACE:
|
case SDLK_SPACE:
|
||||||
GB_set_turbo_mode(gb, event.type == SDL_KEYDOWN);
|
GB_set_turbo_mode(gb, event.type == SDL_KEYDOWN, false);
|
||||||
break;
|
break;
|
||||||
case SDLK_LCTRL:
|
case SDLK_LCTRL:
|
||||||
case SDLK_RCTRL:
|
case SDLK_RCTRL:
|
||||||
|
Loading…
Reference in New Issue
Block a user