Skip to content

Trigger a sound on MSX1

Reuse a small real effect, understand who stops it, and compare its native output with an omitted-trigger control.

Give an accepted action a sound. The same caller changes its picture and triggers this effect; a second version performs the action with the trigger removed. Listen to both.

Working effect

Trigger omitted

Take the effect

The reusable effect

sound.bas
2000 SOUND 0,100:SOUND 1,0:SOUND 7,62:SOUND 8,15
2010 FOR J=1 TO 200:NEXT J
2020 SOUND 8,0
2030 RETURN

BASIC SOUND writes start PSG tone A using period 100 and mixer operand 62, set volume 15, delay with J, then mute volume A. The routine blocks. Leave firmware/PSG port-direction handling to BASIC; do not transplant the mixer operand as an uncontrolled hardware write.

Copy the 2000-range subroutine and call GOSUB 2000 when the game accepts an action. Keep its global scratch variables and any DATA/setup lines with it. A sound call is a consequence of an action, not a substitute for input validation.

Change it and recognise a mistake

Change the tone period or volume; choose a serviced player when animation/music must continue. The caller lowers BASIC’s allocation ceiling below its diagnostic byte at 40000.

The omitted-trigger control still accepts the action but fails the same audio guard as the working caller. Keyboard clicks or other machine output are not enough: the BASIC checks compare against a separate rejected-command recording.

Deliberately omitted sound trigger

no-sound.bas
10 CLEAR 200,39999
20 N=0:POKE 40000,0
30 CLS:PRINT "TURN";N
31 GOSUB 1000
40 GOSUB 3000
50 IF A$="GO" THEN N=(N+1) AND 255
60 POKE 40000,N
70 GOTO 30
1000 PRINT "XXX"
1010 PRINT "X X"
1020 PRINT "XXX"
1030 RETURN
2000 SOUND 0,100:SOUND 1,0:SOUND 7,62:SOUND 8,15
2010 FOR J=1 TO 200:NEXT J
2020 SOUND 8,0
2030 RETURN
3000 INPUT A$
3010 RETURN

The working implementation above repairs that omission. If an effect instead drones on, check the mute/service path and that its state is initialised. Servicing twice makes a counted effect shorter; servicing only after input can leave it running while the player waits. Those are lifecycle decisions to test when adapting it.

Run the caller

Enter the complete demo.bas in MSX1 BASIC and RUN. Submit GO, then Return. One accepted command advances the displayed turn; another gives two.

MSX1 native caller after accepted input.
Captured from the running caller in the configuration below.

Where setup, trigger and service belong

demo.bas
10 CLEAR 200,39999
20 N=0:POKE 40000,0
30 CLS:PRINT "TURN";N
31 GOSUB 1000
40 GOSUB 3000
50 IF A$="GO" THEN N=(N+1) AND 255:GOSUB 2000
60 POKE 40000,N
70 GOTO 30
1000 PRINT "XXX"
1010 PRINT "X X"
1020 PRINT "XXX"
1030 RETURN
2000 SOUND 0,100:SOUND 1,0:SOUND 7,62:SOUND 8,15
2010 FOR J=1 TO 200:NEXT J
2020 SOUND 8,0
2030 RETURN
3000 INPUT A$
3010 RETURN

Compare blocking, serviced and queued sound when choosing the next step.

Verification and sources

Target: MSX1 NTSC, recorded MSX BASIC/BIOS. These callers were executed with released Emu198x 0.44.1; assembly uses Asm198x 0.0.71. The sample folder contains reproduction instructions and retained observations. The independent checker binds source, native captures and actual output; its rejection tests exercise wrong state, missing files and false audio claims.

This qualifies the named emulator/firmware path. Pitch accuracy, original hardware and other peripherals require their own observations.

ASCII/Microsoft, MSX Technical Data Book: BASIC INPUT, CLEAR, SOUND, GOSUB/RETURN; PSG and BIOS ownership.