diff options
| author | Javier Degirolmo | 2013-03-20 22:22:52 -0300 |
|---|---|---|
| committer | Javier Degirolmo | 2013-03-20 22:22:52 -0300 |
| commit | e7617bcf94af9e31655f838bc343f0fea1e80eaa (patch) | |
| tree | 70dc89a7597944ce0bd0812a0e3640f39ab70a47 | |
| parent | da7654b94830523294ecd5fb071bc0eaa06a5087 (diff) | |
PCM is now buffered to improve performance somewhat. Version bumped up to 1.1.
| -rw-r--r-- | README | 12 | ||||
| -rw-r--r-- | built/prog-z80-1.0.bin | bin | 0 -> 4608 bytes | |||
| -rw-r--r-- | built/prog-z80.bin | bin | 4608 -> 4608 bytes | |||
| -rw-r--r-- | src-z80/core/main.z80 | 11 | ||||
| -rw-r--r-- | src-z80/core/vars.z80 | 5 | ||||
| -rw-r--r-- | src-z80/player/pcm.z80 | 169 | ||||
| -rw-r--r-- | tester/core/entry.68k | 2 |
7 files changed, 150 insertions, 49 deletions
@@ -7,12 +7,12 @@ | | |_ |_ ___ | | | | | | | | | |_______ |_ |___| _| | | | | |_ |_____| _| |___________| |________| |___| |___| |_________| - ___ ___ _ _ ___ __ ___ ___ ___ _ ___ ___ _ ___ - | _| | | | | \ | _| | _| | | _| | | | | - | |_| | | | | | | | | | |_| | | |_| | | | |_ _ _ ___ ___ | | | | | - |_ | | | | | | | | | | _| | | | | | | | _| | | | __| _ \ | | | | | - _| | | | | | | | | | | |_| | | | | | | | |_ | | | __| /_ | |_| | | - |___|___|___|_|_|__/ |___|_|_|___|_|_|_|___| \_/|___|_|_\_| |_|_|___| + ___ ___ _ _ ___ __ ___ ___ ___ _ ___ ___ _ _ + | _| | | | | \ | _| | _| | | _| | | | | + | |_| | | | | | | | | | |_| | | |_| | | | |_ _ _ ___ ___ | | | | + |_ | | | | | | | | | | _| | | | | | | | _| | | | __| _ \ | | | | + _| | | | | | | | | | | |_| | | | | | | | |_ | | | __| /_ | |_| | + |___|___|___|_|_|__/ |___|_|_|___|_|_|_|___| \_/|___|_|_\_| |_|_|_| ============================================================================= diff --git a/built/prog-z80-1.0.bin b/built/prog-z80-1.0.bin Binary files differnew file mode 100644 index 0000000..42f33fb --- /dev/null +++ b/built/prog-z80-1.0.bin diff --git a/built/prog-z80.bin b/built/prog-z80.bin Binary files differindex 42f33fb..309036c 100644 --- a/built/prog-z80.bin +++ b/built/prog-z80.bin diff --git a/src-z80/core/main.z80 b/src-z80/core/main.z80 index 82c6bb0..1bd6074 100644 --- a/src-z80/core/main.z80 +++ b/src-z80/core/main.z80 @@ -35,9 +35,7 @@ EntryPoint: ld iyh, $40 exx ; Init PCM playback status - ld bc, $0000 ; B = playing, C = bank - ld de, $0000 ; DE = address - ld hl, $6000 ; HL = always $6000 + ld b, $00 ; Not playing exx ld (ix+0), $2B ; Disable DAC by default @@ -203,7 +201,7 @@ BankSwitch: macro ld (hl), a rrca ld (hl), a - ld (hl), l + ld (hl), h rrca ld (hl), a endm @@ -265,9 +263,10 @@ GetParam: jp z, .noswitchp ld a, c ld (RAM_LastBank), a - exx + push hl + ld hl, $6000 BankSwitch - exx + pop hl .noswitchp: ld b, (hl) ; Get volume diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80 index c1dc8b5..9dcac4b 100644 --- a/src-z80/core/vars.z80 +++ b/src-z80/core/vars.z80 @@ -45,6 +45,9 @@ RAM_Scratch: ds 32 ; Scratch bytes, may be useful when ; buffering to speed up to avoid bank ; switching conflicts + ds $F0-($&$FF), $FF +RAM_PCMBuffer: ds 16 ; PCM buffer + ;**************************************************************************** ; Pointer list starts being stored from here ; $300 (768) bytes are needed to store the pointer list @@ -55,8 +58,6 @@ RAM_Scratch: ds 32 ; Scratch bytes, may be useful when ; RAM_PointerList[$200+n] = bank ;**************************************************************************** - ds $100-($&$FF), $FF - RAM_PointerList: equ $1C00 ;**************************************************************************** diff --git a/src-z80/player/pcm.z80 b/src-z80/player/pcm.z80 index 71b0d72..18527d9 100644 --- a/src-z80/player/pcm.z80 +++ b/src-z80/player/pcm.z80 @@ -19,10 +19,9 @@ PlayPCMBGM: PlayPCM: call GetParam ; Get sample ID - + ld a, b exx ; We'll modify PCM data now - ld b, $01 ; Play PCM! ld h, RAM_PointerList>>8 ; Get offset in pointer list ld l, a @@ -32,10 +31,38 @@ PlayPCM: ld e, (hl) inc h ld c, (hl) + + ld hl, $6000 ; Initial bank switch + ld a, c + ld (RAM_LastBank), a + BankSwitch + + ld h, RAM_PCMBuffer>>8 ; Set buffer where the sample starts + ld a, e + or $F0 + ld l, a + + ld b, l +.load1st: ; Copy initial samples into the buffer + ld a, (de) + ld (hl), a + inc e + inc l + jp nz, .load1st + ld l, b + + ld a, e ; Check if the sample should skip ahead + or a ; already + jp nz, .noskip1st + inc d + jp nz, .noskip1st + ld d, $80 + inc c +.noskip1st: - ld hl, $6000 ; Restore $6000 back to HL - exx ; Back to standard variables - + ld b, $01 ; Play PCM! + exx ; Back to standard registers + ld (ix+0), $2B ; Turn on DAC ld (ix+1), $80 ld (ix+0), $2A @@ -49,43 +76,27 @@ PlayPCM: ;**************************************************************************** UpdatePCM: - ;ld (ix+0), $24 ; Reset timer - ;ld (ix+1), $FE - ;ld (ix+0), $25 - ;ld (ix+1), $03 - - ld (ix+0), $27 - ld (ix+1), $1F - exx ; Switch to PCM registers ld a, b ; Do any playback? or a jr z, .nopcm + +.doagain: + ld (ix+0), $27 ; Acknowledge timer + ld (ix+1), $1F - ld a, (RAM_LastBank) ; Bank switch? - cp c - jp z, .noswitchu - ld a, c - ld (RAM_LastBank), a - BankSwitch -.noswitchu: - - ld a, (de) ; Get sample - inc a ; Is it end of waveform? - jr z, .stop ; If so, stop + ld a, (hl) ; Fetch next sample + inc a ; Check if it's the end of the waveform + jr z, .stop ld (ix+0), $2A ; Nope, send sample to YM2612 ld (ix+1), a - - inc e ; Get address for next sample - jr nz, .nopcm - inc d - jr nz, .nopcm - ld d, $80 - inc c + + inc l ; Update buffer position + jr z, .reload ; Need to buffer more? .nopcm: - exx ; Go back to normal registers + exx ; Switch to normal registers ret ; End of subroutine .stop: @@ -94,9 +105,100 @@ UpdatePCM: ld (ix+1), $80 ld (ix+0), $2B ld (ix+1), $00 - exx ; Go back to normal registers + exx ; Switch to normal registers ret ; End of subroutine +.reload: + ld a, (RAM_LastBank) ; Bank switch if needed + cp c + jp z, .noswitchu + ld a, c + ld (RAM_LastBank), a + ld hl, $6000 + BankSwitch +.noswitchu: + + ld hl, RAM_PCMBuffer ; Load samples into the buffer + + ld a, (de) ; Samples 1~4 + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + + ld a, (de) ; Samples 5~8 + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + + ld a, (de) ; Samples 9~12 + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + + ld a, (de) ; Samples 13~16 + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + ld a, (de) + ld (hl), a + inc l + inc e + + jp nz, .nobankchg ; Update high bytes of address if needed + inc d + jp nz, .nobankchg + ld d, $80 + inc c +.nobankchg: + + ld l, RAM_PCMBuffer&$FF ; Go back to the beginning of the buffer + jp .doagain ; We took so long we should play the next + ; sample already ._.' + ;**************************************************************************** ; StopPCM* ; Stops a PCM sample @@ -126,7 +228,6 @@ StopPCM: ret ; End of subroutine - ;**************************************************************************** ; LockChannelPCM [event $EC] ; Locks the PCM channel diff --git a/tester/core/entry.68k b/tester/core/entry.68k index 361452d..df13b5c 100644 --- a/tester/core/entry.68k +++ b/tester/core/entry.68k @@ -164,7 +164,7 @@ EntryPoint: ; 123456789012345678901234567890123456 @Str_Title1: dc.b "Echo sound engine", 0 -@Str_Title2: dc.b "Version 1.0 by Sik", 0 +@Str_Title2: dc.b "Version 1.1 by Sik", 0 @Str_Instr1: dc.b "Use D-pad to select song", 0 @Str_Instr2: dc.b "A/C: play, B: stop", 0 even |
