This commit is contained in:
Michaelangel007 2017-04-15 11:09:24 -07:00
parent 73f8469482
commit 24a1b679b7
6 changed files with 460 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,107 @@
;PROCESSOR LOOP
;FOR LASER AND BOMB
;SOUND EFFECT
*
ORG $8F00
;FOR FIRST 6522
*
PTR EQU $08 ;DATA POINTE
TONE EQU $0A ;TONAL VALUE
TIME EQU $0B ;TIME VALUE FOR DELAY
BASE EQU $C400 ;CARD ADDRESS
ORA EQU BASE+1 ;PORT A
TAR EQU $8000 ; TABLE ACCESS ROUTINE
LATCH EQU $900B ;LATCH SUBROUTINE
WRITE EQU $9016 ;WRITE SUBROUTINE
RESET EQU $9021 ;RESET SUBROUTINE
WAIT EQU $FCAB ;WAIT SUBROUTINE
*
*
LASER LDA #$00 ;LOAD HIGHEST
STA TONE ;FREQUENCY VALUE
LDA #$0F ;LOAD SHORT
STA TIME ;TIME DELAY
JMP START ;AND START
BOMB LDA #$30 ;LOAD MIDDLE
STA TONE ;FREQUENCY VALUE
LDA #$40 ;LOAD LONGER
STA TIME ;TIME DELAY
START LDA #$90 ;SET TABLE ADDRESS
STA PTR
LDA #$81
STA PTR+1
JSR TAR ;TRANSFER DATA
LDA #$00 ;LATCH FIRST REGISTER
STA ORA ;ADDRESS
JSR LATCH
LOOP LDA TONE ;GET TONE VALUE
STA ORA ;STORE IN REGISTER
JSR WRITE
LDA TIME ;GET TIME VALUE
JSR WAIT ;AND DELAY
INC TONE ;INCREMENT TONE VALUE
LDA #$FF ;END OF INCREASE?
CMP TONE
BEQ DONE ;YES,EXIT
JMP LOOP ;NO, START AGAIN
DONE LDA TIME ;GET TIME VALUE
JSR WAIT ;DELAY
LDA #$00 ;RESTORE ORIGINAL
STA TONE ;TONE VALUE
JSR RESET ;CLEAR SOUND CHIP
RTS ;REGISTERS AND RETURN

View File

@ -0,0 +1,125 @@
MockingBoard Mini-manual (Part 2): Sound Programming
The user can set Tone Frequency (12 bits, 4 coarse & 8 fine)* and
Amplitude (4 bits) for each channel individually. A fifth Amplitude bit
lets
you decide if a channel's Level will be "fixed" (use the Level value) or
"variable" (i.e. follow the current Envelope pattern). You can set NG
Frequency (4 bits)* but not level.
*Tone Freq = A2 Clock Freq/ [ (4096 x Coarse) + (16 x Fine) ]
Noise Freq = A2 Clock Freq/ (16 x NG value)
The Envelope of the combined outputs of enabled sources can be
controlled
for Period (16 bits, 8 coarse & 8 fine)** and, roughly, for Shape (4
bits).
**Env Freq = A2 Clock Freq/ [ (65536 x Coarse) + (256 x Fine) ]
The registers of the PSG are described briefly below:
Reg. Function & Bit(s) used
00 A Freq. fine (0-7)
01 A Freq. coarse (0-3)
02 B Freq. fine (0-7)
03 B Freq. coarse (0-3)
04 C Freq. fine (0-7)
05 C Freq. coarse (0-3)
06 NG Freq. (0-4)
07 Enable =0/ Disable =1
NG on A (5) on B (4) on C (3)
Tone on A (2) on B (1) on C (0)
Ex: Writing $F0 to Reg 07 plays tones A, B, C plus noise on C
08 A Level (0-3) and
Envelope Control (4): 1 = Use Env; 0 = Use Level value
09 B Level (0-3) and ...
0A C Level (0-3) and ...
0B Envelope Period Fine (0-7)
0C Envelope Period Coarse (0-7)
0D Envelope Shape (four bits)
Continue (3) 0= do 1 cycle and set Level to zero
Attack (2) 1= count up 0= count down
Alternate (1) 1= reverse count direction each cycle
Hold (0) 1= do 1 cycle and hold count
To program the MB you write to the board's 6522 I/O chip(s). All
addresses reference here are for a MB Sound II (2 Output channels) in Slot
4.
$C400 ORB1 function to perform, OUT 1
$C480 ORB2 function to perform, OUT 2
$C401 ORA1 data, OUT 1
$C481 ORA2 data, OUT 2
$C402 DDRB1 data direction, OUT 1
$C482 DDRB2 data direction, OUT 2
$C403 DDRA1 data direction, OUT 1
$C483 DDRA2 data direction, OUT 2
Before sending music, etc. data to the MB you must Initialize the board's
I/O. To Initialize the 6522's: Store $FF at $C402 and the other three
DDRxx addresses. This needs to be done by your program just once.
Your program gets access to a PSG via the 6522 by using a few basic
Function codes which set the PSG's I/O control lines:
Set Inactive = $04 Set PSG Reg# = $07 Write Data = $06 Reset = $00
To Write to a PSG register: Tell the PSG which Register you wish to access
(i.e. Set the "current register" #) and Write the data. This is easiest to
do with subroutines to handle the basic Functions.
Example Subroutines (for Output Channel 1):
Set Reg # 1000: A9 07 8D 00 C4 A9 04 8D 00 C4 60
Write Data 100B: A9 06 8D 00 C4 A9 04 8D 00 C4 60
Notice that each Function sub ends by setting the PSG control lines to
Inactive.
Similarly, to do a Reset (set all PSG regs to zero) ...
Reset 1016: A9 00 8D 00 C4 A9 04 8D 00 C4 60
To put the value $55 in PSG Register 02 (Channel B Freq. fine) ....
1080: A9 02 put Reg# in A
1082: 8D 01 C4 store A at the Data address ORA1
1085: 20 00 10 JSR to Set Reg# (sets "current register" to Register
2)
1088: A9 55 put the value $55 in A
108A: 8D 01 C4 store A at the Data address ORA1
108D: 20 0B 10 JSR to Write Data ($55 goes into PSG Register 2)
1090: 60 Exit from subroutine
Good luck!

View File

@ -0,0 +1,133 @@
*PRIMARY ROUTINES
*FOR SLOT 4
*
ORG $9000
;ADDRESSES FOR FIRST 6522
ORB EQU $C400 ;PORT B
ORA EQU $C401 ;PORT A
DDRB EQU $C402 ;DATA DIRECTION REGISTER (A)
DDRA EQU $C403 ;DATA DIRECTION REGISTER (B)
;ADDRESSES FOR SECOND 6522
ORB2 EQU $C480 ;PORT B
ORA2 EQU $C481 ;PORT A
DDRB2 EQU $C482 ;DATA DIRECTION REGISTER (B)
DDRA2 EQU $C483 ;DATA DIRECTION REGISTER (A)
*
*ROUTINES FOR FIRST 6522
*
INIT LDA #$FF ;SET PORT A FOR OUTPUT
STA DDRA
LDA #$07 ;SET PORT B FOR OUTPUT
STA DDRB
RTS ;RETURN
*
LATCH LDA #$07 ;SEND "LATCH COMMAND"
STA ORB ;TO SOUND CHIP
LDA #$04 ;THROUGH PORT B
STA ORB
RTS ;RETURN
*
WRITE LDA #$06 ;SEND "WRITECOMMAND"
STA ORB ;TO SOUND CHIP
LDA #$04 ;THROUGHPORT B
STA ORB
RTS ;RETURN
*
RESET LDA #$00 ;SEND "RESET COMMAND"
STA ORB ;TO SOUND CHIP
LDA #$04 ;THROUGH PORT B
STA ORB
RTS ;RETURN
*
*ROUTINES FOR SECOND 6522
*
INIT2 LDA #$FF ;SET PORT A FOR OUTPUT
STA DDRA2
LDA #$07 ;SET PORT B FOR OUTPUT
STA DDRB2
RTS ;RETURN
*
LATCH2 LDA #$07 ;SEND "LATCH COMMAND"
STA ORB2 ;TO SOUND CHIP
LDA #$04 ;THROUGH PORT B
STA ORB2
RTS ;RETURN
*
WRITE2 LDA #$06 ;SEND "WRITECOMMAND"
STA ORB2 ;TO SOUND CHIP
LDA #$04 ;THROUGHPORT B
STA ORB2
RTS ;RETURN
*
STA #$00 ;SEND "RESET COMMAND"
STA ORB2 ;TO SOUND CHIP
LDA #$04 ;THROUGH PORT B
STA ORB2
RTS ;RETURN

View File

@ -0,0 +1,95 @@
;TABLE ACCESS ROUTINE
;FOR SLOT 4
*
ORG $8000
;ADDRESSES FOR FIRST 6522
PTR EQU $08 ;DATA POINTER
ORA EQU $C401 ;PORT A
LATCH EQU $900B ;LATCH SUB-ROUTINE
WRITE EQU $9016 ;WRITE SUB-ROUTINE
RESET EQU $9021 ;RESET SUB-ROUTINE
;ADDRESSES FOR SECOND 6522
PRT2 EQU $0A ;DATA POINTER
ORA2 EQU $C481 ;PORT A
LATCH2 EQU $9037 ;LATCH SUB-ROUTINE
WRITE2 EQU $9042 ;RESET SUB-ROUTINE
RESET2 EQU $904D ;RESET SUB-ROUTINE
*
*ROUTINES FOR FIRST 6255
*
START JSR RESET ;RESET SOUND CHIP
LDY #$00 ;USED TO IDENTIFY REGISTER
LOOP STY ORA ;# OF SOUND CHIP
JSR LATCH
LDA (PTR),Y ;GET DATA FROM TABLE
STA ORA
JSR WRITE ;STORE IN REGISTER
CPY #$0F ;END OF DATA?
BEQ DONE ;YES, EXIT
INY
JMP LOOP ;NO, GET NEXT SET
DONE RTS ;RETURN
*
*ROUTINES FOR SECOND 6522
*
START2 JSR RESET2 ;SAME INSTRUCTIONS AS
LDY #$00 ;ABOVE
LOOP2 STY ORA2
JSR LATCH2
LDA (PTR2),Y
STA ORA2
JSR WRITE2
CPY #$0F
BEQ DONE2
INY
JMP LOOP2
DONE2 RTS