From a00a42b24497b9c59eda9294ef9412459eca35f6 Mon Sep 17 00:00:00 2001 From: b1ackmai1er Date: Sat, 27 Nov 2021 19:16:04 +0800 Subject: [PATCH 1/2] Update VGMPLAY.ASM Assume default file name VGM, basic memory protection for large files --- Source/Apps/VGM/VGMPLAY.ASM | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Source/Apps/VGM/VGMPLAY.ASM b/Source/Apps/VGM/VGMPLAY.ASM index 4181ffa3..1ca934fc 100644 --- a/Source/Apps/VGM/VGMPLAY.ASM +++ b/Source/Apps/VGM/VGMPLAY.ASM @@ -5,7 +5,8 @@ ; ; Enhanced with multi-chip support by Marco Maccaferri ; -; YM2162/YM3484, GD3 support, VGM Chip identification added by Phil Summers +; YM2162/YM3484, GD3 support, VGM Chip identification, +; default file type, basic file size checking added by Phil Summers ; ; Compile with: ; @@ -79,6 +80,7 @@ BDOS .EQU 0005H ; bdos entry point FCB .EQU 005CH ; file control block FCBCR .EQU FCB + 20H ; fcb current record BUFF .EQU 0080H ; DMA buffer +TOPM .EQU 0002H ; Top of memory PRINTF .EQU 9 ; BDOS print string function OPENF .EQU 15 ; BDOS open file function @@ -97,17 +99,37 @@ EOS .EQU '$' ; end of string marker LD DE,MSG_WELC ; Welcome Message CALL PRTSTR - LD C,OPENF + LD A,(FCB+1) ; Get first char of filename + CP ' ' ; Compare to blank + JP Z,ERR ; If so, missing filename + LD A,(FCB+9) ; If the filetype + CP ' ' ; is blanks + JR NZ,HASEXT ; then assume + LD A,'V' ; type VGM. + LD (FCB+9),A + LD A,'G' ; Fill in + LD (FCB+10),A ; the file + LD A,'M' ; extension + LD (FCB+11),A + +HASEXT: LD C,OPENF ; Open File LD DE,FCB CALL BDOS INC A - JP Z, ERR + JP Z,ERR XOR A ; Read VGM file into memory LD (FCBCR), A LD DE, VGMDATA LD (VGMPOS), DE -RLOOP LD C, READF +RLOOP +; LD A,(TOPM) ; CBIOS start +; SUB 10h ; Less BDOS = Top Memory Page + LD A,$D6 ; Hardcoded top of memory + CP D + LD DE,MSG_MEM + JP Z,EXIT_ERR ; Exit top of memory reached + LD C, READF LD DE, FCB CALL BDOS OR A @@ -335,7 +357,8 @@ ERR LD C, PRINTF CALL BDOS RST 00H -NOFILE .DB "File not found", CR, LF, EOS +NOFILE .DB "File not found", CR, LF, EOS +MSG_MEM .DB "File to big", CR, LF, EOS MSG_EXIT .DB "FINISHED.",CR,LF,0 ;------------------------------------------------------------------------------ From 32005942e424a90f40160275881d6edd760a6f89 Mon Sep 17 00:00:00 2001 From: b1ackmai1er Date: Sat, 27 Nov 2021 22:28:23 +0800 Subject: [PATCH 2/2] Update VGMPLAY.ASM --- Source/Apps/VGM/VGMPLAY.ASM | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Apps/VGM/VGMPLAY.ASM b/Source/Apps/VGM/VGMPLAY.ASM index 1ca934fc..9c7b747d 100644 --- a/Source/Apps/VGM/VGMPLAY.ASM +++ b/Source/Apps/VGM/VGMPLAY.ASM @@ -273,11 +273,13 @@ EXIT AND %00000011 srl a ADC A,'0' + CP '0' + JR Z,NOSN CALL PRTCHR LD DE,MSG_SN CALL PRTSTR - POP AF +NOSN: POP AF srl a srl a PUSH AF @@ -285,11 +287,13 @@ EXIT AND %00000011 srl a ADC A,'0' + CP '0' + JR Z,NOAY CALL PRTCHR LD DE,MSG_AY CALL PRTSTR - POP AF +NOAY: POP AF srl a srl a PUSH AF @@ -297,11 +301,13 @@ EXIT AND %00000011 srl a ADC A,'0' + CP '0' + JR Z,NOYM CALL PRTCHR LD DE,MSG_YM CALL PRTSTR - LD A, 9FH ; Mute all channels on psg +NOYM: LD A, 9FH ; Mute all channels on psg OUT (PSGREG), A OUT (PSG2REG), A LD A, 0BFH @@ -520,7 +526,7 @@ FASTIO: #INCLUDE "printing.inc" -MSG_WELC: .DB "VGM Player for RomWBW v0.1, 8-Nov-2021",CR,LF +MSG_WELC: .DB "VGM Player for RomWBW v0.2, 27-Nov-2021",CR,LF ; .DB "J.B. Langston/Marco Maccaferri/Phil Summers",CR,LF .DB 0 MSG_BADF: .DB "Not a VGM file",CR,LF,0