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
/
example2.s
< prev
next >
Wrap
Text File
|
1994-05-04
|
3KB
|
128 lines
; Unpack.library Example #2: How To Make A Scan Routine
;
INCDIR "Includes1.3:Include1.3/"
INCLUDE "Own/Unpack.i"
INCLUDE "Libraries/Dos_lib.i"
INCLUDE "Exec/Exec_lib.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 #34,d0
lea unpname(pc),a1
jsr _LVOOpenLibrary(a6) ;Open Unpack.library V34+
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
; Test Revision Number
UNPOK move.l d0,a6
jsr UnpackNum(a6) ;Get Version Etc.
cmp.w #20,d1 ;Revision < 20
blt unpfail ;Yop!
; Every Thing Are OK!
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!!!
moveq #0,d0
jsr Unpack(a6) ;Unpack The File
bne 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
move.w #$8000,d7
SCAN1 move.w d7,d6
and.w #$0fff,d6
move.w d6,$dff180
dbra d7,scan1
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 V34.20+",10
ARCPATH dc.b "RAM:",0 ;Enter Archive Path Here!!!
FILNAM dc.b "DF0:CrunchedFile",0 ;Enter Filename Here!!!
even
;------------------------------------------------------------------------------
SLUT