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 [BP+6] ;offset of pixel's scan line in page
\r
44 shr bx,1 ;X/4 = offset of pixel in scan line
\r
45 shr bx,1 ;X/4 = offset of pixel in scan line
\r
46 add bx,ax ;offset of pixel in page
\r
47 add bx,[BP+8] ;offset of pixel in display memory
\r
49 mov es,ax ;point ES:BX to the pixel's address
\r
51 mov cl,byte ptr [BP+4]
\r
52 and cl,011b ;CL = pixel's plane
\r
53 mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg
\r
54 shl ah,cl ;set only the bit for the pixel's
\r
56 mov dx,SC_INDEX ;set the Map Mask to enable only the
\r
57 out dx,ax ; pixel's plane
\r
59 mov al,byte ptr [BP+10]
\r
60 mov es:[bx],al ;draw the pixel in the desired color
\r
62 pop bp ;restore caller's stack frame
\r
66 ;-------------------------------------------------------------------------
\r
67 ; Mode X (320x240, 256 colors) read pixel routine. Works on all VGAs.
\r
68 ; No clipping is performed.
\r
70 ; Based on code originally published in DDJ Mag by M. Abrash
\r
72 ; C near-callable as:
\r
73 ; unsigned int x_get_pix(int X, int Y, unsigned int PageBase);
\r
77 ;ARG x:word,y:word,PageBase:word
\r
78 push bp ;preserve caller's stack frame
\r
79 mov bp,sp ;point to local stack frame
\r
81 mov ax,[_ScrnLogicalByteWidth]
\r
82 mul [bp+6] ;offset of pixel's scan line in page
\r
85 shr bx,1 ;X/4 = offset of pixel in scan line
\r
86 add bx,ax ;offset of pixel in page
\r
87 add bx,[bp+8] ;offset of pixel in display memory
\r
89 mov es,ax ;point ES:BX to the pixel's address
\r
91 mov ah,byte ptr [bp+4]
\r
92 and ah,011b ;AH = pixel's plane
\r
93 mov al,READ_MAP ;AL = index in GC of the Read Map reg
\r
94 mov dx,GC_INDEX ;set the Read Map to read the pixel's
\r
97 mov al,es:[bx] ;read the pixel's color
\r
98 sub ah,ah ;convert it to an unsigned int
\r
100 pop bp ;restore caller's stack frame
\r