1 ;-----------------------------------------------------------------------
\r
4 ; Point functions all MODE X 256 Color resolutions
\r
10 ; ****** XLIB - Mode X graphics library ****************
\r
11 ; ****** ****************
\r
12 ; ****** Written By Themie Gouthas ****************
\r
14 ; egg@dstos3.dsto.gov.au
\r
15 ; teg@bart.dsto.gov.au
\r
16 ;-----------------------------------------------------------------------
\r
25 ;-----------------------------------------------------------------------
\r
26 ; Mode X (256 color mode) write pixel routine.
\r
27 ; No clipping is performed.
\r
29 ; Based on code originally published in DDJ Mag by M. Abrash
\r
31 ; C near-callable as:
\r
32 ; void x_put_pix(int X, int Y, int PageOffset, int Color);
\r
37 ARG X:word,Y:word,PgOfs:word,Color:word
\r
38 push bp ;preserve caller's stack frame
\r
39 mov bp,sp ;point to local stack frame
\r
41 mov ax,[_ScrnLogicalByteWidth]
\r
42 mul [Y] ;offset of pixel's scan line in page
\r
44 shr bx,2 ;X/4 = offset of pixel in scan line
\r
45 add bx,ax ;offset of pixel in page
\r
46 add bx,[PgOfs] ;offset of pixel in display memory
\r
48 mov es,ax ;point ES:BX to the pixel's address
\r
51 and cl,011b ;CL = pixel's plane
\r
52 mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg
\r
53 shl ah,cl ;set only the bit for the pixel's
\r
55 mov dx,SC_INDEX ;set the Map Mask to enable only the
\r
56 out dx,ax ; pixel's plane
\r
58 mov al,byte ptr [Color]
\r
59 mov es:[bx],al ;draw the pixel in the desired color
\r
61 pop bp ;restore caller's stack frame
\r
65 ;-------------------------------------------------------------------------
\r
66 ; Mode X (320x240, 256 colors) read pixel routine. Works on all VGAs.
\r
67 ; No clipping is performed.
\r
69 ; Based on code originally published in DDJ Mag by M. Abrash
\r
71 ; C near-callable as:
\r
72 ; unsigned int x_get_pix(int X, int Y, unsigned int PageBase);
\r
76 ARG x:word,y:word,PageBase:word
\r
77 push bp ;preserve caller's stack frame
\r
78 mov bp,sp ;point to local stack frame
\r
80 mov ax,[_ScrnLogicalByteWidth]
\r
81 mul [Y] ;offset of pixel's scan line in page
\r
84 shr bx,1 ;X/4 = offset of pixel in scan line
\r
85 add bx,ax ;offset of pixel in page
\r
86 add bx,[PageBase] ;offset of pixel in display memory
\r
88 mov es,ax ;point ES:BX to the pixel's address
\r
91 and ah,011b ;AH = pixel's plane
\r
92 mov al,READ_MAP ;AL = index in GC of the Read Map reg
\r
93 mov dx,GC_INDEX ;set the Read Map to read the pixel's
\r
96 mov al,es:[bx] ;read the pixel's color
\r
97 sub ah,ah ;convert it to an unsigned int
\r
99 pop bp ;restore caller's stack frame
\r