unsigned char SetSndOutMode(unsigned char Mode) //0 = Speaker 1= Cassette Out 2=Cassette In { static unsigned char LastMode=0; static unsigned short PrimarySoundRate=SoundRate; switch (Mode) { case 0: if (LastMode==1) //Send the last bits to be encoded FlushCassetteBuffer(CassBuffer,AudioIndex); AudioEvent=AudioOut; SetAudioRate (PrimarySoundRate); // SetAudioRate(44100); break; case 1: AudioEvent=CassOut; PrimarySoundRate=SoundRate; SetAudioRate (TAPEAUDIORATE); break; case 2: AudioEvent=CassIn; PrimarySoundRate=SoundRate;; SetAudioRate (TAPEAUDIORATE); break; default: //QUERY return(SoundOutputMode); break; } if (Mode != LastMode) { // if (LastMode==1) // FlushCassetteBuffer(CassBuffer,AudioIndex); //get the last few bytes AudioIndex=0; //Reset Buffer on true mode switch LastMode=Mode; } SoundOutputMode=Mode; return(SoundOutputMode); }
float RenderFrame (SystemState *RFState) { static unsigned short FrameCounter=0; //********************************Start of frame Render***************************************************** SetBlinkState(BlinkPhase); irq_fs(0); //FS low to High transition start of display Boink needs this for (RFState->LineCounter=0;RFState->LineCounter<13;RFState->LineCounter++) //Vertical Blanking 13 H lines CPUCycle(); for (RFState->LineCounter=0;RFState->LineCounter<4;RFState->LineCounter++) //4 non-Rendered top Boarder lines CPUCycle(); if (!(FrameCounter % RFState->FrameSkip)) if (LockScreen(RFState)) return(0); for (RFState->LineCounter=0;RFState->LineCounter<(TopBoarder-4);RFState->LineCounter++) { if (!(FrameCounter % RFState->FrameSkip)) DrawTopBoarder[RFState->BitDepth](RFState); CPUCycle(); } for (RFState->LineCounter=0;RFState->LineCounter<LinesperScreen;RFState->LineCounter++) //Active Display area { CPUCycle(); if (!(FrameCounter % RFState->FrameSkip)) UpdateScreen[RFState->BitDepth] (RFState); } irq_fs(1); //End of active display FS goes High to Low if (VertInteruptEnabled) GimeAssertVertInterupt(); for (RFState->LineCounter=0;RFState->LineCounter < (BottomBoarder) ;RFState->LineCounter++) // Bottom boarder { // if ( (RFState->LineCounter==1) & (VertInteruptEnabled) ) //Vert Interupt occurs 1 line into // GimeAssertVertInterupt(); // Bottom Boarder MPATDEMO CPUCycle(); if (!(FrameCounter % RFState->FrameSkip)) DrawBottomBoarder[RFState->BitDepth](RFState); } if (!(FrameCounter % RFState->FrameSkip)) { UnlockScreen(RFState); SetBoarderChange(0); } for (RFState->LineCounter=0;RFState->LineCounter<6;RFState->LineCounter++) //Vertical Retrace 6 H lines CPUCycle(); switch (SoundOutputMode) { case 0: FlushAudioBuffer(AudioBuffer,AudioIndex<<2); break; case 1: FlushCassetteBuffer(CassBuffer,AudioIndex); break; case 2: LoadCassetteBuffer(CassBuffer); break; } AudioIndex=0; /* //Debug Code Frames++; if (Frames==60) { Frames=0; sprintf(Msga,"Total Cycles = %i Scan lines = %i LPS= %i\n",TotalCycles,Scans,LinesperScreen+TopBoarder+BottomBoarder+19); WriteLog(Msga,0); TotalCycles=0; Scans=0; } */ return(CalculateFPS()); }