9 std::array<uint8_t, 16>& sheet_ids) {
10 vram_.sheets = sheet_ids;
23 snes_.cpu().A = 0x03D8;
24 snes_.cpu().X = 0x03D8;
25 snes_.cpu().DB = 0x7E;
27 snes_.cpu().WriteLong(0xBF, 0x7E2000);
28 snes_.cpu().WriteLong(0xCB, 0x7E2080);
29 snes_.cpu().WriteLong(0xC2, 0x7E2002);
30 snes_.cpu().WriteLong(0xCE, 0x7E2082);
31 snes_.cpu().SetAccumulatorSize(
false);
32 snes_.cpu().SetIndexSize(
false);
63 snes_.cpu().PB = 0x01;
64 snes_.cpu().PC = routine_ptr;
71 snes_.cpu().PushLong(0x01 << 16 | 0xFFFF);
74 const int MAX_INSTRUCTIONS = 10000;
75 int instruction_count = 0;
78 while (instruction_count < MAX_INSTRUCTIONS) {
85 snes_.cpu().ExecuteInstruction(opcode);
90 snes_.cpu().ExecuteInstruction(opcode);
95 if (instruction_count >= MAX_INSTRUCTIONS) {
96 std::cerr <<
"Warning: Object rendering hit maximum instruction count"
111 for (
int tile_index = 0; tile_index < 512; tile_index++) {
113 uint16_t tile_id =
snes_.memory().ReadWord(0x7E2000 + tile_index * 2);
116 if (tile_id == 0)
continue;
119 int sheet_number = tile_id / 32;
122 if (sheet_number >=
vram_.sheets.size()) {
123 std::cerr <<
"Warning: Invalid sheet number " << sheet_number
129 int tile_x = (tile_index % 32) * 8;
130 int tile_y = (tile_index / 32) * 8;
137 int tilemap_offset = tile_y * 256 + tile_x;
140 sheet.Get8x8Tile(tile_id % 32, 0, 0,
tilemap_, tilemap_offset);
auto mutable_gfx_sheets()
std::vector< uint8_t > tilemap_
void UpdateObjectBitmap()
Updates the bitmap with the rendered object.
std::vector< uint8_t > rom_data_
void RenderObject(uint32_t routine_ptr)
Executes the object drawing routine.
void LoadObject(uint32_t routine_ptr, std::array< uint8_t, 16 > &sheet_ids)
Loads and renders a dungeon object.
void ConfigureObject()
Configures the CPU state for object rendering.
Zelda 3 specific classes and functions.
Main namespace for the application.