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