Reading Pixels in Asm 
Author Message
 Reading Pixels in Asm

Help!
I'm trying to write a function to return the colour of a specified pixel.
I am new to assembly language (I program in C) and am having a terrible time
trying to figure out how to do it (the C version is only one line).
This is what I've got so far:

char GetPix(int x, int y)
{
 char thecolour;  
 asm {
      mov ax, y       // set ax to y
      mov bx, y       // set bx to y
      shl ax, 8       // shift ax's y by 8  (y*256)
      shl bx, 6       // shift bx's y by 6  (y*64)
      add bx,ax       // add them together into bx  (y*320 in total)
      add bx, x       // and add the x
      les di, video_buffer      // I think this might be somewhere close????
      mov thecolour, es:[di+bx] // this doesn't work
     }
 return thecolour;

Quote:
}

'video_buffer' is a pointer to 0xA0000000l, which I know is the starting
address of the video buffer in the screen mode I use (13h).

Please email any answers - I'd be very grateful.

--

(Chris Russell)
http://www.*-*-*.com/



Thu, 18 Feb 1999 03:00:00 GMT  
 Reading Pixels in Asm

Quote:

>Help!
>I'm trying to write a function to return the colour of a specified pixel.
>I am new to assembly language (I program in C) and am having a terrible time
>trying to figure out how to do it (the C version is only one line).
>This is what I've got so far:

I assume you are using real mode. Instead of the les di you could use
mov ax,a000h mov es,ax and skip using di at all. The address is
a000:0000. If you are using Watcom in flat model then the address
would be a0000.

By the way, Our names are almost the same. My name is Chris Rossall :)



Sun, 28 Feb 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Win32 ASM programming of Sound and Painting to screen Pixel by pixel

2. Win32 ASM programming of Sound and Painting to screen Pixel by pixel

3. Search algorithm to decrunch Monochrom BMP's(1 Bit = 1 Pixel) (ASM code)

4. Fastest ASM to plot a pixel in a drawing buffer

5. Reading VBE SVGA pixel values

6. read SVGA pixel values

7. Reading VBE SVGA pixel values

8. Reading the color of a pixel in mode 13h

9. Direct pixel-by-pixel drawing (with Tk)

10. ALL SKILLED ASM PROGRAMMERS READ!

11. x86 ASM FAQ - Read First

12. C/ASM reading from memory

 

 
Powered by phpBB® Forum Software