From b04e4b7d1c0d2667f8613b0564264a5fef81afe0 Mon Sep 17 00:00:00 2001 From: Anachronaut Date: Tue, 1 Sep 2026 16:56:17 -0400 Subject: [PATCH] Finish making the tune a program The user's conversion, which I reverted while I was working out whether it was half done or broken. It was half done: an sbx application wants its #Include above #Program, because services.asm ends in a #Vectors block and a #Base written after that has no segment to be the base of. So the include moves up, the bases move a page with everything else, and the test starts it from the shell instead of booting it. It plays for 9,469,987 cycles, 9,423,527 of them waiting, which is the same 567 frames of music it played as a boot image. BEING A PROGRAM MEANS ITS VECTOR IS THE SYSTEM'S TO INSTALL. It brings the screen's, so that it has a beat to play to, and CosmOS puts it in when the tune starts and takes it back out when it stops - a thing a boot image never had to have right, and the second program here to exercise the version two format at all. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW --- Programs/Examples/tune.asm | 8 +++++++- Tests/expected/cosmosCrossDisk.out | 3 ++- Tests/expected/cosmosDrives.out | 3 ++- Tests/expected/cosmosFault.out | 3 ++- Tests/expected/cosmosGrid.out | 3 ++- Tests/expected/cosmosMonitor.out | 3 ++- Tests/expected/cosmosMonitorRun.out | 3 ++- Tests/expected/cosmosRun.out | 3 ++- Tests/expected/cosmosSlowDisk.out | 3 ++- Tests/expected/tune.out | 5 +++++ Tests/input/tune.in | 2 ++ Tests/makedisks.sh | 6 ++++++ Tests/manifest | 7 ++++++- 13 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 Tests/input/tune.in diff --git a/Programs/Examples/tune.asm b/Programs/Examples/tune.asm index 59ddcec..44d9f88 100644 --- a/Programs/Examples/tune.asm +++ b/Programs/Examples/tune.asm @@ -35,8 +35,12 @@ ; that the inner loop is two: the note, and letting go of it. That split is what the selector ; and value registers are for - see Making A Noise in the Programming Manual. +#Include services.asm + #Program + #Base 0x5000 + start: ; ---- The instrument ---- @@ -182,7 +186,7 @@ lastRing: CIF RSTA OUTA 0x35 - HALT + SWI osExit ; Sixty times a second, and it has nothing to do. WAIT only needs something to have happened, ; and this is the something. A handler still has to exist: an interrupt with nothing installed @@ -192,6 +196,8 @@ frame: #Data + #Base 0x3000 + ; ---- Notes and how long they last ---- ; ; Pairs: a MIDI note, then a count of frames. 60 is middle C and every 12 is an octave. A zero diff --git a/Tests/expected/cosmosCrossDisk.out b/Tests/expected/cosmosCrossDisk.out index 4c4a5bd..a935c79 100644 --- a/Tests/expected/cosmosCrossDisk.out +++ b/Tests/expected/cosmosCrossDisk.out @@ -23,6 +23,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -34,7 +35,7 @@ outer.script 376 inner.script 44 loop.script 35 crossed.txt 560 -21 files, 1 directory +22 files, 1 directory > exit halted Execution halted. diff --git a/Tests/expected/cosmosDrives.out b/Tests/expected/cosmosDrives.out index 8885ef3..21fd2b1 100644 --- a/Tests/expected/cosmosDrives.out +++ b/Tests/expected/cosmosDrives.out @@ -13,6 +13,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -23,7 +24,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > drive 1 > dir other.txt 28 diff --git a/Tests/expected/cosmosFault.out b/Tests/expected/cosmosFault.out index 90d8634..586c052 100644 --- a/Tests/expected/cosmosFault.out +++ b/Tests/expected/cosmosFault.out @@ -30,6 +30,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -40,7 +41,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > exit halted Execution halted. diff --git a/Tests/expected/cosmosGrid.out b/Tests/expected/cosmosGrid.out index 40fe56b..ab00e8a 100644 --- a/Tests/expected/cosmosGrid.out +++ b/Tests/expected/cosmosGrid.out @@ -20,6 +20,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -30,7 +31,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > exit halted Execution halted. diff --git a/Tests/expected/cosmosMonitor.out b/Tests/expected/cosmosMonitor.out index 38d53ab..b521dd1 100644 --- a/Tests/expected/cosmosMonitor.out +++ b/Tests/expected/cosmosMonitor.out @@ -106,6 +106,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -116,7 +117,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > exit halted Execution halted. diff --git a/Tests/expected/cosmosMonitorRun.out b/Tests/expected/cosmosMonitorRun.out index 90b821c..a932ae9 100644 --- a/Tests/expected/cosmosMonitorRun.out +++ b/Tests/expected/cosmosMonitorRun.out @@ -25,6 +25,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -35,7 +36,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > exit halted Execution halted. diff --git a/Tests/expected/cosmosRun.out b/Tests/expected/cosmosRun.out index 34b855e..b3462c2 100644 --- a/Tests/expected/cosmosRun.out +++ b/Tests/expected/cosmosRun.out @@ -13,6 +13,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -23,7 +24,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > load load what? > load nosuch.sbx diff --git a/Tests/expected/cosmosSlowDisk.out b/Tests/expected/cosmosSlowDisk.out index da7f5ff..b5d863b 100644 --- a/Tests/expected/cosmosSlowDisk.out +++ b/Tests/expected/cosmosSlowDisk.out @@ -11,6 +11,7 @@ Grid.sbx 559 Press.sbx 872 Mode.sbx 48 Crash.sbx 632 +tune.sbx 306 notes.txt 21 Apps hi.script 121 @@ -21,7 +22,7 @@ nonl.script 38 outer.script 376 inner.script 44 loop.script 35 -20 files, 1 directory +21 files, 1 directory > load Say.sbx loaded, starting at 5000 > run the disk took its time diff --git a/Tests/expected/tune.out b/Tests/expected/tune.out index 6062395..a90c5b3 100644 --- a/Tests/expected/tune.out +++ b/Tests/expected/tune.out @@ -1,2 +1,7 @@ +CosmOS +> tune +finished +> exit +halted Execution halted. [exit 0] diff --git a/Tests/input/tune.in b/Tests/input/tune.in new file mode 100644 index 0000000..be7c59d --- /dev/null +++ b/Tests/input/tune.in @@ -0,0 +1,2 @@ +tune +exit diff --git a/Tests/makedisks.sh b/Tests/makedisks.sh index a7b1bcb..f38feba 100755 --- a/Tests/makedisks.sh +++ b/Tests/makedisks.sh @@ -129,6 +129,12 @@ for i in 1 2 3 4 5 6 7 8; do "$TOOL" put "$DISKS/sbfs.img" "filler$i.txt" >/dev/ "$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \ "$ROOT/Programs/CosmOS/Apps/Crash.asm" -o "$WORK/Crash.sbx" >/dev/null "$TOOL" put "$DISKS/cosmos.img" "$WORK/Crash.sbx" >/dev/null +# tune.sbx, which used to be a boot image and is now a program like any other. It brings a +# vector of its own - the screen's, so that it has a beat to play to - which makes it the +# second thing here that the version two format exists for. +"$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \ + "$ROOT/Programs/Examples/tune.asm" -o "$WORK/tune.sbx" >/dev/null +"$TOOL" put "$DISKS/cosmos.img" "$WORK/tune.sbx" >/dev/null printf 'this is not a program' > notes.txt "$TOOL" put "$DISKS/cosmos.img" notes.txt >/dev/null diff --git a/Tests/manifest b/Tests/manifest index f26d7a7..462f18c 100644 --- a/Tests/manifest +++ b/Tests/manifest @@ -61,7 +61,12 @@ picture | Examples/picture.asm | run | - # music at 16,667 cycles a frame is 9.45 million, so twelve leaves room to lengthen the tune # without coming back here - and a failure saying "cycle limit reached" means somebody added # bars, not that anything broke. -tune | Examples/tune.asm | run | - | 12000000 +# +# IT IS A PROGRAM NOW rather than a boot image, so the shell starts it and the machine it +# plays on is the one somebody would really be sitting at. That also means its vector is +# INSTALLED BY THE SYSTEM and taken back out when it stops, which is a thing a boot image +# never had to have right. +tune | CosmOS/Source/cosmos.asm | run | tune.in | 12000000 | disks/cosmos.img 8bitSieve | Examples/primeSieve/8bitSieve.asm | run | - | - 16bitSegmentedSieve | Examples/primeSieve/16bitSieve.asm | run | - | - # The four pointer rewrite. It emits exactly the same primes as the line above, which