Subversion Repositories Kolibri OS

Rev

Rev 5292 | 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. BASE_SAND = 4
  80. BASE_SNOW = 5
  81. ;-----------------------------------------------------------------------------
  82. TARGET_RANGE = 3
  83. ;-----------------------------------------------------------------------------
  84. START:
  85.         mcall   68,11
  86.         mcall   66,1,1
  87.         mcall   40,0x7  ;27
  88. ;--------------------------------------
  89. load_libraries  l_libs_start,end_l_libs
  90.         test    eax,eax
  91.         jnz     button.exit
  92. ;--------------------------------------
  93. ; unpack deflate
  94.         mov     eax,[unpack_DeflateUnpack2]
  95.         mov     [deflate_unpack],eax
  96. ;--------------------------------------
  97.         call    load_and_convert_all_icons
  98.        
  99.         cmp     [bootparam],dword 'NOSO'
  100.         je      menu_still
  101.  
  102.         call    load_all_sound_files
  103.        
  104.         mov     eax,[background_music]
  105.         mov     [wav_for_test],eax
  106.         mov     ebx,eax
  107.         add     ebx,1024
  108.         mov     [wav_for_test_end],ebx
  109.         call    test_wav_file
  110.        
  111.         mov     [music_flag],1
  112.         mcall   51,1,snd_background_music_thread_start,snd_background_music_thread_stack
  113.        
  114.         mov     [sounds_flag],1
  115.         mcall   51,1,snd_kick_action_thread_start,snd_kick_action_thread_stack
  116. ;---------------------------------------------------------------------
  117. menu_still:
  118.         jmp     main_menu_start
  119. ;---------------------------------------------------------------------
  120. show_game_stage:
  121.         mov     esi,map_level_game_stage
  122.         call    map_level_to_plan_level
  123.         call    draw_window
  124.         mov     eax,[level_counter]
  125.         inc     eax
  126.         mov     ebx,stage_text.1
  127.         call    decimal_string_2
  128.         mov     edx,stage_text
  129.         mov     ebx,SPRITE_SIZE_X*3 shl 16 + SPRITE_SIZE_Y*5
  130.         call    draw_font
  131.         mcall   5,300
  132.         ret
  133. ;---------------------------------------------------------------------
  134. show_game_win:
  135.         mov     esi,map_level_game_stage
  136.         call    map_level_to_plan_level
  137.         call    draw_window
  138.         mov     edx,game_win_text
  139.         mov     ebx,SPRITE_SIZE_X*2 shl 16 + SPRITE_SIZE_Y*5
  140.         call    draw_font
  141.         mcall   5,1000
  142.         ret
  143. ;---------------------------------------------------------------------
  144. death_of_protagonist_show:
  145.         mov     esi,map_level_game_over
  146.         call    map_level_to_plan_level
  147.         call    draw_window
  148.         mov     edx,protagonist_death_text
  149.         mov     ebx,SPRITE_SIZE_X*2 shl 16 + SPRITE_SIZE_Y*5
  150.         call    draw_font
  151.         mcall   5,500
  152.         jmp     main_menu_start
  153. ;---------------------------------------------------------------------
  154. start_level_0:
  155.         xor     eax,eax
  156.         mov     [level_counter],eax
  157. ;---------------------------------------------------------------------
  158. start_level:
  159.         mov     esi,[level_counter]
  160.         shl     esi,2
  161.         mov     esi,[esi+map_level_pointer]
  162.         test    esi,esi
  163.         jnz     @f
  164.        
  165.         call    show_game_win
  166.         jmp     main_menu_start
  167. ;--------------------------------------        
  168. @@:
  169.         call    show_game_stage
  170.         mov     eax,[stone_kick_sound]
  171.         mov     [sounds_sample],eax
  172. ;       xor     eax,eax
  173. ;       mov     [level_counter],eax
  174.         mov     [death_of_protagonist],0
  175.         mov     [protagonist_route],2
  176.         mov     [protagonist_position.x],4
  177.         mov     [protagonist_position.y],4
  178.        
  179.         mov     esi,[level_counter]
  180.         shl     esi,2
  181.         mov     esi,[esi+map_level_pointer]
  182. ;       mov     esi,map_level_0
  183.         call    map_level_to_plan_level
  184.         call    generate_objects_id
  185.         call    copy_plan_level_to_plan_level_old
  186. ;---------------------------------------------------------------------
  187. red:
  188.         call    draw_window
  189. ;---------------------------------------------------------------------
  190. still:
  191. ;       mcall   10
  192.         mcall   23,1
  193.  
  194.         cmp     eax,1
  195.         je      red
  196.  
  197.         cmp     eax,2
  198.         je      key
  199.  
  200.         cmp     eax,3
  201.         je      button
  202.        
  203.         call    actions_for_all_cell
  204.         call    show_tiles
  205.         call    harvest_of_death
  206.         call    show_tiles_one_iteration
  207.         cmp     [death_of_protagonist],1
  208.         je      death_of_protagonist_show
  209.        
  210.         cmp     [npc_alive],0
  211.         jne     @f
  212.  
  213.         inc     byte [level_counter]
  214.         jmp     start_level
  215. ;--------------------------------------
  216. @@:
  217.         mov     eax,[protagonist_position.y]
  218.         imul    eax,LEVEL_MAP_SIZE_X*4
  219.         mov     ebx,[protagonist_position.x]
  220.         shl     ebx,2
  221.         add     eax,ebx
  222.         add     eax,plan_level
  223.         mov     eax,[eax]
  224.         cmp     ah,OBJECT_PROTAGONIST
  225.         jne     death_of_protagonist_show
  226.  
  227.         jmp     still
  228. ;---------------------------------------------------------------------
  229. button:
  230.         mcall   17
  231.  
  232.         cmp     ah,1
  233.         jne     still
  234. ;--------------------------------------
  235. .exit:
  236.         mov     eax,[N_error]
  237. ;        DEBUGF  1, "N_error: %d\n",eax
  238.         test    eax,eax
  239.         jz      @f
  240.  
  241.         mcall   51,1,thread_start,thread_stack
  242. ;--------------------------------------
  243. @@:
  244.         mov     [music_flag],2
  245.         mov     [sounds_flag],2
  246.         mcall   -1
  247. ;---------------------------------------------------------------------
  248. draw_window:
  249.         mcall   12,1
  250.         mcall   48,4
  251.         mov     ecx,100 shl 16 + 644
  252.         add     cx,ax
  253.         mcall   0,<100,649>,,0x74AABBCC,,title
  254. ;       mcall   13,<0,640>,<0,640>,0xff0000
  255.         mov     [draw_all_level],1
  256. ;       call    show_tiles
  257.         call    show_tiles_one_iteration
  258.         mov     [draw_all_level],0
  259. ;       mcall   4,<3,8>,0,message,message.size
  260.         mcall   12,2
  261.         ret
  262. ;---------------------------------------------------------------------
  263. ;       ……‚Ž„ 10-›• —ˆ‘…‹ ‘Ž ‡€ŠŽŒ ‚ ‘’ŽŠŽ‚›‰ ‚ˆ„
  264. ;       ‚室:
  265. ;               AX - ç¨á«®
  266. ;               EBX -  ¤à¥á áâப¨
  267. ;       ‚ë室:
  268. ;               áâப  ᮤ¥à¦¨â ç¨á«®, ª®­¥æ ®â¬¥ç¥­ ª®¤®¬ 0
  269. ;------------------------------------------------------------------------------
  270. decimal_string_2:
  271.         push    eax ebx ecx edx
  272.         xor     ecx,ecx
  273.         mov     [ebx],byte '0'
  274.         inc     ebx
  275. ;--------------------------------------
  276. .p3:
  277.         xor     edx,edx
  278.         push    ebx
  279.         mov     ebx,10
  280.         div     ebx
  281.         pop     ebx
  282.         add     edx,48
  283.         push    edx
  284.         inc     ecx
  285.         cmp     ax,0
  286.         jne     .p3
  287.  
  288.         cmp     ecx,1
  289.         jbe     .p4
  290.  
  291.         mov     ecx,2
  292.         dec     ebx
  293. ;--------------------------------------
  294. .p4:
  295.         pop     edx
  296.         mov     [ebx],dl
  297.         inc     ebx
  298.         loop    .p4
  299.         pop     edx ecx ebx eax
  300.         ret
  301. ;------------------------------------------------------------------------------
  302. ;---------------------------------------------------------------------
  303. memory_free_error:
  304.         mov     [N_error],3
  305.         jmp     button.exit
  306. ;---------------------------------------------------------------------
  307. memory_get_error:
  308.         mov     [N_error],4
  309.         jmp     button.exit
  310. ;-----------------------------------------------------------------------------
  311. include 'key.inc'
  312. include 'show_tiles.inc'
  313. include 'show_base.inc'
  314. include 'show_object.inc'
  315. include 'load.inc'
  316. include 'icon_convert.inc'
  317. include 'error_window.inc'
  318. include 'actions.inc'
  319. include 'actions_npc.inc'
  320. include 'actions_protagonist.inc'
  321. include 'actions_white_bricks.inc'
  322. include 'random.inc'
  323. include 'snd_api.inc'
  324. include 'sound.inc'
  325. include 'menu.inc'
  326. include 'font.inc'
  327. ;---------------------------------------------------------------------
  328. if lang eq ru
  329.         include 'localization_rus.inc'
  330. else
  331.         include 'localization_eng.inc'
  332. end if
  333. ;---------------------------------------------------------------------
  334. include 'i_data.inc'
  335. include 'levels.inc'
  336. ;---------------------------------------------------------------------
  337. IM_END:
  338. ;---------------------------------------------------------------------
  339. ;include_debug_strings
  340. ;---------------------------------------------------------------------
  341. include 'u_data.inc'
  342. ;---------------------------------------------------------------------
  343. I_END:
  344.