diff --git a/CMakeLists.txt b/CMakeLists.txt index b4ccfb012..8180a92c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,11 @@ endif() add_definitions(/DFEAT_HAS_SOFTREND=0) +if(${BUILD_COMPILER} EQUAL ${COMPILER_VC}) + # appveyor heap size issue + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zm200") +endif() + ### deps.cmake ################################################################################# diff --git a/appveyor.yml b/appveyor.yml index 50c9db088..f171983ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,6 +12,8 @@ before_build: - cmd: >- if "%CONFIGURATION%"=="RelWithDebInfo" (set BUILD_PATH=build) + if "%CONFIGURATION%"=="RelWithDebInfo" ("C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64) + if "%CONFIGURATION%"=="fast" (set BUILD_PATH=shell\linux) set EXTRA_PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin\ diff --git a/core/hw/aica/aica_if.cpp b/core/hw/aica/aica_if.cpp index d562a0de1..c1799793b 100644 --- a/core/hw/aica/aica_if.cpp +++ b/core/hw/aica/aica_if.cpp @@ -160,6 +160,8 @@ void aica_Init() void aica_Reset(bool Manual) { aica_Init(); + VREG = 0; + ARMRST = 0; } void aica_Term() diff --git a/core/hw/arm7/arm7.cpp b/core/hw/arm7/arm7.cpp index 9906f96de..1d980c77e 100644 --- a/core/hw/arm7/arm7.cpp +++ b/core/hw/arm7/arm7.cpp @@ -69,12 +69,6 @@ bool Arm7Enabled=false; u8 cpuBitsSet[256]; -bool intState = false; -bool stopState = false; -bool holdState = false; - - - void CPUSwitchMode(int mode, bool saveState, bool breakLoop=true); extern "C" void CPUFiq(); void CPUUpdateCPSR(); diff --git a/core/hw/flashrom/flashrom.h b/core/hw/flashrom/flashrom.h index d3282e003..8e0e3e665 100644 --- a/core/hw/flashrom/flashrom.h +++ b/core/hw/flashrom/flashrom.h @@ -21,7 +21,7 @@ struct MemChip this->mask=size-1;//must be power of 2 this->write_protect_size = write_protect_size; } - ~MemChip() { delete[] data; } + virtual ~MemChip() { delete[] data; } virtual u8 Read8(u32 addr) { @@ -118,14 +118,11 @@ struct MemChip printf("Saved %s as %s\n\n",path,title.c_str()); } + virtual void Reset() {} }; struct RomChip : MemChip { RomChip(u32 sz, u32 write_protect_size = 0) : MemChip(sz, write_protect_size) {} - void Reset() - { - //nothing, its permanent read only ;p - } void Write(u32 addr,u32 data,u32 sz) { die("Write to RomChip is not possible, address=%x, data=%x, size=%d"); @@ -135,10 +132,6 @@ struct SRamChip : MemChip { SRamChip(u32 sz, u32 write_protect_size = 0) : MemChip(sz, write_protect_size) {} - void Reset() - { - //nothing, its battery backed up storage - } void Write(u32 addr,u32 val,u32 sz) { addr&=mask; @@ -234,7 +227,7 @@ struct DCFlashChip : MemChip }; FlashState state; - void Reset() + virtual void Reset() override { //reset the flash chip state state = FS_Normal; diff --git a/core/hw/gdrom/gdromv3.cpp b/core/hw/gdrom/gdromv3.cpp index 0d8f82e38..f8d423313 100644 --- a/core/hw/gdrom/gdromv3.cpp +++ b/core/hw/gdrom/gdromv3.cpp @@ -5,16 +5,10 @@ #include "gdromv3.h" -#include "types.h" #include "hw/sh4/sh4_mem.h" #include "hw/holly/sb.h" #include "hw/sh4/modules/dmac.h" -#include "hw/sh4/sh4_core.h" #include "hw/holly/holly_intc.h" - -#include "hw/sh4/sh4_mmr.h" -#include "hw/sh4/sh4_sched.h" - #include "hw/sh4/sh4_sched.h" int gdrom_schid; @@ -322,6 +316,13 @@ u32 GetFAD(u8* data, bool msf) void libCore_gdrom_disc_change() { gd_setdisc(); + read_params = { 0 }; + set_mode_offset = 0; + packet_cmd = { 0 }; + read_buff = { 0 }; + pio_buff = { gds_waitcmd, 0 }; + ata_cmd = { 0 }; + cdda = { 0 }; } //This handles the work of setting up the pio regs/state :) diff --git a/core/hw/holly/sb_mem.cpp b/core/hw/holly/sb_mem.cpp index c60e4a7ba..b86bf3603 100644 --- a/core/hw/holly/sb_mem.cpp +++ b/core/hw/holly/sb_mem.cpp @@ -41,7 +41,7 @@ bool LoadRomFiles(const string& root) { #if DC_PLATFORM == DC_PLATFORM_DREAMCAST // Dreamcast absolutely needs a BIOS - msgboxf("Unable to find bios in \n%s\nExiting...", MBX_ICONERROR, root.c_str()); + msgboxf("Unable to find bios in %s. Exiting...", MBX_ICONERROR, root.c_str()); return false; #endif } @@ -348,6 +348,10 @@ void sh4_area0_Init() void sh4_area0_Reset(bool Manual) { sb_Reset(Manual); + sys_rom.Reset(); +#if defined(FLASH_SIZE) || defined(BBSRAM_SIZE) + sys_nvmem.Reset(); +#endif } void sh4_area0_Term() diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index 71c954e34..199d8ae5c 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -88,10 +88,8 @@ cResetEvent rs, re; int max_idx,max_mvo,max_op,max_pt,max_tr,max_vtx,max_modt, ovrn; static bool render_called = false; -u32 fb1_watch_addr_start; -u32 fb1_watch_addr_end; -u32 fb2_watch_addr_start; -u32 fb2_watch_addr_end; +u32 fb_watch_addr_start; +u32 fb_watch_addr_end; bool fb_dirty; TA_context* _pvrrc; @@ -558,10 +556,8 @@ void rend_vblank() void check_framebuffer_write() { u32 fb_size = (FB_R_SIZE.fb_y_size + 1) * (FB_R_SIZE.fb_x_size + FB_R_SIZE.fb_modulus) * 4; - fb1_watch_addr_start = FB_R_SOF1 & VRAM_MASK; - fb1_watch_addr_end = fb1_watch_addr_start + fb_size; - fb2_watch_addr_start = FB_R_SOF2 & VRAM_MASK; - fb2_watch_addr_end = fb2_watch_addr_start + fb_size; + fb_watch_addr_start = FB_R_SOF2 & VRAM_MASK; + fb_watch_addr_end = fb_watch_addr_start + fb_size; } void rend_cancel_emu_wait() diff --git a/core/hw/pvr/Renderer_if.h b/core/hw/pvr/Renderer_if.h index 8bd991835..af7f63019 100644 --- a/core/hw/pvr/Renderer_if.h +++ b/core/hw/pvr/Renderer_if.h @@ -61,10 +61,8 @@ Renderer* rend_GL4(); Renderer* rend_norend(); Renderer* rend_softrend(); -extern u32 fb1_watch_addr_start; -extern u32 fb1_watch_addr_end; -extern u32 fb2_watch_addr_start; -extern u32 fb2_watch_addr_end; +extern u32 fb_watch_addr_start; +extern u32 fb_watch_addr_end; extern bool fb_dirty; void check_framebuffer_write(); diff --git a/core/hw/pvr/pvr_mem.cpp b/core/hw/pvr/pvr_mem.cpp index c9af98a90..45fb1a721 100644 --- a/core/hw/pvr/pvr_mem.cpp +++ b/core/hw/pvr/pvr_mem.cpp @@ -233,9 +233,7 @@ void DYNACALL pvr_write_area1_8(u32 addr,u8 data) void DYNACALL pvr_write_area1_16(u32 addr,u16 data) { u32 vaddr = addr & VRAM_MASK; - if (!fb_dirty - && ((vaddr >= fb1_watch_addr_start && vaddr < fb1_watch_addr_end) - || (vaddr >= fb2_watch_addr_start && vaddr < fb2_watch_addr_end))) + if (vaddr >= fb_watch_addr_start && vaddr < fb_watch_addr_end) { fb_dirty = true; } @@ -244,9 +242,7 @@ void DYNACALL pvr_write_area1_16(u32 addr,u16 data) void DYNACALL pvr_write_area1_32(u32 addr,u32 data) { u32 vaddr = addr & VRAM_MASK; - if (!fb_dirty - && ((vaddr >= fb1_watch_addr_start && vaddr < fb1_watch_addr_end) - || (vaddr >= fb2_watch_addr_start && vaddr < fb2_watch_addr_end))) + if (vaddr >= fb_watch_addr_start && vaddr < fb_watch_addr_end) { fb_dirty = true; } diff --git a/core/hw/pvr/ta.h b/core/hw/pvr/ta.h index eb8505bf6..e4e649090 100644 --- a/core/hw/pvr/ta.h +++ b/core/hw/pvr/ta.h @@ -20,5 +20,3 @@ void DYNACALL ta_vtx_data32(void* data); void ta_vtx_data(u32* data, u32 size); bool ta_parse_vdrc(TA_context* ctx); - -#define TRIG_SORT 1 diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 1deeebad7..c31e6d5c4 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -521,6 +521,7 @@ void InitSettings() settings.rend.Fog = true; settings.rend.FloatVMUs = false; settings.rend.Rotate90 = false; + settings.rend.PerStripSorting = false; settings.pvr.ta_skip = 0; settings.pvr.rend = 0; @@ -609,6 +610,7 @@ void LoadSettings(bool game_specific) settings.rend.Fog = cfgLoadBool(config_section, "rend.Fog", settings.rend.Fog); settings.rend.FloatVMUs = cfgLoadBool(config_section, "rend.FloatVMUs", settings.rend.FloatVMUs); settings.rend.Rotate90 = cfgLoadBool(config_section, "rend.Rotate90", settings.rend.Rotate90); + settings.rend.PerStripSorting = cfgLoadBool(config_section, "rend.PerStripSorting", settings.rend.PerStripSorting); settings.pvr.ta_skip = cfgLoadInt(config_section, "ta.skip", settings.pvr.ta_skip); settings.pvr.rend = cfgLoadInt(config_section, "pvr.rend", settings.pvr.rend); @@ -759,6 +761,7 @@ void SaveSettings() cfgSaveBool("config", "rend.Rotate90", settings.rend.Rotate90); cfgSaveInt("config", "ta.skip", settings.pvr.ta_skip); cfgSaveInt("config", "pvr.rend", settings.pvr.rend); + cfgSaveBool("config", "rend.PerStripSorting", settings.rend.PerStripSorting); cfgSaveInt("config", "pvr.MaxThreads", settings.pvr.MaxThreads); cfgSaveBool("config", "pvr.SynchronousRendering", settings.pvr.SynchronousRender); diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index f25369414..8c23dd58b 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -260,11 +260,9 @@ __forceinline glcache.DepthFunc(Zfunction[gp->isp.DepthMode]); } -#if TRIG_SORT - if (SortingEnabled) + if (SortingEnabled && !settings.rend.PerStripSorting) glcache.DepthMask(GL_FALSE); else -#endif glcache.DepthMask(!gp->isp.ZWriteDis); } @@ -1105,13 +1103,16 @@ void DrawStrips() { if (current_pass.autosort) { -#if TRIG_SORT - GenSorted(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); - DrawSorted(render_pass < pvrrc.render_passes.used() - 1); -#else - SortPParams(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); - DrawList(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); -#endif + if (!settings.rend.PerStripSorting) + { + GenSorted(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); + DrawSorted(render_pass < pvrrc.render_passes.used() - 1); + } + else + { + SortPParams(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); + DrawList(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); + } } else DrawList(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 4feec179b..a2fc9eccf 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -942,20 +942,45 @@ static void gui_display_settings() if (ImGui::BeginTabItem("Video")) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding); -#if !defined(GLES) && HOST_OS != OS_DARWIN - if (!gl.is_gles && gl.gl_major >= 4 && ImGui::CollapsingHeader("Transparent Sorting", ImGuiTreeNodeFlags_DefaultOpen)) + int renderer = settings.pvr.rend == 3 ? 2 : settings.rend.PerStripSorting ? 1 : 0; +#if HOST_OS != OS_DARWIN + bool has_per_pixel = !gl.is_gles && gl.gl_major >= 4; +#else + bool has_per_pixel = false; +#endif + if (ImGui::CollapsingHeader("Transparent Sorting", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::Columns(2, "renderers", false); - ImGui::RadioButton("Per Triangle", (int *)&settings.pvr.rend, 0); + ImGui::Columns(has_per_pixel ? 3 : 2, "renderers", false); + ImGui::RadioButton("Per Triangle", &renderer, 0); ImGui::SameLine(); ShowHelpMarker("Sort transparent polygons per triangle. Fast but may produce graphical glitches"); - ImGui::NextColumn(); - ImGui::RadioButton("Per Pixel", (int *)&settings.pvr.rend, 3); + ImGui::NextColumn(); + ImGui::RadioButton("Per Strip", &renderer, 1); ImGui::SameLine(); - ShowHelpMarker("Sort transparent polygons per pixel. Slower but accurate"); + ShowHelpMarker("Sort transparent polygons per strip. Faster but may produce graphical glitches"); + if (has_per_pixel) + { + ImGui::NextColumn(); + ImGui::RadioButton("Per Pixel", &renderer, 2); + ImGui::SameLine(); + ShowHelpMarker("Sort transparent polygons per pixel. Slower but accurate"); + } ImGui::Columns(1, NULL, false); + switch (renderer) + { + case 0: + settings.pvr.rend = 0; + settings.rend.PerStripSorting = false; + break; + case 1: + settings.pvr.rend = 0; + settings.rend.PerStripSorting = true; + break; + case 2: + settings.pvr.rend = 3; + break; + } } -#endif if (ImGui::CollapsingHeader("Rendering Options", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Checkbox("Synchronous Rendering", &settings.pvr.SynchronousRender); diff --git a/core/serialize.cpp b/core/serialize.cpp index 8b7e29900..e29f6700b 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -54,9 +54,6 @@ extern bool armFiqEnable; extern int armMode; extern bool Arm7Enabled; extern u8 cpuBitsSet[256]; -extern bool intState ; -extern bool stopState ; -extern bool holdState ; /* if AREC dynarec enabled: vector ops; @@ -257,15 +254,6 @@ extern u32 FrameCount; //extern cThread rthd; extern bool pend_rend; -//these will all get cleared out after a few frames - no need to serialize -//static bool render_called = false; -//u32 fb1_watch_addr_start; -//u32 fb1_watch_addr_end; -//u32 fb2_watch_addr_start; -//u32 fb2_watch_addr_end; -//bool fb_dirty; - - //maybe //extern u32 memops_t,memops_l; @@ -722,18 +710,6 @@ extern u32 fallback_blocks; extern u32 total_blocks; extern u32 REMOVED_OPS; - - - -//./core/linux-dist/main.cpp, ./core/windows/winmain.cpp , ... -extern u16 kcode[4]; -extern u8 rt[4]; -extern u8 lt[4]; -extern u32 vks[4]; -extern s8 joyx[4]; -extern s8 joyy[4]; - - bool rc_serialize(void *src, unsigned int src_size, void **dest, unsigned int *total_size) { if ( *dest != NULL ) @@ -812,9 +788,10 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(armMode); REICAST_S(Arm7Enabled); REICAST_SA(cpuBitsSet,256); - REICAST_S(intState); - REICAST_S(stopState); - REICAST_S(holdState); + bool dummy; + REICAST_S(dummy); + REICAST_S(dummy); + REICAST_S(dummy); REICAST_S(dsp); @@ -1132,12 +1109,16 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(total_blocks); REICAST_S(REMOVED_OPS); - REICAST_SA(kcode,4); - REICAST_SA(rt,4); - REICAST_SA(lt,4); - REICAST_SA(vks,4); - REICAST_SA(joyx,4); - REICAST_SA(joyy,4); + REICAST_S(i); //REICAST_SA(kcode,4); + REICAST_S(i); + REICAST_S(i); //REICAST_SA(rt,4); + REICAST_S(i); //REICAST_SA(lt,4); + REICAST_S(i); //REICAST_SA(vks,4); + REICAST_S(i); + REICAST_S(i); + REICAST_S(i); + REICAST_S(i); //REICAST_SA(joyx,4); + REICAST_S(i); //REICAST_SA(joyy,4); REICAST_S(settings.dreamcast.broadcast); REICAST_S(settings.dreamcast.cable); @@ -1166,9 +1147,10 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(armMode); REICAST_US(Arm7Enabled); REICAST_USA(cpuBitsSet,256); - REICAST_US(intState); - REICAST_US(stopState); - REICAST_US(holdState); + bool dummy; + REICAST_US(dummy); + REICAST_US(dummy); + REICAST_US(dummy); REICAST_US(dsp); @@ -1562,9 +1544,10 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(armMode); REICAST_US(Arm7Enabled); REICAST_USA(cpuBitsSet,256); - REICAST_US(intState); - REICAST_US(stopState); - REICAST_US(holdState); + bool dummy; + REICAST_US(dummy); + REICAST_US(dummy); + REICAST_US(dummy); REICAST_US(dsp); @@ -1901,12 +1884,16 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(total_blocks); REICAST_US(REMOVED_OPS); - REICAST_USA(kcode,4); - REICAST_USA(rt,4); - REICAST_USA(lt,4); - REICAST_USA(vks,4); - REICAST_USA(joyx,4); - REICAST_USA(joyy,4); + REICAST_US(i); //REICAST_USA(kcode,4); + REICAST_US(i); + REICAST_US(i); //REICAST_USA(rt,4); + REICAST_US(i); //REICAST_USA(lt,4); + REICAST_US(i); //REICAST_USA(vks,4); + REICAST_US(i); + REICAST_US(i); + REICAST_US(i); + REICAST_US(i); //REICAST_USA(joyx,4); + REICAST_US(i); //REICAST_USA(joyy,4); REICAST_US(settings.dreamcast.broadcast); diff --git a/core/types.h b/core/types.h index 8b1a039a8..e73863133 100644 --- a/core/types.h +++ b/core/types.h @@ -638,6 +638,7 @@ struct settings_t bool Fog; bool FloatVMUs; bool Rotate90; // Rotate the screen 90 deg CC + bool PerStripSorting; } rend; struct