mirror of
https://github.com/jeremysrand/mocklib.git
synced 2024-11-17 15:08:37 +00:00
120 lines
3.7 KiB
C
120 lines
3.7 KiB
C
/*
|
|
* main.c
|
|
* mocktest
|
|
*
|
|
* Created by Jeremy Rand on 2016-09-10.
|
|
* Copyright (c) 2016 Jeremy Rand. All rights reserved.
|
|
*
|
|
*/
|
|
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#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;
|
|
|
|
|
|
tMockingSoundRegisters soundData1 = {
|
|
{ TONE_PERIOD_A(4), 0, 0 }, // Tone period for the three channels
|
|
MIN_NOISE_PERIOD, // Noise period
|
|
ENABLE_CHANNEL(TONE_CHANNEL_A), // Enable
|
|
{ MAX_AMPLITUDE, MIN_AMPLITUDE, MIN_AMPLITUDE }, // Amplitude for the three channels
|
|
MIN_ENVELOPE_PERIOD, // Envelope period
|
|
ENVELOPE_SHAPE_ONE_SHOT_DECAY, // Envelope shape
|
|
0, // Dummy1
|
|
0 // Dummy2
|
|
};
|
|
|
|
|
|
tMockingSoundRegisters soundData2 = {
|
|
{ TONE_PERIOD_F_SHARP(3), 0, 0 }, // Tone period for the three channels
|
|
MIN_NOISE_PERIOD, // Noise period
|
|
ENABLE_CHANNEL(TONE_CHANNEL_A), // Enable
|
|
{ MAX_AMPLITUDE, MIN_AMPLITUDE, MIN_AMPLITUDE }, // Amplitude for the three channels
|
|
MIN_ENVELOPE_PERIOD, // Envelope period
|
|
ENVELOPE_SHAPE_ONE_SHOT_DECAY, // Envelope shape
|
|
0, // Dummy1
|
|
0 // Dummy2
|
|
};
|
|
|
|
|
|
uint8_t mySpeechData[] = {
|
|
0xE8, 0x70, 0xA8, 0x5F, 0x00, 0xE8, 0x70, 0xA8,
|
|
0x5F, 0x00, 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, 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
|
|
};
|
|
|
|
|
|
void delay(void)
|
|
{
|
|
int i;
|
|
for (i = 0; i < 1000; i++) ;
|
|
}
|
|
|
|
|
|
int main(void)
|
|
{
|
|
mockingBoardInit(4);
|
|
|
|
printf("HELLO, WORLD!\n");
|
|
|
|
while (!kbhit()) {
|
|
mockingBoardTableAccess(SOUND_CHIP_1, &soundData1);
|
|
delay();
|
|
mockingBoardReset(SOUND_CHIP_1);
|
|
|
|
mockingBoardTableAccess(SOUND_CHIP_2, &soundData2);
|
|
delay();
|
|
mockingBoardReset(SOUND_CHIP_2);
|
|
}
|
|
|
|
cgetc();
|
|
printf("RUN SPEECH TEST (Y/N) ");
|
|
if (cgetc() != 'Y')
|
|
return 0;
|
|
printf("\n");
|
|
|
|
speechData = mySpeechData;
|
|
speechLen = sizeof(mySpeechData) - 1;
|
|
setupSpeech();
|
|
while (!kbhit()) {
|
|
//printf("numIRQs = %d\n", numIRQs);
|
|
}
|
|
|
|
cgetc();
|
|
|
|
return 0;
|
|
}
|