# HG changeset patch # User Pascal Bellard # Date 1696425197 0 # Node ID 61c76233911ebe27ab3bf0a2f513eedb5b84c5fe # Parent 5d44015ce87815226d1d03bf1afb5e60cff08fa7 bootbricks, bootinvaders, bootmine, bootris: exit with ESC key and restart on end of game diff -r 5d44015ce878 -r 61c76233911e bootbricks/stuff/bricks.asm --- a/bootbricks/stuff/bricks.asm Wed Sep 27 17:13:33 2023 +0000 +++ b/bootbricks/stuff/bricks.asm Wed Oct 04 13:13:17 2023 +0000 @@ -104,7 +104,12 @@ cbw ; Eat key int 0x16 cmp al,27 ; ESC key ? - je exit + jnz .0 + call wait_frame.2 ; Turn off sound + mov ax,0x0003 ; Text mode 80x25x16 colors + int 0x10 ; Setup + int 0x20 ; Exit to DOS / bootOS + int 0x19 .0: mov ah,0x02 ; Read modifier keys int 0x16 @@ -241,16 +246,6 @@ jmp another_ball ; Start another ball .1: call wait_frame.2 ; Turn off sound - stc -exit: - pushf - mov ax,0x0003 ; Text mode 80x25x16 colors - int 0x10 ; Setup - int 0x20 ; Exit to DOS / bootOS - popf - jc .1 - int 0x19 -.1: jmp start wait_frame: diff -r 5d44015ce878 -r 61c76233911e bootinvaders/stuff/invaders.asm --- a/bootinvaders/stuff/invaders.asm Wed Sep 27 17:13:33 2023 +0000 +++ b/bootinvaders/stuff/invaders.asm Wed Oct 04 13:13:17 2023 +0000 @@ -31,8 +31,8 @@ ; Lock. Used the extra bytes to implement ; barriers that stop the invaders' bullets. ; (suggested in Reddit by nils-m-holm). - ; Revision: Sep/13/2023. Fix bootsector end of game. Position - ; independant code. + ; Revision: Sep/13/2023. Fix bootsector end of game. To exit you + ; press ESC. Position independant code. ; cpu 8086 @@ -68,11 +68,9 @@ int 0x10 ; Call BIOS sti ; Allow interrupts cld - mov ax,0xa000 ; Point to screen memory - mov ds,ax ; Both DS... - mov es,ax ; ...and ES - mov ah,0x04 - mov [level],ax ; Level = 0, Lives = 4 + mov sp,0xa000 ; Point to screen memory + mov ds,sp ; Both DS... + mov es,sp ; ...and ES mov cx,level/2 ; Clear screen and variables (except level/lives) xor di,di mul di ; Clear ax and dx @@ -82,10 +80,8 @@ ; ; Setup descend state ; - mov ax,[di] ; al now contains level, ah contains lives - inc ax ; Increase by 2 (so invaders descend correctly) - inc ax - stosw ; Advance level + mov ax,0x0402 ; Level = 2 (so invaders descend correctly), Lives = 4 + stosw ; Store level mov ah,al xchg ax,dx ; Shouldn't damage DX starting here @@ -176,7 +172,6 @@ and bp,7 ; Each 8 invaders push dx push si - push bp mov si,shots ; Point to shots list jne in12 in22: @@ -204,8 +199,7 @@ jc in30 ; No, jump push si push di - mov ah,SPRITE_SIZE ; The pixel indicates the... - mul ah ; ...invader hit. + mul cl ; The pixel indicates the...invader hit. (SPRITE_SIZE=4) add si,ax lodsw xchg ax,di @@ -259,16 +253,40 @@ jne in42 ; Finished? No, jump mov ah,SPACESHIP_COLOR ; Restore color (sprite already) dec byte [si-2-sprites+lives] ; Remove one life - js in10 ; Exit if all used + js restart ; Exit if all used in42: mov [si-2],ax ; Save new frame / color mov di,[si] ; Load position call draw_sprite ; Draw sprite (spaceship) jne in43 ; Jump if still explosion - mov ah,0x02 ; BIOS Get Keyboard Flags +%ifdef USE_ARROW_KEYS + mov ah,0x01 + int 0x16 ; BIOS Got key + jz in35 ; No, jump + mov ah,0x00 + int 0x16 ; BIOS Get key + dec ah ; Escape key ? + je in10 + cmp ah,0x4d-1 ; Left arrow key ? + jnz in17a + inc di ; Move 2 pixels to left + inc di +in17a: cmp ah,0x4b-1 ; Right arrow key ? + jnz in17b + dec di ; Move 2 pixels to right + dec di +in17b: cmp al,0x20 ; Space key ? + jne in35 ; No, jump +%else + mov ah,0x01 + int 0x16 ; BIOS Got key + jz in17a ; No, jump + mov ah,0x00 + int 0x16 ; BIOS Get key + dec ah ; Escape key ? + je in10 +in17a: mov ah,0x02 ; BIOS Get Keyboard Flags int 0x16 - test al,0x10 ; Test for Scroll Lock and exit - jnz in10 mov bx,12 ; Ctrl/Alt key? and bl,al @@ -277,7 +295,8 @@ in17: test al,0x03 ; Shift keys? jz in35 ; No, jump - cmp word [shots],bx ; Bullet available? +%endif + cmp word [si-2-sprites+shots],bx ; Bullet available? ja in35 ; No, jump lea ax,[di+(0x04*2)] ; Offset from spaceship mov [shots],ax ; Start bullet @@ -289,7 +308,6 @@ je in43 in19: mov [si],ax ; Update position in43: - pop bp pop si pop dx @@ -300,11 +318,13 @@ add ax,0x0280 ; Go down by 2 pixels cmp ax,0x55*0x280 ; Reaches Earth? jc in8 ; No, jump +restart: + jmp restart_game in10: - mov ax,0x0003 ; Restore text mode + mov al,0x03 ; Restore text mode int 0x10 int 0x20 ; Exit to DOS - jmp restart_game + int 0x19 ; or reboot in9: dec ax ; Moving to left dec ax diff -r 5d44015ce878 -r 61c76233911e bootmine/stuff/mine.asm --- a/bootmine/stuff/mine.asm Wed Sep 27 17:13:33 2023 +0000 +++ b/bootmine/stuff/mine.asm Wed Oct 04 13:13:17 2023 +0000 @@ -4,6 +4,7 @@ %define CGA_DISPLAY %define DOS_QUIT %define FAT_BOOT +%define RESTART_ON_ANY_KEY cpu 8086 @@ -324,8 +325,6 @@ db 'GAME WIN' ;; Wait for restart key to be pressed, then restart game -WaitRestartLoop: - je RunGame WaitRestart: xor ax, ax int 0x16 @@ -339,8 +338,11 @@ int 0x19 .notQuit: %endif +%ifndef RESTART_ON_ANY_KEY cmp al, Key.Ascii.RestartGame - jmp WaitRestartLoop + jne WaitRestart +%endif + jmp RunGame ;; Array of adjacent cell offsets. A byte in this array can be added to a text ;; buffer cell pointer to get the pointer to an adjacent cell. This is used for diff -r 5d44015ce878 -r 61c76233911e bootris/stuff/tetranglix.asm --- a/bootris/stuff/tetranglix.asm Wed Sep 27 17:13:33 2023 +0000 +++ b/bootris/stuff/tetranglix.asm Wed Oct 04 13:13:17 2023 +0000 @@ -91,7 +91,7 @@ ; Calculate first index into screen. lodsw - aad 0x10 + aad 0x10 ; al = al + 16*ah, ah = 0 mov cl, 0x10 @@ -153,7 +153,7 @@ ret exit_game_over: - je start + jne start exit_dos: mov al,0x03 ; Clear screen int 0x10