TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: LEIGH MORRESI
from: SAM IZZO
date: 1997-10-02 17:22:00
subject: Re: VGA coding.... SpEEED!

 -=> Quoting Leigh Morresi to All <=-
 LM> Ive been dabbing a little in the mistic world of ASM coding...
 LM> basicly what I wanna do is to place a pixel at position X and Y on a
 LM> 320x200 (VGA) screen. Like So......
Ahh, the infamous 'my putpixel is faster than yours' saga, yet again =P
 LM> MOV      AX,0A000h
 LM> MOV      ES,AX
 LM> MOV      DI,0   <--------- OFFSET
 LM> MOV      SI,offset ImageData <------ VALUE
 LM> MOV      CX,2000 <--- NUMBER OF BYTES TO COPY
 LM> CLD      <-- INCREASE SI POINTER
 LM> REP   MOVSW <--- COPY TO MEMORY
But if all you want to do is place a pixel on the screen, why do any of this?
 LM> Could soembody post a good routine that you use in your demo
 LM> or game coding that will help me out here? PLEASE!....
Mmm.. Remember that you don't always need a putpixel.. If possible, try to
incorporate the write to video memory into the routine, unless you're just
drawing a dot-cube or something similar..
But! Drawing a pixel.. To get the offset, you could use a lookup table of
Y*320 values.. The LEA trick _I think_ is best used in protected mode, 
ecause
it makes use of 32-bit registers, and it's slow using these in real mode.  
o,
a putpixel.  This is how one might do it (without a lookup table):
mov ax, 0a000h
mov es, ax
mov di, x
mov ah, y
add di, ax
shr ax, 2
add di, ax
mov al, col
mov es:[di], al
Of course, if you write to a buffer instead of straight to video memory, 
you'll
need to clear al before loading ah with y.
With a lookup table:
mov ax, 0a000h
mov es, ax
mov bx, y
shl bx, 1
mov di, x
add di, word ptr lookup[bx]
mov al, col
mov es:[di], al
and of course lookup is an array of words:
For Y = 0 to 199
Begin
     Lookup[Y] = Y*320
End
So there you go!
Sam
... FOR SALE: Two hilarious taglines, never used.  Asking $30 each.
--- FMail/386 1.20+
---------------
* Origin: Comms Barrier BBS +61.3.9585.1112, +61.3.9583.6119 (3:632/533)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.