Merge pull request #239 from retro-wertz/libretro

Update Libretro port
This commit is contained in:
Zach Bacon 2018-06-04 12:36:32 -04:00 committed by GitHub
commit 893269d897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 263 additions and 106 deletions

View File

@ -1,7 +1,11 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#ifndef __LIBRETRO__
#include "common/cstdint.h"
#else
#include <stdint.h>
#endif
#ifndef __LIBRETRO__
#include <zlib.h>

View File

@ -1,7 +1,11 @@
#ifndef PATCH_H
#define PATCH_H
#ifndef __LIBRETRO__
#include "cstdint.h"
#else
#include <stdint.h>
#endif
bool applyPatch(const char *patchname, uint8_t **rom, int *size);

View File

@ -1,7 +1,11 @@
#ifndef PORT_H
#define PORT_H
#ifndef __LIBRETRO__
#include "cstdint.h"
#else
#include <stdint.h>
#endif
#ifdef __CELLOS_LV2__
/* PlayStation3 */

View File

@ -1,7 +1,11 @@
#ifndef VBA_BKS_H
#define VBA_BKS_H
#ifndef __LIBRETRO__
#include "../common/cstdint.h"
#else
#include <stdint.h>
#endif
#define readWord(addr) \
((map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + ((map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8) + ((map[(addr + 2) >> 24].address[(addr + 2) & map[(addr + 2) >> 24].mask]) << 16) + ((map[(addr + 3) >> 24].address[(addr + 3) & map[(addr + 3) >> 24].mask]) << 24))

View File

@ -1,7 +1,12 @@
#ifndef EEPROM_H
#define EEPROM_H
#ifndef __LIBRETRO__
#include "../common/cstdint.h"
#else
#include <stdint.h>
#endif
#include <zlib.h>
#ifdef __LIBRETRO__

View File

@ -1,7 +1,12 @@
#ifndef FLASH_H
#define FLASH_H
#ifndef __LIBRETRO__
#include "../common/cstdint.h"
#else
#include <stdint.h>
#endif
#include <zlib.h>
#define FLASH_128K_SZ 0x20000

View File

@ -1470,7 +1470,7 @@ void CPUCleanUp()
emulating = 0;
}
#ifndef __LIBRETRO__
void SetMapMasks()
{
map[0].mask = 0x3FFF;
@ -1486,6 +1486,7 @@ void SetMapMasks()
map[12].mask = 0x1FFFFFF;
map[14].mask = 0xFFFF;
#ifdef BKPT_SUPPORT
for (int i = 0; i < 16; i++) {
map[i].size = map[i].mask + 1;
if (map[i].size > 0) {
@ -1504,8 +1505,9 @@ void SetMapMasks()
}
}
clearBreakRegList();
}
#endif
}
int CPULoadRom(const char* szFile)
{
romSize = 0x2000000;
@ -1728,10 +1730,6 @@ int CPULoadRomData(const char* data, int size)
CPUUpdateRenderBuffers(true);
#ifdef BKPT_SUPPORT
SetMapMasks();
#endif
return romSize;
}
@ -3666,9 +3664,8 @@ void CPUReset()
map[12].address = rom;
map[14].address = flashSaveMemory;
#ifndef __LIBRETRO__
SetMapMasks();
#endif
soundReset();
CPUUpdateWindow0();

View File

@ -1,7 +1,11 @@
#ifndef GBA_H
#define GBA_H
#ifndef __LIBRETRO__
#include "../common/cstdint.h"
#else
#include <stdint.h>
#endif
#include "../System.h"

View File

@ -1,6 +1,11 @@
#pragma once
#ifndef __LIBRETRO__
#include "../common/cstdint.h"
#else
#include <stdint.h>
#endif
#include <SFML/Network.hpp>
class GBASockClient {

View File

@ -1,7 +1,11 @@
#ifndef SRAM_H
#define SRAM_H
#ifndef __LIBRETRO__
#include "../common/cstdint.h"
#else
#include <stdint.h>
#endif
uint8_t sramRead(uint32_t address);
void sramWrite(uint32_t address, uint8_t byte);

View File

@ -1,6 +1,13 @@
TILED_RENDERING=0
STATIC_LINKING=0
SPACE :=
SPACE := $(SPACE) $(SPACE)
BACKSLASH :=
BACKSLASH := \$(BACKSLASH)
filter_out1 = $(filter-out $(firstword $1),$1)
filter_out2 = $(call filter_out1,$(call filter_out1,$1))
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
@ -109,6 +116,97 @@ else ifeq ($(platform), vita)
USE_THREADED_RENDERER=1
USE_MOTION_SENSOR=1
HAVE_NEON=1
# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))
PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
ifneq (,$(findstring desktop,$(PlatformSuffix)))
WinPartition = desktop
MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS
LDFLAGS += -MANIFEST -LTCG:incremental -NXCOMPAT -DYNAMICBASE -DEBUG -OPT:REF -INCREMENTAL:NO -SUBSYSTEM:WINDOWS -MANIFESTUAC:"level='asInvoker' uiAccess='false'" -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1
LIBS := kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
else ifneq (,$(findstring uwp,$(PlatformSuffix)))
WinPartition = uwp
MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS
LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO
LIBS := WindowsApp.lib
endif
CFLAGS += $(MSVC2017CompileFlags)
CXXFLAGS += $(MSVC2017CompileFlags)
TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix))
CC = cl.exe
CXX = cl.exe
LD = link.exe
reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul)))
fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1))
ProgramFiles86w := $(shell cmd /c "echo %PROGRAMFILES(x86)%")
ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)")
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir := $(WindowsSdkDir)
WindowsSDKVersion ?= $(firstword $(foreach folder,$(subst $(subst \,/,$(WindowsSdkDir)Include/),,$(wildcard $(call fix_path,$(WindowsSdkDir)Include\*))),$(if $(wildcard $(call fix_path,$(WindowsSdkDir)Include/$(folder)/um/Windows.h)),$(folder),)))$(BACKSLASH)
WindowsSDKVersion := $(WindowsSDKVersion)
VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools
VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise
VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional
VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community
VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi)
ifeq ($(VsInstallRoot), )
VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi)
endif
ifeq ($(VsInstallRoot), )
VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi)
endif
ifeq ($(VsInstallRoot), )
VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi)
endif
VsInstallRoot := $(VsInstallRoot)
VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*')
VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer)
WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared")
WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt")
WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um")
WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)")
WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)")
# For some reason the HostX86 compiler doesn't like compiling for x64
# ("no such file" opening a shared library), and vice-versa.
# Work around it for now by using the strictly x86 compiler for x86, and x64 for x64.
# NOTE: What about ARM?
ifneq (,$(findstring x64,$(TargetArchMoniker)))
VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64
else
VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86
endif
PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)")
ifneq (,$(findstring uwp,$(PlatformSuffix)))
LIB := $(shell IFS=$$'\n'; cygpath -w "$(LIB)/store")
endif
export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir)
export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
else
TARGET := $(TARGET_NAME)_libretro.dll
LDFLAGS += -Wl,-no-undefined -Wl,--version-script=link.T
@ -134,20 +232,50 @@ ifeq ($(DEBUG), 1)
CFLAGS += -g
CXXFLAGS += -g
else
CFLAGS += -O3 -DNDEBUG
CXXFLAGS += -O3 -DNDEBUG
CFLAGS += -O2 -DNDEBUG
CXXFLAGS += -O2 -DNDEBUG
endif
CFLAGS += $(fpic) $(VBA_DEFINES)
CXXFLAGS += $(fpic) $(VBA_DEFINES)
LIBS :=
OBJOUT = -o
LINKOUT = -o
ifneq (,$(findstring msvc,$(platform)))
OBJOUT = -Fo
LINKOUT = -out:
ifeq ($(STATIC_LINKING),1)
LD ?= lib.exe
STATIC_LINKING=0
ifeq ($(DEBUG), 1)
CFLAGS += -MTd
CXXFLAGS += -MTd
else
CFLAGS += -MT
CXXFLAGS += -MT
endif
else
LD = link.exe
ifeq ($(DEBUG), 1)
CFLAGS += -MDd
CXXFLAGS += -MDd
else
CFLAGS += -MD
CXXFLAGS += -MD
endif
endif
else
LD = $(CXX)
endif
%.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCFLAGS)
$(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS) $(INCFLAGS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(INCFLAGS)
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS) $(INCFLAGS)
ifeq ($(platform), theos_ios)
COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
@ -162,7 +290,7 @@ $(TARGET): $(OBJS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJS)
else
$(CXX) -o $@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS)
$(LD) $(LINKOUT)$@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS)
endif
clean:

View File

@ -15,7 +15,6 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "../common/cstdint.h"
#include "SoundRetro.h"
#include "libretro.h"
unsigned g_audio_frames;

View File

@ -102,7 +102,7 @@ bool utilIsGBImage(const char* file)
FILE *fp;
bool ret = false;
char buffer[47];
if (!file || !(fd = fopen (file, "r"))) //TODO more checks here (does file exist, is it a file, a symlink or a blockdevice)
if (!file || !(fp = fopen (file, "r"))) //TODO more checks here (does file exist, is it a file, a symlink or a blockdevice)
return ret;
fseek (fp, 0, SEEK_END);
if (ftell (fp) >= 0x8000) { //afaik there can be no gb-rom smaller than this
@ -150,6 +150,7 @@ uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data,
char *buf = NULL;
fp = fopen(file,"rb");
if(!fp) return NULL;
fseek(fp, 0, SEEK_END); //go to end
size = ftell(fp); // get position at end (length)
rewind(fp);

View File

@ -1,3 +1,6 @@
#ifndef _VBA_UTIL_RETRO_H
#define _VBA_UTIL_RETRO_H
extern bool speedup;
extern int cheatsEnabled;
extern int useBios;
@ -17,9 +20,16 @@ extern bool skipSaveGameBattery;
extern bool skipSaveGameCheats;
#define MAX_CHEATS 100
const char gb_image_header[]={
0xce, 0xed, 0x66, 0x66, 0xcc, 0x0d, 0x00, 0x0b, 0x03, 0x73, 0x00,
0x83, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x08, 0x11, 0x1f, 0x88, 0x89,
0x00, 0x0e, 0xdc, 0xcc, 0x6e, 0xe6, 0xdd, 0xdd, 0xd9, 0x99, 0xbb,
0xbb, 0x67, 0x63, 0x6e, 0x0e, 0xec, 0xcc, 0xdd, 0xdc, 0x99, 0x9f,
0xbb, 0xb9, 0x33, 0x3e};
const char gb_image_header[] =
{
static_cast<const char>
(
0xce, 0xed, 0x66, 0x66, 0xcc, 0x0d, 0x00, 0x0b, 0x03, 0x73, 0x00,
0x83, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x08, 0x11, 0x1f, 0x88, 0x89,
0x00, 0x0e, 0xdc, 0xcc, 0x6e, 0xe6, 0xdd, 0xdd, 0xd9, 0x99, 0xbb,
0xbb, 0x67, 0x63, 0x6e, 0x0e, 0xec, 0xcc, 0xdd, 0xdc, 0x99, 0x9f,
0xbb, 0xb9, 0x33, 0x3e
)
};
#endif // _VBA_UTIL_RETRO_H

View File

@ -1,67 +1,20 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
CORE_DIR := $(LOCAL_PATH)/../..
LIBRETRO_DIR := $(CORE_DIR)/libretro
include $(LIBRETRO_DIR)/Makefile.common
COREFLAGS := -DHAVE_STDINT_H -DLSB_FIRST -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_LINK -DFRONTEND_SUPPORTS_RGB565 -DTILED_RENDERING $(INCFLAGS)
GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
LOCAL_CXXFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -DANDROID_ARM
LOCAL_ARM_MODE := arm
endif
ifeq ($(TARGET_ARCH),x86)
LOCAL_CFLAGS += -DANDROID_X86
endif
ifeq ($(TARGET_ARCH),mips)
LOCAL_CFLAGS += -DANDROID_MIPS
endif
VBADIR = ../../
LOCAL_MODULE := libretro
LOCAL_SRC_FILES = $(VBADIR)/gba/agbprint.cpp \
$(VBADIR)/gba/armdis.cpp \
$(VBADIR)/gba/bios.cpp \
$(VBADIR)/gba/Cheats.cpp \
$(VBADIR)/gba/CheatSearch.cpp \
$(VBADIR)/gba/EEprom.cpp \
$(VBADIR)/gba/elf.cpp \
$(VBADIR)/gba/ereader.cpp \
$(VBADIR)/gba/Flash.cpp \
$(VBADIR)/gba/GBA-arm.cpp \
$(VBADIR)/gba/GBA.cpp \
$(VBADIR)/gba/gbafilter.cpp \
$(VBADIR)/gba/GBAGfx.cpp \
$(VBADIR)/gba/GBALink.cpp \
$(VBADIR)/gba/GBASockClient.cpp \
$(VBADIR)/gba/GBA-thumb.cpp \
$(VBADIR)/gba/Globals.cpp \
$(VBADIR)/gba/Mode0.cpp \
$(VBADIR)/gba/Mode1.cpp \
$(VBADIR)/gba/Mode2.cpp \
$(VBADIR)/gba/Mode3.cpp \
$(VBADIR)/gba/Mode4.cpp \
$(VBADIR)/gba/Mode5.cpp \
$(VBADIR)/gba/remote.cpp \
$(VBADIR)/gba/RTC.cpp \
$(VBADIR)/gba/Sound.cpp \
$(VBADIR)/gba/Sram.cpp \
$(VBADIR)/apu/Blip_Buffer.cpp \
$(VBADIR)/apu/Effects_Buffer.cpp \
$(VBADIR)/apu/Gb_Apu.cpp \
$(VBADIR)/apu/Gb_Apu_State.cpp \
$(VBADIR)/apu/Gb_Oscs.cpp \
$(VBADIR)/apu/Multi_Buffer.cpp \
$(VBADIR)/libretro/libretro.cpp \
$(VBADIR)/libretro/UtilRetro.cpp \
$(VBADIR)/libretro/SoundRetro.cpp \
$(VBADIR)/libretro/scrc32.cpp
LOCAL_CFLAGS = -O3 -DINLINE=inline -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DLSB_FIRST -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DUSE_GBA_ONLY -DNO_LINK -DFRONTEND_SUPPORTS_RGB565 -DTILED_RENDERING
LOCAL_C_INCLUDES = $(VBADIR)
include $(CLEAR_VARS)
LOCAL_MODULE := retro
LOCAL_SRC_FILES := $(SOURCES_CXX)
LOCAL_CXXFLAGS := $(COREFLAGS)
LOCAL_LDFLAGS := -Wl,-version-script=$(LIBRETRO_DIR)/link.T
include $(BUILD_SHARED_LIBRARY)

View File

@ -1 +1,3 @@
APP_ABI := all
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION := 4.9

View File

@ -1,4 +1,3 @@
#include "../common/cstdint.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
@ -25,9 +24,9 @@
#include "../gba/Sound.h"
#include "../gba/bios.h"
#define RETRO_DEVICE_GBA RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
#define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
#define RETRO_DEVICE_GBA_ALT2 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 2)
#define RETRO_DEVICE_GBA RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
#define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
#define RETRO_DEVICE_GBA_ALT2 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 2)
#define ISHEXDEC ((codeLine[cursor]>='0') && (codeLine[cursor]<='9')) || ((codeLine[cursor]>='a') && (codeLine[cursor]<='f')) || ((codeLine[cursor]>='A') && (codeLine[cursor]<='F'))
@ -39,7 +38,6 @@ retro_audio_sample_batch_t audio_batch_cb;
static retro_environment_t environ_cb;
bool enableRtc;
extern uint64_t joy;
static bool can_dupe;
unsigned device_type = 0;
int emulating = 0;
@ -48,6 +46,8 @@ static int controller_layout[2] = { 0, 0 };
uint8_t libretro_save_buf[0x20000 + 0x2000]; /* Workaround for broken-by-design GBA save semantics. */
static unsigned libretro_save_size = sizeof(libretro_save_buf);
static char biosfile[1024] = {0};
static bool usebios = false;
int RGB_LOW_BITS_MASK = 0;
@ -188,14 +188,15 @@ void retro_set_environment(retro_environment_t cb)
environ_cb = cb;
struct retro_variable variables[] = {
{ "vbam_layer_1", "Show layer 1; Yes|No" },
{ "vbam_layer_2", "Show layer 2; Yes|No" },
{ "vbam_layer_3", "Show layer 3; Yes|No" },
{ "vbam_layer_4", "Show layer 4; Yes|No" },
{ "vbam_layer_5", "Show sprite layer; Yes|No" },
{ "vbam_layer_6", "Show window layer 1; Yes|No" },
{ "vbam_layer_7", "Show window layer 2; Yes|No" },
{ "vbam_layer_8", "Show sprite window layer; Yes|No" },
{ "vbam_usebios", "Use BIOS file (Restart); disabled|enabled" },
{ "vbam_layer_1", "Show layer 1; enabled|disabled" },
{ "vbam_layer_2", "Show layer 2; enabled|disabled" },
{ "vbam_layer_3", "Show layer 3; enabled|disabled" },
{ "vbam_layer_4", "Show layer 4; enabled|disabled" },
{ "vbam_layer_5", "Show sprite layer; enabled|disabled" },
{ "vbam_layer_6", "Show window layer 1; enabled|disabled" },
{ "vbam_layer_7", "Show window layer 2; enabled|disabled" },
{ "vbam_layer_8", "Show sprite window layer; enabled|disabled" },
{ NULL, NULL },
};
@ -217,7 +218,11 @@ void retro_get_system_info(struct retro_system_info *info)
{
info->need_fullpath = false;
info->valid_extensions = "gba";
info->library_version = "git" GIT_VERSION;
#ifdef GIT_VERSION
info->library_version = "2.0.2" GIT_VERSION;
#else
info->library_version = "2.0.2-GIT";
#endif
info->library_name = "VBA-M";
info->block_extract = false;
}
@ -235,14 +240,24 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
void retro_init(void)
{
struct retro_log_callback log;
memset(libretro_save_buf, 0xff, sizeof(libretro_save_buf));
adjust_save_ram();
environ_cb(RETRO_ENVIRONMENT_GET_CAN_DUPE, &can_dupe);
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
log_cb = log.log;
else
log_cb = NULL;
#ifdef _WIN32
char slash = '\\';
#else
char slash = '/';
#endif
struct retro_log_callback log;
memset(libretro_save_buf, 0xff, sizeof(libretro_save_buf));
adjust_save_ram();
environ_cb(RETRO_ENVIRONMENT_GET_CAN_DUPE, &can_dupe);
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
log_cb = log.log;
else
log_cb = NULL;
const char* dir = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
snprintf(biosfile, sizeof(biosfile), "%s%c%s", dir, slash, "gba_bios.bin");
#ifdef FRONTEND_SUPPORTS_RGB565
enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565;
@ -458,7 +473,11 @@ static void gba_init(void)
soundInit();
soundSetSampleRate(32000);
CPUInit(0, false);
if (usebios && biosfile[0])
CPUInit(biosfile, true);
else
CPUInit(0, false);
CPUReset();
soundReset();
@ -536,7 +555,7 @@ static void update_variables(void)
{
key[strlen("vbam_layer_")]='1'+i;
var.value=NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && var.value[0]=='N')
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && var.value[0]=='d')
{
disabled_layers|=0x100<<i;
}
@ -544,6 +563,15 @@ static void update_variables(void)
layerSettings = 0xFF00 ^ disabled_layers;
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
var.key = "vbam_usebios";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
bool newval = (strcmp(var.value, "enabled") == 0);
usebios = newval;
}
}
#ifdef FINAL_VERSION
@ -841,7 +869,7 @@ uint32_t systemReadJoypad(int which)
bool systemReadJoypads() { return true; }
void systemUpdateMotionSensor() {}
uint8_t systemGetSensorDarkness() {}
uint8_t systemGetSensorDarkness() { return 0; }
void systemCartridgeRumble(bool)
{