diff --git a/Makefile b/Makefile index 4e4835c..7e046ab 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ RAREST_WORD = murky all: dosdl.com -dosdl.com: dosdl.asm dictionary.inc targets.inc +dosdl.com: dosdl.asm dictionary.inc targets.inc license.inc $(NASM) -fbin -o $@ $< dictionary.inc: dictionary.json targets.json compress-dict.py @@ -16,6 +16,9 @@ dictionary.inc: dictionary.json targets.json compress-dict.py targets.inc: targets.json compress-targets.py $(PYTHON) compress-targets.py $< $(RAREST_WORD) $@ +license.inc: LICENSE embed-textfile.py + $(PYTHON) embed-textfile.py $< license_str $@ + clean: rm -f *.inc *.com diff --git a/dosdl.asm b/dosdl.asm index ac64cbb..f83b4ef 100644 --- a/dosdl.asm +++ b/dosdl.asm @@ -25,7 +25,7 @@ parse_arguments: .leading_spaces_skipped: - ; See whether we have /h or /u + ; See whether we have /h, /u, /l, or /? cmp cx, 2 jb .not_mode_option cmp byte [si], '/' @@ -62,6 +62,12 @@ parse_arguments: .option_done: .not_ultra_hard_mode: + cmp byte [si + 1], 'l' + je print_license + + cmp byte [si + 2], '?' + je print_help + .not_mode_option: test cx, cx @@ -74,6 +80,13 @@ print_help: ret +print_license: + mov ah, 9 + mov dx, license_str + int 0x21 + + ret + seed_rng_date: ; Get date mov ah, 0x2a @@ -1039,9 +1052,11 @@ guesses_str db ' guesses.$' guess_str db ' guess.$' help_str: - db 'Usage: dosdl [/h | /u]', 13, 10 + db 'Usage: dosdl [/h | /u | /l | /?]', 13, 10 db '/h Enable hard mode.', 13, 10 db '/u Enable ultra hard mode.', 13, 10 + db '/l Display license info.', 13, 10 + db '/? Display this help.', 13, 10 db 13, 10 db 'Hello DOSdl is a word guessing game. You have six tries to guess the correct', 13, 10 db 'English word. After a guess the game displays feedback under each letter:', 13, 10 @@ -1061,3 +1076,4 @@ help_str: %include "dictionary.inc" %include "targets.inc" +%include "license.inc" diff --git a/embed-textfile.py b/embed-textfile.py new file mode 100644 index 0000000..64ca405 --- /dev/null +++ b/embed-textfile.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +import sys +srcpath = sys.argv[1] +name = sys.argv[2] +targetpath = sys.argv[3] + +with open(srcpath, 'r') as f: + lines = [line.rstrip() for line in f] + +with open(targetpath, 'w') as f: + f.write(f'{name}:\n') + for line in lines: + encoded = line.encode('cp437') + if len(encoded) > 0: + f.write(f'\tdb {", ".join(str(char) for char in encoded)}, 13, 10\n') + else: + f.write('\tdb 13, 10\n') + f.write("\tdb '$'\n")