diff options
Diffstat (limited to 'source.asm')
-rw-r--r-- | source.asm | 86 |
1 files changed, 71 insertions, 15 deletions
@@ -4,7 +4,7 @@ flag_character equ 'F' bombs_per_65535 equ 5000 board_width equ 26 -board_height equ 7 +board_height equ 10 offset_x equ 1 offset_y equ 1 @@ -59,16 +59,25 @@ number_loop: 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 * 3) * 80 * 2 + offset_x * 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 * 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 ah, controls_color show_controls_loop: @@ -136,7 +145,22 @@ bx_has_bomb: mul cx xor bh, bh 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] pop bx ret @@ -236,7 +260,6 @@ set_cursor: add dl, offset_x + 1 mov dh, ch add dh, ch - add dh, ch add dh, offset_y + 1 int 0x10 jmp main_loop @@ -303,16 +326,50 @@ dig: mov ah, byte [bx + uncovered_colors] mov word [es:di], ax - 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 - 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 + mov bx, word [cursor_x] + test bh, bh + jz .top_full_block + + 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] dec ax @@ -378,7 +435,6 @@ get_cursor_vram_offset: mov bh, ch add bh, ch - add bh, ch add bh, offset_y + 1 mov cx, 80 |