Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 552 | 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'
485 heavyiron 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
    gif_hash_offset = gif_hash_area
364
    giftoimg gif_file_area2,canvas
365
 
366
    gif_hash_offset = gif_hash_area
367
    giftoimg gif_file_area,img_area
368
 
369
    getimg img_area,0,0,32,32,ship
370
    getimg img_area,32,0,32,32,shoot
371
    getimg img_area,64,0,32,32,warship1
372
    getimg img_area,96,0,32,32,warship2
373
    getimg img_area,128,0,32,32,meteor
374
    getimg img_area,160,0,32,32,star
375
    getimg img_area,192,0,32,32,star2
376
    getimg img_area,224,0,32,32,star3
377
    getimg img_area,0,32,32,32,box
378
 
379
 
380
 
381
main_menu:
382
    call draw_logowindow
383
 
384
stillm:
385
    wtevent redm,keym,buttonm
386
    jmp stillm
387
redm:
388
    call draw_logowindow
389
    jmp stillm
390
keym:
391
    mov  eax,2
485 heavyiron 392
    mcall
31 halyavin 393
    jmp  stillm
394
buttonm:
395
    mov  eax,17                 ; get id
485 heavyiron 396
    mcall
31 halyavin 397
    cmp  ah,1                   ; button id=1 ?
398
    je   close_app
399
    cmp  ah,2                   ; button id=1 ?
400
    je   start_game
401
    cmp  ah,3                   ; button id=1 ?
402
    je   help
403
    cmp  ah,4                   ; button id=1 ?
404
    je   close_app
405
    jmp  stillm
406
 
407
draw_logowindow:
408
    call draw_window
409
    setimg 5,21,canvas
410
    drawlbut 300,300,60,14,'START',2,0x990000,cl_Black
411
    drawlbut 300,320,60,14,'HELP',3,0x990000,cl_Black
412
    drawlbut 300,340,60,14,'EXIT',4,0x990000,cl_Black
413
    ret
414
 
415
;***********************
416
; Draw help menu
417
;***********************
418
 
419
help:
420
    call draw_helpwindow
421
 
422
stillh:
423
    wtevent redh,keyh,buttonh
424
    jmp stillh
425
redh:
426
    call draw_helpwindow
427
    jmp stillh
428
keyh:
429
    mov  eax,2
485 heavyiron 430
    mcall
31 halyavin 431
    jmp  stillh
432
buttonh:
433
    mov  eax,17                 ; get id
485 heavyiron 434
    mcall
31 halyavin 435
    cmp  ah,1                   ; button id=1 ?
436
    je   close_app
437
    cmp  ah,2                   ; button id=1 ?
438
    je   start_game
439
    cmp  ah,3                   ; button id=1 ?
440
    je   help
441
    cmp  ah,4                   ; button id=1 ?
442
    je   close_app
443
    cmp  ah,5                   ; button id=1 ?
444
    je   main_menu
445
    jmp  stillh
446
 
447
draw_helpwindow:
448
    call draw_window
449
    setimg 5,21,canvas
450
 
451
    drawfbox 40,50,580,380,cl_Grey
452
 
453
    mov ebp,4*7
454
    mov ebx,180*65536+90
455
    mov edx,helptext
456
    mov esi,50
457
    mov ecx,cl_White
458
    dec ebp
459
looht:
460
    mov eax,4
485 heavyiron 461
    mcall
31 halyavin 462
    add edx,esi
463
    add ebx,10
464
    dec ebp
465
    jnz looht
466
 
467
    setimg 90,90,ship
468
    setimg 90,130,shoot
469
    setimg 90,170,star
470
    setimg 90,210,warship1
471
    setimg 90,250,warship2
472
    setimg 90,290,meteor
473
    setimg 90,330,box
474
 
475
    drawlbut 500,400,80,14,'<
476
 
477
    jmp stillh
478
 
479
helptext:
480
    db 'Phenix                                            '
481
    db 'Controls: Num1 move left, Num3 move right         '
482
    db '          P-pause (use for screen shooting)       '
483
    db '                                                  '
484
 
485
    db 'Lazer cannon                                      '
486
    db 'Press Num5 for shoot                              '
487
    db 'Core fast, speed fast, reload slow                '
488
    db '                                                  '
489
 
490
    db 'Plazma cannon                                     '
491
    db 'Press Num2 for Plazma Nuke and Num8 for shoot     '
492
    db 'Core slow, speed medium, reload fast              '
493
    db '                                                  '
494
 
495
    db 'Blue warship                                      '
496
    db 'Speed fast                                        '
497
    db 'Attack method: plazma bomb                        '
498
    db '                                                  '
499
 
500
    db 'Green warship                                     '
501
    db 'Speed slow                                        '
502
    db 'Attack method: laser shoot                        '
503
    db '                                                  '
504
 
505
    db 'Meteor                                            '
506
    db 'Dangeros object!                                  '
507
    db 'SuperSheld                                        '
508
    db '                                                  '
509
 
510
    db 'Fly Box                                           '
511
    db 'Sheld pack, sheld +5, score +30                   '
512
    db 'Get for sheld level up!                           '
513
    db '                                                  '
514
 
515
start_game:
516
 
517
;    jmp end_gm
518
 
519
    mov [canvas],dword 640
520
    mov [canvas+4],dword 440
521
 
522
    call draw_window
523
 
524
;Main loop wait for event with 10msec
525
still:
526
;    scevent red,key,button ;for full speed
527
 
528
    timeevent 1,no_event,red,key,button
529
no_event:
530
    setimg 5,21,canvas
531
 
532
    cmp [pause_on],0
533
    jne still
534
 
535
    cmp [energy],0
536
    jl  game_over
537
 
538
    cmp [ctime],dword 0
539
    je  no_dct
540
    dec dword [ctime]
541
no_dct:
542
 
543
    cmp [xtime],dword 0
544
    je  no_dxt
545
    dec dword [xtime]
546
no_dxt:
547
 
548
 
549
;
550
;   Add to level new ships
551
;
552
    inc dword [pathtime]
553
    mov ebp,[levelpart]
554
    shl ebp,5
555
    add ebp,levels
556
    mov eax,[ebp]
557
    cmp [pathtime],eax ;500
558
    jne no_nextloc
559
 
560
randobjmasx:
561
    mov ebp,[levelpart]
562
    shl ebp,5
563
    add ebp,levels
564
 
565
    mov  ecx,[ebp+8]
566
    mov  [shiptype],2
567
    mov  [xmoving],9
568
    mov  [xaccel],4
569
    mov  [ymoving],3
570
    mov  [yaccel],2
571
    call add_ships
572
 
573
    mov  ecx,[ebp+12]
574
    mov  [shiptype],1
575
    mov  [xmoving],3
576
    mov  [xaccel],1
577
    mov  [ymoving],3
578
    mov  [yaccel],6
579
    call add_ships
580
 
581
    mov  ecx,[ebp+16]
582
    mov  [shiptype],3
583
    mov  [xmoving],5
584
    mov  [xaccel],2
585
    mov  [ymoving],5
586
    mov  [yaccel],2
587
    call add_ships
588
 
589
    mov  ecx,[ebp+20]
590
    mov  [shiptype],4
591
    mov  [xmoving],4
592
    mov  [xaccel],1
593
    mov  [ymoving],4
594
    mov  [yaccel],1
595
    call add_ships
596
 
597
    jmp newlocend
598
 
599
shiptype dd 0
600
xmoving  dd 0
601
ymoving  dd 0
602
xaccel   dd 0
603
yaccel   dd 0
604
 
605
add_ships:
606
looship:
607
    cmp ecx,0
608
    je  no_ships
609
    push ecx
610
    findmas objmas,findzero
611
;in edi off to free element
612
    jc  close_app
613
    mov ebp,[shiptype]
614
    mov dword [edi+8],ebp ;2 ;green ship
615
; random x
616
    push edi
617
    random 600,eax
618
    pop edi
619
    mov [edi],eax
620
; random y
621
    push edi
622
    mov ebp,[levelpart]
623
    shl ebp,5
624
    add ebp,levels
625
    mov esi,[ebp+4] ;get max range
626
    random esi,eax
627
    neg eax
628
    pop edi
629
    mov [edi+4],eax
630
; x moving
631
    push edi         ;planers
632
    random [xmoving],eax
633
    sub eax,[xaccel];4
634
    pop edi
635
    mov [edi+12],eax
636
; y moving
637
    push edi
638
    random [ymoving],eax     ;slow
639
    add eax,[yaccel] ;2
640
    pop edi
641
    mov [edi+16],eax
642
    pop ecx
643
    dec ecx
644
    jnz looship
645
no_ships:
646
    ret
647
 
648
 
649
levelpart dd 0
650
levels:
651
;level1
652
    dd 1,800,0,0,5,8,0,0     ;one at start
653
    dd 500,2000,4,20,30,0,0,0
654
    dd 500,2000,4,20,0,8,0,0
655
    dd 500,2000,10,0,0,4,0,0
656
    dd 500,4000,0,30,0,0,0,0
657
    dd 400,400,0,0,10,0,0,0
658
    dd 400,400,0,0,10,0,0,0
659
    dd 0,0,0,0,0,0,0,0        ;end of level
660
;level2
661
    dd 1,16000,0,30,0,0,0,0     ;one at start
662
    dd 200,8000,0,20,0,0,0,0
663
    dd 200,2000,0,10,0,8,0,0
664
    dd 200,4000,0,10,0,0,0,0
665
    dd 0,0,0,0,0,0,0,0        ;end of level
666
;level3
667
    dd 1,4000,0,20,30,8,0,0     ;one at start
668
    dd 400,4000,10,10,20,6,0,0
669
    dd 400,4000,0,20,10,2,0,0
670
    dd 400,4000,10,10,20,0,0,0
671
    dd 0,-1,0,0,0,0,0,0        ;end of game
672
 
673
 
674
newlocend:
675
    mov [pathtime],0
676
    inc [levelpart]
677
    jmp no_nextloc
678
 
679
endgame dd 0
680
objects dd 0
681
endtest:
682
    cmp dword [edi+8],0
683
    jne no_free
684
    ret
685
no_free:
686
    mov [endgame],0
687
    inc [objects]
688
    ret
689
 
690
 
691
no_nextloc:
692
    mov [objects],0
693
    mov [endgame],1
694
    readmas objmas,endtest
695
    cmp [endgame],1
696
    jne no_end_lev ;no_nextloc
697
 
698
    mov ebp,[levelpart]
699
    shl ebp,5
700
    add ebp,levels
701
    mov eax,[ebp+4]
702
    cmp eax,dword 0
703
    je  end_lev    ;end of level
704
    cmp eax,dword -1
705
    je  end_gm    ;end of game
706
 
707
no_end_lev:
708
 
709
    cmp [num5],dword 0
710
    je  no_addsh
711
    cmp [ctime],dword 0
712
    jne no_addsh
713
    cmp [lazer],dword 0
714
    je  no_addsh
715
    findmas massive,findzero
716
;in edi off to free element
717
    jc  close_app
718
    mov eax,[shipx]
719
    mov [edi],eax
720
    mov eax,[shipy]
721
    mov [edi+4],eax
722
    mov [edi+8],dword 1   ;show
723
    mov [edi+12],dword 0
724
    mov [edi+16],dword -12
725
    mov [ctime],dword 8   ;wait for cannon
726
    dec [lazer]
727
no_addsh:
728
 
729
    cmp [num8],dword 0
730
    je  no_addplx
731
    cmp [xtime],dword 256-16
732
    jae no_addplx
733
    cmp [plazma],0
734
    je  no_addplx
735
    findmas massive,findzero
736
;in edi off to free element
737
    jc  close_app
738
    mov eax,[shipx]
739
    mov [edi],eax
740
    mov eax,[shipy]
741
    mov [edi+4],eax
742
    mov [edi+8],dword 2   ;show
743
    add [xtime],dword 8  ;wait for cannon
744
    cmp [xtime],dword 256
745
    jna okx
746
    mov [xtime],256
747
okx:
748
    mov [edi+12],dword 0  ;wait for cannon
749
    mov [edi+16],dword -8  ;wait for cannon
750
    dec [plazma]
751
no_addplx:
752
 
753
 
754
 
755
    cmp [num2],dword 0
756
    je  no_addsh2
757
    cmp [xtime],dword 0
758
    jne no_addsh2
759
    cmp [plazma],0
760
    je  no_addsh2
761
    mov eax,[shipy]
762
    mov [temp3],eax
763
    mov [temp2],dword 5
764
loox2:
765
    mov [temp],dword 10
766
loox:
767
    findmas massive,findzero
768
;in edi off to free element
769
    jc  close_app
770
    random 25,eax
771
    mov ebp,eax
772
    sub eax,12
773
    add eax,[shipx]
774
    mov [edi],eax
775
    shr ebp,3
776
    random ebp,eax
777
    neg eax
778
    add eax,[temp3] ;[shipy]
779
    mov [edi+4],eax
780
    mov [edi+8],dword 2   ;show hstar
781
    random 5,eax
782
    sub eax,2
783
    mov [edi+12],eax   ;show hstar
784
    random 7,eax
785
    sub eax,8
786
    mov [edi+16],eax   ;show hstar
787
    dec [temp]
788
    jnz loox
789
    sub [temp3],30
790
    dec [temp2]
791
    jnz loox2
792
    mov [xtime],dword 256  ;wait for cannon
793
    sub [plazma],50
794
no_addsh2:
795
 
796
 
797
    cmp [num1],dword 0
798
    je  no_left
799
    sub dword [shipx],6
800
no_left:
801
 
802
    cmp [num3],dword 0
803
    je  no_right
804
    add dword [shipx],6
805
no_right:
806
 
807
;ship correct
808
    cmp [shipx],5
809
    jnl xl_ok
810
    mov [shipx],5
811
xl_ok:
812
    cmp [shipx],603
813
    jng xr_ok
814
    mov [shipx],603
815
xr_ok:
816
 
817
 
818
;clear scrbuf
819
    mov edi,canvas+8
820
    cld
821
    mov ecx,640*440*3/4
822
    mov eax,0
823
    rep stosd
824
 
825
    compmas objmas,massive,compobr
826
 
827
    readmas objmas,shipobjtest
828
    readmas massive,shipguntest
829
 
830
    readmas objmas,showobjmas
831
    readmas objmas,moveobjmas
832
 
833
    readmas massive,showmas
834
    readmas massive,movemas
835
    readmas massive,delfarshoot
836
;    findmas massive,findzero
837
;in edi off to free element
838
;    jc  close_app
839
 
840
    aimgtoimg ship,[shipx],[shipy],canvas,0x0
841
 
842
    drawfbox 150,5,64,5,0x000000
843
    mov eax,[xtime]
844
    sub eax,256
845
    neg eax
846
    shr eax,2
847
    drawfbox 150,5,eax,5,0x0000ff
848
 
849
    drawfbox 150,12,64,5,0x000000
850
    mov eax,[ctime]
851
    sub eax,8
852
    neg eax
853
    shl eax,3
854
    drawfbox 150,12,eax,5,0xffff00
855
 
856
    drawfbox 220,2,6*5+2 ,9,cl_Grey
857
    outcount [plazma],221,3,cl_Blue,5*65536
858
    drawfbox 220,11,6*5+2 ,9,cl_Grey
859
    outcount [lazer],221,12,0xffff00,5*65536
860
 
861
 
862
    drawfbox 280,6,6*5+2 ,9,cl_Grey
863
    outcount [gship],281,7,cl_Green,5*65536
864
    drawfbox 320,6,6*5+2 ,9,cl_Grey
865
    outcount [bship],321,7,cl_Blue,5*65536
866
    drawfbox 360,6,6*5+2 ,9,cl_Grey
867
    outcount [boxget],361,7,0xffaa00,5*65536
868
 
869
    drawfbox 400,2,6*5+2 ,9,cl_Grey
870
    outcount [objects],401,2,0x00ff00,5*65536
871
    drawfbox 400,11,6*5+2 ,9,cl_Grey
872
    outcount [energy],401,12,0xff0000,5*65536
873
 
874
    drawfbox 450,11,6*5+2 ,9,cl_Grey
875
    outcount [score],451,12,0xffff00,5*65536
876
 
877
 
878
    jmp  still
879
 
880
  red:
881
    call draw_window
882
    jmp still
883
 
884
  key:                          ; key
885
    mov  eax,2
485 heavyiron 886
    mcall                   ; read (eax=2)
31 halyavin 887
 
888
    shr eax,8
889
    and eax,0xff
890
    mov ah,al
891
 
892
    cmp ah,153
893
    jne no_pause
894
    not [pause_on]
895
    jmp still
896
no_pause:
897
 
898
 
899
    cmp ah,76
900
    jne no_num5d
901
    mov [num5],1
902
    jmp still
903
no_num5d:
904
    cmp ah,204
905
    jne no_num5u
906
    mov [num5],0
907
    jmp still
908
no_num5u:
909
 
910
    cmp ah,80
911
    jne no_num2d
912
    mov [num2],1
913
    jmp still
914
no_num2d:
915
    cmp ah,208
916
    jne no_num2u
917
    mov [num2],0
918
    jmp still
919
no_num2u:
920
 
921
    cmp ah,79 ;key_Space 85 exit
922
    jne no_num1d
923
    mov [num1],1
924
    jmp still
925
no_num1d:
926
    cmp ah,207 ;key_Space 85 exit
927
    jne no_num1u
928
    mov [num1],0
929
    jmp still
930
no_num1u:
931
 
932
    cmp ah,81 ;key_Space 85 exit
933
    jne no_num3d
934
    mov [num3],1
935
    jmp still
936
no_num3d:
937
    cmp ah,209 ;key_Space 85 exit
938
    jne no_num3u
939
    mov [num3],0
940
    jmp still
941
no_num3u:
942
 
943
    cmp ah,72  ;key_Space 85 exit
944
    jne no_num8d
945
    mov [num8],1
946
    jmp still
947
no_num8d:
948
    cmp ah,200 ;key_Space 85 exit
949
    jne no_num8u
950
    mov [num8],0
951
    jmp still
952
no_num8u:
953
 
954
    jmp  still                  ; not testing
955
 
956
  button:                       ; button
957
    mov  eax,17                 ; get id
485 heavyiron 958
    mcall
31 halyavin 959
    cmp  ah,1                   ; button id=1 ?
960
    jne  noclose
961
close_app:
962
    mov  eax,-1                 ; close this program
485 heavyiron 963
    mcall
31 halyavin 964
  noclose:
965
    jmp  still
966
 
967
draw_window:
968
    startwd
969
    window 40,40,(640+9),(440+26),window_Skinned+0x00
970
    label  8,8,'ASCL DYNAMIC GAME',cl_White+font_Big
971
;    setimg 5,22,img_area
972
    endwd
973
    ret
974
 
975
;**********************
976
;  Game Over process
977
;**********************
978
 
979
game_over:
980
;    close
981
    call draw_gowindow
982
stillgo:
983
    wtevent redgo,keygo,buttongo
984
    jmp stillgo
985
redgo:
986
    call draw_gowindow
987
    jmp stillgo
988
keygo:
989
    mov  eax,2
485 heavyiron 990
    mcall
31 halyavin 991
    jmp  stillgo
992
buttongo:
993
    mov  eax,17                 ; get id
485 heavyiron 994
    mcall
31 halyavin 995
    cmp  ah,1
996
    je   close_app
997
    cmp  ah,4
998
    je   close_app
999
    cmp  ah,5
1000
    je   main_menu
1001
    cmp  ah,7
1002
    je   restart_lev
1003
    jmp  stillgo
1004
 
1005
restart_lev:
1006
    mov [pathtime],0
1007
 
1008
prevpart:
1009
    mov ebp,[levelpart]
1010
    shl ebp,5
1011
    add ebp,levels
1012
    mov eax,[ebp]
1013
    cmp eax,dword 1
1014
    je  rest    ;end of level
1015
    dec [levelpart]
1016
    jmp prevpart
1017
 
1018
 
1019
rest:
1020
;massives reset - clear massives
1021
    mov edi,massive+8
1022
    cld
1023
    mov ecx,massize*elemsize/4
1024
    mov eax,0
1025
    rep stosd
1026
 
1027
    mov edi,objmas+8
1028
    cld
1029
    mov ecx,omassize*oelemsize/4
1030
    mov eax,0
1031
    rep stosd
1032
 
1033
;counters reset
1034
    mov [boxget],0
1035
    mov [gship],0
1036
    mov [bship],0
1037
 
1038
;ship reset
1039
    mov [energy],100
1040
    mov [shipx],300
1041
    mov [shipy],400
1042
    mov [lazer],1000
1043
    mov [plazma],500
1044
 
1045
 
1046
; reset keyboard
1047
    mov [num1],0
1048
    mov [num5],0
1049
    mov [num3],0
1050
    mov [num2],0
1051
    mov [num8],0
1052
    jmp start_game
1053
 
1054
draw_gowindow:
1055
    startwd
1056
    drawfbox 170,160,300,120,cl_Grey
1057
    drawlbut 180,260,80,14,'(X) EXIT',4,0x990000,cl_Black
1058
    drawlbut 280,260,80,14,'',5,0x990000,cl_Black
1059
    drawlbut 380,260,80,14,'RESTART',7,0x990000,cl_Black
1060
 
1061
    label 280,200,'  GAME OVER  ',cl_Black
1062
    endwd
1063
    ret
1064
 
1065
 
1066
;**********************
1067
;  End level process
1068
;**********************
1069
 
1070
end_lev:
1071
;    close
1072
    call draw_scorewindow
1073
stilleg:
1074
    wtevent redeg,keyeg,buttoneg
1075
    jmp stilleg
1076
redeg:
1077
    call draw_scorewindow
1078
    jmp stilleg
1079
keyeg:
1080
    mov  eax,2
485 heavyiron 1081
    mcall
31 halyavin 1082
    jmp  stilleg
1083
buttoneg:
1084
    mov  eax,17                 ; get id
485 heavyiron 1085
    mcall
31 halyavin 1086
    cmp  ah,1
1087
    je   close_app
1088
    cmp  ah,2
1089
    je   next_lev
1090
    cmp  ah,3
1091
    je   help
1092
    cmp  ah,4
1093
    je   close_app
1094
    cmp  ah,5
1095
    je   main_menu
1096
    jmp  stilleg
1097
 
1098
next_lev:
1099
    mov [pathtime],0
1100
    inc [levelpart]
1101
 
1102
;ship reset
1103
    mov [energy],100
1104
    mov [shipx],300
1105
    mov [shipy],400
1106
    mov [lazer],1000
1107
    mov [plazma],500
1108
 
1109
;counters reset
1110
    mov [boxget],0
1111
    mov [gship],0
1112
    mov [bship],0
1113
 
1114
; reset keyboard
1115
    mov [num1],0
1116
    mov [num5],0
1117
    mov [num3],0
1118
    mov [num2],0
1119
    mov [num8],0
1120
    jmp start_game
1121
 
1122
draw_scorewindow:
1123
    call draw_window
1124
    startwd
1125
    drawfbox 170,130,300,190,cl_Grey
1126
    drawlbut 180,300,80,14,'(X) EXIT',4,0x990000,cl_Black
1127
    drawlbut 280,300,80,14,'',5,0x990000,cl_Black
1128
    drawlbut 380,300,80,14,'NEXT >>',2,0x990000,cl_Black
1129
 
1130
    setimg 180,140,warship1
1131
    outcount [bship],241,151,cl_Blue,5*65536
1132
 
1133
    setimg 180,180,warship2
1134
    outcount [gship],241,191,cl_Green,5*65536
1135
 
1136
    setimg 180,220,meteor
1137
    setimg 180,260,box
1138
    outcount [boxget],241,271,0xbbbb00,5*65536
1139
    endwd
1140
    ret
1141
 
1142
 
1143
;**********************
1144
;  End of game process
1145
;**********************
1146
 
1147
end_gm:
1148
    mov [pathtime],0
1149
    call draw_window
1150
    label 200 ,8,'YOU WIN PRESS ANY KEY TO EXIT',cl_White+font_Big
1151
 
1152
stilleg2:
1153
;    scevent   redeg2,keyeg2,buttoneg2
1154
    timeevent 1,no_event2,redeg2,keyeg2,buttoneg2
1155
 
1156
no_event2:
1157
    setimg 5,21,canvas
1158
 
1159
;clear scrbuf
1160
    mov edi,canvas+8
1161
    cld
1162
    mov ecx,640*440*3/4
1163
    mov eax,0
1164
    rep stosd
1165
 
1166
    aimgtoimg ship,320,220,canvas,0x0
1167
 
1168
    readmas massive,endshowmas
1169
    readmas massive,endmovemas
1170
    readmas massive,delfarshoot
1171
;    findmas massive,findzero
1172
;in edi off to free element
1173
;    jc  close_app
1174
 
1175
    inc [pathtime]
1176
    cmp [pathtime],30
1177
    jne no_firework
1178
    mov [pathtime],0
1179
    random 400,eax
1180
    mov [temp3],eax
1181
    random 600,eax
1182
    mov [temp2],eax
1183
    mov [temp],dword 8;10
1184
xloox:
1185
    findmas massive,findzero
1186
;in edi off to free element
1187
    jc  close_app
1188
 
1189
    mov eax,[temp2] ;[shipx]
1190
    mov [edi],eax
1191
    mov eax,[temp3] ;[shipy]
1192
    mov [edi+4],eax
1193
    mov [edi+8],dword 2   ;show hstar
1194
rerand:
1195
    random 5,eax
1196
    sub eax,2
1197
    cmp eax,0
1198
    je  rerand
1199
    mov [edi+12],eax   ;show hstar
1200
rerand2:
1201
    random 7,eax
1202
    sub eax,3
1203
    cmp eax,0
1204
    je  rerand2
1205
    mov [edi+16],eax   ;show hstar
1206
    dec [temp]
1207
    jnz xloox
1208
no_firework:
1209
    jmp stilleg2
1210
 
1211
redeg2:
1212
    jmp end_gm ;stilleg2
1213
keyeg2:
1214
    mov  eax,2
485 heavyiron 1215
    mcall
31 halyavin 1216
    jmp  main_menu
1217
buttoneg2:
1218
    mov  eax,17                 ; get id
485 heavyiron 1219
    mcall
31 halyavin 1220
    jmp  stilleg2
1221
 
1222
 
1223
 
1224
 
1225
 
1226
 
1227
; DATA AREA
1228
IM_END:
1229
;global
1230
pause_on dd 0
1231
 
1232
;massive
1233
shipx dd 300
1234
shipy dd 400
1235
 
1236
;guns
1237
lazer  dd 1000
1238
plazma dd 500
1239
 
1240
;keys
1241
num1 dd 0
1242
num5 dd 0
1243
num3 dd 0
1244
num2 dd 0
1245
num8 dd 0
1246
 
1247
;enemy countres
1248
gship  dd 0
1249
bship  dd 0
1250
boxget dd 0
1251
 
1252
energy dd 100
1253
score  dd 0
1254
 
1255
;delay for cannon
1256
ctime dd 0
1257
;delay for nuke gun
1258
xtime dd 0
1259
;path time
1260
pathtime dd 0
1261
;
1262
temp  dd 0
1263
temp2 dd 0
1264
temp3 dd 0
1265
temp4 dd 0
1266
otv dd 0
1267
 
1268
;for collimg
1269
imgsize:
1270
 dd 32
1271
 dd 32
1272
 
1273
;massive:
1274
;dd 400  ;elements num
1275
;dd 20  ;size of element in bytes
1276
;rb 400*20
1277
 
1278
 
1279
keymap:
1280
rb 1000
1281
 
1282
;gif_file_area ~21500
1283
gif_file_area2:
1284
file 'phenix.gif'
1285
rb 50
1286
gif_file_area:
1287
file 'star2.gif';include gif file
1288
rb 50          ;50 bytes temp back zone
1289
img_area:
1290
rb 256*64*3+8
1291
ship:
1292
rb 32*32*3+8
1293
shoot:
1294
rb 32*32*3+8
1295
warship1:
1296
rb 32*32*3+8
1297
warship2:
1298
rb 32*32*3+8
1299
meteor:
1300
rb 32*32*3+8
1301
star:
1302
rb 32*32*3+8
1303
star2:
1304
rb 32*32*3+8
1305
star3:
1306
rb 32*32*3+8
1307
box:
1308
rb 32*32*3+8
1309
 
1310
gif_hash_area:
1311
rd 4096+1      ;hash area size for unpacking GIF
1312
 
1313
massive:
1314
rd massize  ;elements num
1315
rd elemsize  ;size of element in bytes
1316
rb massize*elemsize
1317
 
1318
objmas:
1319
rd omassize  ;elements num
1320
rd oelemsize  ;size of element in bytes
1321
rb omassize*oelemsize
1322
 
1323
canvas:
1324
canvas_x:
1325
 rd 1
1326
canvas_y:
1327
 rd 1
1328
rb (640*440*3)+2000
1329
I_END: