home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / graf / fract5.zip / FR8514A.ASM < prev    next >
Assembly Source File  |  1989-12-18  |  6KB  |  392 lines

  1.  
  2.  
  3. IFDEF ??version
  4.     MASM51
  5.     QUIRKS
  6. ENDIF
  7.  
  8.     .MODEL  medium,c
  9.  
  10.     .8086
  11.  
  12.  
  13.  
  14. HOPEN    equ    8
  15. HINT    equ    16
  16. HLDPAL    equ    19
  17. HBBW    equ    21
  18. HBBR    equ    23
  19. HBBCHN    equ    24
  20. HQMODE    equ    29
  21. HCLOSE    equ    34
  22. HINIT    equ    48
  23. HSYNC    equ    49
  24. HSPAL    equ    57
  25. HRPAL    equ    58
  26.  
  27.  
  28. .DATA
  29.  
  30.     extrn    xdots:word, ydots:word    ; number of dots across and down
  31.     extrn    dacbox:byte, daccount:word
  32.  
  33. afiptr        dd    0
  34.  
  35. xadj        dw    0
  36. yadj        dw    0
  37.  
  38. extrn        paldata:byte        ; 1024-byte array (in GENERAL.ASM)
  39.  
  40. extrn        stbuff:byte        ; 415-byte array (in GENERAL.ASM)
  41.  
  42. linedata    db    0
  43.  
  44. hopendata    db    3, 0, 0, 0, 0
  45. hclosedata    dw    2, 0
  46. hinitdata    dw    2, 0
  47. bbw        dw    10, 8, 0, 0, 0, 0
  48. bbr        dw    12, 8, 0, 0, 0, 0, 0
  49. chn        dw    6
  50.         dd    linedata
  51.         dw    1
  52. pal        dw    10, 0, 0, 256
  53.         dd    paldata
  54. hidata        dw    4, 0, 8000h
  55. amode        dw    18, 9 dup(?)
  56.  
  57. ;svpaldata    dw    769
  58. ;        db    769 dup(?)
  59.  
  60. oops        db    13,10
  61.         db    "Couldn't find the 8514/A interface"
  62.         db    13,10
  63.         db    "(Maybe you forgot to load HDIDLOAD)"
  64.         db    13,10
  65.         db    "$"
  66.  
  67. .CODE
  68.  
  69.     public    
  70.  
  71.  
  72. callafi proc    near
  73.  
  74.     push    ds        ; Pass the parameter pointer
  75.     push    si
  76.  
  77.     shl    ax,1        ; form offset from entry no. required
  78.     shl    ax,1
  79.     mov    si,ax
  80.  
  81.     les    bx, afiptr    ; entry block address to es:bx
  82.     call    dword ptr es:[bx][si]     ; call entry point
  83.  
  84.     ret            ; return to caller
  85.  
  86. callafi endp
  87.  
  88.  
  89.  
  90.  
  91. getafi    proc    near
  92.  
  93.  
  94.     mov    ax,357fh    ; read interrupt vector 7f
  95.     int    21h
  96.     mov    ax,es
  97.     or    ax,bx        ; is 7f vector null
  98.     stc
  99.     jz    getafiret
  100.  
  101.     mov    ax,0105h    ; get Interface address
  102.     int    7fh        ; by software interrupt 7f
  103.  
  104.     jc    getafiret        ; Interface not OK if carry set
  105.  
  106.     mov    word ptr afiptr,dx    ; save afi pointer offset
  107.     mov    word ptr afiptr+2,cx    ; save afi pointer segment
  108.  
  109.     clc            ; clear carry flag
  110.  
  111. getafiret:
  112.     ret            ; return to caller
  113.  
  114. getafi endp
  115.  
  116.  
  117. do85open proc    near
  118.  
  119.     push    ax
  120.     mov    ax, HOPEN
  121.     call    callafi
  122.  
  123.     mov    ax, offset stbuff    ;get the state segment
  124.     add    ax, 15
  125.     mov    cl, 4
  126.     shr    ax, cl
  127.  
  128.     mov    bx, ds
  129.     add    ax, bx
  130.  
  131.     mov    si, offset hinitdata
  132.     mov    [si] + 2, ax
  133.  
  134.     pop    ax
  135.     call    callafi
  136.  
  137.     clc
  138.     ret
  139.  
  140. do85open    endp
  141.  
  142.  
  143. open8514    proc    far
  144.  
  145.     call    getafi        ;get adapter interface
  146.     jc    afinotfound
  147.  
  148. ;    mov    si, offset svpaldata
  149. ;    mov    ax, HSPAL
  150. ;    call    callafi
  151.  
  152.     mov    bl, 0        ;if > 640 x 480 then 1024 x 768
  153.  
  154.     mov    ax, xdots
  155.     cmp    ax, 640
  156.     ja    setupopen
  157.  
  158.     mov    ax, ydots
  159.     cmp    ax, 480
  160.     ja    setupopen
  161.  
  162.     inc    bl
  163.  
  164. setupopen:
  165.  
  166.     mov    si, offset hopendata    ;open the adapter
  167.     mov    byte ptr [si + 2], 40h        ;zero the image but leave pallette
  168.     mov    [si + 3], bl
  169.     mov    ax, HINIT        ;initialize state
  170.  
  171.     call    do85open
  172.     jc    afinotfound
  173.  
  174.     mov    si, offset amode    ;make sure on the size
  175.     mov    ax, HQMODE        ;get the adapter mode
  176.     call    callafi
  177.  
  178.     mov    ax, amode + 10        ;get the screen width
  179.     cmp    ax, xdots
  180.     jae    xdotsok               ;check for fit
  181.     mov    xdots, ax
  182. xdotsok:
  183.     sub    ax, xdots        ;save centering factor
  184.     shr    ax, 1
  185.     mov    xadj, ax
  186.  
  187.     mov    ax, amode + 12        ;get the screen height
  188.     cmp    ax, ydots
  189.     jae    ydotsok
  190.     mov    ydots, ax
  191. ydotsok:
  192.     sub    ax, ydots
  193.     shr    ax, 1
  194.     mov    yadj, ax
  195.     clc
  196.     ret
  197.  
  198. afinotfound:                ; No 8514/A interface found
  199.     mov    ax,03h            ; reset to text mode
  200.     int    10h
  201.     mov    dx,offset oops        ; error out
  202.     mov    ah,9            ; sending the message
  203.     int    21h
  204.     mov    ax,4c00h        ; end the program
  205.     int    21h
  206.     ret                ; should never get here!
  207.  
  208. open8514    endp
  209.  
  210. reopen8514    proc    far
  211.  
  212.     mov    si, offset hopendata    ;open the adapter
  213.     mov    byte ptr [si + 2], 0C0h        ;zero the image but leave pallette
  214.     mov    ax, HSYNC        ;initialize state
  215.     call    do85open
  216.     ret
  217.  
  218. reopen8514    endp
  219.  
  220.  
  221. close8514    proc    far
  222.  
  223.     mov    si, offset hclosedata        ;turn off 8514a
  224.     mov    ax, HCLOSE
  225.     call    callafi
  226.     
  227. ;    mov    si, offset svpaldata        ;restore the pallette
  228. ;    mov    ax, HRPAL
  229. ;    call    callafi
  230.  
  231.     ret
  232.  
  233. close8514    endp
  234.  
  235.  
  236.  
  237.  
  238. fr85wdot    proc    far
  239.  
  240.     mov    linedata, al
  241.  
  242.     mov    bbw + 4, 1        ;define the rectangle
  243.     mov    bbw + 6, 1
  244.     add    cx, xadj
  245.     add    dx, yadj
  246.     mov    bbw + 8, cx
  247.     mov    bbw + 10, dx
  248.     mov    si, offset bbw
  249.     mov    ax, HBBW
  250.     call    callafi
  251.  
  252.     mov    si, offset chn
  253.     mov    word ptr [si + 2], offset linedata
  254.     mov    word ptr [si + 6], 1    ;send the data
  255.  
  256.     mov    ax, HBBCHN
  257.     call    callafi
  258.  
  259.     ret
  260.  
  261. fr85wdot    endp
  262.  
  263.  
  264. fr85wbox    proc    far
  265.  
  266.     add    ax, xadj
  267.     add    bx, yadj
  268.     mov    chn + 2, si        ;point to data
  269.     mov    bbw + 4, cx        ;define the rectangle
  270.     mov    bbw + 6, dx
  271.     mov    bbw + 8, ax
  272.     mov    bbw + 10, bx
  273.     mov    ax, dx
  274.     mul    cx
  275.     mov    chn + 6, ax
  276.  
  277.     mov    si, offset bbw
  278.     mov    ax, HBBW
  279.     call    callafi
  280.  
  281.     mov    si, offset chn
  282.     mov    ax, HBBCHN
  283.     call    callafi
  284.  
  285.     ret
  286.  
  287. fr85wbox    endp
  288.  
  289.  
  290. fr85rdot    proc    far
  291.  
  292.  
  293.     mov    bbr + 4, 1        ;define the rectangle
  294.     mov    bbr + 6, 1
  295.     add    cx, xadj
  296.     add    dx, yadj
  297.     mov    bbr + 10, cx
  298.     mov    bbr + 12, dx
  299.     mov    si, offset bbr
  300.     mov    ax, HBBR
  301.     call    callafi
  302.  
  303.     mov    chn, 1            ;get the data
  304.     mov    si, offset chn
  305.     mov    ax, HBBCHN
  306.     call    callafi
  307.  
  308.  
  309.     mov    al, linedata
  310.  
  311.  
  312.     ret
  313.  
  314. fr85rdot    endp
  315.  
  316. w8514pal    proc    far
  317.  
  318.     mov    si, offset dacbox
  319.  
  320.     mov    cx, daccount    ;limit daccount to 128 to avoid fliker
  321.     cmp    cx, 128
  322.     jbe    countok
  323.  
  324.     mov    cx, 128
  325.     mov    daccount, cx
  326.  
  327. countok:                ;now build 8514 pallette
  328.     mov    ax, 256            ;from the data in dacbox
  329.     mov    pal + 4, 0
  330.     mov    di, offset paldata
  331.     cld
  332. cpallp:
  333.     push    ax                 ;do daccount at a time
  334.     mov    dx, di
  335.     cmp    ax, cx
  336.     jae    dopass
  337.     mov    cx, ax
  338. dopass:
  339.     mov    pal + 6, cx        ;entries this time
  340.     push    cx
  341. cpallp2:
  342.     push    ds            ;pallette format is r, b, g
  343.     pop    es            ;0 - 255 each
  344.  
  345.     lodsb                ;red
  346.     shl    al, 1
  347.     shl    al, 1
  348.     stosb
  349.     lodsb                ;green
  350.     shl    al, 1
  351.     shl    al, 1
  352.     xchg    ah, al
  353.     lodsb                ;blue
  354.     shl    al, 1
  355.     shl    al, 1
  356.     stosw
  357.     mov    al, 0            ;filler
  358.     stosb
  359.     loop    cpallp2
  360.  
  361.     push    si
  362.     push    di
  363.     push    dx
  364.  
  365.     mov    si, hidata        ;wait for flyback
  366.     mov    ax, HINT
  367.     call    callafi
  368.  
  369.     pop    dx
  370.     mov    pal + 8, dx
  371.     
  372.     mov    si, offset pal        ;load this piece
  373.     mov    ax, HLDPAL
  374.     call    callafi
  375.  
  376.     pop    di
  377.     pop    si
  378.     pop    cx
  379.     add    pal + 4, cx        ;increment the pallette index
  380.     pop    ax
  381.     sub    ax, cx
  382.     jnz    cpallp
  383.  
  384.  
  385.     ret
  386.  
  387. w8514pal    endp
  388.  
  389.  
  390.     end
  391.  
  392.