cleaning keys-buffer before reading the key.

git-svn-id: svn://kolibrios.org@685 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
gluk 2007-12-30 20:19:55 +00:00
parent e02112ea70
commit 0f35a891d9

View File

@ -57,9 +57,8 @@ use32
dd I_END+1024 ; reguired amount of memory dd I_END+1024 ; reguired amount of memory
dd I_END+1024 ; esp dd I_END+1024 ; esp
dd 0x0,0x0 ; I_PARAM, I_ICON dd 0x0,0x0 ; I_PARAM, I_ICON
include 'lang.inc' include 'lang.inc'
include '..\..\..\macros.inc' include 'macros.inc'
START: ; start of execution START: ; start of execution
@ -68,7 +67,7 @@ START: ; start of execution
; -- quickcode - start ; -- quickcode - start
mov eax,3 mov eax,3
mcall int 0x40
mov cl,16 mov cl,16
ror eax,cl ; to make seconds more significant ror eax,cl ; to make seconds more significant
mov [generator],eax mov [generator],eax
@ -88,7 +87,7 @@ still:
attesa: attesa:
mov eax,11 ; get event mov eax,11 ; get event
mcall int 0x40
cmp eax,1 ; redraw request ? cmp eax,1 ; redraw request ?
jz red jz red
@ -126,7 +125,7 @@ draw: movzx edx,byte [current_block_color]
call draw_block call draw_block
mov eax,5 mov eax,5
movzx ebx,byte [delay] movzx ebx,byte [delay]
mcall int 0x40
jmp still jmp still
block_crash: dec dword [current_block_y] block_crash: dec dword [current_block_y]
@ -141,14 +140,14 @@ block_crash: dec dword [current_block_y]
call check_crash call check_crash
jz adr400 jz adr400
aspetta: mov eax,10 aspetta: mov eax,10
mcall int 0x40
cmp eax,1 cmp eax,1
jne adr10000 jne adr10000
call draw_window call draw_window
adr10000: cmp eax,3 adr10000: cmp eax,3
jne aspetta jne aspetta
new_game: mov eax,17 new_game: mov eax,17
mcall int 0x40
cmp ah,1 cmp ah,1
jnz adr401 jnz adr401
jmp end_program jmp end_program
@ -165,11 +164,18 @@ adr400: movzx edx,byte [current_block_color]
call draw_block call draw_block
mov eax,5 mov eax,5
movzx ebx,byte [delay] movzx ebx,byte [delay]
mcall int 0x40
jmp still jmp still
key: mov eax,2 key: mov eax,2
mcall int 0x40
cmp eax,1
jne getkeyi
mov ah,dh
jmp adr32
getkeyi: mov dh,ah
jmp key
adr32: cmp ah,LEFT_KEY adr32: cmp ah,LEFT_KEY
jne adr_30 jne adr_30
@ -211,7 +217,7 @@ adr62: jmp scendi
button: ; button button: ; button
mov eax,17 mov eax,17
mcall int 0x40
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jz end_program jz end_program
cmp ah,2 cmp ah,2
@ -222,7 +228,7 @@ button: ; button
end_program: end_program:
or eax,-1 ; close this program or eax,-1 ; close this program
mcall int 0x40
go_new_game: go_new_game:
jmp new_game jmp new_game
@ -246,20 +252,20 @@ draw_window:
mov ebx,3 mov ebx,3
mov ecx,sc mov ecx,sc
mov edx,sizeof.system_colors mov edx,sizeof.system_colors
mcall int 0x40
mov eax,12 ; function 12:tell os about windowdraw mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw mov ebx,1 ; 1, start of draw
mcall int 0x40
; DRAW WINDOW ; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window xor eax,eax ; function 0 : define and draw window
mov ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2 mov ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2
mov ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30 mov ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30
mov edx,[sc.work] ; color of work area RRGGBB mov edx,[sc.work] ; color of work area RRGGBB
or edx,0x14000000 or edx,0x13000000
mov edi,title ; WINDOW LABEL mov edi,header ; WINDOW LABEL
mcall int 0x40
mov eax,8 mov eax,8
@ -267,26 +273,26 @@ draw_window:
mov ecx,378*65536+18 mov ecx,378*65536+18
mov edx,2 mov edx,2
mov esi,[sc.work_button] mov esi,[sc.work_button]
mcall int 0x40
;/////////////////////////////////////////////// Wildwest's 'Pause' button ;/////////////////////////////////////////////// Wildwest's 'Pause' button
;mov eax,8 ;mov eax,8
mov ebx,132*65536+102 mov ebx,132*65536+102
mov ecx,378*65536+18 mov ecx,378*65536+18
mov edx,3 mov edx,3
mov esi,[sc.work_button]; mov esi,[sc.work_button];
mcall int 0x40
mov eax,4 ; function 4 : write text to window mov eax,4 ; function 4 : write text to window
mov ebx,164*65536+384 ; [x start] *65536 + [y start] mov ebx,164*65536+384 ; [x start] *65536 + [y start]
mov ecx,[sc.work_button_text] ; color of text RRGGBB mov ecx,[sc.work_button_text] ; color of text RRGGBB
or ecx,0x90000000 or ecx,0x90000000
mov edx,labe ; pointer to text mov edx,labe ; pointer to text
mcall int 0x40
;/////////////////////////////////////////////// ;///////////////////////////////////////////////
;mov eax,4 ;mov eax,4
mov ebx,49*65536+384 mov ebx,49*65536+384
mov edx,game_finished mov edx,game_finished
mcall int 0x40
call draw_table call draw_table
movzx edx,byte [current_block_color] movzx edx,byte [current_block_color]
@ -298,13 +304,13 @@ draw_window:
or ecx,0x90000000 or ecx,0x90000000
mov edx,text mov edx,text
mov eax,4 mov eax,4
mcall int 0x40
call write_score call write_score
mov eax,12 ; function 12:tell os about windowdraw mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw mov ebx,2 ; 2, end of draw
mcall int 0x40
ret ret
@ -440,12 +446,12 @@ x_draw: push edi
; pusha ; pusha
; mov eax,5 ; mov eax,5
; mov ebx,10 ; mov ebx,10
; mcall ; int 0x40
; popa ; popa
mov eax,13 mov eax,13
movzx edx,byte [esi] movzx edx,byte [esi]
mov edx,[color_table+edx*4] mov edx,[color_table+edx*4]
mcall int 0x40
call draw_frames call draw_frames
inc esi inc esi
add ebx,65536*ADOBE_SIZE add ebx,65536*ADOBE_SIZE
@ -494,7 +500,7 @@ adr_122: mov dword [TMP_0],4
adr_121: cmp byte [edi],0 adr_121: cmp byte [edi],0
je adr_120 je adr_120
mcall int 040h
call draw_frames call draw_frames
@ -518,14 +524,14 @@ draw_frames:
mov bx,1 mov bx,1
add edx,0x282828 add edx,0x282828
mov eax,13 mov eax,13
mcall int 0x40
popa popa
pusha pusha
mov cx,1 mov cx,1
add edx,0x282828 add edx,0x282828
mov eax,13 mov eax,13
mcall int 0x40
popa popa
pusha pusha
@ -537,7 +543,7 @@ draw_frames:
shr edx,1 shr edx,1
and edx,0x7f7f7f and edx,0x7f7f7f
mov eax,13 mov eax,13
mcall int 0x40
popa popa
pusha pusha
@ -549,7 +555,7 @@ draw_frames:
shr edx,1 shr edx,1
and edx,0x7f7f7f and edx,0x7f7f7f
mov eax,13 mov eax,13
mcall int 0x40
popa popa
ret ret
@ -619,7 +625,7 @@ random: mov eax,[generator]
push ebx push ebx
mov eax,26 mov eax,26
mov ebx,9 mov ebx,9
mcall int 0x40
pop ebx pop ebx
xor eax,0xdeadbeef xor eax,0xdeadbeef
add eax,[generator] add eax,[generator]
@ -650,7 +656,7 @@ write_score:
mov esi,[size_of_number_str] mov esi,[size_of_number_str]
mov edi,[sc.work] mov edi,[sc.work]
mov eax,4 mov eax,4
mcall int 0x40
ret ret
; DATA AREA ; DATA AREA
@ -826,14 +832,14 @@ block_table:
if lang eq ru if lang eq ru
title db '<E280A6>ˆ 1.61 - <E28098>Šˆ ˆ <20><>Ž<EFBFBD>',0 header db '<E280A6>ˆ 1.61 - <E28098>Šˆ ˆ <20><>Ž<EFBFBD>',0
labe db '<27>€“‡€',0 labe db '<27>€“‡€',0
text db 'Žçª¨:',0 text db 'Žçª¨:',0
game_finished: db '<27>Ž€Ÿ',0 game_finished: db '<27>Ž€Ÿ',0
else else
title db 'TETRIS 1.61 - ARROWS & SPACE',0 header db 'TETRIS 1.61 - ARROWS & SPACE',0
labe db 'PAUSE',0 labe db 'PAUSE',0
text db 'Score:',0 text db 'Score:',0
game_finished: db 'NEW GAME',0 game_finished: db 'NEW GAME',0