Subversion Repositories Kolibri OS

Rev

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

  1. ; Initially written by CH@YKIN EVGENY, 2009
  2. ; Then disassembled for fun by dunkaist, 2017
  3. use32
  4.     org 0
  5.     db  'MENUET01'
  6.     dd  1
  7.     dd  start
  8.     dd  I_END
  9.     dd  stacktop
  10.     dd  stacktop
  11.     dd  0, 0
  12.  
  13. include 'proc32.inc'
  14. include 'struct.inc'
  15. include 'macros.inc'
  16. include 'encoding.inc'
  17.  
  18. CLIENT_WIDTH  = 300
  19. CLIENT_HEIGHT = 200
  20.  
  21. HEALTH_INIT = 24
  22. HEALTH_BONUS = 3
  23. HEALTH_LEVEL_UP = 297
  24.  
  25. BULLET_DAMAGE = 12
  26. BULLETS_CNT = 4
  27.  
  28. NOTE_DAMAGE = 0x31
  29. NOTE_SAVE = 0x63
  30. NOTE_WIN_0 = 0x36
  31. NOTE_WIN_1 = 0x35
  32. NOTE_WIN_2 = 0x31
  33. NOTE_LOST_0 = 0x0d
  34. NOTE_LOST_1 = 0x09
  35. NOTE_LOST_2 = 0x20
  36.  
  37. BULLET_SIZE = 7
  38. SHIELD_SIZE = 20
  39.  
  40. DELAY_INIT = 10
  41. DELAY_NOTE = 10
  42.  
  43. DELAYS_PER_GAME_STEP = 10
  44.  
  45. NW = 1  ; north west
  46. SW = 2
  47. NE = 3
  48. SE = 4
  49.  
  50. macro draw_bullet off_on, x, y {
  51.         mov     eax, 7
  52.         mov     ebx, _pic_bullet_#off_on
  53.         mov     ecx, (BULLET_SIZE SHL 16) + BULLET_SIZE
  54.         mov     edx, x
  55.         imul    edx, edx, 0x10000
  56.         add     edx, y
  57.         mcall
  58. }
  59.  
  60. macro draw_shield side, x, y {
  61.         mov     eax, 7
  62.         mov     ebx, pic_shield_#side
  63.         mov     ecx, (SHIELD_SIZE SHL 16) + SHIELD_SIZE
  64.         mov     edx, x
  65.         imul    edx, edx, 0x10000
  66.         add     edx, y
  67.         mcall
  68. }
  69.  
  70. macro play_note note {
  71.         mov     eax, note
  72.         mov     dword [speaker.note], eax
  73.         mov     eax, 55
  74.         mov     ebx, eax
  75.         mov     esi, speaker
  76.         mcall
  77. }
  78.  
  79. start:
  80.         mcall   48, 3, sys_colors, sizeof.system_colors
  81.         jmp     menu
  82. menu:
  83.         mcall   10
  84.         cmp     eax, 1
  85.         jz      .redraw
  86.         cmp     eax, 2
  87.         jz      .button
  88.         cmp     eax, 3
  89.         jz      .key
  90.         jmp     menu
  91.   .redraw:
  92.         jmp     .draw
  93.   .button:
  94.         mcall   2
  95.         cmp     ah, '1'
  96.         jz      .init_game
  97.         cmp     ah, '2'
  98.         jz      .resume_game
  99.         jmp     menu
  100.   .init_game:
  101.         mov     eax, 13
  102.         mov     ebx, 0
  103.         imul    ebx, ebx, 0x10000
  104.         add     ebx, CLIENT_WIDTH
  105.         mov     ecx, 0
  106.         imul    ecx, ecx, 0x10000
  107.         add     ecx, CLIENT_HEIGHT
  108.         mov     edx, 0
  109.         mcall
  110.         mov     [game_started], 0
  111.         mov     [shield_position], SE
  112.         mov     [finish_draw], 1
  113.         mov     [next_bullet_side_prng], 3
  114.         mov     [next_bullet_side], SE
  115.         mov     [bullet_1_pos], 1
  116.         mov     [bullet_2_pos], 2
  117.         mov     [bullet_3_pos], 3
  118.         mov     [bullet_4_pos], 4
  119.         mov     eax, NW
  120.         mov     [bullet_1_side], eax
  121.         mov     eax, SW
  122.         mov     [bullet_2_side], eax
  123.         mov     eax, NE
  124.         mov     [bullet_3_side], eax
  125.         mov     eax, SE
  126.         mov     [bullet_4_side], eax
  127.         mov     eax, 1
  128.         mov     [bullet_pos], eax
  129.         mov     eax, NW
  130.         mov     [bullet_side], eax
  131.         mov     eax, 1
  132.         mov     [cur_bullet], eax
  133.         mov     eax, 1
  134.         mov     [delays_cnt], eax
  135.         mov     eax, HEALTH_INIT
  136.         mov     [health], eax
  137.         mov     eax, DELAY_INIT
  138.         mov     [delay], eax
  139.         jmp     redraw_window
  140.   .resume_game:
  141.         mov     eax, 13
  142.         mov     ebx, 0
  143.         imul    ebx, ebx, 0x10000
  144.         add     ebx, CLIENT_WIDTH
  145.         mov     ecx, 0
  146.         imul    ecx, ecx, 0x10000
  147.         add     ecx, CLIENT_HEIGHT
  148.         mov     edx, 0
  149.         mcall
  150.         jmp     redraw_window
  151.   .key:
  152.         mcall   17
  153.         cmp     ah, 0x01        ; close button
  154.         jnz     menu
  155.   .exit:
  156.         mcall   -1
  157.   .draw:
  158.         mov     eax, [finish_draw]
  159.         cmp     eax, 1
  160.         jz      .draw.start
  161.         jmp     .draw.finish
  162.   .draw.finish:
  163.         mcall   12, 2
  164.         jmp     .draw.start
  165.   .draw.start:
  166.         mov     eax, 0
  167.         mov     [finish_draw], eax
  168.         mcall   12, 1
  169.         mcall   48, 4
  170.         mov     [skin_height], eax
  171.         mcall   48, 4
  172.         mov     [skin_height], eax
  173.         mov     eax, 0
  174.         mov     ebx, (100 SHL 16) + CLIENT_WIDTH + 10
  175.         mov     ecx, 100
  176.         imul    ecx, ecx, 0x10000
  177.         add     ecx, CLIENT_HEIGHT + 4
  178.         add     ecx, [skin_height]
  179.         mov     edx, 0x33000000
  180.         mov     edi, window_title
  181.         mcall
  182.         mov     eax, 13
  183.         mov     ebx, 0
  184.         imul    ebx, ebx, 0x10000
  185.         add     ebx, CLIENT_WIDTH + 1
  186.         mov     ecx, 0
  187.         imul    ecx, ecx, 0x10000
  188.         add     ecx, CLIENT_HEIGHT
  189.         mov     edx, 0
  190.         mcall
  191.         mcall   4, (140 SHL 16) +  60, 0x10bbbbbb, msg_ataka, msg_ataka.size
  192.         mcall   4, (140 SHL 16) +  61, 0x10bbbbbb, msg_ataka, msg_ataka.size
  193.         mcall   4, (141 SHL 16) +  61, 0x10bbbbbb, msg_ataka, msg_ataka.size
  194.         mcall   4, (141 SHL 16) +  60, 0x10bbbbbb, msg_ataka, msg_ataka.size
  195.         mcall   4, ( 55 SHL 16) + 190, 0x10444444, msg_copyright, msg_copyright.size
  196.         mov     eax, 4
  197.         mov     ebx, (34 SHL 16) + 160
  198.         mov     ecx, 0x888888
  199.         mov     edx, msg_control_by_numpad
  200.         mov     esi, 40
  201.   .print_line:
  202.         mcall
  203.         add     ebx, 10 ; one line down
  204.         add     edx, 40
  205.         cmp     byte [edx], 'x'
  206.         jnz     .print_line
  207.         mcall   4, (110 SHL 16) +  95, 0x10999999, msg_new_game, msg_new_game.size
  208.         mov     eax, [game_started]
  209.         cmp     eax, 0
  210.         jz      menu
  211.         mcall   4, (110 SHL 16) + 110, 0x10999999, msg_continue, msg_continue.size
  212.         jmp     menu
  213.  
  214. redraw_window:
  215.         mov     eax, [finish_draw]
  216.         cmp     eax, 1
  217.         jz      redraw_window.start
  218.         mcall   12, 2
  219.         jmp     redraw_window.start
  220. redraw_window.start:
  221.         mov     eax, 0
  222.         mov     [finish_draw], eax
  223.         mcall   12, 1
  224.         mcall   48, 4
  225.         mov     [skin_height], eax
  226.         mov     eax, 0
  227.         mov     ebx, (100 SHL 16) + CLIENT_WIDTH + 10
  228.         mov     ecx, 100
  229.         imul    ecx, ecx, 0x10000
  230.         add     ecx, CLIENT_HEIGHT + 4
  231.         add     ecx, [skin_height]
  232.         mov     edx, 0x33000000
  233.         mov     edi, window_title
  234.         mcall
  235.         jmp     draw_field
  236.  
  237. game_loop:
  238.         mov     [game_started], 1
  239.         mov     eax, [health]
  240.         cmp     eax, HEALTH_LEVEL_UP
  241.         jg      level_up
  242.         cmp     eax, 0
  243.         jl      lost
  244.         jmp     game_alive
  245. level_up:
  246.         mov     eax, HEALTH_INIT
  247.         mov     [health], eax
  248.         mov     eax, [delay]
  249.         cmp     eax, 10         ; delay for level_0
  250.         jz      level_up_1
  251.         mov     eax, [delay]
  252.         cmp     eax, 8          ; delay for level_1
  253.         jz      level_up_2
  254.         mov     eax, [delay]
  255.         cmp     eax, 7
  256.         jz      level_up_3
  257.         mov     eax, [delay]
  258.         cmp     eax, 6
  259.         jz      level_up_4
  260.         mov     eax, [delay]
  261.         cmp     eax, 5
  262.         jz      level_up_5
  263.         mov     eax, [delay]
  264.         cmp     eax, 4
  265.         jz      level_up_6
  266.         mov     eax, [delay]
  267.         cmp     eax, 3
  268.         jz      win
  269.         jmp     game_alive
  270. lost:
  271.         mcall   5, DELAY_NOTE
  272.         play_note NOTE_LOST_0
  273.         mcall   5, DELAY_NOTE
  274.         play_note NOTE_LOST_1
  275.         mcall   5, DELAY_NOTE
  276.         play_note NOTE_LOST_2
  277.  
  278.         mov     [game_started], 0
  279.         mcall   4, (105 SHL 16) + 100, 0xff0000, msg_you_lost, msg_you_lost.size
  280.         mcall   5, 100
  281.         mov     eax, SE
  282.         mov     [shield_position], eax
  283.         mov     eax, 1
  284.         mov     [finish_draw], eax
  285.         mov     eax, 3
  286.         mov     [next_bullet_side_prng], eax
  287.         mov     eax, SE
  288.         mov     [next_bullet_side], eax
  289.         mov     eax, 1
  290.         mov     [bullet_1_pos], eax
  291.         mov     eax, 2
  292.         mov     [bullet_2_pos], eax
  293.         mov     eax, 3
  294.         mov     [bullet_3_pos], eax
  295.         mov     eax, 4
  296.         mov     [bullet_4_pos], eax
  297.         mov     eax, NW
  298.         mov     [bullet_1_side], eax
  299.         mov     eax, SW
  300.         mov     [bullet_2_side], eax
  301.         mov     eax, NE
  302.         mov     [bullet_3_side], eax
  303.         mov     eax, SE
  304.         mov     [bullet_4_side], eax
  305.         mov     eax, 1
  306.         mov     [bullet_pos], eax
  307.         mov     eax, NW
  308.         mov     [bullet_side], eax
  309.         mov     eax, 1
  310.         mov     [cur_bullet], eax
  311.         mov     eax, 1
  312.         mov     [delays_cnt], eax
  313.         mov     eax, HEALTH_INIT
  314.         mov     [health], eax
  315.         mov     eax, DELAY_INIT
  316.         mov     [delay], eax
  317.         jmp     menu.draw
  318.  
  319. level_up_1:
  320.         mov     eax, 8
  321.         mov     [delay], eax
  322.         jmp     game_alive
  323. level_up_2:
  324.         mov     eax, 7
  325.         mov     [delay], eax
  326.         jmp     game_alive
  327. level_up_3:
  328.         mov     eax, 6
  329.         mov     [delay], eax
  330.         jmp     game_alive
  331. level_up_4:
  332.         mov     eax, 5
  333.         mov     [delay], eax
  334.         jmp     game_alive
  335. level_up_5:
  336.         mov     eax, 4
  337.         mov     [delay], eax
  338.         jmp     game_alive
  339. level_up_6:
  340.         mov     eax, 3
  341.         mov     [delay], eax
  342.         jmp     game_alive
  343. win:
  344.         mcall   5, DELAY_NOTE
  345.         play_note NOTE_WIN_0
  346.         mcall   5, DELAY_NOTE
  347.         play_note NOTE_WIN_1
  348.         mcall   5, DELAY_NOTE
  349.         play_note NOTE_WIN_2
  350.  
  351.         mcall   5, DELAY_NOTE
  352.  
  353.         mov     [game_started], 0
  354.         mov     eax, DELAY_INIT
  355.         mov     [delay], eax
  356.         mcall   4, (105 SHL 16) + 100, 0xff0000, msg_you_won, msg_you_won.size
  357.         mcall   5, 200
  358.         jmp     menu.draw
  359.  
  360. game_alive:
  361.         ; draw max health bar
  362.         mov     eax, 13
  363.         mov     ebx, 0
  364.         imul    ebx, ebx, 0x10000
  365.         add     ebx, CLIENT_WIDTH + 1
  366.         mov     ecx, 0
  367.         imul    ecx, ecx, 0x10000
  368.         inc     ecx
  369.         mov     edx, 0xff0000
  370.         mcall
  371.         ; draw left health bar
  372.         mov     eax, 13
  373.         mov     ebx, 0
  374.         imul    ebx, ebx, 0x10000
  375.         add     ebx, [health]
  376.         mov     ecx, 0
  377.         imul    ecx, ecx, 0x10000
  378.         inc     ecx
  379.         mov     edx, 0x0000ff
  380.         mcall
  381.         mov     eax, [next_bullet_side_prng]
  382.         inc     eax
  383.         mov     [next_bullet_side_prng], eax
  384.         mov     eax, [next_bullet_side_prng]
  385.         cmp     eax, 1
  386.         jz      ._1
  387.         mov     eax, [next_bullet_side_prng]
  388.         cmp     eax, 2
  389.         jz      ._2
  390.         mov     eax, [next_bullet_side_prng]
  391.         cmp     eax, 3
  392.         jz      ._3
  393.         mov     eax, [next_bullet_side_prng]
  394.         cmp     eax, 4
  395.         jz      ._4
  396.         mov     eax, [next_bullet_side_prng]
  397.         cmp     eax, 5
  398.         jz      ._5
  399.         mov     eax, [next_bullet_side_prng]
  400.         cmp     eax, 6
  401.         jz      ._6
  402.         mov     eax, [next_bullet_side_prng]
  403.         cmp     eax, 7
  404.         jz      ._7
  405.         mov     eax, [next_bullet_side_prng]
  406.         cmp     eax, 8
  407.         jz      ._8
  408.         mov     eax, [next_bullet_side_prng]
  409.         cmp     eax, 9
  410.         jg      ._9
  411.         mov     eax, 3
  412.         mov     [next_bullet_side], eax
  413.         jmp     check_event
  414. ._1:
  415.         mov     eax, 1
  416.         mov     [next_bullet_side], eax
  417.         jmp     check_event
  418. ._2:
  419.         mov     eax, 4
  420.         mov     [next_bullet_side], eax
  421.         jmp     check_event
  422. ._3:
  423.         mov     eax, 3
  424.         mov     [next_bullet_side], eax
  425.         jmp     check_event
  426. ._4:
  427.         mov     eax, 4
  428.         mov     [next_bullet_side], eax
  429.         jmp     check_event
  430. ._5:
  431.         mov     eax, 1
  432.         mov     [next_bullet_side], eax
  433.         jmp     check_event
  434. ._6:
  435.         mov     eax, 2
  436.         mov     [next_bullet_side], eax
  437.         jmp     check_event
  438. ._7:
  439.         mov     eax, 1
  440.         mov     [next_bullet_side], eax
  441.         jmp     check_event
  442. ._8:
  443.         mov     eax, 2
  444.         mov     [next_bullet_side], eax
  445.         jmp     check_event
  446. ._9:
  447.         mov     eax, 3
  448.         mov     [next_bullet_side], eax
  449.         mov     eax, 1
  450.         mov     [next_bullet_side_prng], eax
  451.         jmp     check_event
  452.  
  453. check_event:
  454.         mcall   5, [delay]
  455.         mcall   11
  456.         cmp     eax, 1
  457.         jz      redraw_window
  458.         cmp     eax, 2
  459.         jz      .button
  460.         cmp     eax, 3
  461.         jz      .key
  462.         jmp     draw_field
  463.   .key:
  464.         mov     al, 17
  465.         mcall
  466.         cmp     ah, 1
  467.         jnz     draw_field
  468.         mcall   -1
  469.  
  470.   .button:
  471.         mov     al, 2
  472.         mcall
  473.         cmp     ah, 0xb0        ; arrow left / numpad 4
  474.         jz      .move_shield_tl
  475.         cmp     ah, 0xb5        ; end / numpad 1
  476.         jz      .move_shield_bl
  477.         cmp     ah, 0xb3        ; arrow right / numpad 6
  478.         jz      .move_shield_tr
  479.         cmp     ah, 0xb7        ; page down / numpad 3
  480.         jz      .move_shield_br
  481.         cmp     ah, 0xb0        ; never happens, fixme
  482.         jz      menu.draw
  483.         cmp     ah, 'p'         ; 'p' for pause
  484.         jz      menu.draw
  485.         cmp     ah, '4'
  486.         jz      .move_shield_tl
  487.         cmp     ah, '1'
  488.         jz      .move_shield_bl
  489.         cmp     ah, '6'
  490.         jz      .move_shield_tr
  491.         cmp     ah, '3'
  492.         jz      .move_shield_br
  493.         jmp     draw_field
  494.   .move_shield_tl:
  495.         mov     eax, 1
  496.         mov     [shield_position], eax
  497.         jmp     draw_field
  498.   .move_shield_bl:
  499.         mov     eax, 2
  500.         mov     [shield_position], eax
  501.         jmp     draw_field
  502.   .move_shield_tr:
  503.         mov     eax, 3
  504.         mov     [shield_position], eax
  505.         jmp     draw_field
  506.   .move_shield_br:
  507.         mov     eax, 4
  508.         mov     [shield_position], eax
  509.         jmp     draw_field
  510. draw_field:
  511.         mcall   18, 14
  512. ;        mcall   65, pic_bg, (CLIENT_WIDTH SHL 16) + CLIENT_HEIGHT, 0, 8, paletter, 0
  513.         mov     eax, 65
  514.         mov     ebx, pic_bg
  515.         mov     ecx, (CLIENT_WIDTH SHL 16) + CLIENT_HEIGHT
  516.         mov     edx, 0
  517.         mov     esi, 8  ; indexed image
  518.         mov     edi, palette
  519.         mov     ebp, 0
  520.         mcall
  521.         mov     eax, [shield_position]
  522.         cmp     eax, NW
  523.         jz      .shield_nw
  524.         cmp     eax, SW
  525.         jz      .shield_sw
  526.         cmp     eax, NE
  527.         jz      .shield_ne
  528.         cmp     eax, SE
  529.         jz      .shield_se
  530.   .shield_nw:
  531.         draw_shield nw, 90, 70
  532.         jmp     draw_bullets
  533.   .shield_sw:
  534.         draw_shield sw, 90, 105
  535.         jmp     draw_bullets
  536.   .shield_ne:
  537.         draw_shield ne, CLIENT_HEIGHT, 70
  538.         jmp     draw_bullets
  539.   .shield_se:
  540.         draw_shield se, CLIENT_HEIGHT, 105
  541.         jmp     draw_bullets
  542.  
  543. draw_bullets:   ; off
  544.         draw_bullet off,  90,  70
  545.         draw_bullet off,  75,  58
  546.         draw_bullet off,  59,  46
  547.         draw_bullet off,  89, 117
  548.         draw_bullet off,  74, 129
  549.         draw_bullet off,  56, 144
  550.         draw_bullet off, 211,  68
  551.         draw_bullet off, 224,  57
  552.         draw_bullet off, 236,  46
  553.         draw_bullet off, 210, 119
  554.         draw_bullet off, 223, 131
  555.         draw_bullet off, 237, 143
  556.         jmp     draw_bullets_on
  557.  
  558. draw_bullets_on:
  559.         mov     eax, [cur_bullet]
  560.         cmp     eax, 1
  561.         jz      ._1
  562.         cmp     eax, 2
  563.         jz      ._2
  564.         cmp     eax, 3
  565.         jz      ._3
  566.         cmp     eax, 4
  567.         jz      ._4
  568.   ._1:
  569.         mov     eax, [bullet_1_pos]
  570.         mov     [bullet_pos], eax
  571.         mov     eax, [bullet_1_side]
  572.         mov     [bullet_side], eax
  573.         jmp     bullet_on_defined
  574.   ._2:
  575.         mov     eax, [bullet_2_pos]
  576.         mov     [bullet_pos], eax
  577.         mov     eax, [bullet_2_side]
  578.         mov     [bullet_side], eax
  579.         jmp     bullet_on_defined
  580.   ._3:
  581.         mov     eax, [bullet_3_pos]
  582.         mov     [bullet_pos], eax
  583.         mov     eax, [bullet_3_side]
  584.         mov     [bullet_side], eax
  585.         jmp     bullet_on_defined
  586.   ._4:
  587.         mov     eax, [bullet_4_pos]
  588.         mov     [bullet_pos], eax
  589.         mov     eax, [bullet_4_side]
  590.         mov     [bullet_side], eax
  591.         jmp     bullet_on_defined
  592.  
  593. bullet_on_defined:
  594.         mov     eax, [bullet_side]
  595.         cmp     eax, NW
  596.         jz      bullet_nw
  597.         cmp     eax, SW
  598.         jz      bullet_sw
  599.         cmp     eax, NE
  600.         jz      bullet_ne
  601.         cmp     eax, SE
  602.         jz      bullet_se
  603. bullet_nw:
  604.         mov     eax, [bullet_pos]
  605.         cmp     eax, 1
  606.         jz      bullet_nw_dist._1
  607.         cmp     eax, 2
  608.         jz      bullet_nw_dist._2
  609.         cmp     eax, 3
  610.         jz      bullet_nw_dist._3
  611.         cmp     eax, 4
  612.         jz      bullet_nw_dist._4
  613.         cmp     eax, 5
  614.         jz      bullet_nw_dist._5
  615. bullet_sw:
  616.         mov     eax, [bullet_pos]
  617.         cmp     eax, 1
  618.         jz      bullet_sw_dist._1
  619.         cmp     eax, 2
  620.         jz      bullet_sw_dist._2
  621.         cmp     eax, 3
  622.         jz      bullet_sw_dist._3
  623.         cmp     eax, 4
  624.         jz      bullet_sw_dist._4
  625.         cmp     eax, 5
  626.         jz      bullet_sw_dist._5
  627. bullet_ne:
  628.         mov     eax, [bullet_pos]
  629.         cmp     eax, 1
  630.         jz      bullet_ne_dist._1
  631.         cmp     eax, 2
  632.         jz      bullet_ne_dist._2
  633.         cmp     eax, 3
  634.         jz      bullet_ne_dist._3
  635.         cmp     eax, 4
  636.         jz      bullet_ne_dist._4
  637.         cmp     eax, 5
  638.         jz      bullet_ne_dist._5
  639. bullet_se:
  640.         mov     eax, [bullet_pos]
  641.         cmp     eax, 1
  642.         jz      bullet_se_dist._1
  643.         cmp     eax, 2
  644.         jz      bullet_se_dist._2
  645.         cmp     eax, 3
  646.         jz      bullet_se_dist._3
  647.         cmp     eax, 4
  648.         jz      bullet_se_dist._4
  649.         cmp     eax, 5
  650.         jz      bullet_se_dist._5
  651.  
  652. bullet_nw_dist:
  653.   ._1:
  654.         draw_bullet on, 44, 33
  655.         jmp     bullet_on_drawn
  656.   ._2:
  657.         draw_bullet on, 59, 46
  658.         jmp     bullet_on_drawn
  659.   ._3:
  660.         draw_bullet on, 75, 58
  661.         jmp     bullet_on_drawn
  662.   ._4:
  663.         draw_bullet on, 90, 70
  664.         jmp     bullet_on_drawn
  665.   ._5:
  666.         jmp     bullet_on_drawn
  667.  
  668. bullet_sw_dist:
  669.   ._1:
  670.         draw_bullet on, 42, 156
  671.         jmp     bullet_on_drawn
  672.   ._2:
  673.         draw_bullet on, 56, 144
  674.         jmp     bullet_on_drawn
  675.   ._3:
  676.         draw_bullet on, 74, 129
  677.         jmp     bullet_on_drawn
  678.   ._4:
  679.         draw_bullet on, 89, 117
  680.         jmp     bullet_on_drawn
  681.   ._5:
  682.         jmp     bullet_on_drawn
  683.  
  684. bullet_ne_dist:
  685.   ._1:
  686.         draw_bullet on, 250, 34
  687.         jmp     bullet_on_drawn
  688.   ._2:
  689.         draw_bullet on, 236, 46
  690.         jmp     bullet_on_drawn
  691.   ._3:
  692.         draw_bullet on, 224, 57
  693.         jmp     bullet_on_drawn
  694.   ._4:
  695.         draw_bullet on, 211, 68
  696.         jmp     bullet_on_drawn
  697.   ._5:
  698.         jmp     bullet_on_drawn
  699.  
  700. bullet_se_dist:
  701.   ._1:
  702.         draw_bullet on, 251, 156
  703.         jmp     bullet_on_drawn
  704.   ._2:
  705.         draw_bullet on, 237, 143
  706.         jmp     bullet_on_drawn
  707.   ._3:
  708.         draw_bullet on, 223, 131
  709.         jmp     bullet_on_drawn
  710.   ._4:
  711.         draw_bullet on, 210, 119
  712.         jmp     bullet_on_drawn
  713.   ._5:
  714.         jmp     bullet_on_drawn
  715.  
  716. bullet_on_drawn:
  717.         mov     eax, [cur_bullet]
  718.         inc     eax
  719.         mov     [cur_bullet], eax
  720.         mov     eax, [cur_bullet]
  721.         cmp     eax, BULLETS_CNT + 1
  722.         jz      all_bullets_drawn
  723.         jmp     draw_bullets_on
  724. all_bullets_drawn:
  725.         mov     eax, 1
  726.         mov     [cur_bullet], eax
  727.         jmp     check_for_game_step
  728. check_for_game_step:
  729.         mov     eax, [delays_cnt]
  730.         cmp     eax, DELAYS_PER_GAME_STEP
  731.         jz      game_step
  732.         jmp     no_game_step
  733. no_game_step:
  734.         mov     eax, [delays_cnt]
  735.         inc     eax
  736.         mov     [delays_cnt], eax
  737.         jmp     game_loop
  738. game_step:
  739.         mov     eax, 1
  740.         mov     [delays_cnt], eax
  741.         mov     eax, [bullet_1_pos]
  742.         inc     eax
  743.         mov     [bullet_1_pos], eax
  744.         mov     eax, [bullet_2_pos]
  745.         inc     eax
  746.         mov     [bullet_2_pos], eax
  747.         mov     eax, [bullet_3_pos]
  748.         inc     eax
  749.         mov     [bullet_3_pos], eax
  750.         mov     eax, [bullet_4_pos]
  751.         inc     eax
  752.         mov     [bullet_4_pos], eax
  753.         mov     eax, [bullet_1_pos]
  754.         cmp     eax, 6
  755.         jz      bullet_1_new
  756.         mov     eax, [bullet_2_pos]
  757.         cmp     eax, 6
  758.         jz      bullet_2_new
  759.         mov     eax, [bullet_3_pos]
  760.         cmp     eax, 6
  761.         jz      bullet_3_new
  762.         mov     eax, [bullet_4_pos]
  763.         cmp     eax, 6
  764.         jz      bullet_4_new
  765.         jmp     check_bullet_hit
  766.  
  767. bullet_1_new:
  768.         play_note NOTE_SAVE
  769.         mov     eax, 1
  770.         mov     [bullet_1_pos], eax
  771.         mov     eax, [next_bullet_side]
  772.         mov     [bullet_1_side], eax
  773.         jmp     check_bullet_hit
  774. bullet_2_new:
  775.         play_note NOTE_SAVE
  776.         mov     eax, 1
  777.         mov     [bullet_2_pos], eax
  778.         mov     eax, [next_bullet_side]
  779.         mov     [bullet_2_side], eax
  780.         jmp     check_bullet_hit
  781. bullet_3_new:
  782.         play_note NOTE_SAVE
  783.         mov     eax, 1
  784.         mov     [bullet_3_pos], eax
  785.         mov     eax, [next_bullet_side]
  786.         mov     [bullet_3_side], eax
  787.         jmp     check_bullet_hit
  788. bullet_4_new:
  789.         play_note NOTE_SAVE
  790.         mov     eax, 1
  791.         mov     [bullet_4_pos], eax
  792.         mov     eax, [next_bullet_side]
  793.         mov     [bullet_4_side], eax
  794.         jmp     check_bullet_hit
  795.  
  796. check_bullet_hit:
  797.         mov     eax, [bullet_1_pos]
  798.         cmp     eax, 5
  799.         jz      bullet_1_hit
  800.         mov     eax, [bullet_2_pos]
  801.         cmp     eax, 5
  802.         jz      bullet_2_hit
  803.         mov     eax, [bullet_3_pos]
  804.         cmp     eax, 5
  805.         jz      bullet_3_hit
  806.         mov     eax, [bullet_4_pos]
  807.         cmp     eax, 5
  808.         jz      bullet_4_hit
  809.         jmp     game_loop
  810.  
  811. bullet_1_hit:
  812.         mov     eax, [bullet_1_side]
  813.         cmp     eax, [shield_position]
  814.         jz      save
  815.         jmp     damage
  816. bullet_2_hit:
  817.         mov     eax, [bullet_2_side]
  818.         cmp     eax, [shield_position]
  819.         jz      save
  820.         jmp     damage
  821. bullet_3_hit:
  822.         mov     eax, [bullet_3_side]
  823.         cmp     eax, [shield_position]
  824.         jz      save
  825.         jmp     damage
  826. bullet_4_hit:
  827.         mov     eax, [bullet_4_side]
  828.         cmp     eax, [shield_position]
  829.         jz      save
  830.         jmp     damage
  831.  
  832. damage:
  833.         mov     eax, [health]
  834.         sub     eax, BULLET_DAMAGE
  835.         mov     [health], eax
  836.         play_note NOTE_DAMAGE
  837.         jmp     game_loop
  838. save:
  839.         mov     eax, [health]
  840.         add     eax, HEALTH_BONUS
  841.         mov     [health], eax
  842.         play_note NOTE_SAVE
  843.         jmp     game_loop
  844.  
  845. skin_height dd 0
  846. shield_position dd SE
  847. finish_draw dd 1        ; 0 -- finish, 1 -- start
  848. next_bullet_side_prng dd 3
  849. next_bullet_side dd SE
  850. bullet_1_pos dd 1
  851. bullet_2_pos dd 2
  852. bullet_3_pos dd 3
  853. bullet_4_pos dd 4
  854. bullet_1_side dd NW
  855. bullet_2_side dd SW
  856. bullet_3_side dd NE
  857. bullet_4_side dd SE
  858. bullet_pos dd 1         ; nearest to the gun
  859. bullet_side dd NW
  860. cur_bullet dd NW
  861. delays_cnt dd 1
  862. health dd HEALTH_INIT
  863. delay dd DELAY_INIT
  864. game_started dd 0
  865. speaker:
  866.   .duration db 0x90
  867.   .note     db 0x30
  868.   .end      db 0x00
  869. pic_bg:
  870. file 'picture_bg.rgba'
  871. pic_shield_sw:
  872. file 'shield_sw.rgb'
  873. pic_shield_nw:
  874. file 'shield_nw.rgb'
  875. pic_shield_ne:
  876. file 'shield_ne.rgb'
  877. pic_shield_se:
  878. file 'shield_se.rgb'
  879. _pic_bullet_off:
  880. file 'bullet_off.rgb'
  881. _pic_bullet_on:
  882. file 'bullet_on.rgb'
  883. sz msg_copyright, '(c) 2009 CH@YKIN EVGENY'
  884. msg_new_game      cp866 '1  новая игра'
  885. msg_new_game.size = $ - msg_new_game
  886. msg_continue      cp866 '2  продолжить'
  887. msg_continue.size = $ - msg_continue
  888. msg_you_lost    cp866 '   вы проиграли'
  889. msg_you_lost.size = $ - msg_you_lost
  890. msg_you_won     cp866 'ПОБЕДА :)'
  891. msg_you_won.size = $ - msg_you_won
  892. msg_control_by_numpad cp866 'Управление клавишами  NumLock клавиатуры'
  893. msg_control_by_numpad.size = $ - msg_control_by_numpad
  894. msg_controls    cp866 '      1, 4, 6, 3 и пауза Р(Eng).                                                x'
  895. msg_controls.size = $ - msg_controls
  896. palette:
  897. file 'palette.rgba'
  898.  
  899. sz msg_ataka,     'ATAKA'
  900. window_title      db 'ATAKA  V 1.0',0
  901. I_END:
  902. sys_colors system_colors
  903. rb 0x80d
  904. stacktop:
  905.