Skip to content

Commit

Permalink
Merge pull request skylersaleh#377 from Kim-Dewelski/libretro
Browse files Browse the repository at this point in the history
Libretro
  • Loading branch information
skylersaleh authored Aug 30, 2024
2 parents a809235 + 46e0977 commit c37a444
Show file tree
Hide file tree
Showing 15 changed files with 5,869 additions and 139 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/deploy_retro_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Linux (Libretro)
on: [push,pull_request]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Install dependencies
# We don't actually use these dependencies, but they are needed for find package.
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev
sudo apt-get install -y libgl1-mesa-dev libegl1-mesa-dev libasound2-dev
- name: Configure & Build 🔧
run: |
mkdir build
cd build
cmake .. && cmake --build . --target skyemu_libretro --config Release
zip skyemu_libretro.zip skyemu_libretro.so ../skyemu_libretro.info
- name: GH Release 🚀
# You may pin to the exact commit or the version.
uses: actions/upload-artifact@v2
with:
name: LinuxRelease (Libretro)
path: build/skyemu_libretro.zip
#uses: softprops/[email protected]
#with:
# # Note-worthy description of changes in release
# # body: # optional
# # Path to load note-worthy description of changes in release from
# # body_path: # optional
# # Gives the release a custom name. Defaults to tag name
# name: LinuxRelease
# # Identify the release as a prerelease. Defaults to false
# prerelease: True
# # Newline-delimited list of path globs for asset files to upload
# files: build/bin/*

33 changes: 33 additions & 0 deletions .github/workflows/deploy_retro_mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build macOS (Libretro)
on: [push,pull_request]
jobs:
build-and-deploy:
runs-on: macos-latest
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Configure & Build 🔧
run: |
mkdir build
cd build
cmake .. && cmake --build . --target skyemu_libretro
zip skyemu_libretro.zip skyemu_libretro.dylib ../skyemu_libretro.info
- name: GH Release 🚀
# You may pin to the exact commit or the version.
uses: actions/upload-artifact@v2
with:
name: MacOSRelease (Libretro)
path: build/skyemu_libretro.zip
#uses: softprops/[email protected]
#with:
# # Note-worthy description of changes in release
# # body: # optional
# # Path to load note-worthy description of changes in release from
# # body_path: # optional
# # Gives the release a custom name. Defaults to tag name
# name: LinuxRelease
# # Identify the release as a prerelease. Defaults to false
# prerelease: True
# # Newline-delimited list of path globs for asset files to upload
# files: build/bin/*

40 changes: 40 additions & 0 deletions .github/workflows/deploy_retro_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build Windows (Libretro)
on: [push,pull_request]
jobs:
build-and-deploy:
runs-on: windows-2019
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Get latest CMake and ninja
# Using 'latest' branch, the most recent CMake and ninja are installed.
uses: lukka/get-cmake@latest
- name: Build 🔧
run: |
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.19041.0 ..
cmake --build . --config Release --target skyemu_libretro
mkdir skyemu_libretro_zip
mv bin/Release/skyemu_libretro.dll skyemu_libretro_zip
cp ../skyemu_libretro.info skyemu_libretro_zip
Compress-Archive -Destination skyemu_libretro.zip -Path skyemu_libretro_zip
- name: GH Release 🚀
# You may pin to the exact commit or the version.
uses: actions/upload-artifact@v2
with:
name: WindowsRelease (Libretro)
path: build/skyemu_libretro.zip
#uses: softprops/[email protected]
#with:
# # Note-worthy description of changes in release
# # body: # optional
# # Path to load note-worthy description of changes in release from
# # body_path: # optional
# # Gives the release a custom name. Defaults to tag name
# name: LinuxRelease
# # Identify the release as a prerelease. Defaults to false
# prerelease: True
# # Newline-delimited list of path globs for asset files to upload
# files: build/bin/*

16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (MSVC)

endif()

if( (NOT ANDROID))
if(NOT ANDROID)
set(USE_SDL 1)
add_definitions(-DUSE_SDL=1)
endif()
Expand Down Expand Up @@ -155,8 +155,8 @@ add_library(cimgui STATIC
src/cimgui/imgui/imgui_demo.cpp
)
set_property(TARGET cimgui PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")

target_include_directories(cimgui INTERFACE src/cimgui)

if(USE_SDL)
message("Build with SDL!")

Expand Down Expand Up @@ -285,7 +285,7 @@ add_definitions(-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\")
add_definitions(-DGIT_BRANCH=\"${GIT_BRANCH}\")
add_definitions(-DGIT_TAG=\"${GIT_TAG}\")

set(SKYEMU_SRC src/main.c src/stb.c src/miniz.c src/res.c src/localization.c src/mutex.cpp)
set(SKYEMU_SRC src/main.c src/shared.c src/cloud.cpp src/https.cpp src/stb.c src/miniz.c src/res.c src/localization.c src/mutex.cpp)

if(ENABLE_HTTP_CONTROL_SERVER)
add_definitions(-DENABLE_HTTP_CONTROL_SERVER=1)
Expand All @@ -299,7 +299,6 @@ if(UNICODE_GUI)
include_directories(src/utf8proc/)
add_definitions(-DUNICODE_GUI=1)
add_definitions(-DUTF8PROC_STATIC=1)

endif()

if(USE_SDL)
Expand Down Expand Up @@ -380,12 +379,21 @@ elseif(ANDROID)
else()
add_executable(${PROJECT_NAME} ${SKYEMU_SRC})
endif()

add_library(skyemu_libretro SHARED EXCLUDE_FROM_ALL src/libretro.c src/shared.c src/localization.c)
set_target_properties(skyemu_libretro PROPERTIES PREFIX "")
if (MACOS OR IOS)
find_library(FoundationLib CoreFoundation)
target_link_libraries(skyemu_libretro ${FoundationLib})
endif()

if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-sALLOW_MEMORY_GROWTH -s TOTAL_MEMORY=192MB -lidbfs.js -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -flto -s USE_CLOSURE_COMPILER=0 --closure 0 ")
endif ()
if (EMSCRIPTEN)
configure_file(src/sw.js.in ${CMAKE_CURRENT_BINARY_DIR}/bin/sw.js)
endif ()

set(LINK_LIBS ${LINK_LIBS} sokol ${ALSA_LIBRARIES})

if(NOT EMSCRIPTEN)
Expand Down
56 changes: 56 additions & 0 deletions skyemu_libretro.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
display_name = "Nintendo - Game Boy/GBA/NDS (SkyEmu)"
categories = "Emulator"
authors = "Team SkyEmu"
supported_extensions = "gb|gbx|gba|nds"
corename = "SkyEmu"
license = "MIT"
permissions = ""
display_version = "Git"
manufacturer = "Nintendo"

firmware_count = 10
firmware0_desc = "cgb_boot.bin (GBC BIOS)"
firmware0_path = "cgb_boot.bin"
firmware0_opt = "true"
firmware1_desc = "gbc_bios.bin (GBC BIOS)"
firmware1_path = "gbc_bios.bin"
firmware1_opt = "true"
firmware2_desc = "cgb0_boot.bin (GBC BIOS)"
firmware2_path = "cgb0_boot.bin"
firmware2_opt = "true"
firmware3_desc = "cgb_agb_boot.bin (GBC BIOS)"
firmware3_path = "cgb_agb_boot.bin"
firmware3_opt = "true"
firmware4_desc = "dmg_rom.bin (DMG BIOS)"
firmware4_path = "dmg_rom.bin"
firmware4_opt = "true"
firmware5_desc = "dmg0_rom.bin (DMG BIOS)"
firmware5_path = "dmg0_rom.bin"
firmware5_opt = "true"
firmware6_desc = "gba_bios.bin (GBA BIOS)"
firmware6_path = "gba_bios.bin"
firmware6_opt = "true"
firmware7_desc = "nds7.bin (NDS ARM7 BIOS)"
firmware7_path = "nds7.bin"
firmware7_opt = "true"
firmware8_desc = "nds9.bin (NDS ARM9 BIOS)"
firmware8_path = "nds9.bin"
firmware8_opt = "true"
firmware9_desc = "firmware.bin (NDS FIRMWARE)"
firmware9_path = "firmware.bin"
firmware9_opt = "true"

savestate = "true"
savestate_features = "deterministic"
cheats = "true"
input_descriptors = "true"
memory_descriptors = "true"
libretro_saves = "true"
core_options = "true"
core_options_version = "2.0"
database = "Nintendo - Nintendo DS|Nintendo - Game Boy|Nintendo - Game Boy Advance"
needs_fullpath = "false"
is_experimental = "false"

description = "SkyEmu is a multi-system emulator, supporting Game Boy, Game Boy Color and Nintendo DS cores."

11 changes: 8 additions & 3 deletions src/gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1335,10 +1335,15 @@ void gb_tick_rtc(sb_gb_t*gb){
gb->rtc.hour= tm->tm_hour;
gb->rtc.day = (tm->tm_wday-1)%7;
}
void sb_tick(sb_emu_state_t* emu, sb_gb_t* gb,gb_scratch_t* scratch){

void sb_ptrs_init(sb_gb_t* gb, gb_scratch_t* scratch, uint8_t* rom_data) {
gb->lcd.framebuffer = scratch->framebuffer;
gb->cart.data = emu->rom_data;
gb->cart.data = rom_data;
gb->bios = scratch->bios;
}

void sb_tick(sb_emu_state_t* emu, sb_gb_t* gb,gb_scratch_t* scratch){
sb_ptrs_init(gb, scratch, emu->rom_data);
int instructions_to_execute = emu->step_instructions;
if(instructions_to_execute==0)instructions_to_execute=70224/2;
int frames_to_draw = 1;
Expand Down Expand Up @@ -2054,4 +2059,4 @@ static FORCE_INLINE void sb_process_audio(sb_gb_t *gb, sb_emu_state_t*emu, doubl
emu->audio_ring_buff.data[write_entry0] = out_l*32760;
emu->audio_ring_buff.data[write_entry1] = out_r*32760;
}
}
}
11 changes: 9 additions & 2 deletions src/gba.h
Original file line number Diff line number Diff line change
Expand Up @@ -3728,16 +3728,18 @@ static FORCE_INLINE void sb_process_audio(sb_gb_t *gb, sb_emu_state_t*emu, doubl
#undef GBA_AUDIO

// END GB REUSE CODE SHIM//

void gba_cpu_trigger_breakpoint(void* data){
gba_t*gba =(gba_t*)data;
gba->frame_in_progress=false;
gba->pause_after_frame=true;
}

void gba_tick(sb_emu_state_t* emu, gba_t* gba,gba_scratch_t *scratch){
void gba_ptrs_init(gba_t* gba,gba_scratch_t *scratch, uint8_t* rom_data) {

gba->framebuffer = scratch->framebuffer;
gba->mem.bios = scratch->bios;
gba->mem.cart_rom= emu->rom_data;
gba->mem.cart_rom = rom_data;
gba->cpu.log_cmp_file = scratch->log_cmp_file;
gba->cpu.read8 = arm7_read8;
gba->cpu.read16 = arm7_read16;
Expand All @@ -3747,6 +3749,11 @@ void gba_tick(sb_emu_state_t* emu, gba_t* gba,gba_scratch_t *scratch){
gba->cpu.write8 = arm7_write8;
gba->cpu.write16 = arm7_write16;
gba->cpu.write32 = arm7_write32;
gba->cpu.user_data=gba;
}

void gba_tick(sb_emu_state_t* emu, gba_t* gba,gba_scratch_t *scratch){
gba_ptrs_init(gba, scratch, emu->rom_data);
gba->cpu.user_data=gba;
gba->cpu.trigger_breakpoint=gba_cpu_trigger_breakpoint;

Expand Down
Loading

0 comments on commit c37a444

Please sign in to comment.