Subversion Repositories Kolibri OS

Rev

Rev 5274 | Blame | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; Rusty Earth - for Kolibri OS
  3. ; Copyright (c) 2014, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28.   use32
  29.   org 0x0
  30.  
  31.   db 'MENUET01'
  32.   dd 0x01
  33.   dd START
  34.   dd IM_END
  35.   dd I_END
  36.   dd stacktop
  37.   dd bootparam
  38.   dd path
  39. ;-----------------------------------------------------------------------------
  40. include 'lang.inc'
  41. include '../../macros.inc'
  42. include '../../proc32.inc'
  43. ;define __DEBUG__ 1
  44. ;define __DEBUG_LEVEL__ 1
  45. ;include '../../debug-fdo.inc'
  46. include '../../develop/libraries/box_lib/load_lib.mac'
  47. ;include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  48. @use_library
  49. ;---------------------------------------------------------------------
  50. FONT_SIZE_X = 32
  51. FONT_REAL_SIZE_X = 32
  52. FONT_SIZE_Y = 32
  53. ;---------------------------------------------------------------------
  54. LEVEL_MAP_SIZE_X = 10
  55. LEVEL_MAP_SIZE_Y = 10
  56. SPRITE_SIZE_X = 64
  57. SPRITE_SIZE_Y = 64
  58. ;-----------------------------------------------------------------------------
  59. ROUTE_UP    = 1
  60. ROUTE_DOWN  = 2
  61. ROUTE_LEFT  = 3
  62. ROUTE_RIGHT = 4
  63. ;-----------------------------------------------------------------------------
  64. OBJECT_DEATH = 1
  65. OBJECT_SKELETON = 2
  66. OBJECT_IFRIT = 3
  67. OBJECT_BARRET = 4
  68. OBJECT_FINAL_MONSTER = 14 ; 0Eh
  69. OBJECT_PROTAGONIST = 15 ; 0Fh
  70. OBJECT_RED_BRICK = 16   ; 10h
  71. OBJECT_WHITE_BRICK = 17 ; 11h
  72. RED_BRICK_CRASH_1 = 0x80
  73. RED_BRICK_CRASH_2 = 0x81
  74. ;-----------------------------------------------------------------------------
  75. BASE_SMALL_ROCK = 0
  76. BASE_GRASS = 1
  77. BASE_LAVA = 2
  78. BASE_WATER = 3
  79. ;-----------------------------------------------------------------------------
  80. TARGET_RANGE = 3
  81. ;-----------------------------------------------------------------------------
  82. START:
  83.         mcall   68,11
  84.         mcall   66,1,1
  85.         mcall   40,0x7  ;27
  86. ;--------------------------------------
  87. load_libraries  l_libs_start,end_l_libs
  88.         test    eax,eax
  89.         jnz     button.exit
  90. ;--------------------------------------
  91. ; unpack deflate
  92.         mov     eax,[unpack_DeflateUnpack2]
  93.         mov     [deflate_unpack],eax
  94. ;--------------------------------------
  95.         call    load_and_convert_all_icons
  96.        
  97.         cmp     [bootparam],dword 'NOSO'
  98.         je      menu_still
  99.  
  100.         call    load_all_sound_files
  101.        
  102.         mov     eax,[background_music]
  103.         mov     [wav_for_test],eax
  104.         mov     ebx,eax
  105.         add     ebx,1024
  106.         mov     [wav_for_test_end],ebx
  107.         call    test_wav_file
  108.        
  109.         mov     [music_flag],1
  110.         mcall   51,1,snd_background_music_thread_start,snd_background_music_thread_stack
  111.        
  112.         mov     [sounds_flag],1
  113.         mcall   51,1,snd_kick_action_thread_start,snd_kick_action_thread_stack
  114. ;---------------------------------------------------------------------
  115. menu_still:
  116.         jmp     main_menu_start
  117. ;---------------------------------------------------------------------
  118. show_game_stage:
  119.         mov     esi,map_level_game_stage
  120.         call    map_level_to_plan_level
  121.         call    draw_window
  122.         mov     eax,[level_counter]
  123.         inc     eax
  124.         mov     ebx,stage_text.1
  125.         call    decimal_string_2
  126.         mov     edx,stage_text
  127.         mov     ebx,SPRITE_SIZE_X*3 shl 16 + SPRITE_SIZE_Y*5
  128.         call    draw_font
  129.         mcall   5,300
  130.         ret
  131. ;---------------------------------------------------------------------
  132. show_game_win:
  133.         mov     esi,map_level_game_stage
  134.         call    map_level_to_plan_level
  135.         call    draw_window
  136.         mov     edx,game_win_text
  137.         mov     ebx,SPRITE_SIZE_X*2 shl 16 + SPRITE_SIZE_Y*5
  138.         call    draw_font
  139.         mcall   5,1000
  140.         ret
  141. ;---------------------------------------------------------------------
  142. death_of_protagonist_show:
  143.         mov     esi,map_level_game_over
  144.         call    map_level_to_plan_level
  145.         call    draw_window
  146.         mov     edx,protagonist_death_text
  147.         mov     ebx,SPRITE_SIZE_X*2 shl 16 + SPRITE_SIZE_Y*5
  148.         call    draw_font
  149.         mcall   5,500
  150.         jmp     main_menu_start
  151. ;---------------------------------------------------------------------
  152. start_level_0:
  153.         xor     eax,eax
  154.         mov     [level_counter],eax
  155. ;---------------------------------------------------------------------
  156. start_level:
  157.         mov     esi,[level_counter]
  158.         shl     esi,2
  159.         mov     esi,[esi+map_level_pointer]
  160.         test    esi,esi
  161.         jnz     @f
  162.        
  163.         call    show_game_win
  164.         jmp     main_menu_start
  165. ;--------------------------------------        
  166. @@:
  167.         call    show_game_stage
  168.         mov     eax,[stone_kick_sound]
  169.         mov     [sounds_sample],eax
  170. ;       xor     eax,eax
  171. ;       mov     [level_counter],eax
  172.         mov     [death_of_protagonist],0
  173.         mov     [protagonist_route],2
  174.         mov     [protagonist_position.x],4
  175.         mov     [protagonist_position.y],4
  176.        
  177.         mov     esi,[level_counter]
  178.         shl     esi,2
  179.         mov     esi,[esi+map_level_pointer]
  180. ;       mov     esi,map_level_0
  181.         call    map_level_to_plan_level
  182.         call    generate_objects_id
  183.         call    copy_plan_level_to_plan_level_old
  184. ;---------------------------------------------------------------------
  185. red:
  186.         call    draw_window
  187. ;---------------------------------------------------------------------
  188. still:
  189. ;       mcall   10
  190.         mcall   23,1
  191.  
  192.         cmp     eax,1
  193.         je      red
  194.  
  195.         cmp     eax,2
  196.         je      key
  197.  
  198.         cmp     eax,3
  199.         je      button
  200.        
  201.         call    actions_for_all_cell
  202.         call    show_tiles
  203.         call    harvest_of_death
  204.         call    show_tiles_one_iteration
  205.         cmp     [death_of_protagonist],1
  206.         je      death_of_protagonist_show
  207.        
  208.         cmp     [npc_alive],0
  209.         jne     @f
  210.  
  211.         inc     byte [level_counter]
  212.         jmp     start_level
  213. ;--------------------------------------
  214. @@:
  215.         mov     eax,[protagonist_position.y]
  216.         imul    eax,LEVEL_MAP_SIZE_X*4
  217.         mov     ebx,[protagonist_position.x]
  218.         shl     ebx,2
  219.         add     eax,ebx
  220.         add     eax,plan_level
  221.         mov     eax,[eax]
  222.         cmp     ah,OBJECT_PROTAGONIST
  223.         jne     death_of_protagonist_show
  224.  
  225.         jmp     still
  226. ;---------------------------------------------------------------------
  227. button:
  228.         mcall   17
  229.  
  230.         cmp     ah,1
  231.         jne     still
  232. ;--------------------------------------
  233. .exit:
  234.         mov     eax,[N_error]
  235. ;        DEBUGF  1, "N_error: %d\n",eax
  236.         test    eax,eax
  237.         jz      @f
  238.  
  239.         mcall   51,1,thread_start,thread_stack
  240. ;--------------------------------------
  241. @@:
  242.         mov     [music_flag],2
  243.         mov     [sounds_flag],2
  244.         mcall   -1
  245. ;---------------------------------------------------------------------
  246. draw_window:
  247.         mcall   12,1
  248.         mcall   48,4
  249.         mov     ecx,100 shl 16 + 644
  250.         add     cx,ax
  251.         mcall   0,<100,649>,,0x74AABBCC,,title
  252. ;       mcall   13,<0,640>,<0,640>,0xff0000
  253.         mov     [draw_all_level],1
  254. ;       call    show_tiles
  255.         call    show_tiles_one_iteration
  256.         mov     [draw_all_level],0
  257. ;       mcall   4,<3,8>,0,message,message.size
  258.         mcall   12,2
  259.         ret
  260. ;---------------------------------------------------------------------
  261. ;       ……‚Ž„ 10-›• —ˆ‘…‹ ‘Ž ‡€ŠŽŒ ‚ ‘’ŽŠŽ‚›‰ ‚ˆ„
  262. ;       ‚室:
  263. ;               AX - ç¨á«®
  264. ;               EBX -  ¤à¥á áâப¨
  265. ;       ‚ë室:
  266. ;               áâப  ᮤ¥à¦¨â ç¨á«®, ª®­¥æ ®â¬¥ç¥­ ª®¤®¬ 0
  267. ;------------------------------------------------------------------------------
  268. decimal_string_2:
  269.         push    eax ebx ecx edx
  270.         xor     ecx,ecx
  271.         mov     [ebx],byte '0'
  272.         inc     ebx
  273. ;--------------------------------------
  274. .p3:
  275.         xor     edx,edx
  276.         push    ebx
  277.         mov     ebx,10
  278.         div     ebx
  279.         pop     ebx
  280.         add     edx,48
  281.         push    edx
  282.         inc     ecx
  283.         cmp     ax,0
  284.         jne     .p3
  285.  
  286.         cmp     ecx,1
  287.         jbe     .p4
  288.  
  289.         mov     ecx,2
  290.         dec     ebx
  291. ;--------------------------------------
  292. .p4:
  293.         pop     edx
  294.         mov     [ebx],dl
  295.         inc     ebx
  296.         loop    .p4
  297.         pop     edx ecx ebx eax
  298.         ret
  299. ;------------------------------------------------------------------------------
  300. ;---------------------------------------------------------------------
  301. memory_free_error:
  302.         mov     [N_error],3
  303.         jmp     button.exit
  304. ;---------------------------------------------------------------------
  305. memory_get_error:
  306.         mov     [N_error],4
  307.         jmp     button.exit
  308. ;-----------------------------------------------------------------------------
  309. include 'key.inc'
  310. include 'show_tiles.inc'
  311. include 'show_base.inc'
  312. include 'show_object.inc'
  313. include 'load.inc'
  314. include 'icon_convert.inc'
  315. include 'error_window.inc'
  316. include 'actions.inc'
  317. include 'actions_npc.inc'
  318. include 'actions_protagonist.inc'
  319. include 'actions_white_bricks.inc'
  320. include 'random.inc'
  321. include 'snd_api.inc'
  322. include 'sound.inc'
  323. include 'menu.inc'
  324. include 'font.inc'
  325. ;---------------------------------------------------------------------
  326. if lang eq ru
  327.         include 'localization_rus.inc'
  328. else
  329.         include 'localization_eng.inc'
  330. end if
  331. ;---------------------------------------------------------------------
  332. include 'i_data.inc'
  333. include 'levels.inc'
  334. ;---------------------------------------------------------------------
  335. IM_END:
  336. ;---------------------------------------------------------------------
  337. ;include_debug_strings
  338. ;---------------------------------------------------------------------
  339. include 'u_data.inc'
  340. ;---------------------------------------------------------------------
  341. I_END:
  342.