home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume11 / gnuplot2 / part12 < prev    next >
Encoding:
Text File  |  1990-03-25  |  25.2 KB  |  1,204 lines

  1. Newsgroups: comp.sources.misc
  2. organization: Pixar -- Marin County, California
  3. subject: v11i077: Gnuplot 2.0 - 12 of 14
  4. From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 11, Issue 77
  8. Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  9. Archive-name: gnuplot2/part12
  10.  
  11. This is gnuplot.sh12
  12.  
  13. --- CUT HERE ---
  14. #! /bin/sh
  15. echo x - corgraph.asm
  16. sed 's/^X//' >corgraph.asm <<'*-*-END-of-corgraph.asm-*-*'
  17. XTITLE    Corona graphics module
  18. X;    Colin Kelley
  19. X;    January 1987
  20. X
  21. Xinclude header.mac
  22. X
  23. Xif1
  24. Xinclude lineproc.mac
  25. Xendif
  26. X
  27. X
  28. X_text    segment
  29. X
  30. Xpublic    _GrInit,_GrReset,_GrOnly,_TxOnly,_GrandTx,_Cor_line,_Cor_mask
  31. X
  32. Xcorpixel proc near
  33. X    ror word ptr linemask,1
  34. X    jc cont
  35. X    ret
  36. Xcont:    push bp
  37. X    mov bp,sp
  38. X    push ax
  39. X    push bx
  40. X    push cx
  41. X    mov es,ScSeg
  42. X    shl bx,1            ; y
  43. X    mov bx,word ptr LookUp[bx] ; bx has y mem address
  44. X    mov cl,al            ; x
  45. X    and cl,7
  46. X    shr ax,1
  47. X    shr ax,1
  48. X    shr ax,1            ; ax /= 8
  49. X    add bx,ax
  50. X    mov al,1
  51. X    shl al,cl            ; al contains bit mask
  52. X    or byte ptr es:[bx],al
  53. X    pop cx
  54. X    pop bx
  55. X    pop ax
  56. X    pop bp
  57. X    ret
  58. X
  59. Xlineproc _Cor_line, corpixel
  60. X
  61. Xbeginproc _GrInit
  62. X    push bp
  63. X    mov bp,sp
  64. X    push di
  65. X    mov ax, [bp+X]            ; screen number (0 - 7)
  66. X    mov cl,11
  67. X    shl ax,cl            ; multiply by 2048 to get segment
  68. X    mov ScSeg,ax            ; save segment for later
  69. X    push ax
  70. X    mov es, ax
  71. X    xor ax,ax
  72. X    mov di,ax
  73. X    mov cx, 4000h
  74. X    cld
  75. X    rep stosw
  76. X    pop cx
  77. X    call near ptr GrAddr
  78. X    mov ax,es
  79. X    pop di
  80. X    pop bp
  81. X    ret
  82. X_GrInit    endp
  83. X
  84. Xbeginproc _GrReset
  85. X    mov cx, 0
  86. X    call near ptr GrAddr
  87. X    ret
  88. X_GrReset endp
  89. X
  90. XGrAddr    proc near
  91. X    mov dx,3b4h            ; address of 6845
  92. X    mov al,0ch            ; register 12
  93. X    out dx,al
  94. X    inc dx
  95. X    mov al,ch            ; Graphics Segment High
  96. X    out dx,al
  97. X    dec dx
  98. X    mov al,0dh            ; register 13
  99. X    out dx,al
  100. X    mov al,cl            ; Graphics Segment Low
  101. X    inc dx
  102. X    out dx,al
  103. X    ret
  104. XGrAddr    endp
  105. X
  106. Xbeginproc _GrOnly
  107. X    mov dx,3b8h
  108. X    mov al,0a0h
  109. X    out dx,al
  110. X    ret
  111. X_GrOnly    endp
  112. X
  113. Xbeginproc _TxOnly
  114. X    mov dx,3b8h
  115. X    mov al,28h
  116. X    out dx,al
  117. X    ret
  118. X_TxOnly    endp
  119. X
  120. Xbeginproc _GrandTx
  121. X    mov dx,3b8h
  122. X    mov al,0a8h
  123. X    out dx,al
  124. X    ret
  125. X_GrandTx endp
  126. X
  127. Xbeginproc _Cor_mask
  128. X    push bp
  129. X    mov bp,sp
  130. X    mov ax,[bp+x]            ; mask
  131. X    mov linemask,ax
  132. X    pop bp
  133. X    ret
  134. X_Cor_mask endp
  135. X
  136. Xcorpixel endp
  137. X
  138. X_text    ends
  139. X
  140. X_data    segment
  141. Xlinemask dw -1
  142. XScSeg    dw 0
  143. X_data    ends
  144. X
  145. Xconst    segment
  146. X
  147. XK    equ 1024
  148. X
  149. Xmem_mac    MACRO x
  150. X    dw x,2*K+x,4*K+x,6*K+x,8*K+x,10*K+x,12*K+x,14*K+x,16*K+x
  151. X    dw 18*K+x,20*K+x,22*K+x,24*K+x
  152. X    ENDM
  153. XLookUp    equ $
  154. X    mem_mac 0
  155. X    mem_mac 80
  156. X    mem_mac (80*2)
  157. X    mem_mac (80*3)
  158. X    mem_mac (80*4)
  159. X    mem_mac (80*5)
  160. X    mem_mac (80*6)
  161. X    mem_mac (80*7)
  162. X    mem_mac (80*8)
  163. X    mem_mac (80*9)
  164. X    mem_mac (80*10)
  165. X    mem_mac (80*11)
  166. X    mem_mac (80*12)
  167. X    mem_mac (80*13)
  168. X    mem_mac (80*14)
  169. X    mem_mac (80*15)
  170. X    mem_mac (80*16)
  171. X    mem_mac (80*17)
  172. X    mem_mac (80*18)
  173. X    mem_mac (80*19)
  174. X    mem_mac (80*20)
  175. X    mem_mac (80*21)
  176. X    mem_mac (80*22)
  177. X    mem_mac (80*23)
  178. X    mem_mac (80*24)
  179. X
  180. Xconst    ends
  181. X
  182. X    end
  183. *-*-END-of-corgraph.asm-*-*
  184. echo x - corplot.c
  185. sed 's/^X//' >corplot.c <<'*-*-END-of-corplot.c-*-*'
  186. X#include <stdio.h>
  187. X#include <process.h>
  188. X#include <dos.h>
  189. X
  190. X#define BOUNDARY 32768
  191. X#define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
  192. X#define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
  193. X
  194. Xchar *malloc(),*realloc();
  195. X
  196. Xchar prog[] = "gnuplot";
  197. Xchar corscreen[] = "CORSCREEN=0";
  198. X
  199. Xmain()
  200. X{
  201. Xregister unsigned int segm,start;
  202. Xchar *m;
  203. X    if (!(m = malloc(BOUNDARY))) {
  204. X        printf("malloc() failed\n");
  205. X        exit(1);
  206. X    }
  207. X    segm = segment(m);
  208. X    start = round(segm,BOUNDARY/16);
  209. X
  210. X    if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
  211. X        printf("can't realloc() memory\n");
  212. X        exit(2);
  213. X    }
  214. X
  215. X    if ((segm = start >> 11) >= 8) {
  216. X        printf("not enough room in first 256K\n");
  217. X        exit(3);
  218. X    }
  219. X
  220. X    corscreen[sizeof(corscreen)-2] = '0' + segm;
  221. X    if (putenv(corscreen))
  222. X        perror("putenv");
  223. X
  224. X    if (spawnlp(P_WAIT,prog,prog,NULL))
  225. X        perror("spawnlp");
  226. X}
  227. *-*-END-of-corplot.c-*-*
  228. echo x - header.mac
  229. sed 's/^X//' >header.mac <<'*-*-END-of-header.mac-*-*'
  230. Xif1
  231. XLARGE    equ 1            ; define your memory model here
  232. X
  233. Xifdef    SMALL
  234. X    ; default, so do nothing
  235. X    else
  236. X
  237. Xifdef    MEDIUM
  238. X    LARGE_CODE equ 1
  239. X    else
  240. X
  241. Xifdef    COMPACT
  242. X    LARGE_DATA equ 1
  243. X    else
  244. X
  245. Xifdef    LARGE
  246. X    LARGE_DATA equ 1
  247. X    LARGE_CODE equ 1
  248. X
  249. Xelse
  250. X    %out No memory model defined--assuming SMALL
  251. X
  252. Xendif    ; LARGE
  253. Xendif    ; COMPACT
  254. Xendif    ; MEDIUM
  255. Xendif    ; SMALL
  256. X
  257. X
  258. Xbeginproc macro procname
  259. X
  260. Xifdef    LARGE_CODE
  261. X    procname proc far
  262. Xelse
  263. X    procname proc near
  264. Xendif    ; LARGE_CODE
  265. X
  266. X    endm    ; beginproc
  267. X
  268. X
  269. Xendif    ; if1
  270. X
  271. X
  272. X_TEXT    SEGMENT    BYTE PUBLIC 'CODE'
  273. X_TEXT    ENDS
  274. X_DATA    SEGMENT WORD PUBLIC 'DATA'
  275. X_DATA    ENDS
  276. XCONST    SEGMENT WORD PUBLIC 'CONST'
  277. XCONST    ENDS
  278. X_BSS    SEGMENT WORD PUBLIC 'BSS'
  279. X_BSS    ENDS
  280. X
  281. XDGROUP    GROUP    CONST, _BSS, _DATA
  282. X    assume cs:_text, ds:dgroup, ss:dgroup, es:dgroup
  283. X
  284. X; define X as the offset of first argument on stack frame
  285. X
  286. Xifdef LARGE_CODE
  287. X    X    equ 6            ; return offset and segment + old BP
  288. Xelse
  289. X    X    equ 4            ; return offset + old BP
  290. Xendif    ; LARGE_CODE
  291. *-*-END-of-header.mac-*-*
  292. echo x - hrcgraph.asm
  293. sed 's/^X//' >hrcgraph.asm <<'*-*-END-of-hrcgraph.asm-*-*'
  294. XTITLE    Hercules graphics module
  295. X
  296. X;    Michael Gordon - 8-Dec-86
  297. X;
  298. X; Certain routines were taken from the Hercules BIOS of    Dave Tutelman - 8/86
  299. X; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
  300. X;
  301. X; modified slightly by Colin Kelley - 22-Dec-86
  302. X;    added header.mac, parameterized declarations
  303. X; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
  304. X; modified by Russell Lang 3 Jun 1988
  305. X;    added H_init
  306. X
  307. Xinclude header.mac
  308. X
  309. Xif1
  310. Xinclude lineproc.mac
  311. Xendif
  312. X
  313. X
  314. XGPg1_Base equ 0B800h    ; Graphics page 1 base address
  315. X
  316. X_text    segment
  317. X
  318. X    public _H_line, _H_color, _H_mask, _HVmode, _H_puts
  319. X    public _H_init
  320. X
  321. XHCfg_Switch equ    03BFH    ; Configuration Switch - software switch 
  322. X            ; to select graphics card memory map
  323. X
  324. Xbeginproc _H_init
  325. X    mov al, 03H    ; allow graphics in b8000:bffff
  326. X    mov dx, HCfg_Switch
  327. X    out dx, al
  328. X    ret
  329. X_H_init endp
  330. X
  331. Xhpixel    proc near
  332. X    ror word ptr bmask,1
  333. X    jc cont
  334. X    ret
  335. Xcont:
  336. X    push ax
  337. X    push bx
  338. X    push cx
  339. X    push dx
  340. X    push si
  341. X    mov cx,ax        ; x
  342. X    mov dx,bx        ; y
  343. X;
  344. X; [couldn't this be done faster with a lookup table? -cdk]
  345. X;
  346. X    ; first compute the address of byte to be modified
  347. X    ; = 90*[row/4] + [col/8] + 2^D*[row/4] + 2^F*page
  348. X    mov    bh,cl        ; col (low order) in BH
  349. X    mov    bl,dl        ; row (low order) in BL
  350. X    and    bx,0703H    ; mask the col & row remainders
  351. XIFDEF iAPX286
  352. X    shr    cx,3        ; col / 8
  353. X    shr    dx,2        ; row / 4
  354. X    mov    al,90
  355. X    mul    dx        ; AX = 90*[ row/4 ]
  356. X    add    ax,cx        ;  ... + col/8
  357. X    shl    bl,5        ; align row remainder
  358. XELSE            ; same as above, obscure but fast for 8086
  359. X    shr    cx,1        ; divide col by 8
  360. X    shr    cx,1
  361. X    shr    cx,1
  362. X    shr    dx,1        ; divide row by 4
  363. X    shr    dx,1
  364. X    shl    dx,1        ; begin fast multiply by 90 (1011010 B)
  365. X    mov    ax,dx
  366. X    shl    dx,1
  367. X    shl    dx,1
  368. X    add    ax,dx
  369. X    shl    dx,1
  370. X    add    ax,dx
  371. X    shl    dx,1
  372. X    shl    dx,1
  373. X    add    ax,dx        ; end fast multiply by 90
  374. X    add    ax,cx        ; add on the col/8
  375. X    shl    bl,1        ; align row remainder
  376. X    shl    bl,1
  377. X    shl    bl,1
  378. X    shl    bl,1
  379. X    shl    bl,1
  380. XENDIF
  381. X    add    ah,bl        ; use aligned row remainder
  382. Xend_adr_calc:            ; address of byte is now in AX
  383. X    mov    dx,GPg1_Base    ; base of pixel display to DX
  384. X    mov    es,dx        ; ...and thence to segment reg
  385. X    mov    si,ax        ; address of byte w/ pixel to index reg
  386. X    mov    cl,bh        ; bit addr in byte
  387. X    mov    al,80H        ; '1000 0000' in AL 
  388. X    shr    al,cl        ; shift mask to line up with bit to read/write
  389. Xset_pix:            ; set the pixel
  390. X    or    es:[si],al    ; or the mask with the right byte
  391. X    pop si
  392. X    pop dx
  393. X    pop cx
  394. X    pop bx
  395. X    pop ax
  396. X    ret
  397. Xhpixel endp
  398. X
  399. Xlineproc _H_line, hpixel
  400. X
  401. X;
  402. X; clear - clear page 1 of the screen buffer to zero (effectively, blank
  403. X;    the screen)
  404. X;
  405. Xclear   proc near
  406. X    push es
  407. X    push ax
  408. X    push cx
  409. X    push di
  410. X    mov ax, GPg1_Base
  411. X    mov es, ax
  412. X    xor di, di
  413. X    mov cx, 4000h
  414. X    xor ax, ax
  415. X    cld
  416. X    rep stosw            ; zero out screen page
  417. X    pop di
  418. X    pop cx
  419. X    pop ax
  420. X    pop es
  421. X    ret
  422. Xclear    endp
  423. X
  424. Xbeginproc _H_color
  425. X    push bp
  426. X    mov bp,sp
  427. X    mov al,[bp+X]            ; color
  428. X    mov byte ptr color,al
  429. X    pop bp
  430. X    ret
  431. X_H_color endp
  432. X
  433. Xbeginproc _H_mask
  434. X    push bp
  435. X    mov bp,sp
  436. X    mov ax,[bp+X]            ; mask
  437. X    mov word ptr bmask,ax
  438. X    pop bp
  439. X    ret
  440. X_H_mask endp
  441. X
  442. XHCtrl_Port    equ    03B8H    ; Hercules 6845 control port IO addr
  443. XHIndx_Port    equ    03B4H    ; Hercules 6845 index port IO addr
  444. XHScrn_Enable    equ    008h    ; Control port bit to enable video
  445. XHCh_Mode    equ    020h    ; Character output mode
  446. XHGr_Mode    equ    082h    ; Graphics output mode page 1
  447. X
  448. Xparm_count equ 12
  449. X
  450. Xbeginproc _HVmode
  451. X    push bp
  452. X    mov bp, sp
  453. X    push si
  454. X    mov ax, [bp+X]
  455. X    or ah, al
  456. X    mov al, HCh_Mode        ; Assume character mode is wanted
  457. X    mov si, offset dgroup:HCh_Parms
  458. X    cmp ah, 0            ; nonzero means switch to graphics
  459. X    jz vmode_ok
  460. X    call near ptr clear        ; clear the graphics page
  461. X    mov al, HGr_Mode
  462. X    mov si, offset dgroup:HGr_Parms
  463. Xvmode_ok:
  464. X    mov dx, HCtrl_Port
  465. X    out dx, al            ; Set Hercules board to proper mode
  466. X    call near ptr setParms        ; Set the 6845 parameters
  467. X    or al, HScrn_Enable        ; Enable the video output
  468. X    out dx, al
  469. X    pop si
  470. X    pop bp
  471. X    ret
  472. X_HVmode    endp
  473. X
  474. XsetParms proc near        ; Send 6845 parms to Hercules board
  475. X    push ax
  476. X    push dx
  477. X    push si            
  478. X    mov dx, HIndx_Port    ; Index port addr -> DX
  479. X    mov ah, 0        ; 0 -> parameter counter
  480. Xsp_loop:
  481. X    mov al, ah
  482. X    out dx, al        ; output to 6845 addr register
  483. X    inc dx            ; next output to data register
  484. X    mov al, [si]        ; next control byte -> al
  485. X    inc si
  486. X    out dx, al        ; output control byte
  487. X    dec dx            ; 6845 index addr -> dx
  488. X    inc ah            ; bump addr
  489. X    cmp ah, parm_count
  490. X    jnz sp_loop
  491. X    pop si
  492. X    pop dx
  493. X    pop ax
  494. X    ret
  495. XsetParms endp
  496. X
  497. X; H_puts - print text in graphics mode
  498. X;
  499. X;    cx = row
  500. X;    bx = column
  501. X;    si = address of string (null terminated) to print
  502. X
  503. Xbeginproc _H_puts
  504. X    push bp
  505. X    mov bp, sp
  506. X    push si
  507. X    push ds
  508. X    mov si, [bp+X]            ; string offset
  509. X
  510. Xifdef LARGE_DATA
  511. X    mov ds, [bp+X+2]        ; string segment
  512. X    mov cx, [bp+X+4]        ; row
  513. X    mov bx, [bp+X+6]        ; col
  514. Xelse
  515. X    mov cx, [bp+X+2]        ; row
  516. X    mov bx, [bp+X+4]        ; col
  517. Xendif
  518. X
  519. Xploop:    lodsb                ; get next char
  520. X    or    al, al            ; end of display?
  521. X    je    pdone
  522. X    call near ptr display
  523. X    inc    bx            ; bump to next column
  524. X    jmp    ploop
  525. Xpdone:    pop ds
  526. X    pop si
  527. X    pop bp
  528. X    ret
  529. X_H_puts    endp
  530. X
  531. X;
  532. X; display - output an 8x8 character from the IBM ROM to the Herc board
  533. X;
  534. X; AX = char, BX = column (0-89), CX = row(0-42)  ** all preserved **
  535. X;
  536. XCON8    db    8
  537. XCON180    db    180
  538. XIBMROM    equ    0F000h
  539. XCHARTAB    equ    0FA6Eh
  540. X
  541. Xdisplay    proc near
  542. X    push    ds            ; save the lot
  543. X    push    es
  544. X    push    ax
  545. X    push    bx
  546. X    push    cx
  547. X    push    dx
  548. X    push    si
  549. X    push    di
  550. X
  551. X; setup ds -> IBM ROM, and si -> index into IBM ROM character table located
  552. X;    at 0fa6eh in the ROM
  553. X
  554. X    and    ax, 07fh
  555. X    mul    cs:CON8            ; mult by 8 bytes of table per char
  556. X    mov    si, ax
  557. X    mov    ax, IBMROM
  558. X    mov    ds, ax
  559. X    assume    ds:nothing
  560. X    add    si, CHARTAB        ; add offset of character table
  561. X
  562. X; compute index into Hercules screen memory for scan line 0.  The remaining
  563. X;    seven scan lines are all at fixed offsets from the first.
  564. X;
  565. X;    Since graphics mode treats the screen as sets of 16x4 "characters",
  566. X;    we need to map an 8x8 real character onto the front or back of
  567. X;    a pair of graphics "characters".  The first four scan lines of our
  568. X;    8x8 character will map to the top graphics "character", and the second
  569. X;    four scan lines map to the graphics character on the "line" (4 scan
  570. X;    lines high) below it.
  571. X;
  572. X;    For some exotic hardware reason (probably speed), all scan line 0
  573. X;    bits (i.e. every fourth scan line) are stored in memory locations
  574. X;    0-2000h in the screen buffer.  All scan line 1 bits are stored
  575. X;    2000h-4000h.  Within these banks, they are stored by rows.  The first
  576. X;    scan line on the screen (scan line 0 of graphics character row 0)
  577. X;    is the first 45 words of memory in the screen buffer.  The next 45
  578. X;    words are the first scan line graphics row 1, and since graphics
  579. X;    "characters" are 4 bits high, this second scan line is physically
  580. X;    the fifth scan line displayed on the screen.
  581. X;
  582. X;    SO, to display an 8x8 character, the 1st and 5th rows of dots are
  583. X;    both scan line 0 of the graphics "character", the 2nd and 6th are
  584. X;    scan line 1, and so on.
  585. X;
  586. X;    The column (0-89) tells which byte in a scan line we need to load.
  587. X;    Since it takes two rows of graphics characters to hold one row of
  588. X;    our characters, column+90 is a index to scan line 4 rows of pixels
  589. X;    higher (n+4).  Thus 180 bytes of screen memory in any bank (0h, 2000h,
  590. X;    4000h, 6000h) represent a row of 8x8 characters.
  591. X;    
  592. X;    The starting location in screen memory for the first scan line of
  593. X;    a character to be displayed will be:      (row*180)+column
  594. X;    The 5th scan line will be at:        (row*180)+column+90
  595. X;
  596. X;    The second and 6th scan lines will be at the above offsets plus
  597. X;    the bank offset of 2000h.  The third and 7th, add 4000h and finally
  598. X;    the 4th and 8th, add 6000h.
  599. X;
  600. X    mov    ax, GPg1_Base
  601. X    mov    es, ax            ; es = hercules page 0
  602. X    mov    ax, cx            ; get row
  603. X    mul    cs:CON180        ; mult by 180(10)
  604. X    mov    di, ax            ; di = index reg
  605. X    cld                ; insure right direction
  606. X
  607. X;output 8 segments of character to video ram
  608. X
  609. X    lodsb                ; line 0
  610. X    mov    es:[di+bx], al
  611. X    lodsb
  612. X    mov    es:[di+bx+2000h], al    ; line 1
  613. X    lodsb
  614. X    mov    es:[di+bx+4000h], al    ; line 2
  615. X    lodsb
  616. X    mov    es:[di+bx+6000h], al    ; line 3
  617. X    lodsb
  618. X    mov    es:[di+bx+90], al    ; line 4
  619. X    lodsb
  620. X    mov    es:[di+bx+2000h+90], al    ; line 5
  621. X    lodsb
  622. X    mov    es:[di+bx+4000h+90], al    ; line 6
  623. X    lodsb
  624. X    mov    es:[di+bx+6000h+90], al    ; line 7
  625. X
  626. X    pop    di
  627. X    pop    si
  628. X    pop    dx
  629. X    pop    cx
  630. X    pop    bx
  631. X    pop    ax
  632. X    pop    es
  633. X    pop    ds
  634. X    ret
  635. Xdisplay    endp
  636. X
  637. X_text    ends
  638. X
  639. X_data    segment
  640. Xbmask    dw -1
  641. Xcolor    db 1
  642. X_data    ends
  643. X
  644. Xconst    segment
  645. XHCh_Parms db     61H, 50H, 52H, 0FH, 19H, 06H, 19H, 19H, 02H, 0DH, 0BH, 0CH
  646. XHGr_Parms db    35H, 2DH, 2EH, 07H, 5BH, 02H, 57H, 57H, 02H, 03H, 00H, 00H
  647. Xconst    ends
  648. X
  649. X    end
  650. X
  651. X
  652. *-*-END-of-hrcgraph.asm-*-*
  653. echo x - lineproc.mac
  654. sed 's/^X//' >lineproc.mac <<'*-*-END-of-lineproc.mac-*-*'
  655. X; lineproc.mac
  656. X; MASM macro definition for Bresenham line-drawing routine
  657. X; Colin Kelley
  658. X; January 13, 1987
  659. X
  660. X
  661. XINCAX    equ 40h            ; for Self-Modifying Code
  662. XINCBX    equ 43h
  663. XDECAX    equ 48h
  664. XDECBX    equ 4bh
  665. X
  666. X; usage:
  667. X;   lineproc linename, pixelname
  668. X;
  669. X; where linemane is the name you want for the proc, and pixelname is the
  670. X;   name of the routine that linename is to call to set pixels
  671. X;
  672. X
  673. Xlineproc macro linename, pixelname
  674. Xbeginproc linename
  675. X
  676. X    push bp
  677. X    mov bp,sp
  678. X    push si
  679. X    push di
  680. X    mov ax,[bp+X]        ; x1
  681. X    mov bx,[bp+X+2]        ; y1
  682. X    mov cx,[bp+X+4]        ; x2
  683. X    mov si,[bp+X+6]        ; y2
  684. X
  685. X    cmp ax,cx        ; x1,x2
  686. X    jne i19
  687. X    cmp bx,si        ; y1,y2
  688. X    jne i19
  689. X
  690. X    call pixelname
  691. X
  692. X    jmp i28
  693. Xi19:
  694. X    mov dx,ax        ; dx,x1
  695. X    sub dx,cx        ; x2
  696. X    jnc noabsx
  697. X    neg dx
  698. Xnoabsx:
  699. X    mov di,bx        ; dy,y1
  700. X    sub di,si        ; y2
  701. X    jnc noabsy
  702. X    neg di            ; dy
  703. Xnoabsy:
  704. X    cmp dx,di        ; dx,dy
  705. X    jb i21            ; go iterate y's
  706. X;
  707. X; iterate x's
  708. X;
  709. X    cmp bx,si        ; y1,y2
  710. X    jb forwardy
  711. X    mov byte ptr cs:yinc1,DECBX
  712. X    jmp short i22
  713. Xforwardy:
  714. X    mov byte ptr cs:yinc1,INCBX
  715. Xi22:
  716. X    cmp ax,cx        ; x1,x2
  717. X    jae l20004
  718. X    mov byte ptr cs:xinc1,INCAX
  719. X    jmp short l20005
  720. Xl20004:
  721. X    mov byte ptr cs:xinc1,DECAX
  722. Xl20005:
  723. X    mov bp,dx        ; sum,dx
  724. X    shr bp,1        ; sum
  725. Xd23:
  726. X    cmp ax,cx        ; x1,x2
  727. X    je i28            ; done
  728. Xxinc1:    inc ax            ; may become inc or dec
  729. X    add bp,di        ; sum,dy
  730. X    cmp bp,dx
  731. X    jb i27
  732. X    sub bp,dx        ; sum,dx
  733. Xyinc1:    inc bx            ; may become inc or dec
  734. Xi27:
  735. X    call pixelname
  736. X    jmp short d23
  737. X
  738. X;
  739. X; else iterate y's
  740. X;
  741. Xi21:
  742. X    cmp ax,cx        ; x1,x2
  743. X    jae l20006
  744. X    mov byte ptr cs:xinc2,INCAX
  745. X    jmp short l20007
  746. Xl20006:
  747. X    mov byte ptr cs:xinc2,DECAX
  748. Xl20007:
  749. X    cmp bx,si        ; y1,y2
  750. X    jb forwardy2
  751. X    mov byte ptr cs:yinc2,DECBX
  752. X    jmp short i29
  753. Xforwardy2:
  754. X    mov byte ptr cs:yinc2,INCBX
  755. Xi29:
  756. X    mov bp,di        ; sum,dy
  757. X    shr bp,1        ; sum,1
  758. Xd30:
  759. X    cmp bx,si        ; y1,y2
  760. X    je i28
  761. Xyinc2:    inc bx            ; may become inc or dec
  762. X    add bp,dx        ; sum,dx
  763. X    cmp bp,di        ; sum,dy
  764. X    jb i34
  765. X    sub bp,di        ; sum,dy
  766. Xxinc2:    inc ax            ; may become inc or dec
  767. Xi34:
  768. X    call near ptr pixelname
  769. X    jmp short d30
  770. X;
  771. X; clean up and exit
  772. X;
  773. Xi28:
  774. X    pop di
  775. X    pop si
  776. X    pop bp
  777. X    ret
  778. X
  779. Xlinename endp
  780. X    endm
  781. *-*-END-of-lineproc.mac-*-*
  782. echo x - linkopt.msc
  783. sed 's/^X//' >linkopt.msc <<'*-*-END-of-linkopt.msc-*-*'
  784. Xpcgraph+hrcgraph+corgraph+term+graphics+
  785. Xplot+setshow+command+help+internal+misc+
  786. Xparse+eval+scanner+standard+util+version
  787. Xgnuplot
  788. Xnul;
  789. *-*-END-of-linkopt.msc-*-*
  790. echo x - linkopt.tc
  791. sed 's/^X//' >linkopt.tc <<'*-*-END-of-linkopt.tc-*-*'
  792. X\tc\lib\C0l command eval graphics help internal misc parse plot scanner setshow standard term util version cga egavga herc ,gnuplot,gnuplot, \tc\lib\emu \tc\lib\mathl \tc\lib\cl \tc\lib\graphics
  793. X        
  794. *-*-END-of-linkopt.tc-*-*
  795. echo x - makefile.msc
  796. sed 's/^X//' >makefile.msc <<'*-*-END-of-makefile.msc-*-*'
  797. X# Make file for use with Microsoft C  Version 5.10
  798. X# and Microsoft Program Maintenance Utility  Version 4.07
  799. X# 
  800. X
  801. X# where to place gnuplot.gih helpfile
  802. XHELPFILE = gnuplot.gih
  803. X
  804. X# /c  means don't link
  805. X# /AL means large memory model (large code, large data)
  806. X# /DPC means define symbol PC
  807. XCFLAGS = /c /AL /DPC #/DMSDOS #/Zi #/Od
  808. X
  809. XTERMFLAGS = /DHERCULES /DCORONA /DATT6300 /DEPSON /DPOSTSCRIPT /DHP75 /DHPGL /DDXY800A  /DNEC
  810. X
  811. X# /NOE means NO EXTernal Dictionary
  812. X# /EX  means pack EXE file
  813. X# /ST:8000 means stack size 8000 bytes
  814. XLINKFLAGS = /NOE /EX /ST:8000 #/codeview 
  815. X
  816. XOBJS =     command.obj eval.obj graphics.obj help.obj internal.obj \
  817. X    misc.obj parse.obj plot.obj scanner.obj setshow.obj standard.obj \
  818. X    term.obj util.obj version.obj pcgraph.obj hrcgraph.obj corgraph.obj
  819. X
  820. XCSOURCE5 = term\aed.trm term\dxy.trm term\epson.trm term\font5x7.trm \
  821. X    term\hp26.trm term\hp2648.trm term\hpgl.trm \
  822. X    term\hpljet.trm term\iris4d.trm term\latex.trm 
  823. XCSOURCE6 = term\post.trm term\pc.trm term\qms.trm term\regis.trm \
  824. X    term\tek.trm term\unixpc.trm term\unixplot.trm term\v384.trm \
  825. X    term\imPcodes.h term\imagen.trm term\object.h term\fig.trm
  826. X
  827. X
  828. X# default rules
  829. X.c.obj:
  830. X    cl $(CFLAGS) $*.c
  831. X
  832. X.asm.obj:
  833. X    masm $*;
  834. X
  835. Xpcgraph.obj: pcgraph.asm header.mac lineproc.mac
  836. X
  837. Xcorgraph.obj: corgraph.asm header.mac lineproc.mac
  838. X
  839. Xhrcgraph.obj: hrcgraph.asm header.mac lineproc.mac
  840. X
  841. Xcommand.obj: command.c plot.h setshow.h help.h
  842. X    cl $(CFLAGS) /DHELPFILE=\"$(HELPFILE)\" command.c
  843. X
  844. Xeval.obj: eval.c plot.h
  845. X
  846. Xgraphics.obj: graphics.c plot.h setshow.h
  847. X
  848. Xhelp.obj: help.c plot.h help.h
  849. X
  850. Xinternal.obj: internal.c plot.h
  851. X
  852. Xmisc.obj: misc.c plot.h setshow.h
  853. X
  854. Xparse.obj: parse.c plot.h
  855. X
  856. Xplot.obj: plot.c plot.h setshow.h
  857. X
  858. Xscanner.obj: scanner.c plot.h
  859. X
  860. Xsetshow.obj: setshow.c plot.h setshow.h
  861. X
  862. Xstandard.obj: standard.c plot.h
  863. X
  864. Xterm.obj: term.c plot.h $(CSOURCE5) $(CSOURCE6)
  865. X    cl $(CFLAGS) $(TERMFLAGS) term.c
  866. X
  867. Xutil.obj: util.c plot.h
  868. X
  869. Xversion.obj: version.c
  870. X
  871. X# convert gnuplot.doc to gnuplot.gih
  872. Xdoc2gih.exe: docs\doc2gih.c
  873. X    cl docs\doc2gih.c
  874. X
  875. X$(HELPFILE): doc2gih.exe docs\gnuplot.doc
  876. X    doc2gih docs\gnuplot.doc $(HELPFILE)
  877. X
  878. X# Object files in link command line are ordered to avoid far jumps.
  879. X# use linkopt.msc to avoid command-line overflow
  880. X
  881. Xgnuplot.exe: $(OBJS)
  882. X link $(LINKFLAGS) @linkopt.msc
  883. *-*-END-of-makefile.msc-*-*
  884. echo x - makefile.tc
  885. sed 's/^X//' >makefile.tc <<'*-*-END-of-makefile.tc-*-*'
  886. X# make file for Turbo C
  887. X# Modified from MSC make by John Campbell and Bill Wilson
  888. X# The compile and link includes debug flags.  Take them out if you
  889. X# do not want them included  (-y -v -M, /m /s /v /l)
  890. X
  891. X# where to place gnuplot.gih helpfile
  892. XHELPFILE = gnuplot.gih
  893. X# location of Turbo C compiler
  894. X# if this is changed then linkopt.tc will need to be edited.
  895. XTC = \tc
  896. X# location of BGI files
  897. XBGI = $(TC)
  898. X# -c means don't link, -f means emulate 8087 if not present
  899. X# -ml means use large model (large code, large data)
  900. X# -M means produce link map
  901. X# -y means include line numbers for debugger
  902. X# -v means include debug info
  903. XCFLAGS = -c -f -ml -M -y -v -I$(TC)\include -DMSDOS -DPC
  904. XTERMFLAGS = -DPOSTSCRIPT -DHPGL -DHP75 -DDXY800A -DEPSON -DNEC
  905. X
  906. XOBJS =     command.obj eval.obj graphics.obj help.obj internal.obj \
  907. X    misc.obj parse.obj plot.obj scanner.obj setshow.obj standard.obj \
  908. X    term.obj util.obj version.obj cga.obj egavga.obj herc.obj
  909. X
  910. XCSOURCE5 = term\aed.trm term\dxy.trm term\epson.trm term\font5x7.trm \
  911. X    term\hp26.trm term\hp2648.trm term\hpgl.trm \
  912. X    term\hpljet.trm term\iris4d.trm term\latex.trm 
  913. XCSOURCE6 = term\post.trm term\pc.trm term\qms.trm term\regis.trm \
  914. X    term\tek.trm term\unixpc.trm term\unixplot.trm term\v384.trm \
  915. X    term\imPcodes.h term\imagen.trm term\object.h term\fig.trm
  916. X
  917. X
  918. Xall: gnuplot.exe $(HELPFILE)
  919. X
  920. X# use linkopt.tc to avoid command-line overflow
  921. X
  922. Xgnuplot.exe: $(OBJS) 
  923. X    tlink /m /s /v /l @linkopt.tc
  924. X
  925. X# default rules
  926. X
  927. X.c.obj:  
  928. X    tcc $(CFLAGS) $<
  929. X
  930. Xcommand.obj: command.c plot.h setshow.h help.h
  931. X    tcc $(CFLAGS) -DHELPFILE="$(HELPFILE)" command.c
  932. X
  933. Xeval.obj: eval.c plot.h
  934. X
  935. Xgraphics.obj: graphics.c plot.h setshow.h
  936. X
  937. Xhelp.obj: help.c plot.h help.h
  938. X
  939. Xinternal.obj: internal.c plot.h
  940. X
  941. Xmisc.obj: misc.c plot.h setshow.h help.h
  942. X
  943. Xparse.obj: parse.c plot.h
  944. X
  945. Xplot.obj: plot.c plot.h setshow.h
  946. X
  947. Xscanner.obj: scanner.c plot.h
  948. X
  949. Xsetshow.obj: setshow.c plot.h setshow.h
  950. X
  951. Xstandard.obj: standard.c plot.h
  952. X
  953. Xterm.obj: term.c plot.h $(CSOURCE5) $(CSOURCE6)
  954. X    tcc $(CFLAGS) $(TERMFLAGS) term.c
  955. X    
  956. Xutil.obj: util.c plot.h
  957. X
  958. Xversion.obj: version.c
  959. X
  960. X# convert gnuplot.doc to gnuplot.gih
  961. X$(HELPFILE): doc2gih.exe docs\gnuplot.doc
  962. X    doc2gih docs\gnuplot.doc $(HELPFILE)
  963. X
  964. Xdoc2gih.exe: docs\doc2gih.c
  965. X    tcc -I$(TC)\include -L$(TC)\lib docs\doc2gih.c
  966. X
  967. X# convert Borland Graphics Interface files to object for linking
  968. Xcga.obj: $(BGI)\cga.bgi
  969. X    bgiobj $(BGI)\cga
  970. X
  971. Xegavga.obj: $(BGI)\egavga.bgi
  972. X    bgiobj $(BGI)\egavga
  973. X
  974. Xherc.obj: $(BGI)\herc.bgi
  975. X    bgiobj $(BGI)\herc
  976. *-*-END-of-makefile.tc-*-*
  977. echo x - pcgraph.asm
  978. sed 's/^X//' >pcgraph.asm <<'*-*-END-of-pcgraph.asm-*-*'
  979. XTITLE    PC graphics module
  980. X;    uses LINEPROC.MAC
  981. X
  982. X;    Michael Gordon - 8-Dec-86
  983. X;
  984. X; Certain routines were taken from the Hercules BIOS of    Dave Tutelman - 8/86
  985. X; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
  986. X;
  987. X; modified slightly by Colin Kelley - 22-Dec-86
  988. X;    added header.mac, parameterized declarations
  989. X; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
  990. X;
  991. X; modified and added to for use in plot(3) routines back end.
  992. X; Gil Webster.
  993. X;
  994. X; Assemble with masm ver. 4.  
  995. X
  996. Xinclude header.mac
  997. X
  998. Xif1
  999. Xinclude lineproc.mac
  1000. Xendif
  1001. X
  1002. XGPg1_Base equ 0B800h    ; Graphics page 1 base address
  1003. X
  1004. X_text    segment
  1005. X
  1006. X    public _PC_line, _PC_color, _PC_mask, _PC_curloc, _PC_puts, _Vmode
  1007. X    public _erase, _save_stack, _ss_interrupt
  1008. X    extrn _inter:near
  1009. X
  1010. Xpcpixel proc near
  1011. X    ror word ptr linemask,1
  1012. X    jc cont
  1013. X    ret
  1014. Xcont:
  1015. X    push ax
  1016. X    push bx
  1017. X    push cx
  1018. X    push dx
  1019. X    push bp
  1020. X    mov cx,ax        ; x
  1021. X    mov dx,bx        ; y
  1022. X    mov ah,0ch        ; ah = write pixel
  1023. X    mov al,byte ptr color
  1024. X
  1025. X    mov bh, 0        ; page 0
  1026. X    int 10h
  1027. X    pop bp
  1028. X    pop dx
  1029. X    pop cx
  1030. X    pop bx
  1031. X    pop ax
  1032. X    ret
  1033. Xpcpixel endp
  1034. X
  1035. Xlineproc _PC_line, pcpixel
  1036. X
  1037. X;
  1038. X; erase - clear page 1 of the screen buffer to zero (effectively, blank
  1039. X;    the screen)
  1040. X;
  1041. Xbeginproc _erase
  1042. X    push es
  1043. X    push ax
  1044. X    push cx
  1045. X    push di
  1046. X    mov ax, GPg1_Base
  1047. X    mov es, ax
  1048. X    xor di, di
  1049. X    mov cx, 4000h
  1050. X    xor ax, ax
  1051. X    cld
  1052. X    rep stosw            ; zero out screen page
  1053. X    pop di
  1054. X    pop cx
  1055. X    pop ax
  1056. X    pop es
  1057. X    ret
  1058. X_erase endp
  1059. X
  1060. Xbeginproc _PC_color
  1061. X    push bp
  1062. X    mov bp,sp
  1063. X    mov al,[bp+X]            ; color
  1064. X    mov byte ptr color,al
  1065. X    pop bp
  1066. X    ret
  1067. X_PC_color endp
  1068. X
  1069. Xbeginproc _PC_mask
  1070. X    push bp
  1071. X    mov bp,sp
  1072. X    mov ax,[bp+X]            ; mask
  1073. X    mov word ptr linemask,ax
  1074. X    pop bp
  1075. X    ret
  1076. X_PC_mask endp
  1077. X
  1078. Xbeginproc _Vmode
  1079. X    push bp
  1080. X    mov bp,sp
  1081. X    push si
  1082. X    push di
  1083. X    mov ax,[bp+X]
  1084. X    int 10h
  1085. X    pop di
  1086. X    pop si
  1087. X    pop bp
  1088. X    ret
  1089. X_Vmode    endp
  1090. X
  1091. Xbeginproc _PC_curloc
  1092. X    push bp
  1093. X    mov bp,sp
  1094. X    mov dh, byte ptr [bp+X] ; row number
  1095. X    mov dl, byte ptr [bp+X+2] ; col number
  1096. X    mov bh, 0
  1097. X    mov ah, 2
  1098. X    int 10h
  1099. X    pop bp
  1100. X    ret
  1101. X_PC_curloc endp
  1102. X
  1103. X;
  1104. X; thanks to watale!broehl for finding a bug here--I wasn't pushing BP
  1105. X;   and reloading AH before INT 10H, which is necessary on genuine IBM
  1106. X;   boards...
  1107. X;
  1108. Xbeginproc _PC_puts
  1109. X    push bp
  1110. X    mov bp,sp
  1111. X    push si
  1112. X    mov bl,byte ptr color
  1113. X    mov si,[bp+X]        ; offset
  1114. X
  1115. Xifdef LARGE_DATA
  1116. X    mov es,[bp+X+2]        ; segment if large or compact data model
  1117. Xendif
  1118. X
  1119. Xputs2:
  1120. X
  1121. Xifdef LARGE_DATA
  1122. X    mov al,es:[si]
  1123. Xelse
  1124. X    mov al,[si]
  1125. Xendif
  1126. X    or al,al
  1127. X    jz puts3
  1128. X    mov ah,0eh        ; write TTY char
  1129. X    int 10h
  1130. X    inc si
  1131. X    jmp short puts2
  1132. Xputs3:    pop si
  1133. X    pop bp
  1134. X    ret
  1135. X_PC_puts endp
  1136. X
  1137. X
  1138. X; int kbhit();
  1139. X;   for those without MSC 4.0
  1140. X; Use BIOS interrupt 16h to determine if a key is waiting in the buffer.
  1141. X; Return nonzero if so.
  1142. X;
  1143. X
  1144. Xbeginproc _kbhit
  1145. X    mov ah, 1        ; function code 1 is keyboard test
  1146. X    int 16h            ; keyboard functions
  1147. X    jnz kbfin        ; Exit if char available
  1148. X    xor ax, ax        ; No char:  return zero.
  1149. Xkbfin:    ret
  1150. X_kbhit    endp
  1151. X
  1152. X
  1153. X; _save_stack and _ss_interrupt are needed due to a bug in the MSC 4.0
  1154. X; code when run under MS-DOS 3.x.  Starting with 3.0, MS-DOS automatically
  1155. X; switches to an internal stack during system calls.  This leaves SS:SP
  1156. X; pointing at MS-DOS's stack when the ^C interrupt (INT 23H) is triggered.
  1157. X; MSC should restore its own stack before calling the user signal() routine,
  1158. X; but it doesn't.
  1159. X;
  1160. X; Presumably this code will be unnecessary in later releases of the compiler.
  1161. X;
  1162. X
  1163. X; _save_stack saves the current SS:SP to be loaded later by _ss_interrupt.
  1164. X;
  1165. X
  1166. Xbeginproc _save_stack
  1167. X    mov ax,ss
  1168. X    mov cs:save_ss,ax
  1169. X    mov ax,sp
  1170. X    mov cs:save_sp,ax
  1171. X    ret
  1172. X_save_stack endp
  1173. X
  1174. X
  1175. X; _ss_interrupt is called on ^C (INT 23H).  It restores SS:SP as saved in
  1176. X; _save_stack and then jumps to the C routine interrupt().
  1177. X;
  1178. Xbeginproc _ss_interrupt
  1179. X    cli            ; no interrupts while the stack is changed!
  1180. X    mov ax,-1        ; self-modifying code again
  1181. Xsave_ss    equ this word - 2
  1182. X    mov ss,ax
  1183. X    mov sp,-1        ; here too
  1184. Xsave_sp equ this word - 2
  1185. X    sti
  1186. X    jmp _inter; now it's safe to call the real routine
  1187. X_ss_interrupt endp
  1188. X
  1189. X
  1190. X_text    ends
  1191. X
  1192. X
  1193. Xconst    segment
  1194. Xlinemask dw -1
  1195. Xcolor     db 1
  1196. Xconst    ends
  1197. X
  1198. X    end
  1199. *-*-END-of-pcgraph.asm-*-*
  1200. exit
  1201.  
  1202.  
  1203.