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

  1.  Include "equ.h"
  2.  Include "impequ.h"
  3.  
  4.  SECTION ftxt,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,ftxt
  18.  
  19. *
  20. * ftxt 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    #"FTXT",8(a1)
  28.     bne    never
  29.     moveq    #2,d0
  30. rrts:    rts
  31.  
  32.  
  33. ***
  34. *** Text File Import
  35. ***
  36.  
  37. *
  38. * ftxt
  39. *
  40. ftxt:    move.l    sp,savesp
  41.  
  42.     move.l    table,a0
  43.     move.l    f_openr(a0),a0
  44.     jsr    (a0)
  45.     beq    rrts
  46.  
  47.     move.l    table,a0
  48.     move.l    t_open(a0),a0
  49.     jsr    (a0)
  50.     beq    ftxt9
  51.  
  52.     bsr    pgetl        ;"FORM"
  53.     bsr    pgetl
  54.     move.l    d0,length
  55.     bsr    pgetl        ;"FTXT"
  56.     sub.l    #4,length
  57.  
  58. getchunk:
  59.     bsr    pgetl
  60.     move.l    d0,temp
  61.     bsr    pgetl
  62.     move.l    d0,clength
  63.     sub.l    #8,length
  64.     move.l    temp,d0
  65.  
  66.     lea    chunks-4,a0
  67.     move.w    #2,d1
  68. gc1:    lea    4(a0),a0
  69.     cmp.l    (a0)+,d0
  70.     dbeq    d1,gc1
  71.     move.l    (a0),a0
  72.     jsr    (a0)
  73.     tst.l    length
  74.     bne    getchunk
  75.  
  76. ftxt9:    move.l    table,a0
  77.     move.l    f_closer(a0),a0
  78.     jsr    (a0)
  79.     move.l    table,a0
  80.     move.l    t_close(a0),a0
  81.     jmp    (a0)
  82.  
  83.  
  84.  
  85. chunks:    dc.l    "FONS",fons
  86.     dc.l    "CHRS",chrs
  87.     dc.l    0,skip
  88.  
  89. ***********************************
  90. ***                ***
  91. ***********************************
  92. chrs:    move.l    clength,temp
  93. chrs1:    bsr    pget
  94.     cmp.b    #$a,d0
  95.     beq    chrcr
  96.     lea    ktoi,a0
  97.     and.w    #$ff,d0
  98.     move.b    0(a0,d0.w),d0
  99.     beq    chrs2
  100.     bsr    tput
  101.     bra    chrs2
  102. chrcr:    move.w    #CMD_CR,d0
  103.     bsr    tputw
  104. chrs2:    subq.l    #1,temp
  105.     bne    chrs1
  106.     bra    adjlen
  107.  
  108. fons:    bra    skip
  109.  
  110.  
  111. ***********************************
  112. ***                ***
  113. ***********************************
  114. adjlen:    move.l    clength,d0
  115.     btst    #0,d0
  116.     beq    al1
  117.     bsr    pget
  118.     move.l    clength,d0
  119.     add.l    #1,d0
  120.  
  121. al1:    sub.l    d0,length
  122.     rts
  123.  
  124.  
  125. ***********************************
  126. ***                ***
  127. ***********************************
  128. skip:    move.l    clength,d0
  129.     add.l    #1,d0
  130.     bclr    #0,d0
  131.     sub.l    d0,length
  132.  
  133. sk1:    move.l    d0,-(sp)
  134.     bsr    pgetw
  135.     move.l    (sp)+,d0
  136.     sub.l    #2,d0
  137.     bgt    sk1
  138.     rts
  139.  
  140.  
  141. ***********************************
  142. ***                ***
  143. ***********************************
  144. errrts:    move.l    savesp,sp
  145.  
  146.     move.l    table,a0
  147.     move.l    f_closer(a0),a0
  148.     jsr    (a0)
  149.  
  150.     move.l    table,a0
  151.     move.l    t_close(a0),a0
  152.     jmp    (a0)
  153.  
  154.  
  155. ***********************************
  156. ***                ***
  157. ***********************************
  158. pgetl:    move.l    table,a0
  159.     move.l    f_getl(a0),a0
  160.     jsr    (a0)
  161.     beq    errrts
  162.     rts
  163.  
  164. pgetw:    move.l    table,a0
  165.     move.l    f_getw(a0),a0
  166.     jsr    (a0)
  167.     beq    errrts
  168.     rts
  169.  
  170. pget:    move.l    table,a0
  171.     move.l    f_get(a0),a0
  172.     jsr    (a0)
  173.     beq    errrts
  174.     rts
  175.  
  176. tputw:    move.l    table,a0
  177.     move.l    t_putw(a0),a0
  178.     jsr    (a0)
  179.     beq    errrts
  180.     rts
  181.  
  182. tput:    move.l    table,a0
  183.     move.l    t_put(a0),a0
  184.     jsr    (a0)
  185.     beq    errrts
  186.     rts
  187.  
  188. *******************************************************************
  189. ***    called when the import routine choosen finds something    ***
  190. ***    wrong with the file loaded.                ***
  191. *******************************************************************
  192. notright:
  193.     rts
  194.  
  195. never:    moveq    #0,d0
  196.     rts
  197.  
  198. maybe:    moveq    #1,d0
  199.     rts
  200.  
  201. right:    moveq    #2,d0
  202.     rts
  203.  
  204. ***********************************************************
  205. ***                            ***
  206. ***********************************************************
  207.  SECTION ftxt,DATA,PUBLIC
  208.  
  209. *
  210. special:
  211.     dc.w    1
  212.     dc.l    spcl1
  213. *
  214. name:    dc.b    "IFF FTXT v2.0.0",0
  215. *
  216. spcl1:    dc.b    "Formatted Text",0
  217. *
  218.  
  219. * AMIGA ktoi
  220. ktoi:    dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$00-$07
  221.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$08-$0f
  222.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$10-$17
  223.     dc.b    $00,$00,$00,$00,$00,$00,$00,$00        ;$18-$1f
  224.     dc.b    $20,$21,$22,$23,$24,$25,$26,$27
  225.     dc.b    $28,$29,$2a,$2b,$2c,$2d,$2e,$2f
  226.     dc.b    $30,$31,$32,$33,$34,$35,$36,$37
  227.     dc.b    $38,$39,$3a,$3b,$3c,$3d,$3e,$3f
  228.     dc.b    $40,$41,$42,$43,$44,$45,$46,$47
  229.     dc.b    $48,$49,$4a,$4b,$4c,$4d,$4e,$4f
  230.     dc.b    $50,$51,$52,$53,$54,$55,$56,$57
  231.     dc.b    $58,$59,$5a,$5b,$5c,$5d,$5e,$5f
  232.     dc.b    $60,$61,$62,$63,$64,$65,$66,$67
  233.     dc.b    $68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  234.     dc.b    $70,$71,$72,$73,$74,$75,$76,$77
  235.     dc.b    $78,$79,$7a,$7b,$7c,$7d,$7e,$00
  236.  
  237.     dc.b    000,000,000,000,000,000,000,000        ;$80
  238.     dc.b    000,000,000,000,000,000,000,000        ;$88
  239.     dc.b    000,000,000,000,000,000,000,000        ;$90
  240.     dc.b    000,000,000,000,000,000,000,000        ;$98
  241.     dc.b    000,186,162,163,160,161,142,165        ;$a0
  242.     dc.b    000,183,188,136,141,173,184,129        ;$a8
  243.     dc.b    155,140,148,149,166,153,181,172        ;$b0
  244.     dc.b    000,147,156,137,144,145,146,185        ;$b8
  245.     dc.b    192,193,194,195,196,197,198,199        ;$c0
  246.     dc.b    200,201,202,203,204,205,206,207        ;$c8
  247.     dc.b    157,209,210,211,212,213,214,138        ;$d0
  248.     dc.b    159,217,218,219,220,221,158,187        ;$d8
  249.     dc.b    224,225,226,227,228,229,230,231        ;$e0
  250.     dc.b    232,233,234,235,236,237,238,239        ;$e8
  251.     dc.b    189,241,242,243,244,245,246,139        ;$f0
  252.     dc.b    191,249,250,251,252,253,190,254        ;$f8
  253.  
  254.  
  255.  
  256.  SECTION ftxt,BSS,PUBLIC
  257. savesp:        ds.l    1
  258. clength:    ds.l    1
  259. length:        ds.l    1
  260. temp:        ds.l    1
  261.