7 std::array<uint8_t, 16>& sheet_ids) {
8 vram_.sheets = sheet_ids;
26 cpu.WriteLong(0xBF, 0x7E2000);
27 cpu.WriteLong(0xCB, 0x7E2080);
28 cpu.WriteLong(0xC2, 0x7E2002);
29 cpu.WriteLong(0xCE, 0x7E2082);
30 cpu.SetAccumulatorSize(
false);
31 cpu.SetIndexSize(
false);
70 cpu.PushLong(0x01 << 16 | 0xFFFF);
73 const int MAX_INSTRUCTIONS = 10000;
74 int instruction_count = 0;
77 while (instruction_count < MAX_INSTRUCTIONS) {
78 uint8_t opcode =
cpu.ReadByte(
cpu.PB << 16 |
cpu.PC);
83 cpu.ExecuteInstruction(opcode);
88 cpu.ExecuteInstruction(opcode);
93 if (instruction_count >= MAX_INSTRUCTIONS) {
94 std::cerr <<
"Warning: Object rendering hit maximum instruction count"
109 for (
int tile_index = 0; tile_index < 512; tile_index++) {
111 uint16_t tile_id =
memory_.ReadWord(0x7E2000 + tile_index * 2);
114 if (tile_id == 0)
continue;
117 int sheet_number = tile_id / 32;
120 if (sheet_number >=
vram_.sheets.size()) {
121 std::cerr <<
"Warning: Invalid sheet number " << sheet_number
127 int tile_x = (tile_index % 32) * 8;
128 int tile_y = (tile_index / 32) * 8;
132 vram_.sheets[sheet_number]);
135 int tilemap_offset = tile_y * 256 + tile_x;
138 sheet.Get8x8Tile(tile_id % 32, 0, 0,
tilemap_, tilemap_offset);
146 size_t transparent_index) {
148 bitmap_.SetPaletteWithTransparent(palette, transparent_index);
151 vram_.palettes.clear();
152 vram_.palettes.push_back(palette);
auto mutable_gfx_sheets()
static GraphicsSheetManager & GetInstance()
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
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 SetPalette(const gfx::SnesPalette &palette, size_t transparent_index=0)
Sets the palette for the rendered object.
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.