more square

This commit is contained in:
Benji Dial 2022-08-09 10:15:47 -04:00
parent 6c07318e36
commit dc0ae9da11

View file

@ -4,7 +4,7 @@ flag_character equ 'F'
bombs_per_65535 equ 5000 bombs_per_65535 equ 5000
board_width equ 26 board_width equ 26
board_height equ 7 board_height equ 10
offset_x equ 1 offset_x equ 1
offset_y equ 1 offset_y equ 1
@ -59,16 +59,25 @@ number_loop:
rep stosw rep stosw
mov di, offset_y * 80 * 2 + offset_x * 2 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) | ' ' mov ax, (covered_color << 8) | ' '
gray_loop: gray_loop:
mov cx, board_width * 3 mov cx, board_width * 3
rep stosw rep stosw
add di, (80 - board_width * 3) * 2 add di, (80 - board_width * 3) * 2
cmp di, (offset_y + board_height * 3) * 80 * 2 + offset_x * 2 cmp di, (offset_y + board_height * 2) * 80 * 2 + offset_x * 2
jne gray_loop jne gray_loop
mov cx, board_width * 3
mov ax, (covered_color << 8) | 0xdc
rep stosw
mov si, controls_str mov si, controls_str
mov di, (offset_y + board_height * 3 + 1) * 80 * 2 + offset_x * 2 + ((board_width * 3 - controls_str.len) / 4) * 2 mov di, (offset_y + board_height * 2 + 2) * 80 * 2 + offset_x * 2 + ((board_width * 3 - controls_str.len) / 4) * 2
mov cx, controls_str.len mov cx, controls_str.len
mov ah, controls_color mov ah, controls_color
show_controls_loop: show_controls_loop:
@ -136,7 +145,22 @@ bx_has_bomb:
mul cx mul cx
xor bh, bh xor bh, bh
add bx, ax add bx, ax
mov ax, 0x1 mov ax, board_bomb
and al, byte [board_flags + bx]
pop bx
ret
;bx - y:x
;preserves bx, di, and si
;returns in ax
bx_uncovered:
push bx
movzx ax, bh
mov cx, board_width
mul cx
xor bh, bh
add bx, ax
mov ax, board_uncovered
and al, byte [board_flags + bx] and al, byte [board_flags + bx]
pop bx pop bx
ret ret
@ -236,7 +260,6 @@ set_cursor:
add dl, offset_x + 1 add dl, offset_x + 1
mov dh, ch mov dh, ch
add dh, ch add dh, ch
add dh, ch
add dh, offset_y + 1 add dh, offset_y + 1
int 0x10 int 0x10
jmp main_loop jmp main_loop
@ -303,16 +326,50 @@ dig:
mov ah, byte [bx + uncovered_colors] mov ah, byte [bx + uncovered_colors]
mov word [es:di], ax mov word [es:di], ax
mov byte [es:di - 80 * 2 - 2 + 1], ah mov bx, word [cursor_x]
mov byte [es:di - 80 * 2 + 1], ah test bh, bh
mov byte [es:di - 80 * 2 + 2 + 1], ah jz .top_full_block
mov byte [es:di - 2 + 1], ah
mov byte [es:di + 1], ah
mov byte [es:di + 2 + 1], ah
mov byte [es:di + 80 * 2 - 2 + 1], ah
mov byte [es:di + 80 * 2 + 1], ah
mov byte [es:di + 80 * 2 + 2 + 1], ah
dec bh
call bx_uncovered
inc bh
test al, al
jnz .top_full_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], ' '
.middle:
mov byte [es:di - 2 + 1], 0
mov byte [es:di + 2 + 1], 0
cmp bh, board_height - 1
je .bottom_full_block
inc bh
call bx_uncovered
dec bh
test al, al
jnz .bottom_full_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], ' '
.dec_bombs:
mov ax, word [non_bombs_left] mov ax, word [non_bombs_left]
dec ax dec ax
@ -378,7 +435,6 @@ get_cursor_vram_offset:
mov bh, ch mov bh, ch
add bh, ch add bh, ch
add bh, ch
add bh, offset_y + 1 add bh, offset_y + 1
mov cx, 80 mov cx, 80