home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Supremacy 2
/
Supremacy-2.iso
/
Pompey
/
PP_062.MSA
/
TOMATO.S
< prev
next >
Wrap
Text File
|
1989-04-06
|
7KB
|
318 lines
**** CONVERT BINARY TO SOURCE
**** Set tabs to 13 for tidyness
**** if you haven't got devpac 2.2 gemmacro.s, or aeslib.s
**** and are using older versions, set TOS1_4 to no.
**** Written by the Genie of the Pompey Pirates ummm, ages ago
**** Just thought it might be useful to some of you (especialy
**** if you know sod all about gem).
opt o+ OPTIMISE
**** You can find gemmacro.s on the Pompey Pirates devpac menu
**** If you don't have it handy.
include gemmacro.s
yes = 1 for conitional assembly
no = 0
TOS1_4 = yes if you don't have tos 1.4 this
* must be no, or it may bomb.
* if you have got tos 1.4 it will
* do an extendid f_sel!
*
start
pea end-(start-256).w neat memory skrink
pea start-256(pc) saves having to
pea $4a0000 mess with the stack
trap #1 and is a lot shorter
lea 12(sp),sp code.
lea stack(pc),sp
appl_init must always init gem
graf_mouse #0 arrow
goagain form_alert #2,#alertstring brimgs up an alert box
subq #1,d0
move.w d0,size
ifne TOS1_4
fsel_exinput #path,#name,#ltitle
elseif
fsel_input #path,#name
endc
move.w (a0),d0 all this does is
beq exit get the full path
lea path(pc),a0 and filename together
lea savepath(pc),a1
up cmp.b #'*',(a0)
beq.s notup
move.b (a0)+,(a1)+
move.l a1,a3
bra.s up
notup
lea name(pc),a1 then it assumes you want
down move.b (a1)+,(a0)+ the same path and filename
bne.s down with the .S extender, so it
savernamer move.l a3,a0 will put you back into the
move.b #'*',(a0)+ same directory.
move.b #'.',(a0)+
move.b #'S',(a0)+
move.b #0,(a0)+
move.b #0,(a0)
lea name(pc),a0
dot cmp.b #'.',(a0)+
bne.s dot
move.b #'S',(a0)+
move.b #0,(a0)
lea savepath(pc),a1
ifne TOS1_4
fsel_exinput #savepath,#name,#stitle
elseif
fsel_input #savepath,#name
endc
beq exit
lea savepath(pc),a0
up2 cmp.b #'*',(a0)+ this makes sure of the chosen
bne.s up2 directory (can be completely
lea -1(a0),a0 different).
lea name(pc),a1
down2 move.b (a1)+,(a0)+
bne.s down2
move.w #$2f,-(sp) get dta to find file info
trap #1
addq.l #2,sp
move.l d0,dtabuff
move.w #0,-(sp) sfirst for the file size
pea path(pc) as we have done a memory
move.w #$4e,-(sp) shrink me need memory back
trap #1 if I hadn't done a mem shrink
addq.l #8,sp gem would squinny
move.l dtabuff(pc),a0
move.l 26(a0),d0
move.l d0,d4
move.l d0,d5
lsl #2,d4 4 times the amount seems to be
move.l d0,-(sp) enough
move.w #$48,-(sp) malloc for load file
trap #1
addq.l #6,sp
movem.l d0/a0-a1,-(sp)
move.l d0,a0
move.l d5,a1
bsr clearram
movem.l (sp)+,d0/a0-a1
move.l d0,filebuffer
move.l d4,-(sp) malloc for save file
move.w #$48,-(sp) note no ckeck is done to
trap #1 see if there was memory
addq.l #6,sp
movem.l d0/a0-a1,-(sp)
move.l d0,a0
move.l d4,a1
bsr clearram clean it up cause gem
movem.l (sp)+,d0/a0-a1 fills it with crap
move.l d0,source
move.w #0,-(sp)
pea path(pc)
move.w #$3d,-(sp) open file
trap #1
addq.l #8,sp
move.w d0,-(sp)
move.w #$3e,-(sp) ready for close file
move.l filebuffer(pc),-(sp)
pea $3456789 no file's gonna be that big!
move.w d0,-(sp)
move.w #$3f,-(sp) read file
trap #1
move.l d0,d7
lea 12(sp),sp
trap #1 close file
addq.l #4,sp
move.l source(pc),a6
move.l filebuffer(pc),a0
move.l a6,a1 binary code address
move.w size,d0
lsl #2,d0
lea sizes(pc),a3
move.l (a3,d0.w),a3
move.l a3,a2
cmp.w #4,d0 do words?
beq.s dowords
cmp.w #8,d0 do longs then?
beq.s dolongs
**** it's bytes boys
moveq #0,d3
moveq #1,d5
bra.s mainloop
dowords moveq #1,d3
moveq #2,d5
bra.s mainloop
dolongs moveq #2,d3
moveq #3,d5
mainloop
move.l source,a5
move.b (a2)+,(a1)+
move.b (a2)+,(a1)+
move.b (a2)+,(a1)+
move.b (a2)+,(a1)+
move.b (a2)+,(a1)+
move.b (a2)+,(a1)+
bsr convert
move.l a3,a2
cmp.l a0,a5
bgt.s mainloop
move.l a1,endsource
move.w #0,-(sp)
pea savepath(pc)
move.w #$3c,-(sp) create the save file
trap #1
addq.l #8,sp
tst.l d0
bmi filerror
move.w d0,d7
move.l source(pc),-(sp)
move.l endsource,a0
sub.l source,a0
lea -2(a0),a0
pea (a0)
move.w d0,-(sp)
move.w #$40,-(sp) write it
trap #1
lea 12(sp),sp
tst.l d0
bmi.s filerror
move.w d7,-(sp)
move.w #$3e,-(sp)
trap #1 close
addq.l #4,sp
tst.l d0
bmi.s filerror
move.l filebuffer(pc),-(sp) mfree
move.w #$49,-(sp)
trap #1
addq.l #6,sp
move.l source(pc),-(sp) mfree
move.w #$49,-(sp)
trap #1
addq.l #6,sp
form_alert #2,#alert3
cmp.w #1,d0
beq goagain
exit appl_exit
clr.w -(sp)
trap #1
clearram
doclear
add.l a0,a1
doclear1 move.b #0,(a0)+
cmp.l a1,a0
blt.s doclear1
rts
filerror
graf_mouse #0
form_alert #1,#alert4
cmp.w #1,d0
beq goagain
move.l filebuffer(pc),-(sp) mfree
move.w #$49,-(sp)
trap #1
addq.l #6,sp
move.l source(pc),-(sp) mfree
move.w #$49,-(sp)
trap #1
addq.l #6,sp
bra.s exit
convert
**** convert a long word hex to hex ascii
**** enter with a0 number to convert. a1 buffer
**** enter with d3 as size to do 1 for byte 2 for word 3 for long
move.w d3,resetd3+2
moveq #0,d0
moveq #0,d1
moveq #16,d4
divu d5,d4
subq #1,d4
move.b #'$',(a1)+
more12
cmp.l a0,a5
beq.s byebye
move.b (a0)+,d0
lsl.w #8,d0
roxr.l #4,d0
ror.b #4,d0
move.b d0,d1
ror.w #8,d0
ext d0
ext d1
cmp.b #9,d0
bgt.s letter
add #$30,d0
bra.s dr1
letter add #$57,d0
dr1 cmp.b #9,d1
bgt.s lett
add #$30,d1
bra.s more_convert
lett add #$57,d1
more_convert
move.b d0,(a1)+
move.b d1,(a1)+
dbf d3,more12
resetd3 move.w #0,d3
move.b #',',(a1)+
move.b #'$',(a1)+
dbf d4,more12
lea -2(a1),a1
move.b #13,(a1)+
move.b #10,(a1)+
byebye rts
alertstring dc.b "[1][ |Convert HEX file to SOURCE.|What"
dc.b " size do you want to use.][ BYTE | WORD | LONG ]",0
alert2 dc.b "[1][ |Process done. SAVING][ OK ]",0
alert3 dc.b "[1][ |File saved ok. Wanna go again?][ YES | NO ]",0
alert4 dc.b "[1][ |ERROR saving file. Start again][ YES | NO ]",0
ltitle dc.b "LOAD FILE TO CONVERT",0
stitle dc.b "SAVE CONVERTED FILE",0
include aeslib.s
data
sizes dc.l size1,size2,size3
size1 dc.b 9,"DC.B",9
size2 dc.b 9,"DC.W",9
size3 dc.b 9,"DC.L",9
bss
source ds.l 1
endsource ds.l 1
savepath ds.l 12
path
DS.L 12
name ds.b 16
size ds.w 1
dtabuff ds.l 1
filebuffer ds.l 1
ds.l 99
stack ds.l 1
end