Mail Archives: djgpp/1997/08/18/19:50:14
Hi Jesse,
On Mon, 18 Aug 1997, Jesse Legg wrote:
> 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
[snipped and rearranged a bit]
> 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;
> }
That should be int screen_y[200], otherwise with y=199 you'll overrun the
array.
> void _setpixel(int x, int y, char col) {
> __asm__ __volatile__ ("
> movw %3, %%es
> addl %0, %%edi
> movl %1, %%ebx
> addl %%ebx, %%ebx
Problem here is that we are dealing with a 32-bit compiler so the size of
'int' is 32-bits. So to get the right offset to the screen_y array, you need
to multiply y by 4, not by 2:
shll $2, %%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"); }
Hope this helps,
Samppa
Samuli Takala Samuli DOT Takala AT hut DOT fi finger -l tax AT hut DOT fi for long version
- Raw text -