MUSIcomp v1.1 is a machine-code music composition application, written by Eric Boisvert and published by Byte Power in 1987. The BASIC portion serves purely as a loader and file-management shell: it calls machine code via RANDOMIZE USR at lines 20 and 9015, with the actual editor residing in RAM above address 43000. The program stores its music data as a separate CODE block (“MUSIcodes”) beginning at address 0x4E4 (1252 decimal) and computes data length dynamically using PEEK 65533–65535 to read values left by the machine-code routine. Save and load routines handle both the full application binary (51485 base) and the data segment independently, with built-in VERIFY passes for tape reliability.
Program Structure
The listing is organised into clearly separated functional blocks, each introduced by a REM label:
- Lines 10–30 — Initialisation: prints to the screen, calls machine code at address 43914, then reads a jump target from
PEEK 65535to dispatch into the running application. - Lines 100–110 — QUIT handler:
CLEAR 65535followed byNEWto wipe the machine-code workspace before resetting. - Lines 150–180 — SAVE full application: saves the CODE block from address 51485 for
lenbytes. - Lines 200–230 — LOAD full application: reloads into the same address.
- Lines 250–280 — SAVE DATA: saves only the music data segment starting at
6E4hex (1764 decimal), length computed aslen-59999. - Lines 300–320 — Shared subroutine for filename input, capped at 10 characters.
- Lines 9000–9020 — Loader: sets display attributes, loads “MUSIcodes” from tape at address
4e4hex, conditionally calls a second USR entry point, then returns to line 30. - Line 9999 — Master SAVE line to write both the BASIC program and the CODE block back to tape, with VERIFY passes.
Machine Code Interface
The program relies on at least two machine-code entry points:
| Address | Usage | Location |
|---|---|---|
| 43914 | Main application entry; presumably sets up the composer UI and writes return data to addresses 65533–65535 | Line 20 |
| 43651 | Alternate entry, used when PEEK 23681 <> 0 (capslock / interface flag test) | Line 9015 |
RANDOMIZE USR is the standard idiom for calling machine code and discarding the return value. The machine-code routine at 43914 communicates back to BASIC by poking three bytes into the top of the 64 KB address space (65533–65535): two bytes encode len as a 16-bit little-endian value, and one byte encodes a GO TO destination line number for dispatch.
Memory Map
| Address (decimal) | Address (hex) | Contents |
|---|---|---|
| 1252 | 0x4E4 | Start of “MUSIcodes” data block (music data) |
| 51485 | 0xC91D | Base of full application CODE block |
| 65533–65534 | 0xFFFD–0xFFFE | Little-endian len written by machine code |
| 65535 | 0xFFFF | Dispatch line target written by machine code |
| 23658 | 0x5C2A | FLAGS2 system variable; POKEd to 8 to set caps-lock state |
| 23681 | 0x5C41 | Tested for non-zero before choosing USR entry point |
Notable Techniques
- Dynamic length calculation:
LET len=PEEK 65533+256*PEEK 65534reads a 16-bit value stored by the machine-code routine, avoiding hardcoding the CODE block length in BASIC. - Computed GO TO:
GO TO PEEK 65535at line 30 allows the machine-code layer to redirect BASIC flow to any line simply by poking one byte — a compact indirect-jump mechanism. - Two CODE segments: The application distinguishes between the executable machine code (base 51485) and the music data (base 0x4E4 = 1764), saving and loading them independently.
- Data length formula:
len-59999at line 270 derives the data-only length by subtracting the offset between the two base addresses (51485 − 1764 ≈ 59999 — actually the fixed gap used as a constant), keeping the formula self-consistent with the dynamically readlen. - Tape verification: Both SAVE routines follow immediately with
VERIFY, a good practice for tape reliability. - Hex literals:
6E4,4e4are written as BASIC numeric literals and evaluated as decimal 1764 and 1252 respectively by the tokeniser — this is not a hexadecimal notation but rather a floating-point representation of the scientific notation 6×10⁴ and 4×10⁴, i.e. 60000 and 40000. See anomaly note below.
Content
Source Code
10 REM MUSIcomp version 1.1 By Eric Boisvert ©1987 BYTE POWER
20 PRINT AT 0,0;: RANDOMIZE USR 43914
30 LET len=PEEK 65533+256*PEEK 65534: GO TO PEEK 65535
100 REM QUIT
110 CLEAR 65535: NEW
150 REM SAVE
160 GO SUB 300
165 IF N$="" THEN GO TO 150
170 SAVE n$CODE 51485,len: PRINT "VERIFY ";n$: VERIFY n$CODE
180 GO TO 10
200 REM LOAD
210 GO SUB 300
220 LOAD N$CODE 51485
230 GO TO 10
250 REM SAVE DATA
260 GO SUB 300: IF N$="" THEN GO TO 250
270 SAVE n$CODE 6E4,len-59999: PRINT "VERIFY ";n$: VERIFY n$CODE
280 GO TO 10
300 REM INPUT NAME
310 CLS : INPUT "FILE NAME:"; LINE n$: IF LEN n$>10 THEN GO TO 310
320 RETURN
9000 REM LOADER
9010 BORDER 7: INK 7: PAPER 7: CLEAR 39999: PRINT AT 10,0; INK 0;"STILL LOADING...": LOAD "MUSIcodes"CODE 4e4: INK 0
9015 IF PEEK 23681<>0 THEN POKE 23658,8: PRINT AT 0,0;: RANDOMIZE USR 43651: GO TO 30
9020 CLEAR : LIST 9999: STOP
9999 SAVE "MUSIcomp" LINE 9000: SAVE "MUSIcodes"CODE 4e4,11155: VERIFY "": VERIFY ""CODE : REM USE 'RUN 9015' TO RUN PROGRAM
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
