Subversion Repositories Kolibri OS

Rev

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

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