Advertisement
SolidDesu

Untitled

Jan 7th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. static int tile_offs_x = 0;
  2. static int tile_offs_y = 0;
  3. void sdDrawTiles(int layer, int row_begin, int row_end) {
  4.     const int tile_stride = TILE_SIZE * TILE_SIZE;
  5.  
  6.     if (row_end == 0) {
  7.         row_end = image_height;
  8.     }
  9.  
  10.     int* tile_map = sdGetTileIndices(layer);
  11.     const int COLS = tiled_width;
  12.     const int ROWS = tiled_height;
  13.     for (int y = row_begin; y < row_end; ++y) {
  14.         for (int x = 0; x < image_width; ++x) {
  15.             int tilex = ((x + tile_offs_x) & 0b111);
  16.             int tiley = ((y + tile_offs_y) & 0b111);
  17.             int cellx = ((x + tile_offs_x) >> 3) & 0b111111;
  18.             int celly = ((y + tile_offs_y) >> 3) & 0b111111;
  19.             int cellid = cellx + celly * tiled_width;
  20.             int index = tile_map[cellid];
  21.  
  22.             uint32_t* psrc = &tile_data[index * tile_stride];
  23.             uint32_t src = psrc[tilex + tiley * TILE_SIZE];
  24.             uint32_t* dst = &backbuffer[x + y * image_width];
  25.             (src & 0xFF000000) ? *dst = src : 0;
  26.             //*dst = color32Mix(*dst, src);
  27.             //backbuffer[x + y * client_width] = src;
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement