Implement hard mode
This commit is contained in:
parent
7af168618c
commit
a90e026623
123
dosdl.asm
123
dosdl.asm
|
@ -80,6 +80,11 @@ seed_rng_date:
|
|||
int 0x21
|
||||
mov [year], cx
|
||||
mov [month], dh
|
||||
%ifdef DEBUG
|
||||
mov cx, 2022
|
||||
mov dh, 2
|
||||
mov dl, 24
|
||||
%endif
|
||||
mov [day], dl
|
||||
|
||||
; addl32 = year * 10000
|
||||
|
@ -211,6 +216,98 @@ read_guess:
|
|||
|
||||
.done:
|
||||
|
||||
check_hard_mode:
|
||||
cmp byte [hard_mode], 1
|
||||
jne .done
|
||||
|
||||
; See whether exact hits are reused
|
||||
xor bp, bp
|
||||
mov cx, 5
|
||||
.exact_hits:
|
||||
mov al, [exact_hits + bp]
|
||||
test al, al
|
||||
jz .not_exact_hit
|
||||
|
||||
cmp al, [guess + bp]
|
||||
je .exact_hit_match
|
||||
|
||||
mov dx, bp
|
||||
add dl, '1'
|
||||
mov [exact_hit_error_str.position], dl
|
||||
mov [exact_hit_error_str.letter], al
|
||||
mov si, exact_hit_error_str
|
||||
jmp print_error
|
||||
|
||||
.exact_hit_match:
|
||||
.not_exact_hit:
|
||||
inc bp
|
||||
loop .exact_hits
|
||||
|
||||
; See whether wrongly placed letters are reused
|
||||
xor bp, bp
|
||||
.wrong_places:
|
||||
cmp bp, 5
|
||||
je .done
|
||||
|
||||
mov dl, [wrong_places + bp]
|
||||
test dl, dl
|
||||
jz .not_wrong_place
|
||||
|
||||
; Count how many times letter is used in exact_hits + wrong_places
|
||||
xor bx, bx
|
||||
mov cx, 5
|
||||
mov si, exact_hits
|
||||
.count_exact_hits:
|
||||
lodsb
|
||||
cmp al, dl
|
||||
jne .not_count_exact_hit
|
||||
inc bh
|
||||
.not_count_exact_hit:
|
||||
loop .count_exact_hits
|
||||
mov cx, 5
|
||||
mov si, wrong_places
|
||||
.count_wrong_places:
|
||||
lodsb
|
||||
cmp al, dl
|
||||
jne .not_count_wrong_places
|
||||
inc bh
|
||||
.not_count_wrong_places:
|
||||
loop .count_wrong_places
|
||||
|
||||
; Count how many times letter is used in guess
|
||||
mov cx, 5
|
||||
mov si, guess
|
||||
.count_guess:
|
||||
lodsb
|
||||
cmp al, dl
|
||||
jne .not_count_guess
|
||||
inc bl
|
||||
.not_count_guess:
|
||||
loop .count_guess
|
||||
|
||||
cmp bl, bh
|
||||
jae .used_enough
|
||||
|
||||
mov [wrong_place_error_str.letter], dl
|
||||
mov ax, bp
|
||||
add ax, '1'
|
||||
mov [wrong_place_error_str.position], al
|
||||
mov si, wrong_place_error_str
|
||||
jmp print_error
|
||||
|
||||
.used_enough:
|
||||
.not_wrong_place:
|
||||
inc bp
|
||||
jmp .wrong_places
|
||||
|
||||
.done:
|
||||
|
||||
check_ultra_hard_mode:
|
||||
cmp byte [ultra_hard_mode], 1
|
||||
jne .done
|
||||
|
||||
.done:
|
||||
|
||||
check_dictionary:
|
||||
; Dictionary is split by initial letter
|
||||
xor bx, bx
|
||||
|
@ -848,7 +945,20 @@ addr32 dd 0
|
|||
|
||||
year dw 0
|
||||
month dw 0
|
||||
day db 0
|
||||
day dw 0
|
||||
|
||||
exact_hit_error_str:
|
||||
db ' - letter at position '
|
||||
.position db '#'
|
||||
db " must be '"
|
||||
.letter db '#'
|
||||
db "'$"
|
||||
wrong_place_error_str:
|
||||
db " - letter '"
|
||||
.letter db '#'
|
||||
db "' from position "
|
||||
.position db '#'
|
||||
db ' must be reused$'
|
||||
|
||||
section .rodata
|
||||
|
||||
|
@ -863,7 +973,9 @@ guesses_str db ' guesses.$'
|
|||
guess_str db ' guess.$'
|
||||
|
||||
help_str:
|
||||
db 'Usage: dosdl', 13, 10
|
||||
db 'Usage: dosdl [/h | /u]', 13, 10
|
||||
db '/h Enable hard mode.', 13, 10
|
||||
db '/u Enable ultra hard mode.', 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
|
||||
|
@ -874,7 +986,12 @@ help_str:
|
|||
db ' above cases.', 13, 10
|
||||
db 13, 10
|
||||
db 'After the feedback, the game shows a list of letters that have not yet been', 13, 10
|
||||
db 'ruled out.$'
|
||||
db 'ruled out.', 13, 10
|
||||
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.$'
|
||||
|
||||
%include "dictionary.inc"
|
||||
%include "targets.inc"
|
||||
|
|
Loading…
Reference in New Issue