Skip to content

[paint] Draw XOR cursor 8 pixels at a time #2302

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

Merged
merged 1 commit into from
Apr 17, 2025
Merged

[paint] Draw XOR cursor 8 pixels at a time #2302

merged 1 commit into from
Apr 17, 2025

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Apr 17, 2025

@Vutshi asked:

I thought that a small cursor line is just one byte per plane—maybe two if the cursor position isn’t 8-pixel aligned—so what could be faster than writing a byte directly to memory?

Answer: Not much. And so a much faster cursor display routine was written. This version uses a maximum of two VGA memory writes per 8 bits of the cursor image and never draws pixel-by-pixel. Any 16x16 cursor should be wildly faster on real hardware.

The routine could be made even faster for 16x16 cursors, but I wanted to have this first round tested and get more feedback, as it may be finally fast enough to keep up on 8088. I think we should be able to switch to a larger (16x16 or slightly less) cursor as standard and not have to even worry about an 8x8 cursor using the fast draw code, since the draw time is now not dependent on the number of cursor mask one-bits anymore.

I will commit this now for testing, and plan on some cleanup code later, as there are still some issues seen while testing with the Watcom and C86 compilers. I temporarily added back in the original 16x16 cursor for speed comparisons with XOR drawing. The GCC version is running well and uses @Vutshi's new 11x16 cursor.

As a side note, I think we may be able to use the same-style routine to greatly increase the speed of drawing BMP scanlines. More on that later.

@ghaerr ghaerr merged commit 120ad64 into master Apr 17, 2025
1 check passed
@ghaerr ghaerr deleted the cursor4 branch April 17, 2025 05:07
@Vutshi
Copy link
Contributor

Vutshi commented Apr 17, 2025

It is fast!
Small bug: the cursor now wraps around—when you move it past the right edge of the screen, it reappears on the left.

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.

2 participants