Subversion Repositories Kolibri OS

Rev

Rev 552 | Rev 2678 | 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:
976
    startwd
977
    window 40,40,(640+9),(440+26),window_Skinned+0x00
978
    label  8,8,'ASCL DYNAMIC GAME',cl_White+font_Big
979
;    setimg 5,22,img_area
980
    endwd
981
    ret
982
 
983
;**********************
984
;  Game Over process
985
;**********************
986
 
987
game_over:
988
;    close
989
    call draw_gowindow
990
stillgo:
991
    wtevent redgo,keygo,buttongo
992
    jmp stillgo
993
redgo:
994
    call draw_gowindow
995
    jmp stillgo
996
keygo:
997
    mov  eax,2
485 heavyiron 998
    mcall
31 halyavin 999
    jmp  stillgo
1000
buttongo:
1001
    mov  eax,17                 ; get id
485 heavyiron 1002
    mcall
31 halyavin 1003
    cmp  ah,1
1004
    je   close_app
1005
    cmp  ah,4
1006
    je   close_app
1007
    cmp  ah,5
1008
    je   main_menu
1009
    cmp  ah,7
1010
    je   restart_lev
1011
    jmp  stillgo
1012
 
1013
restart_lev:
1014
    mov [pathtime],0
1015
 
1016
prevpart:
1017
    mov ebp,[levelpart]
1018
    shl ebp,5
1019
    add ebp,levels
1020
    mov eax,[ebp]
1021
    cmp eax,dword 1
1022
    je  rest    ;end of level
1023
    dec [levelpart]
1024
    jmp prevpart
1025
 
1026
 
1027
rest:
1028
;massives reset - clear massives
1029
    mov edi,massive+8
1030
    cld
1031
    mov ecx,massize*elemsize/4
1032
    mov eax,0
1033
    rep stosd
1034
 
1035
    mov edi,objmas+8
1036
    cld
1037
    mov ecx,omassize*oelemsize/4
1038
    mov eax,0
1039
    rep stosd
1040
 
1041
;counters reset
1042
    mov [boxget],0
1043
    mov [gship],0
1044
    mov [bship],0
1045
 
1046
;ship reset
1047
    mov [energy],100
1048
    mov [shipx],300
1049
    mov [shipy],400
1050
    mov [lazer],1000
1051
    mov [plazma],500
1052
 
1053
 
1054
; reset keyboard
1055
    mov [num1],0
1056
    mov [num5],0
1057
    mov [num3],0
1058
    mov [num2],0
1059
    mov [num8],0
1060
    jmp start_game
1061
 
1062
draw_gowindow:
1063
    startwd
2062 dunkaist 1064
    call draw_window
1065
    mcall 9,proc_info,-1
1066
    test [proc_info+process_information.wnd_state], 0x04
1067
    jz   @f
1068
    ret
1069
  @@:
31 halyavin 1070
    drawfbox 170,160,300,120,cl_Grey
1071
    drawlbut 180,260,80,14,'(X) EXIT',4,0x990000,cl_Black
1072
    drawlbut 280,260,80,14,'',5,0x990000,cl_Black
1073
    drawlbut 380,260,80,14,'RESTART',7,0x990000,cl_Black
1074
 
1075
    label 280,200,'  GAME OVER  ',cl_Black
1076
    endwd
1077
    ret
1078
 
1079
 
1080
;**********************
1081
;  End level process
1082
;**********************
1083
 
1084
end_lev:
1085
;    close
1086
    call draw_scorewindow
1087
stilleg:
1088
    wtevent redeg,keyeg,buttoneg
1089
    jmp stilleg
1090
redeg:
1091
    call draw_scorewindow
1092
    jmp stilleg
1093
keyeg:
1094
    mov  eax,2
485 heavyiron 1095
    mcall
31 halyavin 1096
    jmp  stilleg
1097
buttoneg:
1098
    mov  eax,17                 ; get id
485 heavyiron 1099
    mcall
31 halyavin 1100
    cmp  ah,1
1101
    je   close_app
1102
    cmp  ah,2
1103
    je   next_lev
1104
    cmp  ah,3
1105
    je   help
1106
    cmp  ah,4
1107
    je   close_app
1108
    cmp  ah,5
1109
    je   main_menu
1110
    jmp  stilleg
1111
 
1112
next_lev:
1113
    mov [pathtime],0
1114
    inc [levelpart]
1115
 
1116
;ship reset
1117
    mov [energy],100
1118
    mov [shipx],300
1119
    mov [shipy],400
1120
    mov [lazer],1000
1121
    mov [plazma],500
1122
 
1123
;counters reset
1124
    mov [boxget],0
1125
    mov [gship],0
1126
    mov [bship],0
1127
 
1128
; reset keyboard
1129
    mov [num1],0
1130
    mov [num5],0
1131
    mov [num3],0
1132
    mov [num2],0
1133
    mov [num8],0
1134
    jmp start_game
1135
 
1136
draw_scorewindow:
1137
    call draw_window
2062 dunkaist 1138
    mcall 9,proc_info,-1
1139
    test [proc_info+process_information.wnd_state], 0x04
1140
    jz   @f
1141
    ret
1142
  @@:
31 halyavin 1143
    startwd
1144
    drawfbox 170,130,300,190,cl_Grey
1145
    drawlbut 180,300,80,14,'(X) EXIT',4,0x990000,cl_Black
1146
    drawlbut 280,300,80,14,'',5,0x990000,cl_Black
1147
    drawlbut 380,300,80,14,'NEXT >>',2,0x990000,cl_Black
1148
 
1149
    setimg 180,140,warship1
1150
    outcount [bship],241,151,cl_Blue,5*65536
1151
 
1152
    setimg 180,180,warship2
1153
    outcount [gship],241,191,cl_Green,5*65536
1154
 
1155
    setimg 180,220,meteor
1156
    setimg 180,260,box
1157
    outcount [boxget],241,271,0xbbbb00,5*65536
1158
    endwd
1159
    ret
1160
 
1161
 
1162
;**********************
1163
;  End of game process
1164
;**********************
1165
 
1166
end_gm:
1167
    mov [pathtime],0
1168
    call draw_window
1169
    label 200 ,8,'YOU WIN PRESS ANY KEY TO EXIT',cl_White+font_Big
1170
 
1171
stilleg2:
1172
;    scevent   redeg2,keyeg2,buttoneg2
1173
    timeevent 1,no_event2,redeg2,keyeg2,buttoneg2
1174
 
1175
no_event2:
1176
    setimg 5,21,canvas
1177
 
1178
;clear scrbuf
1179
    mov edi,canvas+8
1180
    cld
1181
    mov ecx,640*440*3/4
1182
    mov eax,0
1183
    rep stosd
1184
 
1185
    aimgtoimg ship,320,220,canvas,0x0
1186
 
1187
    readmas massive,endshowmas
1188
    readmas massive,endmovemas
1189
    readmas massive,delfarshoot
1190
;    findmas massive,findzero
1191
;in edi off to free element
1192
;    jc  close_app
1193
 
1194
    inc [pathtime]
1195
    cmp [pathtime],30
1196
    jne no_firework
1197
    mov [pathtime],0
1198
    random 400,eax
1199
    mov [temp3],eax
1200
    random 600,eax
1201
    mov [temp2],eax
1202
    mov [temp],dword 8;10
1203
xloox:
1204
    findmas massive,findzero
1205
;in edi off to free element
1206
    jc  close_app
1207
 
1208
    mov eax,[temp2] ;[shipx]
1209
    mov [edi],eax
1210
    mov eax,[temp3] ;[shipy]
1211
    mov [edi+4],eax
1212
    mov [edi+8],dword 2   ;show hstar
1213
rerand:
1214
    random 5,eax
1215
    sub eax,2
1216
    cmp eax,0
1217
    je  rerand
1218
    mov [edi+12],eax   ;show hstar
1219
rerand2:
1220
    random 7,eax
1221
    sub eax,3
1222
    cmp eax,0
1223
    je  rerand2
1224
    mov [edi+16],eax   ;show hstar
1225
    dec [temp]
1226
    jnz xloox
1227
no_firework:
1228
    jmp stilleg2
1229
 
1230
redeg2:
1231
    jmp end_gm ;stilleg2
1232
keyeg2:
1233
    mov  eax,2
485 heavyiron 1234
    mcall
31 halyavin 1235
    jmp  main_menu
1236
buttoneg2:
1237
    mov  eax,17                 ; get id
485 heavyiron 1238
    mcall
31 halyavin 1239
    jmp  stilleg2
1240
 
1241
 
1242
 
1243
 
1244
 
1245
 
1246
; DATA AREA
1247
IM_END:
1248
;global
1249
pause_on dd 0
1250
 
1251
;massive
1252
shipx dd 300
1253
shipy dd 400
1254
 
1255
;guns
1256
lazer  dd 1000
1257
plazma dd 500
1258
 
1259
;keys
1260
num1 dd 0
1261
num5 dd 0
1262
num3 dd 0
1263
num2 dd 0
1264
num8 dd 0
1265
 
1266
;enemy countres
1267
gship  dd 0
1268
bship  dd 0
1269
boxget dd 0
1270
 
1271
energy dd 100
1272
score  dd 0
1273
 
1274
;delay for cannon
1275
ctime dd 0
1276
;delay for nuke gun
1277
xtime dd 0
1278
;path time
1279
pathtime dd 0
1280
;
1281
temp  dd 0
1282
temp2 dd 0
1283
temp3 dd 0
1284
temp4 dd 0
1285
otv dd 0
1286
 
1287
;for collimg
1288
imgsize:
1289
 dd 32
1290
 dd 32
1291
 
1292
;massive:
1293
;dd 400  ;elements num
1294
;dd 20  ;size of element in bytes
1295
;rb 400*20
1296
 
1297
keymap:
1298
rb 1000
1299
 
1300
;gif_file_area ~21500
1301
gif_file_area2:
1302
file 'phenix.gif'
1303
gif_file_area:
1304
file 'star2.gif';include gif file
1305
img_area:
1306
rb 256*64*3+8
1307
ship:
1308
rb 32*32*3+8
1309
shoot:
1310
rb 32*32*3+8
1311
warship1:
1312
rb 32*32*3+8
1313
warship2:
1314
rb 32*32*3+8
1315
meteor:
1316
rb 32*32*3+8
1317
star:
1318
rb 32*32*3+8
1319
star2:
1320
rb 32*32*3+8
1321
star3:
1322
rb 32*32*3+8
1323
box:
1324
rb 32*32*3+8
1325
 
552 diamond 1326
IncludeUGlobals
31 halyavin 1327
 
1328
massive:
1329
rd massize  ;elements num
1330
rd elemsize  ;size of element in bytes
1331
rb massize*elemsize
1332
 
1333
objmas:
1334
rd omassize  ;elements num
1335
rd oelemsize  ;size of element in bytes
1336
rb omassize*oelemsize
1337
 
1338
canvas:
1339
canvas_x:
1340
 rd 1
1341
canvas_y:
1342
 rd 1
1343
rb (640*440*3)+2000
2062 dunkaist 1344
 
1345
proc_info:
1346
rb 1024
31 halyavin 1347
I_END: