🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: maus.lang.c
Article #4

Re: PutPixel

#4
From: Hans Insulander
Date: Fri, 15 Sep 1995 10:19
30 lines
1354 bytes
larstr@stud.idb.hist.no (Lars Troen) wrote:
>Dominik Deobald (MAGICIAN@m-night.domino.de) wrote:
[snap, snap]
>: Die schnellste, die ich bisher habe ist die folgende:
>
>: char *ScreenAddr = (char*)0xA0000000;
>
>: // Schreibt einen Punkt der Farbe 'color' an die stelle 'x/y'
>: void drawxy(int x,int y,char color)
>: {
>:   *(ScreenAddr+320*y+x) = color;
>
>Es ist schneller mit 
>    *(ScreenAddr+y<<8+y<<6+x) = color;
>: }
>

Don't be so sure about that... Depends on your compiler! some compilers 
(bc4.5, watcom 10.5) will use the lea instruction. i.e.

mov eax,y
mov ebx,x
lea eax,[eax*4+eax]  ; eax=y*5
mov cl,color
shl eax,6            ; eax=y*5*64=y*320
mov [0A0000h+eax+ebx],cl ; For Watcom. Use a seg for realmode. 

which is much faster than shifting!

/H.
Technical Details
Message-ID: <43bjvq$82b@news.kth.se>
Path: arc1-ca.pugleaf.net!news.kth.se!usenet
References: <5tQJ7Qt71rB@mpware.m-night.domino.de> <431d3a$6ev@astfgl.idb.hist.no>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.kth.se!usenet
From: Hans Insulander <ib94_hin@isk.kth.se>
Newsgroups: maus.lang.c,de.comp.lang.c++,de.comp.lang.c,comp.lang.asm.x86
Subject: Re: PutPixel
Date: 15 Sep 1995 10:19:37 GMT
Organization: Student at College of Engineering
Message-ID: <43bjvq$82b@news.kth.se>
References: <5tQJ7Qt71rB@mpware.m-night.domino.de> <431d3a$6ev@astfgl.idb.hist.no>
NNTP-Posting-Host: pc450-14.isk.kth.se
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (Windows; I; 16bit)