347 }
else if (
id_ == 0x05) {
350 }
else if (
id_ == 0x06) {
353 }
else if (
id_ == 0x09) {
357 }
else if (
id_ == 0x14) {
389 }
else if (
id_ == 0x01) {
392 }
else if (
id_ == 0x02) {
394 }
else if (
id_ == 0x04) {
399 }
else if (
id_ == 0x05) {
404 }
else if (
id_ == 0x06) {
409 }
else if (
id_ == 0x07) {
414 }
else if (
id_ == 0x08) {
417 }
else if (
id_ == 0x09) {
431 }
else if (
id_ == 0x0A) {
434 }
else if (
id_ == 0x0B) {
436 }
else if (
id_ == 0x0C) {
439 }
else if (
id_ == 0x0D) {
441 }
else if (
id_ == 0x0E) {
443 }
else if (
id_ == 0x0F) {
446 }
else if (
id_ == 0x10) {
448 }
else if (
id_ == 0x11) {
457 }
else if (
id_ == 0x12) {
460 }
else if (
id_ == 0x13) {
462 }
else if (
id_ == 0x15) {
470 }
else if (
id_ == 0x16) {
473 }
else if (
id_ == 0x17)
476 }
else if (
id_ == 0x18)
486 }
else if (
id_ == 0x19)
489 }
else if (
id_ == 0x1A)
494 }
else if (
id_ == 0x1C)
499 }
else if (
id_ == 0x1E)
502 }
else if (
id_ == 0x1F)
510 }
else if (
id_ == 0x20) {
512 }
else if (
id_ == 0x21)
517 }
else if (
id_ == 0x22)
520 }
else if (
id_ == 0x23)
524 }
else if (
id_ == 0x24)
528 }
else if (
id_ == 0x25)
531 }
else if (
id_ == 0x26)
533 if ((
x & 0x01) == 0x00) {
540 }
else if (
id_ == 0x27)
543 }
else if (
id_ == 0x28)
546 }
else if (
id_ == 0x29)
549 }
else if (
id_ == 0x2A)
552 }
else if (
id_ == 0x2B)
555 }
else if (
id_ == 0x2C)
577 }
else if (
id_ == 0x2D)
580 }
else if (
id_ == 0x2E)
583 }
else if (
id_ == 0x2F)
586 }
else if (
id_ == 0x30)
589 }
else if (
id_ == 0x31)
592 }
else if (
id_ == 0x32)
602 else if (
id_ == 0x34)
605 }
else if (
id_ == 0x35)
608 }
else if (
id_ == 0x36)
618 else if (
id_ == 0x38)
621 }
else if (
id_ == 0x39)
624 }
else if (
id_ == 0x3A)
627 }
else if (
id_ == 0x3B)
629 }
else if (
id_ == 0x3C)
632 }
else if (
id_ == 0x3D)
635 }
else if (
id_ == 0x3E)
638 }
else if (
id_ == 0x3F)
641 }
else if (
id_ == 0x40)
648 }
else if (
id_ == 0x41)
657 }
else if (
id_ == 0x42)
666 }
else if (
id_ == 0x43)
675 }
else if (
id_ == 0x44)
682 }
else if (
id_ == 0x45)
691 }
else if (
id_ == 0x46)
700 }
else if (
id_ == 0x47)
708 }
else if (
id_ == 0x48)
715 }
else if (
id_ == 0x49)
723 }
else if (
id_ == 0x4A)
729 }
else if (
id_ == 0x4B)
734 }
else if (
id_ == 0x4C)
737 }
else if (
id_ == 0x4D)
740 }
else if (
id_ == 0x4E)
743 }
else if (
id_ == 0x4F)
746 }
else if (
id_ == 0x50)
749 }
else if (
id_ == 0x51)
752 }
else if (
id_ == 0x53)
755 }
else if (
id_ == 0x54) {
759 }
else if (
id_ == 0x55)
762 }
else if (
id_ == 0x56)
766 }
else if (
id_ == 0x57)
770 }
else if (
id_ == 0x58)
774 }
else if (
id_ == 0x5B)
777 }
else if (
id_ == 0x5C)
780 }
else if (
id_ == 0x5D)
783 if (((
y * 16) & 0x10) == 0x10) {
786 for (
int i = 0; i < 7; i++) {
798 }
else if (
id_ == 0x5E)
801 if (((
y * 16) & 0x10) == 0x10) {
804 for (
int i = 0; i < 7; i++) {
815 }
else if (
id_ == 0x5F)
817 if (((
x * 16) & 0x10) == 0x10) {
823 for (
int i = 0; i < 7; i++) {
830 }
else if (
id_ == 0x60)
833 if (((
x * 16) & 0x10) == 0x10) {
839 for (
int i = 0; i < 7; i++) {
847 }
else if (
id_ == 0x61)
851 }
else if (
id_ == 0x63)
858 }
else if (
id_ == 0x64)
865 }
else if (
id_ == 0x66)
868 }
else if (
id_ == 0x67)
871 }
else if (
id_ == 0x68)
874 }
else if (
id_ == 0x69)
877 }
else if (
id_ == 0x6A)
883 }
else if (
id_ == 0x6B)
889 }
else if (
id_ == 0x6C)
892 }
else if (
id_ == 0x6D)
895 }
else if (
id_ == 0x6E)
898 }
else if (
id_ == 0x6F) {
900 }
else if (
id_ == 0x70)
903 }
else if (
id_ == 0x71)
906 }
else if (
id_ == 0x73)
908 }
else if (
id_ == 0x79)
911 }
else if (
id_ == 0x7C)
914 }
else if (
id_ == 0x7D)
920 }
else if (
id_ == 0x7E)
926 }
else if (
id_ == 0x7F)
932 }
else if (
id_ == 0x80)
939 }
else if (
id_ == 0x81)
942 }
else if (
id_ == 0x82)
949 DrawSpriteTile((
x * 16 + 14) - 4, (
y * 16 + 8) - 16, 3, 30, 5,
false,
false,
951 DrawSpriteTile((
x * 16 + 8) - 4, (
y * 16 + 14) - 16, 3, 30, 5,
false,
false,
960 DrawSpriteTile((
x * 16 + 14) - 16, (
y * 16 + 8) - 4, 3, 30, 5,
false,
false,
962 DrawSpriteTile((
x * 16 + 8) - 16, (
y * 16 + 14) - 4, 3, 30, 5,
false,
false,
988 }
else if (
id_ == 0x83)
992 }
else if (
id_ == 0x84)
996 }
else if (
id_ == 0x85)
1000 }
else if (
id_ == 0x86)
1003 }
else if (
id_ == 0x88)
1007 }
else if (
id_ == 0x8A)
1010 }
else if (
id_ == 0x8B)
1014 }
else if (
id_ == 0x8C)
1018 }
else if (
id_ == 0x8D)
1021 }
else if (
id_ == 0x8E)
1024 }
else if (
id_ == 0x8F)
1027 }
else if (
id_ == 0x90)
1031 DrawSpriteTile((
x * 16) + 16, (
y * 16) + 8, 9, 26, 12,
false,
false, 1, 2);
1033 DrawSpriteTile((
x * 16) + 8, (
y * 16) + 16, 8, 27, 12,
false,
false, 1, 1);
1034 }
else if (
id_ == 0x91)
1039 DrawSpriteTile((
x * 16) + 11, (
y * 16) + 16, 4, 23, 12,
true,
false, 1, 1);
1040 DrawSpriteTile((
x * 16) - 3, (
y * 16) + 16, 4, 23, 12,
false,
false, 1, 1);
1045 }
else if (
id_ == 0x92)
1057 }
else if (
id_ == 0x93)
1063 }
else if (
id_ == 0x95)
1067 }
else if (
id_ == 0x96)
1071 }
else if (
id_ == 0x97)
1075 }
else if (
id_ == 0x98)
1079 }
else if (
id_ == 0x99) {
1082 }
else if (
id_ == 0x9A)
1085 }
else if (
id_ == 0x9B)
1089 }
else if (
id_ == 0x9C)
1093 }
else if (
id_ == 0x9D)
1099 }
else if (
id_ == 0xA1) {
1102 }
else if (
id_ == 0xA2) {
1104 }
else if (
id_ == 0xA5) {
1107 }
else if (
id_ == 0xA6) {
1110 }
else if (
id_ == 0xA7) {
1115 }
else if (
id_ == 0xAC) {
1117 }
else if (
id_ == 0xAD) {
1120 }
else if (
id_ == 0xBA) {
1122 }
else if (
id_ == 0xC1 ||
id_ == 0x7A) {
1124 DrawSpriteTile((
x * 16) + 16, (
y * 16) - 16, 2, 24, 12,
true,
false, 2, 4);
1125 }
else if (
id_ == 0xC3) {
1127 }
else if (
id_ == 0xC4) {
1130 }
else if (
id_ == 0xC5) {
1131 }
else if (
id_ == 0xC6) {
1132 DrawSpriteTile((
x * 16) + 4, (
y * 16) + 14, 3, 30, 14,
false,
false, 1, 1);
1133 DrawSpriteTile((
x * 16) + 14, (
y * 16) + 4, 3, 30, 14,
false,
false, 1, 1);
1137 }
else if (
id_ == 0xC7) {
1142 }
else if (
id_ == 0xC8) {
1145 }
else if (
id_ == 0xC9) {
1148 }
else if (
id_ == 0xCA) {
1150 }
else if (
id_ == 0xD0) {
1153 }
else if (
id_ == 0xD1) {
1161 }
else if (
id_ == 0xD4) {
1164 }
else if (
id_ == 0xE3)
1167 }
else if (
id_ == 0xE4)
1170 }
else if (
id_ == 0xE7)
1173 }
else if (
id_ == 0xE8)
1177 }
else if (
id_ == 0xEB) {
1179 }
else if (
id_ == 0xF2) {
1181 DrawSpriteTile((
x * 16) + 16, (
y * 16) - 16, 12, 24, 2,
true,
false, 2, 4);
1182 }
else if (
id_ == 0xF4) {
1196 std::span<const uint8_t> graphics_resource) {
1198 if (graphics.empty()) {
1202 std::vector<uint8_t> resource_graphics;
1203 if (layout_override !=
nullptr && layout_override->
sprite_id ==
id_ &&
1207 constexpr size_t kObjPageBytes = 0x2000;
1208 constexpr size_t kPageOneOffset = 0x300 * 64;
1209 if (graphics_resource.size() != kObjPageBytes ||
1210 graphics.size() < kPageOneOffset + kObjPageBytes * 2) {
1213 resource_graphics.assign(graphics.begin(), graphics.end());
1214 for (
size_t tile_id = 0; tile_id < 256; ++tile_id) {
1216 const size_t tile_offset =
1217 kPageOneOffset + (tile_id / 16) * 1024 + (tile_id % 16) * 8;
1218 for (
size_t row = 0; row < 8; ++row) {
1219 std::copy_n(tile.data + row * 8, 8,
1220 resource_graphics.begin() + tile_offset + row * 128);
1223 graphics = resource_graphics;
1229 const uint8_t old_nx =
nx_;
1230 const uint8_t old_ny =
ny_;
1231 const int old_x =
x_;
1232 const int old_y =
y_;
1241 const auto draw_preview = [&]() {
1242 if (layout_override !=
nullptr && layout_override->
sprite_id ==
id_) {
1244 for (
auto tile = layout_override->
tiles.rbegin();
1245 tile != layout_override->
tiles.rend(); ++tile) {
1246 if (tile->tile_id > 0x1FF || tile->palette > 7) {
1249 const int size = tile->size_16x16 ? 2 : 1;
1252 DrawSpriteTile(tile->x_offset, tile->y_offset, tile->tile_id % 16,
1253 tile->tile_id / 16, 2 + tile->palette * 2, tile->flip_x,
1254 tile->flip_y, size, size);
1287 bool mirror_x,
bool mirror_y,
int sizex,
1290 const uint8_t* gfx_data =
1292 const size_t gfx_size =
1295 if (gfx_data ==
nullptr || gfx_size == 0) {
1300 if (sizex <= 0 || sizey <= 0) {
1304 if (srcx < 0 || srcy < 0 || pal < 0) {
1308 int drawid_ = (srcx + (srcy * 16)) + 512;
1311 if (drawid_ < 0 || drawid_ > 4096) {
1326 if (use_external_8bpp) {
1340 if (use_external_8bpp) {
1341 const int width = sizex * 8;
1342 const int height = sizey * 8;
1343 constexpr int kTilesPerRow = 16;
1344 constexpr int kTileSize = 8;
1345 constexpr int kTileRowStride = 1024;
1346 constexpr int kPixelRowStride = 128;
1348 for (
int dest_y = 0; dest_y <
height; ++dest_y) {
1349 const int src_y = mirror_y ? (
height - 1 - dest_y) : dest_y;
1350 const int src_tile_y = src_y / kTileSize;
1351 const int src_py = src_y % kTileSize;
1353 for (
int dest_x = 0; dest_x <
width; ++dest_x) {
1354 const int src_x = mirror_x ? (
width - 1 - dest_x) : dest_x;
1355 const int src_tile_x = src_x / kTileSize;
1356 const int src_px = src_x % kTileSize;
1357 const int tile_id = drawid_ + (src_tile_y * kTilesPerRow) + src_tile_x;
1362 const int tile_col = tile_id % kTilesPerRow;
1363 const int tile_row = tile_id / kTilesPerRow;
1364 const int gfx_index = (tile_row * kTileRowStride) +
1365 (src_py * kPixelRowStride) +
1366 (tile_col * kTileSize) + src_px;
1367 if (gfx_index < 0 || gfx_index >=
static_cast<int>(gfx_size)) {
1371 const uint8_t pixel = gfx_data[gfx_index] & 0x0F;
1376 const int preview_x =
x + dest_x;
1377 const int preview_y =
y + dest_y;
1378 if (preview_x < 0 || preview_x >=
preview_bounds_.w || preview_y < 0 ||
1383 if (index >= 0 && index <
static_cast<int>(
preview_gfx_.size())) {
1385 static_cast<uint8_t
>((pixel & 0x0F) + 112 + (pal * 8));
1392 for (
auto yl = 0; yl < sizey * 8; yl++) {
1393 for (
auto xl = 0; xl < (sizex * 8) / 2; xl++) {
1398 mx = (((sizex * 8) / 2) - 1) - xl;
1401 my = ((sizey * 8) - 1) - yl;
1407 int tx = ((drawid_ / 0x10) * 0x400) +
1408 ((drawid_ - ((drawid_ / 0x10) * 0x10)) * 8);
1411 int gfx_index = tx + (yl * 0x80) + xl;
1412 if (gfx_index < 0 || gfx_index >=
static_cast<int>(gfx_size)) {
1416 auto pixel = gfx_data[gfx_index];
1419 int index = (
x) + (
y * 64) + (mx + (my * 0x80));
1422 if (index >= 0 && index <
static_cast<int>(
preview_gfx_.size()) &&
1424 preview_gfx_[index] = (uint8_t)((pixel & 0x0F) + 112 + (pal * 8));
void DrawSpriteTile(int x, int y, int srcx, int srcy, int pal, bool mirror_x=false, bool mirror_y=false, int sizex=2, int sizey=2)