void graph_wait_hsync(void) { // Initiate hsync interrupt _sd(_ld(GS_REG_CSR & 4), GS_REG_CSR); // Wait for hsync interrupt to be generated. while (!(_ld(GS_REG_CSR) & 4)); }
void graph_wait_vsync(void) { // Initiate vsync interrupt. _sd((_ld(GS_REG_CSR) & 8), GS_REG_CSR); // Wait for vsync interrupt to be generated. while (!(_ld(GS_REG_CSR) & 8)); }
void wait_vsync() { // Enable the vsync interrupt. _sd(_ld(GS_REG_CSR) | GS_SET_CSR(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0), GS_REG_CSR); // Wait for the vsync interrupt. while (!(_ld(GS_REG_CSR) & (GS_SET_CSR(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0)))) { } // Disable the vsync interrupt. _sd(_ld(GS_REG_CSR) & ~GS_SET_CSR(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0), GS_REG_CSR); }
Button* Button::CreateHelp(Model::Action* action, bool horizontalFlex, bool verticalFlex) { return Create(_ld(dlgButtonHelp), OS::Theme::imageHelp, action, Button::typeNormal, horizontalFlex,verticalFlex); }
Button* Button::CreateQuit(Model::Action* action, bool horizontalFlex, bool verticalFlex) { return Create(_ld(dlgButtonQuit), OS::Theme::imageDefault, action, Button::typeDefault, horizontalFlex,verticalFlex); }
Button* Button::CreateCancel(Model::Action* action, bool horizontalFlex, bool verticalFlex) { return Create(_ld(dlgButtonCancel), OS::Theme::imageNegative, action, Button::typeCancel, horizontalFlex,verticalFlex); }
Button* Button::CreateOk(Model::Action* action, bool horizontalFlex, bool verticalFlex) { return Create(_ld(dlgButtonOk), OS::Theme::imagePositive, action, Button::typeCommit, horizontalFlex,verticalFlex); }
/* * Executes a given instruction, or errors out * ins - instruction to run */ void execute (unsigned short int ins) { /* seperate instruction into parts */ short int a0 = (ins >> 12) % 16; short int a1 = (ins >> 8) % 16; short int a2 = (ins >> 4) % 16; short int a3 = (ins >> 0) % 16; /* Run associated instruction */ switch(a0) { case 0x0: _add (a1, a2, a3); break; case 0x1: _sub (a1, a2, a3); break; case 0x2: _mul (a1, a2, a3); break; case 0x3: _div (a1, a2, a3); break; case 0x6: _beq (a1, a2, a3); break; case 0x7: _bgt (a1, a2, a3); break; case 0x8: _ld (a1, a2, a3); break; case 0x9: _st (a1, a2, a3); break; case 0xa: _lc (a1, a3); break; case 0xb: _jmp (a1, a3); break; case 0xc: _inc (a1, a3); break; case 0xf: _sys (a1, a3); break; default: printf ("Error: invalid opcode %#x.\n", a0); sys_dump (0x0); sys_halt (0x0); } }
int graph_get_field(void) { // Return the currently displayed field. if (_ld(GS_REG_CSR) & (1 << 13)) { return GRAPH_FIELD_ODD; } return GRAPH_FIELD_EVEN; }
void graph_start_vsync(void) { _sd(_ld(GS_REG_CSR) & 8, GS_REG_CSR); }
int graph_check_vsync(void) { return (_ld(GS_REG_CSR) & 8); }
void VMDriver::execute(){ if( this->m_state == STATE_IDLE ){ printf( "Error: state is idle. \n"); return; } assert( this->currentAssembly() ); while( this->isActive() ){ if( this->isBreak() ){ break; } unsigned char content = this->getByte( m_funcAddr , m_pc ); m_pc++; switch( content ){ case EMnemonic::MovPtr : _mov_ptr(); break; case EMnemonic::Mov : _mov(); break; case EMnemonic::Add : _add(); break; case EMnemonic::Sub : _sub(); break; case EMnemonic::Mul : _mul(); break; case EMnemonic::Div : _div(); break; case EMnemonic::Rem : _rem(); break; case EMnemonic::Inc : _inc(); break; case EMnemonic::Dec : _dec(); break; case EMnemonic::Push : _push(); break; case EMnemonic::PushPtr : _push_ptr(); break; case EMnemonic::Pop : _pop(); break; case EMnemonic::Call : _call(); break; case EMnemonic::ST : _st(); break; case EMnemonic::LD : _ld(); break; case EMnemonic::EndFunc : _endFunc(); break; case EMnemonic::CmpGeq : case EMnemonic::CmpG : case EMnemonic::CmpLeq : case EMnemonic::CmpL : case EMnemonic::CmpEq : case EMnemonic::CmpNEq : _cmp( content ); break; case EMnemonic::Not : _not(); break; case EMnemonic::Minus : _minus(); break; case EMnemonic::LogOr : case EMnemonic::LogAnd : _log( content ); break; case EMnemonic::Jmp : _jmp(); break; case EMnemonic::JumpZero : _jumpzero(); break; case EMnemonic::JumpNotZero : _jumpnotzero(); break; case EMnemonic::RET : _ret(); break; } } }