home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / fish / 911-930 / ff919a / bbbf / unpacklib / sources / example1.s < prev    next >
Text File  |  1994-05-04  |  4KB  |  164 lines

  1. ; Unpack.library Example #1: Show Crunchers
  2. ;
  3.  
  4.     INCDIR    "Includes1.3:Include1.3/"
  5.     INCLUDE    "Own/Unpack.i"
  6.     INCLUDE    "Libraries/Dos_lib.i"
  7.     INCLUDE    "Exec/Exec_lib.i"
  8.  
  9.  
  10. START    move.l    4.w,a6
  11.     moveq    #0,d0
  12.     lea    dosname(pc),a1
  13.     jsr    _LVOOpenLibrary(a6)    ;Open Dos.library
  14.     move.l    d0,dosbase
  15.     beq    doserr
  16.  
  17.     moveq    #34,d0
  18.     lea    unpname(pc),a1
  19.     jsr    _LVOOpenLibrary(a6)    ;Open Unpack.library V34+
  20.     move.l    d0,unpbase
  21.     bne    unpok
  22.  
  23. ; Error While Opening The Unpack.library
  24.  
  25.     move.l    dosbase(pc),a6
  26.     jsr    _LVOOutPut(a6)        ;Get The CLI Window File Handler
  27.  
  28.     move.l    d0,d1            ;File Handler
  29.     move.l    #unperrt,d2        ;Pointer To Error Text
  30.     moveq    #33,d3            ;Length Of Text
  31.     jsr    _LVOWrite(a6)        ;Write Text In Window
  32.     bra    unperr
  33.  
  34. ; Every Thing Are OK!
  35.  
  36. UNPOK    bsr    main            ;Jump To Main Routine
  37.  
  38.     move.l    4.w,a6
  39.     move.l    unpbase(pc),a1
  40.     jsr    _LVOCloseLibrary(a6)    ;Close Unpack.library
  41.  
  42. UNPERR    move.l    4.w,a6
  43.     move.l    dosbase(pc),a1
  44.     jsr    _LVOCloseLibrary(a6)    ;Close Dos.library
  45.  
  46. DOSERR    moveq    #0,d0
  47.     rts
  48. ;------------------------------------------------------------------------------
  49. ; Main Routine
  50. ;
  51.  
  52. MAIN    move.l    dosbase(pc),a6
  53.     move.l    #winname,d1        ;Window Name
  54.     move.l    #1005,d2        ;Mode: Old
  55.     jsr    _LVOOpen(a6)        ;Open A Window
  56.     move.l    d0,winhd
  57.     beq    winerr
  58.  
  59.     move.l    unpbase(pc),a6
  60.     jsr    AllocCInfo(a6)        ;Allocate Cruncher Info Structure
  61.     move.l    d0,cinfo
  62.     beq    cinferr
  63.  
  64. ; Initialize
  65.  
  66.     move.w    #1,crunum        ;Initialize Start Number
  67.     moveq    #1,d7            ;Initialize Number Of Lines
  68.  
  69.     move.l    cinfo(pc),a0
  70.     jsr    UnpackList(a6)        ;Get Pointer To First Name
  71.     move.l    a1,pactxt        ;And Store It
  72.     lea    txtstr(pc),a0
  73.     bsr    print            ;Print Name
  74.     addq.w    #1,crunum        ;Count Cruncher Number
  75.  
  76. ; Loop
  77.  
  78. LOOP    move.l    unpbase(pc),a6
  79.     move.l    cinfo(pc),a0
  80.     jsr    UnpackListNext(a6)    ;Get Pointer To Next Name
  81.     beq    finish            ;No More Crunchers
  82.     move.l    a1,pactxt
  83.     lea    txtstr(pc),a0
  84.     bsr    print
  85.  
  86.     addq.w    #1,crunum        ;Count Cruncher Number
  87.     addq.w    #1,d7            ;Count Number Of Lines
  88.     cmp.w    #12,d7            ;Printed 12 Lines?
  89.     bne    loop            ;Nip, One More
  90.     moveq    #-1,d0
  91.  
  92. FINISH    move.w    d0,-(sp)
  93.     lea    txtstr1(pc),a0
  94.     bsr    print            ;Print "Press RETURN"
  95.  
  96.     move.l    dosbase(pc),a6
  97.     move.l    winhd(pc),d1
  98.     move.l    #txtstrn,d2
  99.     moveq    #1,d3
  100.     jsr    _LVORead(a6)        ;Wait For A Return?
  101.  
  102.     lea    txtstr2(pc),a0
  103.     bsr    print            ;Clear Window
  104.  
  105.     moveq    #0,d7
  106.     move.w    (sp)+,d0
  107.     tst.w    d0            ;Finished?
  108.     bne    loop            ;Nup!
  109.  
  110.     move.l    unpbase(pc),a6
  111.     move.l    cinfo(pc),a0
  112.     jsr    FreeCInfo(a6)        ;Free Cruncher Info Structure Again
  113.  
  114. CINFERR    move.l    dosbase(pc),a6
  115.     move.l    winhd(pc),d1
  116.     jsr    _LVOClose(a6)        ;Close Window Again
  117. WINERR    rts
  118. ;------------------------------------------------------------------------------
  119. ; Print Routine
  120. ;
  121. ; IN : A0 = Pointer To A String
  122. ;
  123.  
  124. PRINT    move.l    4.w,a6
  125.     clr.l    txtlen            ;Clear Text Length
  126.     lea    crunum(pc),a1
  127.     lea    print1(pc),a2
  128.     lea    txtstrn(pc),a3
  129.     jsr    _LVORawDoFmt(a6)    ;Format String
  130.  
  131.     move.l    dosbase(pc),a6
  132.     move.l    winhd(pc),d1
  133.     move.l    #txtstrn,d2
  134.     move.l    txtlen(pc),d3
  135.     jsr    _LVOWrite(a6)        ;Write Text In Window
  136.     rts
  137.  
  138. PRINT1    move.b    d0,(a3)+        ;Store Character In Buffer
  139.     addq.l    #1,txtlen
  140.     rts
  141. ;------------------------------------------------------------------------------
  142. DOSBASE    dc.l    0
  143. UNPBASE    dc.l    0
  144. WINHD    dc.l    0
  145. CINFO    dc.l    0
  146.  
  147. TXTLEN    dc.l    0
  148. CRUNUM    dc.w    1
  149. PACTXT    dc.l    0
  150. ;------------------------------------------------------------------------------
  151. DOSNAME    dc.b    "dos.library",0
  152. UNPNAME    dc.b    "unpack.library",0
  153. WINNAME    dc.b    "CON:120/64/400/128/"
  154.     dc.b    "Crunchers the unpack.library can unpack....",0
  155. ;------------------------------------------------------------------------------
  156. UNPERRT    dc.b    "You need the unpack.library V34+",10
  157. TXTSTR    dc.b    "%3d - %s",10,0
  158. TXTSTR1    dc.b    10,"Press RETURN....",0
  159. TXTSTR2    dc.b    12,0
  160. TXTSTRN    blk.b    40,0
  161.     even
  162. ;------------------------------------------------------------------------------
  163. SLUT
  164.