1 ;-----------------------------------------------------------
\r
3 ; MXGI.ASM - Get image
\r
4 ; Copyright (c) 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 ;-----------------------------------------------------------
\r
23 ; Copies an image from screen to memory.
\r
26 ; Image = pointer to buffer for image
\r
27 ; X, Y = coordinates of image on screen
\r
28 ; Width = width of image in pixels
\r
29 ; Height = height of image in pixels
\r
38 Image:DWORD = ARG_SIZE
\r
39 LOCAL PlaneWidth:WORD:4, \
\r
41 MoveFunction:WORD, \
\r
43 Count:BYTE = AUTO_SIZE
\r
46 .push ds, si, es, di
\r
54 jc @@Exit ; Full clipped
\r
56 add WORD PTR Image[0], si ; Skip clipped pixels
\r
59 mul [mx_BytesPerLine]
\r
64 mov [PixelOffset], si
\r
65 mov ds, [mx_VideoSegment] ; DS:SI points to pixel
\r
69 ; Compute extra bytes and width count for each plane
\r
72 shr bx, 1 ; Width for each plane
\r
78 mov PlaneWidth[di], bx
\r
87 mov [Count], 4 ; Four planes
\r
88 lea bx, PlaneWidth ; SS:[BX] = width in bytes for plane
\r
89 mov es, WORD PTR Image[2] ; ES:DI will point to image
\r
92 cmp WORD PTR ss:[bx], 0 ; Exit if nothing more to do
\r
93 je @@Exit ; (also, never try to move zero bytes!)
\r
94 mov di, WORD PTR Image[0]
\r
97 out dx, ax ; Select read plane
\r
99 mov si, [PixelOffset] ; DS:SI points to video memory
\r
102 mov cx, WORD PTR ss:[bx] ; Number of bytes to move
\r
109 add di, [Width] ; Go to next image line
\r
110 add si, [mx_BytesPerLine] ; Go to next screen row
\r
112 jnz @@Loop ; Repeat for all lines
\r
114 inc bx ; Select width for next plane
\r
116 test ah, 04h ; Plane wraparound?
\r
118 inc [PixelOffset] ; Yes, bump video pointer
\r
121 inc WORD PTR Image[0]
\r
123 jnz @@PlaneLoop ; Repeat for all planes
\r
127 .pop ds, si, es, di
\r