Skip to content

Commit 292b831

Browse files
committed
Add Dreamcast support for DirkSimple, including platform-specific file handling and build scripts
1 parent 3d5c766 commit 292b831

6 files changed

Lines changed: 29 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ if(DIRKSIMPLE_SDL)
203203
set_target_properties(dirksimple PROPERTIES OUTPUT_NAME "dirksimple-wasm")
204204
set_target_properties(dirksimple PROPERTIES LINK_FLAGS "${IPO_FLAG} -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=0 -s EXPORTED_RUNTIME_METHODS=['addRunDependency','removeRunDependency'] -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['$autoResumeAudioContext','$dynCall']")
205205
endif()
206-
206+
if(CMAKE_SYSTEM_NAME STREQUAL "Dreamcast")
207+
target_link_libraries(dirksimple GL)
208+
endif()
207209
# This is safe to set on all platforms. Otherwise your SDL app will have a terminal window pop up with it on Windows.
208210
set_property(TARGET dirksimple PROPERTY WIN32_EXECUTABLE TRUE)
209211

dc.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mkdcdisc -n DCDirkSimple -N -d data -e dirksimple.elf -o dirksimple.cdi
2+

dirksimple.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,10 +1289,18 @@ static void setup_movie(const char *gamepath, DirkSimple_PixFmt pixfmt)
12891289

12901290
DirkSimple_Io *io = DirkSimple_openfile_read(gamepath);
12911291
if (!io) {
1292+
#ifndef __DREAMCAST__
1293+
const size_t slen = 33;
1294+
#else
12921295
const size_t slen = strlen(gamepath) + 5;
1296+
#endif
12931297
char *gamepath_ext = DirkSimple_xmalloc(slen);
12941298
if (gamepath_ext) {
1299+
#ifndef __DREAMCAST__
12951300
snprintf(gamepath_ext, slen, "%s.ogv", gamepath);
1301+
#else
1302+
snprintf(gamepath_ext, slen, "/cd/data/games/lair/lair.ogv");
1303+
#endif
12961304
io = DirkSimple_openfile_read(gamepath_ext);
12971305
DirkSimple_free(gamepath_ext);
12981306
}

dirksimple_sdl.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ void DirkSimple_videoformat(const char *gametitle, uint32_t width, uint32_t heig
187187
if (!GWindow) {
188188
sdlpanic("Failed to create window");
189189
}
190-
190+
#ifndef __DREAMCAST__
191191
load_icon(GWindow);
192-
192+
#endif
193193
GRenderer = SDL_CreateRenderer(GWindow, NULL);
194194
if (!GRenderer) {
195195
sdlpanic("Failed to create renderer");
@@ -283,7 +283,11 @@ void DirkSimple_drawsprite(DirkSimple_Sprite *sprite, int sx, int sy, int sw, in
283283
}
284284

285285
if (texture == NULL) {
286+
#ifdef __DREAMCAST__
287+
texture = SDL_CreateTexture(GRenderer, SDL_PIXELFORMAT_ARGB1555, SDL_TEXTUREACCESS_STATIC, sprite->width, sprite->height);
288+
#else
286289
texture = SDL_CreateTexture(GRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC, sprite->width, sprite->height);
290+
#endif
287291
if (!texture) {
288292
char what[128];
289293
SDL_snprintf(what, sizeof (what), "Failed to create texture for sprite '%s'", sprite->name);
@@ -538,6 +542,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
538542

539543
#ifdef DIRKSIMPLE_FORCE_BASE_DIR // let Linux distros hardcode this to something under /usr/share, or whatever.
540544
basedir = DIRKSIMPLE_FORCE_BASE_DIR;
545+
#ifdef __DREAMCAST__
546+
gamepath = strdup("data/games/lair"); // Relative to basedir
547+
gamename = strdup("lair");
548+
GWantFullscreen = true;
549+
550+
#endif
541551
#else
542552
basedir = SDL_GetBasePath();
543553
#endif
@@ -548,7 +558,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
548558
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Failed to determine base dir", errstr, NULL); // in case this works.
549559
return SDL_APP_FAILURE;
550560
}
551-
561+
#ifndef __DREAMCAST__
552562
for (i = 1; i < argc; i++) {
553563
const char *arg = argv[i];
554564
if (*arg == '-') {
@@ -576,13 +586,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
576586
SDL_EnumerateDirectory(basedir, find_movie_files, &foundpath);
577587
gamepath = foundpath;
578588
}
579-
589+
#endif
580590
if (!gamepath) {
581591
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Can't find a movie file!", "Include an .ogv file with the build or put it on the command line.", NULL);
582592
SDL_Quit();
583593
return SDL_APP_FAILURE;
584594
}
585-
586595
DirkSimple_startup(basedir, gamepath, gamename, DIRKSIMPLE_PIXFMT_IYUV);
587596

588597
SDL_free(foundpath);

dreamcast.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kos-cmake -S . -B build -DDIRKSIMPLE_LIBRETRO=OFF -DDIRKSIMPLE_FORCE_BASE_DIR=\"/cd/\" -DSDL3_DIR=/opt/toolchains/dc/kos/addons/lib/dreamcast/cmake/SDL3

thirdparty/lua/src/ldo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
6161
#define luai_jmpbuf int /* dummy variable */
6262

63-
#elif defined(LUA_USE_POSIX) /* }{ */
63+
#elif defined(LUA_USE_POSIX) && !defined(__DREAMCAST__) /* }{ */
6464

6565
/* in POSIX, try _longjmp/_setjmp (more efficient) */
6666
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)

0 commit comments

Comments
 (0)