Subversion Repositories Kolibri OS

Rev

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

  1. ;---------------------------------------------------------------------
  2. calculate_new_characters_offsets_and_sizes:
  3.         mov     eax,[ecx]
  4.         shr     eax,16
  5.         and     eax,0xff
  6. ;--------------------------------------
  7.         cmp     eax,ROUTE_UP
  8.         jne     @f
  9.        
  10.         xor     eax,eax
  11.         mov     [characters_offset_y],eax
  12.         mov     [characters_offset_x],eax
  13.         mov     [buffer_offset_x],eax
  14.        
  15.         mov     eax,[show_tiles_iterations]
  16.         dec     eax
  17.         mov     [buffer_offset_y],eax
  18.        
  19.         mov     eax,SPRITE_SIZE_Y
  20.         sub     eax,[buffer_offset_y]
  21.         mov     [characters_size_y],eax
  22.        
  23.         mov     eax,SPRITE_SIZE_X
  24.         mov     [characters_size_x],eax
  25.         jmp     .ready
  26. ;--------------------------------------
  27. @@:
  28.         cmp     eax,ROUTE_DOWN
  29.         jne     @f
  30.        
  31.         xor     eax,eax
  32.         mov     [characters_offset_x],eax
  33.         mov     [buffer_offset_y],eax
  34.         mov     [buffer_offset_x],eax
  35.  
  36.         mov     eax,[show_tiles_iterations]
  37.         dec     eax
  38.         mov     [characters_offset_y],eax
  39.        
  40.         mov     eax,SPRITE_SIZE_Y
  41.         sub     eax,[characters_offset_y]
  42.         mov     [characters_size_y],eax
  43.  
  44.         mov     eax,SPRITE_SIZE_X
  45.         mov     [characters_size_x],eax
  46.         jmp     .ready
  47. ;--------------------------------------
  48. @@:
  49.         cmp     eax,ROUTE_LEFT
  50.         jne     @f     
  51.        
  52.         xor     eax,eax
  53.         mov     [characters_offset_y],eax
  54.         mov     [characters_offset_x],eax
  55.         mov     [buffer_offset_y],eax
  56.  
  57.         mov     eax,[show_tiles_iterations]
  58.         dec     eax
  59.         mov     [buffer_offset_x],eax
  60.        
  61.         mov     eax,SPRITE_SIZE_X
  62.         sub     eax,[buffer_offset_x]
  63.         mov     [characters_size_x],eax
  64.        
  65.         mov     eax,SPRITE_SIZE_Y
  66.         mov     [characters_size_y],eax
  67.         jmp     .ready 
  68. ;--------------------------------------
  69. @@:
  70.         xor     eax,eax
  71.         mov     [characters_offset_y],eax
  72.         mov     [buffer_offset_y],eax
  73.         mov     [buffer_offset_x],eax
  74.  
  75.         mov     eax,[show_tiles_iterations]
  76.         dec     eax
  77.         mov     [characters_offset_x],eax
  78.        
  79.         mov     eax,SPRITE_SIZE_X
  80.         sub     eax,[characters_offset_x]
  81.         mov     [characters_size_x],eax
  82.  
  83.         mov     eax,SPRITE_SIZE_Y
  84.         mov     [characters_size_y],eax
  85. ;--------------------------------------
  86. .ready:
  87.         ret
  88. ;---------------------------------------------------------------------
  89. calculate_old_characters_offsets_and_sizes:
  90.         mov     eax,[ecx]
  91.         shr     eax,16
  92.         and     eax,0xff
  93. ;--------------------------------------
  94.         cmp     eax,ROUTE_UP
  95.         jne     @f
  96.        
  97.         xor     eax,eax
  98.         mov     [characters_offset_x],eax
  99.         mov     [buffer_offset_y],eax
  100.         mov     [buffer_offset_x],eax
  101.  
  102.         mov     eax,SPRITE_SIZE_Y
  103.         sub     eax,[show_tiles_iterations]
  104.         inc     eax
  105.         mov     [characters_offset_y],eax
  106.        
  107.         mov     eax,[show_tiles_iterations]
  108.         dec     eax
  109.         mov     [characters_size_y],eax
  110.        
  111.         mov     eax,SPRITE_SIZE_X
  112.         mov     [characters_size_x],eax
  113.         jmp     .ready
  114. ;--------------------------------------
  115. @@:
  116.         cmp     eax,ROUTE_DOWN
  117.         jne     @f
  118.        
  119.         xor     eax,eax
  120.         mov     [characters_offset_x],eax
  121.         mov     [characters_offset_y],eax
  122.         mov     [buffer_offset_x],eax
  123.  
  124.         mov     eax,SPRITE_SIZE_Y
  125.         sub     eax,[show_tiles_iterations]
  126.         inc     eax
  127.         mov     [buffer_offset_y],eax
  128.        
  129.         mov     eax,[show_tiles_iterations]
  130.         dec     eax
  131.         mov     [characters_size_y],eax
  132.  
  133.         mov     eax,SPRITE_SIZE_X
  134.         mov     [characters_size_x],eax
  135.         jmp     .ready
  136. ;--------------------------------------
  137. @@:
  138.         cmp     eax,ROUTE_LEFT
  139.         jne     @f     
  140.        
  141.         xor     eax,eax
  142.         mov     [characters_offset_y],eax
  143.         mov     [buffer_offset_y],eax
  144.         mov     [buffer_offset_x],eax
  145.  
  146.         mov     eax,SPRITE_SIZE_X
  147.         sub     eax,[show_tiles_iterations]
  148.         inc     eax
  149.         mov     [characters_offset_x],eax
  150.        
  151.         mov     eax,[show_tiles_iterations]
  152.         dec     eax
  153.         mov     [characters_size_x],eax
  154.        
  155.         mov     eax,SPRITE_SIZE_Y
  156.         mov     [characters_size_y],eax
  157.         jmp     .ready 
  158. ;--------------------------------------
  159. @@:
  160.         xor     eax,eax
  161.         mov     [characters_offset_y],eax
  162.         mov     [characters_offset_x],eax
  163.         mov     [buffer_offset_y],eax
  164.  
  165.         mov     eax,SPRITE_SIZE_X
  166.         sub     eax,[show_tiles_iterations]
  167.         inc     eax
  168.         mov     [buffer_offset_x],eax
  169.        
  170.         mov     eax,[show_tiles_iterations]
  171.         dec     eax
  172.         mov     [characters_size_x],eax
  173.  
  174.         mov     eax,SPRITE_SIZE_Y
  175.         mov     [characters_size_y],eax
  176. ;--------------------------------------
  177. .ready:
  178.         ret
  179. ;---------------------------------------------------------------------
  180. analize_and_copy_object:
  181. ;       DEBUGF  1, "analize_and_copy_object\n"
  182.         pusha
  183.         mov     ebp,[ecx]
  184. ;       DEBUGF  1, "EBP: %x ECX: %x\n",ebp, ecx
  185.         shr     ebp,8
  186.         and     ebp,0xff
  187.         test    ebp,ebp
  188.         jz      .no_characters
  189.  
  190.         cmp     ebp,OBJECT_DEATH
  191.         jnz     @f
  192.  
  193.         mov     ebp,[ecx]
  194.         shr     ebp,16
  195.         and     ebp,0xff
  196.        
  197.         mov     eax,[npc_death_icons]
  198.         jmp     .copy_characters_1
  199. ;--------------------------------------
  200. @@:
  201.         cmp     ebp,OBJECT_SKELETON
  202.         jnz     @f
  203.        
  204.         mov     ebp,[ecx]
  205.         shr     ebp,16
  206.         and     ebp,0xff
  207.  
  208.         mov     eax,[npc_skeleton_icons]
  209.         jmp     .copy_characters_1
  210. ;--------------------------------------
  211. @@:
  212.         cmp     ebp,OBJECT_IFRIT
  213.         jnz     @f
  214.        
  215.         mov     ebp,[ecx]
  216.         shr     ebp,16
  217.         and     ebp,0xff
  218.  
  219.         mov     eax,[npc_ifrit_icons]
  220.         jmp     .copy_characters_1
  221. ;--------------------------------------
  222. @@:
  223.         cmp     ebp,OBJECT_BARRET
  224.         jnz     @f
  225.        
  226.         mov     ebp,[ecx]
  227.         shr     ebp,16
  228.         and     ebp,0xff
  229.  
  230.         mov     eax,[npc_barret_icons]
  231.         jmp     .copy_characters_1
  232. ;--------------------------------------
  233. @@:
  234.         cmp     ebp,OBJECT_PROTAGONIST
  235.         jnz     @f
  236.  
  237.         mov     eax,[npc_miku_icons]
  238.         mov     ebp,[protagonist_route]
  239.         cmp     ebp,5
  240.         jb      .copy_characters_1
  241.        
  242.         sub     ebp,4
  243.         jmp     .copy_characters_kick
  244. ;--------------------------------------
  245. @@:
  246.         cmp     ebp,OBJECT_RED_BRICK
  247.         jnz     @f
  248.        
  249.         mov     eax,[red_brick_icons]
  250.         mov     ebp,1
  251.         jmp     .copy_characters
  252. ;--------------------------------------
  253. @@:
  254.         cmp     ebp,OBJECT_WHITE_BRICK
  255.         jnz     @f
  256.        
  257.         mov     eax,[white_brick_icons]
  258.         mov     ebp,1
  259.         jmp     .copy_characters
  260. ;--------------------------------------
  261. @@:
  262.         cmp     ebp,RED_BRICK_CRASH_1   ; 0x80 - reb brick crash 1
  263.         jnz     @f
  264. ;       DEBUGF  1, "reb brick crash 11\n"      
  265.         mov     eax,[red_brick_icons]
  266.         mov     ebp,2
  267.         jmp     .copy_characters
  268. ;--------------------------------------
  269. @@:
  270.         cmp     ebp,RED_BRICK_CRASH_2   ; 0x81 - reb brick crash 2
  271.         jnz     .no_characters
  272. ;       DEBUGF  1, "reb brick crash 21\n"              
  273.         mov     eax,[red_brick_icons]
  274.         mov     ebp,3
  275. ;--------------------------------------
  276. .copy_characters:
  277.         dec     ebp
  278.         imul    ebp,SPRITE_SIZE_X*SPRITE_SIZE_Y; 8bpp
  279.         call    copy_characters_with_offset
  280. ;--------------------------------------
  281. .no_characters:
  282. ;       DEBUGF  1, "analize_and_copy_object END\n"
  283.         popa
  284.         ret
  285. ;--------------------------------------
  286. .copy_characters_kick:
  287.         dec     ebp
  288.         imul    ebp,SPRITE_SIZE_X*SPRITE_SIZE_Y; 8bpp
  289.         add     ebp,SPRITE_SIZE_X*SPRITE_SIZE_Y*4*4 ; 8 bpp * 4 frames * 4 route
  290.         call    copy_characters_with_offset
  291.         jmp     .no_characters
  292. ;--------------------------------------
  293. .copy_characters_1:
  294.         dec     ebp
  295.         imul    ebp,SPRITE_SIZE_X*SPRITE_SIZE_Y*4 ; 8 bpp * 4 frames
  296.         mov     ebx,[show_tiles_iterations]
  297.         dec     ebx
  298.         shr     ebx,4 ; divider 16
  299.         imul    ebx,SPRITE_SIZE_X*SPRITE_SIZE_Y ; 8bpp
  300.         add     ebp,ebx
  301.         call    copy_characters_with_offset
  302.         jmp     .no_characters
  303. ;---------------------------------------------------------------------
  304. copy_characters_with_offset:
  305. ;       DEBUGF  1, "copy_characters_with_offset\n"
  306.         pusha   ;       ecx
  307.  
  308.         mov     esi,[eax+28]    ; data offset
  309.         add     esi,eax
  310.         add     esi,ebp
  311.        
  312.         mov     ebp,[eax+20]    ; palette offset
  313.         add     ebp,eax
  314. ; add Y offset to source
  315.         mov     eax,[characters_offset_y]
  316.         imul    eax,SPRITE_SIZE_X       ; 8bpp
  317.         add     esi,eax
  318. ; add X offset to source
  319.         mov     eax,[characters_offset_x]
  320.         add     esi,eax         ; 8bpp
  321.  
  322.         mov     edi,buffer_area
  323. ; add Y offset to destination
  324.         mov     eax,[buffer_offset_y]
  325.         imul    eax,SPRITE_SIZE_X*4     ; 32bpp
  326.         add     edi,eax
  327. ; add X offset to destination
  328.         mov     eax,[buffer_offset_x]
  329.         shl     eax,2   ; 32bpp
  330.         add     edi,eax
  331.  
  332.         mov     edx,[characters_size_y]
  333.         mov     ecx,[characters_size_x]
  334.         cld
  335. ;--------------------------------------
  336. .y:
  337.         push    ecx esi edi
  338. ;--------------------------------------
  339. .x:
  340.         lodsb
  341.         test    al,al
  342.         jz      .transparently
  343.        
  344.         and     eax,0xff
  345.         shl     eax,2
  346.         mov     eax,[ebp+eax] ; palette value
  347.         mov     [edi],eax
  348. ;--------------------------------------
  349. .transparently:
  350.         add     edi,4
  351.         dec     ecx
  352.         jnz     .x
  353.        
  354.         pop     edi esi ecx
  355.         add     esi,SPRITE_SIZE_X       ; 8bpp
  356.         add     edi,SPRITE_SIZE_X*4     ; 32bpp
  357.         dec     edx
  358.         jnz     .y
  359.        
  360.         popa
  361.         ret
  362. ;---------------------------------------------------------------------
  363.