# HG changeset patch # User Laurens Holst # Date 1733156980 -3600 # Mon Dec 02 17:29:40 2024 +0100 # Node ID 94a3a0eb51f790b402f7ae6486bea09757ba91bf # Parent 5b983b6fab187e6c7599c378397693ce048fe4e7 MoonSound: Simplify wave number mapping. The new implementation does away with the mapping table, and instead just masks the instrument number to the 180H-1FFH range. The previous implementation effectively did the same, however it used a lookup table in anticipation of a more complex mapping scheme which never materialized. diff --git a/src/drivers/MoonSound.asm b/src/drivers/MoonSound.asm --- a/src/drivers/MoonSound.asm +++ b/src/drivers/MoonSound.asm @@ -3,15 +3,10 @@ ; MoonSound_FM_BASE_PORT: equ 0C4H MoonSound_WAVE_BASE_PORT: equ 07EH -MoonSound_WAVENUMBERMAP_SIZE: equ 512 MoonSound: MACRO ?fmbase = MoonSound_FM_BASE_PORT this: super: OPL4 ?fmbase, MoonSound_WAVE_BASE_PORT, MoonSound_name - waveNumberMap: - dw 0 - waveNumberMSB: - ds 24 SafeWriteRegister: equ super.SafeWriteRegister SafeWriteRegister2: equ super.SafeWriteRegister2 @@ -24,29 +19,14 @@ cp 38H jr nc,super.SafeWriteRegisterWave cp 20H - jr c,LSB - MSB: - ld c,a - ld b,0 - ld hl,waveNumberMSB - 20H - add hl,bc - ld (hl),d - set 0,d - jr super.SafeWriteRegisterWave + jr nc,MSB LSB: - cp 8H + cp 08H jr c,super.SafeWriteRegisterWave - ld c,a - ld b,0 - ld hl,waveNumberMSB - 8H - add hl,bc - ld a,(hl) - and 1 - ld c,d - ld b,a - ld hl,(waveNumberMap) - add hl,bc - ld d,(hl) + set 7,d + jr super.SafeWriteRegisterWave + MSB: + set 0,d jr super.SafeWriteRegisterWave ENDP @@ -74,39 +54,18 @@ ; ix = this MoonSound_Destruct: - call OPL4_Destruct - ld e,(ix + MoonSound.waveNumberMap) - ld d,(ix + MoonSound.waveNumberMap + 1) - ld a,e - or d - ret z - push ix - ld bc,MoonSound_WAVENUMBERMAP_SIZE - ld ix,Heap_main - call Heap_Free - pop ix - ret + equ OPL4_Destruct ; dehl = size ; ix = this ; iy = reader -MoonSound_ProcessROMDataBlock: +MoonSound_ProcessROMDataBlock: PROC call OPL4_ProcessROMDataBlockHeader ret z exx set 5,e call OPL4_LoadSampleFromReader exx - jr MoonSound_FixUpWaveHeaders - -; dehl = size -; ix = this -; iy = reader -MoonSound_ProcessRAMDataBlock: equ OPL4_ProcessRAMDataBlock -; jp OPL4_ProcessRAMDataBlock - -; ix = this -MoonSound_FixUpWaveHeaders: PROC ld b,128 ld de,0020H ld hl,0000H @@ -119,43 +78,15 @@ add hl,bc pop bc djnz Loop - jr MoonSound_EnableWaveNumberMapping - ENDP - -; ix = this -MoonSound_EnableWaveNumberMapping: - call MoonSound_InitialiseWaveNumberMap ld (ix + MoonSound.SafeWriteRegisterWave + 1),0 ret + ENDP +; dehl = size ; ix = this -MoonSound_InitialiseWaveNumberMap: PROC - ld e,(ix + MoonSound.waveNumberMap) - ld d,(ix + MoonSound.waveNumberMap + 1) - ld a,e - or d - call z,Allocate - ld bc,2 | 00 << 8 ; 512 - ld a,0 -Loop: - or 80H - ld (de),a - inc a - inc de - djnz Loop - dec c - jr nz,Loop - ret -Allocate: - push ix - ld bc,MoonSound_WAVENUMBERMAP_SIZE - ld ix,Heap_main - call Heap_Allocate - pop ix - ld (ix + MoonSound.waveNumberMap),e - ld (ix + MoonSound.waveNumberMap + 1),d - ret - ENDP +; iy = reader +MoonSound_ProcessRAMDataBlock: + equ OPL4_ProcessRAMDataBlock ; ix = this ; iy = drivers