Mail Archives: djgpp/1997/08/18/18:51:42
Message-ID: | <33F8B04B.AEC7D9AF@ecr.net>
|
Date: | Mon, 18 Aug 1997 16:27:56 -0400
|
From: | Jesse Legg <snowcrash AT ecr DOT net>
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | inline asm putpixel routine using table
|
NNTP-Posting-Host: | 207.40.127.216
|
Lines: | 54
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi, I've been working with writing my own graphics routines in DJGPP
using mostly inline asm. My only references are a couple of (old) Pascal
files and some non-protected mode assembler texts as well as various
DJGPP graphics programming docs which give slow examples for my
taste! I have converted several putpixel routines to inline assembly but
in
effort to get even faster =) I am attempting to pre-calc 320*y into an
array (globally defined, btw) to eliminate the multiplication step...
here is
my function:
void _setpixel(int x, int y, char col) {
__asm__ __volatile__ ("
movw %3, %%es
addl %0, %%edi
movl %1, %%ebx
addl %%ebx, %%ebx
addl %%ds:_screen_y(%%ebx), %%edi
movb %%al, %%es:(%%edi)"
: /* no outputs */
: "g" (x), "g" (y), "a" (col), "g" (_dos_ds), "D" (0xA0000)
: "eax", "ebx", "edi"); }
Now the part that is baffling me... this works when you set a pixel with
and EVEN numbered Y coordinate but it only plots the X-coordinate
accurately (ie. Y is in the wrong place). When you attempt to set a
pixel
with an odd numbered Y-coordinate it crashes(!?). I am new to assembly
and have been able to figure out several other problems I've had but
this
seems crazy (though i'm sure obvious to you pros)! =)
Can someone please explain this for me?? (i'm dying to understand!!)
Also, I initialize the 'int screen_y[199]' array like this:
void calc_screen_y(int width)
{
int i;
for (i =0; i < 200; i++)
screen_y[i] = i*width;
}
I'm working in mode 13h and call calc_screen_y(320); right after
initializing the video card (at the begining of the program).
Anyone who can help, MUCH THANKS in advance! :)
--
_/_jesse___________________________________________________
"The Adventures of Batman and Robin is rated TV-Y7
because it is a Super Heroe Action Drama."
-- Fox Kid's show introduction
- Raw text -