home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Supremacy 2
/
Supremacy-2.iso
/
Pompey
/
PP_114.MSA
/
TRAPPER.S
< prev
Wrap
Text File
|
1992-10-31
|
15KB
|
614 lines
* Trapper: catches GEMDOS calls and lists them to printer or screen (well
* I'm not too sure about the screen option, I only shoved it in there when
* I ran out of printer paper and I soon got some more so didn't bother
* updating the screen routines from then on). Coded by The Alien, set your
* tabs to 13... I find this code very useful for games that use files, you
* can see just how they access the files, how much is read at a time, etc.
opt o+,x+
start bra.s past_files
progpath dc.b "E:\",0 location of your program
program dc.b "TEST" name of the program
envcom dc.b 0
screen equ 1
printer equ 0
output_type equ printer
past_files clr.l -(sp)
move.w #$20,-(sp)
trap #1
lea stack,sp
move.l sp,usp
pea (end-(start-256))
pea start-256(pc)
pea $4a0000
trap #1
lea 12(sp),sp
ifne output_type
move.l #screenspace+256,d0
clr.b d0
move.l d0,scraddr+2
endc
cmp.b #':',progpath+1
bne.s nodrivespec
move.b progpath(pc),d0
or.b #32,d0
sub.b #'a',d0
move.w d0,-(sp)
move.w #$e,-(sp)
trap #1
addq.l #4,sp
nodrivespec pea progpath(pc)
move.w #$3b,-(sp)
trap #1
addq.l #6,sp
move.l $84.w,oldtrap1+2
move.l #newtrap1,$84.w
pea envcom(pc)
move.l (sp),-(sp)
pea program(pc)
pea $4b0000
trap #1
lea 16(sp),sp
move.l oldtrap1+2(pc),$84.w
clr.w -(sp)
trap #1
newtrap1 move.l a0,dotrap+2
btst #5,(sp) super mode bit set?
bne.s super
move.l usp,a0 user stack pointer
bra.s user
super lea 6(sp),a0 SSP plus return addr.l and SR.w
user tst.w intrap1
bne.s dotrap
cmp.w #$57,(a0) more than $57? crazee baby!
bgt unused_call
movem.l d0-a6,-(sp)
lea trap1funcs(pc),a1
moveq #0,d0
move.w (a0)+,d0
lsl.w #2,d0
add.l d0,a1
tst.l (a1)
beq.s no_patch
move.l (a1),a1
jsr (a1)
no_patch movem.l (sp)+,d0-a6
dotrap lea 0.l,a0
oldtrap1 jmp 0.l becomes JMP <old trap #1 vector>
*--------------------------------------------------------------------------
dectoasc moveq #5,d1 gotta fix this to work with numbers
d2aloop divu #10,d0 larger than 65535 sometime!
swap d0
add.b #'0',d0
move.b d0,-(a6)
clr.w d0
swap d0
dbf d1,d2aloop
rts
*--------------------------------------------------------------------------
hextoasc lea h2anums(pc),a1
numdigits moveq #7,d1
move.l d0,d2
h2aloop and.l #$f,d0
move.b (a1,d0.w),d0
move.b d0,-(a6)
lsr.l #4,d2
move.l d2,d0
dbf d1,h2aloop
rts
h2anums dc.b "0123456789ABCDEF"
*--------------------------------------------------------------------------
printout
ifne output_type
tst.b screen_on
bne.s nochange
move.l $44e.w,a0
move.l a0,oldscr+2
lea savedscreen,a1
move.w #$1f3f,d0
savepic move.l (a0)+,(a1)+
dbf d0,savepic
move.b $44c.w,oldres+3
move.w #1,-(sp)
scraddr pea 0.l
move.l (sp),-(sp)
move.w #5,-(sp)
trap #14
lea 12(sp),sp
st screen_on
nochange pea (a6)
move.w #9,-(sp)
trap #1
addq.l #6,sp
tst.b pauser
beq.s nopause
sf pauser
pea hitspace(pc)
move.w #9,-(sp)
trap #1
addq.l #6,sp
waitspace move.w #$777,$ffff8240.w
clr.w $ffff8246.w
cmp.b #$39,$fffffc02.w
bne.s waitspace
oldres move.w #0,-(sp)
oldscr pea 0.l
move.l (sp),-(sp)
move.w #5,-(sp)
trap #14
lea 12(sp),sp
lea savedscreen,a0
move.l oldscr+2(pc),a1
move.w #$1f3f,d0
restpic move.l (a0)+,(a1)+
dbf d0,restpic
sf screen_on
nopause
elseif
* movem.l d1-a6,-(sp)
* move.w #$11,-(sp) printer on?
* trap #1 causes problems with printout
* addq.l #2,sp for some reason...
* movem.l (sp)+,d1-a6
* tst.w d0
* beq.s doneprint
moveq #0,d0
printloop move.b (a6)+,d0
beq.s doneprint
move.w d0,-(sp)
move.w #5,-(sp)
trap #1
addq.l #4,sp
tst.l d0
bmi.s printloop
doneprint
endc
rts
*--------------------------------------------------------------------------
p_term0 lea text0(pc),a6
bra common_1part
text0 dc.b "P_TERM0",0
*--------------------------------------------------------------------------
set_drv move.w (a0)+,d0
add.b #'A',d0
move.b d0,drv0e
lea text0e(pc),a6
bra common_1part
text0e dc.b "SET_DRV "
drv0e dc.b "A:",0
*--------------------------------------------------------------------------
current_disk lea text19(pc),a6
bra common_1part
text19 dc.b "CURRENT DISK",0
*--------------------------------------------------------------------------
set_dta move.l (a0)+,d0
lea addr1a(pc),a6
bsr hextoasc
lea text1a(pc),a6
bra common_1part
text1a dc.b "SET_DTA to $00000000"
addr1a dc.b 0
*--------------------------------------------------------------------------
get_dta lea text2f(pc),a6
bra common_1part
text2f dc.b "GET_DTA",0
*--------------------------------------------------------------------------
get_vers lea text30(pc),a6
bra common_1part
text30 dc.b "GET VERSION NUMBER",0
*--------------------------------------------------------------------------
p_termres move.l (a0)+,d0
lea amount31(pc),a6
bsr hextoasc
move.w (a0)+,d0
tst.w d0
bmi.s negative31
move.b #'+',plusminus31
bra.s positive31
negative31 move.b #'-',plusminus31
neg.w d0
positive31 divu #10,d0
move.w #'00',return31
add.b d0,return31
swap d0
add.b d0,return31+1
lea text31(pc),a6
bra common_1part
dc.b 0
text31 dc.b "P_TERMRES returning "
plusminus31 dc.b "+"
return31 dc.b "00, keeping $00000000"
amount31 dc.b " bytes",0
*--------------------------------------------------------------------------
d_free move.l (a0)+,d0
lea addr36(pc),a6
bsr hextoasc
bra commonto36
text36 dc.b "GET DISK FREE SPACE to $00000000"
addr36 dc.b " of ",0
*--------------------------------------------------------------------------
mk_dir lea text39(pc),a6
commonto3a move.l (a0)+,a5
bra.s common_2part
text39 dc.b "MK_DIR: ",0
*--------------------------------------------------------------------------
rm_dir lea text3a(pc),a6
bra.s commonto3a
text3a dc.b "RM_DIR: ",0
*--------------------------------------------------------------------------
ch_dir move.l (a0)+,a5 directory name
lea text3b(pc),a6
bra.s common_2part
text3b dc.b "CH_DIR to ",0
*--------------------------------------------------------------------------
f_create move.l (a0)+,a5 filename
moveq #0,d0
move.w (a0)+,d0 attribute
divu #10,d0
move.w #'00',attr3c
add.b d0,attr3c
swap d0
add.b d0,attr3c+1
lea text3c(pc),a6
opt w-
common_2part bsr printout
move.l a5,a6
common_1part bsr printout
lea crlf(pc),a6
st pauser
bsr printout
opt w+
rts
dc.b 0
text3c dc.b "F_CREATE with attribute of "
attr3c dc.b "00, ",0
*--------------------------------------------------------------------------
f_open move.l (a0)+,a5 filename
moveq #0,d0
move.w (a0)+,d0 attribute
divu #10,d0
move.w #'00',attr3d
add.b d0,attr3d
swap d0
add.b d0,attr3d+1
lea text3d(pc),a6
bra.s common_2part
rts
dc.b 0
text3d dc.b "F_OPEN with attribute of "
attr3d dc.b "00, ",0
*--------------------------------------------------------------------------
f_close moveq #0,d0
move.w (a0)+,d0 handle
divu #10,d0
move.w #'00',handle3e
add.b d0,handle3e
swap d0
add.b d0,handle3e+1
lea text3e(pc),a6
bra common_1part
dc.b 0
text3e dc.b "F_CLOSE handle "
handle3e dc.b "00.",10,0
*--------------------------------------------------------------------------
f_read moveq #0,d0
move.w (a0)+,d0 handle
divu #10,d0
move.w #'00',handle3f
add.b d0,handle3f
swap d0
add.b d0,handle3f+1
move.l (a0)+,d0 length to read
lea len3f(pc),a6
bsr dectoasc
move.l (a0)+,d0 address to read to
lea addr3f(pc),a6
bsr hextoasc
lea text3f(pc),a6
bra common_1part
text3f dc.b "F_READ handle "
handle3f dc.b "00, 000000"
len3f dc.b " bytes to $00000000"
addr3f dc.b ".",0
*--------------------------------------------------------------------------
f_write moveq #0,d0
move.w (a0)+,d0 handle
divu #10,d0
move.w #'00',handle40
add.b d0,handle40
swap d0
add.b d0,handle40+1
move.l (a0)+,d0 length to write
lea len40(pc),a6
bsr dectoasc
move.l (a0)+,d0 address to write from
lea addr40(pc),a6
bsr hextoasc
lea text40(pc),a6
bra common_1part
dc.b 0
text40 dc.b "F_WRITE handle "
handle40 dc.b "00, 000000"
len40 dc.b " bytes from $00000000"
addr40 dc.b ".",0
*--------------------------------------------------------------------------
f_unlink move.l (a0)+,a5
lea text41(pc),a6
bra common_2part
text41 dc.b "F_UNLINK ",0
*--------------------------------------------------------------------------
f_lseek move.l (a0)+,d0
move.b #'-',plusminus42
tst.l d0
bmi.s negative42
move.b #'+',plusminus42
negative42 lea len42(pc),a6
bsr dectoasc
moveq #0,d0
move.w (a0)+,d0
divu #10,d0
move.w #'00',handle42
add.b d0,handle42
swap d0
add.b d0,handle42+1
moveq #0,d0
move.w (a0)+,d0
lsl.w #2,d0
lea lseeks(pc,d0.l),a6
move.l (a6),a5
lea text42(pc),a6
bra common_2part
lseeks dc.l lseek0,lseek1,lseek2
text42 dc.b "L_SEEK handle "
handle42 dc.b "00, "
plusminus42 dc.b "+000000"
len42 dc.b " bytes from ",0
lseek0 dc.b "start of file.",0
lseek1 dc.b "current file pointer.",0
lseek2 dc.b "end of file.",0
*--------------------------------------------------------------------------
get_dir move.l (a0)+,d0
lea addr47(pc),a6
bsr hextoasc
lea text47(pc),a6
commonto36 lea current47(pc),a5
move.w (a0)+,d0
add.b #'A'-1,d0
cmp.b #'A'-1,d0
beq common_2part
lea drv47(pc),a5
move.b d0,(a5)
bra common_2part
text47 dc.b "GET_DIR to $00000000"
addr47 dc.b " on ",0
current47 dc.b "current drive",0
drv47 dc.b "A:",0
*--------------------------------------------------------------------------
p_exec move.w (a0)+,d0 mode
divu #10,d0
move.w #'00',mode4b
add.b d0,mode4b
swap d0
add.b d0,mode4b+1
move.l (a0)+,a3 filename
move.l (a0)+,a4 command line
move.l (a0)+,a5 environment
lea text4b(pc),a6
bsr printout
move.l a3,a6
bsr printout
lea text4b2(pc),a6
bsr printout
move.l a4,a6
tst.b (a6)
bne.s goodcom4b
lea none4b(pc),a6
goodcom4b bsr printout
lea text4b3(pc),a6
tst.b (a5)
bne common_2part
lea none4b(pc),a5
bra common_2part
text4b dc.b "P_EXEC of ",0
text4b2 dc.b ", mode "
mode4b dc.b "00, command line: ",0
text4b3 dc.b ", environment: ",0
none4b dc.b "NONE",0
*--------------------------------------------------------------------------
p_term move.w (a0)+,d0
tst.w d0
bmi.s negative4c
move.b #'+',plusminus4c
bra.s positive4c
negative4c move.b #'-',plusminus4c
neg.w d0
positive4c divu #10,d0
move.w #'00',result4c
add.b d0,result4c
swap d0
add.b d0,result4c+1
lea text4c(pc),a6
bra common_1part
dc.b 0
text4c dc.b "P_TERM with result of "
plusminus4c dc.b "+"
result4c dc.b "00",0
*--------------------------------------------------------------------------
s_first move.l (a0)+,a5
move.w (a0)+,d0
divu #10,d0
move.w #'00',attr4e
add.b d0,attr4e
swap d0
add.b d0,attr4e+1
lea text4e(pc),a6
bra common_2part
text4e dc.b "S_FIRST with attribute of "
attr4e dc.b "00, ",0
*--------------------------------------------------------------------------
s_next lea text4f(pc),a6
bra common_1part
text4f dc.b "S_NEXT",0
*--------------------------------------------------------------------------
f_rename move.w (a0)+,d0
divu #10,d0
move.w #'00',mode56
add.b d0,mode56
swap d0
add.b d0,mode56
lea text56(pc),a6
bsr printout
move.l (a0)+,a6
bsr printout
lea text562(pc),a6
move.l (a0)+,a5
bra common_2part
text56 dc.b "F_RENAME mode "
mode56 dc.b "00; "
text562 dc.b " becomes ",0
*--------------------------------------------------------------------------
unused_call move.w -2(a0),d0
divu #16,d0
lea h2anums(pc),a6
move.b (a6,d0.w),unusednum
swap d0
move.b (a6,d0.w),unusednum+1
bra common_1part
textunused dc.b "UNUSED CALL: $"
unusednum dc.b "00",0
*--------------------------------------------------------------------------
data *-------------------------------------------------
crlf dc.b 13,10,0
hitspace dc.b 13,10,10,"Hit space to continue.",0
pauser dc.b 0
screen_on dc.b 0
* trapped functions; either point to 0 ("ignore this function"), or the
* address of the routine to tell the printer about the function being
* called.
trap1funcs dc.l p_term0 $00 terminate
dc.l 0 $01 conin
dc.l 0 $02 conout
dc.l 0 $03 auxiliary input
dc.l 0 $04 auxiliary output
dc.l 0 $05 printer output
dc.l 0 $06 rawconio
dc.l 0 $07 direct conin without echo
dc.l 0 $08 conin without echo
dc.l 0 $09 print line
dc.l 0 $0a readline
dc.l 0 $0b constat
dc.l unused_call $0c UNUSED
dc.l unused_call $0d UNUSED
dc.l set_drv $0e setdrv
dc.l unused_call $0f UNUSED
dc.l 0 $10 conout stat
dc.l 0 $11 prtout stat
dc.l 0 $12 auxin stat
dc.l 0 $13 auxout stat
dc.l unused_call $14 UNUSED
dc.l unused_call $15 UNUSED
dc.l unused_call $16 UNUSED
dc.l unused_call $17 UNUSED
dc.l unused_call $18 UNUSED
dc.l current_disk $19 current disk
dc.l set_dta $1a set disk transfer address
dc.l unused_call $1b UNUSED
dc.l unused_call $1c UNUSED
dc.l unused_call $1d UNUSED
dc.l unused_call $1e UNUSED
dc.l unused_call $1f UNUSED
dc.l 0 $20 super
dc.l unused_call $21 UNUSED
dc.l unused_call $22 UNUSED
dc.l unused_call $23 UNUSED
dc.l unused_call $24 UNUSED
dc.l unused_call $25 UNUSED
dc.l unused_call $26 UNUSED
dc.l unused_call $27 UNUSED
dc.l unused_call $28 UNUSED
dc.l unused_call $29 UNUSED
dc.l 0 $2a get date
dc.l 0 $2b set date
dc.l 0 $2c get time
dc.l 0 $2d set time
dc.l unused_call $2e UNUSED
dc.l get_dta $2f get disk transfer address
dc.l get_vers $30 get version number
dc.l p_termres $31 keep process
dc.l unused_call $32 UNUSED
dc.l unused_call $33 UNUSED
dc.l unused_call $34 UNUSED
dc.l unused_call $35 UNUSED
dc.l d_free $36 get disk free space
dc.l unused_call $37 UNUSED
dc.l unused_call $38 UNUSED
dc.l mk_dir $39 mkdir
dc.l rm_dir $3a rmdir
dc.l ch_dir $3b chdir
dc.l f_create $3c create
dc.l f_open $3d open
dc.l f_close $3e close
dc.l f_read $3f read
dc.l f_write $40 write
dc.l f_unlink $41 unlink
dc.l f_lseek $42 lseek
dc.l 0 $43 change mode
dc.l unused_call $44 UNUSED
dc.l 0 $45 dup
dc.l 0 $46 force
dc.l get_dir $47 getdir
dc.l 0 $48 malloc
dc.l 0 $49 mfree
dc.l 0 $4a setblock
dc.l p_exec $4b exec
dc.l p_term $4c pterm
dc.l unused_call $4d UNUSED
dc.l s_first $4e sfirst
dc.l s_next $4f snext
dc.l unused_call $50 UNUSED
dc.l unused_call $51 UNUSED
dc.l unused_call $52 UNUSED
dc.l unused_call $53 UNUSED
dc.l unused_call $54 UNUSED
dc.l unused_call $55 UNUSED
dc.l f_rename $56 rename
dc.l 0 $57 get/set date & time of file
bss *-------------------------------------------------
intrap1 ds.w 1
ds.l 100
stack ds.l 1
ifne output_type
screenspace ds.l 32256/4
savedscreen ds.l 32000/4
endc
end