Skip to content

(WIP) feature: VESA VBE 1.2#1587

Draft
maximilien-noal wants to merge 5 commits intomasterfrom
feat/VBE_VESA_1.2
Draft

(WIP) feature: VESA VBE 1.2#1587
maximilien-noal wants to merge 5 commits intomasterfrom
feat/VBE_VESA_1.2

Conversation

@maximilien-noal
Copy link
Copy Markdown
Member

@maximilien-noal maximilien-noal commented Dec 3, 2025

Description of Changes

Introduces VBE VESA 1.2 extensions to the VGA BIOS.

Rationale behind Changes

Some games try to use it (like Rules of Engagement 2)

Suggested Testing Steps

Foud no game that actually requires it, and its only an extension. Maybe a VBE utility ?

@maximilien-noal maximilien-noal self-assigned this Dec 3, 2025
Copilot AI review requested due to automatic review settings December 3, 2025 21:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements VESA BIOS Extension (VBE) 1.2 support for the VGA BIOS emulator, enabling compatibility with games like Rules of Engagement 2 that require Super VGA functionality. The implementation adds standardized VESA functions for querying and setting video modes beyond standard VGA capabilities.

Key Changes:

  • Implements VBE 1.2 specification with three core functions: GetControllerInfo (00h), GetModeInfo (01h), and SetMode (02h)
  • Adds memory-mapped data structures (VbeInfoBlock, VbeModeInfoBlock) for VESA information exchange
  • Refactors existing VGA BIOS code to replace magic numbers with named constants for improved maintainability

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
VgaBios.cs Adds VBE 1.2 implementation with three new functions, two nested data structure classes, and extensive constant definitions. Refactors existing code to use named constants instead of magic numbers.
IVesaBiosExtension.cs Defines the interface contract for VESA BIOS Extension functions with comprehensive documentation from the VBE 1.2 specification.

Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
if (bpp == 15 || bpp == 16) {
modeInfo.RedMaskSize = VbeModeInfoConstants.RedGreenBlueMaskSize;
modeInfo.RedFieldPosition = (byte)(bpp == 16 ? 11 : 10);
modeInfo.GreenMaskSize = (byte)(bpp == 16 ? VbeModeInfoConstants.GreenMaskSize6Bit : VbeModeInfoConstants.RedGreenBlueMaskSize);

Check warning

Code scanning / CodeQL

Cast to same type

This cast is redundant because the expression already has type Byte.

Copilot Autofix

AI 3 months ago

To fix this kind of issue, remove the redundant cast so that the code directly assigns the expression of the already-correct type. This keeps the code cleaner and avoids suggesting a nonexistent type conversion.

Concretely, in src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs, within VbeGetModeInfo, update the line assigning modeInfo.GreenMaskSize. The ternary already produces a byte, so the explicit (byte) cast should be removed. The corrected line will simply assign the result of the conditional expression. No additional imports, methods, or definitions are required, and no other logic in the method needs to change.

Suggested changeset 1
src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs b/src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
--- a/src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
+++ b/src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
@@ -1532,7 +1532,7 @@
             if (bpp == 15 || bpp == 16) {
                 modeInfo.RedMaskSize = VbeModeInfoConstants.RedGreenBlueMaskSize;
                 modeInfo.RedFieldPosition = (byte)(bpp == 16 ? 11 : 10);
-                modeInfo.GreenMaskSize = (byte)(bpp == 16 ? VbeModeInfoConstants.GreenMaskSize6Bit : VbeModeInfoConstants.RedGreenBlueMaskSize);
+                modeInfo.GreenMaskSize = bpp == 16 ? VbeModeInfoConstants.GreenMaskSize6Bit : VbeModeInfoConstants.RedGreenBlueMaskSize;
                 modeInfo.GreenFieldPosition = 5;
                 modeInfo.BlueMaskSize = VbeModeInfoConstants.RedGreenBlueMaskSize;
                 modeInfo.BlueFieldPosition = 0;
EOF
@@ -1532,7 +1532,7 @@
if (bpp == 15 || bpp == 16) {
modeInfo.RedMaskSize = VbeModeInfoConstants.RedGreenBlueMaskSize;
modeInfo.RedFieldPosition = (byte)(bpp == 16 ? 11 : 10);
modeInfo.GreenMaskSize = (byte)(bpp == 16 ? VbeModeInfoConstants.GreenMaskSize6Bit : VbeModeInfoConstants.RedGreenBlueMaskSize);
modeInfo.GreenMaskSize = bpp == 16 ? VbeModeInfoConstants.GreenMaskSize6Bit : VbeModeInfoConstants.RedGreenBlueMaskSize;
modeInfo.GreenFieldPosition = 5;
modeInfo.BlueMaskSize = VbeModeInfoConstants.RedGreenBlueMaskSize;
modeInfo.BlueFieldPosition = 0;
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
@maximilien-noal maximilien-noal marked this pull request as draft December 4, 2025 06:52
@maximilien-noal maximilien-noal removed the request for review from kevinferrare December 6, 2025 21:59
@maximilien-noal maximilien-noal changed the title feature: VESA VBE 1.2 [WIP] feature: VESA VBE 1.2 Dec 6, 2025
@maximilien-noal maximilien-noal added the video Emulator video mode or video device related label Jan 13, 2026
@maximilien-noal maximilien-noal force-pushed the feat/VBE_VESA_1.2 branch 2 times, most recently from 30a8243 to 88734e1 Compare January 16, 2026 16:58
@maximilien-noal maximilien-noal force-pushed the feat/VBE_VESA_1.2 branch 2 times, most recently from 1b5c29d to 3ac5052 Compare February 3, 2026 18:19
@maximilien-noal maximilien-noal marked this pull request as ready for review March 16, 2026 06:17
@maximilien-noal
Copy link
Copy Markdown
Member Author

@copilot #1587 (review) implement changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

@maximilien-noal I've opened a new pull request, #1978, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
@maximilien-noal
Copy link
Copy Markdown
Member Author

@copilot implement changes based on this feedback #1587 (review)

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

@maximilien-noal I've opened a new pull request, #1983, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.


You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
Comment thread src/Spice86.Core/Emulator/InterruptHandlers/VGA/VgaBios.cs Outdated
@maximilien-noal maximilien-noal marked this pull request as draft March 18, 2026 07:05
maximilien-noal and others added 3 commits March 30, 2026 20:31
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@maximilien-noal maximilien-noal marked this pull request as ready for review March 30, 2026 18:32
@maximilien-noal maximilien-noal changed the title [WIP] feature: VESA VBE 1.2 feature: VESA VBE 1.2 Mar 30, 2026
@maximilien-noal maximilien-noal removed the request for review from xorangekiller April 6, 2026 11:01
@maximilien-noal maximilien-noal marked this pull request as draft April 6, 2026 15:13
@maximilien-noal maximilien-noal changed the title feature: VESA VBE 1.2 (WIP) feature: VESA VBE 1.2 Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

video Emulator video mode or video device related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants