Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add s3freak's 4 MiB S3 patch #1244

Merged
merged 46 commits into from
Sep 13, 2021
Merged

Add s3freak's 4 MiB S3 patch #1244

merged 46 commits into from
Sep 13, 2021

Conversation

kcgen
Copy link
Member

@kcgen kcgen commented Sep 3, 2021

This PR adds s3freak's excellent S3 patch to provide a similar vmemsize = setting like ECE and DOSBox-X have.

Care has been taken to ensure it's running clean using SciTech's VBETEST 5.3a testing tool, attached: sdd53a.zip. Simply unzip and launch this branch inside the unzipped directory.

Logging

A small feature is that the video adapter and memory details are provided (given vmem is now configurable):

machine = svga_paradise
# a couple vmemsize values
VIDEO: Initialized Paradise VGA 1A with 256 KiB of DRAM
VIDEO: Initialized Paradise VGA 1A with 512 KiB of DRAM
machine = svga_et3000
machine = svga_et4000
# a couple vmemsize values
VIDEO: Initialized Tseng Labs ET3000 with 512 KiB of DRAM
VIDEO: Initialized Tseng Labs ET4000 with 1 MiB of DRAM
machine = svga_s3
machine = vesa_nolfb
machine = vesa_oldvbe
# and various vmemsize values
VIDEO: Initialized S3 Trio 64 (VESA 2.0) with 512 KiB of EDO DRAM
VIDEO: Initialized S3 Trio 64 (VESA 2.0) without linear framebuffer modes with 8 MiB of EDO DRAM
VIDEO: Initialized S3 Trio 64 (VESA 1.2) with 2 MiB of EDO DRAM

Tall-mode handling

Tall VESA modes are those that are taller than they are wide, ie: 320x400.

When aspect = true, this branch will aspect-correct the image so things appear "correct" in terms of proportions.
For example, notice both VBETEST's graphically-drawn font is correctly proportioned as are the 3D structures and lettering inside Quake:

2021-09-03_09-41

2021-09-03_11-15

When aspect = false, tall modes will be stretched to "fit the CRT", which may result in distorted proportions.

2021-09-03_09-43

We always provide information to the user so they can adjust as needed.

Fixes: #366


Reviewers: suggest reviewing commit-by-commit.

@kcgen kcgen added the bug Something isn't working label Sep 3, 2021
@kcgen kcgen requested review from kklobe and bmunger September 3, 2021 19:46
@kcgen kcgen self-assigned this Sep 3, 2021
@kcgen kcgen added this to In progress in 0.78 release via automation Sep 3, 2021
@lgtm-com
Copy link

lgtm-com bot commented Sep 3, 2021

This pull request introduces 12 alerts when merging e639f57 into 40f37ed - view on LGTM.com

new alerts:

  • 12 for Multiplication result converted to larger type

@kcgen kcgen force-pushed the kc/4mb-video-memory-1 branch 5 times, most recently from 9098f71 to f165daf Compare September 3, 2021 23:51
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Sep 4, 2021
@kcgen kcgen force-pushed the kc/4mb-video-memory-1 branch 6 times, most recently from 986a3f5 to 9ee1cab Compare September 5, 2021 00:14
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Sep 5, 2021
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Sep 5, 2021
@kcgen kcgen force-pushed the kc/4mb-video-memory-1 branch 3 times, most recently from e52faf2 to a28839c Compare September 5, 2021 16:55
@kcgen kcgen added enhancement New feature or enhancement of existing features and removed bug Something isn't working labels Sep 5, 2021
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Sep 5, 2021
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Sep 5, 2021
src/hardware/hardware.cpp Outdated Show resolved Hide resolved
src/hardware/vga_draw.cpp Outdated Show resolved Hide resolved
Fixes:
 - warning: format specifies type 'int' but the argument
   has type 'Bitu' (aka 'unsigned long') [-Wformat] -
   LOG(LOG_VGA,LOG_NORMAL)("Blinking %d",enabled);
We know these Bitu's are only 32-bit on Win32 (and these
don't involve pointers or memory addresses), so we can
safely down-grade these to fixed sizes.

Cleans up 20 warnings flagged on macOS Clang:

vga_draw.cpp:1042:51: warning: format specifies type 'int' but the
argument has type 'double' [-Wformat]

vga_draw.cpp:1310:11: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1310:18: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1310:27: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1310:34: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1310:3: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1310:43: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1312:11: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1312:18: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1312:27: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1312:34: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1312:3: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1312:43: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1352:56: warning: format specifies type 'int' but the
argument has type 'double' [-Wformat]

vga_draw.cpp:1356:68: warning: format specifies type 'int' but the
argument has type 'double' [-Wformat]

vga_draw.cpp:1360:65: warning: format specifies type 'int' but the
argument has type 'double' [-Wformat]

vga_draw.cpp:1360:95: warning: format specifies type 'int' but the
argument has type 'double' [-Wformat]

vga_draw.cpp:1786:48: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:1786:55: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]

vga_draw.cpp:819:40: warning: format specifies type 'int' but the
argument has type 'Bitu' (aka 'unsigned long') [-Wformat]
Fixes many warnings of this type:
 "warning C4244: '=': conversion from 'Bitu' to 'uint32_t', possible loss of data"

We know these sizes at most only hold 32-bit as that's their
limit when compiled on Win32.
These are at-most hundreds of  millions.

Likewise, we also know on 32-bit platforms these Bitu
values are only uint32's.
Per the S3 specification (last sentence):

If bit 7 of CR68 is set to 1, the PD bus size for the Trio64 is
determined by the memory size speci- fied in bits 7-5 of CR36. For a
1-MByte configura- tion, the bus size is 32 bits. For 2-MByte or
larger configurations, the bus size is 64 bits. EDO mem- ory can be
used for 1- or 2-MByte configurations. Fast page mode memory is
required for 4-MByte configurations.
The previous version has silent expectations that the VGA
mode enums would have specific values.

For example, M_LIN8 was assumed to be 5.  If M_LIN8 isn't 5
then the various bit-wise operations will produce unexpected
results.

Obviously this is extremely fragile, as changing the order of the
enums (or inserting new items) will alter their underlying values.

This commit lifts out those hardcoded expected values into local
constexpr's, and then uses a switch statement to perform the mapping.
This way, the original enum list can be changed as needed without
any risk coming to the XGA code.
This will ease the comparison of multiple modes.
@kcgen kcgen force-pushed the kc/4mb-video-memory-1 branch 2 times, most recently from 29addb0 to 420ebcb Compare September 13, 2021 19:03
@kcgen kcgen merged commit 215a1ec into master Sep 13, 2021
0.78 release automation moved this from In progress to Done Sep 13, 2021
@kcgen
Copy link
Member Author

kcgen commented Sep 13, 2021

Thanks to:

@kcgen kcgen deleted the kc/4mb-video-memory-1 branch September 18, 2021 19:35
@kcgen kcgen added this to the 0.78 release milestone Dec 21, 2021
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Dec 25, 2021
@dosbox-staging dosbox-staging deleted a comment from lgtm-com bot Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing features
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

SVGA S3 Trio emulation is faulty for games using VESA LFB (was: Duke Nukem 3D title screen flickers)
4 participants