Advertisement
Clownacy

Untitled

Sep 1st, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. static void DrawPlane(PlaneEntry plane[128][128], uint16_t horizontal_scroll_table[SCREEN_HEIGHT], uint16_t vertical_scroll, bool priority)
  2. {
  3.     for (unsigned int y = 0; y < SCREEN_HEIGHT; ++y)
  4.     {
  5.         PlaneEntry *plane_row = plane[((vertical_scroll + y) / 8) & plane_height_mask];
  6.         const unsigned int start_x = horizontal_scroll_table[y] / 8;
  7.         uint8_t *indexed_framebuffer_pointer = &indexed_framebuffer[y][8 - (horizontal_scroll_table[y] % 8)];
  8.  
  9.         for (unsigned int x = 0; x < (SCREEN_WIDTH / 8) + 1; ++x)
  10.         {
  11.             if (
  12.             unsigned int tile_index = plane_row[(start_x + x) & plane_width_mask].tile_index;
  13.             unsigned int palette_index_high = plane_row[(start_x + x) & plane_width_mask].palette_line << 4;
  14.  
  15.             for (unsigned int i = 0; i < 8; ++i)
  16.             {
  17.                 unsigned char tile_x = i;
  18.                 unsigned char tile_y = (vertical_scroll + y) % 8;
  19.  
  20.                 if (plane_row[(start_x + x) & plane_width_mask].x_flip)
  21.                     tile_x = 8 - 1 - tile_x;
  22.  
  23.                 if (plane_row[(start_x + x) & plane_width_mask].y_flip)
  24.                     tile_y = 8 - 1 - tile_y;
  25.  
  26.                 unsigned int palette_index_low = tile_buffer[tile_index][tile_y][tile_x];
  27.  
  28.                 if (palette_index_low)
  29.                     *indexed_framebuffer_pointer++ = palette_index_high | palette_index_low;
  30.                 else
  31.                     ++indexed_framebuffer_pointer;
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement