116 const uint8_t* tiledata,
int indexoffset) {
119 constexpr int kGfxBufferSize = 0x10000;
120 constexpr int kMaxTileRow = 63;
123 int tile_col_idx = tile.
id_ % 16;
124 int tile_row_idx = tile.
id_ / 16;
127 if (tile_row_idx > kMaxTileRow) {
131 int tile_base_x = tile_col_idx * 8;
132 int tile_base_y = tile_row_idx * 1024;
144 uint8_t palette_offset;
145 if (pal >= 2 && pal <= 7) {
147 palette_offset = (pal - 2) * 16;
157 uint8_t priority = tile.
over_ ? 1 : 0;
160 for (
int py = 0; py < 8; py++) {
163 for (
int px = 0; px < 8; px++) {
168 int src_index = (src_row * 128) + src_col + tile_base_x + tile_base_y;
171 if (src_index < 0 || src_index >= kGfxBufferSize)
continue;
173 uint8_t pixel = tiledata[src_index];
178 uint8_t final_color = pixel + palette_offset;
179 int dest_index = indexoffset + (py *
width_) + px;
182 if (dest_index >= 0 && dest_index < max_dest) {
183 canvas[dest_index] = final_color;
263 int tile_address,
int tile_address_floor,
264 uint8_t floor_graphics) {
268 LOG_DEBUG(
"[DrawFloor]",
"Creating bitmap: %dx%d, active=%d, width=%d",
272 LOG_DEBUG(
"[DrawFloor]",
"After Create: active=%d, width=%d, height=%d",
276 "Bitmap already exists: active=%d, width=%d, height=%d",
280 auto floor_offset =
static_cast<uint8_t
>(floor_graphics << 4);
283 gfx::TileInfo floorTile1(rom_data[tile_address + floor_offset],
284 rom_data[tile_address + floor_offset + 1]);
285 gfx::TileInfo floorTile2(rom_data[tile_address + floor_offset + 2],
286 rom_data[tile_address + floor_offset + 3]);
287 gfx::TileInfo floorTile3(rom_data[tile_address + floor_offset + 4],
288 rom_data[tile_address + floor_offset + 5]);
289 gfx::TileInfo floorTile4(rom_data[tile_address + floor_offset + 6],
290 rom_data[tile_address + floor_offset + 7]);
292 gfx::TileInfo floorTile5(rom_data[tile_address_floor + floor_offset],
293 rom_data[tile_address_floor + floor_offset + 1]);
294 gfx::TileInfo floorTile6(rom_data[tile_address_floor + floor_offset + 2],
295 rom_data[tile_address_floor + floor_offset + 3]);
296 gfx::TileInfo floorTile7(rom_data[tile_address_floor + floor_offset + 4],
297 rom_data[tile_address_floor + floor_offset + 5]);
298 gfx::TileInfo floorTile8(rom_data[tile_address_floor + floor_offset + 6],
299 rom_data[tile_address_floor + floor_offset + 7]);
314 for (
int xx = 0; xx < 16; xx++) {
315 for (
int yy = 0; yy < 32; yy++) {
317 SetTileAt((xx * 4) + 1, (yy * 2), word2);
318 SetTileAt((xx * 4) + 2, (yy * 2), word3);
319 SetTileAt((xx * 4) + 3, (yy * 2), word4);
321 SetTileAt((xx * 4), (yy * 2) + 1, word5);
322 SetTileAt((xx * 4) + 1, (yy * 2) + 1, word6);
323 SetTileAt((xx * 4) + 2, (yy * 2) + 1, word7);
324 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.