home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / EGA_VGA / EGACOLRS.ZIP / PALET.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-10-30  |  5.9 KB  |  114 lines

  1. ;════════════════════════════════════════════════════════════════════════════╗
  2. ; PALETTE()                                                                  ║
  3. ; Paul V. Slabowski                                                          ║
  4. ; October 28, 1988                                                           ║
  5. ;                                                                            ║
  6. ; Set the current palette on an EGA machine to make use of all 64 of those   ║
  7. ; pretty colors...16 at a time, of course.                                   ║
  8. ;                                                                            ║
  9. ; PALETTE(Color_attribute_to_replace, EGA_color_to_replace_it_with)          ║
  10. ;                                                                            ║
  11. ; ex: PALETTE(3,27)                                                          ║
  12. ;════════════════════════════════════════════════════════════════════════════╝
  13.  
  14. PUBLIC PALETTE                            ; Declare this function public
  15.  
  16. EXTRN     __PARINFO:FAR                   ; Declare far functions
  17. EXTRN     __PARNI:FAR                     ;          ·
  18. EXTRN     __RET:FAR
  19.  
  20. DGROUP    GROUP     DATASG                ; Combine data with Clipper's
  21.  
  22. DATASG    SEGMENT   'DATA'                ; Start of Data segment
  23.  
  24.      attrb          DB     0              ; Color parm 1 as-sent <Integer>
  25.      colr           DB     0              ; Color parm 2 as-sent <Integer>
  26.  
  27. DATASG    ENDS                            ;End of Data
  28.  
  29. _PLETT    segment   byte   'PROG'
  30.      ASSUME     cs:_PLETT, ds:DGROUP
  31.  
  32. PALETTE   PROC  FAR
  33.  
  34.     setup:      push    bp                ; Save registers
  35.                 mov     bp,sp             ;       ·
  36.                 push    ds                ;       ·
  37.                 push    es                ;       ·
  38.                 push    si                ;       ·
  39.                 push    di                ;       ·
  40.  
  41.     parnumb:    mov     ax, 0             ; Set up call for # of params
  42.                 push    ax                ;       ·
  43.                 call    __PARINFO         ; Call Clipper function to get
  44.                                           ;    # of params into ax
  45.                 add     sp, 2             ; restore stack
  46.                 cmp     ax, 2             ; If # of parameters sent was,
  47.                 jne     quit              ;    not 2, then quit here,
  48.                                           ;    otherwise...
  49.  
  50.     getpar1:    mov     ax, 1             ; Put 1 in ax to point to 1st parm
  51.                 push    ax                ; Push value of 1 onto stack
  52.                 call    __PARINFO         ; Call Clipper function to test for
  53.                                           ; numeric parameter
  54.                 add     sp, 2             ; restore stack
  55.                 cmp     ax, 2             ; If param is not numeric...
  56.                 jne     quit              ;     then quit here, otherwise...
  57.                 mov     ax, 1             ; Place 1 into ax to get parm 1
  58.                 push    ax                ; Push value of 1 onto the stack
  59.                 call    __PARNI           ; Call Clipper Function to get
  60.                                           ;     actual parameter into ax
  61.                 add     sp, 2             ; Restore stack
  62.  
  63.     testng1:    cmp     ax, 0             ; If attrb >= 0 then cont-
  64.                 jge     testhi1           ;     inue, otherwise...
  65.                 jmp     quit              ; quit
  66.  
  67.     testhi1:    cmp     ax, 15            ; If attrb <= 15 then
  68.                 jle     getpar2           ;     continue, otherwise...
  69.                 jmp     quit              ; quit
  70.  
  71.     getpar2:    mov     attrb, al         ; Save the attrb parameter
  72.                 mov     ax, 2             ; Put 2 in ax to point to 2nd parm
  73.                 push    ax                ; Push value of 2 onto stack
  74.                 call    __PARINFO         ; Call Clipper function to test for
  75.                                           ; numeric parameter
  76.                 add     sp, 2             ; restore stack
  77.                 cmp     ax, 2             ; If param is not numeric...
  78.                 jne     quit              ;     then quit here, otherwise...
  79.                 mov     ax, 2             ; Place 2 into ax to get parm 2
  80.                 push    ax                ; Push value of 2 onto the stack
  81.                 call    __PARNI           ; Call Clipper Function to get
  82.                                           ;     actual parameter into ax
  83.                 add     sp, 2             ; Restore stack
  84.  
  85.     testng2:    cmp     ax, 0             ; If colr >= 0 then cont-
  86.                 jge     testhi2           ;     inue, otherwise...
  87.                 jmp     quit              ; quit
  88.  
  89.     testhi2:    cmp     ax, 63            ; If colr <= 63 then
  90.                 jle     doscall           ;     continue, otherwise...
  91.                 jmp     quit              ; quit
  92.  
  93.     doscall:    mov     colr, al          ; Save the colr parameter
  94.                 mov     ah, 10h           ; Load registers for DOS call
  95.                 mov     al, 0             ; Set palette register function
  96.                 mov     bh, colr          ; Color to use
  97.                 mov     bl, attrb         ; Attribute to use this color
  98.                 int     10h               ; Call to BIOS:Video Drivers
  99.  
  100.     quit:       pop     di                ; Restore registers
  101.                 pop     si                ;         ·
  102.                 pop     es                ;         ·
  103.                 pop     ds                ;         ·
  104.                 pop     bp                ;         ·
  105.  
  106.     clean:      call    __RET             ; Call Clipper function for return
  107.                 ret                       ; Actual return
  108.  
  109. PALETTE         ENDP                      ; End of process
  110.  
  111. _PLETT  ENDS
  112.         END
  113.  
  114. ; eof palette.asm