home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / apps / dtp / pgsmodst / atariimp / 1stword.s next >
Text File  |  1991-05-23  |  5KB  |  266 lines

  1.  Include "equ.h"
  2.  Include "impequ.h"
  3.  
  4. TAB    equ    9
  5. CR    equ    $d
  6. LF    equ    $a
  7. FF    equ    $c
  8. ESC    equ    $1b
  9.  
  10.  SECTION firstword,CODE,PUBLIC
  11. ***************************************************
  12. ***                        ***
  13. ***************************************************
  14. dumbentry:
  15.     clr.l    d0
  16.     rts
  17.  
  18.     dc.l    "IMPT"
  19.     dc.w    200
  20.     dc.l    0
  21.  
  22. table:    dc.l    0
  23.     dc.l    name,special,check,_1stword
  24.  
  25. *
  26. * 1stWord Check routine
  27. *
  28. check:    move.l    table,a0
  29.     move.l    buff1(a0),a1
  30.     move.l    (a1),a1
  31.     cmp.b    #$1f,(a1)+
  32.     bne    never
  33.     moveq    #2,d0
  34. irts:    rts
  35.  
  36.  
  37. ***
  38. *** Text File Import
  39. ***
  40.  
  41. *
  42. * First Word
  43. *
  44. _1stword:
  45.     move.l    table,a0
  46.     move.l    f_openr(a0),a0
  47.     jsr    (a0)
  48.     beq    ascii9
  49.  
  50.     move.l    table,a0
  51.     move.l    t_open(a0),a0
  52.     jsr    (a0)
  53.     beq    ascii9
  54.  
  55.     clr.b    crflag
  56.     clr.b    tabflag
  57. ascii1:    move.l    table,a0
  58.     move.l    f_get(a0),a0
  59.     jsr    (a0)
  60.     beq    ascii9
  61.  
  62.     cmp.b    #$20,d0
  63.     beq    dotab
  64.     cmp.b    #$1f,d0
  65.     beq    header
  66.     cmp.b    #ESC,d0
  67.     beq    command
  68.     cmp.b    #$1e,d0
  69.     beq    dosp
  70.     cmp.b    #CR,d0
  71.     beq    docr
  72.  
  73.     and.w    #$ff,d0
  74.     lea    ktoi,a0
  75.     tst.b    0(a0,d0.w)
  76.     bne    tput
  77.     bra    ascii1
  78. *
  79. command:
  80.     move.l    table,a0
  81.     move.l    f_get(a0),a0
  82.     jsr    (a0)
  83.     beq    ascii9
  84.     move.b    d0,cmd
  85.     move.b    pcmd,d1
  86.     and.b    #%1111,d0
  87.     and.b    #%1111,d1
  88.     cmp.b    d0,d1
  89.     beq    noattrb
  90.     moveq    #0,d1
  91.     btst    #0,d0
  92.     beq    nbold
  93.     bset    #BOLD,d1
  94. nbold:    btst    #1,d0
  95.     beq    nlht
  96.     bset    #LIGHT,d1
  97. nlht:    btst    #2,d0
  98.     beq    nital
  99.     bset    #ITALICS,d1
  100. nital:    btst    #3,d0
  101.     beq    nuln
  102.     bset    #UNDER,d1
  103. nuln:    move.w    d1,-(sp)
  104.     move.w    #CMD_AT,d0
  105.     move.l    table,a0
  106.     move.l    t_putw(a0),a0
  107.     jsr    (a0)
  108.     beq    ascii9
  109.     moveq    #0,d0
  110.     move.w    (sp)+,d0
  111.     move.l    table,a0
  112.     move.l    t_putl(a0),a0
  113.     jsr    (a0)
  114.     beq    ascii9
  115.  
  116. noattrb:
  117.     move.b    cmd,d0
  118.     move.b    pcmd,d1
  119.     and.b    #%110000,d0
  120.     and.b    #%110000,d1
  121.     cmp.b    d0,d1
  122.     beq    nobsln
  123.  
  124.     moveq    #0,d1
  125.     btst    #4,d0
  126.     beq    nsuper
  127.     move.w    #200,d1
  128. nsuper:    btst    #5,d0
  129.     beq    nsub
  130.     move.w    #-200,d1
  131. nsub:    move.w    d1,-(sp)
  132.     move.w    #CMD_BMOD,d0
  133.     move.l    table,a0
  134.     move.l    t_putw(a0),a0
  135.     jsr    (a0)
  136.     beq    ascii9
  137.     move.w    (sp)+,d0
  138.     move.l    table,a0
  139.     move.l    t_putw(a0),a0
  140.     jsr    (a0)
  141.     beq    ascii9
  142.  
  143. nobsln:    move.b    cmd,pcmd
  144.     bra    ascii1
  145. *
  146. header:    move.l    table,a0
  147.     move.l    f_get(a0),a0
  148.     jsr    (a0)
  149.     beq    ascii9
  150.     cmp.b    #LF,d0
  151.     bne    header
  152.     bra    ascii1
  153. *
  154. dosp:    bset    #0,crflag
  155.     move.b    #$20,d0
  156.     bra    tput0
  157. *
  158. docr:    bclr    #0,crflag
  159.     bne    ascii1
  160.     move.w    #CMD_CR,d0
  161.     bra    tputw
  162. *
  163. dotab:    bset    #0,tabflag
  164.     bne    ascii1
  165.     move.w    #CMD_TAB,d0
  166.     bra    tputw
  167. *
  168. * put as is
  169. *
  170. tput:    move.b    0(a0,d0.w),d0
  171.     clr.b    crflag
  172. tput0:    move.l    table,a0
  173.     move.l    t_put(a0),a0
  174.     jsr    (a0)
  175.     beq    ascii9
  176.     clr.b    tabflag
  177.     bra    ascii1
  178. *
  179. * end of input file.  close and flush buffer
  180. *
  181. ascii9:    move.l    table,a0
  182.     move.l    f_closer(a0),a0
  183.     jsr    (a0)
  184.     move.l    table,a0
  185.     move.l    t_close(a0),a0
  186.     jmp    (a0)
  187.  
  188. tputw:    move.l    table,a0
  189.     move.l    t_putw(a0),a0
  190.     jsr    (a0)
  191.     beq    ascii9
  192.     bra    ascii1
  193.  
  194.  
  195. *******************************************************************
  196. ***    called when the import routine choosen finds something    ***
  197. ***    wrong with the file loaded.                ***
  198. *******************************************************************
  199. notright:
  200.     rts
  201.  
  202. never:    moveq    #0,d0
  203.     rts
  204.  
  205. maybe:    moveq    #1,d0
  206.     rts
  207.  
  208. right:    moveq    #2,d0
  209.     rts
  210.  
  211. ***********************************************************
  212. ***                            ***
  213. ***********************************************************
  214.  SECTION firstword,DATA,PUBLIC
  215.  
  216. *
  217. special:
  218.     dc.w    1
  219.     dc.l    spcl1
  220. *
  221. name:    dc.b    "1st Word v2.0.1",0
  222. *
  223. spcl1:    dc.b    "Formatted Text",0
  224. *
  225.  
  226. ktoi:    dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$00-$07
  227.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$08-$0f
  228.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$10-$17
  229.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$18-$1f
  230.     dc.b    $20,$21,$22,$23,$24,$25,$26,$27
  231.     dc.b    $28,$29,$2a,$2b,$2c,$2d,$2e,$2f
  232.     dc.b    $30,$31,$32,$33,$34,$35,$36,$37
  233.     dc.b    $38,$39,$3a,$3b,$3c,$3d,$3e,$3f
  234.     dc.b    $40,$41,$42,$43,$44,$45,$46,$47
  235.     dc.b    $48,$49,$4a,$4b,$4c,$4d,$4e,$4f
  236.     dc.b    $50,$51,$52,$53,$54,$55,$56,$57
  237.     dc.b    $58,$59,$5a,$5b,$5c,$5d,$5e,$5f
  238.     dc.b    $60,$61,$62,$63,$64,$65,$66,$67
  239.     dc.b    $68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  240.     dc.b    $70,$71,$72,$73,$74,$75,$76,$77
  241.     dc.b    $78,$79,$7a,$7b,$7c,$7d,$7e,$00
  242.     dc.b    199,252,233,226,228,224,229,231
  243.     dc.b    234,235,232,239,238,236,196,197
  244.     dc.b    201,230,198,244,246,242,251,249
  245.     dc.b    254,214,220,162,163,161,187,164
  246.     dc.b    225,237,243,250,241,209,189,156
  247.     dc.b    185,000,141,145,144,186,136,137
  248.     dc.b    227,245,159,191,247,215,192,195
  249.     dc.b    213,000,000,180,181,183,184,182
  250.     dc.b    000,000,138,000,000,000,000,000
  251.     dc.b    000,000,000,000,000,000,000,000
  252.     dc.b    000,000,000,000,000,000,000,000
  253.     dc.b    000,000,000,000,000,165,000,151
  254.     dc.b    000,000,000,150,000,000,153,000
  255.     dc.b    000,000,000,000,000,160,000,000
  256.     dc.b    131,140,135,134,000,000,139,130
  257.     dc.b    155,172,171,128,147,148,149,173
  258.  
  259.  
  260.  SECTION firstword,BSS,PUBLIC
  261.  
  262. cmd:        ds.b    1
  263. pcmd:        ds.b    1
  264. crflag:        ds.b    1
  265. tabflag:    ds.b    1
  266.