Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; Date : 1st April 2001 |
2 | ; TETRIS for MENUET |
||
3 | ; Author : Paolo Minazzi (email paolo.minazzi@inwind.it) |
||
4 | ; |
||
5 | ; -Note- |
||
6 | ; 1. This program requires a PENTIUM or higher because uses the RDTSC |
||
7 | ; instrucion for get a random number. |
||
8 | ; 2. You must use NASM to compile. Compiling is OK with NASM 0.98, I |
||
9 | ; don't know what happen with other versions. |
||
10 | ; 3. You must use the arrow key to move and rotate a block. |
||
11 | ; 4. In the near future there will be a new version of TETRIS. This is |
||
12 | ; only the beginning. |
||
13 | ; |
||
14 | ; Thanks to Ville, the author of this wonderful OS ! |
||
15 | ; Join with us to code ! |
||
16 | ; |
||
17 | ; |
||
18 | ; Changelog: |
||
19 | ; |
||
20 | ; 28.06.2001 - fasm port & framed blocks - Ville Turjanmaa |
||
21 | ; 31.10.2001 - rdtsc replaced - quickcode |
||
22 | ; 03.11.2003 - added new blocks & random - Ivan Poddubny |
||
23 | ; |
||
24 | |||
25 | LEN_X equ 14 |
||
26 | LEN_Y equ 24 |
||
27 | BORDER_LEFT equ 2 |
||
28 | BORDER_RIGHT equ 2 |
||
29 | BORDER_TOP equ 1 |
||
30 | BORDER_BOTTOM equ 1 |
||
31 | ADOBE_SIZE equ 12 |
||
32 | X_LOCATION equ 6 |
||
33 | Y_LOCATION equ 21 |
||
34 | _MAXBLOCKS_ = 7*4 |
||
35 | SCORE_TO_NEW_LEVEL equ 100000 |
||
36 | |||
37 | |||
38 | use32 |
||
39 | |||
40 | org 0x0 |
||
41 | |||
42 | db 'MENUET01' ; 8 byte id |
||
43 | dd 0x01 ; header version |
||
44 | dd START ; program start |
||
45 | dd I_END ; program image size |
||
46 | dd IM_END ; reguired amount of memory |
||
47 | dd IM_END ; esp |
||
48 | dd 0x0,0x0 ; I_PARAM, I_ICON |
||
49 | include 'lang.inc' |
||
50 | START: ; start of execution |
||
51 | |||
52 | mov eax,3 ; |
||
53 | int 0x40 ; |
||
54 | mov cl,16 ; |
||
55 | ror eax,cl ; to make seconds more significant |
||
56 | mov [generator],eax ; |
||
57 | call random ; |
||
58 | |||
59 | mov byte[status],'0' |
||
60 | mov byte[menu],'0' |
||
61 | call draw_window ; at first, draw the window |
||
62 | |||
63 | still: |
||
64 | |||
65 | cmp byte[status],'2' |
||
66 | je attesa |
||
67 | |||
68 | cmp byte[status],'1' |
||
69 | |||
70 | jne attesa |
||
71 | xor edx,edx |
||
72 | |||
73 | call draw_block |
||
74 | |||
75 | |||
76 | attesa: |
||
77 | |||
78 | call mouse |
||
79 | ;disabled because of bug |
||
80 | ;EDIT: the bug is somewhere else.. |
||
81 | ;NOTE: dont release this without fixing the bug you lazy bastard! |
||
82 | |||
83 | mov eax,11 ; get event |
||
84 | int 0x40 |
||
85 | |||
86 | cmp eax,1 ; redraw request ? |
||
87 | jz red |
||
88 | cmp eax,2 ; key in buffer ? |
||
89 | jnz check_button |
||
90 | jmp key |
||
91 | check_button: |
||
92 | cmp eax,3 ; button in buffer ? |
||
93 | jnz scendi |
||
94 | mov eax,-1 ; close this program |
||
95 | int 0x40 |
||
96 | |||
97 | red: ; redraw |
||
98 | call draw_window |
||
99 | jmp still |
||
100 | |||
101 | parallel dd 1 |
||
102 | |||
103 | scendi: cmp byte[status],'1' |
||
104 | jne still |
||
105 | |||
106 | cmp byte[blabla],10 |
||
107 | je blabla_0 |
||
108 | inc byte[blabla] |
||
109 | jmp blabla_1 |
||
110 | blabla_0: |
||
111 | mov byte[blabla],0 |
||
112 | inc dword [current_block_y] |
||
113 | call check_crash |
||
114 | jne block_crash |
||
115 | blabla_1: |
||
116 | |||
117 | |||
118 | draw: movzx edx,byte [current_block_color] |
||
119 | call draw_block |
||
120 | mov eax,5 |
||
121 | mov ebx,5 |
||
122 | sub ebx,[speed] |
||
123 | int 0x40 |
||
124 | jmp still |
||
125 | |||
126 | block_crash: dec dword [current_block_y] |
||
127 | movzx edx,byte [current_block_color] |
||
128 | call draw_block |
||
129 | call fix_block |
||
130 | call check_full_line |
||
131 | call draw_table |
||
132 | call new_block |
||
133 | call write_score |
||
134 | call check_crash |
||
135 | jz adr400 |
||
136 | aspetta: mov eax,10 |
||
137 | int 0x40 |
||
138 | cmp eax,1 |
||
139 | jne adr10000 |
||
140 | call draw_window |
||
141 | adr10000: cmp eax,3 |
||
142 | jne aspetta |
||
143 | |||
144 | new_game: mov dword [score],0 |
||
145 | mov dword [lines],0 |
||
146 | mov dword [level],0 |
||
147 | mov dword [speed],0 |
||
148 | mov byte [status],'1' |
||
149 | call clear_table_tetris |
||
150 | call first_block |
||
151 | call new_block |
||
152 | call draw_window |
||
153 | |||
154 | adr400: movzx edx,byte [current_block_color] |
||
155 | call draw_block |
||
156 | jmp still |
||
157 | |||
158 | include 'key.inc' |
||
159 | include 'mouse.inc' |
||
160 | include 'menu.inc' |
||
161 | include 'window.inc' |
||
162 | include 'block.inc' |
||
163 | include 'table.inc' |
||
164 | include 'random.inc' |
||
165 | include 'score.inc' |
||
166 | |||
167 | ; DATA AREA |
||
168 | |||
169 | include 'blocks.inc' |
||
170 | |||
171 | labelt: db 'TETRIS II' |
||
172 | scoretext: db 'Score:' |
||
173 | linestext: db 'Lines:' |
||
174 | speedtext: db 'Speed:' |
||
175 | leveltext: db 'Level:' |
||
176 | startgame: db 'START' |
||
177 | instr: db 'INSTRUCTIONS' |
||
178 | hist: db 'HISTORY' |
||
179 | quit: db 'EXIT' |
||
180 | paused: db 'PAUSED' |
||
181 | txt_end: |
||
182 | |||
183 | history: |
||
184 | db 'TETRIS for MENUET v2.0 ' |
||
185 | db ' ' |
||
186 | db ' ' |
||
187 | db 'Originally made ' |
||
188 | db ' by Paolo Minazzi ' |
||
189 | db ' ' |
||
190 | db 'Port & framed blocks ' |
||
191 | db ' by Ville Turjanmaa ' |
||
192 | db ' ' |
||
193 | db 'RDTSC replaced ' |
||
194 | db ' by quickcode ' |
||
195 | db ' ' |
||
196 | db 'New blocks & better random ' |
||
197 | db ' by Ivan Poddubny ' |
||
198 | db ' ' |
||
199 | db 'Better control, logo, menu, pause ' |
||
200 | db ' by Jeffrey Amelynck' |
||
201 | |||
202 | db 'x <- END MARKER, DONT DELETE ' |
||
203 | |||
204 | instructions: |
||
205 | db 'TETRIS for MENUET v2.0 ' |
||
206 | db ' ' |
||
207 | db 'Controls: ' |
||
208 | db ' ' |
||
209 | db 'Use left & right key to navigate ' |
||
210 | db 'Use up key to turn the block ' |
||
211 | db 'Use down key to make block fall ' |
||
212 | db 'Use P to pause game ' |
||
213 | db 'Use N to start a new game ' |
||
214 | db 'Use ESC to go back to menu or exit' |
||
215 | db 'You can also use the mouse to move' |
||
216 | db 'the blocks, left button to let the' |
||
217 | db 'blocks fall and right button to ' |
||
218 | db 'rotate them ' |
||
219 | db 'you can pause the game by pressing' |
||
220 | db 'both mouse buttons ' |
||
221 | db ' ' |
||
222 | db 'DONT FORGET: move mouse out of the' |
||
223 | db 'window if you want to use keyboard' |
||
224 | |||
225 | db 'x <- END MARKER, DONT DELETE ' |
||
226 | |||
227 | I_END: |
||
228 | |||
229 | score: dd 0 |
||
230 | level: dd 0 |
||
231 | speed: dd 0 |
||
232 | lines: dd 0 |
||
233 | TMP_0: dd 0 |
||
234 | TMP_1: dd 0 |
||
235 | generator: dd 0 |
||
236 | current_block_x: dd 0 |
||
237 | current_block_y: dd 0 |
||
238 | current_block_pointer: dd 0 |
||
239 | current_block_color: db 0 |
||
240 | next_block_pointer: dd 0 |
||
241 | next_block_color: db 0 |
||
242 | blabla dd 0 |
||
243 | lastmousebutton dd 0 |
||
244 | number_str: db 0,0,0,0,0,0,0,0,0 |
||
245 | end_number_str: |
||
246 | size_of_number_str dd 7 |
||
247 | delay: dd 5 |
||
248 | status: dd 0 ; 0=menu, 1=playing, 2=paused, 3=history , 4=instructions |
||
249 | menu: dd 0 ; 0=start, 1=instructions, 2=history, 3=exit |
||
250 | |||
251 | table_tetris: rb 2048+55 |
||
252 | |||
253 | IM_END:->-> |