Subversion Repositories Kolibri OS

Rev

Rev 2678 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2678 Rev 9241
Line 1... Line 1...
1
;
1
;
2
;   Phenix Dynamic Game Created by Pavlushin Evgeni for ASCL
2
;   Phoenix Game. Based on ASCL Library
3
;
-
 
4
;   100% Full relase!
-
 
5
;
-
 
6
;   www.waptap@mail.ru
-
 
7
;
3
;
Line 8... Line -...
8
 
-
 
9
 
4
 
10
;******************************************************************************
5
;**********************************************************************
11
    use32
6
   use32
12
    org    0x0
7
   org    0x0
13
    db     'MENUET01'              ; 8 byte id
8
   db     'MENUET01'              ; 8 byte id
14
    dd     0x01                    ; header version
9
   dd     0x01                    ; header version
15
    dd     START                   ; start of code
10
   dd     START                   ; start of code
16
    dd     IM_END                  ; size of image
11
   dd     IM_END                  ; size of image
17
    dd     I_END                   ; memory for app
12
   dd     I_END                   ; memory for app
18
    dd     I_END                   ; esp
13
   dd     I_END                   ; esp stack position
-
 
14
   dd     0x0 , 0x0               ; I_Param , I_Icon
Line -... Line 15...
-
 
15
;**********************************************************************
-
 
16
 
-
 
17
include 'lang.inc'    ; for SVN 'lang.inc'
-
 
18
include '../../../macros.inc'  ; for SVN '..\..\..\macros.inc;'
-
 
19
include 'ascl.inc'         ; main
-
 
20
include 'ascgl.inc'        ; graphics
-
 
21
include 'ascpoal.inc'      ; processing object array
-
 
22
include 'ascgml.inc'       ; game library for collision detection
-
 
23
 
-
 
24
; debug flags
-
 
25
keyboard_debug=0     ; Set to 1 to view all keyboard keys state in game
-
 
26
light_space=0        ; May used for check canvas position in window
-
 
27
debug_scenario=0     ; May used for fast test of gameplay
-
 
28
stack_leak_debug=0   ; Show stack size on screen
-
 
29
debug_mode=1         ; Support keys:
-
 
30
; A - set player hp = 10000. Make player ship undestructible
-
 
31
; E - player hp / 2
-
 
32
; W - view final screen after game begin
-
 
33
 
-
 
34
screen_w equ 640
-
 
35
screen_h equ 440
-
 
36
;screen_w equ 1014
-
 
37
;screen_h equ 739
-
 
38
 
-
 
39
; Define special colors
-
 
40
cl_DarkRed equ 0x990000
-
 
41
cl_Orange  equ 0xbbbb00
-
 
42
 
-
 
43
; Define objects type id
-
 
44
EmptyObject  equ 0
-
 
45
; This numbers not possible for modify because draw_objects:
-
 
46
BlueWarShip  equ 1
-
 
47
GreenWarShip equ 2
-
 
48
Asteroid     equ 3
-
 
49
Box          equ 4
-
 
50
 
-
 
51
Laser        equ 1
-
 
52
Plasma       equ 2
-
 
53
StaticPlasma equ 3
-
 
54
 
19
    dd     0x0 , 0x0               ; I_Param , I_Icon
55
;**************************************************************
Line -... Line 56...
-
 
56
;                      Start of programm
Line 20... Line -...
20
 
-
 
21
;******************************************************************************
-
 
22
 
57
;**************************************************************
23
 
58
 
24
include 'lang.inc'
-
 
Line -... Line 59...
-
 
59
START:                          ; start of execution
-
 
60
 
Line 25... Line -...
25
include '../../../macros.inc'
-
 
26
include 'ascl.inc'
-
 
27
include 'ascgl.inc'
-
 
28
include 'ascml.inc'
-
 
29
 
-
 
30
 
61
   max_particles = 400
31
showmas:
-
 
32
    cmp [edi+8],dword 0
-
 
33
    je  noshow
-
 
34
    cmp [edi+8],dword 1
-
 
35
    jne no_gun
-
 
36
    mov eax,shoot
-
 
37
    jmp outp
-
 
38
no_gun:
-
 
39
    push edi
-
 
40
    random 3,ebx
-
 
41
    pop edi
-
 
42
    cmp ebx,0
62
   particle_size = 20
43
    jne no_star
-
 
44
    mov eax,star
-
 
45
    jmp outp
-
 
46
no_star:
-
 
47
    cmp ebx,1
-
 
48
    jne no_star2
-
 
49
    mov eax,star2
-
 
50
    jmp outp
-
 
Line 51... Line -...
51
no_star2:
-
 
52
    mov eax,star3
-
 
53
outp:
-
 
54
    aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
63
 
55
noshow:
-
 
56
    ret
64
   mov [particles],dword max_particles
57
 
-
 
58
showobjmas:
-
 
59
    cmp [edi+8],dword 0
-
 
60
    je  noshow1
-
 
61
    cmp [edi+4],dword 380
-
 
62
    jg  noshow1
-
 
63
    cmp [edi+4],dword 0
-
 
64
    jl  noshow1
-
 
65
    cmp [edi+8],dword 1
-
 
66
    jne no_warship1
-
 
67
    mov eax,warship1
-
 
68
    jmp outws
-
 
69
no_warship1:
-
 
70
    cmp [edi+8],dword 2
-
 
71
    jne no_warship2
-
 
72
    mov eax,warship2
-
 
73
    jmp outws
-
 
74
no_warship2:
-
 
75
    cmp [edi+8],dword 3
-
 
76
    jne no_meteor
-
 
77
    mov eax,meteor
-
 
78
    jmp outws
-
 
79
no_meteor:
-
 
80
    cmp [edi+8],dword 4
-
 
81
    jne no_box
-
 
Line -... Line 65...
-
 
65
   mov [particles+4],dword particle_size
Line 82... Line -...
82
    mov eax,box
-
 
83
    jmp outws
66
 
84
no_box:
-
 
85
outws:
67
   max_objects = 100
86
    aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
-
 
87
noshow1:
-
 
88
    ret
-
 
Line 89... Line 68...
89
 
68
   object_size = 20
90
 
69
 
91
moveobjmas:
70
   mov [objects],dword max_objects
92
    cmp [edi+8],dword 0
71
   mov [objects+4],dword object_size
93
    je  no_ws
72
 
94
    mov eax,[edi+12]
73
   keyboard_set_input_mode 1  ; 0 - ASCII; 1 - scancodes;
95
    add [edi],eax
74
 
96
    mov eax,[edi+16]
75
   ;giftoimg gif_file_area2,canvas
97
    add [edi+4],eax
76
   giftoimg gif_file_area,objects_image
98
 
77
 
99
    cmp dword [edi],600
78
   ; load sprites
100
    jng xok1
79
   mov cl,9      ; cl - counter
-
 
80
   xor esi,esi   ; esi = 0
101
    sub dword [edi],20
81
   lea edi,[ship_img]  ; address of first sprite
-
 
82
load_sprite:
102
    neg dword [edi+12]
83
   pushad
103
    jmp xok2
84
   getimg objects_image,esi,0,32,32,edi
104
xok1:
85
   popad
105
    cmp dword [edi],0
86
   add edi,8+32*32*3   ; incrase offest of image data
106
    jnl xok2
87
   add esi,32          ; incrase x position
107
    add dword [edi],20
88
   dec cl
108
    neg dword [edi+12]
89
   jnz load_sprite
109
xok2:
90
 
110
    cmp dword [edi+4],400
91
set_main_menu:
-
 
92
   mov ebx,-1       ; at start event_mode = -1
111
    jng yok
93
   lea ecx,[draw_main_window]
112
    mov dword [edi+8],0
94
   lea edx,[menu_keyboard]
-
 
95
set_draw_proc:
113
    ret
96
   ; assembler extract command ; for use only bl
114
yok:
97
   mov [event_mode],ebx
115
    cmp dword [edi+8],2  ;green ship
98
   mov [draw_proc],ecx
116
    jne no_grs
99
   mov [keyboard_proc],edx
117
    cmp dword [edi+4],100
100
   ; at first draw window
118
    jna no_grs
101
main_menu:
119
    cmp dword [edi+4],103
102
redraw_event:     ; redraw event appears if user move, show/hide window
120
    jna grs
103
   call draw_window
121
    cmp dword [edi+4],200
104
no_event:
122
    jna no_grs
105
   call [draw_proc]  ; no event no requre draw_window for no flickering
123
    cmp dword [edi+4],203
106
if stack_leak_debug = 1
124
    jna  grs
107
   ; stack memory leak debug
125
    cmp dword [edi+4],300
108
   lea ebp,[I_END]
-
 
109
   sub ebp,esp
126
    jna no_grs
110
   outcount ebp,10,30,cl_Green,5*65536
127
    cmp dword [edi+4],303
111
end if
128
    ja  no_grs
112
menu_loop:
129
grs:
113
   ;wait_event redraw_event,keyboard_event,button_event
130
    neg dword [edi+12]
114
   mov eax,10   ; wait event
131
    mov [temp],edi
115
   mov ebx,[event_mode]
132
    findmas massive,findzero
116
   cmp ebx,-1   ; ebx delay for mcall 23
133
;in edi off to free element
117
   je wait_ev
134
    jc  close_app
118
   mov eax,23   ; time event
135
    mov esi,edi
119
wait_ev:
136
    mov edi,[temp]
120
   mcall
137
    mov eax,[edi]
121
   dec eax
138
    mov [esi],eax
122
   js  no_event
139
    mov eax,[edi+4]
123
   jz  redraw_event
140
    mov [esi+4],eax
124
   dec eax
141
    mov [esi+8],dword 1
-
 
142
    mov [esi+12],dword 0
125
   jz  keyboard_event
143
    mov [esi+16],dword 10
126
   dec eax
144
no_grs:
127
   jz  button_event
145
 
128
   jmp menu_loop  ; if unknown event, skip it
146
    cmp dword [edi+8],1  ;blue ship
129
 
147
    jne no_bls
130
keyboard_event:   ; keyboard event if user press button
148
    cmp dword [edi+4],50
131
   call [keyboard_proc]
149
    jna no_bls
-
 
150
    cmp dword [edi+4],64
-
 
151
    jna bls
132
   jmp  menu_loop
152
    cmp dword [edi+4],100
133
button_event:
153
    jna no_bls
134
   window_get_button
154
    cmp dword [edi+4],114
135
   cmp ah,1       ; if button id=1 (Red X of window) then close app
155
    jna bls
136
   je  close_app
156
    cmp dword [edi+4],150
137
   cmp ah,2       ; if button id=2 then close app
157
    jna no_bls
138
   je  close_app
158
    cmp dword [edi+4],164
139
   cmp ah,3       ; if button id=3 then start game
159
    ja  no_bls
-
 
160
bls:
-
 
161
    mov [temp],edi
140
   je  start_game
162
    findmas massive,findzero
141
   cmp ah,4       ; if button id=3 then show help menu
163
    jc  close_app
-
 
164
    mov esi,edi
-
 
165
    mov edi,[temp]
-
 
166
    mov eax,[edi]
-
 
Line -... Line 142...
-
 
142
   je  set_help_window  ; jmp with redraw window
-
 
143
   cmp ah,5       ; if button id=5 then back to main menu
-
 
144
   je  set_main_menu    ; jmp with redraw window
Line 167... Line 145...
167
    mov [esi],eax
145
   cmp ah,6
168
    mov eax,[edi+4]
-
 
169
    mov [esi+4],eax
-
 
170
    mov [esi+8],dword 2
-
 
171
    mov [esi+12],dword 0
146
   je  next_level  ; run next level
172
    mov [esi+16],dword 5
-
 
173
no_bls:
-
 
174
 
-
 
175
no_ws:
-
 
176
    ret
147
   cmp ah,7
177
 
-
 
178
 
-
 
179
delfarshoot:
-
 
180
    cmp [edi+4],dword 40
148
   je  restart_lev ; restart level from gameover
Line -... Line 149...
-
 
149
   cmp ah,9
-
 
150
   je  set_game_window  ; back to game from menu
-
 
151
   jmp menu_loop
Line 181... Line 152...
181
    jb  del
152
 
182
    cmp [edi+4],dword 400
153
close_app:
-
 
154
   mov  eax,-1          ; close this program
-
 
155
   mcall
183
    ja  del
156
 
184
    cmp [edi],dword 40
157
menu_keyboard:
185
    jb  del
-
 
186
    cmp [edi],dword 600
-
 
187
    ja  del
-
 
188
    jmp nodel
-
 
189
del:
-
 
190
    mov [edi+8],dword 0
-
 
191
nodel:
-
 
Line -... Line 158...
-
 
158
   ; nothing do
-
 
159
   window_get_key
-
 
160
   ret
Line 192... Line 161...
192
    ret
161
 
-
 
162
;***********************
193
 
163
;   Main screen menu
194
 
164
;***********************
195
movemas:
165
 
196
    cmp [edi+8],dword 0
166
draw_main_window:
197
    jne no_freeel
167
   draw_label 160,160,'Phoenix',cl_Red+font_size_x8
-
 
168
   draw_button 3,300,320,60,14,'START',cl_DarkRed,cl_Yellow
198
    ret
169
   draw_button 4,300,340,60,14,'HELP',cl_DarkRed,cl_Yellow
-
 
170
   draw_button 2,300,360,60,14,'EXIT',cl_DarkRed,cl_Yellow
-
 
171
   ret
-
 
172
 
-
 
173
;**********************
-
 
174
;  End level process
Line -... Line 175...
-
 
175
;**********************
-
 
176
 
Line -... Line 177...
-
 
177
set_end_level_window_from_call:
-
 
178
   add esp,4    ; remove call address from stack
Line 199... Line -...
199
no_freeel:
-
 
200
    mov eax,[edi+12]
179
set_end_level_window:
201
    add [edi],eax
-
 
202
    mov eax,[edi+16]
-
 
203
    add [edi+4],eax
-
 
204
    ret
-
 
205
 
-
 
206
 
-
 
207
 
180
   lea edx,[menu_keyboard]
208
endshowmas:
181
   mov ebx,-1
Line -... Line 182...
-
 
182
   lea ecx,[draw_end_level_window]
-
 
183
   jmp set_draw_proc
-
 
184
 
Line 209... Line 185...
209
    cmp [edi+8],dword 0
185
draw_end_level_window:
210
    je  noshowem
186
   draw_frect 170,130,300,190,cl_Grey
-
 
187
   draw_label 280,150,'LEVEL COMPLETE',cl_Black
211
    mov eax,star2
188
   draw_button 2,180,300,80,14,'EXIT',cl_DarkRed,cl_Black
212
    aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
189
   draw_button 5,280,300,80,14,'',cl_DarkRed,cl_Black
-
 
190
   draw_button 6,380,300,80,14,'NEXT >',cl_DarkRed,cl_Black
-
 
191
 
-
 
192
   draw_image 180,170,bwarship_img
-
 
193
   draw_number [bships_destroyed],240,185,cl_Blue,3*65536
213
noshowem:
194
 
-
 
195
   draw_image 180,210,gwarship_img
-
 
196
   draw_number [gships_destroyed],240,225,cl_Green,3*65536
214
    ret
197
 
-
 
198
   draw_image 180,250,box_img
-
 
199
   draw_number [boxes_taken],240,265,cl_Orange,3*65536
215
 
200
   ret
-
 
201
 
-
 
202
;**********************
-
 
203
;  Game Over process
-
 
204
;**********************
-
 
205
 
-
 
206
restart_lev:
-
 
207
   mov [next_wave_timer],0  ; Reset new wave timer
-
 
208
prevpart:
-
 
209
   call get_wave_info_offset
216
 
210
   xor eax,eax
Line 217... Line -...
217
 
-
 
218
endmovemas:
211
   mov ax,[ebp]
219
    cmp [edi+8],dword 0
212
   dec eax                  ; If eax = 0 then start of level finded
220
    jne no_fr
-
 
221
    ret
-
 
222
no_fr:
213
   jz  reset_all_varibles_and_restart_level
223
    mov eax,[edi+12]
-
 
Line 224... Line 214...
224
    add [edi],eax
214
   dec [level_wave]
225
    mov eax,[edi+16]
215
   jmp prevpart
226
    add [edi+4],eax
-
 
227
    ret
216
 
228
 
217
set_game_over_window_from_call:
229
 
-
 
230
findzero:
218
   add esp,4
231
    cmp [edi+8],dword 0
219
set_game_over_window:
Line 232... Line -...
232
    je  iz_zero
-
 
233
    xor eax,eax
220
   lea edx,[menu_keyboard]
234
    ret
-
 
235
iz_zero:
221
   mov ebx,-1
236
    mov eax,1
-
 
Line 237... Line 222...
237
    ret
222
   lea ecx,[draw_game_over_window]
238
 
-
 
239
compobr:
-
 
240
    cmp [esi+8],dword 0
-
 
241
    je  no_crsh
223
   jmp set_draw_proc
242
    cmp [edi+8],dword 0
-
 
243
    je  no_crsh
-
 
244
    cmp [esi+16],dword 0
-
 
245
    jg  no_crsh
224
 
246
 
-
 
247
    mov eax,[esi]
-
 
248
    mov [temp],eax
-
 
249
    mov eax,[esi+4]
225
draw_game_over_window:
250
    mov [temp2],eax
-
 
251
    mov eax,[edi]
-
 
252
    mov [temp3],eax
226
   draw_frect 170,160,300,120,cl_Grey
253
    mov eax,[edi+4]
227
   draw_label 292,200,'GAME OVER',cl_Black
254
    mov [temp4],eax
228
   draw_button 2,180,260,80,14,'EXIT',cl_DarkRed,cl_Black
255
 
-
 
256
    pushad
229
   draw_button 5,280,260,80,14,'MENU',cl_DarkRed,cl_Black
257
    collimg imgsize,[temp],[temp2],imgsize,[temp3],[temp4],[otv]
230
   draw_button 7,380,260,80,14,'RESTART',cl_DarkRed,cl_Black
258
    popad
-
 
Line 259... Line -...
259
    cmp [otv],dword 0
-
 
260
    je  no_crsh
231
   ret
261
 
232
 
262
    cmp [edi+8],dword 2
-
 
263
    jne no_grship
-
 
Line 264... Line -...
264
    inc [gship]
-
 
265
    add [score],30
-
 
266
    jmp setzero
-
 
267
no_grship:
-
 
268
    cmp [edi+8],dword 1
-
 
269
    jne no_blship
233
;***********************
270
    inc [bship]
234
;    Main game loop
271
    add [score],20
-
 
272
    jmp setzero
235
;***********************
273
no_blship:
-
 
274
    cmp [edi+8],dword 3
-
 
275
    jne no_metr
-
 
276
    dec dword [edi+16]
236
 
277
    cmp dword [edi+16],0
-
 
278
    jne mok
-
 
279
    mov dword [edi+16],1
-
 
280
mok:
237
next_level:
281
    mov [esi+8],dword 0
-
 
282
    ret
-
 
283
no_metr:
-
 
284
 
-
 
285
setzero:
238
   mov [next_wave_timer],0 ; Reset next wave timer
286
    mov [esi+8],dword 0
-
 
287
    mov [edi+8],dword 0
-
 
Line 288... Line 239...
288
no_crsh:
239
   inc [level_wave]        ; Next wave
289
    ret
240
start_game:
290
 
241
   ; Set canvas size before logo is showed
291
shipobjtest:
242
   image_set_size canvas,screen_w,screen_h
292
    cmp [edi+8],dword 0
243
 
293
    je  no_obj
244
; Clear all, and prepeare varibles before start
294
    mov eax,[edi]
245
reset_all_varibles_and_restart_level:
-
 
246
 
295
    mov [temp3],eax
247
   ; Clear objects arrays
296
    mov eax,[edi+4]
248
   mov eax,0
297
    mov [temp4],eax
249
   cld
298
    pushad
250
   mov edi,particles+8
299
    collimg imgsize,[shipx],[shipy],imgsize,[temp3],[temp4],[otv]
-
 
300
    popad
251
   mov ecx,max_particles*particle_size/4
-
 
252
   rep stosd
301
    cmp [otv],dword 0
253
   mov edi,objects+8
302
    je  no_obj
254
   mov ecx,max_objects*object_size/4
-
 
255
   rep stosd
-
 
256
 
303
    cmp [edi+8],dword 4  ;if box
257
   ; Reset keyboard state array
304
    jne no_fbox
258
   clear_buffer keymap, 128, 0
305
    add [energy],5
259
 
-
 
260
   ; Reset player ship state
Line -... Line 261...
-
 
261
   mov [player_hp],100
-
 
262
   mov [shipx],screen_w/2-16 ; Player ship x start position
Line -... Line 263...
-
 
263
   mov [shipy],screen_h-40   ; Player ship y start position
-
 
264
   mov [laser_shoots],1000   ; Laser projectiles at start
-
 
265
   mov [plasma_shoots],500   ; Plasma projectiles at start
-
 
266
 
-
 
267
   ; Reset counters and gun charge values
-
 
268
   xor eax,eax
-
 
269
   mov [boxes_taken],eax
-
 
270
   mov [gships_destroyed],eax
-
 
271
   mov [bships_destroyed],eax
-
 
272
   mov [laser_charge],eax
-
 
273
   mov [plasma_charge],eax
-
 
274
 
-
 
275
set_game_window:
306
    add [score],50
276
   lea edx,[ingame_keyboard]
-
 
277
   lea ecx,[draw_game_window]
-
 
278
   mov ebx,2          ; time_event ebx = 2 ms
-
 
279
   jmp set_draw_proc
-
 
280
 
-
 
281
draw_game_window:
-
 
282
   draw_image 5,24,canvas
-
 
283
 
-
 
284
   xor eax,eax               ; Use eax as zero for compare
-
 
285
   cmp [pause_on],eax        ; If pause = 0 nothing do
-
 
286
   je no_pause
-
 
287
   ret
-
 
288
no_pause:
-
 
289
 
-
 
290
   cmp [player_hp],eax       ; If player_hp < 0 game over
-
 
291
   jl  set_game_over_window_from_call
-
 
292
 
-
 
293
   cmp [laser_charge],eax
-
 
294
   je  no_dec_laser_charge
-
 
295
   dec dword [laser_charge]  ; If laser_charge > 0 decrase it
-
 
296
no_dec_laser_charge:
-
 
297
   cmp [plasma_charge],eax
-
 
298
   je  no_dec_plasma_charge
-
 
299
   dec dword [plasma_charge] ; If plasma_charge > 0 decrase it
307
    mov [edi+8],dword 0
300
no_dec_plasma_charge:
-
 
301
 
-
 
302
   ; new wave test
308
    inc [boxget]
303
   inc dword [next_wave_timer]
-
 
304
   call get_wave_info_offset
-
 
305
   mov ax,[ebp]        ; [ebp] = time to activate string
-
 
306
   cwde                ; extend ax to eax
-
 
307
   cmp [next_wave_timer],eax
-
 
308
   jne no_next_wave
-
 
309
 
-
 
310
add_new_wave_of_objects:
-
 
311
   mov cl,[ebp+4+0]    ; cl = count of ships
-
 
312
   mov ch,GreenWarShip ; ch = type of object
-
 
313
   mov ebx,0x09040302  ; ebx = [xmoving]:[xaccel]:[ymoving]:[yaccel]
-
 
314
   call add_objects    ; add objects
-
 
315
 
-
 
316
   mov cl,[ebp+4+1]    ; cl = count of ships
-
 
317
   mov ch,BlueWarShip  ; ch = type of object
-
 
318
   mov ebx,0x03010306  ; ebx = random ranges : x = -1..1 y = -6..-4
-
 
319
   call add_objects    ; add objects
309
    ret
320
 
-
 
321
   mov cl,[ebp+4+2]    ; cl = count of asteroids
-
 
322
   mov ch,Asteroid     ; ch = type of object
Line 310... Line -...
310
no_fbox:
-
 
311
    sub [energy],16
323
   mov ebx,0x05020502  ; ebx = [xmoving]:[xaccel]:[ymoving]:[yaccel]
Line -... Line 324...
-
 
324
   call add_objects    ; add objects
-
 
325
 
-
 
326
   mov cl,[ebp+4+3]    ; cl = count of boxes
-
 
327
   mov ch,Box          ; ch = type of object
-
 
328
   mov ebx,0x05020401  ; ebx = [xmoving]:[xaccel]:[ymoving]:[yaccel]
-
 
329
   call add_objects    ; add objects
-
 
330
 
-
 
331
   mov [next_wave_timer],0 ; Reset next wave timer
312
    mov [edi+8],dword 0
332
   inc [level_wave]        ; Next wave
-
 
333
no_next_wave:
-
 
334
 
-
 
335
   ; Calculate all active objects on screen
-
 
336
   xor eax,eax           ; Use eax as zero
-
 
337
   mov [objects_num],eax
-
 
338
   array_processing objects,endtest ; ar_proc not modify eax, ebx
-
 
339
   xor eax,eax           ; Use eax as zero
-
 
340
   cmp [objects_num],eax ; If [objects_num] != 0, level is not complete
-
 
341
   jnz level_not_complete
313
no_obj:
342
 
-
 
343
   call get_wave_info_offset
-
 
344
   mov ax,[ebp+2]  ; ax = maxyrange
-
 
345
   cwde            ; extend ax to eax
-
 
346
   xor ebx,ebx     ; Use ebx as zero for compare
-
 
347
   cmp eax,ebx     ; If [ebp+2] of level = 0, this is end of level
Line -... Line 348...
-
 
348
   je  set_end_level_window_from_call  ; Show player score
-
 
349
   dec ebx         ; Use ebx as -1 for compare
-
 
350
   cmp eax,ebx
-
 
351
   je  set_final_screen_window_from_call ; Show final animation
-
 
352
level_not_complete:
314
    ret
353
 
-
 
354
no_end_lev:
315
 
355
 
-
 
356
; Key state processing
Line -... Line 357...
-
 
357
   cmp byte [keymap+key_Right],0
-
 
358
   je  no_key_right
-
 
359
   add dword [shipx],6
-
 
360
no_key_right:
-
 
361
   cmp byte [keymap+key_Left],0
-
 
362
   je  no_key_left
-
 
363
   sub dword [shipx],6
-
 
364
no_key_left:
-
 
365
   cmp byte [keymap+key_Space],0
-
 
366
   je  no_key_lshoot
-
 
367
   call try_to_make_laser_shoot
-
 
368
   ;call try_to_make_plasma_shoot
-
 
369
no_key_lshoot:
-
 
370
   cmp byte [keymap+key_Up],0
-
 
371
   je  no_key_pshoot
-
 
372
   ;call try_to_make_plasma_nuke
-
 
373
   call try_to_make_plasma_shoot
-
 
374
no_key_pshoot:
-
 
375
   cmp byte [keymap+key_Down],0
-
 
376
   je  no_key_pnuke
-
 
377
   call try_to_make_plasma_nuke
-
 
378
   ;call try_to_make_laser_shoot
-
 
379
no_key_pnuke:
-
 
380
 
-
 
381
; Ship position correction (clamp macro)
-
 
382
   cmp [shipx],5
-
 
383
   jnl @f
-
 
384
   mov [shipx],5
Line -... Line 385...
-
 
385
@@:
316
shipguntest:
386
   cmp [shipx],screen_w-32-5
317
    cmp [edi+8],dword 0
387
   jng @f
318
    je  no_gobj
388
   mov [shipx],screen_w-32-5
319
    cmp [edi+16],dword 0
389
@@:
-
 
390
 
Line -... Line 391...
-
 
391
   mov al,7
-
 
392
if light_space = 1
-
 
393
   mov al,255
-
 
394
end if
-
 
395
   clear_buffer canvas+8,canvas_end-canvas-8,al
-
 
396
 
-
 
397
   compmas objects,particles,objects_and_particles_hit_handling
-
 
398
   ; move objects and particles
-
 
399
   array_processing objects,move_objects
-
 
400
   array_processing particles,move_particles
-
 
401
   ; remove particles out of screen
-
 
402
   array_processing particles,remove_outofscr_particles
320
    jl  no_gobj
403
   ; objects and particles collision test
-
 
404
   array_processing objects,player_and_objects_collision_handling
-
 
405
   array_processing particles,player_and_particles_collision_handling
-
 
406
   ; draw objects and particles
-
 
407
   array_processing objects,draw_objects
-
 
408
   array_processing particles,draw_particles
-
 
409
   ; draw player ship
-
 
410
   image_draw_acimage canvas,ship_img,[shipx],[shipy],cl_Black
-
 
411
 
-
 
412
   ; Draw info indicators
-
 
413
   draw_frect 150,5,64,5,cl_Black
321
    mov eax,[edi]
414
   mov eax,[plasma_charge]
322
    mov [temp3],eax
415
   sub eax,256
323
    mov eax,[edi+4]
416
   neg eax
-
 
417
   shr eax,2
-
 
418
   draw_frect 150,5,eax,5,cl_Cyan
-
 
419
 
324
    mov [temp4],eax
420
   draw_frect 150,12,64,5,cl_Black
-
 
421
   mov eax,[laser_charge]
-
 
422
   sub eax,8
Line -... Line 423...
-
 
423
   neg eax
-
 
424
   shl eax,3
325
    pushad
425
   draw_frect 150,12,eax,5,cl_Yellow
326
    collimg imgsize,[shipx],[shipy],imgsize,[temp3],[temp4],[otv]
426
 
327
    popad
427
   draw_frect 220,2,6*5+2 ,9,cl_Grey
-
 
428
   draw_number [plasma_shoots],221,3,cl_Cyan,5*65536
-
 
429
   draw_frect 220,11,6*5+2 ,9,cl_Grey
-
 
430
   draw_number [laser_shoots],221,12,cl_Yellow,5*65536
-
 
431
 
328
    cmp [otv],dword 0
432
   draw_frect 280,6,6*5+2 ,9,cl_Grey
329
    je  no_gobj
433
   draw_number [gships_destroyed],281,7,cl_Green,5*65536
330
    sub [energy],4
434
   draw_frect 320,6,6*5+2 ,9,cl_Grey
331
    mov [edi+8],dword 0
435
   draw_number [bships_destroyed],321,7,cl_Blue,5*65536
-
 
436
   draw_frect 360,6,6*5+2 ,9,cl_Grey
332
no_gobj:
437
   draw_number [boxes_taken],361,7,0xffaa00,5*65536
-
 
438
 
-
 
439
   ; number of objects in scene
333
    ret
440
   draw_frect 400,2,6*5+2 ,9,cl_Grey
334
 
441
   draw_number [objects_num],401,2,cl_Lime,5*65536
335
 
442
 
336
START:                          ; start of execution
443
   draw_frect 400,11,6*5+2 ,9,cl_Grey
337
 
444
   draw_number [player_hp],401,12,cl_Red,5*65536
-
 
445
 
Line -... Line 446...
-
 
446
   draw_frect 450,11,6*5+2 ,9,cl_Grey
-
 
447
   draw_number [score],451,12,cl_Yellow,5*65536 ;+hide_zeros
-
 
448
 
-
 
449
   ; print keyboard keys state as string for debug
-
 
450
if keyboard_debug = 1
-
 
451
   mov ebx,10*65536+40
-
 
452
   mov edx,keymap
-
 
453
   mov esi,128
-
 
454
   mov ecx,cl_White
-
 
455
   mov eax,4
-
 
456
   mcall
-
 
457
end if
-
 
458
   ret
-
 
459
 
-
 
460
; Proc for calculate active objects on screen
-
 
461
; eax - empty object type = 0
-
 
462
endtest:
-
 
463
   xor eax,eax
-
 
464
   cmp dword [edi+8],eax  ; object is empty ?
-
 
465
   je  is_free
-
 
466
   inc [objects_num]
-
 
467
is_free:
-
 
468
   ret
-
 
469
 
-
 
470
; Proc for get offest to current level wave information
-
 
471
get_wave_info_offset:
-
 
472
   mov ebp,[level_wave]
-
 
473
   shl ebp,3           ; ebp = ebp*8; 8 - lenght of one string in levels array
-
 
474
   add ebp,levels      ; ebp = offset to string in levels array
-
 
475
   ret
-
 
476
 
-
 
477
; time_bwns - time before next wave start
-
 
478
; yrmax - y random position maximum value
-
 
479
macro objects_wave time_bnws, yrmax, gships, bships, asteroids, boxes{
-
 
480
   dw time_bnws, yrmax
-
 
481
   db gships, bships, asteroids, boxes
-
 
482
}
-
 
483
 
-
 
484
level_wave dd 0
-
 
485
; this array may optimized
-
 
486
levels:
-
 
487
; for game not ended at start, each level must have objects set at start (1)
-
 
488
   ; test pattern
-
 
489
if debug_scenario = 1
-
 
490
   ; two levels for debug game
-
 
491
   objects_wave   1,   10,  1,  2,  4,  8   ; objset at start
-
 
492
   objects_wave   0,    0,  0,  0,  0,  0
Line -... Line 493...
-
 
493
   objects_wave   1,   10,  3,  3,  3,  3   ; objset at start
-
 
494
   objects_wave   0,   -1,  0,  0,  0,  0
-
 
495
else
-
 
496
   ; level 1
Line -... Line 497...
-
 
497
   objects_wave   1, 4000,  3, 10, 10,  0    ; objset at start
-
 
498
   objects_wave 800, 2000,  5,  3,  5,  3
-
 
499
   objects_wave 400, 2000,  3,  7,  5,  3
-
 
500
   objects_wave 400,  800,  3,  5,  3,  0
338
massize = 400
501
   objects_wave   0,    0,  0,  0,  0,  0    ; end of level
-
 
502
   ; level 2
-
 
503
   objects_wave   1, 4000, 10, 40,  0,  8    ; objset at start
-
 
504
   objects_wave 400, 4000, 10, 10, 20,  6
-
 
505
   objects_wave 400, 2000,  0, 20, 10,  2
-
 
506
   objects_wave 400,  400, 10, 10, 20,  0
-
 
507
   objects_wave   0,    0,  0,  0,  0,  0    ; end of game
-
 
508
   ; level 3
-
 
509
   objects_wave   1,  800,  0,  0,  5,  5   ; objset at start
-
 
510
   objects_wave 500, 2000,  4, 20, 30,  0
-
 
511
   objects_wave 500, 2000,  4, 20,  0,  8
339
elemsize = 20
512
   objects_wave 500, 2000, 10,  0,  0,  4
-
 
513
   objects_wave 500, 4000,  0, 30,  0,  0
-
 
514
   objects_wave 400,  400,  3,  5, 15,  0
-
 
515
   objects_wave 400,  400,  0,  0, 10,  0
-
 
516
   objects_wave   0,   -1,  0,  0,  0,  0    ; end of level
-
 
517
end if
-
 
518
 
-
 
519
;***********************************
-
 
520
;         In game keyboard
Line 340... Line -...
340
 
-
 
341
    mov [massive],dword massize
-
 
342
    mov [massive+4],dword elemsize
-
 
343
 
-
 
344
omassize = 100
521
;***********************************
345
oelemsize = 20
-
 
346
 
-
 
347
    mov [objmas],dword omassize
-
 
348
    mov [objmas+4],dword oelemsize
-
 
349
 
-
 
350
 
-
 
351
    mov eax,66
-
 
352
    mov ebx,1
-
 
353
    mov ecx,1
-
 
354
    mcall
522
 
355
 
-
 
356
    mov eax,26
523
ingame_keyboard:
357
    mov ebx,2
-
 
358
    mov ecx,1
-
 
359
    mov edx,keymap
-
 
360
    mcall
-
 
361
 
-
 
Line -... Line 524...
-
 
524
   window_get_key  ; read key (eax=2)
-
 
525
   cmp al,0
362
startgame:
526
   jne this_is_hotkey
-
 
527
   ; ah - contain scan code, al = 0
-
 
528
   shl eax,16
-
 
529
   shr eax,24      ; equal shr eax,8 + and eax,0x0FF
363
    giftoimg gif_file_area2,canvas
530
   ; eax - contain scan code
-
 
531
 
-
 
532
   cmp al,key_P+128
-
 
533
   jne not_P_key_up_scan_code
-
 
534
   not [pause_on]
-
 
535
not_P_key_up_scan_code:
-
 
536
 
-
 
537
if debug_mode = 1
364
    giftoimg gif_file_area,img_area
538
   cmp al,key_E    ; player hp = player hp / 2
-
 
539
   jne no_hp_test
-
 
540
   shr [player_hp],1
-
 
541
no_hp_test:
-
 
542
   cmp al,key_A    ; player hp = 10000
-
 
543
   jne no_hp_up
-
 
544
   mov [player_hp],10000
-
 
545
no_hp_up:
365
 
546
   cmp al,key_W    ; Run final screen
-
 
547
   je  set_final_screen_window_from_call
-
 
548
end if
-
 
549
 
-
 
550
   ; Keyboard array update, needs sub state
-
 
551
   cmp al,01111111b
-
 
552
   ja  key_released
-
 
553
   mov byte [keymap+eax],'1'  ; If scan code of key down
-
 
554
   jmp key_pressed
-
 
555
key_released:
366
    getimg img_area,0,0,32,32,ship
556
   and al,01111111b
-
 
557
   mov byte [keymap+eax],0    ; If scan code of key up
367
    getimg img_area,32,0,32,32,shoot
558
key_pressed:
-
 
559
this_is_hotkey:
-
 
560
   ret
-
 
561
 
-
 
562
;**********************
-
 
563
; Final screen process
-
 
564
;**********************
-
 
565
 
368
    getimg img_area,64,0,32,32,warship1
566
set_final_screen_window_from_call:
369
    getimg img_area,96,0,32,32,warship2
567
   add esp,4    ; Remove call address from stack
-
 
568
set_final_screen_window:
370
    getimg img_area,128,0,32,32,meteor
569
   lea edx,[menu_keyboard]
-
 
570
   mov ebx,1
-
 
571
   lea ecx,[draw_final_screen_window]
-
 
572
   jmp set_draw_proc
-
 
573
 
371
    getimg img_area,160,0,32,32,star
574
you_won_text: db 'YOU WON!',0
372
    getimg img_area,192,0,32,32,star2
575
 
-
 
576
draw_final_screen_window:
-
 
577
   draw_image 5,24,canvas
-
 
578
   logo_font_size equ 5
373
    getimg img_area,224,0,32,32,star3
579
   logo_x = 5+(screen_w/2)-(6*logo_font_size*8/2)
Line 374... Line 580...
374
    getimg img_area,0,32,32,32,box
580
   logo_y = screen_h/16*5
375
 
581
   draw_label logo_x,logo_y,you_won_text,cl_White+((logo_font_size-1) shl 24)
376
 
582
   ;image_draw_label canvas,200,8,'YOU WON!',cl_White
Line 377... Line 583...
377
 
583
   draw_button 5,(screen_w/2)-40+5,300,80,14,'BACK TO MENU',cl_DarkRed,cl_Black
-
 
584
 
-
 
585
   clear_buffer canvas+8,canvas_end-canvas-8,7
378
main_menu:
586
 
-
 
587
   image_draw_acimage canvas,ship_img,(screen_w/2)-16,220,cl_Black
-
 
588
   array_processing particles,draw_particles
-
 
589
   array_processing particles,move_particles    ; move particles
-
 
590
   array_processing particles,remove_outofscr_particles     ; del_outscreen_particles
-
 
591
 
-
 
592
try_to_make_firework:
Line 379... Line -...
379
    call draw_logowindow
-
 
380
 
-
 
381
stillm:
-
 
382
    wtevent redm,keym,buttonm
-
 
383
    jmp stillm
-
 
384
redm:
-
 
385
    call draw_logowindow
-
 
386
    jmp stillm
-
 
387
keym:
-
 
388
    mov  eax,2
593
   inc [next_wave_timer]
389
    mcall
-
 
390
    jmp  stillm
594
   cmp [next_wave_timer],30
391
buttonm:
-
 
392
    mov  eax,17                 ; get id
-
 
393
    mcall
-
 
394
    cmp  ah,1                   ; button id=1 ?
-
 
395
    je   close_app
-
 
396
    cmp  ah,2                   ; button id=1 ?
-
 
397
    je   start_game
-
 
398
    cmp  ah,3                   ; button id=1 ?
-
 
399
    je   help
-
 
400
    cmp  ah,4                   ; button id=1 ?
-
 
401
    je   close_app
-
 
402
    jmp  stillm
-
 
403
 
-
 
404
draw_logowindow:
-
 
405
    call draw_window
-
 
406
    mcall 9,proc_info,-1
-
 
407
    test [proc_info+process_information.wnd_state], 0x04
-
 
408
    jz   @f
-
 
409
    ret
-
 
410
  @@:
-
 
411
    setimg 5,21,canvas
-
 
412
    drawlbut 300,300,60,14,'START',2,0x990000,cl_Black
-
 
413
    drawlbut 300,320,60,14,'HELP',3,0x990000,cl_Black
-
 
414
    drawlbut 300,340,60,14,'EXIT',4,0x990000,cl_Black
595
   jna no_firework
415
    ret
596
   mov [next_wave_timer],0   ; reset firework timer before make firework
416
 
597
   random screen_w-60,eax
417
;***********************
598
   mov ebx,eax
418
; Draw help menu
599
   random screen_h-60,eax
419
;***********************
-
 
420
 
600
   mov edx,eax
421
help:
601
   mov ecx,8                 ; how much particles make in one fire explode
-
 
602
next_star:
-
 
603
   array_find particles,find_empty_object
422
    call draw_helpwindow
604
   jc  close_app
423
 
605
   mov [edi],ebx        ; random x position
424
stillh:
606
   mov [edi+4],edx      ; random y position
-
 
607
   mov [edi+8],dword 3  ; type of partice = 3. final screen particle
-
 
608
rerand:
-
 
609
   random 5,eax
425
    wtevent redh,keyh,buttonh
610
   sub eax,2
426
    jmp stillh
611
   jz  rerand         ; eax = -2...2 exclude 0
427
redh:
612
   mov [edi+12],eax   ; x velocity
428
    call draw_helpwindow
613
rerand2:
429
    jmp stillh
614
   random 7,eax
-
 
615
   sub eax,3
430
keyh:
616
   jz  rerand2        ; eax = -3...3 exclude 0
-
 
617
   mov [edi+16],eax   ; y velocity
431
    mov  eax,2
618
   dec ecx
-
 
619
   jnz next_star
432
    mcall
620
no_firework:
433
    jmp  stillh
621
   ret
-
 
622
 
Line 434... Line 623...
434
buttonh:
623
;***********************
-
 
624
;       Help menu
Line -... Line 625...
-
 
625
;***********************
435
    mov  eax,17                 ; get id
626
 
-
 
627
set_help_window:
-
 
628
   lea edx,[menu_keyboard]
Line 436... Line 629...
436
    mcall
629
   mov ebx,-1
437
    cmp  ah,1                   ; button id=1 ?
630
   lea ecx,[draw_help_window]
438
    je   close_app
631
   jmp set_draw_proc
439
    cmp  ah,2                   ; button id=1 ?
-
 
440
    je   start_game
632
 
441
    cmp  ah,3                   ; button id=1 ?
633
draw_help_window:
442
    je   help
634
   ; draw background and gray rectangle for label
443
    cmp  ah,4                   ; button id=1 ?
-
 
444
    je   close_app
635
   ;draw_frect canvas size cl_Black
445
    cmp  ah,5                   ; button id=1 ?
-
 
446
    je   main_menu
-
 
447
    jmp  stillh
-
 
448
 
636
   draw_frect 40,50,580,380,cl_Grey
449
draw_helpwindow:
-
 
450
    call draw_window
-
 
451
    mcall 9,proc_info,-1
637
 
452
    test [proc_info+process_information.wnd_state], 0x04
-
 
453
    jnz  stillh
-
 
454
    setimg 5,21,canvas
638
   ; draw labels
455
 
-
 
456
    drawfbox 40,50,580,380,cl_Grey
-
 
457
 
-
 
458
    mov ebp,4*7
639
   mov ebp,4*7+3  ; Set value to labels counter
459
    mov ebx,180*65536+90
640
   mov ebx,180*65536+90
460
    mov edx,helptext
-
 
461
    mov esi,50
-
 
462
    mov ecx,cl_White
-
 
463
    dec ebp
-
 
464
looht:
-
 
465
    mov eax,4
-
 
466
    mcall
-
 
467
    add edx,esi
-
 
468
    add ebx,10
-
 
469
    dec ebp
-
 
470
    jnz looht
-
 
471
 
-
 
472
    setimg 90,90,ship
641
   mov edx,helptext
473
    setimg 90,130,shoot
-
 
474
    setimg 90,170,star
642
   mov esi,50
475
    setimg 90,210,warship1
-
 
476
    setimg 90,250,warship2
643
   mov ecx,cl_White+(10000000b shl 24)
477
    setimg 90,290,meteor
644
draw_next_string:
478
    setimg 90,330,box
-
 
479
 
645
   mov eax,4
480
    drawlbut 500,400,80,14,'<
-
 
481
 
646
   mcall        ; Draw label
482
    jmp stillh
-
 
483
 
647
@@:
484
helptext:
-
 
485
    db 'Phenix                                            '
648
   mov al,[edx] ; Loop for find next zero
486
    db 'Controls: Num1 move left, Num3 move right         '
649
   inc edx
487
    db '          P-pause (use for screen shooting)       '
650
   cmp al,0
488
    db '                                                  '
651
   jne @b
489
 
-
 
490
    db 'Lazer cannon                                      '
652
 
491
    db 'Press Num5 for shoot                              '
-
 
492
    db 'Core fast, speed fast, reload slow                '
-
 
493
    db '                                                  '
653
   add ebx,10   ; Incrase y position of label
494
 
-
 
495
    db 'Plazma cannon                                     '
654
   dec ebp      ; Decrase labels counter
496
    db 'Press Num2 for Plazma Nuke and Num8 for shoot     '
655
   jnz draw_next_string
497
    db 'Core slow, speed medium, reload fast              '
-
 
498
    db '                                                  '
656
 
499
 
657
   ; draw images of space objects
500
    db 'Blue warship                                      '
658
   mov eax,90
501
    db 'Speed fast                                        '
-
 
502
    db 'Attack method: plazma bomb                        '
659
   mov ecx,7
503
    db '                                                  '
660
@@:
504
 
661
   mov esi,[(img_offset-4)+ecx*4]
505
    db 'Green warship                                     '
662
   pushad
506
    db 'Speed slow                                        '
-
 
Line -... Line 663...
-
 
663
   draw_image 90,eax,esi
-
 
664
   popad
-
 
665
   add eax,40
-
 
666
   dec ecx
-
 
667
   jnz @b
Line 507... Line -...
507
    db 'Attack method: laser shoot                        '
-
 
508
    db '                                                  '
668
 
509
 
-
 
510
    db 'Meteor                                            '
669
   draw_button 5,500,400,80,14,'< BACK',cl_DarkRed,cl_Black
511
    db 'Dangeros object!                                  '
-
 
512
    db 'SuperSheld                                        '
-
 
513
    db '                                                  '
-
 
514
 
-
 
515
    db 'Fly Box                                           '
670
   ret
516
    db 'Sheld pack, sheld +5, score +30                   '
-
 
517
    db 'Get for sheld level up!                           '
671
 
518
    db '                                                  '
-
 
519
 
672
; Offset to images showed in help screen in reverse sequence
520
start_game:
673
img_offset:
521
 
674
dd box_img,asteroid_img,gwarship_img,bwarship_img
522
;    jmp end_gm
-
 
523
 
675
dd plasma1_img,laser_img,ship_img
524
    mov [canvas],dword 640
676
 
525
    mov [canvas+4],dword 440
-
 
526
 
677
helptext:
527
    call draw_window
-
 
528
 
678
   db 'Phoenix - player ship',0
529
;Main loop wait for event with 10msec
-
 
530
still:
-
 
531
;    scevent red,key,button ;for full speed
-
 
532
 
679
   db 'Controls:',0
533
    timeevent 1,no_event,red,key,button
-
 
534
no_event:
680
   db 'Left or Right Arrows for move ship, P - button for pause',0
535
    mcall 9,proc_info,-1
-
 
536
    test [proc_info+process_information.wnd_state], 0x04
681
   db 0
537
    jnz  still
-
 
538
    setimg 5,21,canvas
-
 
539
 
682
   db 'Laser gun',0
540
    cmp [pause_on],0
-
 
541
    jne still
683
   db 'Recharge fast, speed fast. Projectile speed is medium',0
542
 
684
   db 'Press Space button for shoot',0
543
    cmp [energy],0
685
   db 0
544
    jl  game_over
686
   db 'Plasma gun',0
545
 
-
 
546
    cmp [ctime],dword 0
-
 
547
    je  no_dct
-
 
548
    dec dword [ctime]
-
 
549
no_dct:
-
 
550
 
687
   db 'Recharge slow, reload fast. Projectile speed is fast',0
551
    cmp [xtime],dword 0
688
   db 'Press Up button for shoot or Down button for make Nuke',0
552
    je  no_dxt
-
 
553
    dec dword [xtime]
-
 
554
no_dxt:
-
 
555
 
-
 
556
 
-
 
557
;
-
 
558
;   Add to level new ships
-
 
559
;
-
 
560
    inc dword [pathtime]
-
 
561
    mov ebp,[levelpart]
-
 
562
    shl ebp,5
-
 
563
    add ebp,levels
689
   db 0
564
    mov eax,[ebp]
-
 
565
    cmp [pathtime],eax ;500
690
   db 'Blue warship',0
566
    jne no_nextloc
691
   db 'Moving speed is fast',0
567
 
692
   db 'Armed with plasma bombs',0
-
 
693
   db 0
568
randobjmasx:
694
   db 'Green warship',0
569
    mov ebp,[levelpart]
695
   db 'Moving speed is medium',0
570
    shl ebp,5
696
   db 'Armed with laser gun',0
-
 
697
   db 0
571
    add ebp,levels
698
   db 'Asteroid',0
572
 
699
   db 'Is not destructable dangeros object!',0
573
    mov  ecx,[ebp+8]
700
   db 'Collision with asteroid damage ship to much',0
574
    mov  [shiptype],2
-
 
575
    mov  [xmoving],9
701
   db 0
576
    mov  [xaccel],4
-
 
577
    mov  [ymoving],3
702
   db 'Repear Box',0
578
    mov  [yaccel],2
703
   db 'Shield pack. Shield +5, Score +30',0
579
    call add_ships
704
   db 'Take on board for shield level up!',0
580
 
705
   db 0,0,0
581
    mov  ecx,[ebp+12]
-
 
582
    mov  [shiptype],1
-
 
583
    mov  [xmoving],3
706
   db 'Developed by Pavlushin Evgeni 2004',0
584
    mov  [xaccel],1
707
 
585
    mov  [ymoving],3
708
; ****************************************
586
    mov  [yaccel],6
-
 
587
    call add_ships
709
;          GLOBAL DRAW WINDOW
588
 
710
; ****************************************
589
    mov  ecx,[ebp+16]
-
 
590
    mov  [shiptype],3
711
 
591
    mov  [xmoving],5
712
draw_window:
592
    mov  [xaccel],2
-
 
593
    mov  [ymoving],5
713
   window_begin_draw
594
    mov  [yaccel],2
714
   mcall 0, <40, screen_w+9>, <40, screen_h+24+4>, 0x14000000,, wtitle
595
    call add_ships
-
 
596
 
715
   window_end_draw
597
    mov  ecx,[ebp+20]
716
   ret
598
    mov  [shiptype],4
-
 
599
    mov  [xmoving],4
717
 
600
    mov  [xaccel],1
718
; ****************************************
601
    mov  [ymoving],4
719
;           GAME PROCEDURE AREA
602
    mov  [yaccel],1
720
; ****************************************
603
    call add_ships
721
 
604
 
722
; Procedure for add ships to scene
Line -... Line 723...
-
 
723
; cl - number of ships which need to add 0..255
-
 
724
; ebp - offset to level string
-
 
725
add_objects:
-
 
726
   ; unpack values from ebx
-
 
727
   xor eax,eax
-
 
728
   mov al,ch
-
 
729
   mov [shiptype],eax
-
 
730
   mov al,bl
-
 
731
   mov [yaccel],eax
-
 
732
   mov al,bh
-
 
733
   mov [ymoving],eax
-
 
734
   shr ebx,16
-
 
735
   mov al,bl
-
 
736
   mov [xaccel],eax
-
 
737
   mov al,bh
-
 
738
   mov [xmoving],eax
-
 
739
next_ship:
-
 
740
   cmp cl,0
-
 
741
   je  no_ships    ; if ships quantity = 0, exit from proc
-
 
742
   push ecx
-
 
743
   push ebp
-
 
744
   ; find empty slot in space objects array
-
 
745
   array_find objects,find_empty_object
-
 
746
   jc  close_app
-
 
747
   ; edi = offset to empty place in array
-
 
748
   mov eax,[shiptype]
-
 
749
   mov dword [edi+8],eax   ; store ship type
-
 
750
   ; Randomize x position
-
 
751
   random screen_w-32,eax
-
 
752
   mov [edi],eax
-
 
753
   ; Randomize y position
-
 
754
   pop ebp
-
 
755
   mov ax,[ebp+2]  ; get max range
-
 
756
   cwde            ; extend ax to eax
-
 
757
   random eax,eax
-
 
758
   neg eax
-
 
759
   mov [edi+4],eax
-
 
760
   ; Randomize x moving
-
 
761
   random [xmoving],eax
-
 
762
   sub eax,[xaccel]
-
 
763
   mov [edi+12],eax
-
 
764
   ; Randomize y moving
-
 
765
   random [ymoving],eax
-
 
766
   add eax,[yaccel]
-
 
767
   mov [edi+16],eax
-
 
768
   pop ecx
-
 
769
   dec cl
-
 
770
   jnz next_ship
-
 
771
no_ships:
Line 605... Line -...
605
    jmp newlocend
-
 
606
 
-
 
607
shiptype dd 0
-
 
608
xmoving  dd 0
-
 
609
ymoving  dd 0
-
 
610
xaccel   dd 0
-
 
611
yaccel   dd 0
-
 
612
 
-
 
613
add_ships:
-
 
614
looship:
-
 
615
    cmp ecx,0
-
 
616
    je  no_ships
-
 
617
    push ecx
772
   ret
618
    findmas objmas,findzero
-
 
619
;in edi off to free element
-
 
620
    jc  close_app
-
 
621
    mov ebp,[shiptype]
-
 
622
    mov dword [edi+8],ebp ;2 ;green ship
773
 
623
; random x
-
 
624
    push edi
-
 
625
    random 600,eax
-
 
626
    pop edi
-
 
627
    mov [edi],eax
-
 
Line -... Line 774...
-
 
774
; search empty slot in object array
-
 
775
find_empty_object:
-
 
776
   cmp [edi+8],dword 0  ; if object type == 0 then it empty
-
 
777
   je  is_finded        ; empty object is finded set CF = 0
-
 
778
; find_next
-
 
779
   stc     ; CF = 1
-
 
780
   ret
-
 
781
is_finded:
-
 
782
   clc     ; CF = 0
-
 
783
   ret
-
 
784
 
-
 
785
; Try to draw particle from particle array
Line -... Line 786...
-
 
786
draw_particles:
628
; random y
787
   mov ecx,[edi+8]         ; ecx - type of particle
-
 
788
   cmp ecx,0               ; if type == 0 then do not draw object
629
    push edi
789
   je  return
-
 
790
   mov eax,laser_img
630
    mov ebp,[levelpart]
791
   cmp ecx,Laser           ; this is laser particle
-
 
792
   je  draw_space_object
-
 
793
   mov eax,plasma2_img
631
    shl ebp,5
794
   cmp ecx,StaticPlasma    ; particle type for final screen animation
-
 
795
   je  draw_space_object
Line -... Line 796...
-
 
796
   random 3,ebx            ; if else this is Plasma particle
-
 
797
   mov eax,plasma1_img
-
 
798
   dec ebx
-
 
799
   jz draw_space_object
-
 
800
   mov eax,plasma2_img
632
    add ebp,levels
801
   dec ebx
633
    mov esi,[ebp+4] ;get max range
802
   jz draw_space_object
634
    random esi,eax
803
   mov eax,plasma3_img
-
 
804
   jmp draw_space_object
-
 
805
 
635
    neg eax
806
; Draw space objects from array
-
 
807
draw_objects:
-
 
808
   mov ecx,[edi+8]         ; ecx = [edi+8] - type of ship
-
 
809
   cmp ecx,0               ; if type of ship == 0 then not draw it
-
 
810
   je  return
-
 
811
   cmp ecx,(ot_end-object_type)/4+1
-
 
812
   jae return              ; if type out of range ignore it
636
    pop edi
813
   mov edx,[edi+4]         ; edx = [edi+4] - y position of ship
-
 
814
   cmp edx,screen_h-40
637
    mov [edi+4],eax
815
   jg  return
-
 
816
   cmp edx,0               ; do not draw object if it y position is out of screen
-
 
817
   jl  return
-
 
818
   mov eax,[(object_type-4)+ecx*4]   ; -4 when types starts from 1 instead 0
-
 
819
draw_space_object:
-
 
820
   image_draw_acimage canvas,eax,dword [edi],dword [edi+4],cl_Black
-
 
821
return:
-
 
822
   ret
-
 
823
 
-
 
824
object_type: dd bwarship_img,gwarship_img,asteroid_img,box_img
-
 
825
ot_end:
-
 
826
 
-
 
827
; Update (move) particles (laser,plasma)
-
 
828
move_particles:
-
 
829
   xor eax,eax
-
 
830
   cmp [edi+8],eax      ; Is object not empty ?
-
 
831
   je this_is_empty_particle
-
 
832
move_particle:
-
 
833
   mov eax,[edi+12]
-
 
834
   add [edi],eax        ; objectx + [edi+12]
-
 
835
   mov eax,[edi+16]
-
 
836
   add [edi+4],eax      ; objecty + [edi+16]
-
 
837
this_is_empty_particle:
-
 
838
   ret
-
 
839
 
-
 
840
;  update (move) space objects (ships,asteroids,boxes)
-
 
841
move_objects:
-
 
842
   xor eax,eax
-
 
843
   cmp [edi+8],eax
638
; x moving
844
   je  object_is_empty
-
 
845
   ;call move_particle
-
 
846
   mov eax,[edi+12]
-
 
847
   add [edi],eax
-
 
848
   mov eax,[edi+16]
-
 
849
   add [edi+4],eax
-
 
850
 
-
 
851
   ; Do not allow object to go out of screen from right side
-
 
852
   mov eax,screen_w-32     ; eax = right side of screen
-
 
853
   cmp dword [edi],eax
-
 
854
   jng right_side_ok
-
 
855
   mov dword [edi],eax
-
 
856
   neg dword [edi+12]
-
 
857
   jmp left_side_ok
-
 
858
right_side_ok:
-
 
859
   ; Do not allow object to go out of screen from left side
-
 
860
   xor eax,eax             ; eax = 0 - left side of screen
-
 
861
   cmp dword [edi],eax
-
 
862
   jnl left_side_ok
-
 
863
   mov dword [edi],eax
-
 
864
   neg dword [edi+12]
639
    push edi         ;planers
865
left_side_ok:
-
 
866
   ; If object out of screen remove it
-
 
867
   cmp dword [edi+4],screen_h;-40
-
 
868
   jng y_ok
-
 
869
   mov dword [edi+8],0     ; Delete object
640
    random [xmoving],eax
870
   ret
-
 
871
y_ok:
-
 
872
   cmp dword [edi+8],GreenWarShip  ; Object is green enemy ship?
-
 
873
   jne no_grs
-
 
874
   mov eax,dword [edi+4]   ; eax = y position of enemy ship
-
 
875
   ; alternative way is use random for shoot
-
 
876
   cmp eax,100
-
 
877
   jna no_grs
-
 
878
   cmp eax,103
-
 
879
   jna grs
-
 
880
   cmp eax,200
-
 
881
   jna no_grs
-
 
882
   cmp eax,203
-
 
883
   jna grs
-
 
884
   cmp eax,300
-
 
885
   jna no_grs
-
 
886
   cmp eax,303
-
 
887
   ja  no_grs
-
 
888
grs:
-
 
889
   ; invert y moving direction and make shoot
-
 
890
   neg dword [edi+12]
-
 
891
   mov [temp],edi
-
 
892
   array_find particles,find_empty_object
641
    sub eax,[xaccel];4
893
   jc  close_app
Line -... Line 894...
-
 
894
   mov esi,[temp]      ; edi contains address to free element
-
 
895
   mov [edi+8],dword 1
-
 
896
   mov [edi+12],dword 0
-
 
897
   mov [edi+16],dword 10
-
 
898
   jmp set_particle_position
-
 
899
no_grs:
-
 
900
   cmp dword [edi+8],BlueWarShip  ; object is blue enemy ship ?
-
 
901
   jne no_bls
Line 642... Line 902...
642
    pop edi
902
   mov ecx,dword [edi+4]
-
 
903
   cmp ecx,50
643
    mov [edi+12],eax
904
   jna no_bls
-
 
905
   cmp ecx,64
644
; y moving
906
   jna bls
-
 
907
   cmp ecx,100
645
    push edi
908
   jna no_bls
646
    random [ymoving],eax     ;slow
909
   cmp ecx,114
-
 
910
   jna bls
647
    add eax,[yaccel] ;2
911
   cmp ecx,150
-
 
912
   jna no_bls
648
    pop edi
913
   cmp ecx,164
-
 
914
   ja  no_bls
-
 
915
bls:
649
    mov [edi+16],eax
916
   ; drop plasma mine
650
    pop ecx
917
   mov [temp],edi
-
 
918
   array_find particles,find_empty_object
-
 
919
   jc  close_app
-
 
920
   mov esi,[temp]
-
 
921
   mov [edi+8],dword 2
-
 
922
   mov [edi+12],dword 0
651
    dec ecx
923
   mov [edi+16],dword 5
-
 
924
set_particle_position:
-
 
925
   mov eax,[esi]
652
    jnz looship
926
   mov [edi],eax       ; Particle x = Ship x
653
no_ships:
927
   mov eax,[esi+4]
-
 
928
   mov [edi+4],eax     ; Partcle y = Ship y
654
    ret
929
no_bls:
-
 
930
object_is_empty:
-
 
931
   ret
-
 
932
 
-
 
933
; Remove particles that have gone out off screen
655
 
934
remove_outofscr_particles:
-
 
935
   cmp dword [edi+4],40  ; test y position
656
 
936
   jl  del
-
 
937
   cmp dword [edi+4],screen_h-40
-
 
938
   jg  del
Line -... Line 939...
-
 
939
   cmp dword [edi],0     ; x test used for plasma shoots
-
 
940
   jl  del
657
levelpart dd 0
941
   cmp dword [edi],screen_w-32
Line 658... Line -...
658
levels:
-
 
659
;level1
-
 
660
    dd 1,800,0,0,5,8,0,0     ;one at start
-
 
661
    dd 500,2000,4,20,30,0,0,0
-
 
662
    dd 500,2000,4,20,0,8,0,0
-
 
663
    dd 500,2000,10,0,0,4,0,0
-
 
664
    dd 500,4000,0,30,0,0,0,0
-
 
665
    dd 400,400,0,0,10,0,0,0
-
 
666
    dd 400,400,0,0,10,0,0,0
-
 
667
    dd 0,0,0,0,0,0,0,0        ;end of level
942
   jg  del
-
 
943
   ret        ; do not delete
-
 
944
del:
-
 
945
   xor eax,eax
668
;level2
946
   mov [edi+8],eax ; [edi+8] = 0
-
 
947
not_del:
-
 
948
   ret
-
 
949
 
-
 
950
objects_and_particles_hit_handling:
-
 
951
   xor eax,eax
-
 
952
   cmp [esi+8],eax
-
 
953
   je  no_hit
-
 
954
   cmp [edi+8],eax    ; If object is empty skip crush test
-
 
955
   je  no_hit
-
 
956
   cmp [esi+16],eax
-
 
957
   jg  no_hit
-
 
958
 
-
 
959
   mov eax,[esi]
-
 
960
   shl eax,16
-
 
961
   mov ax,word [esi+4]
-
 
962
   mov ebx,32*65536+32
-
 
963
   mov ecx,[edi]
-
 
964
   shl ecx,16
-
 
965
   mov cx,word [edi+4]
-
 
966
   mov edx,32*65536+32
-
 
967
 
-
 
968
   game_collision_2d eax,ebx,ecx,edx
-
 
969
   jnc no_hit
-
 
970
 
-
 
971
   cmp dword [edi+8],GreenWarShip
-
 
972
   jne not_grship
-
 
973
   inc [gships_destroyed]
-
 
974
   add [score],30
-
 
975
   jmp remove_object_and_particle
-
 
976
not_grship:
-
 
977
   cmp dword [edi+8],BlueWarShip
-
 
978
   jne not_blship
-
 
979
   inc [bships_destroyed]
-
 
980
   add [score],20
-
 
981
   jmp remove_object_and_particle
-
 
982
not_blship:
-
 
983
   cmp dword [edi+8],Asteroid
-
 
984
   jne not_asteroid
-
 
985
   cmp dword [edi+16],1 ; Asteroid have minimal speed?
-
 
986
   je  remove_only_particle
-
 
987
   dec dword [edi+16]   ; Decrase speed of asteroid
-
 
988
   jmp remove_only_particle
-
 
989
not_asteroid:
-
 
990
remove_object_and_particle:  ; When hit to ship or box
-
 
991
   mov [edi+8],dword 0
-
 
992
remove_only_particle:        ; When hit to asteroid
-
 
993
   mov [esi+8],dword 0
-
 
994
no_hit:
-
 
995
   ret
-
 
996
 
-
 
997
player_and_objects_collision_handling:
-
 
998
   cmp [edi+8],dword 0
-
 
999
   je  no_obj_cr
-
 
1000
 
-
 
1001
   mov eax,[shipx]
-
 
1002
   shl eax,16
669
    dd 1,16000,0,30,0,0,0,0     ;one at start
1003
   mov ax,word [shipy]
670
    dd 200,8000,0,20,0,0,0,0
1004
   mov ebx,32*65536+32
671
    dd 200,2000,0,10,0,8,0,0
1005
   mov ecx,[edi]
672
    dd 200,4000,0,10,0,0,0,0
1006
   shl ecx,16
673
    dd 0,0,0,0,0,0,0,0        ;end of level
1007
   mov cx,word [edi+4]
674
;level3
1008
   mov edx,32*65536+32
675
    dd 1,4000,0,20,30,8,0,0     ;one at start
1009
 
676
    dd 400,4000,10,10,20,6,0,0
1010
   game_collision_2d eax,ebx,ecx,edx
-
 
1011
   jnc no_obj_cr
677
    dd 400,4000,0,20,10,2,0,0
1012
   cmp dword [edi+8],Box  ; if box
678
    dd 400,4000,10,10,20,0,0,0
1013
   jne no_fbox
679
    dd 0,-1,0,0,0,0,0,0        ;end of game
1014
   add [player_hp],5
680
 
1015
   add [score],50
681
 
1016
   mov [edi+8],dword 0  ; delete object
682
newlocend:
1017
   inc [boxes_taken]
683
    mov [pathtime],0
1018
   ret
684
    inc [levelpart]
1019
no_fbox:
685
    jmp no_nextloc
1020
   sub [player_hp],16
686
 
1021
   mov [edi+8],dword 0  ; delete object
687
endgame dd 0
1022
no_obj_cr:
688
objects dd 0
1023
   ret
689
endtest:
1024
 
690
    cmp dword [edi+8],0
1025
player_and_particles_collision_handling:
691
    jne no_free
1026
   xor eax,eax       ; use eax as zero
692
    ret
1027
   cmp [edi+8],eax   ; empty object?
693
no_free:
1028
   je  no_gobj_cr
694
    mov [endgame],0
1029
   cmp [edi+16],eax  ; is player ?
695
    inc [objects]
1030
   jl  no_gobj_cr
696
    ret
-
 
697
 
1031
 
698
 
1032
   mov eax,[shipx]
699
no_nextloc:
1033
   shl eax,16
700
    mov [objects],0
1034
   mov ax,word [shipy]
701
    mov [endgame],1
-
 
702
    readmas objmas,endtest
1035
   mov ebx,32*65536+32
703
    cmp [endgame],1
1036
   mov ecx,[edi]
704
    jne no_end_lev ;no_nextloc
1037
   shl ecx,16
-
 
1038
   mov cx,word [edi+4]
705
 
1039
   mov edx,32*65536+32
706
    mov ebp,[levelpart]
1040
 
707
    shl ebp,5
1041
   game_collision_2d eax,ebx,ecx,edx
708
    add ebp,levels
1042
   jnc no_gobj_cr
709
    mov eax,[ebp+4]
1043
   sub [player_hp],4
710
    cmp eax,dword 0
1044
   mov [edi+8],dword 0  ; delete object
711
    je  end_lev    ;end of level
1045
no_gobj_cr:
712
    cmp eax,dword -1
1046
   ret
713
    je  end_gm    ;end of game
1047
 
714
 
1048
;**************************
715
no_end_lev:
1049
; Player ship shoot procs
716
 
-
 
717
    cmp [num5],dword 0
1050
;**************************
718
    je  no_addsh
1051
 
719
    cmp [ctime],dword 0
1052
; Try to make laser shoot
720
    jne no_addsh
1053
try_to_make_laser_shoot:
721
    cmp [lazer],dword 0
1054
   cmp [laser_charge],dword 0
722
    je  no_addsh
1055
   jne no_laser_shoot     ; laser_shoots is heat, need time for recharge
723
    findmas massive,findzero
1056
   cmp [laser_shoots],dword 0
724
;in edi off to free element
1057
   je  no_laser_shoot     ; Don't shoot when so many laser particles on screen
725
    jc  close_app
1058
   array_find particles,find_empty_object  ; edi = offset to emppty object
726
    mov eax,[shipx]
1059
   jc  close_app          ; ?
727
    mov [edi],eax
1060
   mov eax,[shipx]
728
    mov eax,[shipy]
1061
   mov [edi],eax           ; 0  = x position of shoot
729
    mov [edi+4],eax
1062
   mov eax,[shipy]
730
    mov [edi+8],dword 1   ;show
1063
   mov [edi+4],eax         ; 4  = y position of shoot
731
    mov [edi+12],dword 0
1064
   mov [edi+8],dword 1     ; 8  = 1 - laser type
732
    mov [edi+16],dword -12
1065
   mov [edi+12],dword 0    ; 12 = 0   - x speed
733
    mov [ctime],dword 8   ;wait for cannon
1066
   mov [edi+16],dword -12  ; 16 = -12 - y speed
734
    dec [lazer]
1067
   mov [laser_charge],dword 8  ; Reset shoot timer
735
no_addsh:
1068
   dec [laser_shoots]      ; Decrase number of laser projectiles
736
 
1069
no_laser_shoot:
737
    cmp [num8],dword 0
1070
   ret
738
    je  no_addplx
1071
 
739
    cmp [xtime],dword 256-16
1072
; Try to make plasma shoot
740
    jae no_addplx
1073
try_to_make_plasma_shoot:
741
    cmp [plazma],0
1074
   cmp [plasma_charge],dword 256-16
742
    je  no_addplx
-
 
743
    findmas massive,findzero
-
 
744
;in edi off to free element
-
 
745
    jc  close_app
-
 
746
    mov eax,[shipx]
-
 
747
    mov [edi],eax
-
 
748
    mov eax,[shipy]
-
 
749
    mov [edi+4],eax
-
 
750
    mov [edi+8],dword 2   ;show
-
 
751
    add [xtime],dword 8  ;wait for cannon
-
 
752
    cmp [xtime],dword 256
-
 
753
    jna okx
-
 
754
    mov [xtime],256
-
 
755
okx:
-
 
756
    mov [edi+12],dword 0  ;wait for cannon
-
 
757
    mov [edi+16],dword -8  ;wait for cannon
-
 
758
    dec [plazma]
-
 
759
no_addplx:
-
 
760
 
-
 
761
 
-
 
762
 
-
 
763
    cmp [num2],dword 0
-
 
764
    je  no_addsh2
-
 
765
    cmp [xtime],dword 0
-
 
766
    jne no_addsh2
-
 
767
    cmp [plazma],0
-
 
768
    je  no_addsh2
-
 
769
    mov eax,[shipy]
-
 
770
    mov [temp3],eax
-
 
771
    mov [temp2],dword 5
-
 
772
loox2:
-
 
773
    mov [temp],dword 10
-
 
774
loox:
-
 
775
    findmas massive,findzero
-
 
776
;in edi off to free element
-
 
777
    jc  close_app
-
 
778
    random 25,eax
-
 
779
    mov ebp,eax
-
 
780
    sub eax,12
-
 
781
    add eax,[shipx]
-
 
782
    mov [edi],eax
-
 
783
    shr ebp,3
-
 
784
    random ebp,eax
-
 
785
    neg eax
-
 
786
    add eax,[temp3] ;[shipy]
-
 
787
    mov [edi+4],eax
-
 
788
    mov [edi+8],dword 2   ;show hstar
-
 
789
    random 5,eax
-
 
790
    sub eax,2
-
 
791
    mov [edi+12],eax   ;show hstar
-
 
792
    random 7,eax
-
 
793
    sub eax,8
-
 
794
    mov [edi+16],eax   ;show hstar
-
 
795
    dec [temp]
-
 
796
    jnz loox
-
 
797
    sub [temp3],30
-
 
798
    dec [temp2]
-
 
799
    jnz loox2
-
 
800
    mov [xtime],dword 256  ;wait for cannon
-
 
801
    sub [plazma],50
-
 
802
no_addsh2:
-
 
803
 
-
 
804
 
-
 
805
    cmp [num1],dword 0
-
 
806
    je  no_left
-
 
807
    sub dword [shipx],6
-
 
808
no_left:
-
 
809
 
-
 
810
    cmp [num3],dword 0
-
 
811
    je  no_right
-
 
812
    add dword [shipx],6
-
 
813
no_right:
-
 
814
 
-
 
815
;ship correct
-
 
816
    cmp [shipx],5
-
 
817
    jnl xl_ok
-
 
818
    mov [shipx],5
-
 
819
xl_ok:
-
 
820
    cmp [shipx],603
-
 
821
    jng xr_ok
-
 
822
    mov [shipx],603
-
 
823
xr_ok:
-
 
824
 
-
 
825
 
-
 
826
;clear scrbuf
-
 
827
    mov edi,canvas+8
-
 
828
    cld
-
 
829
    mov ecx,640*440*3/4
-
 
830
    mov eax,0
-
 
831
    rep stosd
-
 
832
 
-
 
833
    compmas objmas,massive,compobr
-
 
834
 
-
 
835
    readmas objmas,shipobjtest
1075
   jae no_plasma_shoot
836
    readmas massive,shipguntest
-
 
837
 
-
 
838
    readmas objmas,showobjmas
-
 
839
    readmas objmas,moveobjmas
-
 
840
 
-
 
841
    readmas massive,showmas
-
 
842
    readmas massive,movemas
-
 
843
    readmas massive,delfarshoot
-
 
844
;    findmas massive,findzero
-
 
845
;in edi off to free element
1076
   cmp [plasma_shoots],0
846
;    jc  close_app
-
 
847
 
-
 
848
    aimgtoimg ship,[shipx],[shipy],canvas,0x0
-
 
849
 
-
 
850
    drawfbox 150,5,64,5,0x000000
-
 
851
    mov eax,[xtime]
-
 
852
    sub eax,256
-
 
853
    neg eax
-
 
854
    shr eax,2
-
 
855
    drawfbox 150,5,eax,5,0x0000ff
-
 
856
 
-
 
857
    drawfbox 150,12,64,5,0x000000
-
 
858
    mov eax,[ctime]
-
 
859
    sub eax,8
-
 
860
    neg eax
-
 
861
    shl eax,3
-
 
862
    drawfbox 150,12,eax,5,0xffff00
-
 
863
 
-
 
864
    drawfbox 220,2,6*5+2 ,9,cl_Grey
-
 
865
    outcount [plazma],221,3,cl_Blue,5*65536
-
 
866
    drawfbox 220,11,6*5+2 ,9,cl_Grey
-
 
867
    outcount [lazer],221,12,0xffff00,5*65536
-
 
868
 
-
 
869
 
-
 
870
    drawfbox 280,6,6*5+2 ,9,cl_Grey
-
 
871
    outcount [gship],281,7,cl_Green,5*65536
-
 
872
    drawfbox 320,6,6*5+2 ,9,cl_Grey
-
 
873
    outcount [bship],321,7,cl_Blue,5*65536
-
 
874
    drawfbox 360,6,6*5+2 ,9,cl_Grey
-
 
875
    outcount [boxget],361,7,0xffaa00,5*65536
-
 
876
 
-
 
877
    drawfbox 400,2,6*5+2 ,9,cl_Grey
-
 
878
    outcount [objects],401,2,0x00ff00,5*65536
-
 
879
    drawfbox 400,11,6*5+2 ,9,cl_Grey
-
 
880
    outcount [energy],401,12,0xff0000,5*65536
-
 
881
 
-
 
882
    drawfbox 450,11,6*5+2 ,9,cl_Grey
-
 
883
    outcount [score],451,12,0xffff00,5*65536
-
 
884
 
-
 
885
 
-
 
886
    jmp  still
-
 
887
 
-
 
888
  red:
-
 
889
    call draw_window
-
 
890
    jmp still
-
 
891
 
-
 
892
  key:                          ; key
-
 
893
    mov  eax,2
-
 
894
    mcall                   ; read (eax=2)
-
 
895
 
-
 
896
    shr eax,8
-
 
897
    and eax,0xff
-
 
898
    mov ah,al
-
 
899
 
-
 
900
    cmp ah,153
-
 
901
    jne no_pause
-
 
902
    not [pause_on]
-
 
903
    jmp still
-
 
904
no_pause:
-
 
905
 
-
 
906
 
-
 
907
    cmp ah,76
-
 
908
    jne no_num5d
-
 
909
    mov [num5],1
-
 
910
    jmp still
-
 
911
no_num5d:
-
 
912
    cmp ah,204
-
 
913
    jne no_num5u
-
 
914
    mov [num5],0
-
 
915
    jmp still
-
 
916
no_num5u:
-
 
917
 
-
 
918
    cmp ah,80
-
 
919
    jne no_num2d
-
 
920
    mov [num2],1
-
 
921
    jmp still
-
 
922
no_num2d:
-
 
923
    cmp ah,208
1077
   je  no_plasma_shoot
Line 924... Line -...
924
    jne no_num2u
-
 
925
    mov [num2],0
-
 
926
    jmp still
-
 
927
no_num2u:
-
 
928
 
-
 
929
    cmp ah,79 ;key_Space 85 exit
-
 
930
    jne no_num1d
-
 
931
    mov [num1],1
-
 
932
    jmp still
-
 
933
no_num1d:
-
 
934
    cmp ah,207 ;key_Space 85 exit
-
 
935
    jne no_num1u
-
 
936
    mov [num1],0
-
 
937
    jmp still
-
 
938
no_num1u:
-
 
939
 
-
 
940
    cmp ah,81 ;key_Space 85 exit
-
 
941
    jne no_num3d
-
 
942
    mov [num3],1
-
 
943
    jmp still
-
 
944
no_num3d:
-
 
945
    cmp ah,209 ;key_Space 85 exit
-
 
946
    jne no_num3u
-
 
947
    mov [num3],0
-
 
948
    jmp still
-
 
949
no_num3u:
-
 
950
 
-
 
951
    cmp ah,72  ;key_Space 85 exit
-
 
952
    jne no_num8d
-
 
953
    mov [num8],1
-
 
954
    jmp still
-
 
955
no_num8d:
-
 
956
    cmp ah,200 ;key_Space 85 exit
-
 
957
    jne no_num8u
-
 
958
    mov [num8],0
-
 
959
    jmp still
-
 
960
no_num8u:
-
 
961
 
-
 
962
    jmp  still                  ; not testing
-
 
963
 
-
 
964
  button:                       ; button
-
 
965
    mov  eax,17                 ; get id
-
 
966
    mcall
-
 
967
    cmp  ah,1                   ; button id=1 ?
-
 
968
    jne  noclose
-
 
969
close_app:
-
 
970
    mov  eax,-1                 ; close this program
-
 
971
    mcall
-
 
972
  noclose:
-
 
973
    jmp  still
-
 
974
 
-
 
975
draw_window:
-
 
976
	
-
 
977
    mcall 12,1 ;start window redraw
-
 
978
	mcall 0, <40, 640+9>, <40, 440+26>, 0x14000000,, wtitle
-
 
979
    mcall 12,2 ;end window redraw
-
 
980
	;    setimg 5,22,img_area
-
 
981
 
-
 
982
    ret
-
 
983
 
-
 
984
;**********************
-
 
985
;  Game Over process
-
 
986
;**********************
-
 
987
 
-
 
988
game_over:
-
 
989
;    close
-
 
990
    call draw_gowindow
-
 
991
stillgo:
-
 
992
    wtevent redgo,keygo,buttongo
-
 
993
    jmp stillgo
-
 
994
redgo:
-
 
995
    call draw_gowindow
-
 
996
    jmp stillgo
-
 
997
keygo:
-
 
998
    mov  eax,2
-
 
999
    mcall
-
 
1000
    jmp  stillgo
-
 
1001
buttongo:
-
 
1002
    mov  eax,17                 ; get id
-
 
1003
    mcall
-
 
1004
    cmp  ah,1
-
 
1005
    je   close_app
-
 
1006
    cmp  ah,4
-
 
1007
    je   close_app
-
 
1008
    cmp  ah,5
-
 
1009
    je   main_menu
-
 
1010
    cmp  ah,7
-
 
1011
    je   restart_lev
-
 
1012
    jmp  stillgo
-
 
1013
 
-
 
1014
restart_lev:
-
 
1015
    mov [pathtime],0
-
 
1016
 
-
 
1017
prevpart:
-
 
1018
    mov ebp,[levelpart]
-
 
1019
    shl ebp,5
-
 
1020
    add ebp,levels
-
 
1021
    mov eax,[ebp]
-
 
1022
    cmp eax,dword 1
-
 
1023
    je  rest    ;end of level
-
 
1024
    dec [levelpart]
-
 
1025
    jmp prevpart
-
 
1026
 
-
 
1027
 
-
 
1028
rest:
-
 
1029
;massives reset - clear massives
-
 
1030
    mov edi,massive+8
-
 
1031
    cld
-
 
1032
    mov ecx,massize*elemsize/4
-
 
1033
    mov eax,0
-
 
1034
    rep stosd
-
 
1035
 
-
 
1036
    mov edi,objmas+8
-
 
1037
    cld
-
 
1038
    mov ecx,omassize*oelemsize/4
-
 
1039
    mov eax,0
-
 
1040
    rep stosd
-
 
1041
 
-
 
1042
;counters reset
-
 
1043
    mov [boxget],0
-
 
1044
    mov [gship],0
-
 
1045
    mov [bship],0
-
 
1046
 
-
 
1047
;ship reset
-
 
1048
    mov [energy],100
-
 
1049
    mov [shipx],300
-
 
1050
    mov [shipy],400
-
 
1051
    mov [lazer],1000
-
 
1052
    mov [plazma],500
-
 
1053
 
-
 
1054
 
-
 
1055
; reset keyboard
-
 
1056
    mov [num1],0
-
 
1057
    mov [num5],0
-
 
1058
    mov [num3],0
-
 
1059
    mov [num2],0
-
 
1060
    mov [num8],0
-
 
1061
    jmp start_game
-
 
1062
 
-
 
1063
draw_gowindow:
-
 
1064
    startwd
-
 
1065
    call draw_window
-
 
1066
    mcall 9,proc_info,-1
-
 
1067
    test [proc_info+process_information.wnd_state], 0x04
-
 
1068
    jz   @f
-
 
1069
    ret
-
 
1070
  @@:
-
 
1071
    drawfbox 170,160,300,120,cl_Grey
-
 
1072
    drawlbut 180,260,80,14,'EXIT',4,0x990000,cl_Black
-
 
1073
    drawlbut 280,260,80,14,'MENU',5,0x990000,cl_Black
-
 
1074
    drawlbut 380,260,80,14,'RESTART',7,0x990000,cl_Black
-
 
1075
 
-
 
1076
    label 280,200,'  GAME OVER  ',cl_Black
-
 
1077
    endwd
-
 
1078
    ret
-
 
1079
 
-
 
1080
 
-
 
1081
;**********************
-
 
1082
;  End level process
-
 
1083
;**********************
-
 
1084
 
-
 
1085
end_lev:
-
 
1086
;    close
-
 
1087
    call draw_scorewindow
-
 
1088
stilleg:
-
 
1089
    wtevent redeg,keyeg,buttoneg
-
 
1090
    jmp stilleg
-
 
1091
redeg:
-
 
1092
    call draw_scorewindow
-
 
1093
    jmp stilleg
-
 
1094
keyeg:
-
 
1095
    mov  eax,2
-
 
1096
    mcall
-
 
1097
    jmp  stilleg
-
 
1098
buttoneg:
-
 
1099
    mov  eax,17                 ; get id
-
 
1100
    mcall
-
 
1101
    cmp  ah,1
-
 
1102
    je   close_app
-
 
1103
    cmp  ah,2
-
 
1104
    je   next_lev
-
 
1105
    cmp  ah,3
-
 
1106
    je   help
-
 
1107
    cmp  ah,4
-
 
1108
    je   close_app
-
 
1109
    cmp  ah,5
-
 
1110
    je   main_menu
-
 
1111
    jmp  stilleg
-
 
1112
 
-
 
1113
next_lev:
-
 
1114
    mov [pathtime],0
-
 
1115
    inc [levelpart]
-
 
1116
 
-
 
1117
;ship reset
-
 
1118
    mov [energy],100
-
 
1119
    mov [shipx],300
-
 
1120
    mov [shipy],400
-
 
1121
    mov [lazer],1000
-
 
1122
    mov [plazma],500
-
 
1123
 
-
 
1124
;counters reset
-
 
1125
    mov [boxget],0
-
 
1126
    mov [gship],0
-
 
1127
    mov [bship],0
-
 
1128
 
-
 
1129
; reset keyboard
-
 
1130
    mov [num1],0
-
 
1131
    mov [num5],0
-
 
1132
    mov [num3],0
-
 
1133
    mov [num2],0
-
 
1134
    mov [num8],0
-
 
1135
    jmp start_game
-
 
1136
 
-
 
1137
draw_scorewindow:
-
 
1138
    call draw_window
-
 
1139
    mcall 9,proc_info,-1
-
 
1140
    test [proc_info+process_information.wnd_state], 0x04
-
 
1141
    jz   @f
-
 
1142
    ret
-
 
1143
  @@:
-
 
1144
    startwd
-
 
1145
    drawfbox 170,130,300,190,cl_Grey
-
 
1146
    drawlbut 180,300,80,14,'(X) EXIT',4,0x990000,cl_Black
-
 
1147
    drawlbut 280,300,80,14,'',5,0x990000,cl_Black
-
 
1148
    drawlbut 380,300,80,14,'NEXT >>',2,0x990000,cl_Black
-
 
1149
 
-
 
1150
    setimg 180,140,warship1
-
 
1151
    outcount [bship],241,151,cl_Blue,5*65536
-
 
1152
 
-
 
1153
    setimg 180,180,warship2
-
 
1154
    outcount [gship],241,191,cl_Green,5*65536
-
 
1155
 
-
 
1156
    setimg 180,220,meteor
-
 
1157
    setimg 180,260,box
-
 
1158
    outcount [boxget],241,271,0xbbbb00,5*65536
-
 
1159
    endwd
-
 
1160
    ret
-
 
1161
 
-
 
1162
 
-
 
1163
;**********************
-
 
1164
;  End of game process
-
 
1165
;**********************
-
 
1166
 
-
 
1167
end_gm:
-
 
1168
    mov [pathtime],0
-
 
1169
    call draw_window
-
 
1170
    label 200 ,8,'YOU WIN PRESS ANY KEY TO EXIT',cl_White+font_Big
-
 
1171
 
-
 
1172
stilleg2:
-
 
1173
;    scevent   redeg2,keyeg2,buttoneg2
-
 
1174
    timeevent 1,no_event2,redeg2,keyeg2,buttoneg2
-
 
1175
 
-
 
1176
no_event2:
-
 
1177
    setimg 5,21,canvas
-
 
1178
 
-
 
1179
;clear scrbuf
-
 
1180
    mov edi,canvas+8
-
 
1181
    cld
-
 
1182
    mov ecx,640*440*3/4
-
 
1183
    mov eax,0
-
 
1184
    rep stosd
-
 
1185
 
-
 
1186
    aimgtoimg ship,320,220,canvas,0x0
-
 
1187
 
1078
   array_find particles,find_empty_object
1188
    readmas massive,endshowmas
1079
   ; edi = off to free element
1189
    readmas massive,endmovemas
-
 
1190
    readmas massive,delfarshoot
1080
   jc  close_app     ;?
Line 1191... Line -...
1191
;    findmas massive,findzero
-
 
1192
;in edi off to free element
-
 
1193
;    jc  close_app
1081
   mov eax,[shipx]
Line 1194... Line -...
1194
 
-
 
1195
    inc [pathtime]
-
 
1196
    cmp [pathtime],30
-
 
1197
    jne no_firework
-
 
1198
    mov [pathtime],0
-
 
1199
    random 400,eax
-
 
1200
    mov [temp3],eax
-
 
1201
    random 600,eax
-
 
1202
    mov [temp2],eax
-
 
1203
    mov [temp],dword 8;10
-
 
1204
xloox:
-
 
1205
    findmas massive,findzero
-
 
1206
;in edi off to free element
-
 
1207
    jc  close_app
-
 
1208
 
-
 
1209
    mov eax,[temp2] ;[shipx]
-
 
1210
    mov [edi],eax
-
 
1211
    mov eax,[temp3] ;[shipy]
-
 
1212
    mov [edi+4],eax
-
 
1213
    mov [edi+8],dword 2   ;show hstar
-
 
1214
rerand:
-
 
1215
    random 5,eax
1082
   mov [edi],eax
1216
    sub eax,2
-
 
1217
    cmp eax,0
-
 
1218
    je  rerand
1083
   mov eax,[shipy]
1219
    mov [edi+12],eax   ;show hstar
-
 
1220
rerand2:
-
 
1221
    random 7,eax
-
 
1222
    sub eax,3
-
 
1223
    cmp eax,0
-
 
1224
    je  rerand2
-
 
1225
    mov [edi+16],eax   ;show hstar
-
 
1226
    dec [temp]
-
 
1227
    jnz xloox
-
 
1228
no_firework:
-
 
1229
    jmp stilleg2
-
 
1230
 
-
 
1231
redeg2:
-
 
1232
    jmp end_gm ;stilleg2
-
 
1233
keyeg2:
-
 
1234
    mov  eax,2
-
 
1235
    mcall
-
 
1236
    jmp  main_menu
-
 
1237
buttoneg2:
-
 
Line -... Line 1084...
-
 
1084
   mov [edi+4],eax
1238
    mov  eax,17                 ; get id
1085
   mov [edi+8],dword 2   ; 8 = 2 - plasma
-
 
1086
   mov [edi+12],dword 0    ; 12 = 0   - x speed
-
 
1087
   mov [edi+16],dword -8   ; 16 = -8 - y speed
Line 1239... Line 1088...
1239
    mcall
1088
   dec [plasma_shoots]     ; Decrase number of plasma projectiles
1240
    jmp  stilleg2
1089
   add [plasma_charge],dword 8
1241
 
1090
   cmp [plasma_charge],dword 256
1242
 
1091
   jna no_plasma_shoot
1243
 
1092
   mov [plasma_charge],256
1244
 
-
 
1245
 
-
 
1246
 
-
 
1247
; DATA AREA
-
 
1248
IM_END:
-
 
1249
;global
-
 
1250
pause_on dd 0
-
 
1251
 
-
 
1252
;massive
-
 
1253
shipx dd 300
-
 
1254
shipy dd 400
-
 
1255
 
-
 
1256
;guns
-
 
1257
lazer  dd 1000
-
 
1258
plazma dd 500
-
 
1259
 
-
 
1260
;keys
-
 
1261
num1 dd 0
-
 
1262
num5 dd 0
-
 
1263
num3 dd 0
-
 
Line 1264... Line 1093...
1264
num2 dd 0
1093
no_plasma_shoot:
Line -... Line 1094...
-
 
1094
   ret
-
 
1095
 
-
 
1096
; Try to make plasma nuke
-
 
1097
try_to_make_plasma_nuke:
-
 
1098
   xor eax,eax     ; Use eax as zero
-
 
1099
   cmp [plasma_charge],eax
-
 
1100
   jne no_plasma_nuke
-
 
1101
   cmp [plasma_shoots],eax
-
 
1102
   je  no_plasma_nuke
-
 
1103
   mov eax,[shipy]
-
 
1104
   mov [temp3],eax
-
 
1105
   mov [temp2],dword 5
-
 
1106
loopx2:
-
 
1107
   mov [temp],dword 10
-
 
1108
loopx:
-
 
1109
   array_find particles,find_empty_object ; edi = offset to empty element
-
 
1110
   jc  close_app
-
 
1111
   random 25,eax
-
 
1112
   mov ebp,eax
-
 
1113
   sub ebp,12
-
 
1114
   add ebp,[shipx]
-
 
1115
   mov [edi],ebp    ; [edi] = random(0..25)-12+shipx
-
 
1116
   shr eax,3
-
 
1117
   random eax,eax
-
 
1118
   neg eax
-
 
1119
   add eax,[temp3]
-
 
1120
   mov [edi+4],eax
-
 
1121
   mov [edi+8],dword 2  ; 8 = 2 - plasma
-
 
1122
   random 5,eax
-
 
1123
   sub eax,2
-
 
1124
   mov [edi+12],eax
-
 
1125
   random 7,eax
-
 
1126
   sub eax,8
-
 
1127
   mov [edi+16],eax
-
 
1128
   dec [temp]
-
 
1129
   jnz loopx
-
 
1130
   sub [temp3],30     ; shipy - 30
-
 
1131
   dec [temp2]
-
 
1132
   jnz loopx2
-
 
1133
   mov [plasma_charge],dword 256  ; Wait for cannon
-
 
1134
   sub [plasma_shoots],50 ; -50 plasma bullets after nuke
-
 
1135
no_plasma_nuke:
-
 
1136
   ret
-
 
1137
 
-
 
1138
; DATA AREA
-
 
1139
IM_END:
-
 
1140
wtitle db 'Phoenix for KOS', 0
-
 
1141
 
-
 
1142
score    dd 0    ; player score
-
 
1143
 
-
 
1144
; Pause state, if != 0 then game on pause
-
 
1145
pause_on dd 0
-
 
1146
 
-
 
1147
; Frames countdown timer until start of next wave
1265
num8 dd 0
1148
; If = 0 then activate to next wave
1266
 
1149
; next_wave_timer
1267
;enemy countres
1150
next_wave_timer dd 0
1268
gship  dd 0
1151
 
1269
bship  dd 0
1152
;gif_file_area ~21500
1270
boxget dd 0
1153
;gif_file_area2:
1271
 
1154
;file 'phoenix.gif'
1272
energy dd 100
1155
gif_file_area:
1273
score  dd 0
1156
file 'objects.gif' ; Include gif file to code
Line 1274... Line 1157...
1274
 
1157
 
1275
;delay for cannon
1158
IncludeUGlobals
1276
ctime dd 0
-
 
1277
;delay for nuke gun
1159
 
1278
xtime dd 0
-
 
1279
;path time
-
 
Line -... Line 1160...
-
 
1160
; Window drawing function delegate (pointer)
-
 
1161
draw_proc rd 1
1280
pathtime dd 0
1162
; Keyboard processing function delegate (pointer)
1281
;
1163
keyboard_proc rd 1
1282
temp  dd 0
1164