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: 2122
Location: Usono (aka, USA)
PSR Invaders 1.1
Ever played PSR Invaders 1.1 (circa 1995)? invadr11.zip (27 kb) mirror #2

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.

EDIT: Minor .BAT cleanups, now builds in Windows, too.


Code:

@echo off

::#--- fix1.sed begins ---
:: /^ *\([^ ]\+\) \+D[BWD.\+/!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 ---

::#--- asmvars.sed begins ---
:: /^ *;/b
:: / D[BWD] /b
:: /, *offset/b
:: /LEA /b
::#--- asmvars.sed ends ---

if not exist invaders.asm goto end
if not exist %0 %0.bat %1

if "%SED%"=="" set SED=sed
echo %%SED%% = '%SED%'

set B1=begins ---
set E1=ends ---
set S1=fix1.sed fix2.sed fix3.sed asmvars.sed
for %%a in (%S1%do %SED% -n -e "/%%a %B1%/,/%%a %E1%/s/^:: *//w %%a" %0
for %%z in (S1 E1 B1do set %%z=

for %%a in (fix1 fix2 fix3 asmvarsdo if not exist %%a.sed goto end

%SED% -f fix1.sed invaders.asm >>asmvars.sed
%SED% -f asmvars.sed invaders.asm|%SED% -f fix2.sed -f fix3.sed >inv-fasm.asm

REM cwsdpmi
fasm inv-fasm.asm inv-fasm.com >NUL
if not exist inv-fasm.com goto end

echo.
echo INV-FASM.COM    FFF22EF9
crc32 inv-fasm.com
echo.

if "%1"=="notclean" goto end
del asmvars.sed >NUL
del fix?.sed >NUL
del inv-fasm.asm >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.

EDIT: Very minor makefile cleanups.


Code:

GNUmakefile
.RECIPEPREFIX := _

#=== fix1.sed begins ===
# /^ *\([^ ]\+\) \+D[BWD.\+/!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 check clean cleanall

unexport UNZIP

PROG=inv-fasm
OLDASM=invaders.asm

SED=sed
FASM=fasm
MD5SUM=md5sum
WGET=wget
WGETOPT=-q
UNZIP=unzip
UNZIPOPT=-qjLan

GAMEZIP=invadr11.zip

#GAMEURL=ftp.lanet.lv/ftp/mirror/x2ftp/msdos/programming/gamesrc/
GAMEURL=www.ibiblio.org/pub/micro/pc-stuff/freedos/files/games/invaders/

all$(PROG).com check

$(PROG).com$(PROG).asm
_@$(FASM$$@

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

asmvars.sedfix1.sed $(OLDASM)
_@$(SED) -f $^ >$@

$(PROG).asm$(OLDASMasmvars.sed fix2.sed fix3.sed
_@$(SED) -e '/^ *;/b' -e '/ D[BWD] /b' -e '/, *OFFSET/b' -e '/LEA /b'\
 -f asmvars.sed $< | $(SED) -f fix2.sed -f fix3.sed >$@

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

$(OLDASM): $(GAMEZIP)
_@$(UNZIP$(UNZIPOPT$"*/$@"

check$(PROG).com
_@$(MD5SUM$<
_@echo 5d6fa26af01606feb90f17e014390139 \ $<

clean:
_@$(RM$(PROG).asm fix?.sed asmvars.sed

cleanallclean
_@$(RM$(PROG).com

EOF


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.