In a other topic, BiFi wrote about a bug in the MSX-MUSIC of a Panasonic FS-A1GT.
Quote:
|
Any condition where you do that particular CALL... I also tested it in openMSX with the GT and even there I get it to crash in exactly the same way as the real thing...
I got it every time when I wanted to play my last year's xmas tune entry using that on the GT. I wanted to use the MSX-MUSIC PLAY #2 handler which is synced in both PAL and NTSC... The MSX-BASIC PLAY stuff halts shortly for the next PLAY to handle before it continues playing.
The adapted version which causes the crash can be found here.
|
As part of my project msx system sourcefiles, I have analysed the problem and finally isolated the problem. The MSX-MUSIC is an adapted version of the MSX-MUSIC used in the Panasonic FS-A1ST, but now with the MIDI support. But the MIDI code added is realy crap, and causes the BUGGYXMS.FM program of BiFi to crash.
This problem only occures when a CALL MUSIC is done without any OPLL channel, e.g. CALL MUSIC(0,0) and then a tempo MCL issued (e.g. PLAY"T120"

OR when a program is stopped by CTRL-STOP. In these cases, a crash occurs.
The problem can be avoided by doing a CALL MUSIC(0,0,1) and using the PLAY#0 statement or PLAY#2,"",....... For the real code freaks, here are the two buggy routines:
; Subroutine MCL "T"
; Inputs ________________________
; Outputs ________________________
C$5DBA: JR C,J$5DBE
LD E,120 ; default is tempo 120
J$5DBE: LD A,E
CP 32 ; <32 ?
JR C,J.5DB7 ; yep, illegal function call
LD L,11H
CALL C.7009 ; get pointer in current voicebuffer
CALL C.5F87 ; check for byte value
OR E
JR Z,J.5DB7 ; tempo value 0, illegal function call
LD (HL),A ; tempo
LD C,A
; now some buggy MIDI code
; it never checks if playvoice 0 is a FM/MIDI voice, so if there are only PSG playvoices,
; a unknown packet is queued in the PSG playqueue
;
; The following code should be inserted:
;
; LD A,(D.F97F) ; PLAY MIDI ?
; OR A
; RET Z ; nope, quit
; LD A,(D.F992)
; OR A ; any MIDI playvoices ?
; RET Z ; nope, quit
LD A,(VOICEN) ; current playvoice
CP 0 ; playvoice 0 ?
RET NZ ; nope, quit
LD E,8DH ; midi clock
CALL C.5CE6 ; put byte in queue (DI)
LD E,C
POP BC
JP J.6301 ; put byte in queue and stop parsing when queue is almost full
; Subroutine stop background music
; Inputs ________________________
; Outputs ________________________
C.6BCF: CALL C.6B30
CALL C.6B98
LD A,(D.F992) ; number of OPLL playvoices
CALL C.6BF7
; now some buggy MIDI code
; the case where the number of OPLL/MIDI playvoices is zero is not handled correctly
; and causes a crash!
;
; The following code should be inserted:
;
; LD A,(D.F992) ; any OPLL/MIDI playvoices ?
; OR A
; RET Z ; nope, quit
LD A,(D.F98E)
AND 01H ; in drum mode ?
JR Z,J$6BEB ; nope,
LD A,(D.F992) ; number of OPLL playvoices
DEC A
LD C,0
CALL C.69E0 ; start midi rhythm operation
J$6BEB: LD A,(D.F992) ; number of OPLL playvoices
LD B,A
J$6BEF: LD A,B
DEC A
CALL C$6D5D ; notes off MIDI
DJNZ J$6BEF
RET