From 329f0104917472ed427f1d6a80e50285214430b6 Mon Sep 17 00:00:00 2001 From: Wengier Date: Mon, 10 Oct 2022 23:42:39 -0400 Subject: Forward declare the SDL Window to avoid SDL-dependence (If SDL.h is added to video.h, we need to add SDL dependencies inside the unit tests as well) --- include/pci_bus.h | 1 + include/sdlmain.h | 8 ----- include/video.h | 5 ++-- src/gui/sdlmain.cpp | 42 +++++++------------------- src/hardware/pci_bus.cpp | 30 +++++++++---------- src/hardware/pci_devices.h | 68 +++++++++++++++++++++--------------------- src/hardware/voodoo.cpp | 4 +-- src/hardware/voodoo.h | 2 +- src/hardware/voodoo_data.h | 2 +- src/hardware/voodoo_emu.cpp | 44 +++++++++++++++++++++------ src/hardware/voodoo_opengl.cpp | 33 +++++++++++++------- src/hardware/voodoo_types.h | 16 +++++----- src/hardware/voodoo_vogl.cpp | 5 +++- src/hardware/voodoo_vogl.h | 8 ++--- 14 files changed, 142 insertions(+), 126 deletions(-) diff --git a/include/pci_bus.h b/include/pci_bus.h index 39e94329f..d53c52b26 100644 --- a/include/pci_bus.h +++ b/include/pci_bus.h @@ -74,6 +74,7 @@ public: virtual bool OverrideReadRegister(uint8_t regnum, uint8_t* rval, uint8_t* rval_mask)=0; virtual Bits ParseWriteRegister(uint8_t regnum,uint8_t value)=0; virtual bool InitializeRegisters(uint8_t registers[256])=0; + virtual ~PCI_Device() = 0; }; diff --git a/include/sdlmain.h b/include/sdlmain.h index d46948357..9ef107b8d 100644 --- a/include/sdlmain.h +++ b/include/sdlmain.h @@ -48,14 +48,6 @@ static void update_frame_surface(const uint16_t *changedLines); constexpr void update_frame_noop([[maybe_unused]] const uint16_t *) { /* no-op */ } static inline bool present_frame_noop() { return true; } -enum SCREEN_TYPES { - SCREEN_SURFACE, - SCREEN_TEXTURE, -#if C_OPENGL - SCREEN_OPENGL -#endif -}; - enum class FRAME_MODE { UNSET, CFR, // constant frame rate, as defined by the emulated system diff --git a/include/video.h b/include/video.h index 926a9939b..b985b5a04 100644 --- a/include/video.h +++ b/include/video.h @@ -23,7 +23,6 @@ #include #include "types.h" -#include #define REDUCE_JOYSTICK_POLLING @@ -116,8 +115,10 @@ void SetTransparency(); void OpenGL_On(); void OpenGL_Off(); bool OpenGL_using(); + +struct SDL_Window; SDL_Window* GFX_GetSDLWindow(); -SDL_Window *SetWindowMode(SCREEN_TYPES screen_type, +SDL_Window* SetWindowMode(SCREEN_TYPES screen_type, int width, int height, bool fullscreen, diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index e9928627e..31c31fd41 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -218,15 +218,6 @@ constexpr uint32_t AMASK = 0xff000000; #endif #endif // !MACOSX -enum MouseControlType { - CaptureOnClick = 1 << 0, - CaptureOnStart = 1 << 1, - Seamless = 1 << 2, - NoMouse = 1 << 3 -}; - -enum class SCALING_MODE { NONE, NEAREST, PERFECT }; - // Size and ratio constants // ------------------------ constexpr int SMALL_WINDOW_PERCENT = 50; @@ -282,11 +273,6 @@ static bool isDebuggerEvent(const SDL_Event &event) } return false; } - -SDL_Window *GFX_GetSDLWindow(void) -{ - return sdl.window; -} #endif #if C_OPENGL @@ -1349,11 +1335,6 @@ SDL_Window* GFX_GetSDLWindow(void) { return sdl.window; } -SDL_Window* SetWindow(int width, int height) { - sdl.window = SetWindowMode(SCREEN_OPENGL, width, height, false, false); - return sdl.window; -} - bool OpenGL_using(void) { #if C_OPENGL return (sdl.desktop.want_type==SCREEN_OPENGL?true:false); @@ -1366,7 +1347,6 @@ static std::string prev_output = ""; void OpenGL_On() { if (OpenGL_using()) { prev_output.clear(); - return; } Section* tsec = control->GetSection("sdl"); prev_output = static_cast(tsec)->Get_string("output"); @@ -1450,7 +1430,8 @@ SDL_Window* GFX_SetSDLWindowMode(uint16_t width, uint16_t height, SCREEN_TYPES s sdl.window = SDL_CreateWindow("", x>-1?x:pos.x, y>-1?y:pos.y, - width, height, + width, + height, flags); if (!sdl.window) { LOG_ERR("SDL: %s", SDL_GetError()); @@ -1471,7 +1452,6 @@ SDL_Window* GFX_SetSDLWindowMode(uint16_t width, uint16_t height, SCREEN_TYPES s #endif sdl.surface = SDL_GetWindowSurface(sdl.window); - return sdl.window; } /* Fullscreen mode switching has its limits, and is also problematic on @@ -3641,13 +3621,6 @@ static void SetPriorityLevels(const std::string_view active_pref, sdl.priority.inactive = to_level(inactive_pref); } -void SetTransparency() { - Section_prop *section = static_cast(control->GetSection("sdl")); - const auto transparency = clamp(section->Get_int("transparency"), 0, 90); - const auto alpha = static_cast(100 - transparency) / 100.0f; - SDL_SetWindowOpacity(sdl.window, alpha); -} - static void GUI_StartUp(Section *sec) { sec->AddDestroyFunction(&GUI_ShutDown); @@ -3847,12 +3820,14 @@ void GFX_RegenerateWindow(Section *sec) { static void HandleVideoResize(int width, int height) { +#if C_OPENGL if (sdl.desktop.lazy_fullscreen) { new_height = height; new_width = width; voodoo_ogl_update_dimensions(); return; } +#endif /* Maybe a screen rotation has just occurred, so we simply resize. There may be a different cause for a forced resized, though. */ @@ -4681,6 +4656,12 @@ void GFX_GetSize(int &width, int &height, bool &fullscreen) fullscreen = sdl.desktop.fullscreen; } +bool GFX_IsFullScreenSetting() +{ + return control->cmdline->FindExist("-fullscreen") || + static_cast(control->GetSection("sdl"))->Get_bool("fullscreen"); +} + extern "C" int SDL_CDROMInit(void); int sdl_main(int argc, char *argv[]) { @@ -4861,8 +4842,7 @@ int sdl_main(int argc, char *argv[]) /* Some extra SDL Functions */ Section_prop * sdl_sec=static_cast(control->GetSection("sdl")); - if (control->cmdline->FindExist("-fullscreen") || - sdl_sec->Get_bool("fullscreen")) { + if (GFX_IsFullScreenSetting()) { if(!sdl.desktop.fullscreen) { //only switch if not already in fullscreen GFX_SwitchFullScreen(); } diff --git a/src/hardware/pci_bus.cpp b/src/hardware/pci_bus.cpp index 20862c827..62daa206b 100644 --- a/src/hardware/pci_bus.cpp +++ b/src/hardware/pci_bus.cpp @@ -44,7 +44,7 @@ static PCI_Device* pci_devices[PCI_MAX_PCIDEVICES]; // registered PCI devices // 10- 8 - subfunction number (0x00000700) // 7- 2 - config register # (0x000000fc) -static void write_pci_addr(io_port_t port, io_val_t val, io_width_t) +static void write_pci_addr([[maybe_unused]] io_port_t port, io_val_t val, io_width_t) { LOG(LOG_PCI, LOG_NORMAL)("Write PCI address :=%x", val); pci_caddress = val; @@ -105,19 +105,19 @@ static void write_pci(io_port_t port, io_val_t value, io_width_t width) // WORD and DWORD are never used case io_width_t::word: write_pci_register(dev, regnum + 0, (uint8_t)(val & 0xff)); - write_pci_register(dev, regnum + 1, (uint8_t)((val >> 8) & 0xff)); + write_pci_register(dev, regnum + 1, (uint8_t)((val >> 7 >> 1) & 0xff)); break; case io_width_t::dword: write_pci_register(dev, regnum + 0, (uint8_t)(val & 0xff)); - write_pci_register(dev, regnum + 1, (uint8_t)((val >> 8) & 0xff)); - write_pci_register(dev, regnum + 2, (uint8_t)((val >> 16) & 0xff)); - write_pci_register(dev, regnum + 3, (uint8_t)((val >> 24) & 0xff)); + write_pci_register(dev, regnum + 1, (uint8_t)((val >> 7 >> 1) & 0xff)); + write_pci_register(dev, regnum + 2, (uint8_t)((val >> 7 >> 7 >> 2) & 0xff)); + write_pci_register(dev, regnum + 3, (uint8_t)((val >> 7 >> 7 >> 7 >> 3) & 0xff)); break; } } } -static uint32_t read_pci_addr(io_port_t port, io_width_t) +static uint32_t read_pci_addr([[maybe_unused]] io_port_t port, io_width_t) { LOG(LOG_PCI, LOG_NORMAL)("Read PCI address -> %x", pci_caddress); return pci_caddress; @@ -168,15 +168,15 @@ static uint8_t read_pci(io_port_t port, io_width_t width) uint8_t devnum = (uint8_t)((pci_caddress >> 11) & 0x1f); uint8_t fctnum = (uint8_t)((pci_caddress >> 8) & 0x7); uint8_t regnum = (uint8_t)((pci_caddress & 0xfc) + (port & 0x03)); - if (devnum>=pci_devices_installed) return 0xffffffff; + if (devnum>=pci_devices_installed) return 0xff; LOG(LOG_PCI,LOG_NORMAL)(" Read from device %x register %x (function %x); addr %x", devnum,regnum,fctnum,pci_caddress); PCI_Device *selected_device = pci_devices[devnum]; if (selected_device == nullptr) - return 0xffffffff; + return 0xff; if (fctnum > selected_device->NumSubdevices()) - return 0xffffffff; + return 0xff; PCI_Device *dev = selected_device->GetSubdevice(fctnum); @@ -190,7 +190,7 @@ static uint8_t read_pci(io_port_t port, io_width_t width) case io_width_t::word: { uint16_t val16 = read_pci_register(dev, regnum); val16 |= (read_pci_register(dev, regnum + 1) << 8); - return val16; + return (uint8_t)val16; } case io_width_t::dword: { uint32_t val32 = read_pci_register(dev, regnum); @@ -203,7 +203,7 @@ static uint8_t read_pci(io_port_t port, io_width_t width) } } } - return 0xffffffff; + return 0xff; } static Bitu PCI_PM_Handler() { @@ -261,6 +261,7 @@ PCI_Device* PCI_Device::GetSubdevice(Bits subfct) { return NULL; } +PCI_Device::~PCI_Device() {} // queued devices (PCI device registering requested before the PCI framework was initialized) static const Bitu max_rqueued_devices=16; @@ -444,7 +445,7 @@ void PCI_AddSST_Device(Bitu type) { ctype = type; break; default: - LOG_MSG("PCI:SST: Invalid board type %x specified",type); + LOG_MSG("PCI:SST: Invalid board type %x specified", (unsigned int)type); break; } PCI_Device* voodoo_dev=new PCI_SSTDevice(ctype); @@ -458,7 +459,7 @@ void PCI_AddSST_Device(Bitu type) { void PCI_RemoveSST_Device(void) { if (pci_interface!=NULL) { - Bit16u vendor=PCI_SSTDevice::VendorID(); + uint16_t vendor=PCI_SSTDevice::VendorID(); pci_interface->RemoveDevice(vendor,1); pci_interface->RemoveDevice(vendor,2); } @@ -476,8 +477,7 @@ bool PCI_IsInitialized() { return false; } - -void PCI_ShutDown(Section* sec){ +void PCI_ShutDown(Section *){ delete pci_interface; pci_interface=NULL; } diff --git a/src/hardware/pci_devices.h b/src/hardware/pci_devices.h index 0dff163b8..ab9463cc8 100644 --- a/src/hardware/pci_devices.h +++ b/src/hardware/pci_devices.h @@ -22,29 +22,29 @@ void VOODOO_PCI_InitEnable(Bitu val); void VOODOO_PCI_Enable(bool enable); -void VOODOO_PCI_SetLFB(Bit32u lfbaddr); +void VOODOO_PCI_SetLFB(uint32_t lfbaddr); class PCI_VGADevice:public PCI_Device { private: - static const Bit16u vendor=0x5333; // S3 - static const Bit16u device=0x8811; // trio64 -// static const Bit16u device=0x8810; // trio32 + static const uint16_t vendor=0x5333; // S3 + static const uint16_t device=0x8811; // trio64 +// static const uint16_t device=0x8810; // trio32 public: PCI_VGADevice():PCI_Device(vendor,device) { } - static Bit16u VendorID(void) { return vendor; } - static Bit16u DeviceID(void) { return device; } + static uint16_t VendorID(void) { return vendor; } + static uint16_t DeviceID(void) { return device; } - Bits ParseReadRegister(Bit8u regnum) { + Bits ParseReadRegister(uint8_t regnum) { return regnum; } - bool OverrideReadRegister(Bit8u regnum, Bit8u* rval, Bit8u* rval_mask) { + bool OverrideReadRegister(uint8_t, uint8_t*, uint8_t*) { return false; } - Bits ParseWriteRegister(Bit8u regnum,Bit8u value) { + Bits ParseWriteRegister(uint8_t regnum, uint8_t value) { if ((regnum>=0x18) && (regnum<0x28)) return -1; // base addresses are read-only if ((regnum>=0x30) && (regnum<0x34)) return -1; // expansion rom addresses are read-only switch (regnum) { @@ -71,7 +71,7 @@ public: return value; } - bool InitializeRegisters(Bit8u registers[256]) { + bool InitializeRegisters(uint8_t registers[256]) { // init (S3 graphics card) // registers[0x08] = 0x44; // revision ID (s3 trio64v+) registers[0x08] = 0x00; // revision ID @@ -92,18 +92,18 @@ public: // registers[0x3c] = 0x0b; // irq line // registers[0x3d] = 0x01; // irq pin -// Bit32u gfx_address_space=(((Bit32u)S3_LFB_BASE)&0xfffffff0) | 0x08; // memory space, within first 4GB, prefetchable - Bit32u gfx_address_space=(((Bit32u)S3_LFB_BASE)&0xfffffff0); // memory space, within first 4GB - registers[0x10] = (Bit8u)(gfx_address_space&0xff); // base addres 0 - registers[0x11] = (Bit8u)((gfx_address_space>>8)&0xff); - registers[0x12] = (Bit8u)((gfx_address_space>>16)&0xff); - registers[0x13] = (Bit8u)((gfx_address_space>>24)&0xff); +// uint32_t gfx_address_space=(((uint32_t)S3_LFB_BASE)&0xfffffff0) | 0x08; // memory space, within first 4GB, prefetchable + uint32_t gfx_address_space=(((uint32_t)S3_LFB_BASE)&0xfffffff0); // memory space, within first 4GB + registers[0x10] = (uint8_t)(gfx_address_space&0xff); // base addres 0 + registers[0x11] = (uint8_t)((gfx_address_space>>8)&0xff); + registers[0x12] = (uint8_t)((gfx_address_space>>16)&0xff); + registers[0x13] = (uint8_t)((gfx_address_space>>24)&0xff); - Bit32u gfx_address_space_mmio=(((Bit32u)S3_LFB_BASE+0x1000000)&0xfffffff0); // memory space, within first 4GB - registers[0x14] = (Bit8u)(gfx_address_space_mmio&0xff); // base addres 0 - registers[0x15] = (Bit8u)((gfx_address_space_mmio>>8)&0xff); - registers[0x16] = (Bit8u)((gfx_address_space_mmio>>16)&0xff); - registers[0x17] = (Bit8u)((gfx_address_space_mmio>>24)&0xff); + uint32_t gfx_address_space_mmio=(((uint32_t)S3_LFB_BASE+0x1000000)&0xfffffff0); // memory space, within first 4GB + registers[0x14] = (uint8_t)(gfx_address_space_mmio&0xff); // base addres 0 + registers[0x15] = (uint8_t)((gfx_address_space_mmio>>8)&0xff); + registers[0x16] = (uint8_t)((gfx_address_space_mmio>>16)&0xff); + registers[0x17] = (uint8_t)((gfx_address_space_mmio>>24)&0xff); return true; } @@ -112,18 +112,18 @@ public: class PCI_SSTDevice:public PCI_Device { private: - static const Bit16u vendor=0x121a; // 3dfx - Bit16u oscillator_ctr; - Bit16u pci_ctr; + static const uint16_t vendor=0x121a; // 3dfx + uint16_t oscillator_ctr; + uint16_t pci_ctr; public: PCI_SSTDevice(Bitu type):PCI_Device(vendor,(type==2)?0x0002:0x0001) { oscillator_ctr=0; pci_ctr=0; } - static Bit16u VendorID(void) { return vendor; } + static uint16_t VendorID(void) { return vendor; } - Bits ParseReadRegister(Bit8u regnum) { + Bits ParseReadRegister(uint8_t regnum) { // LOG_MSG("SST ParseReadRegister %x",regnum); switch (regnum) { case 0x4c: @@ -144,7 +144,7 @@ public: return regnum; } - bool OverrideReadRegister(Bit8u regnum, Bit8u* rval, Bit8u* rval_mask) { + bool OverrideReadRegister(uint8_t regnum, uint8_t* rval, uint8_t* rval_mask) { switch (regnum) { case 0x54: if (DeviceID() >= 2) { @@ -182,7 +182,7 @@ public: return false; } - Bits ParseWriteRegister(Bit8u regnum,Bit8u value) { + Bits ParseWriteRegister(uint8_t regnum, uint8_t value) { // LOG_MSG("SST ParseWriteRegister %x:=%x",regnum,value); if ((regnum>=0x14) && (regnum<0x28)) return -1; // base addresses are read-only if ((regnum>=0x30) && (regnum<0x34)) return -1; // expansion rom addresses are read-only @@ -215,7 +215,7 @@ public: return value; } - bool InitializeRegisters(Bit8u registers[256]) { + bool InitializeRegisters(uint8_t registers[256]) { // init (3dfx voodoo) registers[0x08] = 0x02; // revision registers[0x09] = 0x00; // interface @@ -234,11 +234,11 @@ public: registers[0x3c] = 0xff; // no irq // memBaseAddr: size is 16MB - Bit32u address_space=(((Bit32u)VOODOO_INITIAL_LFB)&0xfffffff0) | 0x08; // memory space, within first 4GB, prefetchable - registers[0x10] = (Bit8u)(address_space&0xff); // base addres 0 - registers[0x11] = (Bit8u)((address_space>>8)&0xff); - registers[0x12] = (Bit8u)((address_space>>16)&0xff); - registers[0x13] = (Bit8u)((address_space>>24)&0xff); + uint32_t address_space=(((uint32_t)VOODOO_INITIAL_LFB)&0xfffffff0) | 0x08; // memory space, within first 4GB, prefetchable + registers[0x10] = (uint8_t)(address_space&0xff); // base addres 0 + registers[0x11] = (uint8_t)((address_space>>8)&0xff); + registers[0x12] = (uint8_t)((address_space>>16)&0xff); + registers[0x13] = (uint8_t)((address_space>>24)&0xff); if (DeviceID() >= 2) { registers[0x40] = 0x00; diff --git a/src/hardware/voodoo.cpp b/src/hardware/voodoo.cpp index 4e54fac71..1f21a6eb4 100644 --- a/src/hardware/voodoo.cpp +++ b/src/hardware/voodoo.cpp @@ -37,7 +37,7 @@ class VOODOO; static VOODOO* voodoo_dev; -static Bit32u voodoo_current_lfb=(VOODOO_INITIAL_LFB&0xffff0000); +static uint32_t voodoo_current_lfb=(VOODOO_INITIAL_LFB&0xffff0000); class VOODOO:public Module_base{ @@ -157,7 +157,7 @@ void VOODOO_PCI_Enable(bool enable) { } -void VOODOO_PCI_SetLFB(Bit32u lfbaddr) { +void VOODOO_PCI_SetLFB(uint32_t lfbaddr) { voodoo_current_lfb=(lfbaddr&0xffff0000); } diff --git a/src/hardware/voodoo.h b/src/hardware/voodoo.h index 35f20d115..8c48f00a5 100644 --- a/src/hardware/voodoo.h +++ b/src/hardware/voodoo.h @@ -35,7 +35,7 @@ void VOODOO_PCI_InitEnable(Bitu val); void VOODOO_PCI_Enable(bool enable); -void VOODOO_PCI_SetLFB(Bit32u lfbaddr); +void VOODOO_PCI_SetLFB(uint32_t lfbaddr); bool VOODOO_PCI_CheckLFBPage(Bitu page); PageHandler* VOODOO_GetPageHandler(); diff --git a/src/hardware/voodoo_data.h b/src/hardware/voodoo_data.h index 6f9d3f4b6..802f2cdc3 100644 --- a/src/hardware/voodoo_data.h +++ b/src/hardware/voodoo_data.h @@ -1091,7 +1091,7 @@ INLINE UINT32 compute_raster_hash(const raster_info *info) #define DECLARE_DITHER_POINTERS \ const UINT8 *dither_lookup = NULL; \ const UINT8 *dither4 = NULL; \ - const UINT8 *dither = NULL \ + [[maybe_unused]] const UINT8 *dither = NULL \ #define COMPUTE_DITHER_POINTERS(FBZMODE, YY) \ do \ diff --git a/src/hardware/voodoo_emu.cpp b/src/hardware/voodoo_emu.cpp index bc4f11d5e..4445cc2e0 100644 --- a/src/hardware/voodoo_emu.cpp +++ b/src/hardware/voodoo_emu.cpp @@ -73,6 +73,7 @@ iterated W = 18.32 [48 bits] #include #include +#include #include "dosbox.h" #include "cross.h" @@ -778,6 +779,7 @@ void recompute_video_memory(voodoo_state *v) { case 3: /* reserved */ LOG(LOG_VOODOO,LOG_WARN)("VOODOO.ERROR:Unexpected memory configuration in recompute_video_memory!\n"); + [[fallthrough]]; case 0: /* 2 color buffers, 1 aux buffer */ v->fbi.rgboffs[2] = (UINT32)(~0); @@ -1132,7 +1134,7 @@ void poly_render_triangle(void *dest, poly_draw_scanline_func callback, const po INT32 curscan, scaninc=1; INT32 v1yclip, v3yclip; - INT32 v1y, v3y, v1x; + INT32 v1y, v3y; /* first sort by Y */ if (v2->y < v1->y) @@ -1155,7 +1157,7 @@ void poly_render_triangle(void *dest, poly_draw_scanline_func callback, const po } /* compute some integral X/Y vertex values */ - v1x = round_coordinate(v1->x); + //v1x = round_coordinate(v1->x); v1y = round_coordinate(v1->y); v3y = round_coordinate(v3->y); @@ -1326,36 +1328,42 @@ void register_w(UINT32 offset, UINT32 data) { /* Vertex data is 12.4 formatted fixed point */ case fvertexAx: data = float_to_int32(data, 4); + [[fallthrough]]; case vertexAx: if (chips & 1) v->fbi.ax = (INT16)(data&0xffff); break; case fvertexAy: data = float_to_int32(data, 4); + [[fallthrough]]; case vertexAy: if (chips & 1) v->fbi.ay = (INT16)(data&0xffff); break; case fvertexBx: data = float_to_int32(data, 4); + [[fallthrough]]; case vertexBx: if (chips & 1) v->fbi.bx = (INT16)(data&0xffff); break; case fvertexBy: data = float_to_int32(data, 4); + [[fallthrough]]; case vertexBy: if (chips & 1) v->fbi.by = (INT16)(data&0xffff); break; case fvertexCx: data = float_to_int32(data, 4); + [[fallthrough]]; case vertexCx: if (chips & 1) v->fbi.cx = (INT16)(data&0xffff); break; case fvertexCy: data = float_to_int32(data, 4); + [[fallthrough]]; case vertexCy: if (chips & 1) v->fbi.cy = (INT16)(data&0xffff); break; @@ -1363,72 +1371,84 @@ void register_w(UINT32 offset, UINT32 data) { /* RGB data is 12.12 formatted fixed point */ case fstartR: data = float_to_int32(data, 12); + [[fallthrough]]; case startR: if (chips & 1) v->fbi.startr = (INT32)(data << 8) >> 8; break; case fstartG: data = float_to_int32(data, 12); + [[fallthrough]]; case startG: if (chips & 1) v->fbi.startg = (INT32)(data << 8) >> 8; break; case fstartB: data = float_to_int32(data, 12); + [[fallthrough]]; case startB: if (chips & 1) v->fbi.startb = (INT32)(data << 8) >> 8; break; case fstartA: data = float_to_int32(data, 12); + [[fallthrough]]; case startA: if (chips & 1) v->fbi.starta = (INT32)(data << 8) >> 8; break; case fdRdX: data = float_to_int32(data, 12); + [[fallthrough]]; case dRdX: if (chips & 1) v->fbi.drdx = (INT32)(data << 8) >> 8; break; case fdGdX: data = float_to_int32(data, 12); + [[fallthrough]]; case dGdX: if (chips & 1) v->fbi.dgdx = (INT32)(data << 8) >> 8; break; case fdBdX: data = float_to_int32(data, 12); + [[fallthrough]]; case dBdX: if (chips & 1) v->fbi.dbdx = (INT32)(data << 8) >> 8; break; case fdAdX: data = float_to_int32(data, 12); + [[fallthrough]]; case dAdX: if (chips & 1) v->fbi.dadx = (INT32)(data << 8) >> 8; break; case fdRdY: data = float_to_int32(data, 12); + [[fallthrough]]; case dRdY: if (chips & 1) v->fbi.drdy = (INT32)(data << 8) >> 8; break; case fdGdY: data = float_to_int32(data, 12); + [[fallthrough]]; case dGdY: if (chips & 1) v->fbi.dgdy = (INT32)(data << 8) >> 8; break; case fdBdY: data = float_to_int32(data, 12); + [[fallthrough]]; case dBdY: if (chips & 1) v->fbi.dbdy = (INT32)(data << 8) >> 8; break; case fdAdY: data = float_to_int32(data, 12); + [[fallthrough]]; case dAdY: if (chips & 1) v->fbi.dady = (INT32)(data << 8) >> 8; break; @@ -1436,18 +1456,21 @@ void register_w(UINT32 offset, UINT32 data) { /* Z data is 20.12 formatted fixed point */ case fstartZ: data = float_to_int32(data, 12); + [[fallthrough]]; case startZ: if (chips & 1) v->fbi.startz = (INT32)data; break; case fdZdX: data = float_to_int32(data, 12); + [[fallthrough]]; case dZdX: if (chips & 1) v->fbi.dzdx = (INT32)data; break; case fdZdY: data = float_to_int32(data, 12); + [[fallthrough]]; case dZdY: if (chips & 1) v->fbi.dzdy = (INT32)data; break; @@ -2244,6 +2267,8 @@ void lfb_w(UINT32 offset, UINT32 data, UINT32 mem_mask) { /* compute dithering */ COMPUTE_DITHER_POINTERS(v->reg[fbzMode].u, y); + INT32 blendr = 0, blendg = 0, blendb = 0, blenda = 0; + /* loop over up to two pixels */ for (pix = 0; mask; pix++) { @@ -2296,8 +2321,6 @@ void lfb_w(UINT32 offset, UINT32 data, UINT32 mem_mask) { if (FBZCP_CC_MSELECT(v->reg[fbzColorPath].u) != 0) LOG_MSG("lfbw fpp rblend alpha %8x",FBZCP_CCA_REVERSE_BLEND(v->reg[fbzColorPath].u)); } - - INT32 blendr, blendg, blendb, blenda; rgb_union c_local; /* compute c_local */ @@ -2726,8 +2749,8 @@ UINT32 register_r(UINT32 offset) /* start with a blank slate */ result = 0; - result |= ((Bit32u)(Voodoo_GetVRetracePosition() * 0x1fff)) & 0x1fff; - result |= (((Bit32u)(Voodoo_GetHRetracePosition() * 0x7ff)) & 0x7ff) << 16; + result |= ((uint32_t)(Voodoo_GetVRetracePosition() * 0x1fff)) & 0x1fff; + result |= (((uint32_t)(Voodoo_GetHRetracePosition() * 0x7ff)) & 0x7ff) << 16; break; @@ -2756,6 +2779,7 @@ UINT32 register_r(UINT32 offset) case fbiAfuncFail: case fbiPixelsOut: update_statistics(v, true); + [[fallthrough]]; case fbiTrianglesOut: result = v->reg[regnum].u & 0xffffff; break; @@ -3122,7 +3146,7 @@ void fastfill(voodoo_state *v) /* fill in a block of extents */ extents[0].startx = sx; extents[0].stopx = ex; - for (extnum = 1; extnum < ARRAY_LENGTH(extents); extnum++) + for (extnum = 1; extnum < (int)ARRAY_LENGTH(extents); extnum++) extents[extnum] = extents[0]; poly_extra_data *extra = new poly_extra_data; @@ -3134,7 +3158,7 @@ void fastfill(voodoo_state *v) /* iterate over blocks of extents */ for (y = sy; y < ey; y += ARRAY_LENGTH(extents)) { - int count = MIN(ey - y, ARRAY_LENGTH(extents)); + int count = MIN(ey - y, (int)ARRAY_LENGTH(extents)); extra->state = v; memcpy(extra->dither, dithermatrix, sizeof(extra->dither)); @@ -3563,7 +3587,7 @@ static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo) if (LOG_RASTERIZERS) LOG_MSG("Adding rasterizer @ %p : %08X %08X %08X %08X %08X %08X (hash=%d)\n", - info->callback, + (void *)info->callback, info->eff_color_path, info->eff_alpha_mode, info->eff_fog_mode, info->eff_fbz_mode, info->eff_tex_mode_0, info->eff_tex_mode_1, hash); @@ -3726,7 +3750,9 @@ void voodoo_activate(void) { void voodoo_update_dimensions(void) { v->ogl_dimchange = false; +#if C_OPENGL if (v->ogl) { voodoo_ogl_update_dimensions(); } +#endif } diff --git a/src/hardware/voodoo_opengl.cpp b/src/hardware/voodoo_opengl.cpp index 4f4cfd20d..18da2a781 100644 --- a/src/hardware/voodoo_opengl.cpp +++ b/src/hardware/voodoo_opengl.cpp @@ -62,10 +62,15 @@ static UINT32 ogl_texture_index = 1; /* texture cache buffer */ UINT32 texrgb[256*256]; +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wint-to-void-pointer-cast" +#endif /* texture address map */ std::map textures[2]; +bool GFX_IsFullScreenSetting(); +SDL_Window* GFX_GetSDLWindow(void); SDL_Window* GFX_SetSDLWindowMode(uint16_t width, uint16_t height, SCREEN_TYPES screenType); static void ogl_get_depth(voodoo_state* VV, INT32 ITERZ, INT64 ITERW, INT32 *depthval, INT32 *out_wfloat) @@ -918,9 +923,9 @@ void ogl_shaders(const poly_extra_data *extra) { /* shaders extensions not loaded */ if (!glCreateShaderObjectARB) return; - UINT32 FBZMODE = extra->r_fbzMode; - UINT32 FOGMODE = extra->r_fogMode; - UINT32 texcount = extra->texcount; + //UINT32 FBZMODE = extra->r_fbzMode; + UINT32 FOGMODE = (UINT32)extra->r_fogMode; + UINT32 texcount = (UINT32)extra->texcount; /* build a new shader program */ if (!extra->info->shader_ready) { @@ -1106,8 +1111,8 @@ void voodoo_ogl_draw_triangle(poly_extra_data *extra) { td[0].enable = false; td[1].enable = false; - UINT32 ALPHAMODE = extra->r_alphaMode; - UINT32 FBZMODE = extra->r_fbzMode; + UINT32 ALPHAMODE = (UINT32)extra->r_alphaMode; + UINT32 FBZMODE = (UINT32)extra->r_fbzMode; ogl_get_vertex_data(v->fbi.ax, v->fbi.ay, (void*)extra, &vd[0]); @@ -1438,7 +1443,7 @@ void voodoo_ogl_draw_pixel_pipeline(int x, int y, int r, int g, int b) { } -void voodoo_ogl_clip_window(voodoo_state *v) { +void voodoo_ogl_clip_window(voodoo_state *) { /* VOGL_ClearBeginMode(); int sx = (v->reg[clipLeftRight].u >> 16) & 0x3ff; @@ -1481,7 +1486,7 @@ void voodoo_ogl_fastfill(void) { bool scissors_needed = true; if ((sx == 0) && (sy == 0)) { - if ((ex == v->fbi.width) && (ey == v->fbi.height)) scissors_needed = false; + if ((ex == (int)v->fbi.width) && (ey == (int)v->fbi.height)) scissors_needed = false; } sx = (sx* new_width) / v->fbi.width; @@ -1495,7 +1500,7 @@ void voodoo_ogl_fastfill(void) { } - Bit32u clear_mask=0; + uint32_t clear_mask=0; if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u)) { clear_mask|=GL_COLOR_BUFFER_BIT; @@ -1642,8 +1647,6 @@ void voodoo_ogl_reset_videomode(void) { GFX_TearDown(); - bool full_sdl_restart = true; // make dependent on surface=opengl - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); @@ -1673,12 +1676,20 @@ void voodoo_ogl_reset_videomode(void) { if (GFX_LazyFullscreenRequested()) GFX_SwitchFullscreenNoReset(); + int w = -1, h = -1; + SDL_GetWindowSize(GFX_GetSDLWindow(), &w, &h); + if (w > -1 && h > -1 && ((int)new_width != w || (int)new_height != h)) { + new_height = h; + new_width = w; + } SDL_Window *window = GFX_SetSDLWindowMode(new_width, new_height, SCREEN_OPENGL); if (window != NULL) ogl_surface = SDL_GetWindowSurface(window); if (ogl_surface == NULL) E_Exit("VOODOO: opengl init error"); + if (GFX_IsFullScreenSetting() && !GFX_IsFullscreen()) + GFX_SwitchFullScreen(); GFX_SwitchLazyFullscreen(true); //GFX_UpdateSDLCaptureState(); @@ -1825,6 +1836,8 @@ void voodoo_ogl_leave(bool leavemode) { LOG_MSG("VOODOO: OpenGL: quit"); GFX_SwitchLazyFullscreen(false); + if (GFX_IsFullScreenSetting() && !GFX_IsFullscreen()) + GFX_SwitchFullScreen(); if (ogl_surface != NULL) { SDL_FreeSurface(ogl_surface); ogl_surface = NULL; diff --git a/src/hardware/voodoo_types.h b/src/hardware/voodoo_types.h index 2ae14a514..1875cf22b 100644 --- a/src/hardware/voodoo_types.h +++ b/src/hardware/voodoo_types.h @@ -56,23 +56,23 @@ /* 8-bit values */ -typedef Bit8u UINT8; -typedef Bit8s INT8; +typedef uint8_t UINT8; +typedef int8_t INT8; /* 16-bit values */ -typedef Bit16u UINT16; -typedef Bit16s INT16; +typedef uint16_t UINT16; +typedef int16_t INT16; /* 32-bit values */ #ifndef _WINDOWS_ -typedef Bit32u UINT32; -typedef Bit32s INT32; +typedef uint32_t UINT32; +typedef int32_t INT32; #endif /* 64-bit values */ #ifndef _WINDOWS_ -typedef Bit64u UINT64; -typedef Bit64s INT64; +typedef uint64_t UINT64; +typedef int64_t INT64; #endif /* core components of the attotime structure */ diff --git a/src/hardware/voodoo_vogl.cpp b/src/hardware/voodoo_vogl.cpp index cb23a02e3..030bd698a 100644 --- a/src/hardware/voodoo_vogl.cpp +++ b/src/hardware/voodoo_vogl.cpp @@ -21,6 +21,10 @@ #define GL_SILENCE_DEPRECATION #endif +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include #include #include @@ -114,7 +118,6 @@ void VOGL_Reset(void) { read_from_front_buffer = false; } - void VOGL_InitVersion(void) { opengl_version = -1; diff --git a/src/hardware/voodoo_vogl.h b/src/hardware/voodoo_vogl.h index 6a3a7a1ac..8b39fb3d0 100644 --- a/src/hardware/voodoo_vogl.h +++ b/src/hardware/voodoo_vogl.h @@ -110,14 +110,14 @@ void VOGL_Reset(void); bool VOGL_Initialize(void); -bool VOGL_CheckFeature(Bit32u feat); -void VOGL_FlagFeature(Bit32u feat); +bool VOGL_CheckFeature(uint32_t feat); +void VOGL_FlagFeature(uint32_t feat); void VOGL_BeginMode(INT32 new_mode); void VOGL_ClearBeginMode(void); -void VOGL_SetDepthMode(Bit32s mode, Bit32s func); -void VOGL_SetAlphaMode(Bit32s enabled_mode,GLuint src_rgb_fac,GLuint dst_rgb_fac, +void VOGL_SetDepthMode(int32_t mode, int32_t func); +void VOGL_SetAlphaMode(int32_t enabled_mode,GLuint src_rgb_fac,GLuint dst_rgb_fac, GLuint src_alpha_fac,GLuint dst_alpha_fac); void VOGL_SetDepthMaskMode(bool masked); -- cgit v1.2.3