Subversion Repositories Kolibri OS

Rev

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

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