Search

in:

Forum: Software Development

Forums > Software Development > GET YOUR Z80 and ADPCM HERE > Re: z80 and ADPCM

Re: z80 and ADPCM


MERLiX posts: 58 3 stars United_Kingdom
BAD VERSION OF THE Z80 DRIVER, HERE FOR HISTORIC REASONS,, MY BITCHING ABOUT THE GENNY...

Last version of the Z80 ADPCM Driver, it should work for all intents and purposes. BUT OFCOURSE IT FREAKING DOESN'T
Whats even anyoing, is I can get it to function, part of the time, but for the rest of the time, I dont know why.

Do with this code what you will, print it out and feed it to your dog, I dont care...

.org 0
jp start
.fill $35,0 ; pad

ret ; z80 interrupt addr $38

PlayBYTE:
.byte 0
BankToPlay:
.byte 0
BankPlay:
.byte 0
Table:
.byte 1,1,1,1,2,2,2,3,3,4,4,5,5,6,7,8,9,10,11,12,14,15,17,19,20
.byte 23,25,27,30,33,37,40,44,49,54,59,65,72,79,87,96,105,116

start:
ld SP,$3800
ld D,$80
ld HL,Table
push hl
pop iy
WaitPlay:
ld a,(PlayBYTE)
or a
jp z,WaitPlay?
ld a,(BankToPlay)
or a
jp z,WaitPlay?
ld h,a
ld L,0
ld A,L

sla H
sla H
dec HL
dec HL
dec HL
push hl
pop ix
ld hl,0

ld a,$b4 ; initialize sound registers
ld ($4002),a ; enable Stereo
ld a,$c0
ld ($4003),a
ld a,$2b ; enable DAC
ld ($4000),a
ld a,$80
ld ($4001),a

ld bc,$BFF

ReadSound: ;Check for end of bank 1024,

next:

inc ix
inc ix
inc ix
SoundLoop:
dec bc
ld a,c
cp 0
jp nz,SoundLoop2?
ld a,b
cp 0
jp nz,SoundLoop2?
ld (BankToPlay),a
jp WaitPlay?
SoundLoop2:
ld e,(iy+0) ;Grab Table Delta
ld a,0 ;This will be used to update the sound
dec iy ;ZERO = -1 on table

bit 0,(ix+1) ;Bit Test *2
jp z,next1
ld A,E
add A,E

inc iy ;2 +1
inc iy ;+1 to compensate for -1
next1:

SRA (ix+0) ;Bit Test *1
jp nc,next2
add A,E
SRA (ix+1) ;Test for +2
jp nc,next2
inc iy ;If so we are +1
next2:

ld e,a

SRA (ix+2) ; Sign Test
jp nc,sb
ld a,d
add A,E
JP NC,play1
LD A,255
jp play1
sb:
ld a,d
sub e
JP NC,play1
LD A,0
play1:
ld e,a
ld a,$b4
ld ($4002),a ; enable Stereo
bit 0,c
jp nz,left
ld a,$c0
jp play2
left:
ld a,$80
play2:
ld ($4003),a ; enable CHANEL

ld a,$2a ; store byte to DAC
ld ($4000),a
ld a,e
ld ($4001),a

;Shift Bytes
;SRA (IX+0)
;SRA (IX+1)
;SRA (IX+2)


;Do Table Overflow
push iy
pop hl
ld a,l
cp $3c
jp nc,tableok
ld a,$3c
tableok:
cp $66
jp c,tableok2
ld a,$66
tableok2:
ld l,a
push hl
pop iy
ld l,0

ld a,c
and 7
jp z,ReadSound?
jp SoundLoop?


.END


Show posts:
Jump to forum:

Current Poll

All your base are belong to us
  • you bet!
  • what?!?
View Results
(Votes: 198)
Cookies must be allowed to vote

Online users

66 online users

Shoutbox

tomman, 09:00 CEST, 2014/04/08: (Note to myself: try Fusion on Debian Jessie...)
tomman, 09:00 CEST, 2014/04/08: Twitter? Social networking? HELL NO :P
Eidolon, 11:05 CET, 2014/03/22: Good to see you around, Steve! Just installing Fusion on my new laptop to enjoy a round of Lunar The Silver Star once again :)
zyrobs, 00:32 CET, 2014/03/08: I would but I can't figure out how Twitter works. Typical Web2.0 BS, optimized for stupid people...
King, 16:59 CET, 2014/02/26: Followed!
sith-smasher, 14:46 CET, 2014/02/22: A sign of Snakey; good that you are ok man! I hope life is treating you better than before. Peace.
Snake, 06:01 CET, 2014/02/20: Everybody in the world follow me on twitter @RealSteveSnake - just because.
King, 20:57 CET, 2014/02/17: SNAKKEEEEEEEE! :D
Snake, 19:21 CET, 2014/02/16: *waves*
King, 18:49 CET, 2014/02/15: Awesome, let him know we miss him and that we're glad he's okay! :)
RSS feed Wiki RSS feed Articles RSS feed Forums