void ExecuteInterpreterOpCode (usf_state_t * state) { if (*state->WaitMode) state->Timers->Timer = -1; if (!r4300i_LW_VAddr(state, state->PROGRAM_COUNTER, &state->Opcode.u.Hex)) { DoTLBMiss(state, state->NextInstruction == JUMP,state->PROGRAM_COUNTER); state->NextInstruction = NORMAL; return; } #ifdef DEBUG_INFO { char opcode[256]; char arguments[256]; r4300_decode_op(state->Opcode.u.Hex, opcode, arguments, state->PROGRAM_COUNTER); fprintf(state->debug_log, "%08x: %-16s %s\n", state->PROGRAM_COUNTER, opcode, arguments); } #endif COUNT_REGISTER += 2; state->Timers->Timer -= 2; RANDOM_REGISTER -= 1; if ((int32_t)RANDOM_REGISTER < (int32_t)WIRED_REGISTER) { RANDOM_REGISTER = 31; } R4300i_Opcode[ state->Opcode.u.b.op ](state); if (state->GPR[0].DW != 0) { state->GPR[0].DW = 0; } switch (state->NextInstruction) { case NORMAL: state->PROGRAM_COUNTER += 4; break; case DELAY_SLOT: state->NextInstruction = JUMP; state->PROGRAM_COUNTER += 4; break; case JUMP: if ( #ifdef DEBUG_INFO 0 && #endif state->cpu_hle_entry_count && DoCPUHLE(state, state->JumpToLocation)) { state->PROGRAM_COUNTER = state->GPR[31].UW[0]; state->NextInstruction = NORMAL; } else { state->PROGRAM_COUNTER = state->JumpToLocation; state->NextInstruction = NORMAL; } if ((int32_t)state->Timers->Timer < 0) { TimerDone(state); } if (state->CPU_Action->DoSomething) { DoSomething(state); } } }
/* ** Beeper() * * FILENAME: beep.c * * PARAMETERS: BeepMsg. Holds length of beep, [4:0] and number of * beeps, [7:5] * * DESCRIPTION: When BeepMsg != 0 then it splits the uint8 into the two * parameters needed and starts the beep sequence. * * RETURNS: Nothing. * */ void BeeperDevice() { switch (BeepState) { case BEEP_START : if (BeepMsg != 0) { // Set how long beeper is on and off. BeepTime = (BeepMsg & 0x1F) << 2; // times 4 for 40ms to 1.24 sec. // Set how many times we beep BeepRep = (BeepMsg & 0xE0) >> 5; StartBeep(); StartTimer( BEEP_TIMER, BeepTime ); BeepMsg = 0; BeepState = BEEP_OFF; } break; case BEEP_OFF : if (TimerDone( BEEP_TIMER ) ) { StopBeep(); BeepRep--; StartTimer( BEEP_TIMER, BeepTime ); BeepState = BEEP_ON; }; break; case BEEP_ON: if (TimerDone( BEEP_TIMER ) ) { if ( BeepRep != 0 ) { StartBeep(); StartTimer( BEEP_TIMER, BeepTime ); BeepState = BEEP_OFF; } else { BeepState = BEEP_START; // Beeping is done. } } break; default: BeepState = BEEP_START; break; }
void LED_Tasks() { switch(lightShow) { case LED_IDLE: LED1 = 0; LED2 = 0; LED3 = 0; LED4 = 0; LED5 = 1; LED6 = 0; break; case LED_BTLE_ADVERTISING: LED1 = 0; LED2 = 0; LED3 = 0; LED4 = 0; LED6 = 0; if(TimerDone(TMR_LEDS)) { LED5 ^= 1; StartTimer(TMR_LEDS, LED_BLINK_MS); } break; case LED_BTLE_PAIRED: LED1 = appData.led1; LED2 = appData.led2; LED3 = appData.led3; LED4 = appData.led4; LED5 = 1; LED6 = 0; break; case LED_ERROR: switch(appData.error_code) { case ERROR_INITIALIZATION: LED1 = 1; LED2 = 0; LED3 = 0; LED4 = 0; LED5 = 1; LED6 = 1; break; case ERROR_RN_FW: LED1 = 1; LED2 = 1; LED3 = 0; LED4 = 0; LED5 = 1; LED6 = 1; break; default: LED1 = 1; LED2 = 1; LED3 = 1; LED4 = 1; LED5 = 1; LED6 = 1; break; } break; case LED_SLEEP: LED1 = 0; LED2 = 0; LED3 = 0; LED4 = 0; LED5 = 0; LED6 = 1; break; default: break; } }
void ExecuteInterpreterOpCode (usf_state_t * state) { if (*state->WaitMode) state->Timers->Timer = -1; if (!r4300i_LW_VAddr(state, state->PROGRAM_COUNTER, &state->Opcode.u.Hex)) { DoTLBMiss(state, state->NextInstruction == JUMP,state->PROGRAM_COUNTER); state->NextInstruction = NORMAL; return; } COUNT_REGISTER += 2; state->Timers->Timer -= 2; RANDOM_REGISTER -= 1; if ((int32_t)RANDOM_REGISTER < (int32_t)WIRED_REGISTER) { RANDOM_REGISTER = 31; } R4300i_Opcode[ state->Opcode.u.b.op ](state); if (state->GPR[0].DW != 0) { state->GPR[0].DW = 0; } switch (state->NextInstruction) { case NORMAL: state->PROGRAM_COUNTER += 4; break; case DELAY_SLOT: state->NextInstruction = JUMP; state->PROGRAM_COUNTER += 4; break; case JUMP: state->PROGRAM_COUNTER = state->JumpToLocation; state->NextInstruction = NORMAL; if ((int32_t)state->Timers->Timer < 0) { TimerDone(state); } if (state->CPU_Action->DoSomething) { DoSomething(state); } } }