Supermodel patches (Fixes & Improvements)

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Supermodel patches (Fixes & Improvements)

Postby HarryTuttle » Thu Mar 09, 2017 3:20 pm

Hi all, I'm new to this forum and this is my first post. :oops:

I'd like to submit to your attention and discuss about some patches I've made for Supermodel that I'm working on in my private build. Before going into details, my intention is in fact to make separate topics on the diverse aspects, I'll summarize below what I've made so far (it's a rough, not complete list). Should it be of someone's interest I'll also attach the files themselves to be analyzed.

I've also some idea/suggestion on 3D engine that I'd like to discuss, especially with Ian.


// GNU Toolchain (needs testing outside MSYS2 environment, i.e. Linux)

<Makefile.SDL.Win32.GCC>
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1339

- Try to auto set some compile-time variables (bits, includes, libraries, etc.)
- outputs objects to "_obj" and binaries to "_bin", avoids some clutter.
- Less verbose and more cleaner compile progress status (you can always revert to verbose with VERBOSE = 1)
- Multithread-friendly compilation: issuing "make -jx" with x > 1 now works as expected.


// 3D Engine

(Too many files to mention)

In no particular order:
- Added ability to specify alternative vertex/fragment shader files for 3D layer (like the old engine) and scroll fog. It should make debugging easier for now.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1343
- Completely reworked Spotlight & Fog effects to almost match the arcade counterpart:
    Improved Spotlight effect (size & light decay)
    Added Spotlight on Fog effects (see "eca" attract 'dramatic' intro, not the 'tutorial' ones).
    Added Spotlight on Scroll Fog (see above)
    Changed the fog behavior to consider also "fog ambient" value, again see "eca".
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1360#p11975
- Reworked MicroTexture behavior and fixed some texturing in "daytona2" and "skichamp", maybe others.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1337
- More polygon header properties cached. Should improve a little bit rendering performance.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1343
- Correctly aligned 3D layer with 2D. Basically *always* shift 2px in both directions.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1342
- (Actually a hack) include more cases of "shadow" polygon as layered/stencil polygons.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1343
- (Work in progress) improvement to fixed shading polygon brightness.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1344
- (Work in progress) Improvement to specular hi-light emulation.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1350


// Core

<ConsoleDebugger.cpp>

- Fixed typo: "loststate"->"loadstate"
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1341

<Model3.cpp>

- (from MAME) Change only one bit for gear shift up/down in Harley. Can't see any difference though.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1340
- Added correct cast/select inputs for "getbass"; for what is worth, since is still unplayable.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1340
- Modified statusCycles for "fvipers2" (faster speed in attract sequence plus almost proper texture loading timing) and "swtrilgya" (proper game speed).
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1341
- *Not sure / need feedback*: removed game patches that do not cause direct / visible improvements. (from MAME) Changed "swtrilgy" so test menu is accessible and you can disable "lever feedback" check from there and pass boot test. (from MAME) Changed "eca" to pass the "cabinet network error". (from info gathered in forum) activated the debug test menu in "scud", a real treasure for testing 3D features.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1341

<Main.cpp>

- Added high-resolution timer in place of SDL_GetTicks() to obtain precise 60 fps.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1341
- Added InputSystem option parsing to supermodel.ini, in addition to command-line.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1340
- Changed (non working) mouse hiding function from "Inputs->GetInputSystem()->SetMouseVisibility()" to "SDL_ShowCursor()" and set to hide it when playing with light gun (Lost Word) or when in fullscreen.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1340


// Input System

<Inputs.cpp>

- Changed neutral values for "fishingReel" from 0x80 to 0x0, so that leaving joystick in neutral position doesn't cause fishing reel to spin.
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1340


// 2D Engine

<Render2D.cpp>

- Simplified code dealing with bottom surfaces or "clearAll" condition
http://www.supermodel3.com/Forum/viewtopic.php?f=7&t=1342
Last edited by HarryTuttle on Sun Apr 02, 2017 10:09 am, edited 10 times in total.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: Supermodel patches (Fixes & Improvements)

Postby Bart » Fri Mar 10, 2017 8:22 am

This all sounds great. Note that I have a private build I have not merged yet which includes major changes to the underlying configuration and ROM loading system. This unfortunately requires me to touch a huge number of files in the code base and is what's holding up an official 0.3a release, as I have little time to finish the work I started. But it's getting close!

Your changes sound quite extensive but thankfully, will probably have no conflicts with mine. The graphics-related stuff should be easy to merge provided the fixes make sense and work well with the latest SVN revision. Perhaps you and Ian can coordinate this? I'm also hoping you can discuss these changes and your findings in detail here for our understanding. This forum has of late served as a document of record for our Model 3 findings.

As for actually merging in the changes, I suppose we would just give you commit access to the repo so you can submit the changes yourself and get proper credit for them.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Supermodel patches (Fixes & Improvements)

Postby Ian » Fri Mar 10, 2017 9:23 am

Patches are always welcome
What did you change with

Reworked MicroTexture behavior and fixed some texturing in "daytona2" and
"skichamp", maybe others.


The only game that has any advanced usage of micro textures is sega ski champ. Unfortunately the video footage is so low quality you can only just about make out the base textures, let alone the microtextures. So not really sure how to improve on that.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Supermodel patches (Fixes & Improvements)

Postby HarryTuttle » Fri Mar 10, 2017 12:23 pm

@Bart
I'm separating the modification by argument, my intention is to start a new topic for every aspect like, for example, "Spotlight", "Fog", "Microtexture", etc. I'll also post a "diff" file so you can have a preview of what I've done, or if you prefer i could post the entire file with annotations like "// Begin patch", "// End patch".

Sorry to sound a bit alien to this but it would my first time that i can coordinate my efforts with software developers, same goes with svn, git, etc.

@Ian

This is what I've changed/discovered (I'll open a dedicated topic anyway)

(TextureSheet.cpp)
- @line 190 fixed a bug that prevented passing the correct y coordinate ("y = xCoords[id] + (basePage * 1024);" -> "y = yCoords[id] + (basePage * 1024);")
- @line 180-181 switched xCoords and yCoords arrays values, also added 256px offset to y component of the last four values. Actually i haven't seen a game that displays those textures anyway, but vf3 seems to give a hint: the texture memory dump has two large black squares where usually the mictoTextures are placed, also with the help of some debug output i saw that that microtextures (ID > 3) are actually fetched but not mapped to any polys...

Regarding skichamp, I've also found the usual 2-3 very low quality clips , but observing closely where you are about to expect those microTextures you can actually see them, despite being very blurred. Regarding daytona2, by just modifying the fragment shader to just display the microTexture you can actually see a wrong "spinning tire" microT. where should be some foliage growing on the two big boulders you pass in-between on the beginner stage (the oval).

The LOD mechanism doesn't seem to relate to texture coordinate sampling, in fact it seems to be always multiplied by 4. But i suspected, and confirmed with actual high-quality footage from other model3 games, that it's the upper LOD limit of the base texture to be blended with.

I'll try to explain better:

from the texture memory dump you can see there are 6 LOD levels, from 0 (base, best quality, nearer to camera) to 5 (last, worst quality, farthest from camera). Micro/detail textures are used when you approach the base texture for obvious reason, so when you start to go far there should be a mechanism to limit the upper lod samples to appear 'cause if the base texture become tiny/blurred the micro one is even blurrier and should have no use.

So let's say microTexture minLOD is '0', it means that as far as, in the tri-linear sampling process, the base texture fetched is still lod '0' (base) the microTexture is also applied, but it start to fade in the zone between base texture lod '0' and '1', to finally disappear at level '1'. You can specify up to minLOD '3' because at that level you start to have very small base textures.

I've implemented this check mechanism in the fragment shader with code (copied from stackoverflow.com) that I'll post in the dedicated topic, to not add clutter to this one. Basically, in the rasterization phase, I ask the GPU at which lod level I'm currently now and then blend the microTexture accordingly.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: Supermodel patches (Fixes & Improvements)

Postby Bart » Fri Mar 10, 2017 2:28 pm

HarryTuttle wrote:@Bart
I'm separating the modification by argument, my intention is to start a new topic for every aspect like, for example, "Spotlight", "Fog", "Microtexture", etc. I'll also post a "diff" file so you can have a preview of what I've done, or if you prefer i could post the entire file with annotations like "// Begin patch", "// End patch".

Sorry to sound a bit alien to this but it would my first time that i can coordinate my efforts with software developers, same goes with svn, git, etc.


Either way is fine. Feel free to start topics as needed :)
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Supermodel patches (Fixes & Improvements)

Postby VF3 addicted » Fri Mar 10, 2017 3:39 pm

HarryTuttle I'm very pleased that you joined the forum. You sound like you know what is going on . We need these types of people. I hope that cooperation between Bart, Ian, and You will be fruitful and we all take advantage of that . Peace
User avatar
VF3 addicted
 
Posts: 42
Joined: Mon Sep 01, 2014 12:32 pm

Re: Supermodel patches (Fixes & Improvements)

Postby Ian » Fri Mar 10, 2017 5:08 pm

- @line 190 fixed a bug that prevented passing the correct y coordinate ("y = xCoords[id] + (basePage * 1024);" -> "y = yCoords[id] + (basePage * 1024);")


That's definitely a bug! Well spotted.

I too originally thought the LOD parameter was related to the mipmaps. But I decompiled the sdk with ida pro, and the method which sets the value is called SetRelativeTextureScale() or something similar. Actually there were 2 methods. One which takes an int and sets the values directly and another which accepts a float, and has a formula that calculates the correct value. That's where I derived the values from. It's not perfect, I mean the float value has a margin of error so could be off somewhat, but they are roughly along the right lines. If we had access to really high quality footage we might be able to confirm it. But unfortunately it doesn't exist. As far as I know, sega ski champ is the only game to use this value anyway.

As for the texture positions, they are basically correct. The microtextures ocupy the top left 4 positions in each texture sheet. The memory I assume is split into 2 physical chips. A texture read can happen on both these memory banks at the same time. So if the base texture is in sheet 0, the microtexture is always on sheet 1, and vice versa. It's possible there are more than 4 textures on each sheet. But no game uses more than 4, I think sky champ uses 3. So we have no way of knowing really.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Supermodel patches (Fixes & Improvements)

Postby HarryTuttle » Sat Mar 11, 2017 4:40 am

VF3 addicted wrote:HarryTuttle I'm very pleased that you joined the forum. You sound like you know what is going on . We need these types of people. I hope that cooperation between Bart, Ian, and You will be fruitful and we all take advantage of that . Peace


Thanks for the encouragement. I'll do my best, consider that I'm not a programmer (let alone en emulator developer) with the knowledge of processors, bus, etc. inner workings.

My findings are based upon empirical observation, endless hours (spanning last 2-3 years) spent watching original Model3 footage, code experimentation, and reading "to death" the famous Real3D Pro 1000's "devguide4.pdf" and "Real3DPro1000ProductDescription.pdf"
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: Supermodel patches (Fixes & Improvements)

Postby sonic32 » Sat Mar 11, 2017 11:16 pm

It is great that the HarryTuttle added to help Ian Bart
That would be great help for Ian, Microtextury are now much better
I look forward to further corrections:

[Patch] microtexture
[Patch] Core Emulation :o
[Patch] Input System
[Patch] New Makefile
Etc ..


HarryTuttle came to many fixes in the Supermodel

thanks HarryTuttle :)
User avatar
sonic32
 
Posts: 169
Joined: Tue Dec 20, 2011 11:43 am
Location: Slovakia

Re: Supermodel patches (Fixes & Improvements)

Postby Shekel » Sun Mar 12, 2017 1:22 am

It's great when someone comes along and makes improvements like this.

When I was looking around the web yesterday, I noticed this on the Sega Model 3 Japanese Wikipedia page https://ja.wikipedia.org/wiki/MODEL3.

It's just a translation but it says "With parts procurement difficulties, repair support will be terminated on March 31, 2017".

So this is why emulation is really important.
User avatar
Shekel
 
Posts: 345
Joined: Wed Mar 16, 2016 12:45 pm

Next

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest

cron