1 ;-----------------------------------------------------------
\r
3 ; MXPI.ASM - Put image
\r
4 ; Copyright (c) 1993,1994 by Alessandro Scotti
\r
6 ;-----------------------------------------------------------
\r
13 EXTRN subClipImage : NEAR
\r
15 MX_TEXT SEGMENT USE16 PARA PUBLIC 'CODE'
\r
16 ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING
\r
18 EXTRN mx_VideoSegment : WORD
\r
19 EXTRN mx_BytesPerLine : WORD
\r
21 mxTable LABEL WORD ; Raster ops
\r
29 ;-----------------------------------------------------------
\r
32 ; Note: loops unrolled and optimized for CX even, no check for CX = 0.
\r
35 shr cx, 1 ; Make CX even
\r
36 jc @@Odd ; Special case if odd byte
\r
53 @@Loop: mov al, ds:[si]
\r
73 @@Loop: mov al, ds:[si]
\r
93 @@Loop: mov al, ds:[si]
\r
111 @@Loop: mov al, ds:[si]
\r
123 @@Loop: mov al, ds:[si]
\r
132 ;-----------------------------------------------------------
\r
134 ; Copies a "raw" image from memory to screen.
\r
137 ; Image = pointer to image
\r
138 ; X, Y = coordinates of destination
\r
139 ; Width = width of image in pixels
\r
140 ; Height = height of image in pixels
\r
141 ; Op = raster op (OP_xxx)
\r
145 mxPutImage PROC FAR
\r
151 Image:DWORD = ARG_SIZE
\r
152 LOCAL PlaneWidth:WORD:4, \
\r
153 PixelOffset:WORD, \
\r
154 MoveFunction:WORD, \
\r
158 WritePlane:BYTE = AUTO_SIZE
\r
161 .push ds, si, es, di
\r
169 jc @@Exit ; Full clipped
\r
171 add WORD PTR Image[0], si ; Skip clipped pixels
\r
173 ; Get pixel address
\r
174 mul [mx_BytesPerLine]
\r
179 mov [PixelOffset], di
\r
180 mov es, [mx_VideoSegment] ; ES:DI points to pixel
\r
182 mov [ReadPlane], bl
\r
184 ; Compute extra bytes and width count for each plane
\r
187 shr bx, 1 ; Width for each plane
\r
193 mov PlaneWidth[si], bx
\r
200 ; Setup planes for output to VGA registers
\r
201 mov cl, [ReadPlane]
\r
204 mov [WritePlane], al
\r
206 ; Install move function
\r
208 mov [OpInfo], bh ; Remember additional info if needed
\r
211 jbe @@SetMoveFunction
\r
215 mov ax, mxTable[bx]
\r
216 mov [MoveFunction], ax
\r
220 mov [Count], 4 ; Four planes
\r
221 lea bx, PlaneWidth ; SS:[BX] = width in bytes for plane
\r
222 mov ds, WORD PTR Image[2]
\r
224 cmp WORD PTR ss:[bx], 0 ; Exit if nothing more to do
\r
225 je @@Exit ; (also, never try to move zero bytes!)
\r
226 mov si, WORD PTR Image[0]
\r
227 mov ah, [WritePlane]
\r
231 out dx, ax ; Select write plane
\r
232 mov ah, [ReadPlane]
\r
236 out dx, ax ; Select read plane
\r
238 mov di, [PixelOffset]
\r
242 mov cx, WORD PTR ss:[bx] ; Number of bytes to move
\r
243 mov ah, [OpInfo] ; Transparent color for subTrans
\r
244 call [MoveFunction]
\r
247 add si, [Width] ; Go to next image line
\r
248 add di, [mx_BytesPerLine] ; Go to next screen row
\r
250 jnz @@Loop ; Repeat for all lines
\r
252 inc bx ; Select width for next plane
\r
254 rol [WritePlane], 1
\r
255 adc [PixelOffset], 0
\r
256 inc WORD PTR Image[0]
\r
258 jnz @@PlaneLoop ; Repeat for all planes
\r
262 .pop ds, si, es, di
\r