Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
UP_KEY equ 178							; the ascii keycodes of some keys
2
DOWN_KEY equ 177
3
LEFT_KEY equ 176
4
RIGHT_KEY equ 179
5
ENTER_KEY equ 13
6
ESCAPE_KEY equ 27
7
 
8
key:
9
		mov  eax,2					; Read key ascii and store it into ah
10
		int  0x40
11
 
12
		cmp  ah,LEFT_KEY				; Check if left key is pressed
13
		jne  no_left
14
 
15
			cmp  byte[status],'1'
16
			jne  no_left
17
		     go_left:
18
			dec  dword [current_block_x]
19
			call check_crash
20
			jz   no_left
21
			inc  dword [current_block_x]
22
 
23
no_left:
24
		cmp  ah,RIGHT_KEY				; Check if right key is pressed
25
		jne  no_right
26
 
27
			cmp  byte[status],'1'
28
			jne  no_right
29
		    go_right:
30
			inc  dword [current_block_x]
31
			call check_crash
32
			jz   no_right
33
			dec  dword [current_block_x]
34
 
35
no_right:
36
		cmp  ah,UP_KEY					; Compare pressed key with up key
37
		jne  no_up					; Jump to nu_up if up key isnt pressed
38
 
39
			cmp byte[status],'0'			; Check if menu is running
40
			jne no_menu2				; Jump to no_up ifgame isnt running
41
 
42
				cmp  byte[menu],'0'		; Compare menu state with 0
43
				jne  no_menu0			; Jump to no_menu0 if menu state isnt zero
44
 
45
				mov  byte[menu],'3'		; Change menu state to 2
46
				call draw_window		; Redraw the window
47
				jmp  no_menu2			; Jump to no_menu2
48
 
49
			      no_menu0:
50
				dec  byte[menu] 		; menu state = menu state - 1
51
				call draw_window		; Redraw the window
52
 
53
	      no_menu2:
54
		cmp  byte[status],'1'				; Compare game state with 1
55
		jne  no_up					; Jump to no_up if game state isnt 1 (if game isnt running)
56
 
57
		call rotate_block
58
 
59
no_up:
60
		cmp  ah,DOWN_KEY				; Check if down key is pressed
61
		jne  no_down
62
 
63
			cmp  byte[status],'0'
64
			jne  no_menu3
65
 
66
				cmp  byte[menu],'3'
67
				jne  no_menu1
68
 
69
				mov  byte[menu],'0'
70
				call draw_window
71
				jmp  no_menu3
72
 
73
			      no_menu1:
74
				inc  byte[menu]
75
				call draw_window
76
 
77
	      no_menu3:
78
		cmp  byte[status],'1'
79
		jne  no_down
80
 
81
		inc  dword [current_block_y]
82
		call check_crash
83
		jne  block_crash
84
		jmp  still
85
 
86
 
87
no_down:
88
		cmp  ah,'n'					 ; Check if n key is pressed
89
		jne  no_n
90
		jmp  new_game
91
 
92
no_n:
93
		cmp  ah,'p'					 ; Check if p key is pressed
94
		jne  no_p
95
		cmp  byte[status],'2'
96
		je   unpause
97
		cmp  byte[status],'1'				 ; add this two line or p will work
98
		jne  no_p					 ; when your still in the menu
99
		mov  byte[status],'2'
100
		call draw_window
101
		jmp  attesa
102
	      unpause:
103
		mov  byte[status],'1'
104
		call draw_window
105
		jmp  still
106
 
107
no_p:
108
		cmp  byte[status],'0'
109
		jne  no_menu
110
 
111
no_menu:
112
		cmp  byte[status],'1'
113
		jne  no_game
114
 
115
no_game:
116
		cmp  byte[status],'2'
117
		jne  no_pause1
118
 
119
no_pause1:
120
		cmp  ah,ENTER_KEY				; Check if enter key is pressed
121
		jne  no_enter
122
		cmp  byte[status],'0'
123
		jne  no_enter
124
		call exemenu
125
 
126
no_enter:
127
		cmp  ah,ESCAPE_KEY				; Check if escape key is pressed
128
		jne  no_escape
129
 
130
 
131
			cmp  byte[status],'0'
132
			jne  no_instr1
133
			mov  eax,-1
134
			int  0x40
135
 
136
		      no_instr1:
137
			cmp  byte[status],'1'
138
			jne  no_menu4
139
			mov  byte[status],'0'
140
			call draw_window
141
 
142
		      no_menu4:
143
			cmp  byte[status],'3'
144
			jne  no_menu5
145
			mov  byte[status],'0'
146
			call draw_window
147
 
148
		      no_menu5:
149
			cmp  byte[status],'4'
150
			jne  no_escape
151
			mov  byte[status],'0'
152
			call draw_window
153
 
154
no_escape:
155
 
156
		cmp  byte[status],'1'
157
		jne  still
158
		jmp  scendi
159
 
160
ret
161