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