Merge pull request #14 from libretro/master

libretro core
This commit is contained in:
Lior Halphon 2017-10-12 18:29:26 +03:00 committed by GitHub
commit 9615ca6fa6
16 changed files with 3076 additions and 6 deletions

View File

@ -5,10 +5,11 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/time.h>
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h>
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#include <unistd.h>
#include "gb.h" #include "gb.h"
void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, va_list args) void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, va_list args)
@ -48,11 +49,13 @@ static char *default_input_callback(GB_gameboy_t *gb)
char *expression = NULL; char *expression = NULL;
size_t size = 0; size_t size = 0;
#ifndef __LIBRETRO__
if (getline(&expression, &size, stdin) == -1) { if (getline(&expression, &size, stdin) == -1) {
/* The user doesn't have STDIN or used ^D. We make sure the program keeps running. */ /* The user doesn't have STDIN or used ^D. We make sure the program keeps running. */
GB_set_async_input_callback(gb, NULL); /* Disable async input */ GB_set_async_input_callback(gb, NULL); /* Disable async input */
return strdup("c"); return strdup("c");
} }
#endif
if (!expression) { if (!expression) {
return strdup(""); return strdup("");
@ -146,6 +149,25 @@ void GB_free(GB_gameboy_t *gb)
memset(gb, 0, sizeof(*gb)); memset(gb, 0, sizeof(*gb));
} }
#ifdef __LIBRETRO__
#include "../libretro/cgb_boot.h"
#include "../libretro/dmg_boot.h"
int GB_load_boot_rom_dmg(GB_gameboy_t *gb)
{
memset(gb->boot_rom, 0xFF, sizeof(gb->boot_rom));
memcpy(gb->boot_rom, dmg_boot, dmg_boot_length);
return 0;
}
int GB_load_boot_rom_cgb(GB_gameboy_t *gb)
{
memset(gb->boot_rom, 0xFF, sizeof(gb->boot_rom));
memcpy(gb->boot_rom, cgb_boot, cgb_boot_length);
return 0;
}
#endif
int GB_load_boot_rom(GB_gameboy_t *gb, const char *path) int GB_load_boot_rom(GB_gameboy_t *gb, const char *path)
{ {
FILE *f = fopen(path, "rb"); FILE *f = fopen(path, "rb");
@ -258,12 +280,16 @@ exit:
void GB_run(GB_gameboy_t *gb) void GB_run(GB_gameboy_t *gb)
{ {
#ifdef HAVE_DEBUGGER
GB_debugger_run(gb); GB_debugger_run(gb);
#endif
GB_cpu_run(gb); GB_cpu_run(gb);
if (gb->vblank_just_occured) { if (gb->vblank_just_occured) {
GB_update_joyp(gb); GB_update_joyp(gb);
GB_rtc_run(gb); GB_rtc_run(gb);
#ifdef HAVE_DEBUGGER
GB_debugger_handle_async_commands(gb); GB_debugger_handle_async_commands(gb);
#endif
} }
} }

View File

@ -14,7 +14,7 @@
#include "display.h" #include "display.h"
#include "joypad.h" #include "joypad.h"
#include "mbc.h" #include "mbc.h"
#include "memory.h" #include "gbmemory.h"
#include "printer.h" #include "printer.h"
#include "timing.h" #include "timing.h"
#include "z80_cpu.h" #include "z80_cpu.h"
@ -530,6 +530,11 @@ void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t *
void *GB_get_user_data(GB_gameboy_t *gb); void *GB_get_user_data(GB_gameboy_t *gb);
void GB_set_user_data(GB_gameboy_t *gb, void *data); void GB_set_user_data(GB_gameboy_t *gb, void *data);
#ifdef __LIBRETRO__
int GB_load_boot_rom_dmg(GB_gameboy_t *gb);
int GB_load_boot_rom_cgb(GB_gameboy_t *gb);
#endif
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);

View File

@ -266,9 +266,10 @@ static GB_read_function_t * const read_map[] =
uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr) uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr)
{ {
if (gb->n_watchpoints) { #ifdef HAVE_DEBUGGER
if (gb->n_watchpoints)
GB_debugger_test_read_watchpoint(gb, addr); GB_debugger_test_read_watchpoint(gb, addr);
} #endif
if (is_addr_in_dma_use(gb, addr)) { if (is_addr_in_dma_use(gb, addr)) {
addr = gb->dma_current_src; addr = gb->dma_current_src;
} }
@ -678,9 +679,10 @@ static GB_write_function_t * const write_map[] =
void GB_write_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) void GB_write_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
{ {
if (gb->n_watchpoints) { #ifdef HAVE_DEBUGGER
if (gb->n_watchpoints)
GB_debugger_test_write_watchpoint(gb, addr, value); GB_debugger_test_write_watchpoint(gb, addr, value);
} #endif
if (is_addr_in_dma_use(gb, addr)) { if (is_addr_in_dma_use(gb, addr)) {
/* Todo: What should happen? Will this affect DMA? Will data be written? What and where? */ /* Todo: What should happen? Will this affect DMA? Will data be written? What and where? */
return; return;

View File

@ -19,6 +19,7 @@ static int64_t get_nanoseconds(void)
#endif #endif
} }
#ifndef __LIBRETRO__
static void nsleep(uint64_t nanoseconds) static void nsleep(uint64_t nanoseconds)
{ {
#ifndef _WIN32 #ifndef _WIN32
@ -34,6 +35,7 @@ static void nsleep(uint64_t nanoseconds)
CloseHandle(timer); CloseHandle(timer);
#endif #endif
} }
#endif
bool GB_timing_sync_turbo(GB_gameboy_t *gb) bool GB_timing_sync_turbo(GB_gameboy_t *gb)
{ {
@ -59,7 +61,9 @@ void GB_timing_sync(GB_gameboy_t *gb)
uint64_t target_nanoseconds = gb->cycles_since_last_sync * FRAME_LENGTH / LCDC_PERIOD; uint64_t target_nanoseconds = gb->cycles_since_last_sync * FRAME_LENGTH / LCDC_PERIOD;
int64_t nanoseconds = get_nanoseconds(); int64_t nanoseconds = get_nanoseconds();
if (labs((signed long)(nanoseconds - gb->last_sync)) < target_nanoseconds ) { if (labs((signed long)(nanoseconds - gb->last_sync)) < target_nanoseconds ) {
#ifndef __LIBRETRO__
nsleep(target_nanoseconds + gb->last_sync - nanoseconds); nsleep(target_nanoseconds + gb->last_sync - nanoseconds);
#endif
gb->last_sync += target_nanoseconds; gb->last_sync += target_nanoseconds;
} }
else { else {

View File

@ -701,7 +701,9 @@ static void ret_cc(GB_gameboy_t *gb, uint8_t opcode)
{ {
/* Todo: Verify timing */ /* Todo: Verify timing */
if (condition_code(gb, opcode)) { if (condition_code(gb, opcode)) {
#ifdef HAVE_DEBUGGER
GB_debugger_ret_hook(gb); GB_debugger_ret_hook(gb);
#endif
GB_advance_cycles(gb, 8); GB_advance_cycles(gb, 8);
gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]); gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
@ -769,7 +771,9 @@ static void call_cc_a16(GB_gameboy_t *gb, uint8_t opcode)
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = addr; gb->pc = addr;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
else { else {
GB_advance_cycles(gb, 12); GB_advance_cycles(gb, 12);
@ -938,12 +942,16 @@ static void rst(GB_gameboy_t *gb, uint8_t opcode)
GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF); GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = opcode ^ 0xC7; gb->pc = opcode ^ 0xC7;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
static void ret(GB_gameboy_t *gb, uint8_t opcode) static void ret(GB_gameboy_t *gb, uint8_t opcode)
{ {
#ifdef HAVE_DEBUGGER
GB_debugger_ret_hook(gb); GB_debugger_ret_hook(gb);
#endif
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]); gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
@ -972,7 +980,9 @@ static void call_a16(GB_gameboy_t *gb, uint8_t opcode)
GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF); GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = addr; gb->pc = addr;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
static void ld_da8_a(GB_gameboy_t *gb, uint8_t opcode) static void ld_da8_a(GB_gameboy_t *gb, uint8_t opcode)
@ -1388,7 +1398,9 @@ void GB_cpu_run(GB_gameboy_t *gb)
gb->pc = 0; gb->pc = 0;
} }
gb->ime = false; gb->ime = false;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
else if(!gb->halted && !gb->stopped) { else if(!gb->halted && !gb->stopped) {
uint8_t opcode = GB_read_memory(gb, gb->pc++); uint8_t opcode = GB_read_memory(gb, gb->pc++);

23
Makefile.common Normal file
View File

@ -0,0 +1,23 @@
INCFLAGS := -I$(CORE_DIR) \
-I$(CORE_DIR)/Core
SOURCES_C := $(CORE_DIR)/Core/gb.c \
$(CORE_DIR)/Core/apu.c \
$(CORE_DIR)/Core/gbmemory.c \
$(CORE_DIR)/Core/mbc.c \
$(CORE_DIR)/Core/timing.c \
$(CORE_DIR)/Core/display.c \
$(CORE_DIR)/Core/symbol_hash.c \
$(CORE_DIR)/Core/camera.c \
$(CORE_DIR)/Core/z80_cpu.c \
$(CORE_DIR)/Core/joypad.c \
$(CORE_DIR)/Core/save_state.c \
$(CORE_DIR)/libretro/libretro.c
ifeq ($(HAVE_DEBUGGER), 1)
SOURCES_C += $(CORE_DIR)/Core/debugger.c \
$(CORE_DIR)/Core/z80_disassembler.c
endif
SOURCES_CXX :=

150
Makefile.libretro Normal file
View File

@ -0,0 +1,150 @@
STATIC_LINKING := 0
AR := ar
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring win,$(shell uname -a)),)
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
ifeq ($(platform), win)
INCFLAGS += -I Windows
endif
CORE_DIR += .
TARGET_NAME = sameboy
LIBM = -lm
ifeq ($(ARCHFLAGS),)
ifeq ($(archs),ppc)
ARCHFLAGS = -arch ppc -arch ppc64
else
ARCHFLAGS = -arch i386 -arch x86_64
endif
endif
ifeq ($(platform), osx)
ifndef ($(NOUNIVERSAL))
CXXFLAGS += $(ARCHFLAGS)
LFLAGS += $(ARCHFLAGS)
endif
endif
ifeq ($(STATIC_LINKING), 1)
EXT := a
endif
ifeq ($(platform), unix)
EXT ?= so
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
else ifeq ($(platform), linux-portable)
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC -nostdlib
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T
LIBM :=
else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
else ifneq (,$(findstring ios,$(platform)))
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
DEFINES := -DIOS
ifeq ($(platform),ios-arm64)
CC = cc -arch armv64 -isysroot $(IOSSDK)
else
CC = cc -arch armv7 -isysroot $(IOSSDK)
endif
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
CC += -miphoneos-version-min=8.0
CXXFLAGS += -miphoneos-version-min=8.0
else
CC += -miphoneos-version-min=5.0
CXXFLAGS += -miphoneos-version-min=5.0
endif
else ifneq (,$(findstring qnx,$(platform)))
TARGET := $(TARGET_NAME)_libretro_qnx.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
fpic := -fPIC
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_vita.a
CC = arm-vita-eabi-gcc
AR = arm-vita-eabi-ar
CFLAGS += -Wl,-q -Wall -O3 -fno-short-enums -fno-optimize-sibling-calls
STATIC_LINKING = 1
else
CC = gcc
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
endif
LDFLAGS += $(LIBM)
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g
else
CXXFLAGS += -O2 -DNDEBUG
endif
include Makefile.common
OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
CFLAGS += -Wall -D__LIBRETRO__ $(fpic) $(INCFLAGS) -std=gnu11 -D_GNU_SOURCE -D_USE_MATH_DEFINES
CXXFLAGS += -Wall -D__LIBRETRO__ $(fpic)
all: $(TARGET)
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
$(CC) $(fpic) $(SHARED) $(INCFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
endif
Core/%.o: Core/%.c
$(CC) -c -o $@ $< $(CFLAGS) $(fpic) -DGB_INTERNAL
%.o: %.c
$(CC) $(CFLAGS) $(fpic) -c -o $@ $<
clean:
rm -f $(OBJECTS) $(TARGET)
.PHONY: clean

View File

@ -2,6 +2,7 @@
#include_next <stdio.h> #include_next <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef __LIBRETRO__
static inline int vasprintf(char **str, const char *fmt, va_list args) static inline int vasprintf(char **str, const char *fmt, va_list args)
{ {
size_t size = _vscprintf(fmt, args) + 1; size_t size = _vscprintf(fmt, args) + 1;
@ -14,6 +15,7 @@ static inline int vasprintf(char **str, const char *fmt, va_list args)
} }
return ret; return ret;
} }
#endif
/* This code is public domain -- Will Hartung 4/9/09 */ /* This code is public domain -- Will Hartung 4/9/09 */
static inline size_t getline(char **lineptr, size_t *n, FILE *stream) { static inline size_t getline(char **lineptr, size_t *n, FILE *stream) {

214
libretro/cgb_boot.h Normal file
View File

@ -0,0 +1,214 @@
const char cgb_boot[2305] = {
0x31, 0xfe, 0xff, 0xaf, 0xea, 0x40, 0xc0, 0x21, 0x00, 0x80, 0xcd,
0x60, 0x06, 0x26, 0xd0, 0xcd, 0x60, 0x06, 0x21, 0x00, 0xfe, 0x0e,
0xa0, 0xaf, 0x22, 0x0d, 0x20, 0xfc, 0x3e, 0x80, 0xe0, 0x26, 0xe0,
0x11, 0x3e, 0xf3, 0xe0, 0x12, 0xe0, 0x25, 0x3e, 0x77, 0xe0, 0x24,
0x21, 0x30, 0xff, 0xaf, 0x0e, 0x10, 0x22, 0x2f, 0x0d, 0x20, 0xfb,
0x3e, 0xfc, 0xe0, 0x47, 0x11, 0x04, 0x01, 0x21, 0x10, 0x80, 0x1a,
0x47, 0xcd, 0x2e, 0x06, 0xcd, 0x2e, 0x06, 0x13, 0x7b, 0xee, 0x34,
0x20, 0xf2, 0xcd, 0xa1, 0x06, 0x3e, 0x01, 0xe0, 0x4f, 0xaf, 0x21,
0x00, 0x80, 0xcd, 0x60, 0x06, 0x11, 0x96, 0x04, 0x21, 0x80, 0x80,
0x0e, 0xc0, 0x1a, 0x22, 0x23, 0x13, 0x1a, 0x22, 0x23, 0x13, 0x0d,
0x20, 0xf5, 0x11, 0x04, 0x01, 0x0e, 0x06, 0xc5, 0xcd, 0x92, 0x06,
0xc1, 0x0d, 0x20, 0xf8, 0x23, 0xcd, 0xa1, 0x06, 0x21, 0xc2, 0x98,
0x06, 0x03, 0x3e, 0x08, 0x0e, 0x10, 0x77, 0xf5, 0x3e, 0x01, 0xe0,
0x4f, 0x3e, 0x08, 0x77, 0xaf, 0xe0, 0x4f, 0xf1, 0x22, 0x3c, 0x0d,
0x20, 0xee, 0x11, 0x10, 0x00, 0x19, 0x05, 0x20, 0xe5, 0xfe, 0x38,
0x20, 0x09, 0x21, 0xa7, 0x99, 0x06, 0x01, 0x0e, 0x07, 0x18, 0xda,
0x11, 0x16, 0x06, 0x0e, 0x08, 0x21, 0x00, 0xc0, 0xaf, 0x2f, 0x22,
0x22, 0x1a, 0x13, 0x22, 0x1a, 0x13, 0x22, 0xaf, 0x22, 0x22, 0x22,
0x22, 0x0d, 0x20, 0xef, 0x21, 0x00, 0xc0, 0x16, 0x40, 0x1e, 0x00,
0xcd, 0xb2, 0x06, 0x3e, 0x91, 0xe0, 0x40, 0xcd, 0xdd, 0x06, 0x06,
0x2d, 0xcd, 0x4f, 0x06, 0x3e, 0x83, 0xcd, 0x59, 0x06, 0x06, 0x05,
0xcd, 0x4f, 0x06, 0x3e, 0xc1, 0xcd, 0x59, 0x06, 0x06, 0x1e, 0xcd,
0x4f, 0x06, 0xcd, 0xef, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x16, 0x36, 0xd1,
0xdb, 0xf2, 0x3c, 0x8c, 0x92, 0x3d, 0x5c, 0x58, 0xc9, 0x3e, 0x70,
0x1d, 0x59, 0x69, 0x19, 0x35, 0xa8, 0x14, 0xaa, 0x75, 0x95, 0x99,
0x34, 0x6f, 0x15, 0xff, 0x97, 0x4b, 0x90, 0x17, 0x10, 0x39, 0xf7,
0xf6, 0xa2, 0x49, 0x4e, 0xc3, 0x68, 0xe0, 0x8b, 0xf0, 0xce, 0x0c,
0x29, 0xe8, 0xb7, 0x86, 0x9a, 0x52, 0x01, 0x9d, 0x71, 0x9c, 0xbd,
0x5d, 0x6d, 0x67, 0x3f, 0x6b, 0xb3, 0x46, 0x28, 0xa5, 0xc6, 0xd3,
0x27, 0x61, 0x18, 0x66, 0x6a, 0xbf, 0x0d, 0xf4, 0xb3, 0x46, 0x28,
0xa5, 0xc6, 0xd3, 0x27, 0x61, 0x18, 0x66, 0x6a, 0xbf, 0x0d, 0xf4,
0xb3, 0x00, 0x04, 0x05, 0x23, 0x22, 0x03, 0x1f, 0x0f, 0x0a, 0x05,
0x13, 0x24, 0x87, 0x25, 0x1e, 0x2c, 0x15, 0x20, 0x1f, 0x14, 0x05,
0x21, 0x0d, 0x0e, 0x05, 0x1d, 0x05, 0x12, 0x09, 0x03, 0x02, 0x1a,
0x19, 0x19, 0x29, 0x2a, 0x1a, 0x2d, 0x2a, 0x2d, 0x24, 0x26, 0x1a,
0x2a, 0x1e, 0x29, 0x22, 0x22, 0x05, 0x2a, 0x06, 0x05, 0x21, 0x19,
0x2a, 0x2a, 0x28, 0x02, 0x10, 0x19, 0x2a, 0x2a, 0x05, 0x00, 0x27,
0x24, 0x16, 0x19, 0x06, 0x20, 0x0c, 0x24, 0x0b, 0x27, 0x12, 0x27,
0x18, 0x1f, 0x32, 0x11, 0x2e, 0x06, 0x1b, 0x00, 0x2f, 0x29, 0x29,
0x00, 0x00, 0x13, 0x22, 0x17, 0x12, 0x1d, 0x42, 0x45, 0x46, 0x41,
0x41, 0x52, 0x42, 0x45, 0x4b, 0x45, 0x4b, 0x20, 0x52, 0x2d, 0x55,
0x52, 0x41, 0x52, 0x20, 0x49, 0x4e, 0x41, 0x49, 0x4c, 0x49, 0x43,
0x45, 0x20, 0x52, 0x20, 0x20, 0xe8, 0x90, 0x90, 0x90, 0xa0, 0xa0,
0xa0, 0xc0, 0xc0, 0xc0, 0x48, 0x48, 0x48, 0x00, 0x00, 0x00, 0xd8,
0xd8, 0xd8, 0x28, 0x28, 0x28, 0x60, 0x60, 0x60, 0xd0, 0xd0, 0xd0,
0x80, 0x40, 0x40, 0x20, 0xe0, 0xe0, 0x20, 0x10, 0x10, 0x18, 0x20,
0x20, 0x20, 0xe8, 0xe8, 0xe0, 0x20, 0xe0, 0x10, 0x88, 0x10, 0x80,
0x80, 0x40, 0x20, 0x20, 0x38, 0x20, 0x20, 0x90, 0x20, 0x20, 0xa0,
0x98, 0x98, 0x48, 0x18, 0x18, 0x58, 0x88, 0x88, 0x10, 0x20, 0x20,
0x10, 0x20, 0x20, 0x18, 0xe0, 0xe0, 0x00, 0x18, 0x18, 0x00, 0x00,
0x00, 0x08, 0x90, 0xb0, 0x90, 0xa0, 0xb0, 0xa0, 0xc0, 0xb0, 0xc0,
0x80, 0xb0, 0x40, 0x88, 0x20, 0x68, 0xd8, 0x00, 0x70, 0xd8, 0x20,
0x78, 0x98, 0xb0, 0x48, 0x80, 0xe0, 0x50, 0x20, 0xb8, 0xe0, 0x88,
0xb0, 0x10, 0x20, 0x00, 0x10, 0x20, 0xe0, 0x18, 0xe0, 0x18, 0x00,
0x18, 0xe0, 0x20, 0xa8, 0xe0, 0x20, 0x18, 0xe0, 0x00, 0xc8, 0x18,
0xe0, 0x00, 0xe0, 0x40, 0x20, 0x18, 0xe0, 0xe0, 0x18, 0x30, 0x20,
0xe0, 0xe8, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0xf8, 0xe0, 0x20, 0x08,
0x00, 0x00, 0x10, 0xff, 0x7f, 0xbf, 0x32, 0xd0, 0x00, 0x00, 0x00,
0x9f, 0x63, 0x79, 0x42, 0xb0, 0x15, 0xcb, 0x04, 0xff, 0x7f, 0x31,
0x6e, 0x4a, 0x45, 0x00, 0x00, 0xff, 0x7f, 0xef, 0x1b, 0x00, 0x02,
0x00, 0x00, 0xff, 0x7f, 0x1f, 0x42, 0xf2, 0x1c, 0x00, 0x00, 0xff,
0x7f, 0x94, 0x52, 0x4a, 0x29, 0x00, 0x00, 0xff, 0x7f, 0xff, 0x03,
0x2f, 0x01, 0x00, 0x00, 0xff, 0x7f, 0xef, 0x03, 0xd6, 0x01, 0x00,
0x00, 0xff, 0x7f, 0xb5, 0x42, 0xc8, 0x3d, 0x00, 0x00, 0x74, 0x7e,
0xff, 0x03, 0x80, 0x01, 0x00, 0x00, 0xff, 0x67, 0xac, 0x77, 0x13,
0x1a, 0x6b, 0x2d, 0xd6, 0x7e, 0xff, 0x4b, 0x75, 0x21, 0x00, 0x00,
0xff, 0x53, 0x5f, 0x4a, 0x52, 0x7e, 0x00, 0x00, 0xff, 0x4f, 0xd2,
0x7e, 0x4c, 0x3a, 0xe0, 0x1c, 0xed, 0x03, 0xff, 0x7f, 0x5f, 0x25,
0x00, 0x00, 0x6a, 0x03, 0x1f, 0x02, 0xff, 0x03, 0xff, 0x7f, 0xff,
0x7f, 0xdf, 0x01, 0x12, 0x01, 0x00, 0x00, 0x1f, 0x23, 0x5f, 0x03,
0xf2, 0x00, 0x09, 0x00, 0xff, 0x7f, 0xea, 0x03, 0x1f, 0x01, 0x00,
0x00, 0x9f, 0x29, 0x1a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xff, 0x7f,
0x7f, 0x02, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x7f, 0xe0, 0x03, 0x06,
0x02, 0x20, 0x01, 0xff, 0x7f, 0xeb, 0x7e, 0x1f, 0x00, 0x00, 0x7c,
0xff, 0x7f, 0xff, 0x3f, 0x00, 0x7e, 0x1f, 0x00, 0xff, 0x7f, 0xff,
0x03, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x03, 0x1f, 0x00, 0x0c, 0x00,
0x00, 0x00, 0xff, 0x7f, 0x3f, 0x03, 0x93, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x42, 0x7f, 0x03, 0xff, 0x7f, 0xff, 0x7f, 0x8c, 0x7e,
0x00, 0x7c, 0x00, 0x00, 0xff, 0x7f, 0xef, 0x1b, 0x80, 0x61, 0x00,
0x00, 0xff, 0x7f, 0xea, 0x7f, 0x5f, 0x7d, 0x00, 0x00, 0x77, 0x1b,
0xd2, 0x0a, 0xe9, 0x25, 0x45, 0x15, 0x01, 0x30, 0x05, 0x08, 0x00,
0x28, 0x2b, 0x03, 0x06, 0x07, 0x1c, 0x31, 0x33, 0x34, 0x35, 0x36,
0x3c, 0x42, 0xb9, 0xa5, 0xb9, 0xa5, 0x42, 0x3c, 0x00, 0x01, 0x07,
0x0f, 0x1f, 0x1f, 0x3e, 0x3c, 0x00, 0xf8, 0xfe, 0xff, 0xfe, 0x1c,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x00,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0x00, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x0f, 0x00, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0,
0xf0, 0x00, 0x0f, 0x0f, 0x1f, 0x1f, 0x3f, 0x3f, 0x7f, 0x00, 0xcf,
0xcf, 0xcf, 0xcf, 0xcf, 0xde, 0x9e, 0x00, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x8f, 0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x3a, 0xfe, 0x7f,
0x20, 0x02, 0x23, 0x23, 0xf5, 0x2a, 0xe5, 0x21, 0x00, 0xc0, 0xcd,
0xbb, 0x08, 0xe1, 0xea, 0x02, 0xc0, 0x2a, 0xe5, 0x21, 0x01, 0xc0,
0xcd, 0xbb, 0x08, 0xe1, 0xea, 0x03, 0xc0, 0xf1, 0x28, 0x02, 0x23,
0x23, 0x2a, 0xea, 0x3a, 0xc0, 0x2a, 0xea, 0x3b, 0xc0, 0x2a, 0xea,
0x04, 0xc0, 0x7e, 0xea, 0x05, 0xc0, 0xcd, 0x43, 0x06, 0x21, 0x00,
0xc0, 0x16, 0x40, 0x1e, 0x00, 0xcd, 0xb2, 0x06, 0xd1, 0xc1, 0xe1,
0xf1, 0xc9, 0x11, 0x08, 0x00, 0x0e, 0x08, 0x77, 0x19, 0x0d, 0x20,
0xfb, 0xc9, 0xf5, 0xcd, 0x43, 0x06, 0x3e, 0x19, 0xea, 0x10, 0x99,
0x21, 0x2f, 0x99, 0x0e, 0x0c, 0x3d, 0x28, 0x08, 0x32, 0x0d, 0x20,
0xf9, 0x2e, 0x0f, 0x18, 0xf5, 0xf1, 0xc9, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const int cgb_boot_length = 2305;

28
libretro/dmg_boot.h Normal file
View File

@ -0,0 +1,28 @@
const char dmg_boot[257] = {
0x31, 0xfe, 0xff, 0x21, 0x00, 0x80, 0x22, 0xcb, 0x6c, 0x28, 0xfb,
0x3e, 0x80, 0xe0, 0x26, 0xe0, 0x11, 0x3e, 0xf3, 0xe0, 0x12, 0xe0,
0x25, 0x3e, 0x77, 0xe0, 0x24, 0x3e, 0xfc, 0xe0, 0x47, 0x11, 0x04,
0x01, 0x21, 0x10, 0x80, 0x1a, 0x47, 0xcd, 0x82, 0x00, 0xcd, 0x82,
0x00, 0x13, 0x7b, 0xee, 0x34, 0x20, 0xf2, 0x11, 0xac, 0x00, 0x0e,
0x08, 0x1a, 0x13, 0x22, 0x23, 0x0d, 0x20, 0xf9, 0x3e, 0x19, 0xea,
0x10, 0x99, 0x21, 0x2f, 0x99, 0x0e, 0x0c, 0x3d, 0x28, 0x08, 0x32,
0x0d, 0x20, 0xf9, 0x2e, 0x0f, 0x18, 0xf5, 0x3e, 0x91, 0xe0, 0x40,
0x06, 0x2d, 0xcd, 0x9e, 0x00, 0x3e, 0x83, 0xcd, 0xa5, 0x00, 0x06,
0x0f, 0xcd, 0x9e, 0x00, 0x3e, 0xc1, 0xcd, 0xa5, 0x00, 0x06, 0x96,
0xcd, 0x9e, 0x00, 0x21, 0xb0, 0x01, 0xe5, 0xf1, 0x21, 0x4d, 0x01,
0x01, 0x13, 0x00, 0x11, 0xd8, 0x00, 0xc3, 0xfe, 0x00, 0x3e, 0x04,
0x0e, 0x00, 0xcb, 0x20, 0xf5, 0xcb, 0x11, 0xf1, 0xcb, 0x11, 0x3d,
0x20, 0xf5, 0x79, 0x22, 0x23, 0x22, 0x23, 0xc9, 0xf0, 0x44, 0xfe,
0x90, 0x20, 0xfa, 0xc9, 0xcd, 0x97, 0x00, 0x05, 0x20, 0xfa, 0xc9,
0xe0, 0x13, 0x3e, 0x87, 0xe0, 0x14, 0xc9, 0x3c, 0x42, 0xb9, 0xa5,
0xb9, 0xa5, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x50, 0x00
};
const int dmg_boot_length = 257;

31
libretro/jni/Android.mk Normal file
View File

@ -0,0 +1,31 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
HAVE_NETWORK = 1
LOCAL_MODULE := libretro
ifeq ($(TARGET_ARCH),arm)
LOCAL_CXXFLAGS += -DANDROID_ARM
LOCAL_ARM_MODE := arm
endif
ifeq ($(TARGET_ARCH),x86)
LOCAL_CXXFLAGS += -DANDROID_X86
endif
ifeq ($(TARGET_ARCH),mips)
LOCAL_CXXFLAGS += -DANDROID_MIPS
endif
CORE_DIR := ../..
include ../../Makefile.common
LOCAL_SRC_FILES := $(SOURCES_CXX) $(SOURCES_C)
LOCAL_CXXFLAGS += -DINLINE=inline -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DNDEBUG -D_USE_MATH_DEFINES -DGB_INTERNAL
LOCAL_C_INCLUDES = $(INCFLAGS)
include $(BUILD_SHARED_LIBRARY)

View File

@ -0,0 +1,2 @@
APP_STL := gnustl_static
APP_ABI := all

437
libretro/libretro.c Normal file
View File

@ -0,0 +1,437 @@
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <time.h>
#include <assert.h>
#include <signal.h>
#include <stdarg.h>
#define AUDIO_FREQUENCY 44100
#ifdef _WIN32
#include <direct.h>
#include <windows.h>
#define snprintf _snprintf
#endif
#define GB_INTERNAL
#include "gb.h"
#include "libretro.h"
#ifdef _WIN32
char slash = '\\';
#else
char slash = '/';
#endif
#define VIDEO_WIDTH 160
#define VIDEO_HEIGHT 144
#define VIDEO_PIXELS VIDEO_WIDTH * VIDEO_HEIGHT
char battery_save_path[512];
char symbols_path[512];
static uint32_t *frame_buf;
static struct retro_log_callback logging;
static retro_log_printf_t log_cb;
static retro_video_refresh_t video_cb;
static retro_audio_sample_batch_t audio_batch_cb;
static retro_input_poll_t input_poll_cb;
static retro_input_state_t input_state_cb;
signed short soundbuf[1024*2];
char retro_system_directory[4096];
char retro_save_directory[4096];
char retro_game_path[4096];
int RLOOP=1;
GB_gameboy_t gb;
static void fallback_log(enum retro_log_level level, const char *fmt, ...)
{
(void)level;
va_list va;
va_start(va, fmt);
vfprintf(stderr, fmt, va);
va_end(va);
}
static void replace_extension(const char *src, size_t length, char *dest, const char *ext)
{
memcpy(dest, src, length);
dest[length] = 0;
/* Remove extension */
for (size_t i = length; i--;) {
if (dest[i] == '/') break;
if (dest[i] == '.') {
dest[i] = 0;
break;
}
}
/* Add new extension */
strcat(dest, ext);
}
static void GB_update_keys_status(GB_gameboy_t *gb)
{
input_poll_cb();
GB_set_key_state(gb, GB_KEY_RIGHT,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT));
GB_set_key_state(gb, GB_KEY_LEFT, input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT));
GB_set_key_state(gb, GB_KEY_UP,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) );
GB_set_key_state(gb, GB_KEY_DOWN,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN));
GB_set_key_state(gb, GB_KEY_A,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) );
GB_set_key_state(gb, GB_KEY_B,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) );
GB_set_key_state(gb, GB_KEY_SELECT,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT));
GB_set_key_state(gb, GB_KEY_START,input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START) );
}
static void audio_callback(void *gb)
{
GB_apu_copy_buffer(gb, (GB_sample_t *) soundbuf, (float)AUDIO_FREQUENCY / 59.72);
audio_batch_cb(soundbuf, (float)AUDIO_FREQUENCY / 59.72);
}
static void vblank(GB_gameboy_t *gb)
{
GB_update_keys_status(gb);
GB_set_pixels_output(gb, frame_buf);
audio_callback(gb);
}
static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
{
return r<<16|g<<8|b;
}
#ifdef HAVE_DEBUGGER
static void debugger_interrupt(int ignore)
{
/* ^C twice to exit */
if (GB_debugger_is_stopped(&gb))
exit(0);
GB_debugger_break(&gb);
}
#endif
static retro_environment_t environ_cb;
void retro_init(void)
{
frame_buf = (uint32_t*)malloc(VIDEO_PIXELS * sizeof(uint32_t));
const char *dir = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", dir);
else
snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", ".");
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
snprintf(retro_save_directory, sizeof(retro_save_directory), "%s", dir);
else
snprintf(retro_save_directory, sizeof(retro_save_directory), "%s", ".");
}
void retro_deinit(void)
{
free(frame_buf);
frame_buf = NULL;
}
unsigned retro_api_version(void)
{
return RETRO_API_VERSION;
}
void retro_set_controller_port_device(unsigned port, unsigned device)
{
log_cb(RETRO_LOG_INFO, "Plugging device %u into port %u.\n", device, port);
}
void retro_get_system_info(struct retro_system_info *info)
{
memset(info, 0, sizeof(*info));
info->library_name = "SameBoy";
info->library_version = "0.9";
info->need_fullpath = true;
info->valid_extensions = "gb|gbc";
}
void retro_get_system_av_info(struct retro_system_av_info *info)
{
struct retro_game_geometry geom = { VIDEO_WIDTH, VIDEO_HEIGHT,VIDEO_WIDTH, VIDEO_HEIGHT ,160.0 / 144.0 };
struct retro_system_timing timing = { 59.72, 44100.0 };
info->geometry = geom;
info->timing = timing;
}
static struct retro_rumble_interface rumble;
void retro_set_environment(retro_environment_t cb)
{
environ_cb = cb;
if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging))
log_cb = logging.log;
else
log_cb = fallback_log;
static const struct retro_controller_description controllers[] = {
{ "Nintendo Gameboy", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0) },
};
static const struct retro_controller_info ports[] = {
{ controllers, 1 },
{ NULL, 0 },
};
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
}
void retro_set_audio_sample(retro_audio_sample_t cb)
{
}
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
{
audio_batch_cb = cb;
}
void retro_set_input_poll(retro_input_poll_t cb)
{
input_poll_cb = cb;
}
void retro_set_input_state(retro_input_state_t cb)
{
input_state_cb = cb;
}
void retro_set_video_refresh(retro_video_refresh_t cb)
{
video_cb = cb;
}
void retro_reset(void)
{
}
static void check_variables(void)
{
}
void retro_run(void)
{
static int frames;
size_t samples;
bool updated = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
check_variables();
samples = GB_apu_get_current_buffer_length(&gb);
if (!(frames < (samples / 35112)))
{
GB_run_frame(&gb);
frames ++;
}
else
frames = 0;
video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT, 0);
}
bool retro_load_game(const struct retro_game_info *info)
{
struct retro_input_descriptor desc[] = {
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
{ 0 },
};
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
{
log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported.\n");
return false;
}
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
check_variables();
char buf[256];
int err = 0;
if (!strstr(info->path, "gbc"))
{
GB_init(&gb);
snprintf(buf, sizeof(buf), "%s%cdmg_boot.bin", retro_system_directory, slash);
log_cb(RETRO_LOG_INFO, "Loading boot image: %s\n", buf);
err = GB_load_boot_rom(&gb, buf);
if (err)
err = GB_load_boot_rom_dmg(&gb);
}
else
{
GB_init_cgb(&gb);
snprintf(buf, sizeof(buf), "%s%ccgb_boot.bin", retro_system_directory, slash);
log_cb(RETRO_LOG_INFO, "Loading boot image: %s\n", buf);
err = GB_load_boot_rom(&gb, buf);
if (err)
err = GB_load_boot_rom_cgb(&gb);
}
if (err)
log_cb(RETRO_LOG_INFO, "Failed to load boot ROM %s %d\n", buf, err);
(void)info;
if (GB_load_rom(&gb,info->path)) {
perror("Failed to load ROM");
exit(1);
}
GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank);
GB_set_user_data(&gb, (void*)NULL);
GB_set_pixels_output(&gb,(unsigned int*)frame_buf);
GB_set_rgb_encode_callback(&gb, rgb_encode);
size_t path_length = strlen(retro_game_path);
#ifdef HAVE_DEBUGGER
{
char TMPC[512];
sprintf(TMPC,"%s/registers.sym",retro_system_directory);
GB_debugger_load_symbol_file(&gb, TMPC);
}
#endif
replace_extension(retro_game_path, path_length, symbols_path, ".sym");
#ifdef HAVE_DEBUGGER
GB_debugger_load_symbol_file(&gb, symbols_path);
#endif
GB_set_sample_rate(&gb, AUDIO_FREQUENCY);
/* GB_set_highpass_filter_mode(&gb, GB_HIGHPASS_REMOVE_DC_OFFSET); */
return true;
}
void retro_unload_game(void)
{
}
unsigned retro_get_region(void)
{
return RETRO_REGION_NTSC;
}
bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num)
{
return false;
}
size_t retro_serialize_size(void)
{
return GB_get_save_state_size(&gb);
}
bool retro_serialize(void *data, size_t size)
{
GB_save_state_to_buffer(&gb, (uint8_t*) data);
if (data)
return true;
else
return false;
}
bool retro_unserialize(const void *data, size_t size)
{
if (GB_load_state_from_buffer(&gb, (uint8_t*) data, size) == 0)
return true;
else
return false;
}
void *retro_get_memory_data(unsigned type)
{
void* data;
switch(type)
{
case RETRO_MEMORY_SAVE_RAM:
if (gb.cartridge_type->has_battery && gb.mbc_ram_size != 0)
data = gb.mbc_ram;
else
data = NULL;
break;
case RETRO_MEMORY_RTC:
if(gb.cartridge_type->has_battery)
data = &gb.rtc_real;
else
data = NULL;
break;
default:
data = NULL;
break;
}
return data;
}
size_t retro_get_memory_size(unsigned type)
{
size_t size;
switch(type)
{
case RETRO_MEMORY_SAVE_RAM:
if (gb.cartridge_type->has_battery && gb.mbc_ram_size != 0)
size = gb.mbc_ram_size;
else
size = 0;
break;
case RETRO_MEMORY_RTC:
if(gb.cartridge_type->has_battery)
size = sizeof (gb.rtc_real);
else
size = 0;
break;
default:
size = 0;
break;
}
return size;
}
void retro_cheat_reset(void)
{}
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
(void)index;
(void)enabled;
(void)code;
}

2129
libretro/libretro.h Normal file

File diff suppressed because it is too large Load Diff

5
libretro/link.T Normal file
View File

@ -0,0 +1,5 @@
{
global: retro_*;
local: *;
};