12 Commits
Author SHA1 Message Date
Andreas T Jonsson cf520e172e fix(rpi): decode USB HID modifier bits for Shift/Ctrl/Alt
KeyStatusHandlerRaw in the Circle baremetal kernel dropped the
ucModifiers byte and sized the keyboard state arrays to 0x100 entries,
too small for libretro modifier keycodes (RETROK_LSHIFT=304, etc.).
As a result, holding Shift (or Ctrl/Alt) produced no XT scan code in
the shared frontend, so shifted key combinations never worked.

- Translate ucModifiers bits to RETROK_LCTRL/LSHIFT/LALT/RCTRL/RSHIFT/RALT
  so the existing RETROK_LSHIFT -> 0x2A / RETROK_RSHIFT -> 0x36 mapping
  in src/frontend/core.c fires correctly.
- Resize key_states/key_states_current and the dispatch / input_state
  loops from 0x100 to RETROK_LAST so modifier and other high keycodes
  fit and are not silently truncated.
- Add bounds guard for mapped raw keycodes.

Also stages long-pending packaging fixes in tools/package/rpi/package-rpi.sh
(Pi 4/5 KERNEL_MAX_SIZE bump, Pi 4 family DTBs, disable_splash, [pi400]
and [cm4] stanzas) and updates docs/STATUS.md.

Verified with 'make rpi' for Pi 3/4/5 and the new kernel images
written to /dev/sda1.
2026-06-04 15:27:07 +02:00
Andreas T Jonsson 434c022b8a Restore async disk I/O protocol for USB floppy passthrough
Replaces the synchronous Core 0 bridge with the guest-visible async
polling protocol that was proven working on Pi 3 USB floppy boot.

Core changes:
- Disk controller now handles VXT_DISK_NOT_READY from frontends
- Pending operation state tracks multi-sector transfers
- VXTX BIOS polls port 0xB1 and reads AL/AH from 0xB2/0xB3
- Added floppy_timing / harddrive_timing INI toggles

Circle frontend:
- vfs_read/vfs_write return VXT_DISK_NOT_READY for USB handles
- Core 0 processes blocking USB jobs via usb_disk_process()
- Core 1 BIOS polling loop runs without stalls

Docs:
- Added async completion protocol to SPEC.md
- Updated STATUS.md for verified Pi 3 USB floppy boot

Default Pi config remains safe (no USB passthrough enabled).
2026-06-04 11:40:17 +02:00
Andreas T Jonsson 1c53fea03b Add USB storage passthrough support for Pi baremetal target
Implements lazy-resolution USB block device VFS layer that allows
USB floppy drives and USB sticks to be mounted as raw disk images
via machine.ini paths like A=usbfd: or C=umsd1:.

Key design decisions:
- No startup delay: USB devices are resolved on first I/O, allowing
  POST to begin immediately while USB enumeration happens in background
- Supports both UFI floppy (usbfd:, ufd1:) and bulk-only mass storage
  (usbhd:, umsd1:) device types
- Thread-safe: CSpinLock protects USB handle state across emulation
  and USB interrupt threads
- Zero emulator core changes: all logic in frontend VFS layer
- Handles hot-plug gracefully: device re-resolved on each I/O call

Fixes:
- Correctly uses TRUE for bBlockDevice parameter in GetDevice() calls
  (was FALSE, causing device lookup to always fail)
- Removes problematic pre-boot USB polling that broke keyboard enumeration

Tested on Raspberry Pi 3 Model B+ with USB floppy drive.
2026-05-29 15:00:09 +02:00
Andreas T Jonsson 23af71339a feat(pi): CRT offload to Core 2, 4:3 letterboxing, and peripheral status logging
Pi 3 bare-metal improvements:
- Offload CRT filter to Core 2 via CRT_FILTER_EXTERNAL compile flag.
  Core 1 queues frames; Core 2 worker (RenderThread) processes
  asynchronously with 1-frame latency. Trampoline pattern in crt.c/h.
- Add 4:3 letterboxed scaling on Core 2 render thread.
  HW framebuffer created once at physical display resolution
  (CBcmFrameBuffer auto-detect); largest centered 4:3 rect computed,
  black bars cleared once, nearest-neighbor scale into target rect.
- Raise KERNEL_MAX_SIZE to 0x1400000 (20 MB) across Circle Config.mk,
  kernel Makefile, and package-rpi.sh to accommodate ~19 MB .bss.
- Add vxt_peripheral_print_status() in src/vxt/peripheral.c that logs
  CPU type (8088/V20), frequency, installed peripherals, IO map ranges,
  and memory map ranges. Called from retro_load_game() in core.c.

Refs: docs/STATUS.md
2026-05-27 14:25:50 +02:00
Andreas T Jonsson bdb8512cfa Pi 3 bare-metal bring-up: fix boot blockers and add packaging
Fix four critical issues preventing VirtualXT from booting on Raspberry Pi 3B+:

1. vfs_file_load was a stub returning NULL - implement real VFS-backed
   loader using peripheral arena allocator

2. setup_machine_from_ini never wired disk.file_api - refactor to two
   passes (instantiate + wire APIs, then configure)

3. Missing vfs_tell in Circle kernel - null pointer crash when disk
   mount tried to get file size

4. Libretro VFS seek returns position, but disk module expects POSIX
   0/-1 - add adapter in disk_file_seek

Also:
- Add NO_DEFAULT_DISK and NO_SAMPLES build flags for baremetal size
- Replace GLABIOS.ROM with vxtbios.bin in raspberrypi.ini
- Add package-rpi.sh packaging script with cmdline.txt LOGFILE support
- Raise KERNEL_MAX_SIZE to 17 MB for Circle sysinit
- Clean up kernel error handling (halt() instead of error_halt)
- Update STATUS.md with known bugs and recent changes
2026-05-27 10:12:53 +02:00
Andreas T Jonsson 620364d68e Add Raspberry Pi baremetal build target (make rpi) with Circle kernel 2026-04-30 16:55:30 +02:00
Andreas T Jonsson cfe1746a17 code reset 2026-03-27 17:03:43 +01:00
Andreas T Jonsson 74173a5859 Update copyright year to 2026 2026-01-05 19:58:20 +01:00
Andreas T Jonsson ae556e5697 Fixed RPI build 2025-06-18 15:52:05 +02:00
Andreas T Jonsson 8be4386553 Added more flexible config system 2025-03-16 12:04:14 +01:00
Andreas T Jonsson f61a6bbc86 Fixed memory leak 2025-02-27 21:11:01 +01:00
Andreas T Jonsson 37a1bce70f Added Odin codebase 2025-02-13 12:49:35 +01:00