Mercurial > hg > Members > kono > nitros9-code
changeset 1254:5bced1e03639
Changed to new naming convention
author | boisy |
---|---|
date | Sun, 17 Aug 2003 16:25:29 +0000 |
parents | 50d6f82d16d9 |
children | bf6f854a4299 |
files | level2/modules/keydrv.asm level2/modules/keydrv_cc3.asm level2/modules/makefile level2/modules/snddrv.asm level2/modules/snddrv_cc3.asm |
diffstat | 5 files changed, 484 insertions(+), 482 deletions(-) [+] |
line wrap: on
line diff
--- a/level2/modules/keydrv.asm Sun Aug 17 13:05:02 2003 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +0,0 @@ -******************************************************************** -* KeyDrv - Keyboard Driver for CoCo 3 -* -* $Id$ -* -* Ed. Comments Who YY/MM/DD -* ------------------------------------------------------------------ -* 4 L2 Upgrade distribution version -* Annotations by Robert Gault RG 98/10/10 - - nam KeyDrv - ttl Keyboard Driver for CoCo 3 - -* Disassembled 98/09/09 09:02:10 by Disasm v1.6 (C) 1988 by RML - - ifp1 - use defsfile - endc - -tylg set Systm+Objct -atrv set ReEnt+rev -rev set $01 -edition equ 4 - - mod eom,name,tylg,atrv,start,size -size equ . - -name fcs /KeyDrv/ - fcb edition - -start lbra Init init/term; CLRB RTS - lbra Term - lbra FuncKeys test for keys F1, F2 - -ReadKys ldu <D.CCMem CC3IO global memory $1000 - ldx #PIA0Base base address of PIA#1 - clrb - comb - stb $02,x clear all strobe lines - ldb ,x read PIA#1 - comb bit values 0=off 1=on - andb #%00001111 keep only buttons - bne L0059 branch if button pushed; error routine - clr $02,x enable all strobe lines - lda ,x read PIA#1 - coma - anda #%01111111 mask only the joystick conparator - beq L0042 branch if no keys pressed - pshs dp - tfr u,d - tfr a,dp set DP to the address in regU - bsr L005C evaluate the found key matrix - puls dp return to system DP - bpl L005B valid key -L0042 clra regA would have been the found key - ldb <G.CapLok,u CapsLock/SysRq key down flag - bne L0056 - clr <G.KTblLC,u Key table entry# last checked (1-3) - coma - comb - sta <G.LKeyCd,u last keyboard code - sta <G.2Key1,u 2nd key table storage; $FF=none - std <G.2Key2,u format (Row/Column) -L0056 clr <G.CapLok,u see above -L0059 ldb #$FF -L005B rts - -L005C ldx #PIA0Base base value of PIA#1 - clra - clrb - std <G.ShftDn shift/CTRL flag; 0=NO $FF=YES - std <G.KeyFlg PIA bits/ALT flag -* %00000111-Column # (Output, 0-7) -* %00111000-Row # (Input, 0-6) - coma - comb set primary key table - std <G.Key1 key 1&2 flags $FF=none - sta <G.Key3 key 3 ² - deca ie. lda #%11111110 - sta $02,x strobe one column -L006E lda ,x read PIA#1 - coma - anda #$7F keep only keys, bit 0=off 1=on - beq L0082 - ldb #$FF preset counter to -1 -L0077 incb - lsra bit test regA - bcc L007E no key so branch - lbsr L010E convert column/row to matrix value and store it -L007E cmpb #$06 max counter - bcs L0077 loop if more bits to test -L0082 inc <G.KeyFlg counter; used here for column - orcc #Carry bit marker; disable strobe - rol $02,x shift to next column - bcs L006E not finished with columns so loop - lbsr L0166 simultaneous check; recover key matrix value - bmi L00F5 invalid so go - cmpa <G.LKeyCd last keyboard code - bne L0095 - inc <G.KySame same key flag ?counter? -L0095 sta <G.LKeyCd setup for last key pressed - beq L00B5 - suba #$1A the key value (matrix) of Z - bhi L00B5 not a letter so go - adda #$1A restore regA - ldb <G.CntlDn CTRL flag - bne L00E0 CTRL is down so go - adda #$40 convert to ASCII value; all caps - ldb <G.ShftDn shift key flag - ldy <G.CurDev get current device static memory pointer - eorb <$21,y caps lock and keyboard mouse flags - andb #$01 test caps flag - bne L00E0 not shifted so go - adda #$20 convert to ASCII lower case - bra L00E0 -* key is not a letter; this routine is not based on some underlining principle of -* the keyboard hardware. It is also a function of the decode table at $1DC,pcr. -L00B5 ldb #$03 - mul regB = (key#-26) times 3 - lda <G.ShftDn shift key flag - beq L00BF not shifted so go - incb - bra L00C5 -L00BF lda <G.CntlDn CTRL flag - beq L00C5 - addb #$02 -L00C5 ldx <G.CurDev point regX to devices static memory - lda <$22,x key sense flag - beq L00D0 not set so go - cmpb #$11 spacebar - ble L00F3 must be an arrow so go -L00D0 cmpb #$4C SHIFTed ALT key - blt L00D8 not ALT, CTRL, F1, F2, or SHIFT so go - inc <G.AltDwn flag special keys (ALT,CTRL) - subb #$06 -L00D8 leax >L01DC,pcr decode table - lda b,x - bmi L00F6 if regA = $81 - $84 -* several entries to this routine from any key press; regA is already ASCII -L00E0 ldb <G.AltDwn was ALT flagged? - beq L00F0 no so go - cmpa #$3F ? - bls L00EE # or code - cmpa #$5B [ - bcc L00EE capital letter so go - ora #$20 convert to lower case -L00EE ora #$80 set for ALT characters -L00F0 andcc #^Negative not negative - rts -L00F3 orcc #Negative set negative -L00F5 rts -L00F6 inc <G.CapLok caps lock/SysRq - inc <G.Clear one shot caps lock/SysRq - bra L00F0 -L00FC pshs b,a convert column into power of 2 - clrb - orcc #Carry - inca -L0102 rolb - deca - bne L0102 - bra L0108 WHY IS THIS HERE?? -L0108 orb <G.KySns previous value of column - stb <G.KySns - puls pc,b,a -L010E pshs b,a - cmpb #$03 is it row 3? - bne L011C - lda <G.KeyFlg get column # - cmpa #$03 is it column 3?; ie up arrow - blt L011C if lt must be a letter - bsr L00FC its a non letter so bsr -L011C lslb B*8 8 keys per row - lslb - lslb - addb <G.KeyFlg add in the column # - cmpb #$33 ALT - bne L012B - inc <G.AltDwn ALT down flag - ldb #$04 - bra L0108 -L012B cmpb #$34 CTRL - bne L0135 - inc <G.CntlDn CTRL down flag - ldb #$02 - bra L0108 -L0135 cmpb #$37 shift key - bne L013F - com <G.ShftDn shift down flag - ldb #$01 - bra L0108 -* check how many key (1-3) are currently being pressed -L013F pshs x - leax <$2D,u 1st key table - bsr L014A - puls x - puls pc,b,a -L014A pshs a - lda ,x - bpl L0156 - stb ,x - ldb #$01 - puls pc,a -L0156 lda $01,x - bpl L0160 - stb $01,x - ldb #$02 - puls pc,a -L0160 stb $02,x - ldb #$03 - puls pc,a -* simlutaneous key test -L0166 pshs y,x,b - ldb <G.KTblLC key table entry# - beq L019D - leax <$2A,u point to 2nd key table - pshs b -L0171 leay <$2D,u 1st key table - ldb #$03 - lda ,x get key#1 - bmi L018F go if invalid? (no key) -L017A cmpa ,y is it a match? - bne L0184 go if not a matched key - clr ,y - com ,y set value to $FF - bra L018F -L0184 leay $01,y - decb - bne L017A - lda #$FF - sta ,x - dec <G.KTblLC key table entry# -L018F leax $01,x - dec ,s column counter - bne L0171 - leas $01,s - ldb <G.KTblLC key table entry (can test for 3 simul keys) - beq L019D - bsr L01C4 -L019D leax <$2D,u 1st key table - lda #$03 -L01A2 ldb ,x+ - bpl L01B5 - deca - bne L01A2 - ldb <G.KTblLc key table entry (can test for 3 simul keys) - beq L01C0 - decb - leax <$2A,u 2nd key table - lda b,x - bra L01BE -L01B5 tfr b,a - leax <$2A,u 2nd key table - bsr L014A - stb <G.KTblLC -L01BE puls pc,y,x,b -L01C0 orcc #Negative flag negative - puls pc,y,x,b -L01C4 leax <$2A,u - bsr L01CF - leax $01,x - bsr L01CF - leax -$01,x -L01CF lda ,x - bpl L01DB - ldb $01,x - bmi L01DB - sta $01,x - stb ,x -L01DB rts -* These seem to be special key combination values; 3 per key in ASCII -*L01DC fcb @,shift@,nul -* fcb up,shifted,CTRL -* fcb down, shifted, CTRLed -* fcb left, shifted, CTRLed -* fcb right, shifted, CTRLed -* fcb spacebar, spacebar, spacebar -* fcb 0,0,$81 signal shiftlock change -* fcb 1,!,| -* fcb 2,,null -* fcb 3,#,~ -* fcb 4,$,null -* fcb 5,%,null -* fcb 6,&,null -* fcb 7,,^ -* fcb 8,(,[ -* fcb 9,),] -* fcb :,*,null -* fcb ;,+,DEL -* fcb ,,<,{ -* fcb -,=,_ -* fcb .,>,} -* fcb /,?,\ -* fcb ENTER,ENTER,ENTER -* I think these are for ALT -* fcb $82,$83,$84 -* fcb ENQ,BREAK,ESC -* the next I think are for the F1 and F2 keys -* fcb 1,3,5 -* fcb 2,4,6 -L01DC fdb $4060,$000c,$1c13,$0a1a,$1208,$1810,$0919,$1120 - fdb $2020,$3030,$8131,$217c,$3222,$0033,$237e,$3424 - fdb $0035,$2500,$3626,$0037,$275e,$3828,$5b39,$295d - fdb $3a2a,$003b,$2b7f,$2c3c,$7b2d,$3d5f,$2e3e,$7d2f - fdb $3f5c,$0d0d,$0d82,$8384,$0503,$1b31,$3335,$3234 - fcb $36 - -Init -Term clrb - rts - -FuncKeys ldu <D.CCMem - ldx #PIA0Base - clra - ldb #%11011111 strob column #6 PIA#1 - stb $02,x - ldb ,x read PIA#1 - bitb #%01000000 test for F1 function key - bne L0240 - inca flag F1 -L0240 ldb #%10111111 strobe column #7 PIA#1 - stb $02,x - ldb ,x read PIA#1 - bitb #%01000000 test for F2 function key - bne L024C - ora #$04 flag F2 -L024C rts - - emod -eom equ * - end - -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level2/modules/keydrv_cc3.asm Sun Aug 17 16:25:29 2003 +0000 @@ -0,0 +1,333 @@ +******************************************************************** +* KeyDrv - Keyboard Driver for CoCo 3 +* +* $Id$ +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 4 L2 Upgrade distribution version +* Annotations by Robert Gault RG 98/10/10 + + nam KeyDrv + ttl Keyboard Driver for CoCo 3 + +* Disassembled 98/09/09 09:02:10 by Disasm v1.6 (C) 1988 by RML + + ifp1 + use defsfile + endc + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set $01 +edition equ 4 + + mod eom,name,tylg,atrv,start,size +size equ . + +name fcs /KeyDrv/ + fcb edition + +start lbra Init init/term; CLRB RTS + lbra Term + lbra FuncKeys test for keys F1, F2 + +ReadKys ldu <D.CCMem CC3IO global memory $1000 + ldx #PIA0Base base address of PIA#1 + clrb + comb + stb $02,x clear all strobe lines + ldb ,x read PIA#1 + comb bit values 0=off 1=on + andb #%00001111 keep only buttons + bne L0059 branch if button pushed; error routine + clr $02,x enable all strobe lines + lda ,x read PIA#1 + coma + anda #%01111111 mask only the joystick conparator + beq L0042 branch if no keys pressed + pshs dp + tfr u,d + tfr a,dp set DP to the address in regU + bsr L005C evaluate the found key matrix + puls dp return to system DP + bpl L005B valid key +L0042 clra regA would have been the found key + ldb <G.CapLok,u CapsLock/SysRq key down flag + bne L0056 + clr <G.KTblLC,u Key table entry# last checked (1-3) + coma + comb + sta <G.LKeyCd,u last keyboard code + sta <G.2Key1,u 2nd key table storage; $FF=none + std <G.2Key2,u format (Row/Column) +L0056 clr <G.CapLok,u see above +L0059 ldb #$FF +L005B rts + +L005C ldx #PIA0Base base value of PIA#1 + clra + clrb + std <G.ShftDn shift/CTRL flag; 0=NO $FF=YES + std <G.KeyFlg PIA bits/ALT flag +* %00000111-Column # (Output, 0-7) +* %00111000-Row # (Input, 0-6) + coma + comb set primary key table + std <G.Key1 key 1&2 flags $FF=none + sta <G.Key3 key 3 ² + deca ie. lda #%11111110 + sta $02,x strobe one column +L006E lda ,x read PIA#1 + coma + anda #$7F keep only keys, bit 0=off 1=on + beq L0082 + ldb #$FF preset counter to -1 +L0077 incb + lsra bit test regA + bcc L007E no key so branch + lbsr L010E convert column/row to matrix value and store it +L007E cmpb #$06 max counter + bcs L0077 loop if more bits to test +L0082 inc <G.KeyFlg counter; used here for column + orcc #Carry bit marker; disable strobe + rol $02,x shift to next column + bcs L006E not finished with columns so loop + lbsr L0166 simultaneous check; recover key matrix value + bmi L00F5 invalid so go + cmpa <G.LKeyCd last keyboard code + bne L0095 + inc <G.KySame same key flag ?counter? +L0095 sta <G.LKeyCd setup for last key pressed + beq L00B5 + suba #$1A the key value (matrix) of Z + bhi L00B5 not a letter so go + adda #$1A restore regA + ldb <G.CntlDn CTRL flag + bne L00E0 CTRL is down so go + adda #$40 convert to ASCII value; all caps + ldb <G.ShftDn shift key flag + ldy <G.CurDev get current device static memory pointer + eorb <$21,y caps lock and keyboard mouse flags + andb #$01 test caps flag + bne L00E0 not shifted so go + adda #$20 convert to ASCII lower case + bra L00E0 +* key is not a letter; this routine is not based on some underlining principle of +* the keyboard hardware. It is also a function of the decode table at $1DC,pcr. +L00B5 ldb #$03 + mul regB = (key#-26) times 3 + lda <G.ShftDn shift key flag + beq L00BF not shifted so go + incb + bra L00C5 +L00BF lda <G.CntlDn CTRL flag + beq L00C5 + addb #$02 +L00C5 ldx <G.CurDev point regX to devices static memory + lda <$22,x key sense flag + beq L00D0 not set so go + cmpb #$11 spacebar + ble L00F3 must be an arrow so go +L00D0 cmpb #$4C SHIFTed ALT key + blt L00D8 not ALT, CTRL, F1, F2, or SHIFT so go + inc <G.AltDwn flag special keys (ALT,CTRL) + subb #$06 +L00D8 leax >L01DC,pcr decode table + lda b,x + bmi L00F6 if regA = $81 - $84 +* several entries to this routine from any key press; regA is already ASCII +L00E0 ldb <G.AltDwn was ALT flagged? + beq L00F0 no so go + cmpa #$3F ? + bls L00EE # or code + cmpa #$5B [ + bcc L00EE capital letter so go + ora #$20 convert to lower case +L00EE ora #$80 set for ALT characters +L00F0 andcc #^Negative not negative + rts +L00F3 orcc #Negative set negative +L00F5 rts +L00F6 inc <G.CapLok caps lock/SysRq + inc <G.Clear one shot caps lock/SysRq + bra L00F0 +L00FC pshs b,a convert column into power of 2 + clrb + orcc #Carry + inca +L0102 rolb + deca + bne L0102 + bra L0108 WHY IS THIS HERE?? +L0108 orb <G.KySns previous value of column + stb <G.KySns + puls pc,b,a +L010E pshs b,a + cmpb #$03 is it row 3? + bne L011C + lda <G.KeyFlg get column # + cmpa #$03 is it column 3?; ie up arrow + blt L011C if lt must be a letter + bsr L00FC its a non letter so bsr +L011C lslb B*8 8 keys per row + lslb + lslb + addb <G.KeyFlg add in the column # + cmpb #$33 ALT + bne L012B + inc <G.AltDwn ALT down flag + ldb #$04 + bra L0108 +L012B cmpb #$34 CTRL + bne L0135 + inc <G.CntlDn CTRL down flag + ldb #$02 + bra L0108 +L0135 cmpb #$37 shift key + bne L013F + com <G.ShftDn shift down flag + ldb #$01 + bra L0108 +* check how many key (1-3) are currently being pressed +L013F pshs x + leax <$2D,u 1st key table + bsr L014A + puls x + puls pc,b,a +L014A pshs a + lda ,x + bpl L0156 + stb ,x + ldb #$01 + puls pc,a +L0156 lda $01,x + bpl L0160 + stb $01,x + ldb #$02 + puls pc,a +L0160 stb $02,x + ldb #$03 + puls pc,a +* simlutaneous key test +L0166 pshs y,x,b + ldb <G.KTblLC key table entry# + beq L019D + leax <$2A,u point to 2nd key table + pshs b +L0171 leay <$2D,u 1st key table + ldb #$03 + lda ,x get key#1 + bmi L018F go if invalid? (no key) +L017A cmpa ,y is it a match? + bne L0184 go if not a matched key + clr ,y + com ,y set value to $FF + bra L018F +L0184 leay $01,y + decb + bne L017A + lda #$FF + sta ,x + dec <G.KTblLC key table entry# +L018F leax $01,x + dec ,s column counter + bne L0171 + leas $01,s + ldb <G.KTblLC key table entry (can test for 3 simul keys) + beq L019D + bsr L01C4 +L019D leax <$2D,u 1st key table + lda #$03 +L01A2 ldb ,x+ + bpl L01B5 + deca + bne L01A2 + ldb <G.KTblLc key table entry (can test for 3 simul keys) + beq L01C0 + decb + leax <$2A,u 2nd key table + lda b,x + bra L01BE +L01B5 tfr b,a + leax <$2A,u 2nd key table + bsr L014A + stb <G.KTblLC +L01BE puls pc,y,x,b +L01C0 orcc #Negative flag negative + puls pc,y,x,b +L01C4 leax <$2A,u + bsr L01CF + leax $01,x + bsr L01CF + leax -$01,x +L01CF lda ,x + bpl L01DB + ldb $01,x + bmi L01DB + sta $01,x + stb ,x +L01DB rts +* These seem to be special key combination values; 3 per key in ASCII +*L01DC fcb @,shift@,nul +* fcb up,shifted,CTRL +* fcb down, shifted, CTRLed +* fcb left, shifted, CTRLed +* fcb right, shifted, CTRLed +* fcb spacebar, spacebar, spacebar +* fcb 0,0,$81 signal shiftlock change +* fcb 1,!,| +* fcb 2,,null +* fcb 3,#,~ +* fcb 4,$,null +* fcb 5,%,null +* fcb 6,&,null +* fcb 7,,^ +* fcb 8,(,[ +* fcb 9,),] +* fcb :,*,null +* fcb ;,+,DEL +* fcb ,,<,{ +* fcb -,=,_ +* fcb .,>,} +* fcb /,?,\ +* fcb ENTER,ENTER,ENTER +* I think these are for ALT +* fcb $82,$83,$84 +* fcb ENQ,BREAK,ESC +* the next I think are for the F1 and F2 keys +* fcb 1,3,5 +* fcb 2,4,6 +L01DC fdb $4060,$000c,$1c13,$0a1a,$1208,$1810,$0919,$1120 + fdb $2020,$3030,$8131,$217c,$3222,$0033,$237e,$3424 + fdb $0035,$2500,$3626,$0037,$275e,$3828,$5b39,$295d + fdb $3a2a,$003b,$2b7f,$2c3c,$7b2d,$3d5f,$2e3e,$7d2f + fdb $3f5c,$0d0d,$0d82,$8384,$0503,$1b31,$3335,$3234 + fcb $36 + +Init +Term clrb + rts + +FuncKeys ldu <D.CCMem + ldx #PIA0Base + clra + ldb #%11011111 strob column #6 PIA#1 + stb $02,x + ldb ,x read PIA#1 + bitb #%01000000 test for F1 function key + bne L0240 + inca flag F1 +L0240 ldb #%10111111 strobe column #7 PIA#1 + stb $02,x + ldb ,x read PIA#1 + bitb #%01000000 test for F2 function key + bne L024C + ora #$04 flag F2 +L024C rts + + emod +eom equ * + end + +
--- a/level2/modules/makefile Sun Aug 17 13:05:02 2003 +0000 +++ b/level2/modules/makefile Sun Aug 17 16:25:29 2003 +0000 @@ -36,7 +36,9 @@ SCF = scf.mn \ cc3io.dr modpak.dr vrn.dr printer.dr sio.dr sspak.dr sacia.dr dacia.dr \ windint.io vdgint.io vdgint_small.io \ - keydrv joydrv_joy joydrv_6551L joydrv_6552L joydrv_6551M joydrv_6552M snddrv \ + keydrv_cc3.sb snddrv_cc3.sb \ + joydrv_joy.sb joydrv_6551L.sb joydrv_6552L.sb \ + joydrv_6551M.sb joydrv_6552M.sb \ m1.dd m2.dd nil.dd p.dd t1.dd t2_sacia.dd \ t3_sacia.dd t2_dacia.dd t3_dacia.dd \ ftdd.dd vi.dd ssp.dd term_t1.dd \
--- a/level2/modules/snddrv.asm Sun Aug 17 13:05:02 2003 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -******************************************************************** -* SndDrv - Sound Driver for CoCo 3 -* -* $Id$ -* -* Should be fully compatible with old SS.Tone. -* (needs cleaning up for space) -* -* Ed. Comments Who YY/MM/DD -* ------------------------------------------------------------------ -* First working version KKD 88/08/24 -* Bell version for critics <grin> KKD 88/11/14 -* 6 Upgrade to edition 3 from Monk-o-Ware BGP 98/09/26 - - nam SndDrv - ttl Sound Driver for CoCo 3 - - ifp1 - use defsfile - endc - -* SYSTEM MAP GLOBALS: - -rev set 1 -edition set 3 - - mod sndlen,sndnam,systm+objct,reent+rev,entry,0 - -sndnam fcs "SndDrv" - fcb edition - -******************************************************* -entry lbra init init codriver - lbra getstt - lbra setstt ss.tone - lbra term terminate - -******************************************************* -* INIT: set bell vector for F$Alarm - -init leax Bell,pcr - stx >WGlobal+G.BelVec save bell vector -getstt -term -okend clrb - rts - -******************************************************* -* SETSTT: do SS.Tone ($98) calls -* SS.Tone 98 -* regs: X=vol,duration, Y=tone -* Y=path desc - -setstt ldx PD.RGS,y get user regs - ldd #$1000 check for 1-4095 range - subd R$Y,x on passed Y - lble BadArgs ..okay if less - cmpd #$1000 ..else err on $1000 - lbge BadArgs .. - tfr d,y set tone to D - - ldd R$X,x get vol, duration - stb >WGlobal+G.TnCnt save duration - ldb #1 fake cycles - anda #$3F make volume ok - bra BellTone ..do it - -BadArgs comb - ldb #E$IllArg - rts - -******************************************************* -* Bell ($07): -* can destroy D,Y - -Bell inc >WGlobal+G.BelTnF set bell flag -* lda #230/4 start value -* ldb #230/2-18 cycle repeats -* ldd #60*256+96 - ldd #$3E60 - ldy #$0060 bell freq - -* COMMON SS.TONE and BELL ROUTINE: -* A=volume byte (0-63) -* B=cycle repeats (1 means use G.TnCnt as countdown) -* Y=freq - -BellTone lsla set A for PIA D/A bits - lsla - lbeq okend okay end if just setting it - ora #2 add printer port bit - pshs a,b,x - ldx #PIA0Base save current PIA setting - lda 1,x - ldb 3,x - pshs a,b - - anda #$F7 set for sound - andb #$F7 - sta 1,x - stb 3,x - leax $20,x save PIA2 setting - lda 3,x - pshs A - ora #8 and set it too - sta 3,x - bra ToneLoop ..enter main play loop - -BellLoop lda 3,s only bell does this countdown - deca - deca - sta 3,s - anda #$F7 - ora #$02 - bra Loop2 -ToneLoop ldd 3,s get D/A byte, repeat cnt -Loop2 bsr SendByte send it (Y=tone delay) - lda #2 go back to zero - bsr SendByte send it - decb count-1 (SS.Tone always=0!) - bne BellLoop ..loop if bell cycles only << - - ldb >WGlobal+G.BelTnF is it bell? - bne ToneExit ..yes, end - ldb >WGlobal+G.TnCnt else get ticks left - bne ToneLoop and do again if any, else... - -* Note: G.TnCnt is counted down by cc3io at 60hz. - -ToneExit clr >WGlobal+G.BelTnF clear bell flag - puls A reset PIA's as before: - sta 3,x - leax -$20,x - puls a,b - sta 1,x - stb 3,x - clrb okay - puls a,b,x,pc end tone/bell. - -SendByte pshs y save delay - sta ,x store D/A byte -SendDely leay -1,y delay - bne SendDely for tone - puls y,pc retn. - - emod -sndlen equ * - end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level2/modules/snddrv_cc3.asm Sun Aug 17 16:25:29 2003 +0000 @@ -0,0 +1,148 @@ +******************************************************************** +* SndDrv - Sound Driver for CoCo 3 +* +* $Id$ +* +* Should be fully compatible with old SS.Tone. +* (needs cleaning up for space) +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* First working version KKD 88/08/24 +* Bell version for critics <grin> KKD 88/11/14 +* 6 Upgrade to edition 3 from Monk-o-Ware BGP 98/09/26 + + nam SndDrv + ttl Sound Driver for CoCo 3 + + ifp1 + use defsfile + endc + +* SYSTEM MAP GLOBALS: + +rev set 1 +edition set 3 + + mod sndlen,sndnam,systm+objct,reent+rev,entry,0 + +sndnam fcs "SndDrv" + fcb edition + +******************************************************* +entry lbra init init codriver + lbra getstt + lbra setstt ss.tone + lbra term terminate + +******************************************************* +* INIT: set bell vector for F$Alarm + +init leax Bell,pcr + stx >WGlobal+G.BelVec save bell vector +getstt +term +okend clrb + rts + +******************************************************* +* SETSTT: do SS.Tone ($98) calls +* SS.Tone 98 +* regs: X=vol,duration, Y=tone +* Y=path desc + +setstt ldx PD.RGS,y get user regs + ldd #$1000 check for 1-4095 range + subd R$Y,x on passed Y + lble BadArgs ..okay if less + cmpd #$1000 ..else err on $1000 + lbge BadArgs .. + tfr d,y set tone to D + + ldd R$X,x get vol, duration + stb >WGlobal+G.TnCnt save duration + ldb #1 fake cycles + anda #$3F make volume ok + bra BellTone ..do it + +BadArgs comb + ldb #E$IllArg + rts + +******************************************************* +* Bell ($07): +* can destroy D,Y + +Bell inc >WGlobal+G.BelTnF set bell flag +* lda #230/4 start value +* ldb #230/2-18 cycle repeats +* ldd #60*256+96 + ldd #$3E60 + ldy #$0060 bell freq + +* COMMON SS.TONE and BELL ROUTINE: +* A=volume byte (0-63) +* B=cycle repeats (1 means use G.TnCnt as countdown) +* Y=freq + +BellTone lsla set A for PIA D/A bits + lsla + lbeq okend okay end if just setting it + ora #2 add printer port bit + pshs a,b,x + ldx #PIA0Base save current PIA setting + lda 1,x + ldb 3,x + pshs a,b + + anda #$F7 set for sound + andb #$F7 + sta 1,x + stb 3,x + leax $20,x save PIA2 setting + lda 3,x + pshs A + ora #8 and set it too + sta 3,x + bra ToneLoop ..enter main play loop + +BellLoop lda 3,s only bell does this countdown + deca + deca + sta 3,s + anda #$F7 + ora #$02 + bra Loop2 +ToneLoop ldd 3,s get D/A byte, repeat cnt +Loop2 bsr SendByte send it (Y=tone delay) + lda #2 go back to zero + bsr SendByte send it + decb count-1 (SS.Tone always=0!) + bne BellLoop ..loop if bell cycles only << + + ldb >WGlobal+G.BelTnF is it bell? + bne ToneExit ..yes, end + ldb >WGlobal+G.TnCnt else get ticks left + bne ToneLoop and do again if any, else... + +* Note: G.TnCnt is counted down by cc3io at 60hz. + +ToneExit clr >WGlobal+G.BelTnF clear bell flag + puls A reset PIA's as before: + sta 3,x + leax -$20,x + puls a,b + sta 1,x + stb 3,x + clrb okay + puls a,b,x,pc end tone/bell. + +SendByte pshs y save delay + sta ,x store D/A byte +SendDely leay -1,y delay + bne SendDely for tone + puls y,pc retn. + + emod +sndlen equ * + end