uncover orthogonal entries on zero

This commit is contained in:
Benji Dial 2022-08-09 10:57:44 -04:00
parent dc0ae9da11
commit 220abdbdef

View file

@ -1,5 +1,5 @@
covered_color equ 0x70
controls_color equ 0x0f
controls_color equ 0x70
flag_character equ 'F'
bombs_per_65535 equ 5000
@ -54,27 +54,27 @@ number_loop:
pop es
xor di, di
mov ax, ' '
mov ax, (covered_color << 8) | ' '
mov cx, 80 * 25
rep stosw
mov di, offset_y * 80 * 2 + offset_x * 2
mov cx, board_width * 3
mov ax, (covered_color << 8) | 0xdf
rep stosw
mov di, (offset_y + 1) * 80 * 2 + offset_x * 2
mov ax, (covered_color << 8) | ' '
gray_loop:
mov cx, board_width * 3
rep stosw
add di, (80 - board_width * 3) * 2
cmp di, (offset_y + board_height * 2) * 80 * 2 + offset_x * 2
jne gray_loop
mov cx, board_width * 3
mov ax, (covered_color << 8) | 0xdc
rep stosw
; mov di, offset_y * 80 * 2 + offset_x * 2
; mov cx, board_width * 3
; mov ax, (covered_color << 8) | 0xdf
; rep stosw
;
; mov di, (offset_y + 1) * 80 * 2 + offset_x * 2
; mov ax, (covered_color << 8) | ' '
;gray_loop:
; mov cx, board_width * 3
; rep stosw
; add di, (80 - board_width * 3) * 2
; cmp di, (offset_y + board_height * 2) * 80 * 2 + offset_x * 2
; jne gray_loop
;
; mov cx, board_width * 3
; mov ax, (covered_color << 8) | 0xdc
; rep stosw
mov si, controls_str
mov di, (offset_y + board_height * 2 + 2) * 80 * 2 + offset_x * 2 + ((board_width * 3 - controls_str.len) / 4) * 2
@ -305,10 +305,16 @@ right_arrow:
jmp main_loop
dig:
push main_loop
do_dig:
call get_board_flags_at_cursor
test al, board_uncovered | board_flagged
jnz main_loop
jz .can_dig
ret
.can_dig:
test al, board_bomb
jnz lose
@ -321,6 +327,7 @@ dig:
pop ax
call get_number_at_cursor
push ax
movzx bx, al
mov al, byte [bx + uncovered_numbers]
mov ah, byte [bx + uncovered_colors]
@ -328,46 +335,46 @@ dig:
mov bx, word [cursor_x]
test bh, bh
jz .top_full_block
jz .top_half_block
dec bh
call bx_uncovered
inc bh
test al, al
jnz .top_full_block
jz .top_half_block
mov word [es:di - 80 * 2 - 2], (covered_color << 8) | 0xdc
mov word [es:di - 80 * 2], (covered_color << 8) | 0xdc
mov word [es:di - 80 * 2 + 2], (covered_color << 8) | 0xdc
jmp .middle
.top_full_block:
mov word [es:di - 80 * 2 - 2], ' '
mov word [es:di - 80 * 2], ' '
mov word [es:di - 80 * 2 + 2], ' '
jmp .middle
.top_half_block:
mov word [es:di - 80 * 2 - 2], (covered_color << 8) | 0xdc
mov word [es:di - 80 * 2], (covered_color << 8) | 0xdc
mov word [es:di - 80 * 2 + 2], (covered_color << 8) | 0xdc
.middle:
mov byte [es:di - 2 + 1], 0
mov byte [es:di + 2 + 1], 0
cmp bh, board_height - 1
je .bottom_full_block
je .bottom_half_block
inc bh
call bx_uncovered
dec bh
test al, al
jnz .bottom_full_block
jz .bottom_half_block
mov word [es:di + 80 * 2 - 2], (covered_color << 8) | 0xdf
mov word [es:di + 80 * 2], (covered_color << 8) | 0xdf
mov word [es:di + 80 * 2 + 2], (covered_color << 8) | 0xdf
jmp .dec_bombs
.bottom_full_block:
mov word [es:di + 80 * 2 - 2], ' '
mov word [es:di + 80 * 2], ' '
mov word [es:di + 80 * 2 + 2], ' '
jmp .dec_bombs
.bottom_half_block:
mov word [es:di + 80 * 2 - 2], (covered_color << 8) | 0xdf
mov word [es:di + 80 * 2], (covered_color << 8) | 0xdf
mov word [es:di + 80 * 2 + 2], (covered_color << 8) | 0xdf
.dec_bombs:
mov ax, word [non_bombs_left]
@ -378,7 +385,70 @@ dig:
mov word [non_bombs_left], ax
jmp main_loop
pop ax
test al, al
jz .expand
ret
.expand:
mov al, byte [cursor_y]
test al, al
jz .no_up
dec al
mov byte [cursor_y], al
call do_dig
mov al, byte [cursor_y]
inc al
mov byte [cursor_y], al
.no_up:
mov al, byte [cursor_y]
cmp al, board_height - 1
je .no_down
inc al
mov byte [cursor_y], al
call do_dig
mov al, byte [cursor_y]
dec al
mov byte [cursor_y], al
.no_down:
mov al, byte [cursor_x]
test al, al
jz .no_left
dec al
mov byte [cursor_x], al
call do_dig
mov al, byte [cursor_x]
inc al
mov byte [cursor_x], al
.no_left:
mov al, byte [cursor_x]
cmp al, board_width - 1
je .no_right
inc al
mov byte [cursor_x], al
call do_dig
mov al, byte [cursor_x]
dec al
mov byte [cursor_x], al
.no_right:
ret
uncovered_colors:
db 0x08, 0x08, 0x0a, 0x0c, 0x0b, 0x0e, 0x09, 0x07, 0x0f