home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_06 / PP58.ZIP / PP58.MSA / PROFLITE / EXEC_HI.S < prev    next >
Text File  |  1990-11-03  |  5KB  |  246 lines

  1. no    equ    0
  2. yes    equ    1
  3.  
  4. * EXEC HEADER FOR EXEC FILES PACKED WITH POMPEY PACKER 1.9
  5. * You can customise this exec header by setting the values below to YES or
  6. * NO. 'lowresonly' will correctly justify the 'POMPEY PACKER V1.9' text if
  7. * it is set to NO, if set to yes, it will just print in the middle of the
  8. * screen on low res, but will be incorrectly justified in med/high res.
  9. * 'printheading' will print the "POMPEY PACKER V1.9' text if set to YES.
  10. * 'okrobnorthen' will work with Rob Northen protection if set to YES; if
  11. * set to NO it will lock up if protected with RN protection, but will save
  12. * a few bytes.
  13.  
  14. lowresonly    equ    yes
  15. printheading    equ    no
  16. okrobnorthen    equ    no
  17.  
  18. start    move.l    4(sp),a5        base page address
  19.     clr.l    -(sp)
  20.     move.w    #$20,-(sp)
  21.     trap    #1
  22.     move.l    d0,2(sp)
  23.  
  24.     ifne    printheading
  25.     ifeq    lowresonly
  26.     move.w    #4,-(sp)        change x co-or of
  27.     trap    #14        text if in medium
  28.     addq.l    #2,sp        or high res
  29.     tst.w    d0
  30.     beq.s    low
  31.     lea    x(pc),a0
  32.     add.b    #20,(a0)
  33.     endc
  34. low    pea    text(pc)
  35.     move.w    #9,-(sp)
  36.     trap    #1
  37.     addq.l    #6,sp
  38.     endc
  39.  
  40.     ifne    okrobnorthen
  41.     lea    endoffile,a4
  42.     endc
  43.  
  44.     move.l    a4,a0
  45. depack    movea.l    a0,a3            Start of packed file 
  46.     lea    -12(a0),a0
  47.     sub.l    (a0),a3            sub the packedsize.
  48.     movea.l    a3,a2
  49.     add.l    4(a0),a2
  50.     lea    $ffff8240.w,a4
  51.     move.w    (a4),d5            Save color
  52.  
  53. empty    move.b    -(a0),d0        Unpack data.
  54.     beq.s    empty            Not empty.
  55. umain    moveq    #0,d2
  56.     bsr    shifter
  57.     bcs.s    rep
  58.  
  59.     move.b    -(a0),d2
  60. output    move.b    d2,-(a2)
  61.     bra.s    ecxit
  62.  
  63. rep3    moveq    #15,d4            16bit in-operative.
  64.     moveq    #2,d3
  65.     bsr.s    leader
  66.     bne.s    rloop
  67.     move.w    d4,d2
  68.     bra.s    output
  69.         
  70. rep    bsr.s    shifter
  71.     bcc.s    repeat
  72.     bsr.s    shifter
  73.     bcc.s    rep3
  74.     bsr.s    shifter
  75.     bcs.s    rep4
  76. special    moveq    #2,d1
  77.     bsr    nibit
  78.     exg    d1,d2
  79.     addq.w    #1,d2
  80.     bset    d1,d2
  81.     bra.s    output
  82.     
  83. rep4    bsr.s    shifter
  84.     bcc.s    rep5            V1.7 incompatability
  85.     moveq    #15,d4            16bit in-operative.
  86.     move.w    #3,d3
  87.     bsr.s    leader
  88.     bne.s    rloop
  89.     move.b    (a2),-(a2)
  90.  
  91. ecxit    move.w    d3,(a4)
  92.     move.w    d5,(a4)
  93.     cmpa.l    a2,a3
  94.     blt.s    umain
  95.     bra    sort_it_out
  96.  
  97. rep5    moveq    #4,d3
  98.     bra.s    reps
  99.  
  100. ; **    Offset bitsize is x bits depending upon D2.
  101. ; **    Also serves to reproduce RUNS , because an offset of 1 = same
  102. ; **    character repeated D3 times.
  103.  
  104. repeat    bsr.s    shifter
  105.     bcs.s    rep2
  106.     moveq    #1,d1
  107. .1    lsr.b    #1,d0
  108.     bne.s    .2
  109.     move.b    -(a0),d0
  110.     roxr.b    #1,d0
  111. .2    addx.w    d2,d2
  112.     dbf    d1,.1
  113.     
  114.     move.w    d2,d1            Copy bitcount
  115.     beq.s    runing            If ZERO then do RUNS
  116.     addq.w    #1,d1
  117.     add.w    d1,d1
  118.     subq.w    #1,d1
  119.     bsr.s    nibit
  120.     move.w    d2,d3
  121. reps    bsr.s    lead1            Get offset size.
  122. rloop    movea.l    a2,a1
  123.     add.l    d2,a1            Add the offset.
  124. replp    move.b    -(a1),-(a2)
  125.     dbf    d3,replp
  126.     bra.s    ecxit
  127.  
  128. shifter    lsr.b    #1,d0
  129.     bne.s    noz
  130.     move.b    -(a0),d0
  131.     roxr.b    #1,d0
  132. noz    rts
  133.  
  134. ; **    Collect 2bit leader into D1
  135. ; **    Algorithm :- 2bits + 1 (1 to 4) * 4.
  136. ; **    Return the BITS in D2.
  137.  
  138. lead1    moveq    #0,d4            16bits operative.
  139. leader    moveq    #1,d1
  140.  
  141.     moveq    #0,d2
  142. n1    lsr.b    #1,d0
  143.     bne.s    n2
  144.     move.b    -(a0),d0
  145.     roxr.b    #1,d0
  146. n2    addx.w    d2,d2
  147.     dbf    d1,n1
  148.  
  149.     move.w    d2,d1
  150.     addq.w    #1,d1
  151.     lsl.w    #2,d1
  152.     subq.w    #1,d1
  153.     eor.b    d1,d4
  154.     bne.s    nibit
  155.     rts    
  156. nibs    moveq    #7,d1
  157. nibit    moveq    #0,d2
  158. nlp    lsr.b    #1,d0
  159.     bne.s    nlp1
  160.     move.b    -(a0),d0
  161.     roxr.b    #1,d0
  162. nlp1    addx.w    d2,d2
  163.     dbf    d1,nlp
  164.     rts
  165. runing    bsr.s    lead1            16bits operative
  166.     move.w    d2,d3
  167.     moveq    #1,d2
  168.     bra.s    rloop
  169. rep2    moveq    #1,d3            Size of loop.
  170.     move.b    -(a0),d2
  171.     bra.s    rloop
  172.  
  173. sort_it_out    trap    #1
  174.     addq.l    #6,sp
  175. * a3 is already pointing to start of depacked program
  176.     move.l    2(a3),a0        text segment
  177.     add.l    6(a3),a0        + data segment
  178.     add.l    14(a3),a0        + symbol table
  179.     lea    28(a0),a0        + header
  180.     add.l    a3,a0        + start of program
  181. * a0 now points to relocation table
  182.     move.l    8(a5),d0        d0 points to TEXT
  183.     lea    28(a3),a3        a3 points to program
  184.     move.l    a3,a6
  185.     tst.l    (a0)        zero 1st relocation?
  186.     beq.s    done_reloc
  187.  
  188.     moveq    #0,d1
  189.     add.l    (a0)+,a3        + offset
  190. relocate    add.l    d0,(a3)        relocate it
  191. add_no_reloc    move.b    (a0)+,d1        next byte
  192.     beq.s    done_reloc        zero is end
  193.     cmp.b    #1,d1        1 is add 254, but
  194.     bne.s    not1        don't relocate
  195.     lea    254(a3),a3
  196.     bra.s    add_no_reloc
  197. not1    add.l    d1,a3        + offset
  198.     bra.s    relocate
  199.  
  200. done_reloc    lea    packedfile+2(pc),a2    past $601a
  201.     move.l    (a2),12(a5)        write real TEXT len
  202.     add.l    (a2),d0        TEXT len + TEXT addr
  203.     move.l    d0,16(a5)        write real DATA addr
  204.     move.l    4(a2),20(a5)        write real DATA len
  205.     add.l    4(a2),d0        + DATA len
  206.     move.l    d0,24(a5)        write real BSS addr
  207.     move.l    8(a2),28(a5)        write real BSS len
  208.  
  209. * now move code somewhere safe
  210.     move.l    sp,a0
  211.     lea    -256(a0),a0
  212.     pea    (a0)
  213.     lea    mover(pc),a1
  214.     moveq    #(endofmover-mover)/2-1,d0
  215. copy_mover    move.w    (a1)+,(a0)+
  216.     dbf    d0,copy_mover
  217.     rts
  218.  
  219. * move the program down to the correct address
  220. mover    move.l    12(a5),d0        TEXT len
  221.     add.l    20(a5),d0        + DATA len
  222.     lsr.l    #1,d0        divide by 2
  223.     addq.l    #1,d0        one for luck
  224.     move.l    8(a5),a4        pointer to TEXT addr
  225.     pea    (a4)        run address
  226. copydown    move.w    (a6)+,(a4)+
  227.     subq.l    #1,d0
  228.     bne.s    copydown
  229. * clear the BSS
  230.     move.l    28(a5),d1
  231.     add.l    #(packedfile-start)+28,d1
  232.     lsr.l    #1,d1
  233.     addq.l    #1,d1
  234. clearbss    move.l    d0,(a4)+
  235.     subq.l    #1,d1
  236.     bne.s    clearbss
  237.     move.w    #$6006,start+$ef22
  238.     rts            run the program
  239. endofmover
  240.     ifne    printheading
  241. text    dc.b    27,"E",27,"Y",32
  242. x    dc.b    43,"POMPEY PACKER V1.9",0,0
  243.     endc
  244. * the packed exec file goes here
  245. packedfile    incbin    "f:\profligh.t\proflihi.pak"
  246. endoffile