Skip to content

Commit

Permalink
Add GBA version
Browse files Browse the repository at this point in the history
  • Loading branch information
fincs committed Nov 10, 2024
1 parent ce41a82 commit 4b6807e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project(dvm LANGUAGES C)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(NINTENDO_DS AND ARM9)
set(CMAKE_INSTALL_PREFIX "${NDS_ROOT}" CACHE PATH "" FORCE)
elseif(NINTENDO_GBA)
set(CMAKE_INSTALL_PREFIX "${GBA_ROOT}" CACHE PATH "" FORCE)
elseif(NINTENDO_GAMECUBE OR NINTENDO_WII)
set(CMAKE_INSTALL_PREFIX "${OGC_ROOT}" CACHE PATH "" FORCE)
set(LIB_SUBDIR "/${OGC_SUBDIR}")
Expand All @@ -31,10 +33,17 @@ target_compile_options(dvm PRIVATE
-Wall
)

target_compile_definitions(dvm PRIVATE
# Disc I/O buffer alignment (should match CPU cache line size)
LIBDVM_BUFFER_ALIGN=32
)
if (NOT NINTENDO_GBA)
target_compile_definitions(dvm PRIVATE
# Disc I/O buffer alignment (should match CPU cache line size)
LIBDVM_BUFFER_ALIGN=32
)
else()
target_compile_definitions(dvm PRIVATE
# Disc I/O buffer alignment (should match CPU cache line size)
LIBDVM_BUFFER_ALIGN=4
)
endif()

target_include_directories(dvm PRIVATE
include
Expand Down Expand Up @@ -63,6 +72,10 @@ if(NINTENDO_DS)
)
endif()

if(NINTENDO_GBA)
target_sources(dvm PRIVATE source/dvm_libgba.c)
endif()

if(NINTENDO_GAMECUBE OR NINTENDO_WII)
target_sources(dvm PRIVATE source/dvm_libogc.c)
endif()
Expand Down
5 changes: 5 additions & 0 deletions Catnip.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

catnip_package(dvm DEFAULT all)

catnip_add_preset(gba
TOOLSET GBA
BUILD_TYPE MinSizeRel
)

catnip_add_preset(ds
TOOLSET NDS
BUILD_TYPE Release
Expand Down
16 changes: 16 additions & 0 deletions source/dvm_libgba.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <dvm.h>
#include <disc.h>

__attribute__((weak)) unsigned g_dvmDefaultCachePages = 2;
__attribute__((weak)) unsigned g_dvmDefaultSectorsPerPage = 8;

bool dvmInit(bool set_app_cwdir, unsigned cache_pages, unsigned sectors_per_page)
{
unsigned num_mounted = 0;

// Try mounting the disc interface
const DISC_INTERFACE* fat = discGetInterface();
num_mounted += dvmProbeMountDiscIface("fat", fat, cache_pages, sectors_per_page);

return num_mounted != 0;
}

0 comments on commit 4b6807e

Please sign in to comment.