#include "board.h"
#include "lcd.h"
#include "filesys.h"
#include "vs10xx.h"
#include "storage.h"
#include "display.h"
#include "string.h"
#include "ui.h"
#include "mmc.h"
#include "record.h"
#include "miditext1103.ctab-installed"
Include dependency graph for player.c:
Go to the source code of this file.
Defines | |
#define | u_int8 code unsigned char |
typedef for loading patch code | |
#define | u_int16 code unsigned int |
typedef for loading patch code | |
#define | CODELEN CODE_SIZE |
#define | UI_RETURN_DELAY 150 |
How much to wait for button pressed before returning to title. | |
Functions | |
void | timer0_interrupt (void) |
User Interface Timer interrupt. | |
void | timer1_interrupt (void) |
void | MessageBox (char *Msg) |
Display a message box to user and prompt for key press. | |
void | LoadPatch () |
Load a patch code to VS10xx. | |
void | StartPatch () |
Start patch code. | |
unsigned char | PlayerTaskHandler () |
Check status of buffers and do one disk block transfer. | |
void | CancelRecord () |
Stop recording. | |
void | CancelWave () |
Stop wave file playing. | |
void | CancelMidi () |
Stop MIDI file playing. | |
void | SetMidiFromUART () |
Route MIDI from UART in realtime mode. | |
void | SetMidiFromFile () |
Route MIDI from SCI in file play mode. | |
void | EchoEnable () |
Enable delay echo. | |
void | EchoDisable () |
unsigned char | SelectMidiFile (int fileNumber) |
unsigned char | SelectRecordFile (int fileNumber) |
unsigned char | SelectWaveFile (int fileNumber) |
void | AvailableProcessorTime () |
User interface. | |
void | main () |
Program Entry Point. | |
Variables | |
xdata playingstatetype | playingState = PS_NORMAL |
Playing State Global, 0=normal playing, 1=abort playing. | |
bit | userInterfaceDelayElapsed = 0 |
Interrupt-driven flag to reduce unnecessary UI updates. | |
bit | lyricsDisplay |
xdata uimodetype | uiMode = 0 |
Current User Interface mode (Title, Volume, ...). | |
xdata unsigned char | SPMax = 0 |
xdata int | currentWaveFile |
xdata int | currentMidiFile |
xdata int | currentRecordFile |
xdata char | lyrics [40] |
xdata unsigned char | volume |
| |
xdata unsigned char | bass |
| |
xdata unsigned char | treble = 64 |
| |
xdata unsigned char | reclevel = 50 |
| |
xdata signed char | transpose = 0 |
xdata unsigned int | midiChannelMask |
xdata unsigned char | currentWaveVolume |
xdata unsigned char | currentMidiVolume |
xdata unsigned char | currentMicVolume |
xdata unsigned char | currentMicGainSetting |
bit | midiSciActive |
bit | midiDisk |
xdata unsigned char | midiCurrentFragment |
xdata unsigned long | midiCurrentSector |
xdata unsigned long | midiSectorsLeftInFragment |
bit | waveSdiActive |
bit | waveDisk |
xdata unsigned char | waveCurrentFragment |
xdata unsigned long | waveCurrentSector |
xdata unsigned long | waveSectorsLeftInFragment |
bit | recordActive |
bit | recordDisk |
xdata unsigned long | recordCurrentSector |
xdata unsigned long | recordSectorsLeftInFragment |
bit | echoActive |
data signed char | rotaryValue |
Definition in file player.c.
|
|
|
typedef for loading patch code
|
|
typedef for loading patch code
|
|
How much to wait for button pressed before returning to title.
|
|
User interface. This function is called when the player is playing a song and there is free processor time. The basic task of this function is to implement the player user interface. Bass/Treble settings have been changed Key has been pressed but not released Bass/Treble setting calculation There are 2 or 4 adjustments possible:
In this software, all are adjusted based from a single setting (0..128) for bass and another for treble. You may wish to allow user to control frequency and level separately or set fixed frequencies for a known speaker type. This algorithm increases the frequency range of adjustment with the increasing level. Definition at line 1105 of file player.c. References bass, CancelRecord(), currentMicGainSetting, currentMicVolume, currentMidiFile, currentMidiVolume, currentRecordFile, currentWaveFile, currentWaveVolume, EchoDisable(), EchoEnable(), KEY_DOWN, KEY_LEFT, KEY_UP, LcdReset(), lyricsDisplay, midiChannelMask, Mp3ReadRegister(), Mp3SetMixerVolume(), Mp3SetVolume, Mp3WriteRegister, PlayerTaskHandler(), rotaryValue, SCI_BASS, SelectMidiFile(), SelectRecordFile(), SelectWaveFile(), SetDisplayPercent(), SetDisplaySignedValue(), SetDisplayText(), SetMidiFromFile(), SetMidiFromUART(), transpose, treble, UI_ECHOMODE, UI_MIC_GAIN, UI_MIC_VOLUME, UI_MIDIFILE, UI_MIDISOURCE, UI_MIDITRANSPOSE, UI_MIDIVOLUME, UI_RECORDFILE, UI_VOLUME, UI_WAVEFILE, UI_WAVEVOLUME, uiMode, UpdateDisplay(), userInterfaceDelayElapsed, volume, Vs1103B_SetChannelMask(), Vs1103B_SetMidiTranspose(), and Vs1103SetMicGain(). Referenced by main(), and PlayDiskSectors(). 01105 { 01106 unsigned int i; //temp variable 01108 static bit bassUpdateNeeded; 01110 static bit keyInTransit; 01111 01112 01113 if (!userInterfaceDelayElapsed){ 01114 return; /* Not yet time to do user interface stuff */ 01115 } 01116 userInterfaceDelayElapsed = 0; 01117 01118 if (keyInTransit){ //Keypress already registered 01119 if (!KEY_UP && !KEY_DOWN && !KEY_LEFT && !KEY_RIGHT){ 01120 keyInTransit = 0; //Wait until key not pressed 01121 } 01122 }else{ //Is there a new keypress? 01123 if (KEY_UP){ 01124 rotaryValue = NEXT_THRESHOLD; 01125 keyInTransit = 1; 01126 } 01127 if (KEY_DOWN){ 01128 rotaryValue = PREV_THRESHOLD; 01129 keyInTransit = 1; 01130 } 01131 01132 if (KEY_LEFT){ 01133 if (uiMode) { 01134 uiMode--; 01135 keyInTransit = 1; 01136 rotaryValue = 0; 01137 } 01138 } 01139 if (KEY_RIGHT){ 01140 uiMode++; 01141 keyInTransit = 1; 01142 if (uiMode == UI_END_OF_MODES) { 01143 uiMode--; 01144 } 01145 rotaryValue = 0; 01146 } 01147 if (keyInTransit){ 01148 //Always do this once when a key is pressed: 01149 LcdReset(); 01150 lyricsDisplay = 0; 01151 } 01152 } 01153 01154 01155 01156 01157 // K E Y B O A R D E V E N T S 01158 // ----------------------------- 01159 01160 01161 // N E X T 01162 // N E X T 01163 01164 01165 //Is there a large PLUS(UP) rotation? This can mean 01166 //a "NEXT" or "SWITCH ON" request from the user 01167 if (rotaryValue >= NEXT_THRESHOLD) { 01168 signed char storedRotaryValue = rotaryValue; 01169 01170 01171 // Do all midi ch on/off settings in one place 01172 if ((uiMode >= UI_MIDI_CH1) && (uiMode <= UI_MIDI_CH16)){ 01173 midiChannelMask &= ~(1 << (uiMode - UI_MIDI_CH1)); 01174 Vs1103B_SetChannelMask(midiChannelMask); 01175 SetDisplayText(uiMode,"On "); 01176 rotaryValue = 0; 01177 01178 }else{ 01179 rotaryValue = 0; 01180 01181 //What parameters can be affected? 01182 switch(uiMode){ 01183 case UI_MIDITRANSPOSE: 01184 transpose++; 01185 SetDisplaySignedValue(UI_MIDITRANSPOSE,transpose); 01186 Vs1103B_SetMidiTranspose(transpose); 01187 break; 01188 01189 01190 case UI_RECORDFILE: 01191 if (currentRecordFile){ 01192 currentRecordFile=0; 01193 CancelRecord(); 01194 }else{ 01195 currentRecordFile = 0; 01196 if (!SelectRecordFile(1)){ 01197 currentRecordFile = 1; 01198 } 01199 } 01200 break; 01201 01202 case UI_WAVEFILE: 01203 if (!SelectWaveFile(currentWaveFile+1)){ 01204 currentWaveFile++; 01205 } 01206 break; 01207 01208 case UI_MIDIFILE: 01209 if (!SelectMidiFile(currentMidiFile+1)){ 01210 currentMidiFile++; 01211 } 01212 break; 01213 01214 case UI_MIDISOURCE: 01215 SetMidiFromUART(); 01216 break; 01217 01218 01219 case UI_ECHOMODE: 01220 EchoEnable(); 01221 break; 01222 01223 01224 default: 01225 //The request does not apply to current uiMode 01226 rotaryValue = storedRotaryValue; //restore value 01227 break; 01228 } 01229 } 01230 } 01231 01232 01233 01234 01235 // P R E V I O U S 01236 // P R E V I O U S 01237 01238 01239 //Is there a large MINUS rotation? This can mean 01240 //a "PREVIOUS" or "SWITCH OFF" request from the user 01241 if (rotaryValue <= PREV_THRESHOLD) { 01242 signed char storedRotaryValue = rotaryValue; 01243 01244 // Do all midi ch on/off settings in one place 01245 if ((uiMode >= UI_MIDI_CH1) && (uiMode <= UI_MIDI_CH16)){ 01246 midiChannelMask |= (1 << (uiMode - UI_MIDI_CH1)); 01247 Vs1103B_SetChannelMask(midiChannelMask); 01248 SetDisplayText(uiMode,"Off "); 01249 rotaryValue = 0; 01250 01251 }else{ 01252 rotaryValue = 0; //Store and clear 01253 //What parameters can be affected? 01254 01255 01256 switch(uiMode){ 01257 01258 01259 case UI_WAVEFILE: 01260 if (!SelectWaveFile(currentWaveFile-1)){ 01261 currentWaveFile--; 01262 } 01263 break; 01264 01265 case UI_MIDIFILE: 01266 if (!SelectMidiFile(currentMidiFile-1)){ 01267 currentMidiFile--; 01268 } 01269 break; 01270 01271 01272 case UI_RECORDFILE: 01273 if (currentRecordFile){ 01274 currentRecordFile=0; 01275 CancelRecord(); 01276 }else{ 01277 currentRecordFile = 0; 01278 if (!SelectRecordFile(-1)){ 01279 currentRecordFile = -1; 01280 } 01281 } 01282 break; 01283 01284 case UI_MIDITRANSPOSE: 01285 transpose--; 01286 SetDisplaySignedValue(UI_MIDITRANSPOSE,transpose); 01287 Vs1103B_SetMidiTranspose(transpose); 01288 break; 01289 01290 case UI_MIDISOURCE: 01291 SetMidiFromFile(); 01292 break; 01293 01294 case UI_ECHOMODE: 01295 EchoDisable(); 01296 break; 01297 01298 default: 01299 //The request does not apply to current uiMode 01300 rotaryValue = storedRotaryValue; //restore value 01301 break; 01302 } 01303 } 01304 } 01305 01306 01307 01308 01309 01310 01311 // A D J U S T 01312 // A D J U S T 01313 01314 //Is there a plus/minus value from the rotary button? 01315 if (rotaryValue){ 01316 lyricsDisplay = 0; 01317 01318 //What parameter is affected by the rotary value? 01319 switch(uiMode){ 01320 01321 case UI_MIDIVOLUME: 01322 if (rotaryValue>0){ 01323 if (currentMidiVolume<30){ 01324 currentMidiVolume++; 01325 } 01326 } else { 01327 if (currentMidiVolume){ 01328 currentMidiVolume--; 01329 } 01330 } 01331 Mp3SetMixerVolume(currentMidiVolume, currentWaveVolume, 01332 currentMicVolume); 01333 SetDisplayPercent(UI_MIDIVOLUME, currentMidiVolume); 01334 rotaryValue = 0; 01335 break; 01336 01337 case UI_WAVEVOLUME: 01338 if (rotaryValue>0){ 01339 if (currentWaveVolume<30){ 01340 currentWaveVolume++; 01341 } 01342 } else { 01343 if (currentWaveVolume){ 01344 currentWaveVolume--; 01345 } 01346 } 01347 Mp3SetMixerVolume(currentMidiVolume, currentWaveVolume, 01348 currentMicVolume); 01349 SetDisplayPercent(UI_WAVEVOLUME, currentWaveVolume); 01350 rotaryValue = 0; 01351 break; 01352 01353 case UI_MIC_VOLUME: 01354 if (rotaryValue>0){ 01355 if (currentMicVolume<30){ 01356 currentMicVolume++; 01357 } 01358 } else { 01359 if (currentMicVolume){ 01360 currentMicVolume--; 01361 } 01362 } 01363 Mp3SetMixerVolume(currentMidiVolume, currentWaveVolume, 01364 currentMicVolume); 01365 SetDisplayPercent(UI_MIC_VOLUME, currentMicVolume); 01366 rotaryValue = 0; 01367 break; 01368 01369 case UI_MIC_GAIN: 01370 if (rotaryValue>0){ 01371 if (currentMicGainSetting<62){ 01372 currentMicGainSetting++; 01373 } 01374 } else { 01375 if (currentMicGainSetting){ 01376 currentMicGainSetting--; 01377 } 01378 } 01379 Vs1103SetMicGain(currentMicGainSetting); 01380 SetDisplayPercent(UI_MIC_GAIN, currentMicGainSetting); 01381 rotaryValue = 0; 01382 break; 01383 01384 case UI_VOLUME: 01385 if (volume>=rotaryValue){ 01386 volume-=rotaryValue; 01387 } 01388 rotaryValue = 0; 01389 Mp3SetVolume(volume,volume); 01390 if (volume<100){ 01391 SetDisplayPercent(UI_VOLUME,(100-volume)); 01392 }else{ 01393 SetDisplayPercent(UI_VOLUME,0); 01394 } 01395 rotaryValue = 0; 01396 break; 01397 01398 01399 default: 01400 break; 01401 } 01402 }//Switch 01403 01404 PlayerTaskHandler(); 01405 UpdateDisplay(uiMode); 01406 PlayerTaskHandler(); 01407 01408 01409 if (bassUpdateNeeded){ 01410 unsigned int newBassRegister; 01411 01412 //User has pushed button to alter bass/treble register 01413 //calculate new value 01414 01430 //Let's start from bass frequency setting. 01431 //min(0) should give 2 (20Hz), max(127) should give 15 (150Hz) 01432 newBassRegister = (bass + 23) / 10; //into bits 3..0, clear hibits 01433 01434 //Bass boost level. 01435 //min(0) should give 0, max(127) should give 15 01436 newBassRegister |= (bass>>3)<<4; //insert to bits 7..4 01437 01438 //Then the treble frequency 01439 //min(0) should give 15(15kHx), max(127) should give 2(2kHz) 01440 newBassRegister |= (((148-treble)>>3)+2)<<8; //insert into bits 11..8 01441 01442 //Finally the treble value (-8..7) 01443 //min(0) should give -8, max(127) should give 7; 01444 newBassRegister |= ((treble>>3)-8)<<12; //insert into bits 15..12 01445 01446 if (Mp3ReadRegister(SCI_BASS)!=newBassRegister){ 01447 Mp3WriteRegister(SCI_BASS,newBassRegister>>8,newBassRegister&0xff); 01448 } 01449 } 01450 01451 }
|
Here is the call graph for this function:
|
Stop MIDI file playing.
Definition at line 827 of file player.c. References midiSciActive, SetDisplayText(), UI_MIDIFILE, and Vs1103CancelMidi(). Referenced by SelectMidiFile(), and SetMidiFromUART(). 00827 { 00828 if (midiSciActive){ 00829 Vs1103CancelMidi(); 00830 } 00831 midiSciActive = 0; 00832 SetDisplayText(UI_MIDIFILE," ---- "); 00833 }
|
Here is the call graph for this function:
|
Stop recording.
Definition at line 800 of file player.c. References currentRecordFile, echoActive, recordActive, SetDisplayText(), UI_ECHOMODE, UI_RECORDFILE, vs1103_recording_active, and Vs1103SetMode(). Referenced by AvailableProcessorTime(), EchoDisable(), EchoEnable(), SetMidiFromFile(), and SetMidiFromUART(). 00800 { 00801 if (recordActive || vs1103_recording_active){ 00802 00803 echoActive = 0; 00804 recordActive = 0; 00805 vs1103_recording_active = 0; 00806 Vs1103SetMode(); 00807 SetDisplayText(UI_ECHOMODE, "Play/Record "); 00808 00809 currentRecordFile = 0; 00810 SetDisplayText(UI_RECORDFILE,"---- "); 00811 00812 00813 } 00814 }
|
Here is the call graph for this function:
|
Stop wave file playing.
Definition at line 818 of file player.c. References SetDisplayText(), UI_WAVEFILE, Vs1103CancelWave(), and waveSdiActive. Referenced by EchoDisable(), EchoEnable(), SelectWaveFile(), SetMidiFromFile(), and SetMidiFromUART(). 00818 { 00819 if (waveSdiActive){ 00820 Vs1103CancelWave(); 00821 } 00822 waveSdiActive = 0; 00823 SetDisplayText(UI_WAVEFILE,"---- "); 00824 }
|
Here is the call graph for this function:
|
Definition at line 935 of file player.c. References CancelRecord(), CancelWave(), echoActive, and vs1103_record_mixer. Referenced by AvailableProcessorTime(). 00935 { 00936 echoActive = 0; 00937 vs1103_record_mixer = 1; 00938 CancelWave(); 00939 CancelRecord(); 00940 }
|
Here is the call graph for this function:
|
Enable delay echo. It's done by sending the mic recording result ADPCM stream back to the WAVE IN port of VS1103 Definition at line 875 of file player.c. References DiskBlock::Raw::buf, Temp::c, CancelRecord(), CancelWave(), currentMicVolume, currentMidiVolume, currentWaveVolume, dataBufPtr, diskSect, echoActive, Temp::i, Mp3DeselectData, Mp3SelectData, Mp3SetMixerVolume(), DiskBlock::raw, RIFFHeader0, RIFFHeader504, SetDisplayPercent(), SetDisplayText(), SPIPutCharWithoutWaiting, SPIWait, temp, UI_ECHOMODE, UI_WAVEVOLUME, vs1103_record_mixer, vs1103_recording_active, and Vs1103SetMode(). Referenced by AvailableProcessorTime(). 00875 { 00876 CancelWave(); 00877 CancelRecord(); 00878 echoActive = 1; 00879 vs1103_recording_active = 1; 00880 vs1103_record_mixer = 1; //1 = reverb echo; 0 = delay echo 00881 Vs1103SetMode(); 00882 00883 currentWaveVolume = 11; 00884 Mp3SetMixerVolume(currentMidiVolume, currentWaveVolume, 00885 currentMicVolume); 00886 SetDisplayPercent(UI_WAVEVOLUME, currentWaveVolume); 00887 SetDisplayText(UI_ECHOMODE, "Delay Echo "); 00888 00889 00890 // MAKE A WAV HEADER AND TRANSMIT IT TO VS1103 00891 for (temp.c=0; temp.c<56; temp.c++){ //temp is unsafe global temp variable. 00892 // diskSect.raw.buf[temp.c] = RIFFHeader9k6Hz[temp.c]; 00893 diskSect.raw.buf[temp.c] = RIFFHeader0[temp.c]; 00894 } 00895 for (temp.i=52; temp.i<504; temp.i++){ 00896 diskSect.raw.buf[temp.i] = 0; 00897 } 00898 for (temp.i=504; temp.i<512; temp.i++){ 00899 diskSect.raw.buf[temp.i] = RIFFHeader504[temp.i-504]; 00900 } 00901 00902 Mp3SelectData(); 00903 // BlockTransmit in C 00904 dataBufPtr = diskSect.raw.buf; 00905 // Use global pointer and unrolled loop for speed 00906 while (dataBufPtr < diskSect.raw.buf+512){ 00907 SPIPutCharWithoutWaiting(*dataBufPtr++); 00908 SPIPutCharWithoutWaiting(*dataBufPtr++); 00909 SPIPutCharWithoutWaiting(*dataBufPtr++); 00910 SPIPutCharWithoutWaiting(*dataBufPtr++); 00911 SPIPutCharWithoutWaiting(*dataBufPtr++); 00912 SPIPutCharWithoutWaiting(*dataBufPtr++); 00913 SPIPutCharWithoutWaiting(*dataBufPtr++); 00914 SPIPutCharWithoutWaiting(*dataBufPtr++); 00915 SPIPutCharWithoutWaiting(*dataBufPtr++); 00916 SPIPutCharWithoutWaiting(*dataBufPtr++); 00917 SPIPutCharWithoutWaiting(*dataBufPtr++); 00918 SPIPutCharWithoutWaiting(*dataBufPtr++); 00919 SPIPutCharWithoutWaiting(*dataBufPtr++); 00920 SPIPutCharWithoutWaiting(*dataBufPtr++); 00921 SPIPutCharWithoutWaiting(*dataBufPtr++); 00922 SPIPutCharWithoutWaiting(*dataBufPtr++); 00923 } 00924 { 00925 int i; 00926 for (i=0; i<512; i++){ 00927 SPIPutCharWithoutWaiting(0); 00928 SPIWait(); 00929 } 00930 } 00931 00932 Mp3DeselectData(); 00933 }
|
Here is the call graph for this function:
|
Load a patch code to VS10xx.
Definition at line 157 of file player.c. References ConsoleWrite, Delay(), Temp::i, Mp3WriteRegister, and temp. Referenced by Mp3Reset(), and SetMidiFromUART(). 00157 { 00158 #if 1 00159 ConsoleWrite ("Loading patch.\r"); 00160 for (temp.i=0; temp.i < CODELEN; temp.i++) { 00161 while (!MP3_DREQ) 00162 ; 00163 Mp3WriteRegister(atab[temp.i], dtab[temp.i]>>8, dtab[temp.i]&0xff); 00164 while (!MP3_DREQ) 00165 ; 00166 } 00167 Delay(10); 00168 #endif 00169 }
|
Here is the call graph for this function:
|
Program Entry Point. In the final program, main() should be very small. Currently it's the playground for developing the player functionality. Most of it will be cleared away to new functions soon. Definition at line 1458 of file player.c. References AvailableProcessorTime(), bass, ConsoleWrite, currentMicGainSetting, currentMicVolume, currentMidiFile, currentMidiVolume, currentWaveFile, currentWaveVolume, echoActive, InitBoard(), InitFileSystem(), LcdLocateHome, LcdLocateLine2, LcdPutConstantString(), LcdReset(), lyrics, lyricsDisplay, midiChannelMask, midiSciActive, Mp3ReadRegister(), Mp3Reset(), Mp3SetMixerVolume(), PlayerTaskHandler(), recordActive, RED_LED, SCI_AICTRL3, SetDisplayPercent(), SetDisplaySignedValue(), SetDisplayText(), SetDisplayTitle(), transpose, treble, UI_BASS, UI_ECHOMODE, UI_MIC_GAIN, UI_MIC_VOLUME, UI_MIDI_CH1, UI_MIDIFILE, UI_MIDISOURCE, UI_MIDITRANSPOSE, UI_MIDIVOLUME, UI_RECORDFILE, UI_TREBLE, UI_VOLUME, UI_WAVEFILE, UI_WAVEVOLUME, uiMode, volume, vs1103_real_time_midi, vs1103_record_mixer, vs1103_recording_active, Vs1103SetMicGain(), Vs1103SetMode(), and waveSdiActive. 01458 { 01459 unsigned char i; 01460 P2_1 = 0; 01461 01462 01463 waveSdiActive = 0; 01464 midiSciActive = 0; 01465 recordActive = 0; 01466 echoActive = 0; 01467 InitBoard(); 01468 01469 ConsoleWrite("\rApplication Start.\r"); 01470 P2_1 = 1; 01471 LcdReset(); 01472 LcdReset(); 01473 LcdLocateHome(); 01474 LcdPutConstantString (" VS1103B MIDI/ADPCM/Karaoke Chip Demo"); 01475 LcdLocateLine2(); 01476 LcdPutConstantString (" 2006 VLSI Solution Oy www.vlsi.fi "); 01477 ConsoleWrite ("\rVLSI Karaoke Demo\rStarting up.\r\r"); 01478 RED_LED = LED_ON; 01479 01480 01481 Mp3Reset(); 01482 01483 01484 InitFileSystem(); 01485 01486 // INITIAL MODE AND USER INTERFACE TEXTS 01487 01488 for (i=0; i<UI_END_OF_MODES; i++){ 01489 SetDisplayTitle(i," "); 01490 SetDisplayText(i,"------ "); 01491 } 01492 01493 //SetDisplayTitle(UI_MODE, "Current Mode"); 01494 //SetDisplayText(UI_MODE,"Auto Play "); 01495 01496 SetDisplayTitle(UI_MIDISOURCE, "MIDI Source "); 01497 SetDisplayText(UI_MIDISOURCE, "MIDI Input "); 01498 01499 SetDisplayTitle(UI_MIDIFILE, "MIDIf0 File "); 01500 SetDisplayText(UI_MIDIFILE," ---- "); 01501 01502 01503 SetDisplayTitle(UI_WAVEFILE, "Wave File "); 01504 SetDisplayTitle(UI_RECORDFILE, "Record File "); 01505 01506 SetDisplayTitle(UI_MIDITRANSPOSE, "TransposeMID"); 01507 01508 SetDisplayTitle(UI_MIDIVOLUME, "MIDI Volume "); 01509 SetDisplayTitle(UI_WAVEVOLUME, "Wave Volume "); 01510 SetDisplayTitle(UI_MIC_VOLUME, "Mic Volume "); 01511 SetDisplayTitle(UI_MIC_GAIN, "Mic Gain "); 01512 01513 SetDisplayTitle(UI_VOLUME, "MasterVolume"); 01514 01515 SetDisplayTitle(UI_ECHOMODE, "Wave usage "); 01516 SetDisplayText(UI_ECHOMODE, "Play/Record "); 01517 01518 SetDisplayTitle(UI_BASS, "Bass "); 01519 SetDisplayTitle(UI_TREBLE, "Treble "); 01520 01521 for (i=0; i<40; i++){ 01522 lyrics[i] = ' '; 01523 } 01524 lyrics[0] = 'M'; 01525 lyrics[1] = 'i'; 01526 lyrics[2] = 'd'; 01527 lyrics[3] = 'i'; 01528 01529 lyrics[5] = 'C'; 01530 lyrics[6] = 'h'; 01531 lyrics[7] = '.'; 01532 01533 01534 01535 uiMode = 0; 01536 for (i=1; i<17; i++){ 01537 lyrics[9] = '0' + (i / 10); 01538 lyrics[10] = '0' + (i % 10); 01539 SetDisplayTitle((UI_MIDI_CH1 - 1)+i, lyrics); 01540 SetDisplayText((UI_MIDI_CH1 - 1)+i, "On "); 01541 01542 } 01543 01544 01545 for (i=0; i<40; i++){ 01546 lyrics[i] = ' '; 01547 } 01548 lyricsDisplay = 0; //Not now in lyrics mode 01549 01550 transpose = 0; 01551 SetDisplaySignedValue(UI_MIDITRANSPOSE,transpose); 01552 volume = 8; 01553 SetDisplayPercent(UI_VOLUME,(100-volume)); 01554 bass = 0; 01555 treble = 64; 01556 midiChannelMask = 0; 01557 01558 currentMicGainSetting = 25; 01559 vs1103_record_mixer = 1; 01560 vs1103_recording_active = 0; 01561 vs1103_real_time_midi = 1; 01562 currentMidiFile = 0; 01563 currentWaveFile = 0; 01564 recordActive = 0; 01565 Vs1103SetMicGain(25); 01566 Vs1103SetMode(); // Set Initial Mode 01567 currentWaveVolume = 23; 01568 currentMidiVolume = 23; 01569 currentMicVolume = 23; 01570 Mp3SetMixerVolume(currentMidiVolume, currentWaveVolume, currentMicVolume); 01571 SetDisplayPercent(UI_MIDIVOLUME, currentMidiVolume); 01572 SetDisplayPercent(UI_WAVEVOLUME, currentWaveVolume); 01573 SetDisplayPercent(UI_MIC_VOLUME, currentMicVolume); 01574 SetDisplayPercent(UI_MIC_GAIN, currentMicGainSetting); 01575 01576 RED_LED = LED_OFF; 01577 01578 // Start "User Interface" timer 01579 ET0 = 1; 01580 EA = 1; 01581 TR0 = 1; 01582 01583 01584 // SYSTEM MAIN LOOP 01585 while(1){ 01586 data unsigned int ilyric; 01587 01588 while(PlayerTaskHandler()) 01589 ; //Do all pending data transfers 01590 01591 AvailableProcessorTime(); //User Interface Handler 01592 01593 //Read Back Lyrics from the VS1103 01594 ilyric = Mp3ReadRegister(SCI_AICTRL3); 01595 if (ilyric){ 01596 if (ilyric & 0xFF00U){ 01597 //ConsolePutHex16(i);//Debug info 01598 }else{ 01599 //Shift the lyrics display buffer 1 char to the left 01600 for (i=0; i<39; i++){ 01601 lyrics[i] = lyrics[i+1]; 01602 } 01603 //Add a new lyrics character to the lyrics display buffer 01604 lyrics[39] = ilyric; 01605 lyricsDisplay = 1; 01606 } 01607 } 01608 } 01609 }
|
Here is the call graph for this function:
|
Display a message box to user and prompt for key press.
Definition at line 142 of file player.c. References LcdLocateLine2, LcdPutConstantString(), LcdPutString(), and LcdReset(). Referenced by SelectMidiFile(), SetMidiFromFile(), and SetMidiFromUART(). 00142 { 00143 LcdReset(); 00144 LcdPutString(Msg); 00145 LcdLocateLine2(); 00146 LcdPutConstantString(" [~ OK]"); 00147 while (KEY_RIGHT) 00148 ; 00149 while (!KEY_RIGHT) 00150 ; 00151 LcdReset(); 00152 }
|
Here is the call graph for this function:
|
Check status of buffers and do one disk block transfer.
Definition at line 189 of file player.c. References DiskBlock::Raw::buf, dataBufPtr, diskSect, GREEN_LED, Address::l, LED1, fragmentEntry::length, midiCurrentFragment, midiCurrentSector, midiDisk, midiFragment, midiSciActive, midiSectorsLeftInFragment, Mp3DeselectControl, Mp3DeselectData, Mp3ReadRegister(), Mp3SelectControl, Mp3SelectData, DiskBlock::raw, recordActive, recordCurrentSector, recordDisk, recordSectorsLeftInFragment, RED_LED, SCI_IN0, SCI_IN1, sectorAddress, SelectDisk(), SPIPutCharWithoutWaiting, SPIWait, fragmentEntry::start, TransferSectorSCI(), TransferSectorSDI(), VS_READ_COMMAND, waveCurrentFragment, waveCurrentSector, waveDisk, waveFragment, waveSdiActive, waveSectorsLeftInFragment, and WriteDiskSector(). 00189 { 00190 //_____________________________________________________ 00191 // WAV playing ---------------------------------------- 00192 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 00193 00194 00195 // Highest priority: WAVE IN stream is SDI stream in 00196 // Check whether SDI in stream has space for 1 disk sector 00197 if ((waveSdiActive) && (MP3_DREQ)){ 00198 GREEN_LED=LED_ON; 00199 00200 SelectDisk(waveDisk); 00201 TransferSectorSDI(waveCurrentSector); //Send WAV to VS1103 00202 00203 // Find next sector or end of file 00204 waveCurrentSector++; 00205 if (waveSectorsLeftInFragment-- == 0){ 00206 waveCurrentFragment++; 00207 waveCurrentSector = waveFragment[waveCurrentFragment].start; 00208 waveSectorsLeftInFragment = waveFragment[waveCurrentFragment].length; 00209 if (waveSectorsLeftInFragment == 0) { 00210 waveSdiActive = 0; 00211 } 00212 } 00213 GREEN_LED=LED_OFF; 00214 return 1; 00215 } 00216 00217 00218 00219 //_____________________________________________________ 00220 //Recording ------------------------------------------- 00221 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 00222 00223 00224 if ((recordActive) && ((Mp3ReadRegister(SCI_IN1) >> 8) >= 0x20)){ 00225 //Sector is available for storing 00226 00227 // EA=0; 00228 // BlockReceive in C 00229 dataBufPtr = diskSect.raw.buf; 00230 // Use global pointer and unrolled loop for speed 00231 while (dataBufPtr < diskSect.raw.buf+512){ 00232 00233 00234 // Below is the spi data transfer code in ASSEMBLER 00235 // (for super fast data read from VS1103) and also in C. 00236 00237 // READ ONE SECTOR (512 bytes) FROM VS1103 REC BUFFER 00238 // TO DISKSECT.RAW.BUF[512] 00239 00240 #if 1 00241 _asm 00242 00243 push dpl 00244 push dph 00245 push psw 00246 push acc 00247 mov dpl,_dataBufPtr 00248 mov dph,(_dataBufPtr + 1) 00249 00250 00251 // CHIP SELECT 00252 clr _P2_3 00253 mov _SPDAT,#0x03 00254 mov a,_SPSTA 00255 jnb acc.7,.-4 00256 mov _SPDAT,#0x08 00257 mov a,_SPSTA 00258 jnb acc.7,.-4 00259 mov _SPDAT,#0xFF 00260 mov a,_SPSTA 00261 jnb acc.7,.-4 00262 mov a,_SPDAT 00263 00264 00265 mov _SPDAT,#0xFF 00266 movx @dptr,a 00267 inc dptr 00268 // CHIP DESELECT 00269 setb _P2_3 00270 // CHIP SELECT 00271 clr _P2_3 00272 mov a,_SPDAT 00273 mov _SPDAT,#0x03 00274 movx @dptr,a 00275 mov _SPDAT,#0x08 00276 inc dptr 00277 mov a,_SPSTA 00278 mov _SPDAT,#0xFF 00279 nop 00280 nop 00281 nop 00282 mov a,_SPSTA 00283 mov a,_SPDAT 00284 00285 00286 mov _SPDAT,#0xFF 00287 movx @dptr,a 00288 inc dptr 00289 // CHIP DESELECT 00290 setb _P2_3 00291 // CHIP SELECT 00292 clr _P2_3 00293 mov a,_SPDAT 00294 mov _SPDAT,#0x03 00295 movx @dptr,a 00296 mov _SPDAT,#0x08 00297 inc dptr 00298 mov a,_SPSTA 00299 mov _SPDAT,#0xFF 00300 nop 00301 nop 00302 nop 00303 mov a,_SPSTA 00304 mov a,_SPDAT 00305 00306 00307 mov _SPDAT,#0xFF 00308 movx @dptr,a 00309 inc dptr 00310 // CHIP DESELECT 00311 setb _P2_3 00312 // CHIP SELECT 00313 clr _P2_3 00314 mov a,_SPDAT 00315 mov _SPDAT,#0x03 00316 movx @dptr,a 00317 mov _SPDAT,#0x08 00318 inc dptr 00319 mov a,_SPSTA 00320 mov _SPDAT,#0xFF 00321 nop 00322 nop 00323 nop 00324 mov a,_SPSTA 00325 mov a,_SPDAT 00326 00327 00328 mov _SPDAT,#0xFF 00329 movx @dptr,a 00330 inc dptr 00331 // CHIP DESELECT 00332 setb _P2_3 00333 // CHIP SELECT 00334 clr _P2_3 00335 mov a,_SPDAT 00336 mov _SPDAT,#0x03 00337 movx @dptr,a 00338 mov _SPDAT,#0x08 00339 inc dptr 00340 mov a,_SPSTA 00341 mov _SPDAT,#0xFF 00342 nop 00343 nop 00344 nop 00345 mov a,_SPSTA 00346 mov a,_SPDAT 00347 00348 00349 mov _SPDAT,#0xFF 00350 movx @dptr,a 00351 inc dptr 00352 // CHIP DESELECT 00353 setb _P2_3 00354 // CHIP SELECT 00355 clr _P2_3 00356 mov a,_SPDAT 00357 mov _SPDAT,#0x03 00358 movx @dptr,a 00359 mov _SPDAT,#0x08 00360 inc dptr 00361 mov a,_SPSTA 00362 mov _SPDAT,#0xFF 00363 nop 00364 nop 00365 nop 00366 mov a,_SPSTA 00367 mov a,_SPDAT 00368 00369 00370 mov _SPDAT,#0xFF 00371 movx @dptr,a 00372 inc dptr 00373 // CHIP DESELECT 00374 setb _P2_3 00375 // CHIP SELECT 00376 clr _P2_3 00377 mov a,_SPDAT 00378 mov _SPDAT,#0x03 00379 movx @dptr,a 00380 mov _SPDAT,#0x08 00381 inc dptr 00382 mov a,_SPSTA 00383 mov _SPDAT,#0xFF 00384 nop 00385 nop 00386 nop 00387 mov a,_SPSTA 00388 mov a,_SPDAT 00389 00390 00391 mov _SPDAT,#0xFF 00392 movx @dptr,a 00393 inc dptr 00394 // CHIP DESELECT 00395 setb _P2_3 00396 // CHIP SELECT 00397 clr _P2_3 00398 mov a,_SPDAT 00399 mov _SPDAT,#0x03 00400 movx @dptr,a 00401 mov _SPDAT,#0x08 00402 inc dptr 00403 mov a,_SPSTA 00404 mov _SPDAT,#0xFF 00405 nop 00406 nop 00407 nop 00408 mov a,_SPSTA 00409 mov a,_SPDAT 00410 00411 00412 mov _SPDAT,#0xFF 00413 movx @dptr,a 00414 inc dptr 00415 mov a,_SPSTA 00416 mov a,_SPDAT 00417 movx @dptr,a 00418 inc dptr 00419 00420 // CHIP DESELECT 00421 setb _P2_3 00422 00423 mov _dataBufPtr, dpl 00424 mov (_dataBufPtr + 1), dph 00425 pop acc 00426 pop psw 00427 pop dph 00428 pop dpl 00429 00430 00431 _endasm; 00432 00433 #else 00434 Mp3SelectControl(); 00435 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00436 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00437 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00438 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00439 Mp3DeselectControl(); 00440 00441 00442 Mp3SelectControl(); 00443 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00444 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00445 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00446 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00447 Mp3DeselectControl(); 00448 00449 00450 Mp3SelectControl(); 00451 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00452 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00453 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00454 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00455 Mp3DeselectControl(); 00456 00457 00458 Mp3SelectControl(); 00459 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00460 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00461 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00462 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00463 Mp3DeselectControl(); 00464 00465 00466 Mp3SelectControl(); 00467 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00468 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00469 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00470 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00471 Mp3DeselectControl(); 00472 00473 00474 Mp3SelectControl(); 00475 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00476 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00477 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00478 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00479 Mp3DeselectControl(); 00480 00481 00482 Mp3SelectControl(); 00483 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00484 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00485 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00486 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00487 Mp3DeselectControl(); 00488 00489 00490 Mp3SelectControl(); 00491 SPIPutCharWithoutWaiting(VS_READ_COMMAND);SPIWait(); 00492 SPIPutCharWithoutWaiting(SCI_IN0);SPIWait(); 00493 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00494 SPIPutCharWithoutWaiting(0xff); SPIWait(); *dataBufPtr++ = SPI_RESULT_BYTE; 00495 Mp3DeselectControl(); 00496 00497 00498 #endif 00499 00500 } 00501 //ConsolePutChar('w'); 00502 00503 EA=1; 00504 00505 00506 RED_LED = LED_ON; 00507 sectorAddress.l = recordCurrentSector; 00508 recordCurrentSector++; 00509 00510 SelectDisk(recordDisk); 00511 WriteDiskSector(sectorAddress.l); 00512 RED_LED = LED_OFF; 00513 00514 recordSectorsLeftInFragment--; 00515 if (recordSectorsLeftInFragment<1) recordActive = 0; 00516 00517 return 2; 00518 00519 } 00520 00521 //_____________________________________________________ 00522 // ECHO ------------------------------------------- 00523 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 00524 00525 00526 if ((echoActive ) && ((Mp3ReadRegister(SCI_IN1) >> 8) >= 0x20)){ 00527 00528 // EA=0; 00529 // BlockReceive in C 00530 dataBufPtr = diskSect.raw.buf; 00531 // Use global pointer and unrolled loop for speed 00532 while (dataBufPtr < diskSect.raw.buf+256){ 00533 00534 //Similar fast transfer than in the recording mode 00535 // -> record and send back to VS1103 to make echo from the microphone 00536 00537 _asm 00538 00539 push dpl 00540 push dph 00541 push psw 00542 push acc 00543 mov dpl,_dataBufPtr 00544 mov dph,(_dataBufPtr + 1) 00545 00546 00547 // CHIP SELECT 00548 clr _P2_3 00549 mov _SPDAT,#0x03 00550 mov a,_SPSTA 00551 jnb acc.7,.-4 00552 mov _SPDAT,#0x08 00553 mov a,_SPSTA 00554 jnb acc.7,.-4 00555 mov _SPDAT,#0xFF 00556 mov a,_SPSTA 00557 jnb acc.7,.-4 00558 mov a,_SPDAT 00559 00560 00561 mov _SPDAT,#0xFF 00562 movx @dptr,a 00563 inc dptr 00564 // CHIP DESELECT 00565 setb _P2_3 00566 // CHIP SELECT 00567 clr _P2_3 00568 mov a,_SPDAT 00569 mov _SPDAT,#0x03 00570 movx @dptr,a 00571 mov _SPDAT,#0x08 00572 inc dptr 00573 mov a,_SPSTA 00574 mov _SPDAT,#0xFF 00575 nop 00576 nop 00577 nop 00578 mov a,_SPSTA 00579 mov a,_SPDAT 00580 00581 00582 mov _SPDAT,#0xFF 00583 movx @dptr,a 00584 inc dptr 00585 // CHIP DESELECT 00586 setb _P2_3 00587 // CHIP SELECT 00588 clr _P2_3 00589 mov a,_SPDAT 00590 mov _SPDAT,#0x03 00591 movx @dptr,a 00592 mov _SPDAT,#0x08 00593 inc dptr 00594 mov a,_SPSTA 00595 mov _SPDAT,#0xFF 00596 nop 00597 nop 00598 nop 00599 mov a,_SPSTA 00600 mov a,_SPDAT 00601 00602 00603 mov _SPDAT,#0xFF 00604 movx @dptr,a 00605 inc dptr 00606 // CHIP DESELECT 00607 setb _P2_3 00608 // CHIP SELECT 00609 clr _P2_3 00610 mov a,_SPDAT 00611 mov _SPDAT,#0x03 00612 movx @dptr,a 00613 mov _SPDAT,#0x08 00614 inc dptr 00615 mov a,_SPSTA 00616 mov _SPDAT,#0xFF 00617 nop 00618 nop 00619 nop 00620 mov a,_SPSTA 00621 mov a,_SPDAT 00622 00623 00624 mov _SPDAT,#0xFF 00625 movx @dptr,a 00626 inc dptr 00627 // CHIP DESELECT 00628 setb _P2_3 00629 // CHIP SELECT 00630 clr _P2_3 00631 mov a,_SPDAT 00632 mov _SPDAT,#0x03 00633 movx @dptr,a 00634 mov _SPDAT,#0x08 00635 inc dptr 00636 mov a,_SPSTA 00637 mov _SPDAT,#0xFF 00638 nop 00639 nop 00640 nop 00641 mov a,_SPSTA 00642 mov a,_SPDAT 00643 00644 00645 mov _SPDAT,#0xFF 00646 movx @dptr,a 00647 inc dptr 00648 // CHIP DESELECT 00649 setb _P2_3 00650 // CHIP SELECT 00651 clr _P2_3 00652 mov a,_SPDAT 00653 mov _SPDAT,#0x03 00654 movx @dptr,a 00655 mov _SPDAT,#0x08 00656 inc dptr 00657 mov a,_SPSTA 00658 mov _SPDAT,#0xFF 00659 nop 00660 nop 00661 nop 00662 mov a,_SPSTA 00663 mov a,_SPDAT 00664 00665 00666 mov _SPDAT,#0xFF 00667 movx @dptr,a 00668 inc dptr 00669 // CHIP DESELECT 00670 setb _P2_3 00671 // CHIP SELECT 00672 clr _P2_3 00673 mov a,_SPDAT 00674 mov _SPDAT,#0x03 00675 movx @dptr,a 00676 mov _SPDAT,#0x08 00677 inc dptr 00678 mov a,_SPSTA 00679 mov _SPDAT,#0xFF 00680 nop 00681 nop 00682 nop 00683 mov a,_SPSTA 00684 mov a,_SPDAT 00685 00686 00687 mov _SPDAT,#0xFF 00688 movx @dptr,a 00689 inc dptr 00690 // CHIP DESELECT 00691 setb _P2_3 00692 // CHIP SELECT 00693 clr _P2_3 00694 mov a,_SPDAT 00695 mov _SPDAT,#0x03 00696 movx @dptr,a 00697 mov _SPDAT,#0x08 00698 inc dptr 00699 mov a,_SPSTA 00700 mov _SPDAT,#0xFF 00701 nop 00702 nop 00703 nop 00704 mov a,_SPSTA 00705 mov a,_SPDAT 00706 00707 00708 mov _SPDAT,#0xFF 00709 movx @dptr,a 00710 inc dptr 00711 mov a,_SPSTA 00712 mov a,_SPDAT 00713 movx @dptr,a 00714 inc dptr 00715 00716 // CHIP DESELECT 00717 setb _P2_3 00718 00719 mov _dataBufPtr, dpl 00720 mov (_dataBufPtr + 1), dph 00721 pop acc 00722 pop psw 00723 pop dph 00724 pop dpl 00725 00726 00727 _endasm; 00728 00729 00730 } 00731 //ConsolePutChar('w'); 00732 00733 EA=1; 00734 00735 00736 //while (MP3_DREQ){ 00737 00738 Mp3SelectData(); 00739 // BlockTransmit in C 00740 dataBufPtr = diskSect.raw.buf; 00741 // Use global pointer and unrolled loop for speed 00742 while (dataBufPtr < diskSect.raw.buf+256){ 00743 SPIPutCharWithoutWaiting(*dataBufPtr++); 00744 SPIPutCharWithoutWaiting(*dataBufPtr++); 00745 SPIPutCharWithoutWaiting(*dataBufPtr++); 00746 SPIPutCharWithoutWaiting(*dataBufPtr++); 00747 SPIPutCharWithoutWaiting(*dataBufPtr++); 00748 SPIPutCharWithoutWaiting(*dataBufPtr++); 00749 SPIPutCharWithoutWaiting(*dataBufPtr++); 00750 SPIPutCharWithoutWaiting(*dataBufPtr++); 00751 SPIPutCharWithoutWaiting(*dataBufPtr++); 00752 SPIPutCharWithoutWaiting(*dataBufPtr++); 00753 SPIPutCharWithoutWaiting(*dataBufPtr++); 00754 SPIPutCharWithoutWaiting(*dataBufPtr++); 00755 SPIPutCharWithoutWaiting(*dataBufPtr++); 00756 SPIPutCharWithoutWaiting(*dataBufPtr++); 00757 SPIPutCharWithoutWaiting(*dataBufPtr++); 00758 SPIPutCharWithoutWaiting(*dataBufPtr++); 00759 } 00760 Mp3DeselectData(); 00761 //} 00762 return 2; 00763 00764 } 00765 00766 00767 //_____________________________________________________ 00768 // MIDI playing --------------------------------------- 00769 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 00770 00771 00772 // MIDI IN stream is SCI stream in 00773 // Check whether SCI in stream has space for 1 disk sector 00774 if (midiSciActive && (Mp3ReadRegister(SCI_IN1) & 0xff) >= 0x20){ 00775 LED1 = LED_ON; 00776 00777 SelectDisk(midiDisk); 00778 TransferSectorSCI(midiCurrentSector); //Send MID to VS1103 00779 00780 // Find next sector or end of file 00781 midiCurrentSector++; 00782 if (midiSectorsLeftInFragment-- == 0){ 00783 midiCurrentFragment++; 00784 midiCurrentSector = midiFragment[midiCurrentFragment].start; 00785 midiSectorsLeftInFragment = midiFragment[midiCurrentFragment].length; 00786 if (midiSectorsLeftInFragment == 0) { 00787 midiSciActive = 0; 00788 } 00789 } 00790 00791 LED1=LED_OFF; 00792 return 3; 00793 } 00794 00795 return 0; //No transfer was pending. 00796 }
|
Here is the call graph for this function:
|
Definition at line 944 of file player.c. References DiskBlock::Raw::buf, BuildFragmentTable(), CancelMidi(), ConsolePutChar, ConsolePutHex8, currentFileName, diskSect, fragment, Address::l, fragmentEntry::length, lyrics, MessageBox(), midiChannelMask, midiCurrentSector, midiDisk, midiFragment, midiSciActive, midiSectorsLeftInFragment, OpenFile(), DiskBlock::raw, ReadDiskSector(), sectorAddress, SelectDisk(), SetDisplayText(), SetMidiFromFile(), fragmentEntry::start, UI_MIDIFILE, and Vs1103B_SetChannelMask(). Referenced by AvailableProcessorTime(). 00944 { 00945 00946 CancelMidi(); 00947 SetMidiFromFile(); 00948 if (fileNumber == 0) return 0; 00949 00950 //ConsoleWrite("\rLooking for MIDI file\r"); 00951 midiDisk = 0; 00952 if (fileNumber < 0) { 00953 midiDisk = 1; 00954 fileNumber = -fileNumber; 00955 } 00956 SelectDisk(midiDisk); 00957 00958 if (!OpenFile(fileNumber,'M','I','D')){ 00959 unsigned char i; 00960 SetDisplayText(UI_MIDIFILE,currentFileName); 00961 BuildFragmentTable(); 00962 for (i=0; i<MAX_NUMBER_FRAGMENTS; i++){ 00963 midiFragment[i].start = fragment[i].start; 00964 midiFragment[i].length = fragment[i].length; 00965 } 00966 midiCurrentSector = midiFragment[0].start; 00967 midiSectorsLeftInFragment = midiFragment[0].length; 00968 Vs1103B_SetChannelMask(midiChannelMask); 00969 midiSciActive = 1; 00970 if (midiSectorsLeftInFragment == 0) { 00971 midiSciActive = 0; 00972 } 00973 for (i=0; i<40; i++){ 00974 lyrics[i] = ' '; 00975 } 00976 lyrics[34] = 'T'; 00977 lyrics[35] = 'e'; 00978 lyrics[36] = 'x'; 00979 lyrics[37] = 't'; 00980 lyrics[38] = ':'; 00981 00982 sectorAddress.l = midiCurrentSector; 00983 ReadDiskSector(sectorAddress.l); 00984 if (diskSect.raw.buf[9] != 0){ 00985 MessageBox("Please convert file to MIDI format 0."); 00986 } 00987 00988 #if 0 00989 for (i=0; i<16; i++){ 00990 ConsolePutHex8(diskSect.raw.buf[i]); 00991 ConsolePutChar(' '); 00992 ConsolePutChar(diskSect.raw.buf[i]); 00993 ConsolePutChar(13); 00994 } 00995 #endif 00996 00997 00998 return 0; 00999 } else { 01000 SetDisplayText(UI_MIDIFILE," No file "); 01001 } 01002 return 1; 01003 }
|
Here is the call graph for this function:
|
Definition at line 1006 of file player.c. References DiskBlock::Raw::buf, BuildFragmentTable(), Temp::c, currentFileName, diskSect, echoActive, fragment, Temp::i, fragmentEntry::length, OpenFile(), DiskBlock::raw, recordActive, recordCurrentSector, recordDisk, recordSectorsLeftInFragment, RIFFHeader0, RIFFHeader504, SelectDisk(), SetDisplayText(), fragmentEntry::start, temp, UI_RECORDFILE, vs1103_record_mixer, vs1103_recording_active, Vs1103SetMode(), and WriteDiskSector(). Referenced by AvailableProcessorTime(). 01006 { 01007 01008 recordDisk = 0; 01009 if (fileNumber < 0) { 01010 recordDisk = 1; 01011 fileNumber = -fileNumber; 01012 } 01013 SelectDisk(recordDisk); 01014 01015 if (fileNumber == 0){ 01016 01017 recordActive=0; 01018 vs1103_recording_active = 0; 01019 Vs1103SetMode(); 01020 SetDisplayText(UI_RECORDFILE,"---- "); 01021 return 0; 01022 } 01023 01024 //ConsoleWrite("\rLooking for Wave file for recording\r"); 01025 while (!OpenFile(fileNumber++,'W','A','V')){ 01026 if (currentFileName[0]=='R'){ 01027 SetDisplayText(UI_RECORDFILE,currentFileName); 01028 01029 BuildFragmentTable(); 01030 recordCurrentSector = fragment[0].start; 01031 recordSectorsLeftInFragment = fragment[0].length-1; 01032 01033 for (temp.c=0; temp.c<56; temp.c++){ //temp is unsafe global temp variable. 01034 diskSect.raw.buf[temp.c] = RIFFHeader0[temp.c]; 01035 } 01036 for (temp.i=52; temp.i<504; temp.i++){ 01037 diskSect.raw.buf[temp.i] = 0; 01038 } 01039 for (temp.i=504; temp.i<512; temp.i++){ 01040 diskSect.raw.buf[temp.i] = RIFFHeader504[temp.i-504]; 01041 } 01042 WriteDiskSector(recordCurrentSector++); 01043 echoActive = 0; 01044 vs1103_record_mixer = 1; 01045 recordActive = 1; 01046 vs1103_recording_active = 1; 01047 Vs1103SetMode(); 01048 return 0; 01049 } 01050 } 01051 return 1; 01052 }
|
Here is the call graph for this function:
|
Definition at line 1055 of file player.c. References BuildFragmentTable(), CancelWave(), currentFileName, fragment, fragmentEntry::length, OpenFile(), recordActive, SelectDisk(), SetDisplayText(), fragmentEntry::start, UI_WAVEFILE, uiMode, UpdateDisplay(), Vs1103CancelWave(), waveCurrentSector, waveDisk, waveFragment, waveSdiActive, and waveSectorsLeftInFragment. Referenced by AvailableProcessorTime(). 01055 { 01056 unsigned char i; 01057 01058 waveDisk = 0; 01059 if (fileNumber < 0) { 01060 waveDisk = 1; 01061 fileNumber = -fileNumber; 01062 } 01063 SelectDisk(waveDisk); 01064 01065 CancelWave(); 01066 if (fileNumber == 0) return 0; 01067 01068 if (!OpenFile(fileNumber,'W','A','V')){ 01069 SetDisplayText(UI_WAVEFILE,currentFileName); 01070 if (waveSdiActive){ //End playback of previous file 01071 Vs1103CancelWave(); 01072 } 01073 01074 if (!recordActive && !midiSciActive){ 01075 UpdateDisplay(uiMode); 01076 } 01077 01078 BuildFragmentTable(); 01079 for (i=0; i<MAX_NUMBER_FRAGMENTS; i++){ 01080 waveFragment[i].start = fragment[i].start; 01081 waveFragment[i].length = fragment[i].length; 01082 } 01083 waveCurrentSector = fragment[0].start; 01084 waveSectorsLeftInFragment = fragment[0].length; 01085 waveSdiActive = 1; 01086 if (waveSectorsLeftInFragment == 0) { 01087 waveSdiActive = 0; 01088 } 01089 return 0; //OK 01090 } 01091 return 1; //ERROR 01092 }
|
Here is the call graph for this function:
|
Route MIDI from SCI in file play mode.
Definition at line 857 of file player.c. References CancelRecord(), CancelWave(), MessageBox(), SetDisplayText(), UI_MIDISOURCE, vs1103_real_time_midi, and Vs1103SetMode(). Referenced by AvailableProcessorTime(), and SelectMidiFile(). 00857 { 00858 if (vs1103_real_time_midi){ 00859 if (recordActive){ 00860 CancelRecord(); 00861 MessageBox("RTMIDI: Recording Cancelled (N1)."); 00862 } 00863 if (waveSdiActive){ 00864 MessageBox("RTMIDI: Wave Playing Cancelled (N1)."); 00865 CancelWave(); //UART/SCI transition forces reset 00866 } 00867 vs1103_real_time_midi = 0; 00868 Vs1103SetMode(); 00869 SetDisplayText(UI_MIDISOURCE,"File (Fmt 0)"); 00870 } 00871 }
|
Here is the call graph for this function:
|
Route MIDI from UART in realtime mode.
Definition at line 837 of file player.c. References CancelMidi(), CancelRecord(), CancelWave(), LoadPatch(), MessageBox(), SetDisplayText(), UI_MIDISOURCE, vs1103_real_time_midi, and Vs1103SetMode(). Referenced by AvailableProcessorTime(). 00837 { 00838 if (!vs1103_real_time_midi){ 00839 if (recordActive){ 00840 CancelRecord(); 00841 MessageBox("RTMIDI: Recording Cancelled (N1)."); 00842 } 00843 if (waveSdiActive){ 00844 MessageBox("RTMIDI: Wave Playing Cancelled (N1)."); 00845 CancelWave(); //UART/SCI transition forces reset 00846 } 00847 CancelMidi(); 00848 vs1103_real_time_midi = 1; 00849 LoadPatch(); 00850 Vs1103SetMode(); 00851 } 00852 SetDisplayText(UI_MIDISOURCE,"MIDI Input "); 00853 00854 }
|
Here is the call graph for this function:
|
Start patch code.
Definition at line 172 of file player.c. References ConsoleWrite, Mp3WriteRegister, and SCI_AIADDR. Referenced by Vs1103SetMode(). 00173 { 00174 ConsoleWrite("Start Patch.\r"); 00175 while (!MP3_DREQ) 00176 ; 00177 #if 1 00178 Mp3WriteRegister(SCI_AIADDR, 0x00, 0x30); 00179 while (!MP3_DREQ) 00180 ; 00181 #endif 00182 }
|
|
User Interface Timer interrupt. Does NOT do any screen/button handling, only updates screen scroll variable and the userInterfaceDelayElapsed flag. Definition at line 114 of file player.c. References displayTimeCount, SPMax, and userInterfaceDelayElapsed. 00114 { 00115 //LED4 = LED_ON; 00116 userInterfaceDelayElapsed = 1; 00117 displayTimeCount++; 00118 if (SP>SPMax) SPMax = SP; 00119 //LED4 = LED_OFF; 00120 }
|
|
Definition at line 124 of file player.c. References rotaryValue. 00124 { 00125 static bit ledi; 00126 P3_2 = 1; 00127 P3_4 = 1; 00128 P3_5 = 1; 00129 00130 if (P3_4) { 00131 rotaryValue++; 00132 }else{ 00133 rotaryValue--; 00134 } 00135 ledi = !ledi; 00136 //LED4 = ledi; 00137 TF1 = 0; 00138 }
|
|
Definition at line 73 of file player.c. Referenced by AvailableProcessorTime(), and main(). |
|
Definition at line 84 of file player.c. Referenced by AvailableProcessorTime(), and main(). |
|
Definition at line 83 of file player.c. Referenced by AvailableProcessorTime(), EchoEnable(), and main(). |
|
Definition at line 66 of file player.c. Referenced by AvailableProcessorTime(), and main(). |
|
Definition at line 82 of file player.c. Referenced by AvailableProcessorTime(), EchoEnable(), and main(). |
|
Definition at line 67 of file player.c. Referenced by AvailableProcessorTime(), and CancelRecord(). |
|
Definition at line 65 of file player.c. Referenced by AvailableProcessorTime(), and main(). |
|
Definition at line 81 of file player.c. Referenced by AvailableProcessorTime(), EchoEnable(), and main(). |
|
Definition at line 104 of file player.c. Referenced by CancelRecord(), EchoDisable(), EchoEnable(), main(), and SelectRecordFile(). |
|
Definition at line 68 of file player.c. Referenced by main(), SelectMidiFile(), and UpdateDisplay(). |
|
Definition at line 58 of file player.c. Referenced by AvailableProcessorTime(), and main(). |
|
Definition at line 79 of file player.c. Referenced by AvailableProcessorTime(), main(), and SelectMidiFile(). |
|
Definition at line 88 of file player.c. Referenced by PlayerTaskHandler(). |
|
Definition at line 89 of file player.c. Referenced by PlayerTaskHandler(), and SelectMidiFile(). |
|
Definition at line 87 of file player.c. Referenced by PlayerTaskHandler(), and SelectMidiFile(). |
|
Definition at line 86 of file player.c. Referenced by CancelMidi(), main(), PlayerTaskHandler(), and SelectMidiFile(). |
|
Definition at line 90 of file player.c. Referenced by PlayerTaskHandler(), and SelectMidiFile(). |
|
Playing State Global, 0=normal playing, 1=abort playing.
Definition at line 53 of file player.c. Referenced by PlayDiskSectors(). |
|
|
|
Definition at line 98 of file player.c. Referenced by CancelRecord(), main(), PlayerTaskHandler(), SelectRecordFile(), and SelectWaveFile(). |
|
Definition at line 101 of file player.c. Referenced by PlayerTaskHandler(), and SelectRecordFile(). |
|
Definition at line 99 of file player.c. Referenced by PlayerTaskHandler(), and SelectRecordFile(). |
|
Definition at line 102 of file player.c. Referenced by PlayerTaskHandler(), and SelectRecordFile(). |
|
Definition at line 122 of file player.c. Referenced by AvailableProcessorTime(), and timer1_interrupt(). |
|
Definition at line 63 of file player.c. Referenced by timer0_interrupt(). |
|
Definition at line 78 of file player.c. Referenced by AvailableProcessorTime(), main(), and Vs1103B_SetMidiTranspose(). |
|
Definition at line 75 of file player.c. Referenced by AvailableProcessorTime(), and main(). |
|
Current User Interface mode (Title, Volume, ...).
Definition at line 62 of file player.c. Referenced by AvailableProcessorTime(), main(), and SelectWaveFile(). |
|
Interrupt-driven flag to reduce unnecessary UI updates. This is set to 1 by timer interrupt every n milliseconds. Definition at line 57 of file player.c. Referenced by AvailableProcessorTime(), and timer0_interrupt(). |
|
Definition at line 71 of file player.c. Referenced by AvailableProcessorTime(), main(), and Mp3Reset(). |
|
Definition at line 94 of file player.c. Referenced by PlayerTaskHandler(). |
|
Definition at line 95 of file player.c. Referenced by PlayerTaskHandler(), and SelectWaveFile(). |
|
Definition at line 93 of file player.c. Referenced by PlayerTaskHandler(), and SelectWaveFile(). |
|
Definition at line 92 of file player.c. Referenced by CancelWave(), main(), PlayerTaskHandler(), and SelectWaveFile(). |
|
Definition at line 96 of file player.c. Referenced by PlayerTaskHandler(), and SelectWaveFile(). |