diff --git a/Source/Apps/Build.cmd b/Source/Apps/Build.cmd index 6ead2264..0e27703a 100644 --- a/Source/Apps/Build.cmd +++ b/Source/Apps/Build.cmd @@ -34,6 +34,7 @@ pushd Test && call Build || exit /b & popd pushd ZMP && call Build || exit /b & popd pushd ZMD && call Build || exit /b & popd pushd Dev && call Build || exit /b & popd +pushd VGM && call Build || exit /b & popd copy *.com %APPBIN%\ || exit /b diff --git a/Source/Apps/Clean.cmd b/Source/Apps/Clean.cmd index 88cc92e6..0ee31190 100644 --- a/Source/Apps/Clean.cmd +++ b/Source/Apps/Clean.cmd @@ -15,3 +15,4 @@ pushd Test && call Clean || exit /b 1 & popd pushd ZMP && call Clean || exit /b 1 & popd pushd ZMD && call Clean || exit /b 1 & popd pushd Dev && call Clean || exit /b 1 & popd +pushd VGM && call Clean || exit /b 1 & popd diff --git a/Source/Apps/Makefile b/Source/Apps/Makefile index 5a77bb5e..51060be0 100644 --- a/Source/Apps/Makefile +++ b/Source/Apps/Makefile @@ -1,7 +1,7 @@ OBJECTS = sysgen.com survey.com \ syscopy.com assign.com format.com talk.com mode.com rtc.com \ timer.com rtchb.com -SUBDIRS = XM FDU FAT Tune Test ZMP ZMD Dev +SUBDIRS = XM FDU FAT Tune Test ZMP ZMD Dev VGM DEST = ../../Binary/Apps TOOLS =../../Tools diff --git a/Source/Apps/Tune/Build.cmd b/Source/Apps/Tune/Build.cmd index 8823dc31..6c601548 100644 --- a/Source/Apps/Tune/Build.cmd +++ b/Source/Apps/Tune/Build.cmd @@ -8,7 +8,6 @@ set TASMTABS=%TOOLS%\tasm32 tasm -t180 -g3 -fFF -dWBW tune.asm tune.com tune.lst || exit /b tasm -t180 -g3 -fFF -dZX tune.asm tunezx.com tunezx.lst || exit /b tasm -t180 -g3 -fFF -dMSX tune.asm tunemsx.com tunemsx.lst || exit /b -tasm -t180 -g3 -fFF -dWBW vgmplay.asm vgmplay.com vgmplay.lst || exit /b copy /Y tune*.com ..\..\..\Binary\Apps\ || exit /b copy /Y Tunes\*.* ..\..\..\Binary\Apps\Tunes\ || exit /b \ No newline at end of file diff --git a/Source/Apps/VGM/Build.cmd b/Source/Apps/VGM/Build.cmd new file mode 100644 index 00000000..dff972dd --- /dev/null +++ b/Source/Apps/VGM/Build.cmd @@ -0,0 +1,11 @@ +@echo off +setlocal + +set TOOLS=../../../Tools +set PATH=%TOOLS%\tasm32;%PATH% +set TASMTABS=%TOOLS%\tasm32 + +tasm -t180 -g3 -fFF -dWBW vgmplay.asm vgmplay.com vgmplay.lst || exit /b + +copy /Y VGMPLAY.COM ..\..\..\Binary\Apps\ || exit /b +copy /Y Tunes\*.* ..\..\..\Binary\Apps\Tunes\ || exit /b \ No newline at end of file diff --git a/Source/Apps/VGM/Clean.cmd b/Source/Apps/VGM/Clean.cmd new file mode 100644 index 00000000..07f1d4c3 --- /dev/null +++ b/Source/Apps/VGM/Clean.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal + +if exist *.com del *.com +if exist *.lst del *.lst diff --git a/Source/Apps/VGM/Makefile b/Source/Apps/VGM/Makefile new file mode 100644 index 00000000..a39a9b40 --- /dev/null +++ b/Source/Apps/VGM/Makefile @@ -0,0 +1,14 @@ +OBJECTS = VGMPLAY.COM +DEST = ../../../Binary/Apps +TOOLS = ../../../Tools + +include $(TOOLS)/Makefile.inc + +DEPS := VGMPLAY.ASM $(shell find . -name '*.inc') + +VGMPLAY.COM: $(DEPS) + $(TASM) -dWBW VGMPLAY.ASM VGMPLAY.COM VGMPLAY.LST + +all:: + mkdir -p $(DEST)/Tunes + cp Tunes/* $(DEST)/Tunes diff --git a/Source/Apps/Tune/Tunes/ITSGAMOV.VGM b/Source/Apps/VGM/Tunes/ITSGAMOV.VGM similarity index 100% rename from Source/Apps/Tune/Tunes/ITSGAMOV.VGM rename to Source/Apps/VGM/Tunes/ITSGAMOV.VGM diff --git a/Source/Apps/Tune/Tunes/LEMMIN01.VGM b/Source/Apps/VGM/Tunes/LEMMIN01.VGM similarity index 100% rename from Source/Apps/Tune/Tunes/LEMMIN01.VGM rename to Source/Apps/VGM/Tunes/LEMMIN01.VGM diff --git a/Source/Apps/Tune/Tunes/PENGUI03.VGM b/Source/Apps/VGM/Tunes/PENGUI03.VGM similarity index 100% rename from Source/Apps/Tune/Tunes/PENGUI03.VGM rename to Source/Apps/VGM/Tunes/PENGUI03.VGM diff --git a/Source/Apps/Tune/Tunes/PITFAL02.VGM b/Source/Apps/VGM/Tunes/PITFAL02.VGM similarity index 100% rename from Source/Apps/Tune/Tunes/PITFAL02.VGM rename to Source/Apps/VGM/Tunes/PITFAL02.VGM diff --git a/Source/Apps/Tune/Tunes/TIGER02.VGM b/Source/Apps/VGM/Tunes/TIGER02.VGM similarity index 100% rename from Source/Apps/Tune/Tunes/TIGER02.VGM rename to Source/Apps/VGM/Tunes/TIGER02.VGM diff --git a/Source/Apps/Tune/Tunes/WONDER01.VGM b/Source/Apps/VGM/Tunes/WONDER01.VGM similarity index 100% rename from Source/Apps/Tune/Tunes/WONDER01.VGM rename to Source/Apps/VGM/Tunes/WONDER01.VGM diff --git a/Source/Apps/Tune/VGMPLAY.ASM b/Source/Apps/VGM/VGMPLAY.ASM similarity index 89% rename from Source/Apps/Tune/VGMPLAY.ASM rename to Source/Apps/VGM/VGMPLAY.ASM index 726c5ff0..4181ffa3 100644 --- a/Source/Apps/Tune/VGMPLAY.ASM +++ b/Source/Apps/VGM/VGMPLAY.ASM @@ -5,7 +5,7 @@ ; ; Enhanced with multi-chip support by Marco Maccaferri ; -; YM2162/YM3484, GD3 support added by Phil Summers +; YM2162/YM3484, GD3 support, VGM Chip identification added by Phil Summers ; ; Compile with: ; @@ -242,6 +242,43 @@ EXIT #IFDEF SBCV2004 CALL FASTIO #ENDIF + + LD DE,MSG_PO + CALL PRTSTR + + LD A,(IX+0) + PUSH AF + AND %00000011 + srl a + ADC A,'0' + CALL PRTCHR + LD DE,MSG_SN + CALL PRTSTR + + POP AF + srl a + srl a + PUSH AF + + AND %00000011 + srl a + ADC A,'0' + CALL PRTCHR + LD DE,MSG_AY + CALL PRTSTR + + POP AF + srl a + srl a + PUSH AF + + AND %00000011 + srl a + ADC A,'0' + CALL PRTCHR + LD DE,MSG_YM + CALL PRTSTR + LD A, 9FH ; Mute all channels on psg OUT (PSGREG), A OUT (PSG2REG), A @@ -308,6 +345,7 @@ PLAY #IFDEF SBCV2004 CALL SLOWIO #ENDIF + LD IX,DEV_FLAG LD HL, (VGMPOS) ; Start processing VGM commands NEXT LD A, (HL) INC HL @@ -333,6 +371,8 @@ PSG CP VGM_PSG_W ; Write byte to SN76489. LD A, (HL) INC HL OUT (PSGREG), A + LD IX,DEV_FLAG + SET 0,(IX+0) JR NEXT PSG2 CP 30H ; Write byte to second SN76489. @@ -340,6 +380,8 @@ PSG2 CP 30H ; Write byte to second SN76489. LD A, (HL) INC HL OUT (PSG2REG), A + LD IX,DEV_FLAG + SET 1,(IX+0) JR NEXT ; AY SECTION @@ -355,11 +397,15 @@ AY CP 0A0H LD A, (HL) INC HL OUT (RDAT2), A + LD IX,DEV_FLAG + SET 2,(IX+0) JR NEXT AY1 OUT (RSEL), A LD A, (HL) INC HL OUT (RDAT), A + LD IX,DEV_FLAG + SET 3,(IX+0) JR NEXT ; YM SECTION @@ -373,7 +419,9 @@ YM: CP 052H LD A,(HL) OUT (YMDAT),A INC HL - JR NEXT + LD IX,DEV_FLAG + SET 4,(IX+0) + JP NEXT YM2: CP 053H JR NZ, PCM @@ -384,6 +432,8 @@ YM2: CP 053H LD A,(HL) OUT (YM2DAT),A INC HL + LD IX,DEV_FLAG + SET 4,(IX+0) JP NEXT PCM: @@ -451,6 +501,10 @@ MSG_WELC: .DB "VGM Player for RomWBW v0.1, 8-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 +MSG_PO .DB "Played on : ",0 +MSG_YM: .DB "xYM-2612 ",0 +MSG_SN: .DB "xSN76489 ",0 +MSG_AY: .DB "xAY-3-8910 ",0 ;------------------------------------------------------------------------------ ; Variables @@ -459,9 +513,10 @@ MSG_BADF: .DB "Not a VGM file",CR,LF,0 VGMPOS .DW 0 VGMDLY .DW 0 -OLDSTACK .DW 0 ; original stack pointer - .DS 40H ; space for stack -STACK ; top of stack +DEV_FLAG .DB %00000000 ; 000YAASS +OLDSTACK .DW 0 ; original stack pointer + .DS 40H ; space for stack +STACK ; top of stack ;------------------------------------------------------------------------------ ; VGM data diff --git a/Source/Apps/Tune/VGMPLAY.TXT b/Source/Apps/VGM/VGMPLAY.TXT similarity index 100% rename from Source/Apps/Tune/VGMPLAY.TXT rename to Source/Apps/VGM/VGMPLAY.TXT diff --git a/Source/Apps/VGM/printing.inc b/Source/Apps/VGM/printing.inc new file mode 100644 index 00000000..6d118ea2 --- /dev/null +++ b/Source/Apps/VGM/printing.inc @@ -0,0 +1,175 @@ +; +; Print character in A without destroying any registers +; +PRTCHR: + PUSH BC ; save registers + PUSH DE + PUSH HL + LD E,A ; character to print in E + LD C,$02 ; BDOS function to output a character + CALL BDOS ; do it + POP HL ; restore registers + POP DE + POP BC + RET +; +PRTDOT: +; + ; shortcut to print a dot preserving all regs + PUSH AF ; save af + LD A,'.' ; load dot char + CALL PRTCHR ; print it + POP AF ; restore af + RET ; done +; +PRTCR: +; + ; shortcut to print a carriage return preserving all regs + PUSH AF ; save af + LD A,13 ; load CR value + CALL PRTCHR ; print it + POP AF ; restore af + RET ; done +; +; Print a zero terminated string at (DE) without destroying any registers +; +PRTSTR: + PUSH DE +; +PRTSTR1: + LD A,(DE) ; get next char + OR A + JR Z,PRTSTR2 + CALL PRTCHR + INC DE + JR PRTSTR1 +; +PRTSTR2: + POP DE ; restore registers + RET +; +; Print the value in A in hex without destroying any registers +; +PRTHEX: + PUSH AF ; save AF + PUSH DE ; save DE + CALL HEXASCII ; convert value in A to hex chars in DE + LD A,D ; get the high order hex char + CALL PRTCHR ; print it + LD A,E ; get the low order hex char + CALL PRTCHR ; print it + POP DE ; restore DE + POP AF ; restore AF + RET ; done +; +; print the hex word value in bc +; +PRTHEXWORD: + PUSH AF + LD A,B + CALL PRTHEX + LD A,C + CALL PRTHEX + POP AF + RET +; +; print the hex dword value in de:hl +; +PRTHEX32: + PUSH BC + PUSH DE + POP BC + CALL PRTHEXWORD + PUSH HL + POP BC + CALL PRTHEXWORD + POP BC + RET +; +; Convert binary value in A to ascii hex characters in DE +; +HEXASCII: + LD D,A ; save A in D + CALL HEXCONV ; convert low nibble of A to hex + LD E,A ; save it in E + LD A,D ; get original value back + RLCA ; rotate high order nibble to low bits + RLCA + RLCA + RLCA + CALL HEXCONV ; convert nibble + LD D,A ; save it in D + RET ; done + +; +; Convert low nibble of A to ascii hex +; +HEXCONV: + AND $0F ; low nibble only + ADD A,$90 + DAA + ADC A,$40 + DAA + RET + +; +; Print value of A or HL in decimal with leading zero suppression +; Use prtdecb for A or prtdecw for HL +; +PRTDECB: + PUSH HL + LD H,0 + LD L,A + CALL PRTDECW ; print it + POP HL + RET +; +PRTDECW: + PUSH AF + PUSH BC + PUSH DE + PUSH HL + CALL PRTDEC0 + POP HL + POP DE + POP BC + POP AF + RET +; +PRTDEC0: + LD E,'0' + LD BC,-10000 + CALL PRTDEC1 + LD BC,-1000 + CALL PRTDEC1 + LD BC,-100 + CALL PRTDEC1 + LD C,-10 + CALL PRTDEC1 + LD E,0 + LD C,-1 +PRTDEC1: + LD A,'0' - 1 +PRTDEC2: + INC A + ADD HL,BC + JR C,PRTDEC2 + SBC HL,BC + CP E + RET Z + LD E,0 + CALL PRTCHR + RET +; +; Start a new line +; +CRLF2: + CALL CRLF ; two of them +CRLF: + PUSH AF ; preserve AF + LD A,13 ; + CALL PRTCHR ; print it + LD A,10 ; + CALL PRTCHR ; print it + POP AF ; restore AF + RET