Subversion Repositories Kolibri OS

Rev

Rev 2677 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;   Phenix Dynamic Game Created by Pavlushin Evgeni for ASCL
3
;
4
;   100% Full relase!
5
;
6
;   www.waptap@mail.ru
7
;
8
 
9
 
10
;******************************************************************************
11
    use32
12
    org    0x0
13
    db     'MENUET01'              ; 8 byte id
14
    dd     0x01                    ; header version
15
    dd     START                   ; start of code
16
    dd     IM_END                  ; size of image
17
    dd     I_END                   ; memory for app
18
    dd     I_END                   ; esp
19
    dd     0x0 , 0x0               ; I_Param , I_Icon
20
 
21
;******************************************************************************
22
 
23
 
24
include 'lang.inc'
2062 dunkaist 25
include '../../../macros.inc'
31 halyavin 26
include 'ascl.inc'
27
include 'ascgl.inc'
28
include 'ascml.inc'
29
 
30
 
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
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
51
no_star2:
52
    mov eax,star3
53
outp:
54
    aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
55
noshow:
56
    ret
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
82
    mov eax,box
83
    jmp outws
84
no_box:
85
outws:
86
    aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
87
noshow1:
88
    ret
89
 
90
 
91
moveobjmas:
92
    cmp [edi+8],dword 0
93
    je  no_ws
94
    mov eax,[edi+12]
95
    add [edi],eax
96
    mov eax,[edi+16]
97
    add [edi+4],eax
98
 
99
    cmp dword [edi],600
100
    jng xok1
101
    sub dword [edi],20
102
    neg dword [edi+12]
103
    jmp xok2
104
xok1:
105
    cmp dword [edi],0
106
    jnl xok2
107
    add dword [edi],20
108
    neg dword [edi+12]
109
xok2:
110
    cmp dword [edi+4],400
111
    jng yok
112
    mov dword [edi+8],0
113
    ret
114
yok:
115
    cmp dword [edi+8],2  ;green ship
116
    jne no_grs
117
    cmp dword [edi+4],100
118
    jna no_grs
119
    cmp dword [edi+4],103
120
    jna grs
121
    cmp dword [edi+4],200
122
    jna no_grs
123
    cmp dword [edi+4],203
124
    jna  grs
125
    cmp dword [edi+4],300
126
    jna no_grs
127
    cmp dword [edi+4],303
128
    ja  no_grs
129
grs:
130
    neg dword [edi+12]
131
    mov [temp],edi
132
    findmas massive,findzero
133
;in edi off to free element
134
    jc  close_app
135
    mov esi,edi
136
    mov edi,[temp]
137
    mov eax,[edi]
138
    mov [esi],eax
139
    mov eax,[edi+4]
140
    mov [esi+4],eax
141
    mov [esi+8],dword 1
142
    mov [esi+12],dword 0
143
    mov [esi+16],dword 10
144
no_grs:
145
 
146
    cmp dword [edi+8],1  ;blue ship
147
    jne no_bls
148
    cmp dword [edi+4],50
149
    jna no_bls
150
    cmp dword [edi+4],64
151
    jna bls
152
    cmp dword [edi+4],100
153
    jna no_bls
154
    cmp dword [edi+4],114
155
    jna bls
156
    cmp dword [edi+4],150
157
    jna no_bls
158
    cmp dword [edi+4],164
159
    ja  no_bls
160
bls:
161
    mov [temp],edi
162
    findmas massive,findzero
163
    jc  close_app
164
    mov esi,edi
165
    mov edi,[temp]
166
    mov eax,[edi]
167
    mov [esi],eax
168
    mov eax,[edi+4]
169
    mov [esi+4],eax
170
    mov [esi+8],dword 2
171
    mov [esi+12],dword 0
172
    mov [esi+16],dword 5
173
no_bls:
174
 
175
no_ws:
176
    ret
177
 
178
 
179
delfarshoot:
180
    cmp [edi+4],dword 40
181
    jb  del
182
    cmp [edi+4],dword 400
183
    ja  del
184
    cmp [edi],dword 40
185
    jb  del
186
    cmp [edi],dword 600
187
    ja  del
188
    jmp nodel
189
del:
190
    mov [edi+8],dword 0
191
nodel:
192
    ret
193
 
194
 
195
movemas:
196
    cmp [edi+8],dword 0
197
    jne no_freeel
198
    ret
199
no_freeel:
200
    mov eax,[edi+12]
201
    add [edi],eax
202
    mov eax,[edi+16]
203
    add [edi+4],eax
204
    ret
205
 
206
 
207
 
208
endshowmas:
209
    cmp [edi+8],dword 0
210
    je  noshowem
211
    mov eax,star2
212
    aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
213
noshowem:
214
    ret
215
 
216
 
217
 
218
endmovemas:
219
    cmp [edi+8],dword 0
220
    jne no_fr
221
    ret
222
no_fr:
223
    mov eax,[edi+12]
224
    add [edi],eax
225
    mov eax,[edi+16]
226
    add [edi+4],eax
227
    ret
228
 
229
 
230
findzero:
231
    cmp [edi+8],dword 0
232
    je  iz_zero
233
    xor eax,eax
234
    ret
235
iz_zero:
236
    mov eax,1
237
    ret
238
 
239
compobr:
240
    cmp [esi+8],dword 0
241
    je  no_crsh
242
    cmp [edi+8],dword 0
243
    je  no_crsh
244
    cmp [esi+16],dword 0
245
    jg  no_crsh
246
 
247
    mov eax,[esi]
248
    mov [temp],eax
249
    mov eax,[esi+4]
250
    mov [temp2],eax
251
    mov eax,[edi]
252
    mov [temp3],eax
253
    mov eax,[edi+4]
254
    mov [temp4],eax
255
 
256
    pushad
257
    collimg imgsize,[temp],[temp2],imgsize,[temp3],[temp4],[otv]
258
    popad
259
    cmp [otv],dword 0
260
    je  no_crsh
261
 
262
    cmp [edi+8],dword 2
263
    jne no_grship
264
    inc [gship]
265
    add [score],30
266
    jmp setzero
267
no_grship:
268
    cmp [edi+8],dword 1
269
    jne no_blship
270
    inc [bship]
271
    add [score],20
272
    jmp setzero
273
no_blship:
274
    cmp [edi+8],dword 3
275
    jne no_metr
276
    dec dword [edi+16]
277
    cmp dword [edi+16],0
278
    jne mok
279
    mov dword [edi+16],1
280
mok:
281
    mov [esi+8],dword 0
282
    ret
283
no_metr:
284
 
285
setzero:
286
    mov [esi+8],dword 0
287
    mov [edi+8],dword 0
288
no_crsh:
289
    ret
290
 
291
shipobjtest:
292
    cmp [edi+8],dword 0
293
    je  no_obj
294
    mov eax,[edi]
295
    mov [temp3],eax
296
    mov eax,[edi+4]
297
    mov [temp4],eax
298
    pushad
299
    collimg imgsize,[shipx],[shipy],imgsize,[temp3],[temp4],[otv]
300
    popad
301
    cmp [otv],dword 0
302
    je  no_obj
303
    cmp [edi+8],dword 4  ;if box
304
    jne no_fbox
305
    add [energy],5
306
    add [score],50
307
    mov [edi+8],dword 0
308
    inc [boxget]
309
    ret
310
no_fbox:
311
    sub [energy],16
312
    mov [edi+8],dword 0
313
no_obj:
314
    ret
315
 
316
shipguntest:
317
    cmp [edi+8],dword 0
318
    je  no_gobj
319
    cmp [edi+16],dword 0
320
    jl  no_gobj
321
    mov eax,[edi]
322
    mov [temp3],eax
323
    mov eax,[edi+4]
324
    mov [temp4],eax
325
    pushad
326
    collimg imgsize,[shipx],[shipy],imgsize,[temp3],[temp4],[otv]
327
    popad
328
    cmp [otv],dword 0
329
    je  no_gobj
330
    sub [energy],4
331
    mov [edi+8],dword 0
332
no_gobj:
333
    ret
334
 
335
 
336
START:                          ; start of execution
337
 
338
massize = 400
339
elemsize = 20
340
 
341
    mov [massive],dword massize
342
    mov [massive+4],dword elemsize
343
 
344
omassize = 100
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
485 heavyiron 354
    mcall
31 halyavin 355
 
356
    mov eax,26
357
    mov ebx,2
358
    mov ecx,1
359
    mov edx,keymap
485 heavyiron 360
    mcall
31 halyavin 361
 
362
startgame:
363
    giftoimg gif_file_area2,canvas
364
    giftoimg gif_file_area,img_area
365
 
366
    getimg img_area,0,0,32,32,ship
367
    getimg img_area,32,0,32,32,shoot
368
    getimg img_area,64,0,32,32,warship1
369
    getimg img_area,96,0,32,32,warship2
370
    getimg img_area,128,0,32,32,meteor
371
    getimg img_area,160,0,32,32,star
372
    getimg img_area,192,0,32,32,star2
373
    getimg img_area,224,0,32,32,star3
374
    getimg img_area,0,32,32,32,box
375
 
376
 
377
 
378
main_menu:
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
485 heavyiron 389
    mcall
31 halyavin 390
    jmp  stillm
391
buttonm:
392
    mov  eax,17                 ; get id
485 heavyiron 393
    mcall
31 halyavin 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
2062 dunkaist 406
    mcall 9,proc_info,-1
407
    test [proc_info+process_information.wnd_state], 0x04
408
    jz   @f
409
    ret
410
  @@:
31 halyavin 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
415
    ret
416
 
417
;***********************
418
; Draw help menu
419
;***********************
420
 
421
help:
422
    call draw_helpwindow
423
 
424
stillh:
425
    wtevent redh,keyh,buttonh
426
    jmp stillh
427
redh:
428
    call draw_helpwindow
429
    jmp stillh
430
keyh:
431
    mov  eax,2
485 heavyiron 432
    mcall
31 halyavin 433
    jmp  stillh
434
buttonh:
435
    mov  eax,17                 ; get id
485 heavyiron 436
    mcall
31 halyavin 437
    cmp  ah,1                   ; button id=1 ?
438
    je   close_app
439
    cmp  ah,2                   ; button id=1 ?
440
    je   start_game
441
    cmp  ah,3                   ; button id=1 ?
442
    je   help
443
    cmp  ah,4                   ; button id=1 ?
444
    je   close_app
445
    cmp  ah,5                   ; button id=1 ?
446
    je   main_menu
447
    jmp  stillh
448
 
449
draw_helpwindow:
450
    call draw_window
2062 dunkaist 451
    mcall 9,proc_info,-1
452
    test [proc_info+process_information.wnd_state], 0x04
453
    jnz  stillh
31 halyavin 454
    setimg 5,21,canvas
455
 
456
    drawfbox 40,50,580,380,cl_Grey
457
 
458
    mov ebp,4*7
459
    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
485 heavyiron 466
    mcall
31 halyavin 467
    add edx,esi
468
    add ebx,10
469
    dec ebp
470
    jnz looht
471
 
472
    setimg 90,90,ship
473
    setimg 90,130,shoot
474
    setimg 90,170,star
475
    setimg 90,210,warship1
476
    setimg 90,250,warship2
477
    setimg 90,290,meteor
478
    setimg 90,330,box
479
 
480
    drawlbut 500,400,80,14,'<
481
 
482
    jmp stillh
483
 
484
helptext:
485
    db 'Phenix                                            '
486
    db 'Controls: Num1 move left, Num3 move right         '
487
    db '          P-pause (use for screen shooting)       '
488
    db '                                                  '
489
 
490
    db 'Lazer cannon                                      '
491
    db 'Press Num5 for shoot                              '
492
    db 'Core fast, speed fast, reload slow                '
493
    db '                                                  '
494
 
495
    db 'Plazma cannon                                     '
496
    db 'Press Num2 for Plazma Nuke and Num8 for shoot     '
497
    db 'Core slow, speed medium, reload fast              '
498
    db '                                                  '
499
 
500
    db 'Blue warship                                      '
501
    db 'Speed fast                                        '
502
    db 'Attack method: plazma bomb                        '
503
    db '                                                  '
504
 
505
    db 'Green warship                                     '
506
    db 'Speed slow                                        '
507
    db 'Attack method: laser shoot                        '
508
    db '                                                  '
509
 
510
    db 'Meteor                                            '
511
    db 'Dangeros object!                                  '
512
    db 'SuperSheld                                        '
513
    db '                                                  '
514
 
515
    db 'Fly Box                                           '
516
    db 'Sheld pack, sheld +5, score +30                   '
517
    db 'Get for sheld level up!                           '
518
    db '                                                  '
519
 
520
start_game:
521
 
522
;    jmp end_gm
523
 
524
    mov [canvas],dword 640
525
    mov [canvas+4],dword 440
526
 
527
    call draw_window
528
 
529
;Main loop wait for event with 10msec
530
still:
531
;    scevent red,key,button ;for full speed
532
 
533
    timeevent 1,no_event,red,key,button
534
no_event:
2062 dunkaist 535
    mcall 9,proc_info,-1
536
    test [proc_info+process_information.wnd_state], 0x04
537
    jnz  still
31 halyavin 538
    setimg 5,21,canvas
539
 
540
    cmp [pause_on],0
541
    jne still
542
 
543
    cmp [energy],0
544
    jl  game_over
545
 
546
    cmp [ctime],dword 0
547
    je  no_dct
548
    dec dword [ctime]
549
no_dct:
550
 
551
    cmp [xtime],dword 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
564
    mov eax,[ebp]
565
    cmp [pathtime],eax ;500
566
    jne no_nextloc
567
 
568
randobjmasx:
569
    mov ebp,[levelpart]
570
    shl ebp,5
571
    add ebp,levels
572
 
573
    mov  ecx,[ebp+8]
574
    mov  [shiptype],2
575
    mov  [xmoving],9
576
    mov  [xaccel],4
577
    mov  [ymoving],3
578
    mov  [yaccel],2
579
    call add_ships
580
 
581
    mov  ecx,[ebp+12]
582
    mov  [shiptype],1
583
    mov  [xmoving],3
584
    mov  [xaccel],1
585
    mov  [ymoving],3
586
    mov  [yaccel],6
587
    call add_ships
588
 
589
    mov  ecx,[ebp+16]
590
    mov  [shiptype],3
591
    mov  [xmoving],5
592
    mov  [xaccel],2
593
    mov  [ymoving],5
594
    mov  [yaccel],2
595
    call add_ships
596
 
597
    mov  ecx,[ebp+20]
598
    mov  [shiptype],4
599
    mov  [xmoving],4
600
    mov  [xaccel],1
601
    mov  [ymoving],4
602
    mov  [yaccel],1
603
    call add_ships
604
 
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
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
623
; random x
624
    push edi
625
    random 600,eax
626
    pop edi
627
    mov [edi],eax
628
; random y
629
    push edi
630
    mov ebp,[levelpart]
631
    shl ebp,5
632
    add ebp,levels
633
    mov esi,[ebp+4] ;get max range
634
    random esi,eax
635
    neg eax
636
    pop edi
637
    mov [edi+4],eax
638
; x moving
639
    push edi         ;planers
640
    random [xmoving],eax
641
    sub eax,[xaccel];4
642
    pop edi
643
    mov [edi+12],eax
644
; y moving
645
    push edi
646
    random [ymoving],eax     ;slow
647
    add eax,[yaccel] ;2
648
    pop edi
649
    mov [edi+16],eax
650
    pop ecx
651
    dec ecx
652
    jnz looship
653
no_ships:
654
    ret
655
 
656
 
657
levelpart dd 0
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
668
;level2
669
    dd 1,16000,0,30,0,0,0,0     ;one at start
670
    dd 200,8000,0,20,0,0,0,0
671
    dd 200,2000,0,10,0,8,0,0
672
    dd 200,4000,0,10,0,0,0,0
673
    dd 0,0,0,0,0,0,0,0        ;end of level
674
;level3
675
    dd 1,4000,0,20,30,8,0,0     ;one at start
676
    dd 400,4000,10,10,20,6,0,0
677
    dd 400,4000,0,20,10,2,0,0
678
    dd 400,4000,10,10,20,0,0,0
679
    dd 0,-1,0,0,0,0,0,0        ;end of game
680
 
681
 
682
newlocend:
683
    mov [pathtime],0
684
    inc [levelpart]
685
    jmp no_nextloc
686
 
687
endgame dd 0
688
objects dd 0
689
endtest:
690
    cmp dword [edi+8],0
691
    jne no_free
692
    ret
693
no_free:
694
    mov [endgame],0
695
    inc [objects]
696
    ret
697
 
698
 
699
no_nextloc:
700
    mov [objects],0
701
    mov [endgame],1
702
    readmas objmas,endtest
703
    cmp [endgame],1
704
    jne no_end_lev ;no_nextloc
705
 
706
    mov ebp,[levelpart]
707
    shl ebp,5
708
    add ebp,levels
709
    mov eax,[ebp+4]
710
    cmp eax,dword 0
711
    je  end_lev    ;end of level
712
    cmp eax,dword -1
713
    je  end_gm    ;end of game
714
 
715
no_end_lev:
716
 
717
    cmp [num5],dword 0
718
    je  no_addsh
719
    cmp [ctime],dword 0
720
    jne no_addsh
721
    cmp [lazer],dword 0
722
    je  no_addsh
723
    findmas massive,findzero
724
;in edi off to free element
725
    jc  close_app
726
    mov eax,[shipx]
727
    mov [edi],eax
728
    mov eax,[shipy]
729
    mov [edi+4],eax
730
    mov [edi+8],dword 1   ;show
731
    mov [edi+12],dword 0
732
    mov [edi+16],dword -12
733
    mov [ctime],dword 8   ;wait for cannon
734
    dec [lazer]
735
no_addsh:
736
 
737
    cmp [num8],dword 0
738
    je  no_addplx
739
    cmp [xtime],dword 256-16
740
    jae no_addplx
741
    cmp [plazma],0
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
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
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
485 heavyiron 894
    mcall                   ; read (eax=2)
31 halyavin 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
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
485 heavyiron 966
    mcall
31 halyavin 967
    cmp  ah,1                   ; button id=1 ?
968
    jne  noclose
969
close_app:
970
    mov  eax,-1                 ; close this program
485 heavyiron 971
    mcall
31 halyavin 972
  noclose:
973
    jmp  still
974
 
975
draw_window:
2677 leency 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
 
31 halyavin 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
485 heavyiron 999
    mcall
31 halyavin 1000
    jmp  stillgo
1001
buttongo:
1002
    mov  eax,17                 ; get id
485 heavyiron 1003
    mcall
31 halyavin 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
2062 dunkaist 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
  @@:
31 halyavin 1071
    drawfbox 170,160,300,120,cl_Grey
2678 leency 1072
    drawlbut 180,260,80,14,'EXIT',4,0x990000,cl_Black
1073
    drawlbut 280,260,80,14,'MENU',5,0x990000,cl_Black
31 halyavin 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
485 heavyiron 1096
    mcall
31 halyavin 1097
    jmp  stilleg
1098
buttoneg:
1099
    mov  eax,17                 ; get id
485 heavyiron 1100
    mcall
31 halyavin 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
2062 dunkaist 1139
    mcall 9,proc_info,-1
1140
    test [proc_info+process_information.wnd_state], 0x04
1141
    jz   @f
1142
    ret
1143
  @@:
31 halyavin 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
 
1188
    readmas massive,endshowmas
1189
    readmas massive,endmovemas
1190
    readmas massive,delfarshoot
1191
;    findmas massive,findzero
1192
;in edi off to free element
1193
;    jc  close_app
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
1216
    sub eax,2
1217
    cmp eax,0
1218
    je  rerand
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
485 heavyiron 1235
    mcall
31 halyavin 1236
    jmp  main_menu
1237
buttoneg2:
1238
    mov  eax,17                 ; get id
485 heavyiron 1239
    mcall
31 halyavin 1240
    jmp  stilleg2
1241
 
1242
 
1243
 
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
1264
num2 dd 0
1265
num8 dd 0
1266
 
1267
;enemy countres
1268
gship  dd 0
1269
bship  dd 0
1270
boxget dd 0
1271
 
1272
energy dd 100
1273
score  dd 0
1274
 
1275
;delay for cannon
1276
ctime dd 0
1277
;delay for nuke gun
1278
xtime dd 0
1279
;path time
1280
pathtime dd 0
1281
;
1282
temp  dd 0
1283
temp2 dd 0
1284
temp3 dd 0
1285
temp4 dd 0
1286
otv dd 0
1287
 
1288
;for collimg
1289
imgsize:
1290
 dd 32
1291
 dd 32
1292
 
1293
;massive:
1294
;dd 400  ;elements num
1295
;dd 20  ;size of element in bytes
1296
;rb 400*20
1297
 
1298
keymap:
1299
rb 1000
1300
 
2677 leency 1301
wtitle db 'Phenix for KolibriOS', 0
1302
 
31 halyavin 1303
;gif_file_area ~21500
1304
gif_file_area2:
1305
file 'phenix.gif'
1306
gif_file_area:
1307
file 'star2.gif';include gif file
1308
img_area:
1309
rb 256*64*3+8
1310
ship:
1311
rb 32*32*3+8
1312
shoot:
1313
rb 32*32*3+8
1314
warship1:
1315
rb 32*32*3+8
1316
warship2:
1317
rb 32*32*3+8
1318
meteor:
1319
rb 32*32*3+8
1320
star:
1321
rb 32*32*3+8
1322
star2:
1323
rb 32*32*3+8
1324
star3:
1325
rb 32*32*3+8
1326
box:
1327
rb 32*32*3+8
1328
 
552 diamond 1329
IncludeUGlobals
31 halyavin 1330
 
1331
massive:
1332
rd massize  ;elements num
1333
rd elemsize  ;size of element in bytes
1334
rb massize*elemsize
1335
 
1336
objmas:
1337
rd omassize  ;elements num
1338
rd oelemsize  ;size of element in bytes
1339
rb omassize*oelemsize
1340
 
1341
canvas:
1342
canvas_x:
1343
 rd 1
1344
canvas_y:
1345
 rd 1
1346
rb (640*440*3)+2000
2062 dunkaist 1347
 
1348
proc_info:
1349
rb 1024
31 halyavin 1350
I_END: