Playing 128k Spectrum (AY-3-8912) music on SAM (SAA1099)


From Dan Dooré

Cookies Hot Butter demo used 128K music - source is here: http://home.earthlink.net/~simoncooke/samcoupe/infobase/source/htbtter.txt and there’s a section called “Convert 128k Spectrum (AY-3-8912) music to SAM (SAA1099)” but given the only thing I know about Z80 is how to spell it I couldn’t say much more

From Stefan Drissen

The Cookie AY player is one routine that usually resides in the lower 16k bank. The largest chuck is a lookup table for converting AY frequencies to SAA frequencies (attached).

This routine or modifications (I disassembled it) has been used in all Speccy 128k demo conversions on the SAM.

ORG 0
DUMP 3,$

LD C,255 ;soundchip on
LD B,1
LD A,onoff
OUT (C),A
DEC B
LD A,1
OUT (C),A

DEFS $/256+1*256-$

;the outputs to the AY-3-8912’s registers are intercepted and
;are used as memory mapped i/o

memoryio:

ayfine1: DEFB 0
aycoarse1: DEFB 0
ayfine2: DEFB 0
aycoarse2: DEFB 0
ayfine3: DEFB 0
aycoarse3: DEFB 0
aynoisepitch: DEFB 0
aymixer: DEFB 0
ayvol1: DEFB 0
ayvol2: DEFB 0
ayvol3: DEFB 0
ayenvlength:
ayenvlen: DEFB 0
ayenvlen2: DEFB 0
ayenvshape: DEFB 0

saaouts:
DEFB tone2
saatone2: DEFB 0
DEFB amp2
saaamp2: DEFB 0
DEFB tone3
saatone3: DEFB 0
DEFB amp3
saaamp3: DEFB 0
DEFB oct32
saaoct32: DEFB 0
DEFB tone5
saatone5: DEFB 0
DEFB amp5
saaamp5: DEFB 0
DEFB oct54
saaoct54: DEFB 0
DEFB noisefreq
saanoisefreq: DEFB 0
DEFB freqen
saafreqen: DEFB 0
DEFB noiseen
saanoiseen: DEFB 0
DEFB onoff
DEFB 1

play.it:
LD HL,ayfine1
LD E,(HL) ;ayfine1
INC L
LD A,(HL) ;aycoarse1

AND 15
LD D,A

EX DE,HL
ADD HL,HL
LD DE,pitchconvert
ADD HL,DE

LD A,(HL)
LD (saatone2),A
INC L
LD A,(HL)
LD (stoctave1+1),A

LD HL,ayfine2
LD E,(HL) ;ayfine2
INC HL
LD A,(HL) ;aycoarse2
AND 15
LD D,A

EX DE,HL
ADD HL,HL
LD DE,pitchconvert
ADD HL,DE

LD A,(HL)
LD (saatone3),A
INC L
LD A,(HL)
RLCA
RLCA
RLCA
RLCA
stoctave1: OR 0
LD (saaoct32),A

LD HL,ayfine3
LD E,(HL) ;ayfine3
INC L
LD A,(HL) ;aycoarse3
AND 15
LD D,A

EX DE,HL
ADD HL,HL
LD DE,pitchconvert
ADD HL,DE

LD A,(HL)
LD (saatone5),A
INC L
LD A,(HL)
RLCA
RLCA
RLCA
RLCA
LD (saaoct54),A

LD A,(aynoisepitch)
LD HL,noiseconvert
ADD L
LD L,A
LD A,(HL)
LD (saanoisefreq),A

LD A,(aymixer)
LD DE,0
BIT 0,A
JR NZ,c2nsound
SET 2,D
c2nsound: BIT 3,A
JR NZ,c2nnoise
SET 2,E
c2nnoise: BIT 1,A
JR NZ,c3nsound
SET 3,D
c3nsound: BIT 4,A
JR NZ,c3nnoise
SET 3,E
c3nnoise: BIT 2,A
JR NZ,c5nsound
SET 5,D
c5nsound: BIT 5,A
JR NZ,c5nnoise
SET 5,E
c5nnoise:
LD A,D
LD (saafreqen),A
LD A,E
LD (saanoiseen),A

LD HL,ayvol1
LD A,(HL)
RLCA
RLCA
RLCA
RLCA
OR (HL)
LD (saaamp2),A

INC HL
LD A,(HL) ;chan2vol
RLCA
RLCA
RLCA
RLCA
OR (HL)
LD (saaamp3),A

INC HL ;chan3vol
LD A,(HL)
RLCA
RLCA
RLCA
RLCA
OR (HL)
LD (saaamp5),A

LD BC,&00FF
LD HL,saaouts
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
OUTI
RET

amp0: EQU 0
amp1: EQU 1
amp2: EQU 2
amp3: EQU 3
amp4: EQU 4
amp5: EQU 5

tone0: EQU 8
tone1: EQU 9
tone2: EQU 10
tone3: EQU 11
tone4: EQU 12
tone5: EQU 13

oct10: EQU 16
oct32: EQU 17
oct54: EQU 18

freqen: EQU 20
noiseen: EQU 21
noisefreq: EQU 22

env0: EQU 24
env1: EQU 25

onoff: EQU 28

noiseconvert: DEFB 0,0,0,0,0,0,17,17,17,17,17,17,17,17,17,17,34
DEFB 34,34,34,34,34,34,34,34,34,34,34,34,34,34,34

envconvert: DEFB 132,132,132,132,140,140,140,140
DEFB 134,132,138,130,142,130,138,140

pitchconvert: MDAT “AYtable.bin”

The attached aytable.bin is an 8k file containing the conversions.


AYtable.bin (8 KB)

hi

http://www.youtube.com/user/grad1u5#p/u/108/EZ_ZAPjTV3E

off topic but on tune
rtype for atari st was ay8912
there’s some speccy three channel buzzer toons there too

http://www.youtube.com/user/grad1u5#p/search/3/yxVE1OGlBFE

http://velesoft.speccy.cz/sam_zx128.htm

if it works as a 48SNApshot from nmi of +d isciple maybe can run in last page of this link set external as 1mb and then option two on snapper menu 6mhz above 32768 it vveurkes!but not 128 stuff still

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.