141 const uint8_t* tiledata,
int indexoffset) {
144 constexpr int kGfxBufferSize = 0x10000;
145 constexpr int kMaxTileRow = 63;
148 int tile_col_idx = tile.
id_ % 16;
149 int tile_row_idx = tile.
id_ / 16;
152 if (tile_row_idx > kMaxTileRow) {
156 int tile_base_x = tile_col_idx * 8;
164 const uint8_t pal = tile.
palette_ & 0x07;
165 const uint8_t palette_offset =
static_cast<uint8_t
>(pal * 16);
171 uint8_t priority = tile.
over_ ? 1 : 0;
174 for (
int py = 0; py < 8; py++) {
177 for (
int px = 0; px < 8; px++) {
182 int src_index = (src_row * 128) + src_col + tile_base_x + tile_base_y;
185 if (src_index < 0 || src_index >= kGfxBufferSize)
188 uint8_t pixel = tiledata[src_index];
193 uint8_t final_color = pixel + palette_offset;
194 int dest_index = indexoffset + (py *
width_) + px;
197 if (dest_index >= 0 && dest_index < max_dest) {
198 canvas[dest_index] = final_color;
273 int tile_address,
int tile_address_floor,
274 uint8_t floor_graphics) {
278 LOG_DEBUG(
"[DrawFloor]",
"Creating bitmap: %dx%d, active=%d, width=%d",
282 LOG_DEBUG(
"[DrawFloor]",
"After Create: active=%d, width=%d, height=%d",
286 "Bitmap already exists: active=%d, width=%d, height=%d",
290 auto floor_offset =
static_cast<uint8_t
>(floor_graphics << 4);
293 gfx::TileInfo floorTile1(rom_data[tile_address + floor_offset],
294 rom_data[tile_address + floor_offset + 1]);
295 gfx::TileInfo floorTile2(rom_data[tile_address + floor_offset + 2],
296 rom_data[tile_address + floor_offset + 3]);
297 gfx::TileInfo floorTile3(rom_data[tile_address + floor_offset + 4],
298 rom_data[tile_address + floor_offset + 5]);
299 gfx::TileInfo floorTile4(rom_data[tile_address + floor_offset + 6],
300 rom_data[tile_address + floor_offset + 7]);
302 gfx::TileInfo floorTile5(rom_data[tile_address_floor + floor_offset],
303 rom_data[tile_address_floor + floor_offset + 1]);
304 gfx::TileInfo floorTile6(rom_data[tile_address_floor + floor_offset + 2],
305 rom_data[tile_address_floor + floor_offset + 3]);
306 gfx::TileInfo floorTile7(rom_data[tile_address_floor + floor_offset + 4],
307 rom_data[tile_address_floor + floor_offset + 5]);
308 gfx::TileInfo floorTile8(rom_data[tile_address_floor + floor_offset + 6],
309 rom_data[tile_address_floor + floor_offset + 7]);
324 for (
int xx = 0; xx < 16; xx++) {
325 for (
int yy = 0; yy < 32; yy++) {
327 SetTileAt((xx * 4) + 1, (yy * 2), word2);
328 SetTileAt((xx * 4) + 2, (yy * 2), word3);
329 SetTileAt((xx * 4) + 3, (yy * 2), word4);
331 SetTileAt((xx * 4), (yy * 2) + 1, word5);
332 SetTileAt((xx * 4) + 1, (yy * 2) + 1, word6);
333 SetTileAt((xx * 4) + 2, (yy * 2) + 1, word7);
334 SetTileAt((xx * 4) + 3, (yy * 2) + 1, word8);
void Create(int width, int height, int depth, std::span< uint8_t > data)
Create a bitmap with the given dimensions and data.