Skip to content

[paint] Move VGA access macros to vgalib.h file#2284

Merged
ghaerr merged 3 commits intomasterfrom
paint5
Apr 7, 2025
Merged

[paint] Move VGA access macros to vgalib.h file#2284
ghaerr merged 3 commits intomasterfrom
paint5

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Apr 7, 2025

C macros for programming various VGA hardware registers are moved out of graphics.c into a new file vgalib.h, where they can be used to create functionality not already built into graphics.c functions.

Also allows vga_drawscanline() to be compiled with OpenWatcom, and included in build. Working on C86.
Removes most __far pointers in vga_drawscanline for tighter code and C86 compatibility.
Rewrites drawhline for OpenWatcom by replacing far pointer VGA access with macros for speed.

@Vutshi, the C macros in vgalib.h can now be used to experiment with XOR drawing using any of the existing graphics functions, without having to burden each function with a specific XOR capability. This means you can turn on VGA hardware XOR drawing mode, execute a graphics function, and then turn it back off - for drawing a pixel with drawpixel, or a horizontal line with drawhline, etc. It will be up to you to turn back off XOR drawing before returning into the main loop.

To add this functionality to some function in render.c, try something like:

#include "vgalib.h"
...
R_DrawDisk(...)
{
...
    set_op(0x18);    // turn on XOR drawing
    ...
    drawhline(...); 
    ...
    set_op(0);       // turn off XOR drawing
}

I played around a bit like above, here's a screenshot of R_DrawDisk doing XOR drawing with a large brush (this XOR paint modification is not included in this PR):
paint xor

@ghaerr ghaerr merged commit 5cfb00b into master Apr 7, 2025
1 check passed
@ghaerr ghaerr deleted the paint5 branch April 7, 2025 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant