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

[+] org $0

[+] dc.l $0,$200
dc.l INT,INT,INT,INT,INT,INT,INT ;
dc.l INT,INT,INT,INT,INT,INT,INT,INT ; $24
dc.l INT,INT,INT,INT,INT,INT,INT,INT ; $44
dc.l INT,INT,INT,HBL,INT,VBL,INT,INT ; $64
dc.l INT,INT,INT,INT,INT,INT,INT,INT ; $84
dc.l INT,INT,INT,INT,INT,INT,INT,INT ; $A4
dc.l INT,INT,INT,INT,INT,INT,INT,INT ; $C4
dc.l INT,INT,INT,INT,INT,INT,INT ;

dc.b 'SEGA GENESIS (C) 2005 MERLIX '
dc.b 'ADPCM TEST DEMO 1 '
dc.b 'ADPCM TEST DEMO 1 '
dc.b 'GM 00000000-00',$a5,$fb
dc.b 'JD ',$00,$00,$00,$00,$00,$02,$00,$00
dc.b $00,$ff,$00,$00,$ff,$ff,$ff,$ff,' '
dc.b ' '
dc.b ' '
dc.b 'JUE '

tst.l $a10008
bne SkipJoyDetect?
tst.w $a1000c
SkipJoyDetect:
bne SkipSetup?
lea Table,a5
movem.w (a5)+,d5-d7
movem.l (a5)+,a0-a4
move.b -$10ff(a1),d0 ;Check Version Number
andi.b #$0f,d0
beq WrongVersion?
move.l #$53454741,$2f00(a1) ;Sega Security Code (SEGA)
WrongVersion:
move.w (a4),d0
moveq #$00,d0
movea.l d0,a6
move a6,usp
moveq #$17,d1 ; Set VDP registers
FillLoop:
move.b (a5)+,d5
move.w d5,(a4)
add.w d7,d5
dbra d1,FillLoop?
move.l (a5)+,(a4)
move.w d0,(a3)
move.w d7,(a1)
move.w d7,(a2)
L0250:
btst d0,(a1)
bne L0250
moveq #$25,d2 ; Put initial vaules into a00000
Filla:
move.b (a5)+,(a0)+
dbra d2,Filla
move.w d0,(a2)
move.w d0,(a1)
move.w d7,(a2)
L0262:
move.l d0,-(a6)
dbra d6,L0262
move.l (a5)+,(a4)
move.l (a5)+,(a4)
moveq #$1f,d3 ; Put initial values into c00000
Filc0:
move.l d0,(a3)
dbra d3,Filc0
move.l (a5)+,(a4)
moveq #$13,d4 ; Put initial values into c00000
Fillc1:
move.l d0,(a3)
dbra d4,Fillc1
moveq #$03,d5 ; Put initial values into c00011
Fillc2:
move.b (a5)+,$0011(a3)
dbra d5,Fillc2
move.w d0,(a2)
movem.l (a6),d0-d7/a0-a6
move #$2700,sr
SkipSetup:
bra Continue
Table:
dc.w $8000, $3fff, $0100, $00a0, $0000, $00a1, $1100, $00a1
dc.w $1200, $00c0, $0000, $00c0, $0004, $0414, $302c, $0754
dc.w $0000, $0000, $0000, $812b, $0001, $0100, $00ff, $ff00
dc.w $0080, $4000, $0080, $af01, $d91f, $1127, $0021, $2600
dc.w $f977, $edb0, $dde1, $fde1, $ed47, $ed4f, $d1e1, $f108
dc.w $d9c1, $d1e1, $f1f9, $f3ed, $5636, $e9e9, $8104, $8f01
dc.w $c000, $0000, $4000, $0010, $9fbf, $dfff
INT:
rte

; --- Do nothing for this demo ---
HBL:
rte

; --- Do nothing for this demo ---
VBL:
rte

Continue:
tst.w $00C00004

clr.l a7 ; set stack pointer

move.w #$2300,sr ; user mode

lea $ff0000,a0 ; clear Genesis RAM
moveq #0,d0
clrram: move.w #0,(a0)+
subq.w #2,d0
bne clrram


[+] move.w #$100,$a11100 ; halt the Z80
move.w #$100,$a11200 ; reset it

lea Z80Driver?,a0
lea $a00000,a1
move.l #Z80DriverEnd,d0
move.l #Z80Driver,d1
sub.l d1,d0
Z80loop:
move.b (a0)+,(a1)+
subq.w #1,d0
bne Z80loop

move.w #$0,$a11100 ; enable the Z80


[+] move.l #ADPCMSND,d0
move.l #100,d1
bsr PlaySample?


[+] Forever:
nop
nop
bra Forever


[+] PlaySample:
move.w #$100,$a11100 ; halt the Z80
move.w #$100,$a11200 ; reset it

;Setup to Play Bank1
lea $a00039,a0 ; point to address $39 in Z80
move.b #1,(a0)+ ; Enable start_flag = 1
move.l d0,a1

PlayAgain:
move.w #$100,$a11100 ; Halt Z80

move.w #$400,d2
lea $a00400,a2
move.b #72,(a2)+
move.b #73,(a2)+
PlayLoop1:
;Copy 1024 Bytes
move.b (a1)+,(a2)+
dbra d2,PlayLoop1?

move.b #1,(a0) ; Setup Bank

move.w #$0,$a11100 ; Enable Z80

sub.b #1,d1
beq PlayEnd?
PlayWait10:
move.w #$0,$a11100 ; Enable Z80
PlayWait1:
move.l #$10000,d2
WaitLoop1:
nop
dbra d2,WaitLoop1?

move.w #$100,$a11100 ; Halt Z80
; move.b $a11100,d6
; move.l #$10,d2
; and.b #1,d6
beq PlayWait1?


move.b (a0),d0
move.w #$0,$a11100 ; Enable Z80
cmp.b #0,d0
bne PlayWait1?




;Setup to Play Bank 2
move.w #$100,$a11100 ; Halt Z80

move.w #$400,d2
lea $a00800,a2
; move.b #72,(a2)+
; move.b #73,(a2)+

PlayLoop2: ;Copy 1024 Bytes
move.l (a1)+,(a2)+
dbra d2,PlayLoop2?

move.b #2,(a0) ; Setup Bank

move.w #$0,$a11100 ; Enable Z80

sub.b #1,d1
beq PlayEnd?

PlayWait20:
move.w #$0,$a11100 ; Enable Z80
PlayWait2:
move.l #$10000,d2
WaitLoop2:
nop
dbra d2,WaitLoop2?

move.w #$100,$a11100 ; Halt Z80
; move.b $a11100,d6
; move.l #$10,d2
; and.b #1,d6
beq PlayWait2?


move.b (a0),d0
move.w #$0,$a11100 ; Enable Z80
cmp.b #0,d0
bne PlayWait2?
jmp PlayAgain?


PlayEnd:
rts


[+] Z80Driver:
dc.b $C3,$67,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
dc.b $00,$00,$00,$00,$00,$00,$00,$00,$C9,$00,$00,$00,$01,$01,$01,$01
dc.b $02,$02,$02,$03,$03,$04,$04,$05,$05,$06,$07,$08,$09,$0A,$0B,$0C
dc.b $0E,$0F,$11,$13,$14,$17,$19,$1B,$1E,$21,$25,$28,$2C,$31,$36,$3B
dc.b $41,$48,$4F,$57,$60,$69,$74,$31,$00,$38,$16,$80,$21,$3C,$00,$E5
dc.b $FD,$E1,$3A,$39,$00,$B7,$CA,$72,$00,$3A,$3A,$00,$B7,$CA,$72,$00
dc.b $67,$2E,$00,$7D,$CB,$24,$CB,$24,$2B,$2B,$2B,$E5,$DD,$E1,$21,$00
dc.b $00,$3E,$B4,$32,$02,$40,$3E,$C0,$32,$03,$40,$3E,$2B,$32,$00,$40
dc.b $3E,$80,$32,$01,$40,$01,$FF,$0B,$0B,$DD,$23,$DD,$23,$DD,$23,$0B
dc.b $79,$FE,$00,$C2,$C2,$00,$78,$FE,$00,$C2,$C2,$00,$32,$3A,$00,$C3
dc.b $72,$00,$FD,$5E,$00,$3E,$00,$FD,$2B,$DD,$CB,$01,$46,$CA,$D6,$00
dc.b $7B,$83,$FD,$23,$FD,$23,$DD,$CB,$00,$2E,$D2,$E7,$00,$83,$DD,$CB
dc.b $01,$2E,$D2,$E7,$00,$FD,$23,$5F,$DD,$CB,$02,$2E,$D2,$F9,$00,$7A
dc.b $83,$D2,$00,$01,$3E,$FF,$C3,$00,$01,$7A,$93,$D2,$00,$01,$3E,$00
dc.b $5F,$3E,$B4,$32,$02,$40,$CB,$41,$C2,$10,$01,$3E,$C0,$C3,$12,$01
dc.b $3E,$80,$32,$03,$40,$3E,$2A,$32,$00,$40,$7B,$32,$01,$40,$FD,$E5
dc.b $E1,$7D,$FE,$3C,$D2,$29,$01,$3E,$3C,$FE,$66,$DA,$30,$01,$3E,$66
dc.b $6F,$E5,$FD,$E1,$2E,$00,$79,$E6,$07,$CA,$A8,$00,$C3,$AF,$00,$00

Z80DriverEnd:


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

57 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