Mail Archives: djgpp/1998/01/07/18:02:26
I'm in the middle of writing an all encompassing game library in
DJGPP+NASM but I keep getting crashes for no apparent reason.
Specifically I KNOW there is a problem with this function for
drawing a vertical line. In works in an arbitrary video mode, the
width and height being contained in vidCurrentWidth and
vidCurrentHeight. The max window coords are in vidMaxX and vidMaxY.
It works for a few 100 lines and then gets a SIGSEGV anyone got
any ideas?
;
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
; gfxVline : Draws a vertical line in a single colour
;
; void gfxVline(int x, int y1, int y2, UCHAR col, UCHAR *where);
;
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
_gfxVline:
push ebp
mov ebp, esp
mov ebx, [ebp + 8] ; \
cmp ebx, 0 ; |
jl .endit ; |>--- check x clipping
cmp ebx, [_vidMaxX] ; |
jg .endit ; /
mov eax, [ebp + 12] ; \
mov ecx, [ebp + 16] ; |
cmp ecx, eax ; |\___ check that ecx is bottom
y
jg .dontxchg ; |/
xchg ecx, eax ; |
.dontxchg: ; /
cmp ecx, 0 ; \
jl .endit ; |___ check y clipping
cmp eax, [_vidMaxY] ; |
jg .endit ; /
cmp eax, 0 ; \
jnl .notopclip ; |
xor eax, eax ; |
.notopclip: ; |\____ clip line to screen
cmp ecx, [_vidMaxY] ; |/
jng .nobottomclip ; |
mov ecx, [_vidMaxY] ; |
.nobottomclip: ; /
mov edi, [ebp + 24] ; \
add edi, ebx ; |
mov ebx, [_vidCurrentWidth] ; |\
sub ecx, eax ; ||--- setup destination and
copy
xor edx, edx ; |/
mul ebx ; |
add edi, eax ; |
mov eax, [ebp + 20] ; /
.loopstart: ; \
mov [edi], al ; |___ draw the line
add edi, ebx ; |
loop .loopstart ; /
.endit:
pop ebp
ret
-Richard
--
.------------------------------+--------------------------------.
| Richard Nichols | Inspire Media (Demos/Games) |
| mailto:tiberius AT mailhost DOT net | mailto:InspireMedia AT post1 DOT com |
| http://tiberius.home.ml.org/ | http://inspire.home.ml.org/ |
+------------------------------+--------------------------------+
| Organizer, coder for Inspire Media |
`---------------------------------------------------------------'
"The life of the coder is that of the hermit, except
the hermit can't make shadebobs." -- Leviathan
- Raw text -