Browse Source

vgminfo v1.1: Improved chip detection using hybrid approach

- Fixed missing chip detection (e.g., SN76489 in SHIRAKAW.VGM)
- Fixed false positive detection (e.g., AY-3-8910 in files without it)
- Implemented hybrid detection strategy:
  * Check VGM header clock values (offsets 0x0C, 0x2C, 0x30, 0x74) to
    determine which chip types are present
  * Scan VGM command stream (up to 255 commands) to detect multiple
    instances of same chip type (e.g., '2xSN76489')
- Added VGM version check: only read AY-3-8910 clock for VGM v1.51+
  to avoid false positives from invalid data in earlier versions
- Updated documentation with new detection approach and examples
pull/635/head
jduraes 2 months ago
parent
commit
b55d7a3f72
  1. 120
      Source/Apps/VGM/vgminfo.asm
  2. 83
      Source/Apps/VGM/vgminfo.txt

120
Source/Apps/VGM/vgminfo.asm

@ -8,7 +8,7 @@
; (c) 2025 Joao Miguel Duraes ; (c) 2025 Joao Miguel Duraes
; Licensed under the MIT License ; Licensed under the MIT License
; ;
; Version: 1.0 - 06-Dec-2025
; Version: 1.1 - 06-Dec-2025
; ;
; Assemble with: ; Assemble with:
; TASM -80 -b vgminfo.asm vgminfo.com ; TASM -80 -b vgminfo.asm vgminfo.com
@ -42,7 +42,11 @@ LF .equ 0AH ; line feed
VGM_IDENT .equ 00H ; "Vgm " identifier VGM_IDENT .equ 00H ; "Vgm " identifier
VGM_VERSION .equ 08H ; Version VGM_VERSION .equ 08H ; Version
VGM_SN76489_CLK .equ 0CH ; SN76489 clock (4 bytes, little-endian)
VGM_YM2612_CLK .equ 2CH ; YM2612 clock (4 bytes, little-endian)
VGM_YM2151_CLK .equ 30H ; YM2151 clock (4 bytes, little-endian)
VGM_DATAOFF .equ 34H ; VGM data offset (relative to 0x34) VGM_DATAOFF .equ 34H ; VGM data offset (relative to 0x34)
VGM_AY8910_CLK .equ 74H ; AY-3-8910 clock (4 bytes, little-endian)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; VGM Command codes (subset) ; VGM Command codes (subset)
@ -232,13 +236,116 @@ PAD_DONE:
RET RET
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; Check which chips are used by scanning VGM command stream (first ~100 cmds)
; Check which chips are used: hybrid approach
; 1. Check header clocks to see which chip types are present
; 2. Scan commands to detect multiple instances of same chip type
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
CHECK_CHIPS: CHECK_CHIPS:
; Initialize chip flags ; Initialize chip flags
XOR A XOR A
LD (CHIP_FLAGS), A LD (CHIP_FLAGS), A
LD (CHIP_TYPES), A ; Types present from header
; Check SN76489 clock (4 bytes at 0x0C)
LD HL, VGMBUF+VGM_SN76489_CLK
LD A, (HL)
INC HL
OR (HL)
INC HL
OR (HL)
INC HL
OR (HL)
JR Z, CHK_YM2612_CLK
LD A, (CHIP_TYPES)
OR 01H ; bit 0 = SN76489 present
LD (CHIP_TYPES), A
CHK_YM2612_CLK:
; Check YM2612 clock (4 bytes at 0x2C)
LD HL, VGMBUF+VGM_YM2612_CLK
LD A, (HL)
INC HL
OR (HL)
INC HL
OR (HL)
INC HL
OR (HL)
JR Z, CHK_YM2151_CLK
LD A, (CHIP_TYPES)
OR 02H ; bit 1 = YM2612 present
LD (CHIP_TYPES), A
CHK_YM2151_CLK:
; Check YM2151 clock (4 bytes at 0x30)
LD HL, VGMBUF+VGM_YM2151_CLK
LD A, (HL)
INC HL
OR (HL)
INC HL
OR (HL)
INC HL
OR (HL)
JR Z, CHK_AY_CLK
LD A, (CHIP_TYPES)
OR 04H ; bit 2 = YM2151 present
LD (CHIP_TYPES), A
CHK_AY_CLK:
; Check AY-3-8910 clock (4 bytes at 0x74, only valid in VGM v1.51+)
LD HL, VGMBUF+VGM_VERSION
LD A, (HL) ; Get low byte of version
CP 51H ; Check if >= 0x51 (v1.51)
JR C, START_CMD_SCAN ; Skip if < v1.51
INC HL
LD A, (HL) ; Get high byte
CP 01H ; Must be 0x01
JR NZ, START_CMD_SCAN ; Skip if not v1.xx
LD HL, VGMBUF+VGM_AY8910_CLK
LD A, (HL)
INC HL
OR (HL)
INC HL
OR (HL)
INC HL
OR (HL)
JR Z, START_CMD_SCAN
LD A, (CHIP_TYPES)
OR 08H ; bit 3 = AY present
LD (CHIP_TYPES), A
START_CMD_SCAN:
; If chip type is present, scan commands to detect multiples
; Set base flags from types
LD A, (CHIP_TYPES)
BIT 0, A
JR Z, NO_SN_BASE
LD A, (CHIP_FLAGS)
OR 01H ; Set SN #1
LD (CHIP_FLAGS), A
NO_SN_BASE:
LD A, (CHIP_TYPES)
BIT 1, A
JR Z, NO_YM2612_BASE
LD A, (CHIP_FLAGS)
OR 04H ; Set YM2612 #1
LD (CHIP_FLAGS), A
NO_YM2612_BASE:
LD A, (CHIP_TYPES)
BIT 2, A
JR Z, NO_YM2151_BASE
LD A, (CHIP_FLAGS)
OR 10H ; Set YM2151 #1
LD (CHIP_FLAGS), A
NO_YM2151_BASE:
LD A, (CHIP_TYPES)
BIT 3, A
JR Z, NO_AY_BASE
LD A, (CHIP_FLAGS)
OR 40H ; Set AY #1
LD (CHIP_FLAGS), A
NO_AY_BASE:
; Compute absolute data start within VGMBUF window ; Compute absolute data start within VGMBUF window
LD HL, (VGMBUF+VGM_DATAOFF) LD HL, (VGMBUF+VGM_DATAOFF)
@ -254,8 +361,8 @@ GOT_OFFSET: LD DE, VGMBUF+VGM_DATAOFF
SBC HL, DE ; HL = offset from VGMBUF base SBC HL, DE ; HL = offset from VGMBUF base
ADD HL, DE ; restore HL absolute inside VGMBUF ADD HL, DE ; restore HL absolute inside VGMBUF
; Scan up to 100 commands or until EOD
LD C, 100
; Scan up to 255 commands or until EOD
LD C, 255
SCAN_LOOP: LD A, (HL) SCAN_LOOP: LD A, (HL)
INC HL INC HL
@ -486,7 +593,7 @@ CRLF: LD A, CR
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
MSG_HEADER: .DB CR, LF MSG_HEADER: .DB CR, LF
.DB "VGM Music Chip Scanner v1.0 - 06-Dec-2025", CR, LF
.DB "VGM Music Chip Scanner v1.1 - 06-Dec-2025", CR, LF
.DB "(c)2025 Joao Miguel Duraes - MIT License", CR, LF .DB "(c)2025 Joao Miguel Duraes - MIT License", CR, LF
.DB CR, LF .DB CR, LF
.DB "Filename Chips Used", CR, LF .DB "Filename Chips Used", CR, LF
@ -528,6 +635,9 @@ CHIP_FLAGS: .DB 0 ; Detected chip flags
; bit2 YM2612 #1, bit3 YM2612 #2 ; bit2 YM2612 #1, bit3 YM2612 #2
; bit4 YM2151 #1, bit5 YM2151 #2 ; bit4 YM2151 #1, bit5 YM2151 #2
; bit6 AY #1, bit7 AY #2 ; bit6 AY #1, bit7 AY #2
CHIP_TYPES: .DB 0 ; Chip types present from header
; bit0 SN76489, bit1 YM2612
; bit2 YM2151, bit3 AY-3-8910
; Buffer for VGM header + first data sector (256 bytes) ; Buffer for VGM header + first data sector (256 bytes)
VGMBUF: .FILL 512, 0 VGMBUF: .FILL 512, 0

83
Source/Apps/VGM/vgminfo.txt

@ -0,0 +1,83 @@
VGM File Info Scanner for CP/M
===============================
A utility that scans all .VGM files in the current directory and
displays a table showing which audio chips each file uses.
Version 1.1 uses a hybrid detection approach:
- Checks VGM header clock values to detect chip types
- Scans VGM command stream to detect multiple instances of same chip type
Usage:
------
Simply run the program from a directory containing VGM files:
VGMINFO
No command line arguments are needed. The program will automatically scan
all .VGM files in the current directory.
Output:
-------
The program displays a formatted table with two columns:
- Filename: The name of the VGM file
- Chips Used: A comma-separated list of audio chips used in that file
Supported Chips:
----------------
The program can detect the following audio chips:
- SN76489 (PSG - Programmable Sound Generator)
- YM2612 (FM Synthesis chip used in Sega Genesis/Mega Drive)
- YM2151 (OPM - FM Operator Type-M)
- AY-3-8910 (PSG used in many arcade and home computers)
Example Output:
---------------
VGM Music Chip Scanner v1.1
Filename Chips Used
======== =====================
BGM 2xAY-3-8910
ENDING AY-3-8910
INCHINA YM2612
SHIRAKAW SN76489, YM2612
STARTDEM 2xSN76489, AY-3-8910
WONDER01 2xSN76489
======== =====================
Notes:
------
- The program reads the VGM file headers and scans up to 255 commands from
the VGM data stream for accurate chip detection.
- Files that don't have a valid VGM header are silently skipped.
- Chip detection uses a hybrid approach:
* VGM header clock values (offsets 0x0C, 0x2C, 0x30, 0x74) determine
which chip types are present
* Command stream scanning detects multiple instances (e.g., "2xSN76489")
- AY-3-8910 clock detection respects VGM version - only checked for v1.51+
to avoid false positives from invalid header data in older VGM versions.
Building:
---------
To rebuild from source:
build_vgminfo.cmd
Or manually with TASM:
tasm -t80 -b -g3 -fFF vgminfo.asm vgminfo.com
Author:
-------
Created for RomWBW/CP/M systems
Based on VGM format specification from vgmrips.net
Loading…
Cancel
Save