void MD5::Final(u8* digest) { // Compute the message length in bits (before padding) u64 len = m_InputLen * 8; // Pad with 1-bit const u8 pad = 0x80; Update(&pad, 1); // Fill with zeros until length % 64 = 56 (bytes) while (m_BufLen % 64 != 56) { const u8 zero = 0; Update(&zero, 1); } // Append the length (assumes little-endian) Update((const u8*)&len, 8); // Return the digest (assumes little-endian) memcpy(digest, m_Digest, DIGESTSIZE); // Reset InitState();
bool COGLGraphicsContext::Initialize(uint32_t dwWidth, uint32_t dwHeight) { DebugMessage(M64MSG_INFO, "Initializing OpenGL Device Context."); CGraphicsContext::Initialize(dwWidth, dwHeight); int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; int bVerticalSync = windowSetting.bVerticalSync; if (options.colorQuality == TEXTURE_FMT_A4R4G4B4) colorBufferDepth = 16; InitState(); InitOGLExtension(); sprintf(m_strDeviceStats, "%.60s - %.128s : %.60s", m_pVendorStr, m_pRenderStr, m_pVersionStr); TRACE0(m_strDeviceStats); DebugMessage(M64MSG_INFO, "Using OpenGL: %s", m_strDeviceStats); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER, 0xFF000000, 1.0f); // Clear buffers UpdateFrame(false); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER, 0xFF000000, 1.0f); UpdateFrame(false); return true; }
// The demangler entry point. bool Demangle(const char *mangled, char *out, int out_size) { State state; InitState(&state, mangled, out, out_size); return (ParseMangledName(&state) && state.overflowed == false && RemainingLength(&state) == 0); }
/*---------------------------------------------------------------------*/ BOOL ReadState(H_ARCHIVE harchive) { UINT32 i; STREAM stream; NODE *node; if (!ValidateHandle(harchive)) { ArchiveLog(ARC_LOG_ERRORS, "ReadState: Invalid archive handle"); return (FALSE); } _archive[harchive].last_error = ARC_NO_ERROR; _archive_error = ARC_NO_ERROR; /* Go to top of file */ if (!FileRewind(_archive[harchive].file)) { _archive[harchive].last_error = ARC_FILE_IO_ERROR; ArchiveLog(ARC_LOG_ERRORS, "ReadState: Error rewinding state file (state): %s", _archive[harchive].filespec); return (FALSE); } /* Read state structure */ InitState(&_archive[harchive].state); if (SerializedRead(&_archive[harchive].state, _state_template, _archive[harchive].file) == VOID_UINT32) { ArchiveLog(ARC_LOG_ERRORS, "ReadState: Error reading state file (state): %s", _archive[harchive].filespec); return (FALSE); } /* If we don't have streams... */ if (_archive[harchive].state.n_streams == 0) return (TRUE); /* Read stream structures into stream list */ /* Destroy any existing list */ DestroyList(&_archive[harchive].streams); /* Set node to head */ node = &_archive[harchive].streams.head; for (i = 0; i < _archive[harchive].state.n_streams; i++) { /* Clean stream record */ InitStream(&stream); if (SerializedRead(&stream, _stream_template, _archive[harchive].file) == VOID_UINT32) { ArchiveLog(ARC_LOG_ERRORS, "ReadState: Error reading state file (stream): %s", _archive[harchive].filespec); return (FALSE); } /* Insert new node after the current one */ if ((node = InsertNodeAfter(node, &stream, sizeof(STREAM))) == NULL) { _archive_error = ARC_NO_MEMORY; ArchiveLog(ARC_LOG_ERRORS, "ReadState: Error allocating stream node (stream): %s", _archive[harchive].filespec); return (FALSE); } } return (TRUE); }
void CPicDLg::Piao( ) { MoveWindow( posX+speedX ,posY+speedY , sizeX,sizeY ); if ( posX < -sizeX || posX >theApp.cxScreen || posY> theApp.cyScreen ) { InitState(); } }
lua_State * CInitLua::GetLua_State() { if (L == NULL) { InitState(); } return L; }
void CUITrackBar::InitTrackBar(Fvector2 pos, Fvector2 size) { float item_height; float item_width; InitIB (pos, size); InitState (S_Enabled, "ui_inGame2_opt_slider_bar"); InitState (S_Disabled, "ui_inGame2_opt_slider_bar"); item_width = CUITextureMaster::GetTextureWidth("ui_inGame2_opt_slider_box_e"); item_height = CUITextureMaster::GetTextureHeight("ui_inGame2_opt_slider_box_e"); item_width *= UI().get_current_kx(); m_pSlider->InitButton( Fvector2().set(0.0f, 0.0f) /*(size.y - item_height)/2.0f)*/, Fvector2().set(item_width, item_height) ); //size m_pSlider->InitTexture("ui_inGame2_opt_slider_box"); SetCurrentState(S_Enabled); }
BOOL CPicDLg::OnInitDialog() { CDialog::OnInitDialog(); UpdateDisplay( 100 ); InitState( true ); ::SetWindowPos( m_hWnd, HWND_TOPMOST,posX , posY ,m_BakWidth,m_BakHeight,SWP_NOSIZE); //雪花下落定时器 timer =SetTimer(ID_TIMER_BIG_SNOW_FALL,40,NULL); //雪花开始变化定时器 timer_change = SetTimer( ID_TIMER_SNOW_CHANGE, (unsigned)rand()%3000 ,NULL); return TRUE; }
bool COGLGraphicsContext::ResizeInitialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed ) { Lock(); CGraphicsContext::Initialize(dwWidth, dwHeight, bWindowed ); int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; int bVerticalSync = windowSetting.bVerticalSync; if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) colorBufferDepth = 16; /* hard-coded attribute values */ const int iDOUBLEBUFFER = 1; /* set opengl attributes */ CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, iDOUBLEBUFFER); CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, bVerticalSync); CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, colorBufferDepth); CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, depthBufferDepth); /* set multisampling */ if (options.multiSampling > 0) { CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLEBUFFERS, 1); if (options.multiSampling <= 2) CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 2); else if (options.multiSampling <= 4) CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 4); else if (options.multiSampling <= 8) CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 8); else CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16); } /* Call Mupen64plus core Video Extension to resize the window, which will create a new OpenGL Context under SDL */ if (CoreVideo_ResizeWindow(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight) != M64ERR_SUCCESS) { DebugMessage(M64MSG_ERROR, "Failed to set %i-bit video mode: %ix%i", colorBufferDepth, (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight); CoreVideo_Quit(); return false; } InitState(); Unlock(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); // Clear buffers UpdateFrame(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); UpdateFrame(); return true; }
// The demangler entry point. int gimli_demangle(const char *mangled, char *out, int out_size) { State state; #ifdef __MACH__ /* skip leading '_' that is present on this platform */ mangled++; #endif InitState(&state, mangled, out, out_size); return (ParseMangledName(&state) && state.overflowed == false && RemainingLength(&state) == 0); }
//移进-规约搜索 void CDecoder::Search(string &result, float &maxscore) { m_vState.clear(); //初始化状态栈 CState ini; InitState(ini); m_vState.push_back(ini); //移进规约2N-1步 int steps = 2 * int(m_vToken.size()) - 1; for (int i = 0; i < steps; ++i) { vector<CState> buf; for (size_t j = 0; j < m_vState.size(); ++j) { map<string, double> scores; GetScores(m_vState[j], scores); vector<string> ops; GetOps(m_vState[j], ops); for (size_t k = 0; k < ops.size(); ++k) { CState next; Transition(m_vState[j], scores, ops[k], next); buf.push_back(next); } } sort(buf.begin(), buf.end()); //选出最好的N个状态 m_vState.clear(); int p = int(buf.size()) - 1; int cnt = 0; while (p >= 0 && cnt < m_nBeam) { m_vState.push_back(buf[p]); --p; ++cnt; } } maxscore = m_vState[0].score; GetResult(m_vState[0], result); }
void WdeEnablePasteItem( HMENU menu ) { UINT cmd; WdeResInfo *rinfo; cmd = MF_GRAYED; rinfo = WdeGetCurrentRes(); if( rinfo != NULL && rinfo->editting ) { InitState( rinfo->forms_win ); if( FMPasteValid() ) { cmd = MF_ENABLED; } } EnableMenuItem( menu, IDM_PASTEOBJECT, cmd | MF_BYCOMMAND ); }
int Activate(InitInfo *initInfo) { // Redundant. Should match the next line. // Deactivate(); if (wmk) wmk->Deactivate(); hWndProc = initInfo->hWndProc; if (!wmm) hWndProc->Eat(WindowsMessagingWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES); wmk = this; InitState(); active = 1; return 1; }
void IntegratingVelocityTrackerStrategy::AddMovement( const TimeTicks& event_time, BitSet32 id_bits, const PointerXY* positions) { uint32_t index = 0; for (BitSet32 iter_id_bits(id_bits); !iter_id_bits.is_empty();) { uint32_t id = iter_id_bits.clear_first_marked_bit(); State& state = mPointerState[id]; const PointerXY& position = positions[index++]; if (pointer_id_bits_.has_bit(id)) UpdateState(state, event_time, position.x, position.y); else InitState(state, event_time, position.x, position.y); } pointer_id_bits_ = id_bits; }
int FMEDITAPI FMTranslateAccelerator( HWND wnd, LPMSG message ) { bool ret; int i; if( !InitState( wnd ) ) { return( false ); } if( State->currstate == EDITING ) { return( false ); } ret = false; for( i = 0; i < ACCELS && !ret; i++ ) { if( State->hAccel[i] != NULL ) { ret |= ( TranslateAccelerator( wnd, State->hAccel[i], message ) != 0 ); } } return( ret ); }
OBJPTR WdeGetCurrentDialog( void ) { WdeResInfo *info; OBJPTR curr_obj; OBJPTR ancestor; OBJ_ID id; info = WdeGetCurrentRes(); if( info == NULL ) { return( NULL ); } InitState( info->forms_win ); curr_obj = GetCurrObject(); if( curr_obj == NULL ) { return( NULL ); } if( !Forward( curr_obj, IDENTIFY, &id, NULL ) ) { WdeWriteTrail( "WdeGetCurrentDialog: IDENTIFY failed!" ); return( NULL ); } while( id != DIALOG_OBJ && id != BASE_OBJ ) { GetObjectParent( curr_obj, &ancestor ); if( ancestor == NULL ) { WdeWriteTrail( "WdeGetCurrentDialog: IDENTIFY failed!" ); return( NULL ); } curr_obj = ancestor; if( !Forward( curr_obj, IDENTIFY, &id, NULL ) ) { WdeWriteTrail( "WdeGetCurrentDialog: IDENTIFY failed!" ); return( NULL ); } } if( id != DIALOG_OBJ ) { return( NULL ); } return( curr_obj ); }
int Activate(void *d) { InitInfo *info = (InitInfo*)d; // Redundant. Should match the next line. // Deactivate(); if (wmk) wmk->Deactivate(); HWND hWnd = info->hWnd; if (info->hWndButton) { hWnd = info->hWndButton; // hWndDlg = info->hWnd; } if (!wmm && !EatWndProc(hWnd, WindowsMessagingWndProc)) { Deactivate(); return 0; } wmk = this; InitState(); active = 1; return 1; }
int FMEDITAPI FMTranslateAccelerator( HWND wnd, LPMSG message ) { int ret; int i; if( !InitState( wnd ) ) { return( FALSE ); } ret = FALSE; if( State->currstate == EDITING ) { return( ret ); } for( i = 0; i < ACCELS && ret == FALSE; i++ ) { if( State->hAccel[i] != NULL ) { ret |= TranslateAccelerator( wnd, State->hAccel[i], message ); } } return( ret ); }
static void WdeActivateResourceWindow( WdeResInfo *res_info, WPARAM wParam, LPARAM lParam ) { WdeResInfo *info; OBJPTR current_obj; bool fActivate; HWND hwndDeact; int id; _wde_touch( wParam ); if( res_info == NULL ) { return; } fActivate = GET_WM_MDIACTIVATE_FACTIVATE( res_info->res_win, wParam, lParam ); hwndDeact = GET_WM_MDIACTIVATE_HWNDDEACTIVATE( wParam, lParam ); res_info->active = fActivate; if( fActivate ) { WdeSetCurrentRes( res_info ); info = WdeResInfoFromWin( hwndDeact ); if( info != NULL ) { info->active = FALSE; } } if( res_info->editting ) { InitState( res_info->forms_win ); id = WdeGetCToolID(); WdeSetBaseObject( id ); if( fActivate ) { current_obj = GetCurrObject(); if( current_obj != NULL ) { Notify( current_obj, PRIMARY_OBJECT, NULL ); } } } }
bool COGLGraphicsContext::Initialize(uint32 dwWidth, uint32 dwHeight, bool bWindowed) { DebugMessage(M64MSG_INFO, "Initializing OpenGL Device Context."); CGraphicsContext::Get()->m_supportTextureMirror = false; CGraphicsContext::Initialize(dwWidth, dwHeight, bWindowed); if (bWindowed) { windowSetting.statusBarHeightToUse = windowSetting.statusBarHeight; windowSetting.toolbarHeightToUse = windowSetting.toolbarHeight; } else { windowSetting.statusBarHeightToUse = 0; windowSetting.toolbarHeightToUse = 0; } int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; int bVerticalSync = windowSetting.bVerticalSync; if (options.colorQuality == TEXTURE_FMT_A4R4G4B4) colorBufferDepth = 16; InitState(); InitOGLExtension(); sprintf(m_strDeviceStats, "%.60s - %.128s : %.60s", m_pVendorStr, m_pRenderStr, m_pVersionStr); TRACE0(m_strDeviceStats); DebugMessage(M64MSG_INFO, "Using OpenGL: %s", m_strDeviceStats); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER, 0xFF000000, 1.0f); // Clear buffers UpdateFrame(false); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER, 0xFF000000, 1.0f); UpdateFrame(false); m_bReady = true; status.isVertexShaderEnabled = false; return true; }
bool COGLGraphicsContext::ResizeInitialize(uint32_t dwWidth, uint32_t dwHeight) { CGraphicsContext::Initialize(dwWidth, dwHeight); int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; int bVerticalSync = windowSetting.bVerticalSync; if (options.colorQuality == TEXTURE_FMT_A4R4G4B4) colorBufferDepth = 16; /* Hard-coded attribute values */ const int iDOUBLEBUFFER = 1; InitState(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER, 0xFF000000, 1.0f); // Clear buffers UpdateFrame(false); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER, 0xFF000000, 1.0f); UpdateFrame(false); return true; }
LRESULT WINEXPORT WdeFormsWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { WdeResInfo *info; LRESULT result; info = (WdeResInfo *)GetWindowLong( hWnd, 0 ); result = FALSE; if( info != NULL && info->editting && info->forms_win != (HWND)NULL ) { InitState( info->forms_win ); result = FMEditWndProc( hWnd, message, wParam, lParam ); if( message == WM_ERASEBKGND ) { SendMessage( info->edit_win, message, wParam, lParam ); result = TRUE; } } if( !result ) { result = DefWindowProc( hWnd, message, wParam, lParam ); } return( result ); }
IDCOffer_clp Binder_MuxedOffer(DomainMgr_st *dm_st, dcb_ro_t *rop, dcb_rw_t *rwp , Type_Any *server) { PerDomain_st *bst = ROP_TO_PDS(rop); Client_t *bcl = (Client_t *)&(rwp->binder_rw); _generic_cl *client_ops; Server_t *new_server; Client_t *new_client; IDCOffer_cl *offer; IDCStubs_Info NOCLOBBER stubinfo; #define TC_STRING_LEN (2*sizeof(Type_Code)) char tname[TC_STRING_LEN+1]; TRY { Context_clp stub_ctxt = NAME_FIND (IDC_CONTEXT, Context_clp); TRC(eprintf ("Binder_MuxedOffer: got stub context.\n")); sprintf(tname, "%Q", server->type); TRC(eprintf ("Binder_MuxedOffer: looking for '%s'.\n", tname)); stubinfo = NAME_LOOKUP (tname, stub_ctxt, IDCStubs_Info); } CATCH_ALL { eprintf("Binder_MuxedOffer: failed to find stub info!\n"); RERAISE; } ENDTRY; /* Sort out the client side first */ new_client = Heap$Calloc(Pvs(heap), 1, sizeof(Client_t)); offer = Heap$Calloc(Pvs(heap), 1, sizeof(IDCOffer_cl)); client_ops = ((_generic_cl *)(stubinfo->surr.val))->op; CL_INIT(new_client->client_cl, client_ops, new_client); CL_INIT(new_client->binding_cl, &BinderClientBinding_op, new_client); ANY_INITC(&new_client->cs.srgt, server->type, (pointerval_t)&new_client->client_cl); new_client->cs.binding = &new_client->binding_cl; new_client->cs.marshal = dm_st->shmidc; new_client->conn = bcl->conn; if(stubinfo->clnt) { /* Let the stubs set up any required run-time state */ IDCClientStubs$InitState(stubinfo->clnt, &new_client->cs); } /* Now sort out the server side */ new_server = Heap$Calloc(Pvs(heap), 1, sizeof(Server_t)); new_server->ss.service = (addr_t)(pointerval_t)server->val; new_server->ss.binding = &new_server->binding_cl; new_server->ss.marshal = dm_st->shmidc; CL_INIT(new_server->cntrl_cl, stubinfo->stub->op, new_server); CL_INIT(new_server->binding_cl, &ShmServerBinding_op, new_server); new_server->conn = &bst->sconn; /* Hijack offer field for PerDomain_st */ new_server->offer = (Offer_t *)bst; new_client->offer = (Offer_t *)RegisterServer(&bst->mux, &new_server->cntrl_cl); if(new_client->offer == (Offer_t *)-1) { eprintf("Binder_MuxedOffer: adding new server to mux svr failed!\n"); ntsc_halt(); } /* We use our special binder offer ops, as for the binder binding. Note that this means we cannot use ObjectTbl$Import() to deal with this offer - we must call IDCOffer$Bind ourselves. */ CLP_INIT(offer, &offer_ops, new_client); return offer; }
PerDomain_st *Binder_InitDomain(DomainMgr_st *dm_st, dcb_ro_t *rop, dcb_rw_t *rwp, StretchAllocator_clp salloc) { Client_t *bcl; Server_t *bsv; PerDomain_st *bst; IDCStubs_Info stubinfo; /* Allocate bsv, bcl and bst */ bst = ROP_TO_PDS(rop); memset(bst, 0, sizeof(*bst)); bsv = &bst->s; bcl = (Client_t *)&(rwp->binder_rw); TRC (eprintf("Binder_NewDomain: state at %x\n", bst)); #if 0 /* Block until the boot domains are ready */ /* XXX XXX see comment in DomainMgr.c about Intel and ARM */ TRC(eprintf("Dom ID = %qx, boot_regs = %qx\n", rop->id, EC_READ(dm_st->boot_regs))); #ifdef SRCIT #undef DOM_USER #define DOM_USER DOM_SERIAL #endif #ifndef __ALPHA__ EC_AWAIT (dm_st->boot_regs, ((rop->id < DOM_USER) ? rop->id : DOM_USER)&0xffffffff); #else EC_AWAIT (dm_st->boot_regs, (rop->id < DOM_USER) ? rop->id : DOM_USER); #endif #endif /* 0 */ /* Create IDC buffers for the new domain's channel to the binder */ bst->args = STR_NEW_SALLOC(dm_st->sysalloc, FRAME_SIZE); bst->results = STR_NEW_SALLOC(dm_st->sysalloc, FRAME_SIZE); /* Map the stretches. */ SALLOC_SETPROT(dm_st->sysalloc, bst->results, rop->pdid, SET_ELEM(Stretch_Right_Read) ); SALLOC_SETPROT(dm_st->sysalloc, bst->args, rop->pdid, SET_ELEM(Stretch_Right_Read)| SET_ELEM(Stretch_Right_Write)); /* * Next, initialise as much of the Client structure as we can at * this stage, given that we're in the Binder's domain and the * client won't have a threads package anyway. The rest of this * state will be initialised when the client domain calls Bind on * the Binder offer. Compare with lib/nemesis/IDC/ShmTransport.c: * notice that we have to init the state to what the methods in * Shm[Client|Server]Binding_op are expecting. */ stubinfo = NAME_FIND (IDC_CONTEXT">Binder", IDCStubs_Info); TRC(eprintf("Binder_NewDomain: creating Binder client IDC state.\n")); { Binder_clp client_cl = NARROW ((Type_Any *)(&stubinfo->surr), Binder_clp); CL_INIT(bcl->client_cl, (addr_t) client_cl->op, bcl); CL_INIT(bcl->binding_cl, &BinderClientBinding_op, bcl); } ANY_INIT (&bcl->cs.srgt, Binder_clp, &bcl->client_cl); bcl->cs.binding = &bcl->binding_cl; bcl->cs.marshal = dm_st->shmidc; /* The client ShmConnection_t immediately follows the Client_t (aka bcl) in the binder_rw. */ bcl->conn = (ShmConnection_t *)(bcl+1); if(stubinfo->clnt) { /* Let the stubs set up any required run-time state */ IDCClientStubs$InitState(stubinfo->clnt, &bcl->cs); } /* Now setup the client side ShmConnection */ /* XXX Leave mu_init to user */ /* Transmit buffer rec */ bcl->conn->txbuf.base = STR_RANGE(bst->args, &bcl->conn->txsize); bcl->conn->txbuf.ptr = bcl->conn->txbuf.base; bcl->conn->txbuf.space = bcl->conn->txsize; bcl->conn->txbuf.heap = NULL; /* Receive buffer rec */ bcl->conn->rxbuf.base = STR_RANGE(bst->results, &bcl->conn->rxsize); bcl->conn->rxbuf.ptr = bcl->conn->rxbuf.base; bcl->conn->rxbuf.space = bcl->conn->rxsize; bcl->conn->rxbuf.heap = NULL; /* Event counts will be filled in by the domain */ bcl->conn->evs.tx = NULL_EVENT; bcl->conn->evs.rx = NULL_EVENT; /* We can call the new domain's VP interface to get end-points */ bcl->conn->eps.tx = VP$AllocChannel (&rop->vp_cl); bcl->conn->eps.rx = VP$AllocChannel (&rop->vp_cl); bcl->conn->call = 0; bcl->conn->dom = dm_st->dm_dom->id; /* XXX SMH: for some reason we don't know our own pdom. Hoho. */ bcl->conn->pdid = NULL_PDID; /* bcl->offer is not used normally; in BINDER_MUX it is inited below */ /* * Initialise the server idc state. */ /* First we setup the server connection state */ MU_INIT (&bst->sconn.mu); /* XXX - unused; entry SYNC on server */ bst->sconn.txbuf = bcl->conn->rxbuf; bst->sconn.txsize = bst->sconn.txbuf.space; bst->sconn.rxbuf = bcl->conn->txbuf; bst->sconn.rxbuf.heap = Pvs(heap); /* XXX */ bst->sconn.rxsize = bst->sconn.rxbuf.space; bst->sconn.call = 0; bst->sconn.eps.tx = Events$AllocChannel(Pvs(evs)); bst->sconn.eps.rx = Events$AllocChannel(Pvs(evs)); bst->sconn.evs.tx = EC_NEW(); bst->sconn.evs.rx = NULL_EVENT; /* we use "Entry" synch. on server */ bst->sconn.dom = rop->id; bst->sconn.pdid = rop->pdid; #ifdef CONFIG_BINDER_MUX /* Initialise the (de)muxing server. */ TRC(eprintf("Binder_NewDomain: creating Binder MuxIDC server state.\n")); CL_INIT (bst->mux.cntrl_cl, &MuxStubs_ms, &bst->mux); CL_INIT (bst->mux.cntrl_cl, &MuxStubs_ms, &bst->mux); /* We use the connection state we setup above */ bst->mux.conn = &bst->sconn; bst->mux.ss.service = NULL; /* There's no specific service */ bst->mux.ss.binding = &bsv->binding_cl; #endif TRC(eprintf("Binder_NewDomain: creating Binder IDC server state.\n")); bsv->ss.service = &bst->binder; bsv->ss.binding = &bsv->binding_cl; bsv->ss.marshal = dm_st->shmidc; CL_INIT (bsv->cntrl_cl, stubinfo->stub->op, bsv); CL_INIT (bsv->binding_cl, &ShmServerBinding_op, bsv); /* We use (or share!) the connection state we setup above */ bsv->conn = &bst->sconn; /* Hijack offer field for PerDomain_st */ bsv->offer = (Offer_t *) bst; /* XXX PRB Moved this before the Plumber_Connect since otherwise Events$Attach does an ntsc_send causing the new domain to be woken up! */ Events$Attach (Pvs(evs), bsv->conn->evs.tx, bsv->conn->eps.tx, Channel_EPType_TX); /* Connect the event channels */ Plumber$Connect (Plumber, dm_st->dm_dom, rop, bsv->conn->eps.tx, bcl->conn->eps.rx); Plumber$Connect (Plumber, rop, dm_st->dm_dom, bcl->conn->eps.tx, bsv->conn->eps.rx); #ifdef CONFIG_BINDER_MUX /* Register the binder server with the demuxing server */ bcl->offer = (Offer_t *)RegisterServer(&bst->mux, &bsv->cntrl_cl); if(bcl->offer == (Offer_t *)-1) { eprintf("Binder_NewDomain: addition of binder to mux svr failed!\n"); ntsc_halt(); } #endif /* Initialise the rest of the per-domain state */ TRC(eprintf("Binder_NewDomain: creating Binder per-domain state.\n")); bst->rop = rop; bst->rwp = rwp; bst->dm_st = dm_st; /* refCount starts at 1, to allow for the following references to the rop/rwp to be held (update as necessary): 1: the server binding (possibly muxed) */ bst->refCount = 1; bst->callback = NULL; CL_INIT (bst->binder, &binder_ops, bst); /* The offer closure is a special hand crafted one */ CL_INIT (bst->offer_cl, &offer_ops, bcl); rop->binder_offer = &bst->offer_cl; #define panic(format, args...) \ do { eprintf(format, ## args); ntsc_halt(); } while(0) TRC(eprintf("Binder_NewDomain: registering entry.\n")); TRY { #ifdef CONFIG_BINDER_MUX Entry$Bind (Pvs(entry), bst->mux.conn->eps.rx, &(bst->mux.cntrl_cl)); #else Entry$Bind (Pvs(entry), bsv->conn->eps.rx, &bsv->cntrl_cl ); #endif } CATCH_Entry$TooManyChannels() { eprintf("Too many channels registering Binder\n"); } ENDTRY; TRC(eprintf("Binder_NewDomain: done.\n")); return bst; }
void FMEDITAPI SetMouseRtn( HWND wnd, MOUSEACTION *rtn ) { InitState( wnd ); State->mouseaction = rtn; }
bool FMEDITAPI IsEditting( HWND wnd ) { InitState( wnd ); return( State->currstate == EDITING ); }
bool CScriptState::ResetState() { ClearState(); return InitState(); }
void ActorFrame::InitState() { FOREACH( Actor*, m_SubActors, a ) (*a)->InitState(); Actor::InitState(); }
void OpcodesTest() { printf(">>> OpcodesTest \n"); struct State state; struct CompilationState compilationState; Mem memory[512]; InitState(&state, memory, sizeof(memory)); InitCompilationState(&compilationState, memory, sizeof(memory)); int opcodeTestOffset = 127; char* string = "OpcodeTest #1"; long len = strlen(string); memcpy(memory+opcodeTestOffset, string, len); int argNum = 0; PutCall(&compilationState, "MethodEnter"); PutByte(&compilationState, (argNum+1) * sizeof(Short)); NextInstruction(&state); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, opcodeTestOffset); NextInstruction(&state); AssertStackTopShort(&state, opcodeTestOffset); PutCall(&compilationState, "StoreShort"); PutByte(&compilationState, argNum); NextInstruction(&state); PutCall(&compilationState, "LoadByte"); PutByte(&compilationState, argNum); NextInstruction(&state); AssertStackTopByte(&state, (Byte)opcodeTestOffset); PutCall(&compilationState, "StoreByte"); PutByte(&compilationState, argNum); NextInstruction(&state); PutCall(&compilationState, "LoadShort"); PutByte(&compilationState, argNum); NextInstruction(&state); AssertStackTopShort(&state, opcodeTestOffset); PutCall(&compilationState, "PushByteToStack"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, CodeSizeForInstruction("ZeroOpcodeFail") + CodeSizeForInstruction("Jump")); PutCall(&compilationState, "ZeroOpcodeFail"); PutCall(&compilationState, "Jump"); PutShort(&compilationState, CodeSizeForInstruction("Jump") + CodeSizeForInstruction("ZeroOpcodeFail")); PutCall(&compilationState, "Jump"); PutShort(&compilationState, -CodeSizeForInstruction("Jump")*2); PutCall(&compilationState, "ZeroOpcodeFail"); PutCall(&compilationState, "PassToPutS"); NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); AssertStackTopShort(&state, opcodeTestOffset); NextInstruction(&state); PutCall(&compilationState, "PushByteToStack"); PutByte(&compilationState, 0); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, -CodeSizeForInstruction("JumpIf") ); NextInstruction(&state); PutCall(&compilationState, "PushByteToStack"); PutByte(&compilationState, 2); NextInstruction(&state); PutCall(&compilationState, "PushByteToStack"); PutByte(&compilationState, 2); NextInstruction(&state); PutCall(&compilationState, "CompareBytes"); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, CodeSizeForInstruction("ZeroOpcodeFail")); PutCall(&compilationState, "ZeroOpcodeFail"); NextInstruction(&state); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, 2000); NextInstruction(&state); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, 2000); NextInstruction(&state); PutCall(&compilationState, "CompareShorts"); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, CodeSizeForInstruction("ZeroOpcodeFail")); PutCall(&compilationState, "ZeroOpcodeFail"); NextInstruction(&state); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, 100); NextInstruction(&state); PutCall(&compilationState, "StoreByte"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "LoadShort"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "Inc"); NextInstruction(&state); PutCall(&compilationState, "Dec"); NextInstruction(&state); PutCall(&compilationState, "LoadShort"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "CompareShorts"); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, CodeSizeForInstruction("ZeroOpcodeFail")); PutCall(&compilationState, "ZeroOpcodeFail"); NextInstruction(&state); PutCall(&compilationState, "LoadShort"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "DupShort"); NextInstruction(&state); PutCall(&compilationState, "CompareShorts"); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, CodeSizeForInstruction("ZeroOpcodeFail")); PutCall(&compilationState, "ZeroOpcodeFail"); NextInstruction(&state); PutCall(&compilationState, "LoadByte"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "DupByte"); NextInstruction(&state); PutCall(&compilationState, "CompareBytes"); NextInstruction(&state); PutCall(&compilationState, "JumpIf"); PutShort(&compilationState, CodeSizeForInstruction("ZeroOpcodeFail")); PutCall(&compilationState, "ZeroOpcodeFail"); NextInstruction(&state); PutCall(&compilationState, "LoadShort"); PutByte(&compilationState, 1); NextInstruction(&state); PutCall(&compilationState, "DupShort"); NextInstruction(&state); PutCall(&compilationState, "Add"); NextInstruction(&state); AssertStackTopShort(&state, 200); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, -2); NextInstruction(&state); AssertStackTopShort(&state, -2); PutCall(&compilationState, "Mul"); NextInstruction(&state); AssertStackTopShort(&state, -400); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, -4); NextInstruction(&state); PutCall(&compilationState, "Div"); NextInstruction(&state); AssertStackTopShort(&state, 100); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, 99); NextInstruction(&state); PutCall(&compilationState, "Sub"); NextInstruction(&state); AssertStackTopShort(&state, 1); int methodOffset = 200; MemPtr mainPC = compilationState.PC; { compilationState.PC = compilationState.memory + methodOffset; PutCall(&compilationState, "MethodEnter"); PutByte(&compilationState, 0); PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, opcodeTestOffset); PutCall(&compilationState, "PassToPutS"); PutCall(&compilationState, "MethodExit"); } compilationState.PC = mainPC; PutCall(&compilationState, "PushShortToStack"); PutShort(&compilationState, methodOffset); NextInstruction(&state); PutCall(&compilationState, "CallStackPtr"); NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); methodOffset = 200; int argValue = 0x40; PutCall(&compilationState, "PushByteToStack"); PutByte(&compilationState, argValue); PutCall(&compilationState, "Call"); PutShort(&compilationState, methodOffset); mainPC = compilationState.PC; { compilationState.PC = compilationState.memory + methodOffset; PutCall(&compilationState, "MethodEnter"); PutByte(&compilationState, 1*sizeof(Short)); PutCall(&compilationState, "SetupArgsStack"); PutCall(&compilationState, "StoreByte"); PutByte(&compilationState, 0); PutCall(&compilationState, "SetupFrameStack"); PutCall(&compilationState, "LoadShort"); PutByte(&compilationState, 0); PutCall(&compilationState, "MethodReturn"); PutByte(&compilationState, sizeof(Short)); } compilationState.PC = mainPC; NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); AssertStackTopByte(&state, argValue); NextInstruction(&state); NextInstruction(&state); NextInstruction(&state); AssertStackTopShort(&state, argValue); NextInstruction(&state); AssertStackTopShort(&state, argValue); PutCall(&compilationState, "MethodExit"); NextInstruction(&state); }
bool COGLGraphicsContext::Initialize(HWND hWnd, HWND hWndStatus, uint32 dwWidth, uint32 dwHeight, BOOL bWindowed ) { printf("Initializing OpenGL Device Context\n"); Lock(); CGraphicsContext::Get()->m_supportTextureMirror = false; CGraphicsContext::Initialize(hWnd, hWndStatus, dwWidth, dwHeight, bWindowed ); if( bWindowed ) { windowSetting.statusBarHeightToUse = windowSetting.statusBarHeight; windowSetting.toolbarHeightToUse = windowSetting.toolbarHeight; } else { windowSetting.statusBarHeightToUse = 0; windowSetting.toolbarHeightToUse = 0; } int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) colorBufferDepth = 16; // init sdl & gl const SDL_VideoInfo *videoInfo; Uint32 videoFlags = 0; /* Initialize SDL */ printf("(II) Initializing SDL video subsystem...\n"); if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) { printf("(EE) Error initializing SDL video subsystem: %s\n", SDL_GetError()); return false; } /* Video Info */ printf("(II) Getting video info...\n"); if(!(videoInfo = SDL_GetVideoInfo())) { printf("(EE) Video query failed: %s\n", SDL_GetError()); SDL_QuitSubSystem(SDL_INIT_VIDEO); return false; } /* Setting the video mode */ videoFlags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE; if(videoInfo->hw_available) videoFlags |= SDL_HWSURFACE; else videoFlags |= SDL_SWSURFACE; if(videoInfo->blit_hw) videoFlags |= SDL_HWACCEL; if(!bWindowed) videoFlags |= SDL_FULLSCREEN; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, colorBufferDepth); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBufferDepth); printf("(II) Setting video mode %dx%d...\n", (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight); if(!(m_pScreen = SDL_SetVideoMode(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, colorBufferDepth, videoFlags))) { printf("(EE) Error setting video mode %dx%d: %s\n", (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight, SDL_GetError()); SDL_QuitSubSystem(SDL_INIT_VIDEO); return false; } char caption[500]; sprintf(caption, "RiceVideoLinux N64 Plugin %s", MUPEN_VERSION); SDL_WM_SetCaption(caption, caption); SetWindowMode(); InitState(); InitOGLExtension(); sprintf(m_strDeviceStats, "%s - %s : %s", m_pVendorStr, m_pRenderStr, m_pVersionStr); TRACE0(m_strDeviceStats); printf("%s\n", m_strDeviceStats); Unlock(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); // Clear buffers UpdateFrame(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); UpdateFrame(); m_bReady = true; status.isVertexShaderEnabled = false; return true; }