]> 4ch.mooo.com Git - 16.git/blob - 16/xx/mxgm.asm
push
[16.git] / 16 / xx / mxgm.asm
1 ;-----------------------------------------------------------\r
2 ;\r
3 ; MXGM.ASM - Gamma correction\r
4 ; Copyright (c) 1994 by Alessandro Scotti\r
5 ;\r
6 ;-----------------------------------------------------------\r
7 WARN    PRO\r
8 INCLUDE MODEX.DEF\r
9 \r
10 PUBLIC  mxGammaCorrect\r
11 \r
12 MX_TEXT         SEGMENT USE16 PARA PUBLIC 'CODE'\r
13                 ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING\r
14 \r
15 mx_tblGamma     LABEL BYTE\r
16     DB  00, 10, 14, 17, 19, 21, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34\r
17     DB  35, 36, 37, 37, 38, 39, 40, 41, 41, 42, 43, 44, 44, 45, 46, 46\r
18     DB  47, 48, 48, 49, 49, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55\r
19     DB  56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63\r
20 \r
21 ;-----------------------------------------------------------\r
22 ;\r
23 ; Correct palette colors (gamma is 2.3).\r
24 ;\r
25 ; Input:\r
26 ;       CPal    = pointer to color palette\r
27 ;       GPal    = pointer to destination (gamma corrected) palette\r
28 ;       Count   = number of colors to convert\r
29 ; Output:\r
30 ;       none\r
31 ;\r
32 ; Note: CPal and GPal may point to the same buffer.\r
33 ;\r
34 mxGammaCorrect  PROC    FAR\r
35         ARG     Count:WORD,     \\r
36                 DPal:DWORD,     \\r
37                 SPal:DWORD      = ARG_SIZE\r
38         ASSUME  ds:NOTHING\r
39         .enter  0\r
40         .push   ds, si, es, di\r
41 \r
42         mov     cx, [Count]\r
43         jcxz    @@Exit                  ; Exit now if nothing to do\r
44         lds     si, [SPal]\r
45         les     di, [DPal]\r
46         mov     bx, OFFSET mx_tblGamma  ; Setup BX for XLAT instruction\r
47         cld\r
48         mov     ax, cx                  ; AX = Count\r
49         add     cx, cx                  ; CX = Count*2\r
50         add     cx, ax                  ; CX = Count*3\r
51 @@Loop:\r
52         lodsb\r
53         xlat    mx_tblGamma\r
54         stosb\r
55         loop    @@Loop\r
56 \r
57 @@Exit:\r
58         .pop    ds, si, es, di\r
59         .leave  ARG_SIZE\r
60 mxGammaCorrect  ENDP\r
61 \r
62 MX_TEXT         ENDS\r
63 END\r