Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;   Hunter. Version 1.1.
  3. ;   The game application for MeOS game compo 05.03.2005 - 12.03.2005
  4. ;
  5. ;   Author:       Trans
  6. ;   Date:         07.03.2005 - 08.03.2005
  7. ;   Modification: 08.05.2007
  8. ;   Compiler:     FASM
  9. ;   Target:       MenuetOS game
  10. ;
  11.  
  12. include '..\..\..\macros.inc'
  13.  
  14. use32
  15.  
  16.                org    0x0
  17.  
  18.                db     'MENUET01'              ; 8 byte id
  19.                dd     0x01                    ; header version
  20.                dd     START                   ; start of code
  21.                dd     I_END                   ; size of image
  22.                dd     end_memory        ;0x180000 ; memory for app
  23.                dd     start_stack             ; esp
  24.                dd     0x0 , 0x0               ; I_Param , I_Icon
  25.  
  26. START:                          ; start of execution
  27.      mov eax,40
  28.      mov ebx,00100111b
  29.      mcall
  30.  
  31.         mov eax,26
  32.         mov ebx,9
  33.         mcall
  34.         mov [second_count],eax
  35.  
  36.         call init_object
  37.  
  38.      call draw_window
  39.  
  40. still:
  41.  
  42. ;    mov eax,23                 ; wait here for event
  43. ;    mov ebx,10
  44. ;    mcall
  45.  
  46.         mov eax,05
  47.         mov ebx,5
  48.         mcall
  49.         mov eax,11
  50.         mcall
  51.  
  52.         push eax
  53.         mov eax,26
  54.         mov ebx,9
  55.         mcall
  56.         mov ebx,eax
  57.         sub eax,[second_count]
  58.         cmp ax,100
  59.         jb still_continue_00
  60.         inc dword [time_count]
  61.         mov [second_count],ebx
  62.         xor edx,edx
  63.         mov eax,ebx
  64.         mov ebx,30
  65.         div ebx
  66.         cmp dl,0
  67.         jnz still_loc_01
  68.         call change_objects_speed
  69. still_loc_01:
  70.         xor eax,eax
  71.         mov esi,forward_list
  72.         mov ecx,4
  73. still_loc_00:
  74.         cmp eax,dword [esi]
  75.         jnz still_continue_00
  76.         add esi,4
  77.         loop still_loc_00
  78. ;       call set_current_objects_list
  79.         call init_object
  80. still_continue_00:
  81.         pop eax
  82.        
  83.         call movie_objects
  84.        
  85.     cmp  eax,1                  ; redraw request ?
  86.     je   red
  87.     cmp  eax,2                  ; key in buffer ?
  88.     je   key
  89.     cmp  eax,3                  ; button in buffer ?
  90.     je   button
  91.     cmp  eax,6                  ; mouse ?
  92.     je   mouse
  93.  
  94.         call draw_frame
  95.  
  96.     jmp  still
  97.  
  98.   red:                          ; redraw
  99.     call draw_window
  100.     jmp  still
  101.  
  102.   key:                          ; key
  103.     mov  eax,2                  ; just read it and ignore
  104.     mcall
  105.         cmp al,0
  106.         jnz still
  107.         cmp byte [menu_flag],0
  108.         jnz still
  109.         cmp ah,' '
  110.         jnz key_loc_00
  111.         inc byte [pause_flag]
  112.         call draw_frame
  113.         call pause_game
  114. key_loc_00:
  115.     jmp  still
  116.  
  117.   button:                       ; button
  118.     mov  eax,17                 ; get id
  119.     mcall
  120.  
  121.     cmp  ah,1                   ; button id=1 ?
  122.     jne  noclose
  123.  
  124.         inc byte [game_over_flag]
  125.         call game_over_draw
  126.  
  127.     mov  eax,-1                 ; close this program
  128.     mcall
  129.   noclose:
  130.  
  131.     jmp  still
  132.  
  133.  
  134. mouse:                          ; mouse
  135.     mov eax,37                 ; get coordinate
  136.     xor ebx,ebx
  137.     inc ebx
  138.     mcall
  139.  
  140.     cmp ax,20
  141.     jae mouse_loc_00
  142.     mov ax,20
  143. mouse_loc_00:
  144.     sub ax,20
  145.     shr ax,1
  146.     ror eax,16
  147.     shr ax,1
  148.     push ax
  149.     ror eax,16
  150.     mov dword [mouse_coord],eax
  151.     pop ax
  152.     cmp ax,110
  153.     ja mouse_loc_03
  154.     mov byte [gun_angle],0
  155.     jmp mouse_loc_05
  156. mouse_loc_03:
  157.     cmp ax,210
  158.     ja mouse_loc_04
  159.     mov byte [gun_angle],1
  160.     jmp mouse_loc_05
  161. mouse_loc_04:
  162.     mov byte [gun_angle],2
  163. mouse_loc_05:    
  164.  
  165.     mov eax,37
  166.     xor ebx,ebx
  167.     mov bl,2
  168.     mcall
  169.  
  170.     cmp ax,1
  171.     jnz not_left_button
  172.         call left_button_down
  173. not_left_button:
  174.     call draw_frame
  175.     jmp  still
  176.  
  177.  
  178.  
  179.  
  180. ;   *********************************************
  181. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  182. ;   *********************************************
  183.  
  184.  
  185. draw_window:
  186.  
  187.  
  188.     mov  eax,12                    ; function 12:tell os about windowdraw
  189.     mov  ebx,1                     ; 1, start of draw
  190.     mcall
  191.  
  192.                                    ; DRAW WINDOW
  193.     mov  eax,0                     ; function 0 : define and draw window
  194.     mov  ebx,100*65536+640         ; [x start] *65536 + [x size]
  195.     mov  ecx,100*65536+420         ; [y start] *65536 + [y size]
  196.     mov  edx,0x13ffffff            ; color of work area RRGGBB,8->color gl
  197.     mov  edi,title                 ; WINDOW LABEL
  198.     mcall
  199.  
  200.         call draw_frame
  201.        
  202.     mov  eax,12                    ; function 12:tell os about windowdraw
  203.     mov  ebx,2                     ; 2, end of draw
  204.     mcall
  205.  
  206.     ret
  207.  
  208. ;-------------Subprograms------------------------
  209.  
  210. ;
  211. ; In:
  212. ; Out:
  213. draw_frame:
  214.         cmp byte [menu_flag],0
  215.         jz df_loc_00
  216.         call draw_menu
  217.         retn
  218. df_loc_00:
  219.         call draw_backside
  220.         mov esi,buf_oblako
  221.         mov eax,0*65536+0
  222.         call draw_pict
  223.         mov eax,190*65536+23
  224.         call draw_pict_scale_div_2
  225.         mov esi,buf_sun
  226.         mov eax,256*65536+0
  227.         call draw_pict
  228.         mov esi,buf_rock
  229.         mov eax,47*65536+83
  230.         call draw_pict_scale_div_2
  231.         mov eax,0*65536+70
  232.         call draw_pict
  233.  
  234.         call draw_objects
  235.  
  236.         mov esi,buf_kust02
  237.         mov eax,256*65536+127
  238.         call draw_pict
  239.         mov esi,buf_kust01
  240.         mov eax,0*65536+127
  241.         call draw_pict
  242.         mov esi,buf_time
  243.         mov eax,5*65536+180
  244.         call draw_pict
  245.         mov esi,buf_shots
  246.         mov eax,200*65536+180
  247.         call draw_pict
  248.         mov esi,buf_lives
  249.         mov eax,5*65536+5
  250.         call draw_pict
  251.         mov eax,56*65536+3
  252.         call draw_lives
  253.         call draw_promakh
  254. ;       call draw_hole 
  255.         cmp byte [gun_angle],0
  256.         jnz df_loc_01
  257.         mov esi,buf_gun02
  258.         mov eax,120*65536+151
  259.         call draw_pict
  260.         cmp byte [fire_flag],0
  261.         jz df_loc_03
  262.         mov esi,buf_fire02
  263.         mov eax,108*65536+131
  264.         call draw_pict
  265.         dec byte [fire_flag]
  266.         jmp df_loc_03
  267. df_loc_01:
  268.         cmp byte [gun_angle],2
  269.         jnz df_loc_02
  270.         mov esi,buf_gun01
  271.         mov eax,140*65536+151
  272.         call draw_pict
  273.         cmp byte [fire_flag],0
  274.         jz df_loc_03
  275.         mov esi,buf_fire01
  276.         mov eax,167*65536+128
  277.         call draw_pict
  278.         dec byte [fire_flag]
  279.         jmp df_loc_03
  280. df_loc_02:
  281.         mov esi,buf_gun00
  282.         mov eax,140*65536+144
  283.         call draw_pict
  284.         cmp byte [fire_flag],0
  285.         jz df_loc_03
  286.         mov esi,buf_fire00
  287.         mov eax,135*65536+124
  288.         call draw_pict
  289.         dec byte [fire_flag]
  290. df_loc_03:
  291. ;       mov esi,buf_star
  292. ;       mov eax,300*65536+180
  293. ;       call draw_pict
  294.         mov esi,buf_score
  295.         mov eax,120*65536+5
  296.         call draw_pict
  297.         mov eax,260*65536+180
  298.         mov ebx,[shots_count]
  299.         call number_print
  300.         mov eax,175*65536+3
  301.         mov ebx,[score_count]
  302.         call number_print
  303.         mov eax,60*65536+180
  304.         mov ebx,[time_count]
  305.         call number_print
  306.         call draw_mushka
  307.         cmp byte [pause_flag],0
  308.         jz df_loc_04
  309.         mov esi,buf_pause
  310.         mov eax,90*65536+80
  311.         call draw_pict
  312. df_loc_04:
  313.         cmp byte [game_over_flag],0
  314.         jz df_loc_05
  315.         mov esi,buf_gameover
  316.         mov eax,[game_over_coord]
  317.         call draw_pict
  318. df_loc_05:
  319.  
  320.         call buffer_scale_on_2
  321. ;       call smooth_filter
  322.         mov eax,07
  323.         mov ebx,buffer02
  324.         mov ecx,640*65536+400
  325.         mov edx,0*65536+20
  326.         mcall
  327.         retn
  328.  
  329.  
  330. ;
  331. ; In:
  332. ; Out:
  333. draw_menu:
  334.         call clear_buffer
  335.         mov esi,buf_start
  336.         mov eax,60*65536+50
  337.         call draw_pict
  338.         mov esi,buf_exit
  339.         mov eax,86*65536+120
  340.         call draw_pict
  341.         call draw_mushka
  342.         call buffer_scale_on_2
  343.         mov eax,07
  344.         mov ebx,buffer02
  345.         mov ecx,640*65536+400
  346.         mov edx,0*65536+20
  347.         mcall
  348.         retn
  349.  
  350.  
  351.  
  352. ;
  353. ; In:
  354. ; Out:
  355. pause_game:
  356.         mov eax,40
  357.         mov ebx,00000111b
  358.         mcall
  359.  
  360. pause_game_00:
  361.     mov eax,10                 ; wait here for event
  362.     mcall
  363.  
  364.     cmp  eax,1                  ; redraw request ?
  365.     je   pg_red
  366.     cmp  eax,2                  ; key in buffer ?
  367.     je   pg_key
  368.     cmp  eax,3                  ; button in buffer ?
  369.     je   pg_button
  370.     jmp  pause_game_00
  371.  
  372. pg_red:                          ; redraw
  373.     call draw_window
  374.     jmp  pause_game_00
  375.  
  376. pg_key:                          ; key
  377.     mov  eax,2                  ; just read it and ignore
  378.     mcall
  379.         cmp al,0
  380.         jnz pause_game_00
  381.         cmp ah,' '
  382.         jnz pgk_loc_00
  383.         dec byte [pause_flag]
  384.         call draw_frame
  385.         mov eax,40
  386.         mov ebx,00100111b
  387.         mcall
  388.         retn
  389. pgk_loc_00:
  390.     jmp  pause_game_00
  391.  
  392. pg_button:                       ; button
  393.     mov  eax,17                 ; get id
  394.     mcall
  395.     cmp  ah,1                   ; button id=1 ?
  396.     jne  pg_noclose
  397.     mov  eax,-1                 ; close this program
  398.     mcall
  399. pg_noclose:
  400.     jmp  pause_game
  401.         retn
  402.  
  403. ;
  404. ; In:
  405. ; Out:
  406. left_button_down:
  407.         cmp byte [menu_flag],0
  408.         jz lbd_loc_00
  409.         call check_menu
  410.         retn
  411. lbd_loc_00:
  412.         inc dword [shots_count]
  413.         inc byte [fire_flag]
  414. ;       mov eax,[mouse_coord]
  415. ;       mov [current_hole],eax
  416.         call check_kill_object
  417.         cmp byte [promakh_count],5
  418.         jnz lbd_loc_01
  419.         mov byte [promakh_count],0
  420.         dec byte [lives_count]
  421.         jnz lbd_loc_01
  422.         call draw_frame
  423.         mov byte [game_over_flag],1
  424.         call game_over_draw
  425.         dec byte [game_over_flag]
  426.         inc byte [menu_flag]
  427. lbd_loc_01:
  428.         retn
  429.  
  430. ;
  431. ; In:
  432. ; Out:
  433. check_menu:
  434.         push eax
  435.         mov eax,[mouse_coord]
  436.         cmp ax,50
  437.         jb cm_loc_00
  438.         cmp ax,90
  439.         ja cm_loc_00
  440.         shr eax,16
  441.         cmp ax,60
  442.         jb cm_loc_00
  443.         cmp ax,260
  444.         ja cm_loc_00
  445.         dec byte [menu_flag]
  446.         xor eax,eax
  447.         mov [score_count],eax
  448.         mov [shots_count],eax
  449.         mov [time_count],eax
  450.         mov [current_hole],eax
  451.         mov [current_hole+4],eax
  452.         mov [gun_angle],al
  453.         mov [stars_count],al
  454.         mov [promakh_count],al
  455.         mov byte [lives_count],3
  456. ;       call set_current_objects_list
  457.         call init_object
  458.         pop eax
  459.         retn
  460. cm_loc_00:
  461.         mov eax,[mouse_coord]
  462.         cmp ax,120
  463.         jb cm_loc_01
  464.         cmp ax,160
  465.         ja cm_loc_01
  466.         shr eax,16
  467.         cmp ax,86
  468.         jb cm_loc_01
  469.         cmp ax,234
  470.         ja cm_loc_01
  471.         mov eax,-1
  472.         mcall
  473. cm_loc_01:
  474.         pop eax
  475.         retn
  476.  
  477.  
  478. ;
  479. ;
  480. ;
  481. game_over_draw:
  482.         pusha
  483.         mov dword [game_over_coord],42*65536+0
  484.         mov ecx,15
  485. god_loc_00:
  486.         push ecx
  487.         call draw_frame
  488.         add word [game_over_coord],5
  489.         mov eax,05
  490.         mov ebx,3
  491.         mcall
  492.         pop ecx
  493.         loop god_loc_00
  494. ;       mov eax,7
  495.         mov edx,0*65536+20
  496.         mov ebx,buffer02
  497.         mov ecx,3
  498. god_loc_01:
  499.         push ecx
  500.         mov eax,7
  501.         mov ecx,640*65536+400
  502.         mcall
  503.         push ebx
  504.         mov eax,05
  505.         mov ebx,5
  506.         mcall
  507.         pop ebx
  508.         sub ebx,640*3*5
  509.         pop ecx
  510.         loop god_loc_01
  511.         mov ecx,4
  512. god_loc_02:
  513.         push ecx
  514.         mov eax,7
  515.         mov ecx,640*65536+400
  516.         mcall
  517.         push ebx
  518.         mov eax,5
  519.         mov ebx,5
  520.         mcall
  521.         pop ebx
  522.         add ebx,640*3*5
  523.         pop ecx
  524.         loop god_loc_02
  525.         mov eax,5
  526.         mov ebx,200
  527.         mcall
  528.         popa
  529.         retn
  530.  
  531. include 'picture.inc'
  532. include 'math.inc'
  533. include 'object.inc'
  534. ;----------------Data----------------------------
  535.  
  536. mouse_coord     dd 144*65536+84
  537. pause_flag      db 0    ; 0/1 - active/pause
  538. menu_flag       db 1    ; 0/1 - game/menu
  539. lives_count     db 3
  540. stars_count     db 0    ; 3 Stars = 1 Heart
  541. shots_count     dd 0
  542. time_count      dd 0
  543. score_count     dd 0
  544. second_count    dd 0
  545. game_over_coord dd 0
  546. gun_angle       db 0    ; 0/1/2 - left/vertical/right
  547. game_over_flag  db 0    ; 0/1 - continuing/end game
  548. promakh_count   db 0
  549. fire_flag       db 0    ; 0/1 - no fire/fire from gun
  550. current_hole    dd 0,0,0,0,0,0
  551. forward_list    db 0,0,0,0,0,0,0,0
  552. back_list       db 0,0,0,0,0,0,0,0
  553. present_objects_list:
  554.         dd buf_glass,   buf_net,     buf_glaz, buf_plane00
  555.         dd buf_heart02, buf_plane01, buf_net,  buf_glaz
  556.  
  557. title   db 'HUNTER 1.2  Trans, 2005',0
  558.  
  559. buf_start:
  560. include 'inc\start.inc'
  561. buf_exit:
  562. include 'inc\exit.inc'
  563. buf_gameover:
  564. include 'inc\gameover.inc'
  565. buf_pause:
  566. include 'inc\pause.inc'
  567. buf_gun00:
  568. include 'inc\gun00.inc'
  569. buf_gun01:
  570. include 'inc\gun01.inc'
  571. buf_gun02:
  572. include 'inc\gun02.inc'
  573. buf_heart:
  574. include 'inc\heart.inc'
  575. buf_star:
  576. include 'inc\star.inc'
  577. buf_lives:
  578. include 'inc\lives.inc'
  579. buf_score:
  580. include 'inc\score.inc'
  581. buf_shots:
  582. include 'inc\shots.inc'
  583. buf_time:
  584. include 'inc\time.inc'
  585. buf_numbers:
  586. ;include 'inc\numbers.inc'
  587. buf_num0:
  588. include 'inc\num0.inc'
  589. buf_num1:
  590. include 'inc\num1.inc'
  591. buf_num2:
  592. include 'inc\num2.inc'
  593. buf_num3:
  594. include 'inc\num3.inc'
  595. buf_num4:
  596. include 'inc\num4.inc'
  597. buf_num5:
  598. include 'inc\num5.inc'
  599. buf_num6:
  600. include 'inc\num6.inc'
  601. buf_num7:
  602. include 'inc\num7.inc'
  603. buf_num8:
  604. include 'inc\num8.inc'
  605. buf_num9:
  606. include 'inc\num9.inc'
  607. buf_plus:
  608. include 'inc\plus.inc'
  609. buf_minus:
  610. include 'inc\minus.inc'
  611. buf_sun:
  612. include 'inc\sun.inc'
  613. buf_oblako:
  614. include 'inc\oblako.inc'
  615. buf_mushka:
  616. include 'inc\mushka.inc'
  617. buf_kust01:
  618. include 'inc\kust01.inc'
  619. buf_kust02:
  620. include 'inc\kust02.inc'
  621. buf_glass:
  622. include 'inc\glass.inc'
  623. buf_glaz:
  624. include 'inc\glaz.inc'
  625. buf_net:
  626. include 'inc\net.inc'
  627. buf_plane00:
  628. include 'inc\plane00.inc'
  629. buf_plane01:
  630. include 'inc\plane01.inc'
  631. buf_heart02:
  632. include 'inc\heart02.inc'
  633. buf_rock:
  634. include 'inc\rock.inc'
  635. buf_fire00:
  636. include 'inc\fire00.inc'
  637. buf_fire01:
  638. include 'inc\fire01.inc'
  639. buf_fire02:
  640. include 'inc\fire02.inc'
  641. buf_hole:
  642. include 'inc\hole.inc'
  643.  
  644. I_END:
  645.  
  646. end_stack:
  647.         org $+1000h
  648. start_stack:
  649.  
  650.         org $+64        ; For stack protect
  651.  
  652. movieng_objects:
  653. ; For one object - 16 bytes structure:
  654. ;       dd ; +00 Pointer to object  OR  0 - if empty structure
  655. ;       dd ; +04 Current object coordinate X*65536+Y
  656. ;       db ; +08 Speed - Maximum 16 (???)
  657. ;       db ; +09 Amplitude
  658. ;       db ; +0A Direction 0/1 - right/left
  659. ;       db ; +0B Object Cost
  660. ;       dd ; +0C Reserve
  661. ;
  662.    org $+16*16
  663.  
  664. buffer00:
  665.    org $+320*201*3
  666. buffer01:
  667.    org $+100*201*3
  668. buffer02:
  669.    org $+640*401*3
  670.    org $+640*40*3
  671. end_memory: