home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_2.iso
/
files
/
785b.lha
/
Fast_A-Max_v2.5
/
Read_File.a
< prev
next >
Wrap
Text File
|
1991-04-18
|
2KB
|
65 lines
;ReadFile.a written by John O'Leary, 90.4.18
SECTION CODE
_ReadFile:
XDEF _ReadFile
MOVEM.L D0-D7/A0-A6,-(SP) ;Save all registers
MOVE.L 4,A6 ;AbsExecBase
LEA DOS_NAME(PC),A1 ;library Name
MOVEQ #0,D0 ;version
JSR -$228(A6) ;OpenLibrary
MOVE.L D0,A6 ;DOSBase, don't bother to check
LEA FILE_NAME(PC),A1
MOVE.L A1,D1
MOVE.L #1005,D2 ;MODE_OLDFILE
JSR -$1E(A6) ;Open
TST.L D0
BEQ.S ERROR ;couldn't open ROMs file
MOVE.L D0,D7 ;save file handle in D7
MOVE.L D0,D1
MOVE.L 64(SP),D2 ;buffer address on stack
MOVE.L #4,D3 ;number bytes to read
JSR -$2A(A6) ;Read
CMP.L #4,D0
BEQ.S NOT_EMPTY
MOVE.L D7,D1 ;file handle
JSR -$24(A6) ;Close
BRA.S ERROR ;empty ROMs file
NOT_EMPTY:
MOVE.L D2,A0 ;buffer
MOVE.L (A0),D0 ;original return code
MOVE.L D0,(SP)
SWAP D0 ;D0.W = $69 or $75
MOVEQ #2,D3
SWAP D3 ;D3.L = $20000
CMP.W #$69,D0
BNE READ
LSR.L #1,D3 ;D3.L = $10000
READ:
MOVE.L D3,D6 ;save ROM size in D6
MOVE.L D7,D1 ;file handle
JSR -$2A(A6) ;Read
MOVE.L D7,D1 ;file handle
MOVE.L D0,D7 ;save number bytes read in D7
JSR -$24(A6) ;Close
CMP.L D6,D7
BEQ.S CLOSE_DOS ;correct number bytes read
ERROR: MOVE.L #-13,(SP) ;error return code
CLOSE_DOS: MOVE.L A6,A1 ;DOSBase
MOVE.L 4,A6 ;AbsExecBase
JSR -$19E(A6) ;CloseLibrary
MOVEM.L (SP)+,D0-D7/A0-A6 ;restore regs., ret code --> D0
RTS
DOS_NAME: DC.B "dos.library",0
FILE_NAME: DC.B "Mac ROMs",0
DC.B "FastMax patch version 2, written by John O'Leary, 1991."
END