Professional Documents
Culture Documents
Code
Code
org 100h
;;=============================================================================;;
;; ;;
;; Hoover Ball ;;
;; ;;
;; ;;
;; ;;
;; ;;
;; ;;
;;=============================================================================;;
.model large
.data
exit db 0
;direction of player
;up=8, down=2
direction db 0d
hit_num db 0d
hits dw 0d
miss dw 0d
dw ' | |',0ah,0dh
dw ' |---------------|',0ah,0dh
dw ' |_______________|',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ',0ah,0dh
dw ' ====================================================',0ah,0dh
dw ' || ||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' ||--------------------------------------------------||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' || ||',0ah,0dh
dw ' ====================================================',0ah,0dh
dw '$',0ah,0dh
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
jmp game_menu ;display main menu
mov ah,1h
jnz key_pressed
jge game_over
je hit
je player_up
je player_down
cmp arrow_pos, dx
jge hide_arrow
jle miss_loon
jne render_loon
mov ah,2
mov dx, 7d
int 21h
call show_score
lea dx,state_buf
mov ah,09h
int 21h
int 21h
mov es:[bx], cx
mov bx,loon_pos
mov es:[bx], cx
je render_arrow
jne inside_loop2
mov es:[bx], cx
mov bx,arrow_pos
mov es:[bx], cx
inside_loop2:
mov bx,player_pos
mov es:[bx], cx
cmp exit,0
jmp exit_game
jmp inside_loop2
mov bx,player_pos
mov es:[bx], cx
mov direction, 0
player_down:
mov cl, ' ' ;same as player up
mov ch, 1111b ;hide old one and set new postion
mov bx,player_pos
mov es:[bx], cx
mov direction, 0
jmp inside_loop2
mov ah,0
int 16h
je upKey
je downKey
je spaceKey
je leftKey
jmp inside_loop
leftKey: ;we use it for debuging
;jmp game_over
inc miss
lea bx,state_buf
call show_score
lea dx,state_buf
mov ah,09h
int 21h
mov ah,2
int 21h
jmp inside_loop
mov direction, 8d
jmp inside_loop
downKey:
jmp inside_loop
cmp arrow_status,0
je fire_arrow
jmp inside_loop
mov arrow_pos, dx
miss_loon:
call show_score
lea dx,state_buf
mov ah,09h
int 21h
;new line
mov ah,2
int 21h
jmp fire_loon
mov loon_status, 1d
jmp render_loon
hide_arrow:
mov bx,arrow_pos
mov es:[bx], cx
cmp loon_pos, 0d
jle miss_loon
jne render_loon
jmp inside_loop2
game_over:
mov ah,09h
;mov dh,0
int 21h
mov bx,arrow_pos
mov miss, 0d
mov hits,0d
mov arrow_pos, 0d
mov arrow_status, 0d
mov loon_status, 0d
mov direction, 0d
input:
mov ah,1
int 21h
cmp al,13d
jne input
call clear_screen
jmp main_loop
game_menu:
mov dh,0
int 21h
input2:
mov ah,1
int 21h
cmp al,13d
jne input2
call clear_screen
call show_score
lea dx,state_buf
mov ah,09h
int 21h
mov ah,2
int 21h
jmp main_loop
mov exit,10d
main endp
;;--------------------------------------------------------------------;;
;; ;;
;; ;;
;;____________________________________________________________________;;
proc show_score
lea bx,state_buf
add dx,48d
mov [bx], 9d
mov [bx+1], 9d
mov [bx+2], 9d
mov [bx+3], 9d
mov [bx+9], dx
add dx,48d
mov [bx+16], dx
ret
show_score endp
;;--------------------------------------------------------------------;;
;; ;;
;; ;;
;;____________________________________________________________________;;
mov ah,0
mov al,3
int 10h
ret
clear_screen endp
end main
ret