Amazi-Music

This file is part of and Byte Power December 1986 - January 1987. Download the collection to get this file.
Developer(s): Eric Boisvert
Date: 1987
Type: Program
Platform(s): TS 2068
Tags: Music

AMAZI-MUSIC is a music playback program that loads and executes a machine code music player along with accompanying music data. The program uses two separate CODE blocks: a 450-byte machine code routine starting at address 64902, and 3,443 bytes of music data starting at address 61459. Key parameters of the player are controlled via POKEs to specific addresses, including tempo (64915), main volume (64988), end-note volume (64998), and the address of the music data itself (64897). A sanity check at line 9015 uses PEEK 23681 to verify the machine code loaded correctly before attempting playback via RANDOMIZE USR 65296.


Program Analysis

Program Structure

The BASIC portion of AMAZI-MUSIC is compact, serving primarily as a loader and launcher for external machine code. The REM blocks at lines 1–160 serve as inline documentation for the programmer, listing USR entry points and POKE addresses. The executable logic begins at line 9000 and is intentionally placed at a high line number, likely to keep it out of the way of any future BASIC additions or to co-locate it with the SAVE routine at line 9999.

  1. Lines 1–160: REM documentation block listing all relevant addresses and their purposes.
  2. Line 9000: Clears the screen and prints a loading message.
  3. Line 9010: Loads the machine code player (AMAZIN MC) and music data (MUSIC DATA) from tape.
  4. Line 9015: Sanity check — if PEEK 23681 returns 0, the load is considered failed and the program halts.
  5. Line 9020: Executes the music player via RANDOMIZE USR 65296, then lists and stops.
  6. Line 9999: SAVE block for re-saving the full program suite to tape.

Machine Code Layout

The machine code occupies the upper RAM area, with the player engine at address 64902 (450 bytes) and music data starting at 61459 (3,443 bytes). This places both blocks in high memory, above the normal BASIC/variable area, a common technique to keep machine code safe from BASIC memory management.

AddressPurposeSize / Notes
61459Music data (demo)3,443 bytes
64892Last free byte marker
64897Pointer to music dataPOKE to change song
64902Machine code player start450 bytes
64915Tempo controlRange 0–254
64947End music code
64957Voice open parameterFormat: 7,X
64967Pause code
64988Main volume
64998End note volume
65296USR entry: start music
65309USR entry: end music

Notable Techniques

  • PEEK-based load verification: Line 9015 checks PEEK 23681 against 0 to detect whether the machine code loaded successfully. Address 23681 is in the system variables area, and the machine code presumably writes a non-zero sentinel value there during initialization.
  • RANDOMIZE USR for execution: RANDOMIZE USR 65296 at line 9020 is the standard idiom for calling machine code without needing to handle the return value, as RANDOMIZE discards any integer result gracefully.
  • Parameter exposure via POKE: The REM block documents a clean POKE-based API, allowing users to adjust tempo, volume, voice settings, and even swap in different music data by changing the pointer at 64897 — making the player effectively data-driven.
  • Dual USR entry points: Separate entry points at 65296 (start) and 65309 (end) give BASIC programs fine-grained control over playback lifecycle without reloading the engine.
  • LIST after USR call: The LIST : STOP sequence following RANDOMIZE USR in line 9020 suggests the music player returns to BASIC when finished, at which point the program tidily displays its own listing and halts.

Save Block

Line 9999 packages the entire suite for re-distribution: the BASIC loader saves with LINE 9000 as the auto-run entry point, followed by the machine code block and music data block. The trailing VERIFY ""CODE : VERIFY ""CODE calls confirm both CODE blocks saved correctly, which is good practice given the large size of the music data.

Content

Appears On

Related Products

Related Articles

This program allows you to play any music (MUSIcomp compatible data) during any program, even while programming! The music data...

Related Content

Image Gallery

Source Code

    1 REM                                  AMAZI-MUSIC                     by Eric Boisvert                ©1987 BYTE POWER                                      
   10 
   20 REM  USR CALLS 
   30 REM 65296 START MUSIC
   40 REM 65309 END MUSIC
   50 REM  USEFUL POKE 
   60 REM 64915 TEMPO (0-254)
   70 REM 64988 MAIN VOLUME
   80 REM 64998 END NOTE VOLUME
   90 REM 64947 END MUSIC CODE
  100 REM 64967 PAUSE CODE
  110 REM 64957 VOICE OPEN (7,X)
  120 REM  ADDRESS 
  130 REM 64897 ADDRESS OF MUSIC
  140 
  150 REM 64892 LAST FREE BYTE
  160 
  170 REM 61459 MUSICS [DEMO]
 9000 CLS : PRINT AT 10,0;"STILL LOADING..."''
 9010 LOAD "AMAZIN MC"CODE : LOAD "MUSIC DATA"CODE 
 9015 IF PEEK 23681=0 THEN CLS : LIST 9999: STOP 
 9020 RANDOMIZE USR 65296: LIST : STOP 
 9999 SAVE "AMAZIMUSIC" LINE 9000: SAVE "AMAZIN MC"CODE 64902,450: SAVE "MUSIC DATA"CODE 61459,3443: VERIFY "": VERIFY ""CODE : VERIFY ""CODE 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top