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

  1.  
  2.  Include "equ.h"
  3.  Include "impequ.h"
  4.  
  5. CR    equ    $d
  6. LF    equ    $a
  7.  
  8.  SECTION eps,CODE,PUBLIC
  9. *******************************************
  10. ***                    ***
  11. *******************************************
  12. dumbentry:
  13.     clr.l    d0
  14.     rts
  15.  
  16.     dc.l    "IMPO"
  17.     dc.w    201
  18.     dc.l    0
  19.  
  20. table:    dc.l    0
  21.     dc.l    name,special,check,eps
  22.  
  23. *
  24. * Encapsulated PostScript
  25. *
  26. check:    move.l    table,a0
  27.     move.l    buff1(a0),a1
  28.     move.l    (a1),a1
  29.     lea    epsfhdr,a2
  30. chk1:    cmp.b    (a2)+,(a1)+
  31.     bne    never
  32.     tst.b    (a2)
  33.     bne    chk1
  34.     moveq    #2,d0
  35. rrts:    rts
  36.  
  37. *
  38. *
  39. *
  40. eps:    bsr    geteps
  41.     beq    rrts
  42.  
  43.     move.b    #teps,object+ob_Type
  44.     clr.b    object+ob_Flag
  45.     clr.w    object+ob_Slant
  46.     clr.w    object+ob_Twist
  47.     move.w    #50,object+ob_LWidth
  48.     clr.b    object+ob_LType
  49.     move.b    #1,object+ob_LColor
  50.     clr.b    object+ob_FType
  51.     move.b    #1,object+ob_FColor
  52.     clr.b    object+ob_LBegin
  53.     clr.b    object+ob_LEnd
  54.     move.w    #900,object+ob_HStandOff
  55.     move.w    #900,object+ob_VStandOff
  56.  
  57.     clr.l    object+ob_Left
  58.     clr.l    object+ob_Top
  59.     move.l    eright,d0
  60.     sub.l    eleft,d0
  61.     bpl    eps1
  62.     neg.l    d0
  63. eps1:    move.l    etop,d1
  64.     sub.l    ebottom,d1
  65.     bpl    eps2
  66.     neg.l    d1
  67. eps2:    mulu    #100,d0
  68.     mulu    #100,d1
  69.     move.l    d0,object+ob_Right
  70.     move.l    d1,object+ob_Bottom
  71.  
  72.     move.l    table,a0
  73.     move.l    o_open(a0),a0
  74.     jsr    (a0)
  75.  
  76.     move.l    table,a1
  77.     move.l    o_obj(a1),a1
  78.     lea    object,a0
  79.     jsr    (a1)
  80.     beq    abortobj
  81.  
  82.     move.l    elength,d0
  83.     add.l    #eps_Sizeof,d0
  84.     add.l    #16,d0
  85.     move.l    table,a0
  86.     move.l    o_malloc(a0),a0
  87.     jsr    (a0)
  88.     beq    abortobj
  89.  
  90.     move.w    #3,eps_Type(a0)
  91.     move.l    object+ob_Right,eps_Width(a0)
  92.     move.l    object+ob_Bottom,eps_Height(a0)
  93.     clr.l    eps_PicPtr(a0)
  94.     clr.l    eps_PlyPtr(a0)
  95.     move.l    elength,d0
  96.     add.l    #16,d0
  97.     move.l    d0,eps_DataLen(a0)
  98.  
  99.     lea    eps_Sizeof(a0),a0
  100.     move.l    eleft,(a0)+
  101.     move.l    ebottom,(a0)+
  102.     move.l    eright,(a0)+
  103.     move.l    etop,(a0)+
  104.  
  105.     move.l    ehandle,a1
  106.     move.l    (a1),a1
  107.     move.l    elength,d0
  108.     move.l    d0,d1
  109.     swap    d1
  110.     bra    ce2
  111. ce1:    move.b    (a1)+,(a0)+
  112. ce2:    dbf    d0,ce1
  113.     dbf    d1,ce1
  114.  
  115.     move.l    ehandle,a0
  116.     move.l    table,a1
  117.     move.l    m_delete(a1),a1
  118.     jsr    (a1)
  119.  
  120.     move.l    table,a0
  121.     move.l    o_close(a0),a0
  122.     jmp    (a0)
  123.  
  124. abortobj:
  125.     move.l    table,a0
  126.     move.l    o_abort(a0),a0
  127.     jmp    (a0)
  128.  
  129. *******************************************
  130. ***                    ***
  131. *******************************************
  132.  
  133. rtf0:    move.l    ehandle,a0
  134.     move.l    table,a1
  135.     move.l    m_delete(a1),a1
  136.     jsr    (a1)
  137.     addq.l    #4,sp
  138.  
  139. rtfail:    moveq    #0,d0
  140.     rts
  141.  
  142. rtok:    moveq    #1,d0
  143.     rts
  144.  
  145.  
  146. *******************************************
  147. ***                    ***
  148. *******************************************
  149. geteps:
  150.     move.l    table,a1
  151.     move.l    flen(a1),a0
  152.     move.l    (a0),elength
  153.  
  154.     move.l    m_alloc(a1),a1
  155.     move.l    elength,d0
  156.     clr.l    d1
  157.     clr.l    d2
  158.     jsr    (a1)
  159.     beq    rtfail
  160.  
  161.     move.l    a0,ehandle
  162.  
  163.     move.l    table,a0
  164.     move.l    f_openr(a0),a0
  165.     jsr    (a0)
  166.     beq    rtf0
  167.  
  168.     move.l    table,a1
  169.     move.l    f_getr(a1),a1
  170.     move.l    ehandle,a0
  171.     move.l    (a0),a0
  172.     move.l    elength,d0
  173.     jsr    (a1)
  174.  
  175.     move.l    table,a0
  176.     move.l    f_closer(a0),a0
  177.     jsr    (a0)
  178.  
  179.     move.l    ehandle,a0
  180.     move.l    (a0),a0
  181.     move.l    elength,d0
  182.  
  183.     move.l    #0,eleft
  184.     move.l    #0,etop
  185.     move.l    #72,eright
  186.     move.l    #72,ebottom
  187.     bra    geps9
  188. geps6:    lea    bbstr,a1
  189. geps7:    cmp.b    (a0)+,(a1)+
  190.     bne    geps9
  191.     subq.l    #1,d0
  192.     tst.b    (a1)
  193.     bne    geps7
  194.     bra    geps10
  195.  
  196. geps9:    subq.l    #1,d0
  197.     bcc    geps6
  198.     bra    geps11
  199. *
  200. * got a match
  201. *
  202. geps10:    bsr    getnum
  203.     move.l    d0,eleft
  204.     bsr    getnum
  205.     move.l    d0,ebottom
  206.     bsr    getnum
  207.     move.l    d0,eright
  208.     bsr    getnum
  209.     move.l    d0,etop
  210.  
  211. geps11:    bsr    putzero
  212.     beq    rrts
  213.  
  214.     move.l    elength,d0
  215.     btst    #0,d0
  216.     beq    even
  217.     bsr    putzero
  218.     beq    rrts
  219.  
  220. even:
  221. ;    rts
  222.  
  223. *
  224. *
  225. *
  226.     move.l    ehandle,a0
  227.     move.l    (a0),a0
  228.     move.l    elength,d0
  229.     bra    gclr3
  230. gclr1:    lea    ccstr,a1
  231. gclr2:    cmp.b    (a0)+,(a1)+
  232.     bne    gclr3
  233.     subq.l    #1,d0
  234.     tst.b    (a1)
  235.     bne    gclr2
  236.     bra    gclr4
  237.  
  238. gclr3:    subq.l    #1,d0
  239.     bcc    gclr1
  240.     bra    rtok
  241. *
  242. * got a match
  243. *
  244. gclr4:    bsr    getclr
  245.     move.w    d0,color+cl_Cyan
  246.     bsr    getclr
  247.     move.w    d0,color+cl_Magenta
  248.     bsr    getclr
  249.     move.w    d0,color+cl_Yellow
  250.     bsr    getclr
  251.     move.w    d0,color+cl_Black
  252.     clr.w    color+cl_Map
  253.     clr.w    color+cl_Type
  254. gclr5:    move.b    (a0)+,d0
  255.     cmp.b    #"(",d0
  256.     beq    gclr6
  257.     cmp.b    #" ",d0
  258.     beq    gclr5
  259.     bra    rtok
  260.  
  261. gclr6:    lea    color+cl_Name,a1
  262.     lea    color+cl_Name+23,a2
  263. gclr7:    move.b    (a0)+,d0
  264.     beq    rtok
  265.     cmp.b    #")",d0
  266.     beq    gclr8
  267.     cmp.b    #CR,d0
  268.     beq    rtok
  269.     cmp.b    #LF,d0
  270.     beq    rtok
  271.     move.b    d0,(a1)+
  272.     cmp.l    a2,a1
  273.     bcs    gclr7
  274.     subq.l    #1,a1
  275.     bra    gclr7
  276.  
  277. gclr8:    clr.b    (a1)
  278.  
  279.     move.l    ehandle,a1
  280.     sub.l    (a1),a0
  281.     move.l    a0,-(sp)
  282.  
  283.     lea    color,a0
  284.     move.l    table,a1
  285.     move.l    newcolor(a1),a1
  286.     jsr    (a1)
  287.  
  288.     move.l    ehandle,a0
  289.     move.l    (a0),a0
  290.     add.l    (sp)+,a0
  291.  
  292. gclr9:    move.b    (a0)+,d0
  293.     beq    rtok
  294.     cmp.b    #CR,d0
  295.     beq    gclr9
  296.     cmp.b    #LF,d0
  297.     beq    gclr9
  298.     cmp.b    #" ",d0
  299.     beq    gclr9
  300.     cmp.b    #"%",d0
  301.     bne    rtok
  302.     cmp.b    #"%",(a0)+
  303.     bne    rtok
  304.     cmp.b    #"+",(a0)+
  305.     beq    gclr4
  306.     rts
  307. *
  308. *
  309. *
  310.  
  311.  
  312. putzero:
  313.     move.l    #1,d0
  314.     move.l    ehandle,a0
  315.     move.l    table,a1
  316.     move.l    m_grow(a1),a1
  317.     jsr    (a1)
  318.     beq    rtf0
  319.  
  320.     move.l    ehandle,a0
  321.     move.l    (a0),a0
  322.     add.l    elength,a0
  323.     clr.b    (a0)
  324.     addq.l    #1,elength
  325.     moveq    #1,d0
  326.     rts
  327.  
  328.  
  329. getnum:    move.b    (a0),d1
  330.     moveq    #0,d0
  331.     moveq    #1,d2
  332.     cmp.b    #"-",d1
  333.     beq    gtnm2
  334.     cmp.b    #"0",d1
  335.     bcs    gtnm0
  336.     cmp.b    #"9",d1
  337.     bls    gtnm1
  338. gtnm0:    addq.l    #1,a0
  339.     bra    getnum
  340. gtnm1:    moveq    #0,d0
  341.     moveq    #0,d2
  342. gtnm2:    move.b    (a0)+,d1
  343.     beq    gtnm9
  344.     cmp.b    #"-",d1
  345.     bne    gtnm3
  346.     moveq    #1,d2
  347.     bra    gtnm2
  348. gtnm3:    cmp.b    #" ",d1
  349.     beq    gtnm9
  350.     cmp.b    #CR,d1
  351.     beq    gtnm9
  352.     cmp.b    #LF,d1
  353.     beq    gtnm9
  354.     cmp.b    #".",d1
  355.     beq    gtnm10
  356.     sub.b    #"0",d1
  357.     bcs    gtnm9
  358.     cmp.b    #9,d1
  359.     bhi    gtnm9
  360.     move.l    d0,-(sp)
  361.     lsl.l    #2,d0
  362.     add.l    (sp)+,d0
  363.     lsl.l    #1,d0
  364.     and.l    #$ff,d1
  365.     add.l    d1,d0
  366.     bra    gtnm2
  367. gtnm9:    tst.w    d2
  368.     beq    rrts
  369.     neg.l    d0
  370.     rts
  371.  
  372. gtnm10:    move.b    (a0)+,d1
  373.     beq    gtnm9
  374.     sub.b    #"0",d1
  375.     bcs    gtnm9
  376.     cmp.w    #9,d1
  377.     bhi    gtnm9
  378.     bra    gtnm10
  379.  
  380.  
  381.  
  382. getclr:    moveq    #0,d0
  383.     move.w    #10000,d1
  384. gtcl1:    move.b    (a0)+,d2
  385.     cmp.b    #" ",d2
  386.     beq    gtcl1
  387.     bra    gtcl3
  388.  
  389. gtcl2:    move.b    (a0)+,d2
  390. gtcl3:    cmp.b    #".",d2
  391.     beq    gtcl5
  392.     cmp.b    #" ",d2
  393.     beq    gtcl10
  394.     sub.b    #"0",d2
  395.     bcs    gtcl10
  396.     cmp.b    #9,d2
  397.     bhi    gtcl10
  398.     and.w    #$ff,d2
  399.     cmp.w    #10000,d1
  400.     beq    gtcl4
  401. *
  402. * decimal portion
  403. *
  404.     mulu    d1,d2
  405.     add.w    d2,d0
  406.     and.l    #$ffff,d1
  407.     divu    #10,d1
  408.     bra    gtcl2
  409. *
  410. * integer portion (should ONLY be a 0 or a 1)
  411. *
  412. gtcl4:    cmp.b    #2,d2
  413.     bcc    gtcl10
  414.     mulu    d1,d2
  415.     move.w    d2,d0
  416.     bra    gtcl2
  417. *
  418. * decimal point
  419. *
  420. gtcl5:    cmp.w    #10000,d1
  421.     bne    gtcl10
  422.     move.w    #1000,d1
  423.     bra    gtcl2
  424. *
  425. * return number 0-10000
  426. *
  427. gtcl10:    cmp.w    #10000,d0
  428.     bcs    rrts
  429.     move.w    #10000,d0
  430.     rts
  431.  
  432.  
  433. *******************************************************************
  434. ***    called when the import routine choosen finds something    ***
  435. ***    wrong with the file loaded.                ***
  436. *******************************************************************
  437. notcorrect:
  438.     rts
  439.  
  440. never:    moveq    #0,d0
  441.     rts
  442.  
  443. maybe:    moveq    #1,d0
  444.     rts
  445.  
  446. correct:
  447.     moveq    #2,d0
  448.     rts
  449.  
  450.  
  451. *******************************************
  452. ***                    ***
  453. *******************************************
  454.  SECTION eps,DATA,PUBLIC
  455. *
  456. special:
  457.     dc.w    1
  458.     dc.l    spcl1
  459. *
  460. *
  461. name:    dc.b    "Ascii EPSF v2.1.1",0
  462. *
  463. spcl1:    dc.b    "EPSF 1.2",0
  464.  
  465. bbstr:        dc.b    "%%BoundingBox:",0
  466. ccstr:        dc.b    "%%CMYKCustomColor:",0
  467. epsfhdr:    dc.b    "%!PS-Adobe",0
  468.  
  469.  SECTION eps,BSS,PUBLIC
  470.  
  471. data:        ds.w    1
  472. object:        ds.w    ob_SizeOf/2
  473. array:        ds.w    3
  474.  
  475. eleft:        ds.l    1
  476. etop:        ds.l    1
  477. eright:        ds.l    1
  478. ebottom:    ds.l    1
  479.  
  480. ehandle:    ds.l    1
  481. elength:    ds.l    1
  482. color:        ds.w    cl_Sizeof/2
  483.