I need FAST putpixel and bar routines 
Author Message
 I need FAST putpixel and bar routines

I need some FAST routines to replace the original Putpixel, Bar and Get/putimage routines. Yes I know the
Answer is ASEMBLER, but HOW, I mean I'm no asembler programmer, please help me out.

 Dirk Manders



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

Quote:

> I need some FAST routines to replace the original Putpixel, Bar and Get/putimage routines. Yes I know the
> Answer is ASEMBLER, but HOW, I mean I'm no asembler programmer, please help me out.

>  Dirk MandersOne fast way of putpixel is mem[$A000:y*320+x] but this is different

from Pascal's putpixel in that the x goes from 0..319 and y 0..199.  
Another fast way is mem[$A000:y shl 8 + y shl 6 + x], I read this
somewhere and don't really know how much faster it would be.  I'm not
sure what you mean by bar so I can't answer that, sorry.
        Jake Richards


Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

: I need some FAST routines to replace the original Putpixel, Bar and Get/putimage routines. Yes I know the
: Answer is ASEMBLER, but HOW, I mean I'm no asembler programmer, please help me out.

:  Dirk Manders

well, i'm not sure how you would write it in assembler, but you could
change the PutPixel (change to assembler)

mem[$a000:x+(y*320)] := col;

just make it do that in asm, although i'm no asm programmer either, maybe
it would go something like (don't take as true :)

procedure AsmPutPixel(x, y : integer; col : byte);
asm
  mov   [$a000:x+(y*320)],[col]
  int 10h
end;

i hope this helps..
victor dods



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

Quote:


>: I need some FAST routines to replace the original Putpixel, Bar and
>Get/putimage routines. Yes I know the
>: Answer is ASEMBLER, but HOW, I mean I'm no asembler programmer, please help
>me out.
>:  Dirk Manders
>well, i'm not sure how you would write it in assembler, but you could
>change the PutPixel (change to assembler)
>mem[$a000:x+(y*320)] := col;

This is actually sufficiently fast in some applications, and if you use it
as a single statement (not as a procedure), you don't have the call overhead.

Quote:
>just make it do that in asm, although i'm no asm programmer either, maybe
>it would go something like (don't take as true :)

Not an ASM programmer?  Really?  It shows.  ;-)

Quote:
>procedure AsmPutPixel(x, y : integer; col : byte);
>asm
>  mov   [$a000:x+(y*320)],[col]
>  int 10h
>end;

procedure asmputpixel (x, y : word; b : byte); assembler;

asm
  mov   ax,$a000
  mov   es,ax
  mov   ax,[y]
  shl   ax,6
  mov   di,ax
  shl   ax,2
  add   di,ax
  add   di,[x]
  mov   al,[c]
  stosb
end;

That's what an assembler putpixel looks like.

Quote:
>i hope this helps..
>victor dods

--
Scott F. Earnest           | We now return you to our regularly scheduled



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines


Quote:


>>: I need some FAST routines to replace the original Putpixel, Bar and
>>Get/putimage routines. Yes I know the
>>: Answer is ASEMBLER, but HOW, I mean I'm no asembler programmer, please help
>>me out.

>>:  Dirk Manders

>>well, i'm not sure how you would write it in assembler, but you could
>>change the PutPixel (change to assembler)

>>mem[$a000:x+(y*320)] := col;

>This is actually sufficiently fast in some applications, and if you use it
>as a single statement (not as a procedure), you don't have the call overhead.

>>just make it do that in asm, although i'm no asm programmer either, maybe
>>it would go something like (don't take as true :)

>Not an ASM programmer?  Really?  It shows.  ;-)

>>procedure AsmPutPixel(x, y : integer; col : byte);
>>asm
>>  mov   [$a000:x+(y*320)],[col]
>>  int 10h
>>end;

>procedure asmputpixel (x, y : word; b : byte); assembler;

>asm
>  mov   ax,$a000
>  mov   es,ax
>  mov   ax,[y]
>  shl   ax,6
>  mov   di,ax
>  shl   ax,2
>  add   di,ax
>  add   di,[x]
>  mov   al,[c]
>  stosb
>end;

Or you can try this...

{ first, create a lookup table }
var
  count : byte;
  ScrOfs : Array[0..199] of word;
begin
  for count := 0 to 199 do
    ScrOfs[count] := count * 320;
end;

you need to create this at the start of the program

procedure putpixel(x,y : word; col : byte); assembler;
asm
  mov  ax,0a000h
  mov  es,ax
  mov  bx,[y]
  shl  bx,1
  mov  di,word ptr [ScrOfs + bx]
  add  di,[x]
  mov  al,[col]
  mov  es:[di],al
end;



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

Quote:

>Another fast way is mem[$A000:y shl 8 + y shl 6 + x], I read this

The minute you port this to DPMI it will blow up.  Use this instead:

Quote:
>Another fast way is mem[SegA000:y shl 8 + y shl 6 + x], I read this

http://www.webworldinc.com/joejared/
ftp://webworldinc.com/joejared/
--- Fidoknot v1.0



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

Quote:


>>Another fast way is mem[$A000:y shl 8 + y shl 6 + x], I read this
>The minute you port this to DPMI it will blow up.  Use this instead:
>>Another fast way is mem[SegA000:y shl 8 + y shl 6 + x], I read this
>http://www.webworldinc.com/joejared/
>ftp://webworldinc.com/joejared/
>--- Fidoknot v1.0


On my computer, the mem[$A000:x+y shl 6+y shl 8]:=c is approximately 3
times faster than the mem[$A000:x+y*320]:=c method.  However, the
fastest assembler PutPixel known (as of yet) follows... it's about 4-5
times faster than mem[$A000:x+y*320]:=c

Procedure PutPixel(X, Y : Word;  C : Byte);  Assembler;
{ code from  Jannie Hanekom  }
{ optimized by  Andreas Jung }
Asm
  mov  bx, Y
  add  bx, bx
  mov  ax, 0A000h
  mov  es, ax
  mov  bx, word ptr lut[bx]  { Note:  BX not changed within 2 cycles }
  mov  cx, x
  add  bx, cx
  mov  al, C
  mov  byte ptr es:[bx], al  { Again 1 cycle before memory move }
End;

- Samiel

http://www.fastlane.net/~samiel



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

Quote:

>>>Another fast way is mem[$A000:y shl 8 + y shl 6 + x], I read this
>>The minute you port this to DPMI it will blow up.  Use this instead:
>>>Another fast way is mem[SegA000:y shl 8 + y shl 6 + x], I read this
>On my computer, the mem[$A000:x+y shl 6+y shl 8]:=c is approximately 3
>times faster than the mem[$A000:x+y*320]:=c method.  However, the
>fastest assembler PutPixel known (as of yet) follows... it's about 4-5
>times faster than mem[$A000:x+y*320]:=c

While speed is an issue for you, a year or so from now you might have
a application requiring huge ammounts of memory.  In your current
application, it is probably fine.  As I said though, the minute you
try to use DPMI mode, it will blow up.  In terms of speed, there is a
pretty reasonable modexp.zip file on my home page, written primarily
in assembly.

http://www.webworldinc.com/joejared/
ftp://webworldinc.com/joejared/
--- Fidoknot v1.0



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines

Quote:

>On my computer, the mem[$A000:x+y shl 6+y shl 8]:=c is approximately 3
>times faster than the mem[$A000:x+y*320]:=c method.  However, the
>fastest assembler PutPixel known (as of yet) follows... it's about 4-5
>times faster than mem[$A000:x+y*320]:=c

>Procedure PutPixel(X, Y : Word;  C : Byte);  Assembler;
>{ code from  Jannie Hanekom  }
>{ optimized by  Andreas Jung }
>Asm
>  mov  bx, Y
>  add  bx, bx
>  mov  ax, 0A000h
>  mov  es, ax
>  mov  bx, word ptr lut[bx]  { Note:  BX not changed within 2 cycles }
>  mov  cx, x
>  add  bx, cx
>  mov  al, C
>  mov  byte ptr es:[bx], al  { Again 1 cycle before memory move }
>End;

Well one could make it even faster by making it an inline procedure:

Procedure PutPixel(X, Y : Word;  C : Byte);
  {asm
  pop  dx
  pop  bx
  add  bx, bx
  mov  ax, 0A000h
  mov  es, ax
  mov  bx, _lut[bx]
  pop  cx
  add  bx, cx
  mov  al, dl
  mov  es:[bx], al
  end}

  Inline($5A/$5B/$01/$DB/$B8/$00/$A0/$8E/$C0/$8B/$9F/LUT/$59/$01/$CB/
         $8A/$C2/$26/$88/$07);

That takes 23 s on my 386DX40 instead of 47 s that the assembler
procedure version takes.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 I need FAST putpixel and bar routines


Quote:

>That takes 23 s on my 386DX40 instead of 47 s that the assembler
>procedure version takes.

Oops, those are 2.3 s and 4.7 s respectively.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. putpixel routine..help to make faster

2. I need a fast putpixel for 640x480x16 !

3. Need help with this VESA PutPixel routine please!

4. Need Putpixel routine with r,g,b header

5. Vesa Mouse Unit Needed (or putpixel routine)

6. Need fast putpixel-sequence for TP

7. Need fast putpixel-sequence for TP

8. Need help on a fast putpixel for 640x480x256

9. I need a fast Putpixel for 640x480x16

10. Need a (very) fast write-routine for the full screen

 

 
Powered by phpBB® Forum Software