More speech assembly cleanup. Create a proper API for speech.
This commit is contained in:
parent
9bb4f83010
commit
4e3c65288f
|
@ -8,6 +8,9 @@
|
|||
|
||||
/* Begin PBXFileReference section */
|
||||
9D16BCE21D9E070B005EE214 /* speech.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = speech.s; sourceTree = "<group>"; };
|
||||
9D49929C1DB5C5F700606789 /* speech.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = speech.h; sourceTree = "<group>"; };
|
||||
9D49929D1DB5C65200606789 /* speech_api.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = speech_api.c; sourceTree = "<group>"; };
|
||||
9D49929E1DB5C65200606789 /* speech_api.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = speech_api.h; sourceTree = "<group>"; };
|
||||
9DB3C98C1D84A11600395532 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
||||
9DB3C98D1D84A11600395532 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
|
||||
9DB3C98F1D84A11600395532 /* AppleCommander.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; name = AppleCommander.jar; path = make/AppleCommander.jar; sourceTree = "<group>"; };
|
||||
|
@ -37,6 +40,9 @@
|
|||
9DB3C99C1D84A21E00395532 /* mockingboard.c */,
|
||||
9DB3C99D1D84A21E00395532 /* mockingboard.h */,
|
||||
9D16BCE21D9E070B005EE214 /* speech.s */,
|
||||
9D49929C1DB5C5F700606789 /* speech.h */,
|
||||
9D49929D1DB5C65200606789 /* speech_api.c */,
|
||||
9D49929E1DB5C65200606789 /* speech_api.h */,
|
||||
9DB3C98D1D84A11600395532 /* Makefile */,
|
||||
9DB3C98E1D84A11600395532 /* make */,
|
||||
);
|
||||
|
|
|
@ -14,13 +14,7 @@
|
|||
#include <conio.h>
|
||||
|
||||
#include "mockingboard.h"
|
||||
|
||||
|
||||
extern void setupSpeech(void);
|
||||
extern uint8_t *speechData;
|
||||
extern uint16_t speechLen;
|
||||
extern bool busy;
|
||||
extern uint8_t numIRQs;
|
||||
#include "speech_api.h"
|
||||
|
||||
|
||||
tMockingSoundRegisters soundData1 = {
|
||||
|
@ -73,7 +67,8 @@ uint8_t mySpeechData[] = {
|
|||
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
|
||||
0xE8, 0x70, 0xA8, 0x39, 0x00, 0xE8, 0xFF, 0xFF,
|
||||
0xFF, 0xFF
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,13 +101,11 @@ int main(void)
|
|||
return 0;
|
||||
printf("\n");
|
||||
|
||||
speechData = mySpeechData;
|
||||
speechLen = sizeof(mySpeechData) - 1;
|
||||
setupSpeech();
|
||||
while (!kbhit()) {
|
||||
//printf("numIRQs = %d\n", numIRQs);
|
||||
speakMessage(mySpeechData, sizeof(mySpeechData));
|
||||
while (speechIsBusy()) {
|
||||
}
|
||||
|
||||
printf("\nDone speaking\n");
|
||||
cgetc();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// speech.h
|
||||
// mocktest
|
||||
//
|
||||
// Created by Jeremy Rand on 2016-10-17.
|
||||
// Copyright © 2016 Jeremy Rand. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef speech_h
|
||||
#define speech_h
|
||||
|
||||
|
||||
extern uint8_t *speechData;
|
||||
extern uint16_t speechLen;
|
||||
extern uint8_t speechBusy;
|
||||
extern uint16_t outptr;
|
||||
extern uint16_t endptr;
|
||||
|
||||
extern void setupSpeech(void);
|
||||
|
||||
|
||||
#endif /* speech_h */
|
|
@ -7,7 +7,8 @@
|
|||
;
|
||||
|
||||
|
||||
.export _setupSpeech, _numIRQs, _speechData, _speechLen, _busy
|
||||
.export _setupSpeech, _speechData, _speechLen, _speechBusy
|
||||
.export _outptr, _endptr
|
||||
; .interruptor speechIRQ
|
||||
|
||||
|
||||
|
@ -29,11 +30,11 @@ 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
|
||||
_outptr: .byte $00, $00
|
||||
_endptr: .byte $00, $00
|
||||
_speechBusy: .byte $00
|
||||
|
||||
|
||||
.CODE
|
||||
|
@ -58,29 +59,29 @@ _busy: .byte $00
|
|||
LDA _speechLen+1 ;GET HIGH LENGTH BYTE
|
||||
CLC
|
||||
ADC _speechData+1 ;AND ADD TO BASE ADDRESS
|
||||
STA endptr+1 ;STORE END ADDRESS
|
||||
STA _endptr+1 ;STORE END ADDRESS
|
||||
LDA _speechLen ;GET LOW LENGTH BYTE
|
||||
CLC
|
||||
ADC _speechData ;AND ADD TO BASE ADDRESS
|
||||
BCC @L2 ;CHECK FOR PAGE BOUNDARY
|
||||
INC endptr+1
|
||||
BCC @L2 ;CHECK FOR PAGE BOUNDARY
|
||||
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
|
||||
LDA #$0C ;REGISTER TO RECOGNIZE
|
||||
STA PCR ;SIGNAL FROM SPEECH CHIP
|
||||
LDA #$80 ;RAISE CTRL BIT IN REGISTER 3
|
||||
LDA #$FF ;SET BUSY FLAG
|
||||
STA _speechBusy ;AND SET PERIPHERAL CONTROL
|
||||
LDA #$0C ;REGISTER TO RECOGNIZE
|
||||
STA PCR ;SIGNAL FROM SPEECH CHIP
|
||||
LDA #$80 ;RAISE CTRL BIT IN REGISTER 3
|
||||
STA CTTRAMP
|
||||
LDA #$C0 ;SET TRANSITIONED INFLECTION
|
||||
STA DURPHON ;MODE IN REGISTER 0
|
||||
LDA #$70 ;LOWER CTRL BIT
|
||||
LDA #$C0 ;SET TRANSITIONED INFLECTION
|
||||
STA DURPHON ;MODE IN REGISTER 0
|
||||
LDA #$70 ;LOWER CTRL BIT
|
||||
STA CTTRAMP
|
||||
LDA #$82 ;ENABLE 6522 INTERRUPTS
|
||||
LDA #$82 ;ENABLE 6522 INTERRUPTS
|
||||
STA IER
|
||||
CLI ;CLEAR INTERRUPT MASK
|
||||
RTS ;RETURN TO CALLER
|
||||
CLI ;CLEAR INTERRUPT MASK
|
||||
RTS ;RETURN TO CALLER
|
||||
.endproc
|
||||
|
||||
|
||||
|
@ -90,18 +91,18 @@ _busy: .byte $00
|
|||
PHA
|
||||
TYA
|
||||
PHA
|
||||
LDA IFR
|
||||
BPL @L2
|
||||
; LDA IFR
|
||||
; BPL @L2
|
||||
LDA #$02 ;CLEAR INTERRUPT FLAG
|
||||
STA IFR
|
||||
LDY #$00 ;INIT REGISTERS
|
||||
LDX #$04
|
||||
LDA OUTPTR+1
|
||||
CMP endptr+1
|
||||
CMP _endptr+1
|
||||
BCC @L1
|
||||
BNE @L5
|
||||
LDA OUTPTR ;CHECK FOR END OF DATA FILE
|
||||
CMP endptr
|
||||
CMP _endptr
|
||||
BCC @L1 ;IF NOT THEN CONTINUE
|
||||
@L5:
|
||||
LDA #$00 ;IF END, TURN EVERYTHING OFF
|
||||
|
@ -109,7 +110,7 @@ _busy: .byte $00
|
|||
LDA #$70 ;ZERO AMPLITUDE
|
||||
STA CTTRAMP
|
||||
LDA #$00 ;CLEAR BUSY FLAG
|
||||
STA _busy
|
||||
STA _speechBusy
|
||||
LDA #$02 ;CLEAR INTERRUPT ENABLE
|
||||
STA IER ;IN 6522
|
||||
LDA #$FF
|
||||
|
@ -117,6 +118,10 @@ _busy: .byte $00
|
|||
LDA #$07
|
||||
STA DDRB
|
||||
@L2:
|
||||
LDA OUTPTR
|
||||
STA _outptr
|
||||
LDA OUTPTR+1
|
||||
STA _outptr+1
|
||||
PLA ;RESTORE REGISTERS
|
||||
TAY
|
||||
PLA
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// speech_api.c
|
||||
// mocktest
|
||||
//
|
||||
// Created by Jeremy Rand on 2016-10-17.
|
||||
// Copyright © 2016 Jeremy Rand. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "speech_api.h"
|
||||
#include "speech.h"
|
||||
|
||||
|
||||
bool speechIsBusy(void)
|
||||
{
|
||||
static uint16_t old_outptr = 0;
|
||||
if (old_outptr == 0) {
|
||||
printf("endptr=%x\n", endptr);
|
||||
}
|
||||
if (old_outptr != outptr) {
|
||||
old_outptr = outptr;
|
||||
printf("%x ", old_outptr);
|
||||
}
|
||||
//printf("busy=0x%x, outptr=0x%x, endptr=0x%x\n", speechBusy, outptr, endptr);
|
||||
return (speechBusy != 0);
|
||||
}
|
||||
|
||||
|
||||
bool speakMessage(uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
if (speechIsBusy())
|
||||
return false;
|
||||
|
||||
speechData = data;
|
||||
speechLen = dataLen;
|
||||
setupSpeech();
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// speech_api.h
|
||||
// mocktest
|
||||
//
|
||||
// Created by Jeremy Rand on 2016-10-17.
|
||||
// Copyright © 2016 Jeremy Rand. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __mocktest__speech_api__
|
||||
#define __mocktest__speech_api__
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
extern bool speechIsBusy(void);
|
||||
extern bool speakMessage(uint8_t *data, uint16_t dataLen);
|
||||
|
||||
|
||||
|
||||
#endif /* defined(__mocktest__speech_api__) */
|
Loading…
Reference in New Issue