9 Commits

Author SHA1 Message Date
Ville Lindholm
acb3925bb4
Cleanup: fix logger warnings introduced by SDL 3 migration
- logger.c:103 log_write_raw() missing return in unreachable
  assert(0) branch; clang flagged the missing return statement.
- logger.c:191 SDL_GetTicks() now returns Uint64 in SDL 3; widen the
  printf format from %d to %llu and bump the local buffer size.

Build is clean. Remaining warnings (strncat-size in a_wave.c,
invalid-source-encoding in a_midifile.c) are pre-2007 code-style
issues unrelated to SDL.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 22:05:20 +03:00
Ville Lindholm
0e6865c4da
WIP: port deferred input/audio stubs to real SDL 3 APIs
Phase 7-8 of the migration. Replaces the per-subsystem stubs added in
the earlier "builds clean" commit with proper SDL 3 implementations.

- gfxengine: add SDL_Window* accessor window_handle() so callers that
  need to talk to SDL 3's window APIs (grab, text input) can reach it.
- states.cpp mouse grab: SDL_WM_GrabInput → SDL_SetWindowMouseGrab.
  Drops the local SDL_GRAB_* / SDL_WM_GrabInput stub macros.
- states.cpp text input: SDL_EnableUNICODE → SDL_StartTextInput /
  SDL_StopTextInput. kobo.cpp event loop now handles
  SDL_EVENT_TEXT_INPUT (in both quit_requested() and the main game
  loop) and forwards each byte of the UTF-8 string as a unicode value
  to gsm.press(-1, ch) so the high-score name-entry path keeps
  working without any state-side changes.
- kobo.cpp joystick: full re-port of init_js / close_js using
  SDL_GetJoysticks (returns SDL_JoystickID array), SDL_OpenJoystick,
  SDL_CloseJoystick. options.cpp joystick enumeration already used
  the new API from the previous commit.
- sound/audio.c: replace the silent stub with a real SDL 3 backend
  built on SDL_OpenAudioDeviceStream + an SDL_AudioStreamCallback.
  The engine's existing _audio_callback (Sint16 stereo fill-buffer)
  is kept; a small adapter (sdl3_stream_callback) runs it on a
  scratch buffer and pushes the result via SDL_PutAudioStreamData.
  audio_lock/unlock now call SDL_LockAudioStream / SDL_UnlockAudioStream.

After this commit the binary opens an audio device successfully and
the joystick path resolves real SDL 3 calls. Renderer + audio +
input are now all on SDL 3 with no compat shims.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 22:02:38 +03:00
Ville Lindholm
f11b6516da
WIP: port renderer + supporting layers to SDL 3 (builds clean)
Completes phases 3-6 of the migration plan. After this commit, the
codebase compiles and links against pure SDL 3 (no compat shim). The
binary is unverified at runtime but the build is clean.

Renderer (graphics/gfxengine.{cpp,h}):
- Replace SDL_SetVideoMode + SDL_Flip + page-flip machinery with
  SDL_CreateWindow + SDL_CreateRenderer + a streaming SDL_Texture.
  The CPU-side back buffer (softbuf) is now always ARGB8888; legacy
  HW/double-buffer/page flags are dead.
- flip() does a single full-frame SDL_UpdateTexture + SDL_RenderClear
  + SDL_RenderTexture + SDL_RenderPresent each frame. The dirtyrect
  iteration is retained only to drive widget phys_refresh() callbacks.
- SDL_SetRenderLogicalPresentation gives us letterbox scaling for free.
- SDL_SetRenderVSync replaces glSDL_VSync.
- title()/cursor() ported to SDL 3 window/cursor APIs.

Surface API (graphics/sprite.c, filters.c, window.cpp, sofont.cpp,
region.c):
- SDL_FreeSurface → SDL_DestroySurface
- SDL_FillRect → SDL_FillSurfaceRect
- SDL_SetClipRect → SDL_SetSurfaceClipRect
- SDL_SetColorKey(s, flags, key) → SDL_SetSurfaceColorKey(s, bool, key)
- SDL_SetAlpha(s, flags, a) → SDL_SetSurfaceAlphaMod + BlendMode
- SDL_SetColors → SDL_SetSurfacePalette
- SDL_CreateRGBSurface(...) → SDL_CreateSurface(w, h, format_enum)
- SDL_DisplayFormat[Alpha] → SDL_ConvertSurface(s, ARGB8888)
- SDL_MapRGB(surf->format, ...) → SDL_MapSurfaceRGB(surf, ...)
- surface->format->Field → SDL_GetPixelFormatDetails(surf->format)->field
- surface->format->Amask test → SDL_ISPIXELFORMAT_ALPHA
- surface->clip_rect → SDL_GetSurfaceClipRect

Events (kobo.cpp):
- SDL_{KEYDOWN,KEYUP,QUIT,VIDEOEXPOSE,MOUSE*,JOY*} → SDL_EVENT_*
- SDL_ACTIVEEVENT (with gain check) → SDL_EVENT_WINDOW_FOCUS_LOST
- ev.key.keysym.sym → ev.key.key (.unicode → text input, deferred)
- SDLK_PRINT/SYSREQ → SDLK_PRINTSCREEN; lowercase SDLK_p/y/n → uppercase
- ev.motion.x/y for button events → ev.button.x/y (struct layout differs)
- KMOD_META → SDL_KMOD_GUI
- SDL_INIT_NOPARACHUTE → SDL_Init(0) (no parachute by default in SDL 3)

Keymap (gamectl.{cpp,h}):
- SDLKey → SDL_Keycode
- SDLK_KP{1..9} → SDLK_KP_{1..9}

Stubs deferred for later phases (binary will run but with degraded
behavior):
- sound/audio.c: _start_SDL_output returns -1 immediately; SDL 1.2
  audio callback model needs full rewrite onto SDL_AudioStream.
- kobo.cpp init_js/close_js: SDL 3 joystick API uses instance IDs;
  re-port deferred.
- states.cpp SDL_WM_GrabInput/SDL_EnableUNICODE: need window pointer
  exposed from gfxengine; stubbed.
- gamectl.cpp SDL_EnableKeyRepeat: removed; relies on ev.key.repeat.

Other adjustments:
- options.cpp: GFX_DRIVER_GLSDL menu paths removed; show vsync option
  always (renderer handles it).
- sound/a_wave.c: AUDIO_S8/AUDIO_S16SYS → SDL_AUDIO_S8/S16, SDL_FreeWAV
  → SDL_free.
- gfxengine.cpp: SDL_putenv("SDL_VIDEO_CENTERED=1") obsolete (handled
  by SDL_CreateWindow defaults).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 21:54:55 +03:00
Ville Lindholm
762b095462
WIP: delete glSDL shim, replace with sdl_compat.h
Step 1+2 of the SDL 3 migration. The 2300-line graphics/glSDL.{c,h}
OpenGL-on-top-of-SDL-1.2 shim is obsolete under SDL 3 (SDL_Renderer
does what glSDL did natively), and its #define overrides of SDL
surface APIs collided directly with SDL 3's SDL_oldnames.h.

- Add graphics/sdl_compat.h: a one-line umbrella that just pulls in
  <SDL3/SDL.h>.
- Replace every #include "glSDL.h" with #include "sdl_compat.h" (15
  files across the tree).
- Delete graphics/glSDL.c, graphics/glSDL.h.
- Drop glSDL.c from graphics/CMakeLists.txt.
- Remove GFX_DRIVER_GLSDL from the gfx_drivers_t enum and from all
  switches/conditions in gfxengine.cpp.
- Drop the glSDL_VSync() call site (will be re-introduced as
  SDL_SetRenderVSync once gfxengine is ported to SDL_Renderer).
- Drop the two glSDL_Invalidate() calls in window.cpp (texture
  re-upload hints with no equivalent in a pure-surface compositor).
- options.cpp: remove the now-empty "OpenGL/glSDL" menu item; force
  videodriver to GFX_DRIVER_SDL2D.
- prefs.cpp: collapse legacy GLSDL setting onto SDL2D on load.

After this commit the macro-collision wall is gone (renamed_-token
errors drop from many to zero). The build still fails on the next
layer of work: SDL 1.2 surface APIs that no longer exist
(SDL_FreeSurface, SDL_SetAlpha, SDL_CreateRGBSurface, SDL_DisplayFormat,
SDL_PixelFormat struct member access, SDL audio callback API, etc.).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 21:37:01 +03:00
Ville Lindholm
9b0662865e
WIP: switch build to SDL 3 (does not compile yet)
This is the first commit of the SDL 1.2 -> SDL 3 migration. It lands
the build-system change and the include-path rewrites; the code does
NOT compile against SDL 3 yet, by design. Stays on this branch until
the migration is finished.

- CMakeLists.txt: find_package(SDL3 CONFIG) + SDL3::SDL3 /
  SDL3_image::SDL3_image. Drops the legacy FindSDL machinery.
- glSDL.h, sprite.c, glSDL.c, filters.c, gfxengine.cpp, audio.c:
  rewrite #include "SDL*.h" -> <SDL3/...> / <SDL3_image/...>.

Known wall: graphics/glSDL.{c,h} collides with SDL 3's surface API
renames (SDL_FreeSurface, SDL_FillRect, SDL_SetColorKey,
SDL_SetClipRect, SDL_bool). The next phase deletes the entire glSDL
shim and rewrites graphics/ against SDL_Renderer / SDL_Texture.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 21:23:08 +03:00
Ville Lindholm
9eaf27b297
Migrate build system from autotools to CMake
Replace configure.in + 7 Makefile.am files with a CMake build:
- Top-level CMakeLists.txt with feature detection (SDL 1.2,
  SDL_image, OpenGL, optional OSS/ALSA), platform-specific install
  layouts (macOS .app bundle, Windows simple bundle, Unix), and a
  shared kobo_deps INTERFACE target for flags and link libraries.
- Sub-CMakeLists for graphics/, sound/, eel/ static libraries.
- aconfig.h.cmake.in and Info.plist.cmake.in templates (minimal:
  only the HAVE_* macros actually referenced by the code).

Remove all autotools machinery: configure, configure.in, aclocal.m4,
Makefile.am files, generated Makefile.in files, install-sh, missing,
depcomp, compile, mkinstalldirs, config.guess, config.sub, the
buildpkg.sh Solaris helper, and the cfg-* configure shortcuts.

Update .gitignore for CMake out-of-tree builds, and point
run-kobodl.sh at build/kobodl (overridable via KOBODL_BIN).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 21:08:58 +03:00
Ville Lindholm
be85e999f0
Fix latent bugs and collapse repetition in myship/filemap
- filemap.cpp: fix inverted ternary in getkey() that dereferenced ref
  when ref==NULL; remove dead strncpy in recurse_get(); log a warning
  when addpath() silently truncates keys longer than 8 chars.
- screen.cpp: replace lone strcpy with memcpy.
- enemies.h: brace nested if/else blocks to silence dangling-else
  warnings (no behavior change).
- myship.cpp: replace three 8-case direction switches (movement and
  twice in shot_single) with dir_dx[]/dir_dy[] lookup tables;
  extract free_bolt() helper to deduplicate five copies of the
  boltst/free_obj/NULL pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 20:56:11 +03:00
Ville Lindholm
72d4cd0102
Build on modern macOS
Three source patches the modern clang/C++ frontend requires:
- graphics/window.cpp: strchr on const char* now returns const char*
- filemap.cpp, prefs.cpp: C++11 forbids no-space concatenation of a
  string literal with an adjacent macro identifier

Autotools state regenerated with autoreconf -fi against current
autoconf/automake so configure can be run on macOS 26 / Apple Silicon.

Added run-kobodl.sh to launch the binary from the source tree (the
compiled-in data paths assume a .app bundle), and a .gitignore for
build artifacts.

Out-of-tree dependency: SDL_image 1.2 must be built with
--disable-imageio. Apple's ImageIO backend in IMG_ImageIO.m yields
SDL_Surfaces with all-zero pixel data on current macOS, leaving every
sprite invisible; libpng decodes correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 20:39:48 +03:00
Ville Lindholm
dbc223eb84
Initial commit
Import existing source tree; original VCS history is no longer available.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-28 16:35:31 +03:00