flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > DOS > PSR Invaders 1.1

Author
Thread Post new topic Reply to topic
rugxulo



Joined: 09 Aug 2005
Posts: 2071
Location: Usono (aka, USA)
PSR Invaders 1.1
Ever played PSR Invaders 1.1 (circa 1995)? invadr11.zip (27 kb)

In 2004, I manually (but sloppily) converted it to work with free assemblers. But this new script is much simpler, smaller, and more accurate than the full quirky, modified source.

Tested with either GNU sed or Cheap sed.


Code:

@echo off
if "%SED%"=="" set SED=sed
if not exist invaders.asm goto end
echo %%SED%% = '%SED%'
:fix1
echo /^ *\([^ ]\+\) \+[dD][bBwWdD.\+/!d>fix1.sed
echo "s||\1\\>/[\&]/|"|%SED% -e "s/^.//" -e "s/.$//">>fix1.sed
echo "s|^|s/\\<|"|%SED% -e "s/^.//" -e "s/.$//">>fix1.sed
if not exist fix1.sed goto end
:fix2
echo 1i\>fix2.sed
echo offset equ\>>fix2.sed
echo ptr equ>>fix2.sed
echo /^ *;/b>>fix2.sed
echo s/[oO][fF][fF][sS][eE][tT]/offset/g>>fix2.sed
echo s/ [pP][tT][rR]/ ptr/g>>fix2.sed
echo /CODE_SEG/d>>fix2.sed
echo /^ *END/d>>fix2.sed
echo s/\]\[\([1-9]\)\]/+\1]/>>fix2.sed
echo s/\[0\]//>>fix2.sed
echo s/\]\(+BX\)/\1/>>fix2.sed
echo s/ES:\[/[ES:/>>fix2.sed
echo s/ \+PROC \+/: ;&/>>fix2.sed
echo / ENDP/s/^/;/>>fix2.sed
echo s/\[\[/[/>>fix2.sed
echo s/LEA \+\([^ ]\+\), *\[*\([^;]\+\)\]*/MOV \1,offset \2/>>fix2.sed
echo s/\(offset\) \[\([^]]\+\)\]/\1 \2/>>fix2.sed
if not exist fix2.sed goto cleanup
:fix3
echo /RemoveNewInt9:/,/ RET/s/OldInt9Addr/cs:&/>fix3.sed
echo /NewInt9Handler:/,/NotIntercept:/{>>fix3.sed
echo s/byte ptr \[/&cs:/>>fix3.sed
echo /cs:/!s/\(MOV \+\)\([^,]\+\)/\1cs:\2/>>fix3.sed
echo s/\(cs:\)\[/[\1/>>fix3.sed
echo }>>fix3.sed
echo /NotIntercept:/,/^ *$/{>>fix3.sed
echo s/StoreAX/cs:&/>>fix3.sed
echo s/40://>>fix3.sed
echo }>>fix3.sed
if not exist fix3.sed goto cleanup
:asmvars
echo /^ *;/b>asmvars.sed
echo / [dD][bBwWdD] /b>>asmvars.sed
echo /, *offset/b>>asmvars.sed
echo /LEA /b>>asmvars.sed
%SED% -f fix1.sed invaders.asm >>asmvars.sed
if not exist asmvars.sed goto cleanup
%SED% -f asmvars.sed invaders.asm|%SED% -f fix2.sed -f fix3.sed >inv-fasm.asm
if not exist inv-fasm.asm goto cleanup
:build
fasm inv-fasm.asm >NUL
if not exist inv-fasm.com goto cleanup
echo.
dir inv-fasm.com | grep -i "com"
echo.
echo INV-FASM.COM    FFF22EF9
crc32 inv-fasm.com
echo.
:cleanup
if "%1"=="notclean" goto end
del fix*.sed >NUL
del asmvars.sed >NUL
:end
if "%SED%"=="sed" set SED=




Since I'm also sometimes using antiX Linux, which comes with DOSBox, I also whipped up a quick makefile in order to cross-build:


Code:

GNUmakefile
.RECIPEPREFIX := _

#=== fix1.sed begins ===
# /^ *\([^ ]\+\) \+[dD][bBwWdD.\+/!d
s||\1\\>/[\&]/|
s|^|s/\\<|
#=== fix1.sed ends ===

#=== fix2.sed begins ===
1i\
offset equ\
ptr equ
# /^ *;/b
s/[oO][fF][fF][sS][eE][tT]/offset/g
s/ [pP][tT][rR]/ ptr/g
# /CODE_SEG/d
# /^ *END/d
s/\]\[\([1-9]\)\]/+\1]/
s/\[0\]//
s/\]\(+BX\)/\1/
s/ES:\[/[ES:/
s/ \+PROC \+/: ;&/
# / ENDP/s/^/;/
s/\[\[/[/
s/LEA \+\([^ ]\+\), *\[*\([^;]\+\)\]*/MOV \1,offset \2/
s/\(offset\) \[\([^]]\+\)\]/\1 \2/
#=== fix2.sed ends ===

#=== fix3.sed begins ===
# /RemoveNewInt9:/,/ RET/s/OldInt9Addr/cs:&/
# /NewInt9Handler:/,/NotIntercept:/{
s/byte ptr \[/&cs:/
# /cs:/!s/\(MOV \+\)\([^,]\+\)/\1cs:\2/
s/\(cs:\)\[/[\1/
# }
# /NotIntercept:/,/^ *$/{
s/StoreAX/cs:&/
s/40://
# }
#=== fix3.sed ends ===

.PHONYall clean

unexport UNZIP

SED=sed
FASM=fasm
MD5SUM=md5sum
WGET=wget
WGETOPT=-q
UNZIP=unzip
UNZIPOPT=-qjLan
GAMEURL=ftp.lanet.lv/ftp/mirror/x2ftp/msdos/programming/gamesrc/
GAMEZIP=invadr11.zip

allinv-fasm.com

inv-fasm.cominv-fasm.asm
_@$(FASM$<
_@$(MD5SUM$@
_@echo 5d6fa26af01606feb90f17e014390139 \ inv-fasm.com

fix1.sed fix2.sed fix3.sed$(lastword $(MAKEFILE_LIST))
_@$(SED) -e '/$@ begins ===/,/$@ ends ===/!d' $< | $(SED) -e 's/^#  *//' >$@

asmvars.sedfix1.sed invaders.asm
_@echo '/^ *;/b' >$@
_@echo '/ [dD][bBwWdD] /b' >>$@
_@echo '/, *offset/b' >>$@
_@echo '/LEA /b' >>$@
_@$(SED) -f $^ >>$@

inv-fasm.asminvaders.asm asmvars.sed fix2.sed fix3.sed
_@$(SED) -f asmvars.sed $< | $(SED) -f fix2.sed -f fix3.sed >$@

$(GAMEZIP):
_@$(WGET$(WGETOPT$(GAMEURL)$(GAMEZIP)

invaders.asm$(GAMEZIP)
_@$(UNZIP$(UNZIPOPT$"*/$@"

clean:
_@$(RMinv-fasm.fix?.sed asmvars.sed


Post 08 Feb 2017, 09:30
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.