home *** CD-ROM | disk | FTP | other *** search
- ; NEW Unpack.library Example #2: How To Make A Scan Routine
- ;
-
- INCDIR "Includes1.3:Include1.3/"
- INCLUDE "Libraries/Dos_lib.i"
- INCLUDE "Exec/Exec_lib.i"
-
- INCDIR "Includes3.0:Include3.0/"
- INCLUDE "Own/Unpack.i"
-
-
- START move.l 4.w,a6
- moveq #0,d0
- lea dosname(pc),a1
- jsr _LVOOpenLibrary(a6) ;Open Dos.library
- move.l d0,dosbase
- beq doserr
-
- moveq #39,d0
- lea unpname(pc),a1
- jsr _LVOOpenLibrary(a6) ;Open Unpack.library V39+
- move.l d0,unpbase
- bne unpok
-
- ; Error While Opening The Unpack.library
-
- UNPFAIL move.l dosbase(pc),a6
- jsr _LVOOutPut(a6) ;Get The CLI Window File Handler
-
- move.l d0,d1 ;File Handler
- move.l #unperrt,d2 ;Pointer To Error Text
- moveq #36,d3 ;Length Of Text
- jsr _LVOWrite(a6) ;Write Text In Window
- bra unperr
-
- ; Every Thing Are OK!
-
- UNPOK bsr main ;Jump To Main Routine
-
- move.l 4.w,a6
- move.l unpbase(pc),a1
- jsr _LVOCloseLibrary(a6) ;Close Unpack.library
-
- UNPERR move.l 4.w,a6
- move.l dosbase(pc),a1
- jsr _LVOCloseLibrary(a6) ;Close Dos.library
-
- DOSERR moveq #0,d0
- rts
- ;------------------------------------------------------------------------------
- ; Main Routine
- ;
- ; Returns the error number in D0 or 0
- ;
-
- MAIN move.l unpbase(pc),a6
- jsr AllocCInfo(a6) ;Allocate Cruncher Info Structure
- move.l d0,cinfo
- beq cinferr
-
- ; Initialize Structure
-
- move.l d0,a0
- move.l #arcpath,UI_Path(a0)
- move.l #scan,UI_Jump(a0)
- move.b #UFN_Delete,UI_Flag(a0) ;NOTE: The Delete Flag Are Set
-
- lea filnam(pc),a1 ;Pointer To A Filename
- jsr DetermineFile(a6)
- beq deterr ;A Error!!!
-
- jsr Unpack(a6) ;Unpack The File
- beq loaderr
- moveq #0,d0
- bra unpacok
-
- LOADERR
- DETERR1 move.w UI_ErrorNum(a0),d0 ;Get Error Number
-
- UNPACOK move.l cinfo(pc),a0
- jsr FreeCInfo(a6) ;Free Cruncher Info Structure
- CINFERR rts
-
- ; Error Handling Routine For Determine
-
- DETERR cmp.w #ERR_Determine,UI_ErrorNum(a0)
- bne deterr1
-
- jsr LoadFile(a6) ;Load The File
- beq loaderr
- bsr scan ;Call Your Scan Routine
- jsr FreeFile(a6) ;Free The File From Memory
- moveq #0,d0
- bra unpacok
- ;------------------------------------------------------------------------------
- ; The Scan Routine
- ;
-
- SCAN move.l cinfo(pc),a0
- move.l UI_DecrunchAdr(a0),a1 ;Start Address Of Decrunched File
- move.l UI_DecrunchLen(a0),d0 ;Length Of Decrunched File
- move.l UI_CruncherName(a0),a2 ;Cruncher Name
-
- ; This will only demostrate how to get the filename
-
- lea filnam(pc),a3
- tst.b UI_UseFilenamePointer(a0)
- beq scan1
- move.l UI_LoadNamePoi(a0),a3
-
- ; Just some simple flashing
-
- SCAN1 move.w #$8000,d7
- SCAN2 move.w d7,d6
- and.w #$0fff,d6
- move.w d6,$dff180
- dbra d7,scan2
- rts
- ;------------------------------------------------------------------------------
- DOSBASE dc.l 0
- UNPBASE dc.l 0
- CINFO dc.l 0
- ;------------------------------------------------------------------------------
- DOSNAME dc.b "dos.library",0
- UNPNAME dc.b "unpack.library",0
- ;-----------------------------------------------------------------------------
- UNPERRT dc.b "You need the unpack.library V39+",10
- ARCPATH dc.b "RAM:",0 ;Enter Archive Path Here!!!
- FILNAM dc.b "DF0:CrunchedFile",0 ;Enter Filename Here!!!
- even
- ;------------------------------------------------------------------------------
- SLUT
-