mirror of
https://github.com/jeremysrand/mocklib.git
synced 2025-01-05 00:29:42 +00:00
Some cleanup of the speech assembly
This commit is contained in:
parent
84ddb58602
commit
84a08225de
@ -17,7 +17,10 @@
|
||||
|
||||
|
||||
extern void setupSpeech(void);
|
||||
uint8_t **tabPtr = (uint8_t **)0x00f9;
|
||||
extern uint8_t *speechData;
|
||||
extern uint16_t speechLen;
|
||||
extern bool busy;
|
||||
extern uint8_t numIRQs;
|
||||
|
||||
|
||||
tMockingSoundRegisters soundData1 = {
|
||||
@ -44,34 +47,33 @@ tMockingSoundRegisters soundData2 = {
|
||||
};
|
||||
|
||||
|
||||
uint8_t speechData[] = {
|
||||
0xCF, 0x00, 0xE8, 0x70, 0xA8, 0x5F, 0x00, 0xE8,
|
||||
0x70, 0xA8, 0x5F, 0x00, 0xE8, 0x70, 0xA8, 0x5F,
|
||||
0x00, 0xE8, 0x7B, 0xA8, 0x5F, 0x63, 0xE7, 0x6B,
|
||||
0xA8, 0x59, 0x47, 0xE8, 0x6A, 0xA8, 0x61, 0x36,
|
||||
0xE8, 0x79, 0xA8, 0x65, 0x37, 0xE7, 0x79, 0xA8,
|
||||
0x69, 0x0E, 0xE7, 0x6A, 0xA8, 0x61, 0x29, 0xE8,
|
||||
0x6B, 0xA8, 0x59, 0xAD, 0xE8, 0x6B, 0xA8, 0x51,
|
||||
0xC0, 0xE8, 0x6A, 0xA8, 0x51, 0x07, 0xE8, 0x6A,
|
||||
0xA8, 0x4B, 0x39, 0xE8, 0x6A, 0xA8, 0x49, 0x64,
|
||||
0xE7, 0x6A, 0x88, 0x49, 0x11, 0xE7, 0x5A, 0xB8,
|
||||
0x51, 0x63, 0xE7, 0x5A, 0xB8, 0x59, 0x1D, 0xE8,
|
||||
0x7A, 0xA8, 0x61, 0x65, 0xE8, 0x79, 0xA8, 0x61,
|
||||
0xC0, 0xE8, 0x70, 0x78, 0x51, 0x00, 0xE8, 0x70,
|
||||
0x78, 0x51, 0x00, 0xE8, 0x70, 0x78, 0x59, 0x00,
|
||||
0xE7, 0x79, 0xA8, 0x65, 0x04, 0xE7, 0x6A, 0x98,
|
||||
0x61, 0x16, 0xE8, 0x6B, 0xA8, 0x61, 0x60, 0xE8,
|
||||
0x7C, 0xA8, 0x59, 0x78, 0xE7, 0x7C, 0xA8, 0x55,
|
||||
0x0A, 0xE8, 0x6B, 0xA8, 0x62, 0x33, 0xE8, 0x6A,
|
||||
0xA8, 0x59, 0x1C, 0xE8, 0x7A, 0xA8, 0x51, 0x64,
|
||||
0xE7, 0x7B, 0x88, 0x51, 0x01, 0xE8, 0x7C, 0xA8,
|
||||
0x59, 0x30, 0xE8, 0x7D, 0xA8, 0x59, 0x27, 0xE7,
|
||||
0x7D, 0x78, 0x61, 0x01, 0xE8, 0x6C, 0xA8, 0x61,
|
||||
0x28, 0xE8, 0x6B, 0xA8, 0x59, 0x32, 0xE8, 0x6A,
|
||||
0xA8, 0x4D, 0x60, 0xE7, 0x29, 0xA8, 0x41, 0x0A,
|
||||
0xE8, 0x78, 0xA8, 0x41, 0x30, 0xE8, 0x70, 0xA8,
|
||||
0x39, 0xFF, 0xE8, 0x70, 0xA8, 0x39, 0x00, 0xE8,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
uint8_t mySpeechData[] = {
|
||||
0xE8, 0x70, 0xA8, 0x5F, 0x00, 0xE8, 0x70, 0xA8,
|
||||
0x5F, 0x00, 0xE8, 0x70, 0xA8, 0x5F, 0x00, 0xE8,
|
||||
0x7B, 0xA8, 0x5F, 0x63, 0xE7, 0x6B, 0xA8, 0x59,
|
||||
0x47, 0xE8, 0x6A, 0xA8, 0x61, 0x36, 0xE8, 0x79,
|
||||
0xA8, 0x65, 0x37, 0xE7, 0x79, 0xA8, 0x69, 0x0E,
|
||||
0xE7, 0x6A, 0xA8, 0x61, 0x29, 0xE8, 0x6B, 0xA8,
|
||||
0x59, 0xAD, 0xE8, 0x6B, 0xA8, 0x51, 0xC0, 0xE8,
|
||||
0x6A, 0xA8, 0x51, 0x07, 0xE8, 0x6A, 0xA8, 0x4B,
|
||||
0x39, 0xE8, 0x6A, 0xA8, 0x49, 0x64, 0xE7, 0x6A,
|
||||
0x88, 0x49, 0x11, 0xE7, 0x5A, 0xB8, 0x51, 0x63,
|
||||
0xE7, 0x5A, 0xB8, 0x59, 0x1D, 0xE8, 0x7A, 0xA8,
|
||||
0x61, 0x65, 0xE8, 0x79, 0xA8, 0x61, 0xC0, 0xE8,
|
||||
0x70, 0x78, 0x51, 0x00, 0xE8, 0x70, 0x78, 0x51,
|
||||
0x00, 0xE8, 0x70, 0x78, 0x59, 0x00, 0xE7, 0x79,
|
||||
0xA8, 0x65, 0x04, 0xE7, 0x6A, 0x98, 0x61, 0x16,
|
||||
0xE8, 0x6B, 0xA8, 0x61, 0x60, 0xE8, 0x7C, 0xA8,
|
||||
0x59, 0x78, 0xE7, 0x7C, 0xA8, 0x55, 0x0A, 0xE8,
|
||||
0x6B, 0xA8, 0x62, 0x33, 0xE8, 0x6A, 0xA8, 0x59,
|
||||
0x1C, 0xE8, 0x7A, 0xA8, 0x51, 0x64, 0xE7, 0x7B,
|
||||
0x88, 0x51, 0x01, 0xE8, 0x7C, 0xA8, 0x59, 0x30,
|
||||
0xE8, 0x7D, 0xA8, 0x59, 0x27, 0xE7, 0x7D, 0x78,
|
||||
0x61, 0x01, 0xE8, 0x6C, 0xA8, 0x61, 0x28, 0xE8,
|
||||
0x6B, 0xA8, 0x59, 0x32, 0xE8, 0x6A, 0xA8, 0x4D,
|
||||
0x60, 0xE7, 0x29, 0xA8, 0x41, 0x0A, 0xE8, 0x78,
|
||||
0xA8, 0x41, 0x30, 0xE8, 0x70, 0xA8, 0x39, 0xFF,
|
||||
0xE8, 0x70, 0xA8, 0x39, 0x00, 0xE8, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
|
||||
@ -102,9 +104,14 @@ int main(void)
|
||||
printf("RUN SPEECH TEST (Y/N) ");
|
||||
if (cgetc() != 'Y')
|
||||
return 0;
|
||||
printf("\n");
|
||||
|
||||
*tabPtr = speechData;
|
||||
speechData = mySpeechData;
|
||||
speechLen = sizeof(mySpeechData) - 1;
|
||||
setupSpeech();
|
||||
while (!kbhit()) {
|
||||
//printf("numIRQs = %d\n", numIRQs);
|
||||
}
|
||||
|
||||
cgetc();
|
||||
|
||||
|
@ -7,13 +7,11 @@
|
||||
;
|
||||
|
||||
|
||||
.export _setupSpeech
|
||||
.export _setupSpeech, _numIRQs, _speechData, _speechLen, _busy
|
||||
; .interruptor speechIRQ
|
||||
|
||||
|
||||
TABPTR := $F9 ;DATA POINTER
|
||||
OUTPTR := $FB ;START OF DATA POINTER
|
||||
ENDPTR := $FD ;END OF DATA POINTER
|
||||
BUSY := $FF ;BUSY FLAG
|
||||
IRQL := $03FE ;INTERRUPT VECTOR, LOW BYTE
|
||||
IRQH := $03FF ;INTERRUPT VECTOR, HIGH BYTE
|
||||
BASE := $C440 ;FIRST SPEECH CHIP
|
||||
@ -29,6 +27,15 @@ IFR := $C48D ;INTERRUPT FLAG REG-6522
|
||||
IER := $C48E
|
||||
|
||||
|
||||
.DATA
|
||||
speechIRQ: .byte $60, <_interr, >_interr ; RTS plus two dummy bytes
|
||||
_numIRQs: .byte $00
|
||||
_speechData: .byte $00, $00
|
||||
_speechLen: .byte $00, $00
|
||||
endptr: .byte $00, $00
|
||||
_busy: .byte $00
|
||||
|
||||
|
||||
.CODE
|
||||
|
||||
.proc _setupSpeech
|
||||
@ -37,36 +44,31 @@ IER := $C48E
|
||||
STA IRQL ;TO POINT TO INTERRUPT
|
||||
LDA #>_interr ;SERVICE ROUTINE
|
||||
STA IRQH
|
||||
; LDA #$4C ; JMP opcode
|
||||
; STA speechIRQ
|
||||
LDA #$00
|
||||
STA DDRA
|
||||
STA DDRB
|
||||
|
||||
LDA TABPTR+1 ;GET HIGH ADDRESS OF DATA
|
||||
STA OUTPTR+1 ;STORE IN WORK POINTER
|
||||
LDX TABPTR ;GET LOW ADDRESS OF DATA
|
||||
INX ;INCREMENT TWICE
|
||||
INX ;TO SKIP OVER LENGTH BYTES
|
||||
BNE @L1 ;CHECK FOR PAGE BOUNDARY
|
||||
INC OUTPTR+1
|
||||
@L1:
|
||||
STX OUTPTR ;STORE LOW BYTE
|
||||
LDA _speechData+1 ;GET HIGH ADDRESS OF DATA
|
||||
STA OUTPTR+1 ;STORE IN WORK POINTER
|
||||
LDA _speechData ;GET LOW ADDRESS OF DATA
|
||||
STA OUTPTR ;STORE LOW BYTE
|
||||
|
||||
LDY #$01
|
||||
LDA (TABPTR),Y ;GET HIGH LENGTH BYTE
|
||||
LDA _speechLen+1 ;GET HIGH LENGTH BYTE
|
||||
CLC
|
||||
ADC TABPTR+1 ;AND ADD TO BASE ADDRESS
|
||||
STA ENDPTR+1 ;STORE END ADDRESS
|
||||
DEY
|
||||
LDA (TABPTR),Y ;GET LOW LENGTH BYTE
|
||||
ADC _speechData+1 ;AND ADD TO BASE ADDRESS
|
||||
STA endptr+1 ;STORE END ADDRESS
|
||||
LDA _speechLen ;GET LOW LENGTH BYTE
|
||||
CLC
|
||||
ADC TABPTR ;AND ADD TO BASE ADDRESS
|
||||
ADC _speechData ;AND ADD TO BASE ADDRESS
|
||||
BCC @L2 ;CHECK FOR PAGE BOUNDARY
|
||||
INC ENDPTR+1
|
||||
INC endptr+1
|
||||
@L2:
|
||||
STA ENDPTR ;STORE END ADDRESS
|
||||
STA endptr ;STORE END ADDRESS
|
||||
|
||||
LDA #$FF ;SET BUSY FLAG
|
||||
STA BUSY ;AND SET PERIPHERAL CONTROL
|
||||
STA _busy ;AND SET PERIPHERAL CONTROL
|
||||
LDA #$0C ;REGISTER TO RECOGNIZE
|
||||
STA PCR ;SIGNAL FROM SPEECH CHIP
|
||||
LDA #$80 ;RAISE CTRL BIT IN REGISTER 3
|
||||
@ -93,18 +95,20 @@ IER := $C48E
|
||||
STA IFR
|
||||
LDY #$00 ;INIT REGISTERS
|
||||
LDX #$04
|
||||
LDA OUTPTR+1
|
||||
CMP endptr+1
|
||||
BCC @L1
|
||||
BNE @L5
|
||||
LDA OUTPTR ;CHECK FOR END OF DATA FILE
|
||||
CMP ENDPTR
|
||||
BCC @L1 ;IF NOT THEN CONTINUE
|
||||
LDA OUTPTR+1 ;CHECK HIGH ADDRESS ALSO
|
||||
CMP ENDPTR+1
|
||||
CMP endptr
|
||||
BCC @L1 ;IF NOT THEN CONTINUE
|
||||
@L5:
|
||||
LDA #$00 ;IF END, TURN EVERYTHING OFF
|
||||
STA DURPHON ;STORE PAUSE PHONEME
|
||||
LDA #$70 ;ZERO AMPLITUDE
|
||||
STA CTTRAMP
|
||||
LDA #$00 ;CLEAR BUSY FLAG
|
||||
STA BUSY
|
||||
STA _busy
|
||||
LDA #$02 ;CLEAR INTERRUPT ENABLE
|
||||
STA IER ;IN 6522
|
||||
LDA #$FF
|
||||
|
Loading…
Reference in New Issue
Block a user