Compare commits

...

4 Commits

Author SHA1 Message Date
Juhani Krekelä df2cd4079f Allow upper case switches 2022-02-25 02:19:44 +02:00
Juhani Krekelä 2ae741d705 Add ability to set seed manually 2022-02-25 02:19:12 +02:00
Juhani Krekelä 9b2cd70f4d Include license info in the executable 2022-02-25 02:05:00 +02:00
Juhani Krekelä e5b42749e5 Tweak phrasing in the explanation for ultra hard mode 2022-02-25 01:53:47 +02:00
4 changed files with 86 additions and 10 deletions

View File

@ -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

View File

@ -13,11 +13,6 @@ Gameplay
Gameplay is as in hello wordl's default daily mode. `x` under a letter marks it
as incorrect and `^` marks it as being in the wrong place.
Missing features
----------------
- Ability to set the seed manually
Word lists
----------
The words lists are taken from

View File

@ -25,13 +25,15 @@ 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], '/'
jne .not_mode_option
cmp byte [si + 1], 'h'
je .hard_mode
cmp byte [si + 1], 'H'
jne .not_hard_mode
.hard_mode:
@ -42,6 +44,8 @@ parse_arguments:
.not_hard_mode:
cmp byte [si + 1], 'u'
je .ultra_hard_mode
cmp byte [si + 1], 'U'
jne .not_ultra_hard_mode
.ultra_hard_mode:
@ -62,11 +66,57 @@ parse_arguments:
.option_done:
.not_ultra_hard_mode:
cmp byte [si + 1], 'l'
je print_license
cmp byte [si + 1], 'L'
je print_license
cmp byte [si + 2], '?'
je print_help
.not_mode_option:
test cx, cx
jz seed_rng_date
seed_rng_argument:
xor ax, ax
xor dx, dx
mov bp, mull32
call store32
.loop:
xor dx, dx
mov ax, 10
mov bp, mulr32
call store32
call mul32
mov bp, addl32
call store32
lodsb
cmp al, '0'
jb print_help
cmp al, '9'
ja print_help
sub al, '0'
xor ah, ah
xor dx, dx
mov bp, addr32
call store32
call add32
mov bp, mull32
call store32
loop .loop
mov bp, rng_seed
call store32
jmp select_target
print_help:
mov ah, 9
mov dx, help_str
@ -74,6 +124,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 +1096,11 @@ guesses_str db ' guesses.$'
guess_str db ' guess.$'
help_str:
db 'Usage: dosdl [/h | /u]', 13, 10
db 'Usage: dosdl [/h | /u | /l | /?] [seed]', 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
@ -1056,8 +1115,9 @@ help_str:
db 13, 10
db 'In hard mode all letters marked as being in the correct place must stay fixed', 13, 10
db 'and those marked as being in the wrong place must be reused. In ultra hard mode', 13, 10
db 'letters marked as being in the wrong place must also be moved and letters not', 13, 10
db 'in the word must not be played again.$'
db 'letters marked as being in the wrong place must also be moved and letters that', 13, 10
db 'have been ruled out must not be played again.$'
%include "dictionary.inc"
%include "targets.inc"
%include "license.inc"

18
embed-textfile.py Normal file
View File

@ -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")