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