Commit graph

929 commits

Author SHA1 Message Date
gm-matthew ac53101214 Implement LOD blending
If two translucent polygons with opposing patterns overlap the result is always opaque
Also the LOD scale calculation depends on Euclidean distance of x, y and z, not just z
2023-11-17 15:13:27 +00:00
Ian Curtis d726356006 Remove debug code 2023-11-13 23:19:18 +00:00
Ian Curtis 33d65e097f Merge branch 'master' of https://github.com/trzy/Supermodel 2023-11-13 21:17:15 +00:00
Ian Curtis efe3077f53 Fix some stencil issues
The stencil mask must be set to all 1s otherwise we can't clear all the bits in the stencil buffer. Also we no longer need to save/restore the depth buffer into between priority layers.
2023-11-13 21:17:06 +00:00
Bart Trzynadlowski 3022e418c7 Added some TODO notes to Main.cpp 2023-11-11 13:57:30 -08:00
Bart Trzynadlowski 47253d8398 Fixed graphics analysis -gfx-state option 2023-11-11 13:55:02 -08:00
Bart Trzynadlowski a57b379498 DSB.h: when generating a debug build in gcc w/ -g, k_framePeriod was causing a linker error. Not sure why k_timerPeriod wasn't but made them both constexpr. 2023-11-11 13:46:05 -08:00
Bart Trzynadlowski ccca9afceb byte_layout attribute for region tag, intended to support Sega Racing Classic 2 ROM extracted from Yakuza 2023-11-11 13:11:15 -08:00
Ian Curtis c40d6ac17b Rewrite the stencil buffer usage slightly, so both the LOS and layered polys work. LOS uses the top bit of the stencil buffer. Fixes some minor issues with draw order in sega rally. 2023-11-10 19:13:37 +00:00
Ian Curtis f9a0901e8c Fix regression
Scroll attenuation seems to disable ambient fog. If scroll attenuation is enabled it's telling the h/w to draw the real3d spot light on fog for the scroll fog layer. This should fix a regression where the background disappears on sega rally.
2023-11-09 18:41:57 +00:00
Ian Curtis a8976b51a2 typo 2023-11-06 10:56:39 +00:00
Ian Curtis a065df24b8 Correct scroll fog attenuation logic (gm_matthew)
The attenuation value effects the spot light on fog for the scroll fog layer. The old implemention was nearly correct but the paramaters for the mix function were swapped.
2023-11-05 23:44:27 +00:00
Ian Curtis aecf61762e Various fixes
- Scroll fog needed a break statement otherwise it could draw potentially multiples times.
- The fog atttenuation paramater doesn't appear to effect scroll fog, other than to potentially enable it. This fixes some issues with emergency call ambulance.
- Added support for the node discard attributes which sega rally2 uses to throw away specific geometry. This fixes junk that starts to show up in the levels after multiple runs.
2023-11-05 17:39:23 +00:00
dukeeeey 628eeebbc3
Merge pull request #101 from gm-matthew/lod-and-blending
Add LOD switching and blending out culling nodes
2023-11-03 19:56:17 +00:00
Ian Curtis 8dda8e9105 Fix the line of sight function.
Polygons have a line of sight value that's either a 0 or 1. We write this value into the stencil buffer, then read the app can read it back to determine the polygon attribute is visible or not. The returned value is 1/depth value in world coordinates. The first bit of the float is actually a control bit, 1 indicates no geometry hit, 0 indicates geometry hit.
2023-11-03 13:24:59 +00:00
gm-matthew 483dbdda2e Add LOD switching and blending out culling nodes
We're not blending between LODs yet as we're not sure of the best way to implement it
Also implementing control bits for disable culling and enable model scale (needed for ECA and Harley)
2023-11-02 14:16:07 +00:00
Ian Curtis 3a85bd9e25 remove debug code 2023-11-01 16:03:11 +00:00
Ian Curtis d16ba90856 Update comments for the culling node function. gm_matthew worked out that the last 2 bits of the model scale float appear to be control bits for disable culling and valid model scale. Strange logic but the line of sight (LOS) function does something similar by re-using float bits for control words. 2023-11-01 16:01:13 +00:00
Ian Curtis 8fea5bd3bf gm_mathew - the line scroll values, the top 16bits are the even lines, the bottom 16bits are the odd lines. We had it swapped. This fixes the number below the word results in daytona, when you finish a game. 2023-10-31 23:50:19 +00:00
Ian Curtis f89da17f17 Fix white gfx on linux / intel gpus. These optimisations originally came from toxieainc 2023-10-27 10:45:16 +01:00
Ian Curtis c5f9a3ad26 Amend the ambient fog logic to be disabled if fog density/start is set to zero. This fixes a regression where the sky stops drawing in lost world.
Rewrite the scroll fog shader slightly. Scroll fog is a 2d layer, it has no depth, or can be considered to be drawn at infinity, therefore is not effected by the viewport light. The scroll attenatuion value also I think attenatutes the scroll fog alpha value. This fixes various effects in emergency call ambulance.
2023-10-24 10:17:15 +01:00
Ian Curtis a214c6dae8 Prior scroll fog logic was nearly correct. For scroll fogging to draw it needs either a start value or a fog density value, but these can come from a different viewport if they have the same colour fog set. This fixes the credits in vf3 which sets scroll fog, but it never draws on the original hardware.
For a long time we've had bug reports that in vf3 the background in the Dural levels was the wrong colour, it should have been much darker. We thought it was again missing scroll fog, but gm_mathew worked out it was actually coming from the fogAmbient paramater. Not only does it darken the fog, but it also has an effect on the 2d background from the tilegen, similar to scroll fog. This also fixes the sky in lemans24.
2023-10-22 21:07:35 +01:00
Ian Curtis 2af0787279 Remove debug code 2023-10-17 17:33:26 +01:00
Ian Curtis 79ddc8c739 Rewrite the logic for the scoll fog (render buffer clear colour). Each viewport can potentially have a scroll fog value so the logic of which value to pick wasn't immediately clear. TLDR I think it picks the highest value starting from the lowest priority layers. This fixes the sky in daytona battle on the edge. 2023-10-17 17:30:14 +01:00
Ian Curtis 86d477263f Scroll fog is like a clear colour for the render target, but can be semi transparent as the tilegen layer can be shown underneath. I assumed that transprent polys would be drawn to the render target for transparent polys but unfortunately the logic does not work. So where else could it be drawn? Well with limited memory it must be draw to the buffer for opaque polys, which means this render target is also blended. 2023-10-15 17:16:52 +01:00
gm-matthew 392900fee2 Implement correct "round to nearest" mode
On PowerPC round to nearest ties to even, not away from zero
Also implement correct behavior for ppc_fresx
Fixes "tips to win" sequence in Daytona 2 BOTE
2023-10-14 17:45:27 -07:00
Ian Curtis 6595b9320e Rewrite the renderer a bit to spit out the finished graphics from the 3d chip on separate buffers. One buffer is for opaque pixels, and 2 more for translucent pixels. Before the frame was composited on the back buffer, which meant the tilegen had to have been drawn first. This way the images are now totally independant of the tilegen chip so can be drawn as soon as the register write 0xC is written to the tilegen.
Some games update the tilegen after the ping_ping bit has flipped at 66% of the frame, so we need to split the tilegen drawing up into two stages to get some effects to work. So having the tilegen draw independantly of the 3d chip can make this happen.
2023-10-14 20:05:00 +01:00
Ian Curtis d656643087 gm_mathew worked out that the camera flashes in sega rally 2 have the 'reset-matrix' attribute set inside the culling nodes, which was unsupported until now because we never found any games to have used this bit. The reset matrix is a bit strange, I would assume it would just reset the matrix back to identity, instead it seems to just reset the rotation back to identity whilst preserving the scale/position. 2023-09-27 16:33:53 +01:00
Bart Trzynadlowski 7867c0145e
Model3.cpp: Comment describing scan line timing. 2023-09-25 14:45:57 +02:00
Matthew Daniels 801945d066 Whitespace 2023-09-25 14:41:35 +02:00
gm-matthew 24d24db988 Ping-pong flip timing depends of the value of tilegen register 0x08
Also make the debugger display 16 bytes per line when using the "listmemory" command. Mirrored system registers can now be watched
2023-09-25 14:41:35 +02:00
Ian Curtis 6b0d5c453a Merge branch 'master' of https://github.com/trzy/Supermodel 2023-09-23 15:27:12 +01:00
Ian Curtis c6ea81d996 Emulate the entire tilegen chip in a GLSL shader. (This is now possible with opengl 3+). The tilegen drawing was emulated on the CPU, but was one of the most expensive functions in the emulator according to a profiler. On a modern GPU it's pretty much free, because a GPU is a massive SIMD monster.
Tilegen shaders are mapped to uniforms, and the vram and palette are mapped to two textures.

TODO rip out the redundant code in the tilegen class. We don't need to pre-calculate palettes anymore. etc

The tilegen code supports has a start/end line so we can emulate as many lines as we want in a chunk, which will come in later as some games update the tilegen immediately after the ping_pong bit has flipped ~ 66% of the frame.

The scud rolling start tilegen bug is probably actually a bug in the original h/w implementation, that ends up looking correct on original h/w but not for us. Need hardware testing to confirm what it's actually doing.
2023-09-23 15:27:04 +01:00
gm-matthew c9b718e89a Fix Z80Debug.cpp compile with C++20
String literals should not be used to initialize char* but C++17 and earlier were letting it slide
2023-09-02 20:38:24 -07:00
Bart Trzynadlowski ebff9a8b2d SCSP: added more detail to comment explaining 68K clock speed as recommended by Brian Troha 2023-09-02 20:32:11 -07:00
gm-matthew b2fee4242c DMA device register always returns Step 1.x PCI ID
Step 2.x games by AM3 request PCI ID this way and expect to see 0x16c311db
2023-08-20 17:43:40 -07:00
gm-matthew 7924fed369 Set soundboard CPU to correct clock speed
The 68K on the soundboard is rated at 12 MHz but runs at 11.2896 MHz, which is 256 cycles/sample with a 44100 Hz sample rate. Removed SoundClock and Freq as they are not needed
2023-08-20 17:43:27 -07:00
gm-matthew 015e8e9212 Drive board uses the value 0xFF (not 0x00) on ports 42 and 45 to stop all effects when port 46 is set to 0xFF; fixes FFB effects continuing after game ends 2023-07-01 23:21:51 -07:00
ToBul 583d237b2b Fix GCC 13 build.
MSYS and probably a few Linux distros are now shipping GCC 13.
The new standards and issues are listed here,

https://gcc.gnu.org/gcc-13/porting_to.html
2023-05-07 21:42:21 -07:00
CapitaineSheridan 18f3c23a9f Work around to prevent I/O error after a while on fishing games with tension 2023-05-07 21:41:57 -07:00
CapitaineSheridan 813edb8218 Crosshair optimization:
-create crosshairs only once in Init() instead of created them at every cycle
-use matrix scale to apply the aspect ratio
2023-05-07 21:41:05 -07:00
Bart Trzynadlowski 87de86f7d1 Crosshair: use actual adjusted viewport resolution (configuration resolution is not the same thing). Fixes crosshair alignment for resolutions with non-Model 3 aspect. 2023-03-18 10:00:28 -07:00
Bart Trzynadlowski 95fc08e0a3 Windows app manifest added to enable PerMonitorV2 DPI awareness 2023-03-15 18:24:01 -07:00
Bart Trzynadlowski b5ca365928 NetBoard: guard against freeing null pointers and INetBoard needed a virtual destructor (was causing crashes on exit on some systems) 2023-03-14 11:18:20 -07:00
CapitaineSheridan abc2900770 m_crosshair is not needed and the config should be checked every frame because otherwise Alt-I command was broken (the number of crosshairs to render is mapped to a UI key) [Bart] 2023-03-13 20:18:51 -07:00
CapitaineSheridan a319bbee0c Better optimisations.
Moved all UI rendering from Main to CCrosshair.
Take care of syntax about crosshair style.
2023-03-13 20:18:51 -07:00
CapitaineSheridan b19fdb6a77 Change Media folder to Assets folder.
Naming variable convention.
Command line change -crosshair-style = vector|bmp.
Config ini variable change CrosshairStyle = vector|bmp.
CCrosshair::DrawCrosshair optimisation.
Modifying UpdateCrosshairs() to eliminate global variable.
2023-03-13 20:18:51 -07:00
CapitaineSheridan 1b066fe4b3 Crosshair refactor
-add a new separate class for crosshair
-crosshair coordinates are calculated by matrix instead of recreating every object at correct coordinates
-add ability to scale crosshair by dpi
-add ability to use bitmap crosshair (located in ./Media/). 32bits bmp format + alpha
-cmd line "-bitmapcrosshair" or "-vectorcrosshair" and/or BitmapCrosshair=0|1 in config file
-these changes are only for lost world game with Crosshairs=1|2|3

don't forget to copy the 2 crosshair images in Supermodel/Media folder
2023-03-13 20:18:51 -07:00
Bart Trzynadlowski ae5af4c036 Fixed window position config storage and command line parsing 2023-03-09 10:34:51 -08:00
Bart Trzynadlowski 83144f80b7 Config nodes: added the ability to clear out node values or create empty leaf nodes 2023-03-09 10:34:51 -08:00
joachim 043f901c80 comply to @trzy requested changes # 2023-03-09 10:34:51 -08:00
joachim 4a64a0df71 comply to @trzy requested changes 2023-03-09 10:34:51 -08:00
joachim c301a574ed -pos=<x>,<y> -> correct error when not present 2023-03-09 10:34:51 -08:00
joachim c97e3acce7 Add two video settings:
-pos=<x>,<y>            Position [Default: centered]
-borderless             Windowed mode with no border

These 2 settings are usefull when setting up a multiplayer game on one machine.

Example for 4 windows in fullHD:

start "Master" /D"Master_P4" Supermodel.exe -input-system=sdl ..\ROMS\dayto2pe.zip -res=960,540 -borderless -pos=0,0
start "Slave1" /D"Slave1_P4" Supermodel.exe -input-system=sdl ..\ROMS\dayto2pe.zip -res=960,540 -borderless -pos=960,0
start "Slave2" /D"Slave2_P4" Supermodel.exe -input-system=sdl ..\ROMS\dayto2pe.zip -res=960,540 -borderless -pos=0,540
start "Slave3" /D"Slave3_P4" Supermodel.exe -input-system=sdl ..\ROMS\dayto2pe.zip -res=960,540 -borderless -pos=960,540
2023-03-09 10:34:51 -08:00
joachim 5fa190490d Allow joystick to be fetch if windows has no focus in SDL input mode.
This is usefull for multiple instance of supermodel networked on the same machine.
2023-03-09 10:34:51 -08:00
Aaron Paden 78f5056223 Add missing filename to ErrorLog call. 2022-12-28 20:04:25 -08:00
CapitaineSheridan 7e025e64a2 Memory allocated but not released. 2022-12-28 18:24:11 -08:00
Ian Curtis 69a458ecf7 Make sure to invalidate texture memory when going fullscreen otherwise it might not be syned correctly. 2022-12-25 00:32:01 +00:00
Ian Curtis 11c01a349f SDL_SetWindowFullscreen isn't needed as we call ResizeGLScreen which sets the fullscreen mode afterwards. 2022-12-24 23:54:47 +00:00
Ian Curtis 6dcf144694 We must explicitly call SDL_SetWindowFullscreen after setting the display mode otherwise the refresh rate doesn't change. 2022-12-24 17:29:08 +00:00
Ian Curtis ad0aed42a4 be a bit more flexible with the display frequencies we'll match 2022-12-19 14:11:21 +00:00
Ian Curtis 25604512f4 The model 3 (actually model 1,2 and 3) all used some crazy refresh rate of 57.524hz. If your screen refresh rate is 60hz, supermodel will work fine, but really run too fast. Anyway if you create a custom refresh rate, supermodel will automatically pick this, and set it when the emulator is in fullscreen mode. Apparently this works with most monitors, even cheapo low end ones.
To active set your command line to:
-res=1920,1080 -vsync -fullscreen -true-hz

Replace the resolution with whatever your monitor's native resolution is.
2022-12-19 00:13:08 +00:00
Ian Curtis 984f78ad1b Merge branch 'master' of https://github.com/trzy/Supermodel 2022-12-17 23:46:11 +00:00
Ian Curtis 57ead6037d Better opengl resource allocation. Fixes going fullscreen and back. 2022-12-17 23:46:02 +00:00
Fernando Casas Schössow d83e4754fe Fixed build on macOS 2022-12-12 16:49:07 -08:00
Fernando Casas Schössow 07429b9187 Switched to Util::Format() to generate screenshot filename 2022-12-12 16:49:07 -08:00
Fernando Casas Schössow 317f8bacde First review code changes (identation and cosmetic changes) 2022-12-12 16:49:07 -08:00
Fernando Casas Schössow d11efb8553 Changed pathType from string var to enum 2022-12-12 16:49:07 -08:00
Fernando Casas Schössow df7787f040 Keep Supermodel files (config, nvram, saves, etc.) in a predictable path when running on Linux 2022-12-12 16:49:07 -08:00
toxieainc db455ba5c1 add undefd codepath for correct use of the 18bit DAC path (which seems to be triggered for all games)
the volume correction to bring the data back into a valid range is not really needed in practice though, only Daytona2 seems to need it, and also only extremely rarely, so lets just live with a tiny bit of clamping for that game then

while add it, make some formatting similar to MAME, and add one comment regarding a most likely wrong recent MAME change
2022-11-29 12:36:27 -08:00
Ian Curtis 153c510009 Fix uniform location. 2022-11-26 12:58:07 +00:00
Matthew Daniels 7513cc769a Update Model3.cpp
whitespace
2022-11-25 15:27:12 -08:00
gm-matthew 6a392f2cc9 Add comment 2022-11-25 15:27:12 -08:00
gm-matthew 916d3d3af1 whitespace 2022-11-25 15:27:12 -08:00
gm-matthew 2063303a4d Wait until IRQ2 is acknowledged before starting IRQ40 sequence. Fixes Ski Champ hanging at FBI screen when region set to USA 2022-11-25 15:27:12 -08:00
gm-matthew 79a2414f3f Incomplete texture headers uploaded via FIFO are now discarded. Ski Champ sends one more 32-bit word via DMA than it should which was causing Supermodel to erroneously intepret the extra word as another texture 2022-11-19 21:06:39 -08:00
Ian Curtis 5f30614c4c FIx shaders failing to build on apple h/w 2022-11-09 18:56:15 +00:00
Ian Curtis e47258c61d Remove some left over depreciated opengl functions. They were basically no-op anyway with shader path. 2022-11-07 23:52:44 +00:00
Ian Curtis 9348fd852d Merge branch 'master' of https://github.com/trzy/Supermodel 2022-11-07 21:33:08 +00:00
Ian Curtis 40c8259130 Rewrite the whole project for GL4+. I figured if we removed the limitation of a legacy rendering API we could improve things a bit. With GL4+ we can do unsigned integer math in the shaders. This allows us to upload a direct copy of the real3d texture sheet, and texture directly from this memory given the x/y pos and type. This massively simplifies the binding and invalidation code. Also the crazy corner cases will work because it essentially works the same way as the original hardware.
The standard triangle render requires gl 4.1 core, so should work on mac. The quad renderer runs on 4.5 core. The legacy renderer should still work, and when enabled a regular opengl context will be created, which allows functions marked depreciated in the core profiles to still work. This will only work in windows/linux I think. Apple doesn't support this.

A GL 4.1 GPU is now the min required spec. Sorry if you have an OLDER gpu. GL 4.1 is over 12 years old now.

This is a big update so I apologise in advance if I accidently broke something :]
2022-11-07 21:33:01 +00:00
toxieainc 4c727abdc8 change all INT16 mixing/intermediate clamping to floats
also fixes 3 bugs:
1) mpeg right channel volume was always using the left channel volume, too
2) too high MusicVolume setting was not clamped to 0..200
3) too high SoundVolume setting was not clamped to 0..200
2022-11-06 13:00:13 -08:00
Bart Trzynadlowski 121f81c742 68K now uses run-time hooks for IRQ and instruction hook callbacks 2022-11-02 18:46:08 -07:00
Ian Curtis b2e5a200da Fix build for linux (just missing header) 2022-10-17 09:34:11 +01:00
Ian Curtis f0872cc998 Upgrade the glsl shader class a bit. Add a const char* comparitor so we can use a map with a simple "string" key. Fine to use when performance is not critical. 2022-10-16 21:03:41 +01:00
Ian Curtis 6fbf938335 Add a proper git ignore file .. And fix the legacy renderer to build with new visual studio (2019) 2022-10-16 20:45:40 +01:00
toxieainc e644751f01 after clarifications, minor cleanup 2022-10-10 16:35:02 -07:00
toxieainc 75771b3d14 remove 2 dupe function calls, where ProcessLos should actually be rather costly 2022-10-10 16:35:02 -07:00
Fernando Casas Schössow 412e9232d7 Fix new 3D engine texture2DLod function missing error on Linux/MESA. MESA requires needed extensions to be explicitly declared in code otherwise it will not enable them. 2022-10-10 16:30:09 -07:00
toxieainc aae58edd62 change one more place with potential aliasing issue 2022-10-03 17:59:59 -07:00
toxieainc 5f97e5af6c address review 2022-10-03 17:59:59 -07:00
toxieainc 519d695f57 address review and move bit casts to new header 2022-10-03 17:59:59 -07:00
toxieainc 1b0e3be8dc use correct slash 2022-10-03 17:59:59 -07:00
toxieainc 22ffb5cc19 Harmless math warning fixes. map->unordered_map in CNew3D::CacheModel. Avoid general aliasing problems (using bit_cast or the recommended/optimized-away memcpy). 2022-10-03 17:59:59 -07:00
toxieainc 0eef09ba2b Revert "port some changes from MAME/MESS"
This reverts commit b5f3d8b68e1ae62a08b00a730b6b8150758c0af3.
2022-08-19 08:41:22 -07:00
toxieainc d7041a83c9 fix missing version GLSL compiler warnings on startup
happens (at least) on Intel drivers
2022-08-19 08:41:22 -07:00
toxieainc 7052e8375e port some changes from MAME/MESS 2022-08-19 08:41:22 -07:00
toxieainc a60f99848f Revert "port some changes from MAME/MESS"
This reverts commit b5f3d8b68e1ae62a08b00a730b6b8150758c0af3.
2022-08-16 21:34:31 -07:00
toxieainc 6c24bf7c8f Optimize quad rendering by replacing the double computations for the area computation with the equivalent shoelace algorithm along with kahans algorithm to compute the cross products. In addition pull out the /w to the end, which increases precision even more.
Thus making the result similar to the fp64 version, tested e.g. with harleys first person mode (all artifacts still gone as before).

Improves perf on low end boards (e.g. Intel) dramatically (10fps with harley before, now 70 on my laptop), and even on higher end (e.g. NVIDIA laptop, quads are now faster than tri pipeline on my laptop).
2022-08-16 21:34:31 -07:00
toxieainc d919f3865c port some changes from MAME/MESS 2022-08-16 21:34:31 -07:00
ToBul e06788e768 Fix SUPERMODEL_DEBUGGER build. - Ian
As requested by Bart; Ian's last SourceForge commit.
Also, purely to appease my OCD, a change I forgot on my last 'Games.xml' PR that really shouldn't bother me as much as it does.
2022-08-14 11:46:35 -07:00