Add Fetch Disks button and Anleitung copy-protection viewer

- Cross-compile nibtools for Android NDK; download all 8 episode disks
  from the Internet Archive C64 Preservation Project as NBZ and convert
  to G64 via JNI (throwaway-pthread to contain nibconv's exit() calls)
- Bundle manual transcription as APK asset; 📖 button opens scrollable
  viewer with Seite→Absatz→Zeile→Wort lookup hierarchy documented
This commit is contained in:
ml
2026-06-27 10:36:15 +02:00
parent aaa6e772a7
commit daefed88b1
16 changed files with 765 additions and 10 deletions
+33 -1
View File
@@ -118,7 +118,8 @@ during development, but nothing in the Gradle build copies them into the APK.
| `C64DisplayView.kt` | SurfaceView — blits 320×200 ARGB framebuffer, scaled with correct aspect ratio |
| `C64KeyboardView.kt` | Multi-touch virtual C64 keyboard; fires `KeyEventListener` on press/release |
| `jni/vice_jni.c` | JNI wrapper — custom VICE video canvas writes frames to `g_framebuf[320×200]` |
| `jni/CMakeLists.txt` | NDK build; conditionally links `libvice.a` when `HAVE_VICE_SRC=1` |
| `jni/nibconv_jni.c` | JNI wrapper around nibtools' nibconv — converts downloaded NIB/NBZ dumps to G64 |
| `jni/CMakeLists.txt` | NDK build; conditionally links `libvice.a`/`libnibtools.a` when their `HAVE_*` flags are set |
### Disk images
@@ -127,3 +128,34 @@ same external files directory as the ROMs (via USB or adb), then load via:
```kotlin
engine.loadDisk(getExternalFilesDir(null)!!.absolutePath + "/schwert_und_magie_1.d64")
```
Alternatively, the in-app **Download Disks** button (next to Import Disks) fetches all
8 episode disks from the Internet Archive's C64 Preservation Project and converts them
to G64 automatically — see "Disk download (nibtools)" below.
### Disk download (nibtools)
The Internet Archive's C64 Preservation Project only has these disks as `.nbz`
(nibtools' compressed raw-GCR NIB format) — not `.d64`. `MainActivity.downloadDisks()`
fetches each of the 8 `.nbz` files (one per disk side) and runs them through nibtools'
`nibconv` to produce G64 images (VICE attaches G64 exactly like D64, detecting the
format from file content, not the extension). G64 was chosen over the lossy D64
reconstruction nibconv also supports, since these old dumps aren't always cleanly
sector-readable — G64 preserves whatever the original drive actually saw.
Only `nibconv`'s pure file-format conversion code is built (`gcr.c prot.c fileio.c
crc.c md5.c lz.c nibconv.c`) — nibtools' hardware-access tools (`nibread`/`nibwrite`,
which talk to a real 1541 over OpenCBM) are not needed and not built. `jni/nibtools_android/`
stubs out the OpenCBM header so the unused declarations that pull it in still compile.
**nibtools compilation is automatic**, the same way as VICE:
1. The Gradle `buildNibtools` task runs before every native CMake build
2. It calls `app/src/main/jni/build_nibtools.sh`, which unpacks `res/nibtools-<rev>.tar.gz`
and cross-compiles the files above into `nibtools-libs/<abi>/libnibtools.a`
3. `CMakeLists.txt` auto-detects the library via `EXISTS` and links it in
nibconv's `main()` is renamed to `nibtools_nibconv_main` at compile time (`-Dmain=...`)
so it can coexist in the same shared library as the JNI entry points. It's invoked
from `nibconv_jni.c` on a throwaway pthread — nibconv calls `exit()` on malformed input,
which is wrapped (`-Wl,--wrap=exit`) to `pthread_exit()` so a bad conversion only kills
that disposable thread, never the app process or the calling JNI thread.