home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / apps / dtp / pgsmodst / atariimp / prowrite.s < prev    next >
Text File  |  1991-05-23  |  10KB  |  650 lines

  1.  Include "equ.h"
  2.  Include "impequ.h"
  3.  
  4.  SECTION prowrite,CODE,PUBLIC
  5. ***************************************************
  6. ***                        ***
  7. ***************************************************
  8. dumbentry:
  9.     clr.l    d0
  10.     rts
  11.  
  12.     dc.l    "IMPT"
  13.     dc.w    200
  14.     dc.l    0
  15.  
  16. table:    dc.l    0
  17.     dc.l    name,special,check,prowrite
  18.  
  19. *
  20. * Excellence Check routine
  21. *
  22. check:    move.l    table,a0
  23.     move.l    buff1(a0),a1
  24.     move.l    (a1),a1
  25.     cmp.l    #"FORM",(a1)
  26.     bne    never
  27.     cmp.l    #"WORD",8(a1)
  28.     bne    never
  29.     moveq    #2,d0
  30. rrts:    rts
  31.  
  32.  
  33. ***
  34. *** Text File Import
  35. ***
  36.  
  37. *
  38. * ProWrite
  39. *
  40. prowrite:
  41.     move.l    sp,savesp
  42.  
  43.     move.l    table,a0
  44.     move.l    f_openr(a0),a0
  45.     jsr    (a0)
  46.     beq    rrts
  47.  
  48.     move.l    table,a0
  49.     move.l    t_open(a0),a0
  50.     jsr    (a0)
  51.     beq    ftxt9
  52.  
  53.     jsr    pgetl        ;"FORM"
  54.     jsr    pgetl
  55.     move.l    d0,length
  56.     jsr    pgetl        ;"WORD"
  57.     sub.l    #4,length
  58.  
  59.     clr.b    tflag
  60.  
  61.     clr.b    newstyle
  62.     move.b    #1,readflag
  63.     move.w    #1200,curpoint
  64.  
  65. getchunk:
  66.     jsr    pgetl
  67.     move.l    d0,temp
  68.     jsr    pgetl
  69.     move.l    d0,clength
  70.     sub.l    #8,length
  71.  
  72.     move.l    temp,d0
  73.     lea    chunks-4,a0
  74.     move.w    #12,d1
  75. gc1:    lea    4(a0),a0
  76.     cmp.l    (a0)+,d0
  77.     dbeq    d1,gc1
  78.     move.l    (a0),a0
  79.     jsr    (a0)
  80.     tst.l    length
  81.     bne    getchunk
  82.  
  83. ftxt9:    jsr    tflush
  84.  
  85.     move.l    table,a0
  86.     move.l    f_closer(a0),a0
  87.     jsr    (a0)
  88.     move.l    table,a0
  89.     move.l    t_close(a0),a0
  90.     jmp    (a0)
  91.  
  92.  
  93. chunks:    dc.l    "FONT",font
  94.     dc.l    "COLR",skip
  95.     dc.l    "DOC ",doc
  96.     dc.l    "HEAD",head
  97.     dc.l    "FOOT",foot
  98.     dc.l    "PCTS",skip
  99.     dc.l    "PARA",para
  100.     dc.l    "TABS",skip
  101.     dc.l    "PAGE",skip
  102.     dc.l    "TEXT",text
  103.     dc.l    "FSCC",fscc
  104.     dc.l    "PINF",skip
  105.     dc.l    0,skip
  106.  
  107.  
  108. ***********************************
  109. ***                ***
  110. ***********************************
  111. font:    jsr    pget            ;font number
  112.     move.b    d0,temp
  113.     jsr    pget            ;pad
  114.  
  115.     jsr    pgetw            ;font size
  116.     mulu    #100,d0
  117.     lea    pntlist,a0
  118.     moveq    #0,d1
  119.     move.b    temp,d1
  120.     lsl.w    #1,d1
  121.     move.w    d0,0(a0,d1.w)
  122.  
  123.     move.l    clength,d0
  124.     addq.l    #1,d0
  125.     bclr    #0,d0
  126.     sub.l    d0,length
  127.     subq.l    #4,d0
  128.     bra    skippy
  129.  
  130. skippy:    tst.l    d0
  131.     beq    rrts
  132.     move.l    d0,-(sp)
  133.     jsr    pget
  134.     move.l    (sp)+,d0
  135.     sub.l    #1,d0
  136.     bra    skippy
  137.  
  138.  
  139. ***********************************
  140. ***                ***
  141. ***********************************
  142. doc:    bsr    tflush
  143.     move.b    #1,readflag
  144.     clr.b    newstyle
  145.     bra    skip
  146.  
  147. ***********************************
  148. ***                ***
  149. ***********************************
  150. head:    bsr    tflush
  151.     clr.b    readflag
  152.     bra    skip
  153.  
  154. ***********************************
  155. ***                ***
  156. ***********************************
  157. foot:    bsr    tflush
  158.     clr.b    readflag
  159.     bra    skip
  160.  
  161. ***********************************
  162. ***                ***
  163. ***********************************
  164. para:    bsr    tflush
  165.     tst.b    readflag
  166.     beq    skip
  167.  
  168.     clr.b    newstyle
  169.  
  170.     move.w    #CMD_PIN,d0        ;paragraph indent
  171.     bsr    tputw
  172.     bsr    pgetw            ;indent
  173.     move.w    d0,temp
  174.     bsr    pgetw            ;left margin
  175.     sub.w    temp,d0
  176.     neg.w    d0
  177.     muls    #10,d0
  178.     bsr    tputw
  179.     bsr    pgetw            ;right margin
  180.  
  181.  
  182.     move.w    #CMD_LSP,d0        ;line spacing
  183.     bsr    tputw
  184.     bsr    pget
  185.     and.w    #$ff,d0
  186.     lsr.w    #4,d0
  187.     addq.w    #1,d0
  188.     mulu    curpoint,d0
  189.     bsr    tputw
  190.  
  191.     move.w    #CMD_JST,d0        ;justification
  192.     bsr    tputw
  193.     bsr    pget
  194.     bsr    tput
  195.  
  196.     bsr    pget            ;font number
  197.     lea    pntlist,a0
  198.     and.w    #$ff,d0
  199.     lsl.w    #1,d0
  200.     move.w    0(a0,d0.w),curpoint
  201.     move.w    0(a0,d0.w),parapoint
  202.     move.w    #CMD_PT,d0
  203.     jsr    tputw
  204.     moveq    #0,d0
  205.     move.w    curpoint,d0
  206.     jsr    tputl
  207.     moveq    #0,d0
  208.     move.w    curpoint,d0
  209.     jsr    tputl
  210.  
  211.     move.w    #CMD_AT,d0        ;style
  212.     jsr    tputw
  213.     bsr    pget
  214.     moveq    #0,d1
  215.     btst    #0,d0
  216.     beq    newa1
  217.     bset    #UNDER,d1
  218. newa1:    btst    #1,d0
  219.     beq    newa2
  220.     bset    #BOLD,d1
  221. newa2:    btst    #2,d0
  222.     beq    newa3
  223.     bset    #ITALICS,d1
  224. newa3:    move.l    d1,d0
  225.     move.w    d0,parastyle
  226.     jsr    tputl
  227.  
  228.     move.w    #CMD_BMOD,d0        ;super/sub
  229.     bsr    tputw
  230.     bsr    pget
  231.     moveq    #0,d1
  232.     cmp.b    #1,d0
  233.     bne    para1
  234.     move.w    curpoint,d1
  235.     lsr.w    #1,d1
  236. para1:    cmp.b    #2,d0
  237.     bne    para2
  238.     move.w    curpoint,d1
  239.     lsr.w    #1,d1
  240.     neg.w    d1
  241. para2:    move.w    d1,d0
  242.     move.w    d0,parabmod
  243.     bsr    tputw
  244.  
  245.     bsr    pget        ;color
  246.     bsr    pgetl        ;pad
  247.  
  248.     bra    adjlen
  249.  
  250. ***********************************
  251. ***                ***
  252. ***********************************
  253. text:    bsr    tflush
  254.     tst.b    readflag
  255.     beq    skip
  256.  
  257.     tst.b    newstyle
  258.     beq    text0
  259.     clr.b    newstyle
  260.     move.w    #CMD_PT,d0
  261.     bsr    tputw
  262.     moveq    #0,d0
  263.     move.w    parapoint,d0
  264.     bsr    tputl
  265.     moveq    #0,d0
  266.     move.w    parapoint,d0
  267.     bsr    tputl
  268.     move.w    #CMD_AT,d0
  269.     bsr    tputw
  270.     moveq    #0,d0
  271.     move.w    parastyle,d0
  272.     bsr    tputl
  273.     move.w    #CMD_BMOD,d0
  274.     bsr    tputw
  275.     move.w    parabmod,d0
  276.     bsr    tputw
  277.  
  278. text0:
  279.  
  280.     move.l    clength,d0
  281.     clr.w    d1
  282.     clr.w    d2
  283.     move.l    table,a1
  284.     move.l    m_alloc(a1),a1
  285.     jsr    (a1)
  286.     move.l    a0,thandle
  287.     move.b    #1,tflag
  288.  
  289.     move.l    clength,temp
  290.     clr.l    tlength
  291.     clr.l    toffset
  292.     bra    text3
  293. text1:    jsr    pget
  294.     tst.b    d0
  295.     bne    text2
  296.     moveq    #1,d0
  297. text2:    jsr    qput
  298. text3:    subq.l    #1,temp
  299.     bcc    text1
  300.  
  301.     bra    adjlen
  302.  
  303.  
  304. qput:    move.l    thandle,a0
  305.     move.l    (a0),a0
  306.     add.l    tlength,a0
  307.     move.b    d0,(a0)
  308.     addq.l    #1,tlength
  309.     rts
  310.  
  311.  
  312.  
  313. tflush:    tst.b    tflag
  314.     beq    rrts
  315.     clr.b    tflag
  316.     clr.l    temp
  317.     clr.w    count
  318.     bra    tf9
  319. tf1:    move.l    thandle,a0
  320.     move.l    (a0),a0
  321.     add.l    temp,a0
  322.     move.b    (a0),d0
  323.     tst.w    count
  324.     beq    tf3
  325.     subq.w    #1,count
  326.     bra    tf8
  327. tf3:    tst.b    d0
  328.     bne    tf7
  329.     moveq    #0,d1
  330.     move.b    1(a0),d1
  331.     move.l    table,a1
  332.     move.l    cmdlength(a1),a1
  333.     move.b    0(a1,d1.w),d1
  334.     addq.w    #1,d1
  335.     move.w    d1,count
  336.     bra    tf8
  337. tf7:    cmp.b    #$9,d0
  338.     beq    txttab
  339.     and.w    #$ff,d0
  340.     lea    ktoi,a0
  341.     move.b    0(a0,d0.w),d0
  342.     beq    tf10
  343.     bra    tf8
  344. txttab:    move.w    #CMD_TAB,d0
  345.     bsr    tputw
  346.     bra    tf10
  347. tf8:    bsr    tput
  348. tf10:    addq.l    #1,temp
  349. tf9:    subq.l    #1,tlength
  350.     bcc    tf1
  351.  
  352.     move.w    #CMD_CR,d0
  353.     bsr    tputw
  354.  
  355.     move.l    thandle,a0
  356.     move.l    table,a1
  357.     move.l    m_delete(a1),a1
  358.     jsr    (a1)
  359.     rts
  360.  
  361. ***********************************
  362. ***                ***
  363. ***********************************
  364. fscc:    tst.b    readflag
  365.     beq    skip
  366.     tst.b    tflag
  367.     beq    skip
  368.  
  369. topfscc:
  370.     move.b    #1,newstyle
  371.     move.l    table,a1
  372.     move.l    m_grow(a1),a1
  373.     move.l    thandle,a0
  374.     move.l    #20,d0
  375.     jsr    (a1)
  376.     add.l    #20,tlength
  377.  
  378.     bsr    pgetw            ;TEXT chunk byte offset for change
  379.     and.l    #$ffff,d0
  380.     add.l    toffset,d0
  381.     move.l    d0,temp
  382.     add.l    #20,toffset
  383.     move.l    thandle,a0
  384.     move.l    (a0),a0
  385.     move.l    a0,a1
  386.     add.l    d0,a0
  387.     add.l    tlength,a1
  388.     move.l    a1,a2
  389.     sub.l    #20,a2
  390. fscc0:    move.b    -(a2),-(a1)
  391.     cmp.l    a0,a2
  392.     bhi    fscc0
  393.  
  394.     bsr    pget            ;font number (point size - 6)
  395.     lea    pntlist,a0
  396.     and.w    #$ff,d0
  397.     lsl.w    #1,d0
  398.     move.w    0(a0,d0.w),curpoint
  399.     move.w    #CMD_PT,d0
  400.     jsr    sputw
  401.     moveq    #0,d0
  402.     move.w    curpoint,d0
  403.     jsr    sputl
  404.     moveq    #0,d0
  405.     move.w    curpoint,d0
  406.     jsr    sputl
  407.  
  408.     move.w    #CMD_AT,d0        ;style (4)
  409.     jsr    sputw
  410.     bsr    pget
  411.     moveq    #0,d1
  412.     btst    #0,d0
  413.     beq    fscc1
  414.     bset    #UNDER,d1
  415. fscc1:    btst    #1,d0
  416.     beq    fscc2
  417.     bset    #BOLD,d1
  418. fscc2:    btst    #2,d0
  419.     beq    fscc3
  420.     bset    #ITALICS,d1
  421. fscc3:    move.l    d1,d0
  422.     jsr    sputl
  423.  
  424.     move.w    #CMD_BMOD,d0        ;super/sub (4)
  425.     bsr    sputw
  426.     bsr    pget
  427.     moveq    #0,d1
  428.     cmp.b    #1,d0
  429.     bne    fscc7
  430.     move.w    curpoint,d1
  431.     lsr.w    #1,d1
  432. fscc7:    cmp.b    #2,d0
  433.     bne    fscc8
  434.     move.w    curpoint,d1
  435.     lsr.w    #1,d1
  436.     neg.w    d1
  437. fscc8:    move.w    d1,d0
  438.     bsr    sputw
  439.  
  440.     bsr    pget        ;color
  441.  
  442.     bsr    pgetw        ;pad
  443.  
  444.     sub.l    #8,length
  445.     sub.l    #8,clength
  446.     bhi    topfscc
  447.     rts
  448.  
  449.  
  450. sputl:    move.l    thandle,a0
  451.     move.l    (a0),a0
  452.     add.l    temp,a0
  453.  
  454.     move.b    d0,3(a0)
  455.     lsr.l    #8,d0
  456.     move.b    d0,2(a0)
  457.     lsr.l    #8,d0
  458.     move.b    d0,1(a0)
  459.     lsr.l    #8,d0
  460.     move.b    d0,(a0)
  461.  
  462.     addq.l    #4,temp
  463.     rts
  464.  
  465. sputw:    move.l    thandle,a0
  466.     move.l    (a0),a0
  467.     add.l    temp,a0
  468.     move.b    d0,1(a0)
  469.     lsr.w    #8,d0
  470.     move.b    d0,(a0)
  471.     addq.l    #2,temp
  472.     rts
  473.  
  474. sput:    move.l    thandle,a0
  475.     move.l    (a0),a0
  476.     add.l    temp,a0
  477.     move.b    d0,(a0)
  478.     addq.l    #1,temp
  479.     rts
  480.  
  481.  
  482. ***********************************
  483. ***                ***
  484. ***********************************
  485. adjlen:    move.l    clength,d0
  486.     btst    #0,d0
  487.     beq    al1
  488.     jsr    pget
  489.     move.l    clength,d0
  490.     add.l    #1,d0
  491.  
  492. al1:    sub.l    d0,length
  493.     rts
  494.  
  495.  
  496. ***********************************
  497. ***                ***
  498. ***********************************
  499. skip:    move.l    clength,d0
  500.     add.l    #1,d0
  501.     bclr    #0,d0
  502.     sub.l    d0,length
  503.  
  504. sk1:    tst.l    d0
  505.     beq    rrts
  506.     move.l    d0,-(sp)
  507.     jsr    pgetw
  508.     move.l    (sp)+,d0
  509.     sub.l    #2,d0
  510.     bra    sk1
  511.  
  512. ***********************************
  513. ***                ***
  514. ***********************************
  515. errrts:    move.l    savesp,sp
  516.  
  517.     move.l    table,a0
  518.     move.l    f_closer(a0),a0
  519.     jsr    (a0)
  520.  
  521.     move.l    table,a0
  522.     move.l    t_close(a0),a0
  523.     jmp    (a0)
  524.  
  525.  
  526. ***********************************
  527. ***                ***
  528. ***********************************
  529. pgetl:    move.l    table,a0
  530.     move.l    f_getl(a0),a0
  531.     jsr    (a0)
  532.     beq    errrts
  533.     rts
  534.  
  535. pgetw:    move.l    table,a0
  536.     move.l    f_getw(a0),a0
  537.     jsr    (a0)
  538.     beq    errrts
  539.     rts
  540.  
  541. pget:    move.l    table,a0
  542.     move.l    f_get(a0),a0
  543.     jsr    (a0)
  544.     beq    errrts
  545.     rts
  546.  
  547. tputw:    move.l    table,a0
  548.     move.l    t_putw(a0),a0
  549.     jsr    (a0)
  550.     beq    errrts
  551.     rts
  552.  
  553. tputl:    move.l    table,a0
  554.     move.l    t_putl(a0),a0
  555.     jsr    (a0)
  556.     beq    errrts
  557.     rts
  558.  
  559. tput:    move.l    table,a0
  560.     move.l    t_put(a0),a0
  561.     jsr    (a0)
  562.     beq    errrts
  563.     rts
  564.  
  565. *******************************************************************
  566. ***    called when the import routine choosen finds something    ***
  567. ***    wrong with the file loaded.                ***
  568. *******************************************************************
  569. notright:
  570.     rts
  571.  
  572. never:    moveq    #0,d0
  573.     rts
  574.  
  575. maybe:    moveq    #1,d0
  576.     rts
  577.  
  578. right:    moveq    #2,d0
  579.     rts
  580.  
  581. ***********************************************************
  582. ***                            ***
  583. ***********************************************************
  584.  SECTION prowrite,DATA,PUBLIC
  585.  
  586. ktoi:    dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$00-$07
  587.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$08-$0f
  588.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$10-$17
  589.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$18-$1f
  590.     dc.b    $20,$21,$22,$23,$24,$25,$26,$27
  591.     dc.b    $28,$29,$2a,$2b,$2c,$2d,$2e,$2f
  592.     dc.b    $30,$31,$32,$33,$34,$35,$36,$37
  593.     dc.b    $38,$39,$3a,$3b,$3c,$3d,$3e,$3f
  594.     dc.b    $40,$41,$42,$43,$44,$45,$46,$47
  595.     dc.b    $48,$49,$4a,$4b,$4c,$4d,$4e,$4f
  596.     dc.b    $50,$51,$52,$53,$54,$55,$56,$57
  597.     dc.b    $58,$59,$5a,$5b,$5c,$5d,$5e,$5f
  598.     dc.b    $60,$61,$62,$63,$64,$65,$66,$67
  599.     dc.b    $68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  600.     dc.b    $70,$71,$72,$73,$74,$75,$76,$77
  601.     dc.b    $78,$79,$7a,$7b,$7c,$7d,$7e,$00
  602.  
  603.     dc.b    000,000,000,000,000,000,000,000        ;$80
  604.     dc.b    000,000,000,000,000,000,000,000        ;$88
  605.     dc.b    000,000,000,000,000,000,000,000        ;$90
  606.     dc.b    000,000,000,000,000,000,000,000        ;$98
  607.     dc.b    000,186,162,163,160,161,142,165        ;$a0
  608.     dc.b    000,183,188,136,141,173,184,129        ;$a8
  609.     dc.b    155,140,148,149,166,153,181,172        ;$b0
  610.     dc.b    000,147,156,137,144,145,146,185        ;$b8
  611.     dc.b    192,193,194,195,196,197,198,199        ;$c0
  612.     dc.b    200,201,202,203,204,205,206,207        ;$c8
  613.     dc.b    157,209,210,211,212,213,214,138        ;$d0
  614.     dc.b    159,217,218,219,220,221,158,187        ;$d8
  615.     dc.b    224,225,226,227,228,229,230,231        ;$e0
  616.     dc.b    232,233,234,235,236,237,238,239        ;$e8
  617.     dc.b    189,241,242,243,244,245,246,139        ;$f0
  618.     dc.b    191,249,250,251,252,253,190,254        ;$f8
  619.  
  620. special:
  621.     dc.w    1
  622.     dc.l    spcl1
  623. *
  624. name:    dc.b    "ProWrite v2.0.2",0
  625. *
  626. spcl1:    dc.b    "Formatted Text",0
  627. *
  628.  
  629.  
  630. *
  631.  
  632.  SECTION prowrite,BSS,PUBLIC
  633. savesp:        ds.l    1
  634. clength:    ds.l    1
  635. length:        ds.l    1
  636. temp:        ds.l    1
  637. thandle:    ds.l    1
  638. tlength:    ds.l    1
  639. toffset:    ds.l    1
  640. pntlist:    ds.w    256
  641. parapoint:    ds.w    1
  642. parastyle:    ds.w    1
  643. parabmod:    ds.w    1
  644. count:        ds.w    1
  645. curpoint:    ds.w    1
  646. newstyle:    ds.b    1
  647. readflag:    ds.b    1
  648. tflag:        ds.b    1
  649.         ds.b    1
  650.