mirror of
https://github.com/wwarthen/RomWBW.git
synced 2026-02-06 22:43:15 -06:00
ym2612 minors
This commit is contained in:
@@ -39,13 +39,11 @@ MBC .equ 4
|
||||
;
|
||||
plt_romwbw .equ 1 ; Build for ROMWBW?
|
||||
plt_type .equ sbcecb ; Select build configuration
|
||||
debug .equ 0
|
||||
|
||||
debug .equ 0 ; Display port, register, config info
|
||||
;
|
||||
#IF (plt_type=custom)
|
||||
RSEL .equ 0D8H ; Primary AY-3-8910 Register selection
|
||||
RDAT .equ 0D0H ; Primary AY-3-8910 Register data
|
||||
RSEL .SET 09AH ; Primary AY-3-8910 Register selection
|
||||
RDAT .SET 09BH ; Primary AY-3-8910 Register data
|
||||
RSEL .equ 09AH ; Primary AY-3-8910 Register selection
|
||||
RDAT .equ 09BH ; Primary AY-3-8910 Register data
|
||||
RSEL2 .equ 88H ; Secondary AY-3-8910 Register selection
|
||||
RDAT2 .equ 89H ; Secondary AY-3-8910 Register data
|
||||
VGMBASE .equ $C0
|
||||
@@ -105,8 +103,8 @@ plt_cpuspd .equ 7 ; Non ROMWBW cpu speed default
|
||||
#ENDIF
|
||||
;
|
||||
#IF (plt_type=sbcecb)
|
||||
RSEL .equ 0D8H ; Primary AY-3-8910 Register selection
|
||||
RDAT .equ 0D0H ; Primary AY-3-8910 Register data
|
||||
RSEL .equ 09AH ; Primary AY-3-8910 Register selection
|
||||
RDAT .equ 09BH ; Primary AY-3-8910 Register data
|
||||
RSEL2 .equ 0A0H ; Secondary AY-3-8910 Register selection
|
||||
RDAT2 .equ 0A1H ; Secondary AY-3-8910 Register data
|
||||
VGMBASE .equ $C0
|
||||
@@ -134,7 +132,7 @@ YMSEL .equ 0C0H ; 11000000 a1=0 a0=0
|
||||
YMDAT .equ 0C1H ; 11000001 a1=0 a0=1
|
||||
YM2SEL .equ 0C2H ; 11000010 a1=1 a0=0
|
||||
YM2DAT .equ 0C3H ; 11000011 a1=1 a0=1
|
||||
PSG1REG .equ 0C6H ; Primary SN76489
|
||||
PSG1REG .equ 0C6H ; Primary SN76489
|
||||
PSG2REG .equ 0C7H ; Secondary SN76489
|
||||
ctcbase .equ 000H ; CTC base address
|
||||
YM2151_SEL1 .equ 0FEH ; Primary YM2151 register selection
|
||||
@@ -203,7 +201,7 @@ RTCIO .equ 070H
|
||||
#DEFCONT \ djnz $-6
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VGM Codes
|
||||
; VGM Codes - see vgmrips.net/wiki/VGM_specification
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
VGM_GG_W .equ 04FH ; GAME GEAR PSG STEREO. WRITE DD TO PORT 0X06
|
||||
@@ -280,32 +278,41 @@ _S1 LD DE, VGMDATA + 34H
|
||||
LD (VGMPOS), HL
|
||||
|
||||
LD HL,D60 ; VGM delay (60hz)
|
||||
LD (VGMDLY), HL
|
||||
|
||||
LD (vdelay), HL
|
||||
;
|
||||
LD IX,VGM_DEV ; IX points to device mask
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
; Play loop
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
MAINLOOP CALL PLAY ; Play one frame
|
||||
;
|
||||
LD HL,KEYCHK ; Check for keypress
|
||||
DEC (HL)
|
||||
JR NZ,NO_CHK
|
||||
;
|
||||
LD C,6 ; Every 256 commands
|
||||
LD E,0FFH
|
||||
CALL BDOS
|
||||
LD E,0FFH ; because HBIOS calls
|
||||
CALL BDOS ; take a long time
|
||||
OR A
|
||||
JR NZ,EXIT
|
||||
NO_CHK:
|
||||
#IF (delay_type==cpu_loop)
|
||||
LD HL,(VGMDLY) ; Frame delay
|
||||
fdelay: .equ $+1
|
||||
lp1: LD B,FRAME_DLY ; 44100 one frame = 0.0000226757 seconds
|
||||
DJNZ $
|
||||
DEC HL
|
||||
LD A,H
|
||||
OR L
|
||||
JR NZ,lp1
|
||||
vdelay: .equ $+1
|
||||
ld hl,vdelay
|
||||
fdelay: .equ $+1
|
||||
lp1: LD B,FRAME_DLY ; 44100 one frame = 0.0000226757 seconds
|
||||
DJNZ $
|
||||
DEC HL
|
||||
LD A,H
|
||||
OR L
|
||||
JP NZ,lp1 ; Normally NZ so jp is faster
|
||||
#ENDIF
|
||||
|
||||
;
|
||||
#IF (delay_type==ctc_poll)
|
||||
LD HL,(VGMDLY) ; Frame delay
|
||||
vdelay: .equ $+1
|
||||
ld hl,vdelay ; Frame delay
|
||||
lp1: in a,(ctcch3) ; wait for counter to reach zero
|
||||
dec a
|
||||
jr nz,lp1
|
||||
@@ -321,13 +328,13 @@ lp3: in a,(ctcch3) ; wait for counter to reach zero
|
||||
DEC HL
|
||||
LD A,H
|
||||
OR L
|
||||
JR NZ,lp1
|
||||
JP NZ,lp1 ; Normally NZ so jp is faster
|
||||
#ENDIF
|
||||
;
|
||||
#IF (delay_type==ctc_int)
|
||||
#ENDIF
|
||||
;
|
||||
JR MAINLOOP
|
||||
JP MAINLOOP
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
; Program Exit
|
||||
@@ -687,7 +694,6 @@ PLAY
|
||||
#IFDEF SBCV2004
|
||||
CALL SLOWIO
|
||||
#ENDIF
|
||||
LD IX,VGM_DEV
|
||||
LD HL, (VGMPOS) ; Start processing VGM commands
|
||||
NEXT LD A, (HL)
|
||||
INC HL
|
||||
@@ -704,13 +710,7 @@ NEXT LD A, (HL)
|
||||
JR NEXT
|
||||
|
||||
NEXT1:
|
||||
; CP VGM_GG_W ; Game Gear SN76489 stereo. Ignored
|
||||
; JR NZ, PSG
|
||||
; LD IX,VGM_DEV
|
||||
; SET 0,(IX+1)
|
||||
; INC HL
|
||||
; JR NEXT
|
||||
|
||||
;
|
||||
; SN76489 SECTION
|
||||
|
||||
PSG CP VGM_PSG1_W ; Write byte to SN76489.
|
||||
@@ -750,9 +750,9 @@ AY1 OUT (RSEL), A
|
||||
OUT (RDAT), A
|
||||
SET 3,(IX+0)
|
||||
JR NEXT
|
||||
|
||||
;
|
||||
; YM2612 SECTION
|
||||
|
||||
;
|
||||
YM2162_1 CP VGM_YM26121_W
|
||||
JR NZ, YM2162_2
|
||||
LD A,(HL)
|
||||
@@ -774,9 +774,9 @@ YM2162_2 CP VGM_YM26122_W
|
||||
INC HL
|
||||
SET 4,(IX+0) ; 2nd channel
|
||||
JP NEXT
|
||||
|
||||
;
|
||||
; YM2151 SECTION
|
||||
|
||||
;
|
||||
YM2151_1 CP VGM_YM21511_W
|
||||
JR NZ,YM2151_2
|
||||
LD A,(HL)
|
||||
@@ -789,7 +789,7 @@ YM2151_1 CP VGM_YM21511_W
|
||||
JP NEXT
|
||||
;
|
||||
YM2151_2 CP VGM_YM21512_W
|
||||
JR NZ,WAITNN
|
||||
JR NZ,GG
|
||||
LD A,(HL)
|
||||
OUT (YM2151_SEL2),A
|
||||
INC HL
|
||||
@@ -798,6 +798,14 @@ YM2151_2 CP VGM_YM21512_W
|
||||
INC HL
|
||||
SET 7,(IX+0)
|
||||
JP NEXT
|
||||
;
|
||||
; GAME GEAR SN76489 STEREO SECTION
|
||||
;
|
||||
GG: CP VGM_GG_W ; Stereo steering port value
|
||||
JR NZ, WAITNN
|
||||
; SET 0,(IX+1)
|
||||
INC HL
|
||||
JP NEXT
|
||||
;
|
||||
WAITNN CP VGM_WNS ; Wait nn samples
|
||||
JR NZ, WAIT60
|
||||
@@ -808,35 +816,43 @@ WAITNN CP VGM_WNS ; Wait nn samples
|
||||
LD (VGMPOS), HL
|
||||
LD L, A
|
||||
LD H, D
|
||||
LD (VGMDLY), HL
|
||||
LD (vdelay), HL
|
||||
RET
|
||||
;
|
||||
WAIT60 CP VGM_W735 ; Wait 735 samples (60Hz)
|
||||
JR NZ, WAIT50
|
||||
LD (VGMPOS), HL
|
||||
LD HL, D60
|
||||
LD (VGMDLY), HL
|
||||
LD (vdelay), HL
|
||||
RET
|
||||
;
|
||||
WAIT50 CP VGM_W882 ; Wait 882 samples (50Hz)
|
||||
JR NZ, WAIT1
|
||||
LD (VGMPOS), HL
|
||||
LD HL, D50
|
||||
LD (VGMDLY), HL
|
||||
WAIT50: CP VGM_W882 ; Wait 882 samples (50Hz)
|
||||
JR NZ, WAIT1
|
||||
LD (VGMPOS), HL
|
||||
LD HL, D50
|
||||
LD (vdelay), HL
|
||||
RET
|
||||
;
|
||||
WAIT1 CP 70H ; WAIT 0-15 SAMPLES
|
||||
WAIT1: CP 70H ; WAIT 0-15 SAMPLES
|
||||
JR C, UNK ; CODES 70-7FH
|
||||
CP 80H
|
||||
JP NC, UNK
|
||||
SUB 6FH
|
||||
LD L, A
|
||||
LD H, 0
|
||||
LD (VGMDLY), HL
|
||||
LD (vdelay), HL
|
||||
RET
|
||||
;
|
||||
UNK: SET 0,(IX+1) ; unknown device
|
||||
INC HL ; Try and skip
|
||||
#IF (debug)
|
||||
ld a,'u' ; Display unknow command
|
||||
call PRTCHR
|
||||
call PRTDOT
|
||||
call PRTHEX
|
||||
ld a,' '
|
||||
call PRTCHR
|
||||
#ENDIF
|
||||
JP NEXT
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -1277,7 +1293,7 @@ MSG_MBC .DB " [mbc] ",0
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
VGMPOS .DW 0
|
||||
VGMDLY .DW 0
|
||||
;VGMDLY .DW 0 ; Saves number of frames to delay
|
||||
KEYCHK .DB 0 ; Counter for keypress checks
|
||||
;
|
||||
VGM_DEV .DB %00000000 ; IX+0 Flags for devices
|
||||
|
||||
@@ -5,30 +5,30 @@ Simple player for VGM (Video Game Music) files.
|
||||
|
||||
Usage:
|
||||
|
||||
VGMPLAY MUSIC[.VGM]
|
||||
VGMPLAY MUSIC[.VGM]
|
||||
|
||||
Supported devices:
|
||||
Press a key to exit the program.
|
||||
|
||||
SN76489
|
||||
AY-3-89810
|
||||
YM2612/YM3484
|
||||
YM2151
|
||||
Supported devices
|
||||
=================
|
||||
|
||||
Default Ports:
|
||||
SN76489
|
||||
AY-3-89810
|
||||
YM2612/YM3484
|
||||
YM2151
|
||||
|
||||
D8H-D0H - First AY-3-8910 (RSEL/RDAT)
|
||||
A0H-A1H - Second AY-3-8910
|
||||
FFH - First SN76489
|
||||
FBH - Second SN76489
|
||||
C6H-C7H - YM2612/YM3484
|
||||
Supported platforms
|
||||
===================
|
||||
|
||||
If your system uses different ports you need to recompile the source.
|
||||
VGM Player is currently being developed on the ROMWBW platform using the Retrobrew computers
|
||||
EBC-SBC-V2 (Z80), ECB-SCG (AY-3-8910) and ECB-VGM (YM2612 and 2xSN76489) board.
|
||||
It can be configured to run with other hardware such as RC2014, P8X180 and nhyodyne MBC.
|
||||
|
||||
Note: The player should be compatible with VGM files up to version 1.51
|
||||
but there are very few controls (if any) in the code, be sure to have
|
||||
a good VGM file that doesn't contain much extra data. These files can be
|
||||
very big, the player is limited to the available TPA space which is
|
||||
typically around 52k.
|
||||
VGM files can be very big and are limited in size by the available TPA space, which is typically 52k.
|
||||
|
||||
Processor speed affects the playback speed. Under ROMWBW the player will detect the cpu speed configuration
|
||||
and adjust timing loops. For other platforms, default speeds are configured but may need to be changed
|
||||
to suit your hardware. Counter/Timer hardware may be supported in future.
|
||||
|
||||
Example Music Files
|
||||
===================
|
||||
@@ -53,4 +53,22 @@ INCHINA.VGM - YM2612 * Double Dragon 3: The Rosetta Stone: In Chin
|
||||
|
||||
* Included in disk images
|
||||
|
||||
Original Source by J.B Langston, Marco Maccaferri, Ed Brindley. ROMWBW version by Phil Summers.
|
||||
VGM sources
|
||||
===========
|
||||
https://www.smspower.org/forums/15359-VGMPacksGameGearMegaCollection
|
||||
https://vgmrips.net/packs/chip/ym2612
|
||||
https://project2612.org/
|
||||
|
||||
VGM Tools
|
||||
=========
|
||||
https://vgmrips.net/wiki/VGMTool
|
||||
https://github.com/vgmrips/vgmtools
|
||||
|
||||
References
|
||||
==========
|
||||
http://www.primrosebank.net/computers/mtx/tools/PD/vgmplayer.zip - Paul Daniels MTX SN76489 interrupt version with embedded VGM tune.
|
||||
https://github.com/jblang/SN76489/blob/master/examples/vgmplayer.asm - J.B. Langston RC2014 polled version with file loading.
|
||||
https://groups.google.com/g/rc2014-z80/c/9nHnETJzGKU - Marco Maccaferri P8X180 & AY-3-8910 support
|
||||
https://github.com/electrified/rc2014-ym2151/tree/main/software/vgmplay - Ed Brindly RC2014 & YM2151 support
|
||||
|
||||
ROMWBW version by Phil Summers. VGM Player is still in development. The ECB-VGM is also still under development.
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
; References:
|
||||
; https://hiddenpalace.org/News/Sega_of_Japan_Sound_Documents_and_Source_Code
|
||||
; https://www.smspower.org/maxim/Documents/YM2612
|
||||
; https://plutiedev.com/blog/20200103
|
||||
; https://www.plutiedev.com/ym2612-registers
|
||||
; https://www.plutiedev.com/ym2612-operations
|
||||
; https://en.wikipedia.org/wiki/Scientific_pitch_notation
|
||||
; https://gendev.spritesmind.net/forum/viewtopic.php?t=2915 (1)
|
||||
; http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2608J.PDF
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
; Octave range is A#0-B7+3/4 HBIOS note 0..343
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -24,14 +29,15 @@ YM2DAT .EQU VGMBASE+03H ; Secondary YM2162 11000011 a1=1 a0=1
|
||||
YM_TONECNT .EQU 6 ; Count number of tone channels
|
||||
YM_NOISECNT .EQU 0 ; Count number of noise channels
|
||||
;
|
||||
YM_PENDING_PERIOD .DW 0 ; PENDING PERIOD (12 BITS) ; ORDER
|
||||
YM_PENDING_VOLUME .DB 0 ; PENDING VOL (8 BITS) ; SIGNIFICANT
|
||||
YM_PENDING_PERIOD .DW 0 ; PENDING PERIOD (12 BITS)
|
||||
YM_PENDING_VOLUME .DB 0 ; PENDING VOL (8 BITS)
|
||||
YM_PENDING_DURATION .DW 0 ; PENDING DURATION (16 BITS)
|
||||
YM_READY .DB 0 ; BIT 0 -> NZ DRIVER IS READY TO RECEIVE PLAY COMMAND
|
||||
; BIT 1 -> NZ EXECUTING WITHIN TIMER HANDLER = DO NOT DIS/ENABLE INT
|
||||
YM_RDY_RST .DB 0 ; FLAG INDICATES IF DEVICE IS IN READY (NZ) OR RESET STATE (Z)
|
||||
YM_DEBUG .EQU 0 ; CHANGE TO 1 TO ENABLE DEBUGGING
|
||||
YM_RSTCFG .EQU 0 ; SET TO 1 FOR FULL REGISTER CLEAR
|
||||
YM_FAST3438 .EQU 0 ; FAST CPU'S WITH A YM3438 MAY REQUIRE A DELAY
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
; Driver function table and instance data
|
||||
@@ -111,10 +117,12 @@ t_loop: ld a,(hl) ; get register to write
|
||||
#ENDIF
|
||||
;
|
||||
dec c ; point back to RSEL port
|
||||
ld b,0 ; check device
|
||||
nready1: in a,(c) ; ready with timeout
|
||||
rlca ;
|
||||
jr nc,ready1 ; bits 7 = busy
|
||||
ld b,0 ;
|
||||
nready1:
|
||||
#IF YM_FAST3438==1) \ cp (ix) \ #ENDIF \ ; ym3438 delay (1)
|
||||
in a,(c) ; check device
|
||||
rlca ; ready with timeout
|
||||
jr nc,ready1 ; bits 7 = busy
|
||||
djnz nready1
|
||||
;
|
||||
; timed out
|
||||
@@ -397,7 +405,7 @@ ym_playcmd09: .db $F0 ; [0] KEY ON
|
||||
.db $00 ; End flag
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
; Quarter semitone values
|
||||
; Quarter semitone F-Number values for frequency
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
ym_notetable: .dw 644 ; C ; 152
|
||||
@@ -497,14 +505,14 @@ ym_cfg_ready: .db part0, 2/2
|
||||
.db $46, $7F
|
||||
;
|
||||
.db part0, 6/2
|
||||
.db $4C, $7f ;$00 ; Channel 1-3
|
||||
.db $4d, $7f ;$00 ; Max volume for operator 4
|
||||
.db $4e, $7f ;$00
|
||||
.db $4C, $00 ; Channel 1-3
|
||||
.db $4d, $00 ; Max volume for operator 4
|
||||
.db $4e, $00
|
||||
;
|
||||
.db part1, 6/2
|
||||
.db $4C, $7f ;$00 ; Channel 4-6
|
||||
.db $4d, $7f ;$00 ; Max volume for operator 4
|
||||
.db $4e, $7f ;$00
|
||||
.db $4C, $00 ; Channel 4-6
|
||||
.db $4d, $00 ; Max volume for operator 4
|
||||
.db $4e, $00
|
||||
;
|
||||
.db part0, 6/2
|
||||
.db $5C, $1F ; Channel 1-3
|
||||
|
||||
Reference in New Issue
Block a user