static void _dump_DIEFFECT_flags(DWORD dwFlags) { if (TRACE_ON(dinput)) { unsigned int i; static const struct { DWORD mask; const char *name; } flags[] = { #define FE(x) { x, #x} FE(DIEFF_CARTESIAN), FE(DIEFF_OBJECTIDS), FE(DIEFF_OBJECTOFFSETS), FE(DIEFF_POLAR), FE(DIEFF_SPHERICAL) #undef FE }; for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) if (flags[i].mask & dwFlags) TRACE("%s ", flags[i].name); TRACE("\n"); } }
/***************************************************************************** * IDirect3DViewport3::GetViewport2 * * Returns the currently set viewport in a D3DVIEWPORT2 structure. * Similar to IDirect3DViewport3::GetViewport * * Params: * lpData: Pointer to the structure to fill * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if the viewport was set with * IDirect3DViewport3::SetViewport * DDERR_INVALIDPARAMS if Data is NULL * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; DWORD dwSize; TRACE("iface %p, data %p.\n", iface, lpData); EnterCriticalSection(&ddraw_cs); dwSize = lpData->dwSize; memset(lpData, 0, dwSize); if (This->use_vp2) memcpy(lpData, &(This->viewports.vp2), dwSize); else { D3DVIEWPORT2 vp2; vp2.dwSize = sizeof(vp2); vp2.dwX = This->viewports.vp1.dwX; vp2.dwY = This->viewports.vp1.dwY; vp2.dwWidth = This->viewports.vp1.dwWidth; vp2.dwHeight = This->viewports.vp1.dwHeight; vp2.dvClipX = 0.0; vp2.dvClipY = 0.0; vp2.dvClipWidth = 0.0; vp2.dvClipHeight = 0.0; vp2.dvMinZ = This->viewports.vp1.dvMinZ; vp2.dvMaxZ = This->viewports.vp1.dvMaxZ; memcpy(lpData, &vp2, dwSize); } if (TRACE_ON(ddraw)) { TRACE(" returning D3DVIEWPORT2 :\n"); _dump_D3DVIEWPORT2(lpData); } LeaveCriticalSection(&ddraw_cs); return D3D_OK; }
/***************************************************************************** * IDirect3DViewport3::SetViewport * * Sets the viewport information for this interface * * Params: * lpData: Viewport to set * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if Data is NULL * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *lpData) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; LPDIRECT3DVIEWPORT3 current_viewport; TRACE("iface %p, data %p.\n", iface, lpData); if (TRACE_ON(ddraw)) { TRACE(" getting D3DVIEWPORT :\n"); _dump_D3DVIEWPORT(lpData); } EnterCriticalSection(&ddraw_cs); This->use_vp2 = 0; memset(&(This->viewports.vp1), 0, sizeof(This->viewports.vp1)); memcpy(&(This->viewports.vp1), lpData, lpData->dwSize); /* Tests on two games show that these values are never used properly so override them with proper ones :-) */ This->viewports.vp1.dvMinZ = 0.0; This->viewports.vp1.dvMaxZ = 1.0; if (This->active_device) { IDirect3DDevice3 *d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; IDirect3DDevice3_GetCurrentViewport(d3d_device3, ¤t_viewport); if (current_viewport) { if ((IDirect3DViewportImpl *)current_viewport == This) viewport_activate(This, FALSE); IDirect3DViewport3_Release(current_viewport); } } LeaveCriticalSection(&ddraw_cs); return DD_OK; }
/***************************************************************************** * IDirect3DExecuteBuffer::SetExecuteData * * Sets the execute data. This data is used to describe the buffer's content * * Params: * Data: Pointer to a D3DEXECUTEDATA structure containing the data to * assign * * Returns: * D3D_OK on success * DDERR_OUTOFMEMORY if the vertex buffer allocation failed * *****************************************************************************/ static HRESULT WINAPI d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer *iface, D3DEXECUTEDATA *data) { struct d3d_execute_buffer *buffer = impl_from_IDirect3DExecuteBuffer(iface); DWORD nbvert; TRACE("iface %p, data %p.\n", iface, data); memcpy(&buffer->data, data, data->dwSize); /* Get the number of vertices in the execute buffer */ nbvert = buffer->data.dwVertexCount; /* Prepares the transformed vertex buffer */ HeapFree(GetProcessHeap(), 0, buffer->vertex_data); buffer->vertex_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbvert * sizeof(D3DTLVERTEX)); buffer->nb_vertices = nbvert; if (TRACE_ON(ddraw)) _dump_executedata(data); return D3D_OK; }
/****************************************************************************** * ME_JoinRuns * * Merges two adjacent runs, the one given as a parameter and the next one. */ void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p) { ME_DisplayItem *pNext = p->next; int i; assert(p->type == diRun && pNext->type == diRun); assert(p->member.run.nCharOfs != -1); ME_GetParagraph(p)->member.para.nFlags |= MEPF_REWRAP; /* Update all cursors so that they don't contain the soon deleted run */ for (i=0; i<editor->nCursors; i++) { if (editor->pCursors[i].pRun == pNext) { editor->pCursors[i].pRun = p; editor->pCursors[i].nOffset += p->member.run.len; } } p->member.run.len += pNext->member.run.len; ME_Remove(pNext); ME_DestroyDisplayItem(pNext); ME_UpdateRunFlags(editor, &p->member.run); if(TRACE_ON(richedit_check)) ME_CheckCharOffsets(editor); }
/*********************************************************************** * start_thread * * Startup routine for a newly created thread. */ static void start_thread( struct startup_info *info ) { TEB *teb = info->teb; struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)teb->SpareBytes1; PRTL_THREAD_START_ROUTINE func = info->entry_point; void *arg = info->entry_arg; struct debug_info debug_info; debug_info.str_pos = debug_info.strings; debug_info.out_pos = debug_info.output; thread_data->debug_info = &debug_info; thread_data->pthread_id = pthread_self(); signal_init_thread( teb ); server_init_thread( func ); pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL ); MODULE_DllThreadAttach( NULL ); if (TRACE_ON(relay)) DPRINTF( "%04x:Starting thread proc %p (arg=%p)\n", GetCurrentThreadId(), func, arg ); call_thread_entry_point( (LPTHREAD_START_ROUTINE)func, arg ); }
/***************************************************************************** * IDirect3DViewport3::SetViewport * * Sets the viewport information for this interface * * Params: * lpData: Viewport to set * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if Data is NULL * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *lpData) { ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface); LPDIRECT3DVIEWPORT3 current_viewport; TRACE("(%p/%p)->(%p)\n", This, iface, lpData); if (TRACE_ON(d3d7)) { TRACE(" getting D3DVIEWPORT :\n"); _dump_D3DVIEWPORT(lpData); } EnterCriticalSection(&ddraw_cs); This->use_vp2 = 0; memset(&(This->viewports.vp1), 0, sizeof(This->viewports.vp1)); memcpy(&(This->viewports.vp1), lpData, lpData->dwSize); /* Tests on two games show that these values are never used properly so override them with proper ones :-) */ This->viewports.vp1.dvMinZ = 0.0; This->viewports.vp1.dvMaxZ = 1.0; if (This->active_device) { IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice3), ¤t_viewport); if (current_viewport) { if (ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport) == This) This->activate(This, FALSE); IDirect3DViewport3_Release(current_viewport); } } LeaveCriticalSection(&ddraw_cs); return DD_OK; }
/*********************************************************************** * SendInput (USER32.@) */ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size ) { if (TRACE_ON(win)) { UINT i; for (i = 0; i < count; i++) { switch(inputs[i].type) { case INPUT_MOUSE: TRACE("mouse: dx %d, dy %d, data %x, flags %x, time %u, info %lx\n", inputs[i].u.mi.dx, inputs[i].u.mi.dy, inputs[i].u.mi.mouseData, inputs[i].u.mi.dwFlags, inputs[i].u.mi.time, inputs[i].u.mi.dwExtraInfo); break; case INPUT_KEYBOARD: TRACE("keyboard: vk %X, scan %x, flags %x, time %u, info %lx\n", inputs[i].u.ki.wVk, inputs[i].u.ki.wScan, inputs[i].u.ki.dwFlags, inputs[i].u.ki.time, inputs[i].u.ki.dwExtraInfo); break; case INPUT_HARDWARE: TRACE("hardware: msg %d, wParamL %x, wParamH %x\n", inputs[i].u.hi.uMsg, inputs[i].u.hi.wParamL, inputs[i].u.hi.wParamH); break; default: FIXME("unknown input type %u\n", inputs[i].type); break; } } } return USER_Driver->pSendInput( count, inputs, size ); }
static void _dump_EnumDevices_dwFlags(DWORD dwFlags) { if (TRACE_ON(dinput)) { unsigned int i; static const struct { DWORD mask; const char *name; } flags[] = { #define FE(x) { x, #x} FE(DIEDFL_ALLDEVICES), FE(DIEDFL_ATTACHEDONLY), FE(DIEDFL_FORCEFEEDBACK), FE(DIEDFL_INCLUDEALIASES), FE(DIEDFL_INCLUDEPHANTOMS) #undef FE }; if (dwFlags == 0) { DPRINTF("DIEDFL_ALLDEVICES"); return; } for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) if (flags[i].mask & dwFlags) DPRINTF("%s ",flags[i].name); } }
static HRESULT WINAPI IDirectMusicSynth8Impl_Download(LPDIRECTMUSICSYNTH8 iface, LPHANDLE hDownload, LPVOID data, LPBOOL free) { IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface); LPBYTE buffer = (LPBYTE)data; DMUS_DOWNLOADINFO *info = (DMUS_DOWNLOADINFO*)buffer; ULONG *offsets = ((DMUS_OFFSETTABLE*)(buffer + sizeof(DMUS_DOWNLOADINFO)))->ulOffsetTable; LPBYTE object = buffer + sizeof(DMUS_DOWNLOADINFO) + info->dwNumOffsetTableEntries * sizeof(ULONG); FIXME("(%p)->(%p, %p, %p): stub\n", This, hDownload, data, free); /* FIXME: Currently we only dump data which is very useful to known how native dmusic behave and debug builtin dmusic */ if (!hDownload || !data || !free) return E_POINTER; if (TRACE_ON(dmsynth)) { TRACE("Dump DMUS_DOWNLOADINFO struct:\n"); TRACE(" - dwDLType = %u\n", info->dwDLType); TRACE(" - dwDLId = %u\n", info->dwDLId); TRACE(" - dwNumOffsetTableEntries = %u\n", info->dwNumOffsetTableEntries); TRACE(" - cbSize = %u\n", info->cbSize); } /* The struct should have at least one offset corresponding to the donwload object itself */ if (!info->dwNumOffsetTableEntries) { FIXME("Offset table is empty\n"); return DMUS_E_BADOFFSETTABLE; } /* First offset should point to the download object */ if ((buffer + offsets[0]) != object) { FIXME("Object is not at the beginning\n"); return DMUS_E_BADOFFSETTABLE; } if (info->dwDLType == DMUS_DOWNLOADINFO_INSTRUMENT) { FIXME("Download type DMUS_DOWNLOADINFO_INSTRUMENT not yet supported\n"); } else if (info->dwDLType == DMUS_DOWNLOADINFO_WAVE) { DMUS_WAVE *wave = (DMUS_WAVE*)object; DMUS_WAVEDATA *wave_data; TRACE("Processing download type DMUS_DOWNLOADINFO_WAVE\n"); if (TRACE_ON(dmsynth)) { TRACE("Dump DMUS_WAVE struct\n"); TRACE(" - ulFirstExtCkIdx = %u\n", wave->ulFirstExtCkIdx); TRACE(" - ulCopyrightIdx = %u\n", wave->ulCopyrightIdx); TRACE(" - ulWaveDataIdx = %u\n", wave->ulWaveDataIdx); TRACE(" - WaveformatEx:\n"); TRACE(" - wFormatTag = %u\n", wave->WaveformatEx.wFormatTag); TRACE(" - nChannels = %u\n", wave->WaveformatEx.nChannels); TRACE(" - nSamplesPerSec = %u\n", wave->WaveformatEx.nSamplesPerSec); TRACE(" - nAvgBytesPerSec = %u\n", wave->WaveformatEx.nAvgBytesPerSec); TRACE(" - nBlockAlign = %u\n", wave->WaveformatEx.nBlockAlign); TRACE(" - wBitsPerSample = %u\n", wave->WaveformatEx.wBitsPerSample); TRACE(" - cbSize = %u\n", wave->WaveformatEx.cbSize); if (wave->ulCopyrightIdx) { DMUS_COPYRIGHT *copyright = (DMUS_COPYRIGHT*)(buffer + offsets[wave->ulCopyrightIdx]); TRACE("Copyright = '%s'\n", (char*)copyright->byCopyright); } wave_data = (DMUS_WAVEDATA*)(buffer + offsets[wave->ulWaveDataIdx]); TRACE("Found %u bytes of wave data\n", wave_data->cbSize); } } else if (info->dwDLType == DMUS_DOWNLOADINFO_INSTRUMENT2) { DMUS_INSTRUMENT *instrument = (DMUS_INSTRUMENT*)object; ULONG nb_regions = 0; TRACE("Processing download type DMUS_DOWNLOADINFO_INSTRUMENT2\n"); if (TRACE_ON(dmsynth)) { TRACE("Dump DMUS_INSTRUMENT struct\n"); TRACE(" - ulPatch = %u\n", instrument->ulPatch); TRACE(" - ulFirstRegionIdx = %u\n", instrument->ulFirstRegionIdx); TRACE(" - ulGlobalArtIdx = %u\n", instrument->ulGlobalArtIdx); TRACE(" - ulFirstExtCkIdx = %u\n", instrument->ulFirstExtCkIdx); TRACE(" - ulCopyrightIdx = %u\n", instrument->ulCopyrightIdx); TRACE(" - ulFlags = %u\n", instrument->ulFlags); if (instrument->ulCopyrightIdx) { DMUS_COPYRIGHT *copyright = (DMUS_COPYRIGHT*)(buffer + offsets[instrument->ulCopyrightIdx]); TRACE("Copyright = '%s'\n", (char*)copyright->byCopyright); } } if (instrument->ulFirstRegionIdx) { ULONG region_idx = instrument->ulFirstRegionIdx; while (region_idx) { DMUS_REGION *region = (DMUS_REGION*)(buffer + offsets[region_idx]); region_idx = region->ulNextRegionIdx; nb_regions++; } } TRACE("Number of regions = %u\n", nb_regions); } else if (info->dwDLType == DMUS_DOWNLOADINFO_WAVEARTICULATION) { FIXME("Download type DMUS_DOWNLOADINFO_WAVEARTICULATION not yet supported\n"); } else if (info->dwDLType == DMUS_DOWNLOADINFO_STREAMINGWAVE) { FIXME("Download type DMUS_DOWNLOADINFO_STREAMINGWAVE not yet supported\n"); } else if (info->dwDLType == DMUS_DOWNLOADINFO_ONESHOTWAVE) { FIXME("Download type DMUS_DOWNLOADINFO_ONESHOTWAVE not yet supported\n"); } else { WARN("Unknown download type %u\n", info->dwDLType); return DMUS_E_UNKNOWNDOWNLOAD; } return S_OK; }
static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in, const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags) { struct wined3d_surface *back_buffer = swapchain->back_buffers[0]; const struct wined3d_fb_state *fb = &swapchain->device->fb; const struct wined3d_gl_info *gl_info; struct wined3d_context *context; RECT src_rect, dst_rect; BOOL render_to_fbo; context = context_acquire(swapchain->device, back_buffer); if (!context->valid) { context_release(context); WARN("Invalid context, skipping present.\n"); return; } gl_info = context->gl_info; if (swapchain->device->logo_texture) { struct wined3d_surface *src_surface = surface_from_resource( wined3d_texture_get_sub_resource(swapchain->device->logo_texture, 0)); RECT rect = {0, 0, src_surface->resource.width, src_surface->resource.height}; /* Blit the logo into the upper left corner of the drawable. */ wined3d_surface_blt(back_buffer, &rect, src_surface, &rect, WINEDDBLT_ALPHATEST, NULL, WINED3D_TEXF_POINT); } if (swapchain->device->bCursorVisible && swapchain->device->cursor_texture && !swapchain->device->hardwareCursor) { struct wined3d_surface *cursor = surface_from_resource( wined3d_texture_get_sub_resource(swapchain->device->cursor_texture, 0)); RECT destRect = { swapchain->device->xScreenSpace - swapchain->device->xHotSpot, swapchain->device->yScreenSpace - swapchain->device->yHotSpot, swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot, swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot, }; TRACE("Rendering the software cursor.\n"); if (swapchain->desc.windowed) MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&destRect, 2); wined3d_surface_blt(back_buffer, &destRect, cursor, NULL, WINEDDBLT_ALPHATEST, NULL, WINED3D_TEXF_POINT); } TRACE("Presenting HDC %p.\n", context->hdc); render_to_fbo = swapchain->render_to_fbo; if (src_rect_in) { src_rect = *src_rect_in; if (!render_to_fbo && (src_rect.left || src_rect.top || src_rect.right != swapchain->desc.backbuffer_width || src_rect.bottom != swapchain->desc.backbuffer_height)) { render_to_fbo = TRUE; } } else { src_rect.left = 0; src_rect.top = 0; src_rect.right = swapchain->desc.backbuffer_width; src_rect.bottom = swapchain->desc.backbuffer_height; } if (dst_rect_in) dst_rect = *dst_rect_in; else if (context->surface && !swapchain->desc.windowed) { dst_rect.left = 0; dst_rect.top = 0; dst_rect.right = swapchain->front_buffer->resource.width; dst_rect.bottom = swapchain->front_buffer->resource.height; } else GetClientRect(swapchain->win_handle, &dst_rect); if (!render_to_fbo && (dst_rect.left || dst_rect.top || dst_rect.right != swapchain->desc.backbuffer_width || dst_rect.bottom != swapchain->desc.backbuffer_height)) render_to_fbo = TRUE; /* Rendering to a window of different size, presenting partial rectangles, * or rendering to a different window needs help from FBO_blit or a textured * draw. Render the swapchain to a FBO in the future. * * Note that FBO_blit from the backbuffer to the frontbuffer cannot solve * all these issues - this fails if the window is smaller than the backbuffer. */ if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO) { surface_load_location(back_buffer, WINED3D_LOCATION_TEXTURE_RGB); surface_invalidate_location(back_buffer, WINED3D_LOCATION_DRAWABLE); swapchain->render_to_fbo = TRUE; swapchain_update_draw_bindings(swapchain); } else { surface_load_location(back_buffer, back_buffer->draw_binding); } if (swapchain->render_to_fbo) { static unsigned int once; if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP && !once++) FIXME("WINED3D_SWAP_EFFECT_FLIP not implemented.\n"); swapchain_blit(swapchain, context, &src_rect, &dst_rect); } if (swapchain->num_contexts > 1) gl_info->gl_ops.gl.p_glFinish(); /* call wglSwapBuffers through the gl table to avoid confusing the Steam overlay */ gl_info->gl_ops.wgl.p_wglSwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */ TRACE("SwapBuffers called, Starting new frame\n"); /* FPS support */ if (TRACE_ON(fps)) { DWORD time = GetTickCount(); ++swapchain->frames; /* every 1.5 seconds */ if (time - swapchain->prev_time > 1500) { TRACE_(fps)("%p @ approx %.2ffps\n", swapchain, 1000.0 * swapchain->frames / (time - swapchain->prev_time)); swapchain->prev_time = time; swapchain->frames = 0; } } if (!swapchain->render_to_fbo && ((swapchain->front_buffer->locations & WINED3D_LOCATION_SYSMEM) || (back_buffer->locations & WINED3D_LOCATION_SYSMEM))) { /* Both memory copies of the surfaces are ok, flip them around too instead of dirtifying * Doesn't work with render_to_fbo because we're not flipping */ struct wined3d_surface *front = swapchain->front_buffer; if (front->resource.size == back_buffer->resource.size) { flip_surface(front, back_buffer); /* Tell the front buffer surface that is has been modified. However, * the other locations were preserved during that, so keep the flags. * This serves to update the emulated overlay, if any. */ surface_validate_location(front, WINED3D_LOCATION_DRAWABLE); } else { surface_validate_location(front, WINED3D_LOCATION_DRAWABLE); surface_invalidate_location(front, ~WINED3D_LOCATION_DRAWABLE); surface_validate_location(back_buffer, WINED3D_LOCATION_DRAWABLE); surface_invalidate_location(back_buffer, ~WINED3D_LOCATION_DRAWABLE); } } else { surface_validate_location(swapchain->front_buffer, WINED3D_LOCATION_DRAWABLE); surface_invalidate_location(swapchain->front_buffer, ~WINED3D_LOCATION_DRAWABLE); /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM * and INTEXTURE copies can keep their old content if they have any defined content. * If the swapeffect is COPY, the content remains the same. If it is FLIP however, * the texture / sysmem copy needs to be reloaded from the drawable */ if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP) { surface_validate_location(back_buffer, back_buffer->draw_binding); surface_invalidate_location(back_buffer, ~back_buffer->draw_binding); } } if (fb->depth_stencil) { if (swapchain->desc.flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL || fb->depth_stencil->flags & SFLAG_DISCARD) { surface_modify_ds_location(fb->depth_stencil, WINED3D_LOCATION_DISCARDED, fb->depth_stencil->resource.width, fb->depth_stencil->resource.height); if (fb->depth_stencil == swapchain->device->onscreen_depth_stencil) { wined3d_surface_decref(swapchain->device->onscreen_depth_stencil); swapchain->device->onscreen_depth_stencil = NULL; } } } context_release(context); }
/*** IDirectXFile methods ***/ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPVOID pvSource, DXFILELOADOPTIONS dwLoadOptions, LPDIRECTXFILEENUMOBJECT* ppEnumObj) { IDirectXFileImpl *This = impl_from_IDirectXFile(iface); IDirectXFileEnumObjectImpl* object; HRESULT hr; LPBYTE file_buffer; DWORD file_size; DWORD bytes_written; TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj); if (!ppEnumObj) return DXFILEERR_BADVALUE; /* Only lowest 4 bits are relevant in DXFILELOADOPTIONS */ dwLoadOptions &= 0xF; hr = IDirectXFileEnumObjectImpl_Create(&object); if (FAILED(hr)) return hr; if (dwLoadOptions == DXFILELOAD_FROMFILE) { HANDLE hFile, file_mapping; TRACE("Open source file '%s'\n", (char*)pvSource); hFile = CreateFileA(pvSource, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile == INVALID_HANDLE_VALUE) { TRACE("File '%s' not found\n", (char*)pvSource); return DXFILEERR_FILENOTFOUND; } file_size = GetFileSize(hFile, NULL); file_mapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL); CloseHandle(hFile); if (!file_mapping) { hr = DXFILEERR_BADFILETYPE; goto error; } object->mapped_memory = MapViewOfFile(file_mapping, FILE_MAP_READ, 0, 0, 0); CloseHandle(file_mapping); if (!object->mapped_memory) { hr = DXFILEERR_BADFILETYPE; goto error; } file_buffer = object->mapped_memory; } else if (dwLoadOptions == DXFILELOAD_FROMRESOURCE) { HRSRC resource_info; HGLOBAL resource_data; LPDXFILELOADRESOURCE lpdxflr = pvSource; TRACE("Source in resource (module = %p, name = %s, type = %s)\n", lpdxflr->hModule, debugstr_a(lpdxflr->lpName), debugstr_a(lpdxflr->lpType)); resource_info = FindResourceA(lpdxflr->hModule, lpdxflr->lpName, lpdxflr->lpType); if (!resource_info) { hr = DXFILEERR_RESOURCENOTFOUND; goto error; } file_size = SizeofResource(lpdxflr->hModule, resource_info); resource_data = LoadResource(lpdxflr->hModule, resource_info); if (!resource_data) { hr = DXFILEERR_BADRESOURCE; goto error; } file_buffer = LockResource(resource_data); if (!file_buffer) { hr = DXFILEERR_BADRESOURCE; goto error; } } else if (dwLoadOptions == DXFILELOAD_FROMMEMORY) { LPDXFILELOADMEMORY lpdxflm = pvSource; TRACE("Source in memory at %p with size %d\n", lpdxflm->lpMemory, lpdxflm->dSize); file_buffer = lpdxflm->lpMemory; file_size = lpdxflm->dSize; } else { FIXME("Source type %d is not handled yet\n", dwLoadOptions); hr = DXFILEERR_NOTDONEYET; goto error; } TRACE("File size is %d bytes\n", file_size); if (TRACE_ON(d3dxof_dump)) { static USHORT num; char tmp[12]; HANDLE file; sprintf(tmp, "file%05u.x", num++); file = CreateFileA(tmp, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); if (file != INVALID_HANDLE_VALUE) { WriteFile(file, file_buffer, file_size, &bytes_written, NULL); CloseHandle(file); } } object->pDirectXFile = This; object->buf.pdxf = This; object->buf.token_present = FALSE; object->buf.buffer = file_buffer; object->buf.rem_bytes = file_size; hr = parse_header(&object->buf, &object->decomp_buffer); if (FAILED(hr)) goto error; /* Check if there are templates defined before the object */ if (!parse_templates(&object->buf, TRUE)) { hr = DXFILEERR_PARSEERROR; goto error; } if (TRACE_ON(d3dxof)) { ULONG i; TRACE("Registered templates (%d):\n", This->nb_xtemplates); for (i = 1; i < This->nb_xtemplates; i++) DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id)); } *ppEnumObj = &object->IDirectXFileEnumObject_iface; return DXFILE_OK; error: IDirectXFileEnumObject_Release(&object->IDirectXFileEnumObject_iface); *ppEnumObj = NULL; return hr; }
static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p ) { ME_Paragraph *para = &p->member.para; ME_Run *run; ME_DisplayItem *di; SCRIPT_ITEM buf[16], *items = buf; int items_passed = sizeof( buf ) / sizeof( buf[0] ), num_items, cur_item; SCRIPT_CONTROL control = { LANG_USER_DEFAULT, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0 }; SCRIPT_STATE state = { 0, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0, 0 }; HRESULT hr; assert( p->type == diParagraph ); while (1) { hr = ScriptItemize( para->text->szData, para->text->nLen, items_passed, &control, &state, items, &num_items ); if (hr != E_OUTOFMEMORY) break; /* may not be enough items if hr == E_OUTOFMEMORY */ if (items_passed > para->text->nLen + 1) break; /* something else has gone wrong */ items_passed *= 2; if (items == buf) items = heap_alloc( items_passed * sizeof( *items ) ); else items = heap_realloc( items, items_passed * sizeof( *items ) ); if (!items) break; } if (FAILED( hr )) goto end; if (TRACE_ON( richedit )) { TRACE( "got items:\n" ); for (cur_item = 0; cur_item < num_items; cur_item++) { TRACE( "\t%d - %d RTL %d bidi level %d\n", items[cur_item].iCharPos, items[cur_item+1].iCharPos - 1, items[cur_item].a.fRTL, items[cur_item].a.s.uBidiLevel ); } TRACE( "before splitting runs into ranges\n" ); for (di = p->next; di != p->member.para.next_para; di = di->next) { if (di->type != diRun) continue; TRACE( "\t%d: %s\n", di->member.run.nCharOfs, debugstr_run( &di->member.run ) ); } } /* split runs into ranges at item boundaries */ for (di = p->next, cur_item = 0; di != p->member.para.next_para; di = di->next) { if (di->type != diRun) continue; run = &di->member.run; if (run->nCharOfs == items[cur_item+1].iCharPos) cur_item++; items[cur_item].a.fLogicalOrder = TRUE; run->script_analysis = items[cur_item].a; if (run->nFlags & MERF_ENDPARA) break; /* don't split eop runs */ if (run->nCharOfs + run->len > items[cur_item+1].iCharPos) { ME_Cursor cursor = {p, di, items[cur_item+1].iCharPos - run->nCharOfs}; ME_SplitRunSimple( c->editor, &cursor ); } } if (TRACE_ON( richedit )) { TRACE( "after splitting into ranges\n" ); for (di = p->next; di != p->member.para.next_para; di = di->next) { if (di->type != diRun) continue; TRACE( "\t%d: %s\n", di->member.run.nCharOfs, debugstr_run( &di->member.run ) ); } } para->nFlags |= MEPF_COMPLEX; end: if (items != buf) heap_free( items ); return hr; }
/************************************************************************* * ScrollDC (X11DRV.@) */ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate ) { RECT rcSrc, rcClip, offset; INT dxdev, dydev, res; HRGN DstRgn, clipRgn, visrgn; INT code = X11DRV_START_EXPOSURES; TRACE("dx,dy %d,%d rcScroll %s rcClip %s hrgnUpdate %p lprcUpdate %p\n", dx, dy, wine_dbgstr_rect(lprcScroll), wine_dbgstr_rect(lprcClip), hrgnUpdate, lprcUpdate); /* enable X-exposure events */ if (hrgnUpdate || lprcUpdate) ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); /* get the visible region */ visrgn=CreateRectRgn( 0, 0, 0, 0); GetRandomRgn( hdc, visrgn, SYSRGN); if( !(GetVersion() & 0x80000000)) { /* Window NT/2k/XP */ POINT org; GetDCOrgEx(hdc, &org); OffsetRgn( visrgn, -org.x, -org.y); } /* intersect with the clipping Region if the DC has one */ clipRgn = CreateRectRgn( 0, 0, 0, 0); if (GetClipRgn( hdc, clipRgn) != 1) { DeleteObject(clipRgn); clipRgn=NULL; } else CombineRgn( visrgn, visrgn, clipRgn, RGN_AND); /* only those pixels in the scroll rectangle that remain in the clipping * rect are scrolled. */ if( lprcClip) rcClip = *lprcClip; else GetClipBox( hdc, &rcClip); rcSrc = rcClip; OffsetRect( &rcClip, -dx, -dy); IntersectRect( &rcSrc, &rcSrc, &rcClip); /* if an scroll rectangle is specified, only the pixels within that * rectangle are scrolled */ if( lprcScroll) IntersectRect( &rcSrc, &rcSrc, lprcScroll); /* now convert to device coordinates */ LPtoDP(hdc, (LPPOINT)&rcSrc, 2); TRACE("source rect: %s\n", wine_dbgstr_rect(&rcSrc)); /* also dx and dy */ SetRect(&offset, 0, 0, dx, dy); LPtoDP(hdc, (LPPOINT)&offset, 2); dxdev = offset.right - offset.left; dydev = offset.bottom - offset.top; /* now intersect with the visible region to get the pixels that will * actually scroll */ DstRgn = CreateRectRgnIndirect( &rcSrc); res = CombineRgn( DstRgn, DstRgn, visrgn, RGN_AND); /* and translate, giving the destination region */ OffsetRgn( DstRgn, dxdev, dydev); if( TRACE_ON( scroll)) dump_region( "Destination scroll region: ", DstRgn); /* if there are any, do it */ if( res > NULLREGION) { RECT rect ; /* clip to the destination region, so we can BitBlt with a simple * bounding rectangle */ if( clipRgn) ExtSelectClipRgn( hdc, DstRgn, RGN_AND); else SelectClipRgn( hdc, DstRgn); GetRgnBox( DstRgn, &rect); DPtoLP(hdc, (LPPOINT)&rect, 2); TRACE("destination rect: %s\n", wine_dbgstr_rect(&rect)); BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hdc, rect.left - dx, rect.top - dy, SRCCOPY); } /* compute the update areas. This is the combined clip rectangle * minus the scrolled region, and intersected with the visible * region. */ if (hrgnUpdate || lprcUpdate) { HRGN hrgn = hrgnUpdate; HRGN ExpRgn = 0; /* collect all the exposures */ code = X11DRV_END_EXPOSURES; ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(ExpRgn), (LPSTR)&ExpRgn ); /* Intersect clip and scroll rectangles, allowing NULL values */ if( lprcScroll) if( lprcClip) IntersectRect( &rcClip, lprcClip, lprcScroll); else rcClip = *lprcScroll; else if( lprcClip) rcClip = *lprcClip; else GetClipBox( hdc, &rcClip); /* Convert the combined clip rectangle to device coordinates */ LPtoDP(hdc, (LPPOINT)&rcClip, 2); if( hrgn ) SetRectRgn( hrgn, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); else hrgn = CreateRectRgnIndirect( &rcClip); CombineRgn( hrgn, hrgn, visrgn, RGN_AND); CombineRgn( hrgn, hrgn, DstRgn, RGN_DIFF); /* add the exposures to this */ if( ExpRgn) { if( TRACE_ON( scroll)) dump_region( "Expose region: ", ExpRgn); CombineRgn( hrgn, hrgn, ExpRgn, RGN_OR); DeleteObject( ExpRgn); } if( TRACE_ON( scroll)) dump_region( "Update region: ", hrgn); if( lprcUpdate) { GetRgnBox( hrgn, lprcUpdate ); /* Put the lprcUpdate in logical coordinates */ DPtoLP( hdc, (LPPOINT)lprcUpdate, 2 ); TRACE("returning lprcUpdate %s\n", wine_dbgstr_rect(lprcUpdate)); } if( !hrgnUpdate) DeleteObject( hrgn); } /* restore original clipping region */ SelectClipRgn( hdc, clipRgn); DeleteObject( visrgn); DeleteObject( DstRgn); if( clipRgn) DeleteObject( clipRgn); return TRUE; }
HRESULT WINAPI DXGID3D10CreateDevice(HMODULE d3d10core, IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count, void **device) { struct layer_get_size_args get_size_args; struct dxgi_device_layer d3d10_layer; struct dxgi_device *dxgi_device; UINT device_size; DWORD count; HRESULT hr; TRACE("d3d10core %p, factory %p, adapter %p, flags %#x, feature_levels %p, level_count %u, device %p.\n", d3d10core, factory, adapter, flags, feature_levels, level_count, device); if (flags) FIXME("Ignoring flags %#x.\n", flags); if (TRACE_ON(dxgi)) dump_feature_levels(feature_levels, level_count); hr = register_d3d10core_layers(d3d10core); if (FAILED(hr)) { ERR("Failed to register d3d10core layers, returning %#x.\n", hr); return hr; } if (!get_layer(DXGI_DEVICE_LAYER_D3D10_DEVICE, &d3d10_layer)) { ERR("Failed to get D3D10 device layer.\n"); return E_FAIL; } count = 0; hr = d3d10_layer.init(d3d10_layer.id, &count, NULL); if (FAILED(hr)) { WARN("Failed to initialize D3D10 device layer.\n"); return E_FAIL; } get_size_args.unknown0 = 0; get_size_args.unknown1 = 0; get_size_args.unknown2 = NULL; get_size_args.unknown3 = NULL; get_size_args.adapter = adapter; get_size_args.interface_major = 10; get_size_args.interface_minor = 1; get_size_args.version_build = 4; get_size_args.version_revision = 6000; device_size = d3d10_layer.get_size(d3d10_layer.id, &get_size_args, 0); device_size += sizeof(*dxgi_device); dxgi_device = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, device_size); if (!dxgi_device) { ERR("Failed to allocate device memory.\n"); return E_OUTOFMEMORY; } hr = dxgi_device_init(dxgi_device, &d3d10_layer, factory, adapter, feature_levels, level_count); if (FAILED(hr)) { WARN("Failed to initialize device, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, dxgi_device); *device = NULL; return hr; } TRACE("Created device %p.\n", dxgi_device); *device = dxgi_device; return S_OK; }
FARPROC16 SNOOP16_GetProcAddress16(HMODULE16 hmod,DWORD ordinal,FARPROC16 origfun) { SNOOP16_DLL *dll = firstdll; SNOOP16_FUN *fun; NE_MODULE *pModule = NE_GetPtr(hmod); unsigned char *cpnt; char name[200]; if (!TRACE_ON(snoop) || !pModule || !HIWORD(origfun)) return origfun; if (!*(LPBYTE)MapSL((SEGPTR)origfun)) /* 0x00 is an impossible opcode, possible dataref. */ return origfun; while (dll) { if (hmod == dll->hmod) break; dll=dll->next; } if (!dll) /* probably internal */ return origfun; if (ordinal>65535/sizeof(SNOOP16_FUN)) return origfun; fun = dll->funs+ordinal; /* already done? */ fun->lcall = 0x9a; fun->snr = MAKELONG(0,xsnr); fun->origfun = origfun; if (fun->name) return (FARPROC16)(SEGPTR)MAKELONG(((char*)fun-(char*)dll->funs),dll->funhandle); cpnt = (unsigned char *)pModule + pModule->ne_restab; while (*cpnt) { cpnt += *cpnt + 1 + sizeof(WORD); if (*(WORD*)(cpnt+*cpnt+1) == ordinal) { sprintf(name,"%.*s",*cpnt,cpnt+1); break; } } /* Now search the non-resident names table */ if (!*cpnt && pModule->nrname_handle) { cpnt = (unsigned char *)GlobalLock16( pModule->nrname_handle ); while (*cpnt) { cpnt += *cpnt + 1 + sizeof(WORD); if (*(WORD*)(cpnt+*cpnt+1) == ordinal) { sprintf(name,"%.*s",*cpnt,cpnt+1); break; } } } if (*cpnt) { fun->name = HeapAlloc(GetProcessHeap(),0,strlen(name)+1); strcpy( fun->name, name ); } else fun->name = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,1); /* empty string */ if (!SNOOP16_ShowDebugmsgSnoop(dll->name, ordinal, fun->name)) return origfun; /* more magic. do not try to snoop thunk data entries (MMSYSTEM) */ if (strchr(fun->name,'_')) { char *s=strchr(fun->name,'_'); if (!strncasecmp(s,"_thunkdata",10)) { HeapFree(GetProcessHeap(),0,fun->name); fun->name = NULL; return origfun; } } fun->lcall = 0x9a; fun->snr = MAKELONG(0,xsnr); fun->origfun = origfun; fun->nrofargs = -1; return (FARPROC16)(SEGPTR)MAKELONG(((char*)fun-(char*)dll->funs),dll->funhandle); }
static HRESULT swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in, const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags) { struct wined3d_surface *back_buffer = swapchain->back_buffers[0]; const struct wined3d_fb_state *fb = &swapchain->device->fb; const struct wined3d_gl_info *gl_info; struct wined3d_context *context; RECT src_rect, dst_rect; BOOL render_to_fbo; context = context_acquire(swapchain->device, back_buffer); if (!context->valid) { context_release(context); WARN("Invalid context, skipping present.\n"); return WINED3D_OK; } gl_info = context->gl_info; /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */ if (swapchain->device->bCursorVisible && swapchain->device->cursorTexture && !swapchain->device->hardwareCursor) { struct wined3d_surface cursor; RECT destRect = { swapchain->device->xScreenSpace - swapchain->device->xHotSpot, swapchain->device->yScreenSpace - swapchain->device->yHotSpot, swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot, swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot, }; TRACE("Rendering the cursor. Creating fake surface at %p\n", &cursor); /* Build a fake surface to call the Blitting code. It is not possible to use the interface passed by * the application because we are only supposed to copy the information out. Using a fake surface * allows to use the Blitting engine and avoid copying the whole texture -> render target blitting code. */ memset(&cursor, 0, sizeof(cursor)); cursor.resource.ref = 1; cursor.resource.device = swapchain->device; cursor.resource.pool = WINED3D_POOL_SCRATCH; cursor.resource.format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM); cursor.resource.type = WINED3D_RTYPE_SURFACE; cursor.texture_name = swapchain->device->cursorTexture; cursor.texture_target = GL_TEXTURE_2D; cursor.texture_level = 0; cursor.resource.width = swapchain->device->cursorWidth; cursor.resource.height = swapchain->device->cursorHeight; /* The cursor must have pow2 sizes */ cursor.pow2Width = cursor.resource.width; cursor.pow2Height = cursor.resource.height; /* The surface is in the texture */ cursor.flags |= SFLAG_INTEXTURE; /* DDBLT_KEYSRC will cause BltOverride to enable the alpha test with GL_NOTEQUAL, 0.0, * which is exactly what we want :-) */ if (swapchain->desc.windowed) MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&destRect, 2); wined3d_surface_blt(back_buffer, &destRect, &cursor, NULL, WINEDDBLT_KEYSRC, NULL, WINED3D_TEXF_POINT); } if (swapchain->device->logo_surface) { struct wined3d_surface *src_surface = swapchain->device->logo_surface; RECT rect = {0, 0, src_surface->resource.width, src_surface->resource.height}; /* Blit the logo into the upper left corner of the drawable. */ wined3d_surface_blt(back_buffer, &rect, src_surface, &rect, WINEDDBLT_KEYSRC, NULL, WINED3D_TEXF_POINT); } TRACE("Presenting HDC %p.\n", context->hdc); render_to_fbo = swapchain->render_to_fbo; if (src_rect_in) { src_rect = *src_rect_in; if (!render_to_fbo && (src_rect.left || src_rect.top || src_rect.right != swapchain->desc.backbuffer_width || src_rect.bottom != swapchain->desc.backbuffer_height)) { render_to_fbo = TRUE; } } else { src_rect.left = 0; src_rect.top = 0; src_rect.right = swapchain->desc.backbuffer_width; src_rect.bottom = swapchain->desc.backbuffer_height; } if (dst_rect_in) dst_rect = *dst_rect_in; else GetClientRect(swapchain->win_handle, &dst_rect); if (!render_to_fbo && (dst_rect.left || dst_rect.top || dst_rect.right != swapchain->desc.backbuffer_width || dst_rect.bottom != swapchain->desc.backbuffer_height)) render_to_fbo = TRUE; /* Rendering to a window of different size, presenting partial rectangles, * or rendering to a different window needs help from FBO_blit or a textured * draw. Render the swapchain to a FBO in the future. * * Note that FBO_blit from the backbuffer to the frontbuffer cannot solve * all these issues - this fails if the window is smaller than the backbuffer. */ if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO) { surface_load_location(back_buffer, SFLAG_INTEXTURE, NULL); surface_modify_location(back_buffer, SFLAG_INDRAWABLE, FALSE); swapchain->render_to_fbo = TRUE; swapchain_update_draw_bindings(swapchain); } else { surface_load_location(back_buffer, back_buffer->draw_binding, NULL); } if (swapchain->render_to_fbo) { /* This codepath should only be hit with the COPY swapeffect. Otherwise a backbuffer- * window size mismatch is impossible(fullscreen) and src and dst rectangles are * not allowed(they need the COPY swapeffect) * * The DISCARD swap effect is ok as well since any backbuffer content is allowed after * the swap. */ if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP) FIXME("Render-to-fbo with WINED3D_SWAP_EFFECT_FLIP\n"); swapchain_blit(swapchain, context, &src_rect, &dst_rect); } if (swapchain->num_contexts > 1) wglFinish(); SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */ TRACE("SwapBuffers called, Starting new frame\n"); /* FPS support */ if (TRACE_ON(fps)) { DWORD time = GetTickCount(); ++swapchain->frames; /* every 1.5 seconds */ if (time - swapchain->prev_time > 1500) { TRACE_(fps)("%p @ approx %.2ffps\n", swapchain, 1000.0 * swapchain->frames / (time - swapchain->prev_time)); swapchain->prev_time = time; swapchain->frames = 0; } } /* This is disabled, but the code left in for debug purposes. * * Since we're allowed to modify the new back buffer on a D3DSWAPEFFECT_DISCARD flip, * we can clear it with some ugly color to make bad drawing visible and ease debugging. * The Debug runtime does the same on Windows. However, a few games do not redraw the * screen properly, like Max Payne 2, which leaves a few pixels undefined. * * Tests show that the content of the back buffer after a discard flip is indeed not * reliable, so no game can depend on the exact content. However, it resembles the * old contents in some way, for example by showing fragments at other locations. In * general, the color theme is still intact. So Max payne, which draws rather dark scenes * gets a dark background image. If we clear it with a bright ugly color, the game's * bug shows up much more than it does on Windows, and the players see single pixels * with wrong colors. * (The Max Payne bug has been confirmed on Windows with the debug runtime) */ if (FALSE && swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_DISCARD) { static const struct wined3d_color cyan = {0.0f, 1.0f, 1.0f, 1.0f}; TRACE("Clearing the color buffer with cyan color\n"); wined3d_device_clear(swapchain->device, 0, NULL, WINED3DCLEAR_TARGET, &cyan, 1.0f, 0); } if (!swapchain->render_to_fbo && ((swapchain->front_buffer->flags & SFLAG_INSYSMEM) || (back_buffer->flags & SFLAG_INSYSMEM))) { /* Both memory copies of the surfaces are ok, flip them around too instead of dirtifying * Doesn't work with render_to_fbo because we're not flipping */ struct wined3d_surface *front = swapchain->front_buffer; if (front->resource.size == back_buffer->resource.size) { DWORD fbflags; flip_surface(front, back_buffer); /* Tell the front buffer surface that is has been modified. However, * the other locations were preserved during that, so keep the flags. * This serves to update the emulated overlay, if any. */ fbflags = front->flags; surface_modify_location(front, SFLAG_INDRAWABLE, TRUE); front->flags = fbflags; } else { surface_modify_location(front, SFLAG_INDRAWABLE, TRUE); surface_modify_location(back_buffer, SFLAG_INDRAWABLE, TRUE); } } else { surface_modify_location(swapchain->front_buffer, SFLAG_INDRAWABLE, TRUE); /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM * and INTEXTURE copies can keep their old content if they have any defined content. * If the swapeffect is COPY, the content remains the same. If it is FLIP however, * the texture / sysmem copy needs to be reloaded from the drawable */ if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP) surface_modify_location(back_buffer, back_buffer->draw_binding, TRUE); } if (fb->depth_stencil) { if (swapchain->desc.flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL || fb->depth_stencil->flags & SFLAG_DISCARD) { surface_modify_ds_location(fb->depth_stencil, SFLAG_DISCARDED, fb->depth_stencil->resource.width, fb->depth_stencil->resource.height); if (fb->depth_stencil == swapchain->device->onscreen_depth_stencil) { wined3d_surface_decref(swapchain->device->onscreen_depth_stencil); swapchain->device->onscreen_depth_stencil = NULL; } } } context_release(context); TRACE("returning\n"); return WINED3D_OK; }
HRESULT InternetTransport_Connect(InternetTransport *This, LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging) { struct addrinfo *ai; struct addrinfo *ai_cur; struct addrinfo hints; int ret; char szPort[10]; if (This->Status != IXP_DISCONNECTED) return IXP_E_ALREADY_CONNECTED; This->ServerInfo = *pInetServer; This->fCommandLogging = fCommandLogging; This->hwnd = CreateWindowW(wszClassName, wszClassName, 0, 0, 0, 0, 0, NULL, NULL, NULL, 0); if (!This->hwnd) return HRESULT_FROM_WIN32(GetLastError()); SetWindowLongPtrW(This->hwnd, GWLP_USERDATA, (LONG_PTR)This); hints.ai_flags = 0; hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_addrlen = 0; hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; snprintf(szPort, sizeof(szPort), "%d", (unsigned short)pInetServer->dwPort); InternetTransport_ChangeStatus(This, IXP_FINDINGHOST); ret = getaddrinfo(pInetServer->szServerName, szPort, &hints, &ai); if (ret) { ERR("getaddrinfo failed: %d\n", ret); return IXP_E_CANT_FIND_HOST; } for (ai_cur = ai; ai_cur; ai_cur = ai->ai_next) { int so; if (TRACE_ON(inetcomm)) { char host[256]; char service[256]; getnameinfo(ai_cur->ai_addr, ai_cur->ai_addrlen, host, sizeof(host), service, sizeof(service), NI_NUMERICHOST | NI_NUMERICSERV); TRACE("trying %s:%s\n", host, service); } InternetTransport_ChangeStatus(This, IXP_CONNECTING); so = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol); if (so == -1) { WARN("socket() failed\n"); continue; } This->Socket = so; /* FIXME: set to async */ if (0 > connect(This->Socket, ai_cur->ai_addr, ai_cur->ai_addrlen)) { WARN("connect() failed\n"); closesocket(This->Socket); continue; } InternetTransport_ChangeStatus(This, IXP_CONNECTED); /* FIXME: call WSAAsyncSelect */ freeaddrinfo(ai); TRACE("connected\n"); return S_OK; } freeaddrinfo(ai); return IXP_E_CANT_FIND_HOST; }
/************************************************************************** * widOpen [internal] */ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) { WINE_WAVEDEV* wwi; snd_pcm_hw_params_t * hw_params; snd_pcm_sw_params_t * sw_params; snd_pcm_access_t access; snd_pcm_format_t format; unsigned int rate; unsigned int buffer_time = 500000; unsigned int period_time = 10000; snd_pcm_uframes_t buffer_size; snd_pcm_uframes_t period_size; int flags; snd_pcm_t * pcm; int err; int dir; DWORD ret; /* JPW TODO - review this code */ TRACE("(%u, %p, %08X);\n", wDevID, lpDesc, dwFlags); if (lpDesc == NULL) { WARN("Invalid Parameter !\n"); return MMSYSERR_INVALPARAM; } if (wDevID >= ALSA_WidNumDevs) { TRACE("Requested device %d, but only %d are known!\n", wDevID, ALSA_WidNumDevs); return MMSYSERR_BADDEVICEID; } /* only PCM format is supported so far... */ if (!ALSA_supportedFormat(lpDesc->lpFormat)) { WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%d !\n", lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels, lpDesc->lpFormat->nSamplesPerSec); return WAVERR_BADFORMAT; } if (dwFlags & WAVE_FORMAT_QUERY) { TRACE("Query format: tag=%04X nChannels=%d nSamplesPerSec=%d !\n", lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels, lpDesc->lpFormat->nSamplesPerSec); return MMSYSERR_NOERROR; } wwi = &WInDev[wDevID]; if (wwi->pcm != NULL) { WARN("already allocated\n"); return MMSYSERR_ALLOCATED; } wwi->pcm = 0; flags = SND_PCM_NONBLOCK; if ( (err=snd_pcm_open(&pcm, wwi->pcmname, SND_PCM_STREAM_CAPTURE, flags)) < 0 ) { ERR("Error open: %s\n", snd_strerror(err)); return MMSYSERR_NOTENABLED; } wwi->wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK); wwi->waveDesc = *lpDesc; ALSA_copyFormat(lpDesc->lpFormat, &wwi->format); if (wwi->format.Format.wBitsPerSample == 0) { WARN("Resetting zeroed wBitsPerSample\n"); wwi->format.Format.wBitsPerSample = 8 * (wwi->format.Format.nAvgBytesPerSec / wwi->format.Format.nSamplesPerSec) / wwi->format.Format.nChannels; } hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() ); sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() ); snd_pcm_hw_params_any(pcm, hw_params); #define EXIT_ON_ERROR(f,e,txt) do \ { \ int err; \ if ( (err = (f) ) < 0) \ { \ WARN(txt ": %s\n", snd_strerror(err)); \ ret = (e); \ goto error; \ } \ } while(0) access = SND_PCM_ACCESS_MMAP_INTERLEAVED; if ( ( err = snd_pcm_hw_params_set_access(pcm, hw_params, access ) ) < 0) { WARN("mmap not available. switching to standard write.\n"); access = SND_PCM_ACCESS_RW_INTERLEAVED; EXIT_ON_ERROR( snd_pcm_hw_params_set_access(pcm, hw_params, access ), MMSYSERR_INVALPARAM, "unable to set access for playback"); wwi->read = snd_pcm_readi; } else wwi->read = snd_pcm_mmap_readi; EXIT_ON_ERROR( snd_pcm_hw_params_set_channels(pcm, hw_params, wwi->format.Format.nChannels), WAVERR_BADFORMAT, "unable to set required channels"); if ((wwi->format.Format.wFormatTag == WAVE_FORMAT_PCM) || ((wwi->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) && IsEqualGUID(&wwi->format.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) { format = (wwi->format.Format.wBitsPerSample == 8) ? SND_PCM_FORMAT_U8 : (wwi->format.Format.wBitsPerSample == 16) ? SND_PCM_FORMAT_S16_LE : (wwi->format.Format.wBitsPerSample == 24) ? SND_PCM_FORMAT_S24_3LE : (wwi->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_S32_LE : -1; } else if ((wwi->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) && IsEqualGUID(&wwi->format.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)){ format = (wwi->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_FLOAT_LE : -1; } else if (wwi->format.Format.wFormatTag == WAVE_FORMAT_MULAW) { FIXME("unimplemented format: WAVE_FORMAT_MULAW\n"); ret = WAVERR_BADFORMAT; goto error; } else if (wwi->format.Format.wFormatTag == WAVE_FORMAT_ALAW) { FIXME("unimplemented format: WAVE_FORMAT_ALAW\n"); ret = WAVERR_BADFORMAT; goto error; } else if (wwi->format.Format.wFormatTag == WAVE_FORMAT_ADPCM) { FIXME("unimplemented format: WAVE_FORMAT_ADPCM\n"); ret = WAVERR_BADFORMAT; goto error; } else { ERR("invalid format: %0x04x\n", wwi->format.Format.wFormatTag); ret = WAVERR_BADFORMAT; goto error; } EXIT_ON_ERROR( snd_pcm_hw_params_set_format(pcm, hw_params, format), WAVERR_BADFORMAT, "unable to set required format"); rate = wwi->format.Format.nSamplesPerSec; dir = 0; err = snd_pcm_hw_params_set_rate_near(pcm, hw_params, &rate, &dir); if (err < 0) { WARN("Rate %d Hz not available for playback: %s\n", wwi->format.Format.nSamplesPerSec, snd_strerror(rate)); ret = WAVERR_BADFORMAT; goto error; } if (!ALSA_NearMatch(rate, wwi->format.Format.nSamplesPerSec)) { WARN("Rate doesn't match (requested %d Hz, got %d Hz)\n", wwi->format.Format.nSamplesPerSec, rate); ret = WAVERR_BADFORMAT; goto error; } dir=0; EXIT_ON_ERROR( snd_pcm_hw_params_set_buffer_time_near(pcm, hw_params, &buffer_time, &dir), MMSYSERR_INVALPARAM, "unable to set buffer time"); dir=0; EXIT_ON_ERROR( snd_pcm_hw_params_set_period_time_near(pcm, hw_params, &period_time, &dir), MMSYSERR_INVALPARAM, "unable to set period time"); EXIT_ON_ERROR( snd_pcm_hw_params(pcm, hw_params), MMSYSERR_INVALPARAM, "unable to set hw params for playback"); dir=0; err = snd_pcm_hw_params_get_period_size(hw_params, &period_size, &dir); err = snd_pcm_hw_params_get_buffer_size(hw_params, &buffer_size); snd_pcm_sw_params_current(pcm, sw_params); EXIT_ON_ERROR( snd_pcm_sw_params_set_start_threshold(pcm, sw_params, 1), MMSYSERR_ERROR, "unable to set start threshold"); EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_size(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence size"); EXIT_ON_ERROR( snd_pcm_sw_params_set_avail_min(pcm, sw_params, period_size), MMSYSERR_ERROR, "unable to set avail min"); EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_threshold(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence threshold"); EXIT_ON_ERROR( snd_pcm_sw_params(pcm, sw_params), MMSYSERR_ERROR, "unable to set sw params for playback"); #undef EXIT_ON_ERROR snd_pcm_prepare(pcm); if (TRACE_ON(wave)) ALSA_TraceParameters(hw_params, sw_params, FALSE); /* now, we can save all required data for later use... */ if ( wwi->hw_params ) snd_pcm_hw_params_free(wwi->hw_params); snd_pcm_hw_params_malloc(&(wwi->hw_params)); snd_pcm_hw_params_copy(wwi->hw_params, hw_params); wwi->dwBufferSize = snd_pcm_frames_to_bytes(pcm, buffer_size); wwi->lpQueuePtr = wwi->lpPlayPtr = wwi->lpLoopPtr = NULL; wwi->pcm = pcm; ALSA_InitRingMessage(&wwi->msgRing); wwi->dwPeriodSize = snd_pcm_frames_to_bytes(pcm, period_size); TRACE("dwPeriodSize=%u\n", wwi->dwPeriodSize); TRACE("wBitsPerSample=%u, nAvgBytesPerSec=%u, nSamplesPerSec=%u, nChannels=%u nBlockAlign=%u!\n", wwi->format.Format.wBitsPerSample, wwi->format.Format.nAvgBytesPerSec, wwi->format.Format.nSamplesPerSec, wwi->format.Format.nChannels, wwi->format.Format.nBlockAlign); wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD_PTR)wDevID, 0, &(wwi->dwThreadID)); if (wwi->hThread) SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL); WaitForSingleObject(wwi->hStartUpEvent, INFINITE); CloseHandle(wwi->hStartUpEvent); wwi->hStartUpEvent = INVALID_HANDLE_VALUE; HeapFree( GetProcessHeap(), 0, hw_params ); HeapFree( GetProcessHeap(), 0, sw_params ); return widNotifyClient(wwi, WIM_OPEN, 0L, 0L); error: snd_pcm_close(pcm); HeapFree( GetProcessHeap(), 0, hw_params ); HeapFree( GetProcessHeap(), 0, sw_params ); return ret; }
void* CDECL MSVCRT___RTDynamicCast(void *cppobj, int unknown, type_info *src, type_info *dst, int do_throw) { void *ret; if (!cppobj) return NULL; TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n", cppobj, unknown, src, dbgstr_type_info(src), dst, dbgstr_type_info(dst), do_throw); /* To cast an object at runtime: * 1.Find out the true type of the object from the typeinfo at vtable[-1] * 2.Search for the destination type in the class hierarchy * 3.If destination type is found, return base object address + dest offset * Otherwise, fail the cast * * FIXME: the unknown parameter doesn't seem to be used for anything */ __TRY { int i; const rtti_object_locator *obj_locator = get_obj_locator( cppobj ); const rtti_object_hierarchy *obj_bases = obj_locator->type_hierarchy; const rtti_base_descriptor * const* base_desc = obj_bases->base_classes->bases; if (TRACE_ON(msvcrt)) dump_obj_locator(obj_locator); ret = NULL; for (i = 0; i < obj_bases->array_len; i++) { const type_info *typ = base_desc[i]->type_descriptor; if (!strcmp(typ->mangled, dst->mangled)) { /* compute the correct this pointer for that base class */ void *this_ptr = (char *)cppobj - obj_locator->base_class_offset; ret = get_this_pointer( &base_desc[i]->offsets, this_ptr ); break; } } /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned * to a reference, since references cannot be NULL. */ if (!ret && do_throw) { const char *msg = "Bad dynamic_cast!"; bad_cast e; MSVCRT_bad_cast_ctor( &e, &msg ); _CxxThrowException( &e, &bad_cast_exception_type ); } } __EXCEPT_PAGE_FAULT { __non_rtti_object e; MSVCRT___non_rtti_object_ctor( &e, "Access violation - no RTTI data!" ); _CxxThrowException( &e, &bad_typeid_exception_type ); return NULL; } __ENDTRY return ret; }
/* We haven't found out the nrofargs yet. If we called a cdecl * function it is too late anyway and we can just set '0' (which * will be the difference between orig and current SP * If pascal -> everything ok. */ if (ret->dll->funs[ret->ordinal].nrofargs<0) { ret->dll->funs[ret->ordinal].nrofargs=(LOWORD(context->Esp)-ret->origSP-4)/2; } context->Eip = LOWORD(ret->origreturn); context->SegCs = HIWORD(ret->origreturn); DPRINTF("%04x:RET %s.%d: %s(", GetCurrentThreadId(),ret->dll->name,ret->ordinal, ret->dll->funs[ret->ordinal].name); if (ret->args) { int i,max; max = ret->dll->funs[ret->ordinal].nrofargs; if (max>16) max=16; if (max<0) max=0; for (i=max;i--;) DPRINTF("%04x%s",ret->args[i],i?",":""); if (max!=ret->dll->funs[ret->ordinal].nrofargs) DPRINTF(" ..."); HeapFree(GetProcessHeap(),0,ret->args); ret->args = NULL; } DPRINTF(") retval = %04x:%04x ret=%04x:%04x\n", (WORD)context->Edx,(WORD)context->Eax, HIWORD(ret->origreturn),LOWORD(ret->origreturn)); ret->origreturn = NULL; /* mark as empty */ } #else /* !__i386__ */ void SNOOP16_RegisterDLL(HMODULE16 hModule,LPCSTR name) { if (!TRACE_ON(snoop)) return; FIXME("snooping works only on i386 for now.\n"); }
HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d_device *device, struct d3d_viewport *viewport) { DWORD vs = buffer->data.dwVertexOffset; DWORD is = buffer->data.dwInstructionOffset; char *instr = (char *)buffer->desc.lpData + is; unsigned int i; if (viewport->active_device != device) { WARN("Viewport %p active device is %p.\n", viewport, viewport->active_device); return DDERR_INVALIDPARAMS; } /* Activate the viewport */ viewport_activate(viewport, FALSE); TRACE("ExecuteData :\n"); if (TRACE_ON(ddraw)) _dump_executedata(&(buffer->data)); for (;;) { D3DINSTRUCTION *current = (D3DINSTRUCTION *)instr; BYTE size; WORD count; count = current->wCount; size = current->bSize; instr += sizeof(D3DINSTRUCTION); switch (current->bOpcode) { case D3DOP_POINT: { WARN("POINT-s (%d)\n", count); instr += count * size; } break; case D3DOP_LINE: { WARN("LINE-s (%d)\n", count); instr += count * size; } break; case D3DOP_TRIANGLE: { D3DTLVERTEX *tl_vx = buffer->vertex_data; TRACE("TRIANGLE (%d)\n", count); if (buffer->nb_indices < count * 3) { buffer->nb_indices = count * 3; HeapFree(GetProcessHeap(), 0, buffer->indices); buffer->indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer->indices) * buffer->nb_indices); } for (i = 0; i < count; ++i) { D3DTRIANGLE *ci = (D3DTRIANGLE *)instr; TRACE(" v1: %d v2: %d v3: %d\n",ci->u1.v1, ci->u2.v2, ci->u3.v3); TRACE(" Flags : "); if (TRACE_ON(ddraw)) { /* Wireframe */ if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) TRACE("EDGEENABLE1 "); if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2) TRACE("EDGEENABLE2 "); if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) TRACE("EDGEENABLE3 "); /* Strips / Fans */ if (ci->wFlags == D3DTRIFLAG_EVEN) TRACE("EVEN "); if (ci->wFlags == D3DTRIFLAG_ODD) TRACE("ODD "); if (ci->wFlags == D3DTRIFLAG_START) TRACE("START "); if ((ci->wFlags > 0) && (ci->wFlags < 30)) TRACE("STARTFLAT(%u) ", ci->wFlags); TRACE("\n"); } buffer->indices[(i * 3) ] = ci->u1.v1; buffer->indices[(i * 3) + 1] = ci->u2.v2; buffer->indices[(i * 3) + 2] = ci->u3.v3; instr += size; } if (count) IDirect3DDevice7_DrawIndexedPrimitive(&device->IDirect3DDevice7_iface, D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, tl_vx, buffer->nb_vertices, buffer->indices, count * 3, 0); } break; case D3DOP_MATRIXLOAD: WARN("MATRIXLOAD-s (%d)\n", count); instr += count * size; break; case D3DOP_MATRIXMULTIPLY: TRACE("MATRIXMULTIPLY (%d)\n", count); for (i = 0; i < count; ++i) { D3DMATRIXMULTIPLY *ci = (D3DMATRIXMULTIPLY *)instr; D3DMATRIX *a, *b, *c; a = ddraw_get_object(&device->handle_table, ci->hDestMatrix - 1, DDRAW_HANDLE_MATRIX); b = ddraw_get_object(&device->handle_table, ci->hSrcMatrix1 - 1, DDRAW_HANDLE_MATRIX); c = ddraw_get_object(&device->handle_table, ci->hSrcMatrix2 - 1, DDRAW_HANDLE_MATRIX); if (!a || !b || !c) { ERR("Invalid matrix handle (a %#x -> %p, b %#x -> %p, c %#x -> %p).\n", ci->hDestMatrix, a, ci->hSrcMatrix1, b, ci->hSrcMatrix2, c); } else { TRACE("dst %p, src1 %p, src2 %p.\n", a, b, c); multiply_matrix(a, c, b); } instr += size; } break; case D3DOP_STATETRANSFORM: TRACE("STATETRANSFORM (%d)\n", count); for (i = 0; i < count; ++i) { D3DSTATE *ci = (D3DSTATE *)instr; D3DMATRIX *m; m = ddraw_get_object(&device->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATRIX); if (!m) { ERR("Invalid matrix handle %#x.\n", ci->u2.dwArg[0]); } else { if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_WORLD) device->world = ci->u2.dwArg[0]; if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_VIEW) device->view = ci->u2.dwArg[0]; if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_PROJECTION) device->proj = ci->u2.dwArg[0]; IDirect3DDevice7_SetTransform(&device->IDirect3DDevice7_iface, ci->u1.dtstTransformStateType, m); } instr += size; } break; case D3DOP_STATELIGHT: TRACE("STATELIGHT (%d)\n", count); for (i = 0; i < count; ++i) { D3DSTATE *ci = (D3DSTATE *)instr; if (FAILED(IDirect3DDevice3_SetLightState(&device->IDirect3DDevice3_iface, ci->u1.dlstLightStateType, ci->u2.dwArg[0]))) WARN("Failed to set light state.\n"); instr += size; } break; case D3DOP_STATERENDER: TRACE("STATERENDER (%d)\n", count); for (i = 0; i < count; ++i) { D3DSTATE *ci = (D3DSTATE *)instr; if (FAILED(IDirect3DDevice3_SetRenderState(&device->IDirect3DDevice3_iface, ci->u1.drstRenderStateType, ci->u2.dwArg[0]))) WARN("Failed to set render state.\n"); instr += size; } break; case D3DOP_PROCESSVERTICES: { /* TODO: Share code with d3d_vertex_buffer7_ProcessVertices() * and / or wined3d_device_process_vertices(). */ D3DMATRIX view_mat, world_mat, proj_mat, mat; TRACE("PROCESSVERTICES (%d)\n", count); /* Get the transform and world matrix */ /* Note: D3DMATRIX is compatible with struct wined3d_matrix. */ wined3d_device_get_transform(device->wined3d_device, D3DTRANSFORMSTATE_VIEW, (struct wined3d_matrix *)&view_mat); wined3d_device_get_transform(device->wined3d_device, D3DTRANSFORMSTATE_PROJECTION, (struct wined3d_matrix *)&proj_mat); wined3d_device_get_transform(device->wined3d_device, WINED3D_TS_WORLD_MATRIX(0), (struct wined3d_matrix *)&world_mat); if (TRACE_ON(ddraw)) { TRACE(" Projection Matrix:\n"); dump_D3DMATRIX(&proj_mat); TRACE(" View Matrix:\n"); dump_D3DMATRIX(&view_mat); TRACE(" World Matrix:\n"); dump_D3DMATRIX(&world_mat); } multiply_matrix(&mat, &view_mat, &world_mat); multiply_matrix(&mat, &proj_mat, &mat); for (i = 0; i < count; ++i) { D3DPROCESSVERTICES *ci = (D3DPROCESSVERTICES *)instr; D3DTLVERTEX *dst = (D3DTLVERTEX *)buffer->vertex_data + ci->wDest; DWORD op = ci->dwFlags & D3DPROCESSVERTICES_OPMASK; TRACE(" start %u, dest %u, count %u, flags %#x.\n", ci->wStart, ci->wDest, ci->dwCount, ci->dwFlags); if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS) FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n"); if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR) FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n"); switch (op) { case D3DPROCESSVERTICES_TRANSFORMLIGHT: { const D3DVERTEX *src = (D3DVERTEX *)((char *)buffer->desc.lpData + vs) + ci->wStart; unsigned int vtx_idx; static unsigned int once; if (!once++) FIXME("Lighting not implemented.\n"); for (vtx_idx = 0; vtx_idx < ci->dwCount; ++vtx_idx) { transform_vertex(&dst[vtx_idx], &mat, &viewport->viewports.vp1, src[vtx_idx].u1.x, src[vtx_idx].u2.y, src[vtx_idx].u3.z); /* No lighting yet */ dst[vtx_idx].u5.color = 0xffffffff; /* Opaque white */ dst[vtx_idx].u6.specular = 0xff000000; /* No specular and no fog factor */ dst[vtx_idx].u7.tu = src[vtx_idx].u7.tu; dst[vtx_idx].u8.tv = src[vtx_idx].u8.tv; } break; } case D3DPROCESSVERTICES_TRANSFORM: { const D3DLVERTEX *src = (D3DLVERTEX *)((char *)buffer->desc.lpData + vs) + ci->wStart; unsigned int vtx_idx; for (vtx_idx = 0; vtx_idx < ci->dwCount; ++vtx_idx) { transform_vertex(&dst[vtx_idx], &mat, &viewport->viewports.vp1, src[vtx_idx].u1.x, src[vtx_idx].u2.y, src[vtx_idx].u3.z); dst[vtx_idx].u5.color = src[vtx_idx].u4.color; dst[vtx_idx].u6.specular = src[vtx_idx].u5.specular; dst[vtx_idx].u7.tu = src[vtx_idx].u6.tu; dst[vtx_idx].u8.tv = src[vtx_idx].u7.tv; } break; } case D3DPROCESSVERTICES_COPY: { const D3DTLVERTEX *src = (D3DTLVERTEX *)((char *)buffer->desc.lpData + vs) + ci->wStart; memcpy(dst, src, ci->dwCount * sizeof(*dst)); break; } default: FIXME("Unhandled vertex processing op %#x.\n", op); break; } instr += size; } break; } case D3DOP_TEXTURELOAD: { WARN("TEXTURELOAD-s (%d)\n", count); instr += count * size; } break; case D3DOP_EXIT: { TRACE("EXIT (%d)\n", count); /* We did this instruction */ instr += size; /* Exit this loop */ goto end_of_buffer; } break; case D3DOP_BRANCHFORWARD: TRACE("BRANCHFORWARD (%d)\n", count); for (i = 0; i < count; ++i) { D3DBRANCH *ci = (D3DBRANCH *)instr; if ((buffer->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) { if (!ci->bNegate) { TRACE(" Branch to %d\n", ci->dwOffset); if (ci->dwOffset) { instr = (char*)current + ci->dwOffset; break; } } } else { if (ci->bNegate) { TRACE(" Branch to %d\n", ci->dwOffset); if (ci->dwOffset) { instr = (char*)current + ci->dwOffset; break; } } } instr += size; } break; case D3DOP_SPAN: { WARN("SPAN-s (%d)\n", count); instr += count * size; } break; case D3DOP_SETSTATUS: TRACE("SETSTATUS (%d)\n", count); for (i = 0; i < count; ++i) { buffer->data.dsStatus = *(D3DSTATUS *)instr; instr += size; } break; default: ERR("Unhandled OpCode %d !!!\n",current->bOpcode); /* Try to save ... */ instr += count * size; break; } } end_of_buffer: return D3D_OK; }
/*********************************************************************** * UpDownWndProc */ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); static const WCHAR themeClass[] = {'S','p','i','n',0}; HTHEME theme; TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam); if (!infoPtr && (message != WM_CREATE)) return DefWindowProcW (hwnd, message, wParam, lParam); switch(message) { case WM_CREATE: { CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam; infoPtr = Alloc (sizeof(UPDOWN_INFO)); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* initialize the info struct */ infoPtr->Self = hwnd; infoPtr->Notify = pcs->hwndParent; infoPtr->dwStyle = pcs->style; infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; infoPtr->AccelIndex = -1; infoPtr->CurVal = 0; infoPtr->MinVal = 100; infoPtr->MaxVal = 0; infoPtr->Base = 10; /* Default to base 10 */ infoPtr->Buddy = 0; /* No buddy window yet */ infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0; SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER); if (!(infoPtr->dwStyle & UDS_HORZ)) SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy, SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE); /* Do we pick the buddy win ourselves? */ if (infoPtr->dwStyle & UDS_AUTOBUDDY) UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV)); OpenThemeData (hwnd, themeClass); TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd); } break; case WM_DESTROY: Free (infoPtr->AccelVect); if (infoPtr->Buddy) RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID); Free (infoPtr); SetWindowLongPtrW (hwnd, 0, 0); theme = GetWindowTheme (hwnd); CloseThemeData (theme); TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd); break; case WM_ENABLE: if (wParam) { infoPtr->dwStyle &= ~WS_DISABLED; } else { infoPtr->dwStyle |= WS_DISABLED; UPDOWN_CancelMode (infoPtr); } InvalidateRect (infoPtr->Self, NULL, FALSE); break; case WM_STYLECHANGED: if (wParam == GWL_STYLE) { infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew; InvalidateRect (infoPtr->Self, NULL, FALSE); } break; case WM_THEMECHANGED: theme = GetWindowTheme (hwnd); CloseThemeData (theme); OpenThemeData (hwnd, themeClass); InvalidateRect (hwnd, NULL, FALSE); break; case WM_TIMER: /* is this the auto-press timer? */ if(wParam == TIMER_AUTOPRESS) { KillTimer(hwnd, TIMER_AUTOPRESS); infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW); InvalidateRect(infoPtr->Self, NULL, FALSE); } /* if initial timer, kill it and start the repeat timer */ if(wParam == TIMER_AUTOREPEAT) { INT delay; KillTimer(hwnd, TIMER_AUTOREPEAT); /* if no accel info given, used default timer */ if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) { infoPtr->AccelIndex = -1; delay = REPEAT_DELAY; } else { infoPtr->AccelIndex = 0; /* otherwise, use it */ delay = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1; } SetTimer(hwnd, TIMER_ACCEL, delay, 0); } /* now, if the mouse is above us, do the thing...*/ if(infoPtr->Flags & FLAG_MOUSEIN) { int temp; temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc; UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW); if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) { KillTimer(hwnd, TIMER_ACCEL); infoPtr->AccelIndex++; /* move to the next accel info */ temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1; /* make sure we have at least 1ms intervals */ SetTimer(hwnd, TIMER_ACCEL, temp, 0); } } break; case WM_CANCELMODE: return UPDOWN_CancelMode (infoPtr); case WM_LBUTTONUP: if (GetCapture() != infoPtr->Self) break; if ( (infoPtr->Flags & FLAG_MOUSEIN) && (infoPtr->Flags & FLAG_ARROW) ) { SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL, MAKELONG(SB_ENDSCROLL, infoPtr->CurVal), (LPARAM)hwnd); if (UPDOWN_IsBuddyEdit(infoPtr)) SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1)); } UPDOWN_CancelMode(infoPtr); break; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: case WM_MOUSELEAVE: if(UPDOWN_IsEnabled(infoPtr)) UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); break; case WM_MOUSEWHEEL: UPDOWN_MouseWheel(infoPtr, wParam); break; case WM_KEYDOWN: if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr)) return UPDOWN_KeyPressed(infoPtr, (int)wParam); break; case WM_PRINTCLIENT: case WM_PAINT: return UPDOWN_Paint (infoPtr, (HDC)wParam); case UDM_GETACCEL: if (wParam==0 && lParam==0) return infoPtr->AccelCount; if (wParam && lParam) { int temp = min(infoPtr->AccelCount, wParam); memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL)); return temp; } return 0; case UDM_SETACCEL: { TRACE("UDM_SETACCEL\n"); if(infoPtr->AccelVect) { Free (infoPtr->AccelVect); infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; } if(wParam==0) return TRUE; infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL)); if(infoPtr->AccelVect == 0) return FALSE; memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL)); infoPtr->AccelCount = wParam; if (TRACE_ON(updown)) { UINT i; for (i = 0; i < wParam; i++) TRACE("%u: nSec %u nInc %u\n", i, infoPtr->AccelVect[i].nSec, infoPtr->AccelVect[i].nInc); } return TRUE; } case UDM_GETBASE: return infoPtr->Base; case UDM_SETBASE: TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd); if (wParam==10 || wParam==16) { WPARAM old_base = infoPtr->Base; infoPtr->Base = wParam; if (old_base != infoPtr->Base) UPDOWN_SetBuddyInt(infoPtr); return old_base; } break; case UDM_GETBUDDY: return (LRESULT)infoPtr->Buddy; case UDM_SETBUDDY: return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam); case UDM_GETPOS: { BOOL err; int pos; pos = UPDOWN_GetPos(infoPtr, &err); return MAKELONG(pos, err); } case UDM_SETPOS: { return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam)); } case UDM_GETRANGE: return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal); case UDM_SETRANGE: /* we must have: UD_MINVAL <= Max <= UD_MAXVAL UD_MINVAL <= Min <= UD_MAXVAL |Max-Min| <= UD_MAXVAL */ UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam)); break; case UDM_GETRANGE32: if (wParam) *(LPINT)wParam = infoPtr->MinVal; if (lParam) *(LPINT)lParam = infoPtr->MaxVal; break; case UDM_SETRANGE32: UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam); break; case UDM_GETPOS32: { return UPDOWN_GetPos(infoPtr, (BOOL*)lParam); } case UDM_SETPOS32: { return UPDOWN_SetPos(infoPtr, (int)lParam); } case UDM_GETUNICODEFORMAT: /* we lie a bit here, we're always using Unicode internally */ return infoPtr->UnicodeFormat; case UDM_SETUNICODEFORMAT: { /* do we really need to honour this flag? */ int temp = infoPtr->UnicodeFormat; infoPtr->UnicodeFormat = (BOOL)wParam; return temp; } default: if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message)) ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam); return DefWindowProcW (hwnd, message, wParam, lParam); } return 0; }
void SNOOP16_RegisterDLL(HMODULE16 hModule,LPCSTR name) { SNOOP16_DLL **dll = &(firstdll); char *s; if (!TRACE_ON(snoop)) return; TRACE("hmod=%x, name=%s\n", hModule, name); if (!snr) { xsnr=GLOBAL_Alloc(GMEM_ZEROINIT,2*sizeof(*snr),0,WINE_LDT_FLAGS_CODE|WINE_LDT_FLAGS_32BIT); snr = GlobalLock16(xsnr); snr[0].pushbp = 0x5566; snr[0].pusheax = 0x50; snr[0].pushax = 0x5066; snr[0].pushl = 0x68; snr[0].realfun = (DWORD)SNOOP16_Entry; snr[0].lcall = 0x9a; snr[0].callfromregs = (DWORD)__wine_call_from_16_regs; snr[0].seg = wine_get_cs(); snr[0].lret = 0xcb66; snr[1].pushbp = 0x5566; snr[1].pusheax = 0x50; snr[1].pushax = 0x5066; snr[1].pushl = 0x68; snr[1].realfun = (DWORD)SNOOP16_Return; snr[1].lcall = 0x9a; snr[1].callfromregs = (DWORD)__wine_call_from_16_regs; snr[1].seg = wine_get_cs(); snr[1].lret = 0xcb66; } while (*dll) { if ((*dll)->hmod == hModule) { /* another dll, loaded at the same address */ GlobalUnlock16((*dll)->funhandle); GlobalFree16((*dll)->funhandle); break; } dll = &((*dll)->next); } if (*dll) *dll = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *dll, sizeof(SNOOP16_DLL)+strlen(name)); else *dll = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SNOOP16_DLL)+strlen(name)); (*dll)->next = NULL; (*dll)->hmod = hModule; if ((s=strrchr(name,'\\'))) name = s+1; strcpy( (*dll)->name, name ); if ((s=strrchr((*dll)->name,'.'))) *s='\0'; (*dll)->funhandle = GlobalHandleToSel16(GLOBAL_Alloc(GMEM_ZEROINIT,65535,0,WINE_LDT_FLAGS_CODE)); (*dll)->funs = GlobalLock16((*dll)->funhandle); if (!(*dll)->funs) { HeapFree(GetProcessHeap(),0,*dll); FIXME("out of memory\n"); return; } }
/****************************************************************************** * SetProperty : change input device properties */ HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph) { JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface); DWORD i; TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph); if (ph == NULL) { WARN("invalid parameter: ph == NULL\n"); return DIERR_INVALIDPARAM; } if (TRACE_ON(dinput)) _dump_DIPROPHEADER(ph); if (IS_DIPROP(rguid)) { switch (LOWORD(rguid)) { case (DWORD_PTR)DIPROP_RANGE: { LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph; if (ph->dwHow == DIPH_DEVICE) { TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax); for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) { This->props[i].lMin = pr->lMin; This->props[i].lMax = pr->lMax; } } else { int obj = find_property(&This->base.data_format, ph); TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj); if (obj >= 0) { This->props[obj].lMin = pr->lMin; This->props[obj].lMax = pr->lMax; return DI_OK; } } break; } case (DWORD_PTR)DIPROP_DEADZONE: { LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; if (ph->dwHow == DIPH_DEVICE) { TRACE("deadzone(%d) all\n", pd->dwData); for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) This->props[i].lDeadZone = pd->dwData; } else { int obj = find_property(&This->base.data_format, ph); TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj); if (obj >= 0) { This->props[obj].lDeadZone = pd->dwData; return DI_OK; } } break; } case (DWORD_PTR)DIPROP_SATURATION: { LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; if (ph->dwHow == DIPH_DEVICE) { TRACE("saturation(%d) all\n", pd->dwData); for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) This->props[i].lSaturation = pd->dwData; } else { int obj = find_property(&This->base.data_format, ph); TRACE("saturation(%d) obj=%d\n", pd->dwData, obj); if (obj >= 0) { This->props[obj].lSaturation = pd->dwData; return DI_OK; } } break; } default: return IDirectInputDevice2WImpl_SetProperty(iface, rguid, ph); } } return DI_OK; }
/********************************************************************** * K32WOWCallback16Ex (KERNEL32.55) */ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode ) { #ifdef __i386__ /* * Arguments must be prepared in the correct order by the caller * (both for PASCAL and CDECL calling convention), so we simply * copy them to the 16-bit stack ... */ char *stack = (char *)CURRENT_STACK16 - cbArgs; memcpy( stack, pArgs, cbArgs ); if (dwFlags & (WCB16_REGS|WCB16_REGS_LONG)) { CONTEXT *context = (CONTEXT *)pdwRetCode; if (TRACE_ON(relay)) { DWORD count = cbArgs / sizeof(WORD); WORD * wstack = (WORD *)stack; DPRINTF("%04lx:CallTo16(func=%04lx:%04x,ds=%04lx", GetCurrentThreadId(), context->SegCs, LOWORD(context->Eip), context->SegDs ); while (count) DPRINTF( ",%04x", wstack[--count] ); DPRINTF(") ss:sp=%04x:%04x", SELECTOROF(NtCurrentTeb()->WOW32Reserved), OFFSETOF(NtCurrentTeb()->WOW32Reserved) ); DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x bp=%04x es=%04x fs=%04x\n", (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx, (WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi, (WORD)context->Ebp, (WORD)context->SegEs, (WORD)context->SegFs ); SYSLEVEL_CheckNotLevel( 2 ); } if (context->EFlags & 0x00020000) /* v86 mode */ { EXCEPTION_REGISTRATION_RECORD frame; frame.Handler = vm86_handler; __wine_push_frame( &frame ); __wine_enter_vm86( context ); __wine_pop_frame( &frame ); } else { /* push return address */ if (dwFlags & WCB16_REGS_LONG) { stack -= sizeof(DWORD); *((DWORD *)stack) = HIWORD(call16_ret_addr); stack -= sizeof(DWORD); *((DWORD *)stack) = LOWORD(call16_ret_addr); cbArgs += 2 * sizeof(DWORD); } else { stack -= sizeof(SEGPTR); *((SEGPTR *)stack) = call16_ret_addr; cbArgs += sizeof(SEGPTR); } /* * Start call by checking for pending events. * Note that wine_call_to_16_regs overwrites context stack * pointer so we may modify it here without a problem. */ if (NtCurrentTeb()->dpmi_vif) { context->SegSs = wine_get_ds(); context->Esp = (DWORD)stack; insert_event_check( context ); cbArgs += (DWORD)stack - context->Esp; } _EnterWin16Lock(); wine_call_to_16_regs( context, cbArgs, call16_handler ); _LeaveWin16Lock(); } if (TRACE_ON(relay)) { DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x ", GetCurrentThreadId(), SELECTOROF(NtCurrentTeb()->WOW32Reserved), OFFSETOF(NtCurrentTeb()->WOW32Reserved)); DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x bp=%04x sp=%04x\n", (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx, (WORD)context->Edx, (WORD)context->Ebp, (WORD)context->Esp ); SYSLEVEL_CheckNotLevel( 2 ); } } else { DWORD ret; if (TRACE_ON(relay)) { DWORD count = cbArgs / sizeof(WORD); WORD * wstack = (WORD *)stack; DPRINTF("%04lx:CallTo16(func=%04x:%04x,ds=%04x", GetCurrentThreadId(), HIWORD(vpfn16), LOWORD(vpfn16), SELECTOROF(NtCurrentTeb()->WOW32Reserved) ); while (count) DPRINTF( ",%04x", wstack[--count] ); DPRINTF(") ss:sp=%04x:%04x\n", SELECTOROF(NtCurrentTeb()->WOW32Reserved), OFFSETOF(NtCurrentTeb()->WOW32Reserved) ); SYSLEVEL_CheckNotLevel( 2 ); } /* push return address */ stack -= sizeof(SEGPTR); *((SEGPTR *)stack) = call16_ret_addr; cbArgs += sizeof(SEGPTR); /* * Actually, we should take care whether the called routine cleans up * its stack or not. Fortunately, our wine_call_to_16 core doesn't rely on * the callee to do so; after the routine has returned, the 16-bit * stack pointer is always reset to the position it had before. */ _EnterWin16Lock(); ret = wine_call_to_16( (FARPROC16)vpfn16, cbArgs, call16_handler ); if (pdwRetCode) *pdwRetCode = ret; _LeaveWin16Lock(); if (TRACE_ON(relay)) { DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x retval=%08lx\n", GetCurrentThreadId(), SELECTOROF(NtCurrentTeb()->WOW32Reserved), OFFSETOF(NtCurrentTeb()->WOW32Reserved), ret); SYSLEVEL_CheckNotLevel( 2 ); } } #else assert(0); /* cannot call to 16-bit on non-Intel architectures */ #endif /* __i386__ */ return TRUE; /* success */ }
static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, JoystickImpl **pdev, unsigned short index) { DWORD i; JoystickImpl* newDevice; HRESULT hr; LPDIDATAFORMAT df = NULL; int idx = 0; TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index); newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl)); if (newDevice == 0) { WARN("out of memory\n"); *pdev = 0; return DIERR_OUTOFMEMORY; } newDevice->joydev = &joystick_devices[index]; newDevice->joyfd = -1; newDevice->generic.guidInstance = DInput_Wine_Joystick_GUID; newDevice->generic.guidInstance.Data3 = index; newDevice->generic.guidProduct = DInput_Wine_Joystick_GUID; newDevice->generic.joy_polldev = joy_polldev; newDevice->generic.name = newDevice->joydev->name; newDevice->generic.device_axis_count = newDevice->joydev->axis_count; newDevice->generic.devcaps.dwButtons = newDevice->joydev->button_count; if (newDevice->generic.devcaps.dwButtons > 128) { WARN("Can't support %d buttons. Clamping down to 128\n", newDevice->generic.devcaps.dwButtons); newDevice->generic.devcaps.dwButtons = 128; } newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt; newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt; newDevice->generic.base.ref = 1; newDevice->generic.base.dinput = dinput; newDevice->generic.base.guid = *rguid; InitializeCriticalSection(&newDevice->generic.base.crit); newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit"); /* setup_dinput_options may change these */ newDevice->generic.deadzone = 0; /* do any user specified configuration */ hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->dev_axes_map); if (hr != DI_OK) goto FAILED1; /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto FAILED; memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize); df->dwNumObjs = newDevice->generic.devcaps.dwAxes + newDevice->generic.devcaps.dwPOVs + newDevice->generic.devcaps.dwButtons; if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto FAILED; for (i = 0; i < newDevice->generic.device_axis_count; i++) { int wine_obj = newDevice->generic.axis_map[i]; if (wine_obj < 0) continue; memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[wine_obj], df->dwObjSize); if (wine_obj < 8) df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS; else { df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(wine_obj - 8) | DIDFT_POV; i++; /* POV takes 2 axes */ } } for (i = 0; i < newDevice->generic.devcaps.dwButtons; i++) { memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 12], df->dwObjSize); df->rgodf[idx ].pguid = &GUID_Button; df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON; } newDevice->generic.base.data_format.wine_df = df; /* initialize default properties */ for (i = 0; i < c_dfDIJoystick2.dwNumObjs; i++) { newDevice->generic.props[i].lDevMin = -32767; newDevice->generic.props[i].lDevMax = +32767; newDevice->generic.props[i].lMin = 0; newDevice->generic.props[i].lMax = 0xffff; newDevice->generic.props[i].lDeadZone = newDevice->generic.deadzone; /* % * 1000 */ newDevice->generic.props[i].lSaturation = 0; } IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface); EnterCriticalSection(&dinput->crit); list_add_tail(&dinput->devices_list, &newDevice->generic.base.entry); LeaveCriticalSection(&dinput->crit); newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps); newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED; if (newDevice->generic.base.dinput->dwVersion >= 0x0800) newDevice->generic.devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); else newDevice->generic.devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); newDevice->generic.devcaps.dwFFSamplePeriod = 0; newDevice->generic.devcaps.dwFFMinTimeResolution = 0; newDevice->generic.devcaps.dwFirmwareRevision = 0; newDevice->generic.devcaps.dwHardwareRevision = 0; newDevice->generic.devcaps.dwFFDriverVersion = 0; if (TRACE_ON(dinput)) { _dump_DIDATAFORMAT(newDevice->generic.base.data_format.wine_df); for (i = 0; i < (newDevice->generic.device_axis_count); i++) TRACE("axis_map[%d] = %d\n", i, newDevice->generic.axis_map[i]); _dump_DIDEVCAPS(&newDevice->generic.devcaps); } *pdev = newDevice; return DI_OK; FAILED: hr = DIERR_OUTOFMEMORY; FAILED1: if (df) HeapFree(GetProcessHeap(), 0, df->rgodf); HeapFree(GetProcessHeap(), 0, df); release_DataFormat(&newDevice->generic.base.data_format); HeapFree(GetProcessHeap(),0,newDevice->generic.axis_map); HeapFree(GetProcessHeap(),0,newDevice); *pdev = 0; return hr; }
/*********************************************************************** * server_init_thread * * Send an init thread request. Return 0 if OK. */ size_t server_init_thread( void *entry_point ) { static const int is_win64 = (sizeof(void *) > sizeof(int)); const char *arch = getenv( "WINEARCH" ); int ret; int reply_pipe[2]; struct sigaction sig_act; size_t info_size; sig_act.sa_handler = SIG_IGN; sig_act.sa_flags = 0; sigemptyset( &sig_act.sa_mask ); /* ignore SIGPIPE so that we get an EPIPE error instead */ sigaction( SIGPIPE, &sig_act, NULL ); /* create the server->client communication pipes */ if (server_pipe( reply_pipe ) == -1) server_protocol_perror( "pipe" ); if (server_pipe( ntdll_get_thread_data()->wait_fd ) == -1) server_protocol_perror( "pipe" ); wine_server_send_fd( reply_pipe[1] ); wine_server_send_fd( ntdll_get_thread_data()->wait_fd[1] ); ntdll_get_thread_data()->reply_fd = reply_pipe[0]; close( reply_pipe[1] ); SERVER_START_REQ( init_thread ) { req->unix_pid = getpid(); req->unix_tid = get_unix_tid(); req->teb = wine_server_client_ptr( NtCurrentTeb() ); req->entry = wine_server_client_ptr( entry_point ); req->reply_fd = reply_pipe[1]; req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; req->debug_level = (TRACE_ON(server) != 0); req->cpu = client_cpu; ret = wine_server_call( req ); NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid); NtCurrentTeb()->ClientId.UniqueThread = ULongToHandle(reply->tid); info_size = reply->info_size; server_start_time = reply->server_start; server_cpus = reply->all_cpus; } SERVER_END_REQ; is_wow64 = !is_win64 && (server_cpus & (1 << CPU_x86_64)) != 0; ntdll_get_thread_data()->wow64_redir = is_wow64; switch (ret) { case STATUS_SUCCESS: if (arch) { if (!strcmp( arch, "win32" ) && (is_win64 || is_wow64)) fatal_error( "WINEARCH set to win32 but '%s' is a 64-bit installation.\n", wine_get_config_dir() ); if (!strcmp( arch, "win64" ) && !is_win64 && !is_wow64) fatal_error( "WINEARCH set to win64 but '%s' is a 32-bit installation.\n", wine_get_config_dir() ); } return info_size; case STATUS_NOT_REGISTRY_FILE: fatal_error( "'%s' is a 32-bit installation, it cannot support 64-bit applications.\n", wine_get_config_dir() ); case STATUS_NOT_SUPPORTED: if (is_win64) fatal_error( "wineserver is 32-bit, it cannot support 64-bit applications.\n" ); else fatal_error( "'%s' is a 64-bit installation, it cannot be used with a 32-bit wineserver.\n", wine_get_config_dir() ); default: server_protocol_error( "init_thread failed with status %x\n", ret ); } }
static HRESULT swapchain_gdi_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in, const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags) { struct wined3d_surface *front, *back; if (!swapchain->back_buffers) { WARN("Swapchain doesn't have a backbuffer, returning WINED3DERR_INVALIDCALL\n"); return WINED3DERR_INVALIDCALL; } front = swapchain->front_buffer; back = swapchain->back_buffers[0]; /* Flip the DC. */ { HDC tmp; tmp = front->hDC; front->hDC = back->hDC; back->hDC = tmp; } /* Flip the DIBsection. */ { HBITMAP tmp; tmp = front->dib.DIBsection; front->dib.DIBsection = back->dib.DIBsection; back->dib.DIBsection = tmp; } /* Flip the surface data. */ { void *tmp; tmp = front->dib.bitmap_data; front->dib.bitmap_data = back->dib.bitmap_data; back->dib.bitmap_data = tmp; tmp = front->resource.allocatedMemory; front->resource.allocatedMemory = back->resource.allocatedMemory; back->resource.allocatedMemory = tmp; if (front->resource.heapMemory) ERR("GDI Surface %p has heap memory allocated.\n", front); if (back->resource.heapMemory) ERR("GDI Surface %p has heap memory allocated.\n", back); } /* FPS support */ if (TRACE_ON(fps)) { static LONG prev_time, frames; DWORD time = GetTickCount(); ++frames; /* every 1.5 seconds */ if (time - prev_time > 1500) { TRACE_(fps)("@ approx %.2ffps\n", 1000.0 * frames / (time - prev_time)); prev_time = time; frames = 0; } } x11_copy_to_screen(swapchain, NULL); return WINED3D_OK; }
/*********************************************************************** * apply_relocations * * Apply relocations to a segment. Helper for NE_LoadSegment. */ static inline BOOL apply_relocations( NE_MODULE *pModule, const struct relocation_entry_s *rep, int count, int segnum ) { BYTE *func_name; char buffer[256]; int i, ordinal; WORD offset, *sp; HMODULE16 module; FARPROC16 address = 0; HMODULE16 *pModuleTable = (HMODULE16 *)((char *)pModule + pModule->ne_modtab); SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule ); SEGTABLEENTRY *pSeg = pSegTable + segnum - 1; /* * Go through the relocation table one entry at a time. */ for (i = 0; i < count; i++, rep++) { /* * Get the target address corresponding to this entry. */ /* If additive, there is no target chain list. Instead, add source and target */ int additive = rep->relocation_type & NE_RELFLAG_ADDITIVE; switch (rep->relocation_type & 3) { case NE_RELTYPE_ORDINAL: module = pModuleTable[rep->target1-1]; ordinal = rep->target2; address = NE_GetEntryPoint( module, ordinal ); if (!address) { NE_MODULE *pTarget = NE_GetPtr( module ); if (!pTarget) WARN_(module)("Module not found: %04x, reference %d of module %*.*s\n", module, rep->target1, *((BYTE *)pModule + pModule->ne_restab), *((BYTE *)pModule + pModule->ne_restab), (char *)pModule + pModule->ne_restab + 1 ); else { ERR("No implementation for %.*s.%d, setting to 0xdeadbeef\n", *((BYTE *)pTarget + pTarget->ne_restab), (char *)pTarget + pTarget->ne_restab + 1, ordinal ); address = (FARPROC16)0xdeadbeef; } } if (TRACE_ON(fixup)) { NE_MODULE *pTarget = NE_GetPtr( module ); TRACE("%d: %.*s.%d=%04x:%04x %s\n", i + 1, *((BYTE *)pTarget + pTarget->ne_restab), (char *)pTarget + pTarget->ne_restab + 1, ordinal, HIWORD(address), LOWORD(address), NE_GetRelocAddrName( rep->address_type, additive ) ); } break; case NE_RELTYPE_NAME: module = pModuleTable[rep->target1-1]; func_name = (BYTE *)pModule + pModule->ne_imptab + rep->target2; memcpy( buffer, func_name+1, *func_name ); buffer[*func_name] = '\0'; ordinal = NE_GetOrdinal( module, buffer ); address = NE_GetEntryPoint( module, ordinal ); if (ERR_ON(fixup) && !address) { NE_MODULE *pTarget = NE_GetPtr( module ); ERR("No implementation for %.*s.%s, setting to 0xdeadbeef\n", *((BYTE *)pTarget + pTarget->ne_restab), (char *)pTarget + pTarget->ne_restab + 1, buffer ); } if (!address) address = (FARPROC16) 0xdeadbeef; if (TRACE_ON(fixup)) { NE_MODULE *pTarget = NE_GetPtr( module ); TRACE("%d: %.*s.%s=%04x:%04x %s\n", i + 1, *((BYTE *)pTarget + pTarget->ne_restab), (char *)pTarget + pTarget->ne_restab + 1, buffer, HIWORD(address), LOWORD(address), NE_GetRelocAddrName( rep->address_type, additive ) ); } break; case NE_RELTYPE_INTERNAL: if ((rep->target1 & 0xff) == 0xff) { address = NE_GetEntryPoint( pModule->self, rep->target2 ); } else { address = (FARPROC16)MAKESEGPTR( SEL(pSegTable[rep->target1-1].hSeg), rep->target2 ); } TRACE("%d: %04x:%04x %s\n", i + 1, HIWORD(address), LOWORD(address), NE_GetRelocAddrName( rep->address_type, additive ) ); break; case NE_RELTYPE_OSFIXUP: /* Relocation type 7: * * These appear to be used as fixups for the Windows * floating point emulator. Let's just ignore them and * try to use the hardware floating point. Linux should * successfully emulate the coprocessor if it doesn't * exist. */ TRACE("%d: TYPE %d, OFFSET %04x, TARGET %04x %04x %s\n", i + 1, rep->relocation_type, rep->offset, rep->target1, rep->target2, NE_GetRelocAddrName( rep->address_type, additive ) ); continue; } offset = rep->offset; /* Apparently, high bit of address_type is sometimes set; */ /* we ignore it for now */ if (rep->address_type > NE_RADDR_OFFSET32) { char module[10]; GetModuleName16( pModule->self, module, sizeof(module) ); ERR("WARNING: module %s: unknown reloc addr type = 0x%02x. Please report.\n", module, rep->address_type ); } if (additive) { sp = MapSL( MAKESEGPTR( SEL(pSeg->hSeg), offset ) ); TRACE(" %04x:%04x\n", offset, *sp ); switch (rep->address_type & 0x7f) { case NE_RADDR_LOWBYTE: *(BYTE *)sp += LOBYTE((int)address); break; case NE_RADDR_OFFSET16: *sp += LOWORD(address); break; case NE_RADDR_POINTER32: *sp += LOWORD(address); *(sp+1) = HIWORD(address); break; case NE_RADDR_SELECTOR: /* Borland creates additive records with offset zero. Strange, but OK */ if (*sp) ERR("Additive selector to %04x.Please report\n",*sp); else *sp = HIWORD(address); break; default: goto unknown; } } else /* non-additive fixup */ { do { WORD next_offset; sp = MapSL( MAKESEGPTR( SEL(pSeg->hSeg), offset ) ); next_offset = *sp; TRACE(" %04x:%04x\n", offset, *sp ); switch (rep->address_type & 0x7f) { case NE_RADDR_LOWBYTE: *(BYTE *)sp = LOBYTE((int)address); break; case NE_RADDR_OFFSET16: *sp = LOWORD(address); break; case NE_RADDR_POINTER32: *(FARPROC16 *)sp = address; break; case NE_RADDR_SELECTOR: *sp = SELECTOROF(address); break; default: goto unknown; } if (next_offset == offset) break; /* avoid infinite loop */ if (next_offset >= GlobalSize16(pSeg->hSeg)) break; offset = next_offset; } while (offset != 0xffff); } } return TRUE; unknown: WARN("WARNING: %d: unknown ADDR TYPE %d, " "TYPE %d, OFFSET %04x, TARGET %04x %04x\n", i + 1, rep->address_type, rep->relocation_type, rep->offset, rep->target1, rep->target2); return FALSE; }