2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by NotNull
0

Painting pixels, not so much tedious work.

Try MCGA mode 13h you can set this using the video bios,
if you are in 32-bit code try passing down the call to the
BIOS through the DPMI server.
AH=0000 AL=0013 INT 10h

INT 10/AH=00 Set Video Mode
10/AH=0C Write Pixel
10/AH=0D Read Pixel

If you are a 32-bit app the EGA Video Ram is located at
ulong 000A0000
or for a 16-bit app it will be located at A000:0000
You can draw pixels by directly writing to the above locations.
Each pixel's color is defined by a byte's value yielding 256 colors,
and the position of the byte in the segment defines its location
on a screen,
the pallete for these colors can be manipulated using I/O
programming.

When using a XY coordinate it needs to be turned into its
corresponding position in the video ram.
To do so for zero-base coordinates do:
Y_ROW*WIDTH+X_COL
Hence for a 320x200 pixel screen you would perform
the following calculation:
Y*320+X

I'll come back with some example code later.
Good day.

*NOTE: This all applies to DOS programs...

Edited by NotNull: n/a

0

PAINT_A_PIXEL example code...

bits 16
org 100h

start:
mov ax, 0xa000
mov es, ax
call govideo
mov bx, 0
mov cx, 0
mov dl, 0xe
call plotpixel
call waitkey

govideo:
push ax
mov ax,0013h
int 10h
pop ax
ret

waitkey:
mov ah,06
mov dl,0ffh
int 21h
jz waitkey
mov ax,0003h
int 10h
mov ax,4c00h
int 21h

plotpixel:
push dx
mov ax,320
xor dx,dx
mul bx
mov si,ax
add si,cx
pop dx
mov [es:si],dl
ret
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.