I'm using VESA modes 10Eh and 111h. In real mode bank switching is slow, but a necessary evil. So, instead of calling the ISR via an interrupt I figured that a far call would be faster.
Obviously I was wrong. Why is the far call slower than the interrupt when interrupts are known for being notoriously slow?
Here is my code:
so for bank switch:
void far (*VideoINT)();
void far *ISR;
(void far *)VideoInt=(void far *)ISR;
... //this portion sets up the rendering system
... //Not relevant to question, didn't include
If I was to replace call VideoINT with int 10h, the entire function is faster.
void PlotPixel(DWORD offset,WORD color)
static WORD bank;
WORD actualoffset=offset & 0xFFFF;
push dx //Preserve dx across call
call VideoINT //far call to int 10 based on int vector table
mov [bank],dx //Set bank to curbank
This does not make sense to me. It is faster to plot pixels via a far pointer than to use an ISR to do so. Why isn't it faster to call the INT 10 ISR instead of invoking it via an interrupt? I thought this would be a way to circumvent the slow bank switch interrupt call, but I guess not.
I'm also only specifying 0 in BX because it is too slow to call or invoke the ISR twice for 0 and 1. Besides, it works fine just using 0, so I left it.
Never mind....I'm so careless. In my actual code I forgot to preserve dx across the call. So when I called the ISR, dx was obviously changed. When I assigned dx to curbank, dx did not really represent the correct bank. This forced a bank switch on every single pixel (hitting myself in the head). Sorry everyone, but I figured it out amidst writing this.
Well, anyways, this is a fast plot pixel function for VESA modes.
For those that don't like or know assembly (mine is far from perfect) this can be done in C as well.