Moved the call to pc_init_modules() once again to before the renderer API is initializes, fixes Eradicator when 86Box is started with the renderer set to Direct3D;

Added some sanity checks to both the DirectDraw and Direct3D code.
This commit is contained in:
OBattler
2017-12-15 03:40:36 +01:00
parent 356a481f73
commit 1fc459b8b9
3 changed files with 21 additions and 19 deletions

View File

@@ -8,7 +8,7 @@
*
* Rendering module for Microsoft Direct3D 9.
*
* Version: @(#)win_d3d.cpp 1.0.7 2017/12/13
* Version: @(#)win_d3d.cpp 1.0.8 2017/12/15
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -144,7 +144,7 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h)
hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0);
if (hr == D3D_OK) {
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
if (buffer32) memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
video_blit_complete();
d3dTexture->UnlockRect(0);
@@ -248,8 +248,9 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h)
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (hr == D3D_OK) {
for (yy = y1; yy < y2; yy++) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
if (buffer32)
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
}
video_blit_complete();

View File

@@ -11,7 +11,7 @@
* NOTES: This code should be re-merged into a single init() with a
* 'fullscreen' argument, indicating FS mode is requested.
*
* Version: @(#)win_ddraw.cpp 1.0.2 2017/11/25
* Version: @(#)win_ddraw.cpp 1.0.3 2017/12/15
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -245,7 +245,7 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
}
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
if (buffer32) memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
video_blit_complete();
lpdds_back->Unlock(NULL);
@@ -317,8 +317,9 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
}
for (yy = y1; yy < y2; yy++) {
if ((y + yy) >= 0 && (y + yy) < buffer->h)
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
if (buffer32)
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
}
video_blit_complete();
lpdds_back->Unlock(NULL);

View File

@@ -8,7 +8,7 @@
*
* user Interface module for WinAPI on Windows.
*
* Version: @(#)win_ui.c 1.0.7 2017/12/09
* Version: @(#)win_ui.c 1.0.8 2017/12/15
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -756,6 +756,16 @@ ui_init(int nCmdShow)
0, 0, 1, 1, hwnd, NULL, hinstance, NULL);
MoveWindow(hwndRender, 0, 0, scrnsz_x, scrnsz_y, TRUE);
/* All done, fire up the actual emulated machine. */
if (! pc_init_modules()) {
/* Dang, no ROMs found at all! */
MessageBox(hwnd,
plat_get_string(IDS_2056),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(6);
}
/* Initialize the configured Video API. */
if (! plat_setvid(vid_api)) {
MessageBox(hwnd,
@@ -772,16 +782,6 @@ ui_init(int nCmdShow)
/* Set up the current window size. */
plat_resize(scrnsz_x, scrnsz_y);
/* All done, fire up the actual emulated machine. */
if (! pc_init_modules()) {
/* Dang, no ROMs found at all! */
MessageBox(hwnd,
plat_get_string(IDS_2056),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(6);
}
/* Fire up the machine. */
pc_reset_hard();