v1.3.7: TinyBASIC file I/O, Makefile unification, timestamp support #26

Merged
bcox merged 13 commits from version-1.3.7 into main 2026-04-12 15:55:08 +00:00
Owner

Summary

  • TinyBASIC file I/O: Added DIR, SAVE, and LOAD commands, giving TinyBASIC programs the ability to list, store, and retrieve files on the S7FS filesystem. LOAD handles multi-cluster files, so programs that outgrow a single cluster no longer vanish into the ether.
  • Filesystem timestamps: File create and write-close operations now stamp the current time from the RTC. Timestamps are truncated to quarter-hour granularity -- not because we are lazy, but because we are parsimonious with bits.
  • ROM syscalls: New STDIO_FILE and STDIO_NOVGA calls let programs redirect PRINT output to a file buffer without cluttering the screen. Handy for SAVE, essential for not annoying the user.
  • Build system overhaul: The justfile has been retired in favor of a unified Makefile covering ROM builds, emulator launch, cross-compilation, RPM/deb packaging, and make clean. One ring to rule them all.

Bug Fixes

  • SYS_FS_WRITE file size: Previously stored sector-aligned sizes, meaning every file looked suspiciously round. Now stores exact byte counts.
  • PRINT_RTC cross-bank address (73e6f59): A stale equate pointed PRINT_RTC into the middle of _ext_color_clear rather than _print_rtc, causing the VGA display to fill with horizontal bar characters (glyph 0x01) at boot -- a bold aesthetic choice, but not an intentional one. Fixed the address and cleaned up leftover debug tracing in the emulator harness.
  • TinyBASIC memory layout overlap: The variable storage region and the BASIC program area were sharing real estate they had no business sharing. Boundaries corrected.

Test Plan

  • Boot the ROM in emu7 and confirm no glyph-0x01 wallpaper at startup.
  • In TinyBASIC: enter a short program, SAVE "TEST", NEW, LOAD "TEST", and verify it round-trips intact.
  • DIR should list files with sizes and timestamps.
  • SAVE a program larger than one cluster, LOAD it back, confirm nothing is truncated.
  • make clean && make all from a fresh checkout; verify ROM, emulator, and packaging targets all complete.
  • Verify make run, make basic, and make forth launch correctly.
## Summary - **TinyBASIC file I/O**: Added `DIR`, `SAVE`, and `LOAD` commands, giving TinyBASIC programs the ability to list, store, and retrieve files on the S7FS filesystem. `LOAD` handles multi-cluster files, so programs that outgrow a single cluster no longer vanish into the ether. - **Filesystem timestamps**: File create and write-close operations now stamp the current time from the RTC. Timestamps are truncated to quarter-hour granularity -- not because we are lazy, but because we are parsimonious with bits. - **ROM syscalls**: New `STDIO_FILE` and `STDIO_NOVGA` calls let programs redirect `PRINT` output to a file buffer without cluttering the screen. Handy for `SAVE`, essential for not annoying the user. - **Build system overhaul**: The justfile has been retired in favor of a unified Makefile covering ROM builds, emulator launch, cross-compilation, RPM/deb packaging, and `make clean`. One ring to rule them all. ## Bug Fixes - **`SYS_FS_WRITE` file size**: Previously stored sector-aligned sizes, meaning every file looked suspiciously round. Now stores exact byte counts. - **`PRINT_RTC` cross-bank address (73e6f59)**: A stale equate pointed `PRINT_RTC` into the middle of `_ext_color_clear` rather than `_print_rtc`, causing the VGA display to fill with horizontal bar characters (glyph 0x01) at boot -- a bold aesthetic choice, but not an intentional one. Fixed the address and cleaned up leftover debug tracing in the emulator harness. - **TinyBASIC memory layout overlap**: The variable storage region and the BASIC program area were sharing real estate they had no business sharing. Boundaries corrected. ## Test Plan - Boot the ROM in `emu7` and confirm no glyph-0x01 wallpaper at startup. - In TinyBASIC: enter a short program, `SAVE "TEST"`, `NEW`, `LOAD "TEST"`, and verify it round-trips intact. - `DIR` should list files with sizes and timestamps. - `SAVE` a program larger than one cluster, `LOAD` it back, confirm nothing is truncated. - `make clean && make all` from a fresh checkout; verify ROM, emulator, and packaging targets all complete. - Verify `make run`, `make basic`, and `make forth` launch correctly.
bcox added 11 commits 2026-04-12 05:03:29 +00:00
_dir_create_entry now writes create_time (offset 18) from the RTC.
_fs5_dir_update_size now writes modify_time (offset 22) on close.
Timestamp format: year-2000, month, day, (hour<<2)|(minute/15).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DIR lists files on disk with sizes and modification timestamps,
like an ls -l.  Supports optional path and drive arguments:

  DIR              root directory on drive 0
  DIR, N           root directory on drive N
  DIR "path"       subdirectory on drive 0
  DIR "path", N    subdirectory on drive N

Output format (43 of 64 columns):
  readme.txt          1234  2026-03-15 14:00
  [docs]                    2026-03-10 09:30

ROM changes: SYS_FS_DIR now accepts B register as a format flag
(B=0 short/names-only, B!=0 long with sizes and timestamps).
Short format is backward-compatible; the monitor $ command now
explicitly sets B=0.  Long-format listing lives in ROM bank 5
(bank 3 had no room).  Subdirectory paths use a two-phase
dispatch: bank 3 resolves the path, bank 5 lists the entries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SAVE writes the current program to a file on disk using the same
argument syntax as DIR (quoted filename, optional drive number):

  SAVE "HELLO.BAS"        save to drive 0
  SAVE "HELLO.BAS", 1     save to drive 1

Implementation reuses the existing LIST logic by routing _putchar
output to a RAM buffer: SAVE sets STDIO_FILE | STDIO_NOVGA in
STDIO_FLAGS, calls _list_all, restores flags, then writes the
buffer to the file via SYS_FS_WRITE.

ROM changes:
- _putchar (console.s) restructured with PUSH CD / LD C,A pattern
  to support four output destinations: VGA (suppressible via
  STDIO_NOVGA), UART0, UART1, and file buffer (STDIO_FILE).
- STDIO_FILE ($04) and STDIO_NOVGA ($08) added to STDIO_FLAGS.
- FILE_PTR at &00:66-67 (overlaps D_CNT/LD_SCAN, safe during
  user programs).
- _detect_mem moved from bank 0 to bank 1 to free space for the
  larger _putchar.

TinyBASIC changes:
- Memory layout bumped: B_VARS to &22:00, B_TIB to &23:00,
  B_PROG_START to &26:00 (code grew past old &20:00 boundary).
- Include order changed: interpreter.s before commands.s so keyword
  strings stay below the variable area.
- SAVE buffer at &50:00 (slot 5, safe across syscalls).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FS_FILE_SIZE was being set to FS_FILE_POS after each sector write,
which always produced a multiple of 512. Now computed once before the
sector loop as FS_FILE_POS + C:D (the caller's exact byte count).

Also fix SAVE to pass byte count (C:D) and buffer pointer (FS_ARG_GH)
to SYS_FS_WRITE — previously omitted, masked by the old per-sector
size update.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge the justfile (dev workflow) and Makefile (release packaging) into
a single Makefile. Dev targets use debug builds for fast iteration;
`make all` and packaging targets use release builds. Bare `make` builds
the ROM, matching the old `just` default.

Key changes:
- BUILD_ROM macro shared between dev `rom` and release `dist-rom`
- Fixes old Makefile rom target (was missing charrom bank 7)
- Parameterized targets: NAME= for examples, FILE= for fmt
- factory-disk/mister-zip converted from bash shebang blocks
- All docs, skills, and agent files updated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adding LOAD (and earlier SAVE/DIR) pushed inline storage variables
past B_TIB's address, causing silent corruption of interpreter state
on every keystroke.  Fix by moving all data regions up 4 pages:
B_VARS &22→&26, B_TIB &23→&27, stacks &24→&28, B_PROG_START &26→&2A.

LOAD "filename" / LOAD "filename", N reads one cluster (2048 cells)
into a buffer at &48:00, scans line by line (handling CR, LF, CRLF),
and inserts each numbered line via b_parse_linenum + b_line_insert.
SAVE now appends a NUL terminator for clean end-of-file detection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
LOAD now reads additional clusters when the scan pointer reaches the
buffer end, handling files of any size.  Lines that straddle a cluster
boundary are handled by refilling the buffer mid-copy while preserving
the partial line already in B_TIB.  The CRLF peek also guards against
reading past the buffer when CR falls on the last byte of a cluster.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix rom symbol
Some checks failed
PR Check / test (pull_request) Failing after 4m41s
PR Check / build-rpm (pull_request) Successful in 28m20s
73e6f59ec8
Fix pr workflow
All checks were successful
PR Check / test (pull_request) Successful in 11m10s
PR Check / build-rpm (pull_request) Successful in 23m17s
33ac72dcc4
Update docs
All checks were successful
PR Check / test (pull_request) Successful in 12m53s
PR Check / build-rpm (pull_request) Successful in 22m51s
f41a1cf358
bcox merged commit 9b60ea05df into main 2026-04-12 15:55:08 +00:00
bcox deleted branch version-1.3.7 2026-04-12 15:55:18 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bcox/sbc7!26
No description provided.