yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::zelda3::DungeonObjectRenderer Class Reference

Renders dungeon objects from Link to the Past. More...

#include <object_renderer.h>

Inheritance diagram for yaze::zelda3::DungeonObjectRenderer:

Public Member Functions

 DungeonObjectRenderer ()=default
 
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.
 
void RenderObject (uint32_t routine_ptr)
 Executes the object drawing routine.
 
void UpdateObjectBitmap ()
 Updates the bitmap with the rendered object.
 
void SetPalette (const gfx::SnesPalette &palette, size_t transparent_index=0)
 Sets the palette for the rendered object.
 
gfx::Bitmapbitmap ()
 Gets the rendered bitmap.
 
auto memory ()
 Gets the memory implementation.
 
auto mutable_memory ()
 Gets a mutable pointer to the memory implementation.
 
- Public Member Functions inherited from yaze::SharedRom
 SharedRom ()=default
 
virtual ~SharedRom ()=default
 
std::shared_ptr< Romshared_rom ()
 
auto rom ()
 

Private Attributes

std::vector< uint8_t > tilemap_
 
std::vector< uint8_t > rom_data_
 
PseudoVram vram_
 
emu::MemoryImpl memory_
 
emu::CpuCallbacks cpu_callbacks_
 
emu::Ppu ppu {memory_}
 
emu::Cpu cpu {memory_, cpu_callbacks_}
 
gfx::Bitmap bitmap_
 

Additional Inherited Members

- Static Public Member Functions inherited from yaze::SharedRom
static void set_rom (Rom *rom)
 
- Static Public Attributes inherited from yaze::SharedRom
static std::shared_ptr< Romshared_rom_ = nullptr
 

Detailed Description

Renders dungeon objects from Link to the Past.

This class uses the emulator subsystem to simulate the SNES CPU drawing routines for dungeon objects. It captures the tile data written to memory and renders it to a bitmap.

Definition at line 34 of file object_renderer.h.

Constructor & Destructor Documentation

◆ DungeonObjectRenderer()

yaze::zelda3::DungeonObjectRenderer::DungeonObjectRenderer ( )
default

Member Function Documentation

◆ LoadObject()

void yaze::zelda3::DungeonObjectRenderer::LoadObject ( uint32_t routine_ptr,
std::array< uint8_t, 16 > & sheet_ids )

Loads and renders a dungeon object.

Parameters
routine_ptrPointer to the drawing routine in ROM
sheet_idsArray of graphics sheet IDs used by the object

Definition at line 6 of file object_renderer.cc.

References ConfigureObject(), memory_, RenderObject(), yaze::SharedRom::rom(), rom_data_, and vram_.

Here is the call graph for this function:

◆ ConfigureObject()

void yaze::zelda3::DungeonObjectRenderer::ConfigureObject ( )

Configures the CPU state for object rendering.

Definition at line 21 of file object_renderer.cc.

References cpu.

Referenced by LoadObject().

◆ RenderObject()

void yaze::zelda3::DungeonObjectRenderer::RenderObject ( uint32_t routine_ptr)

Executes the object drawing routine.

Parameters
routine_ptrPointer to the drawing routine in ROM

Example: the STA $BF, $CD, $C2, $CE are the location of the object in the room $B2 is used for size loop so if object size is setted on 07 that draw code will be repeated 7 times and since Y is increasing by 4 it makes the object draw from left to right

RoomDraw_Rightwards2x2_1to15or32: #_018B89: JSR RoomDraw_GetSize_1to15or32 .next #_018B8C: JSR RoomDraw_Rightwards2x2 #_018B8F: DEC.b $B2 #_018B91: BNE .next #_018B93: RTS

RoomDraw_Rightwards2x2: #_019895: LDA.w RoomDrawObjectData+0,X #_019898: STA.b [$BF],Y #_01989A: LDA.w RoomDrawObjectData+2,X #_01989D: STA.b [$CB],Y #_01989F: LDA.w RoomDrawObjectData+4,X #_0198A2: STA.b [$C2],Y #_0198A4: LDA.w RoomDrawObjectData+6,X #_0198A7: STA.b [$CE],Y #_0198A9: INY #4 #_0198AD: RTS

Definition at line 61 of file object_renderer.cc.

References cpu, and UpdateObjectBitmap().

Referenced by LoadObject().

Here is the call graph for this function:

◆ UpdateObjectBitmap()

void yaze::zelda3::DungeonObjectRenderer::UpdateObjectBitmap ( )

Updates the bitmap with the rendered object.

Definition at line 104 of file object_renderer.cc.

References bitmap_, yaze::GraphicsSheetManager::GetInstance(), memory_, yaze::GraphicsSheetManager::mutable_gfx_sheets(), tilemap_, and vram_.

Referenced by RenderObject().

Here is the call graph for this function:

◆ SetPalette()

void yaze::zelda3::DungeonObjectRenderer::SetPalette ( const gfx::SnesPalette & palette,
size_t transparent_index = 0 )

Sets the palette for the rendered object.

Parameters
paletteThe palette to use for the object
transparent_indexIndex of the transparent color (default: 0)

Definition at line 145 of file object_renderer.cc.

References bitmap_, and vram_.

◆ bitmap()

gfx::Bitmap * yaze::zelda3::DungeonObjectRenderer::bitmap ( )
inline

Gets the rendered bitmap.

Returns
gfx::Bitmap* Pointer to the bitmap

Definition at line 76 of file object_renderer.h.

References bitmap_.

◆ memory()

auto yaze::zelda3::DungeonObjectRenderer::memory ( )
inline

Gets the memory implementation.

Returns
Memory implementation

Definition at line 83 of file object_renderer.h.

References memory_.

◆ mutable_memory()

auto yaze::zelda3::DungeonObjectRenderer::mutable_memory ( )
inline

Gets a mutable pointer to the memory implementation.

Returns
Mutable pointer to the memory implementation

Definition at line 90 of file object_renderer.h.

References memory_.

Member Data Documentation

◆ tilemap_

std::vector<uint8_t> yaze::zelda3::DungeonObjectRenderer::tilemap_
private

Definition at line 93 of file object_renderer.h.

Referenced by UpdateObjectBitmap().

◆ rom_data_

std::vector<uint8_t> yaze::zelda3::DungeonObjectRenderer::rom_data_
private

Definition at line 94 of file object_renderer.h.

Referenced by LoadObject().

◆ vram_

PseudoVram yaze::zelda3::DungeonObjectRenderer::vram_
private

Definition at line 96 of file object_renderer.h.

Referenced by LoadObject(), SetPalette(), and UpdateObjectBitmap().

◆ memory_

emu::MemoryImpl yaze::zelda3::DungeonObjectRenderer::memory_
private

Definition at line 98 of file object_renderer.h.

Referenced by LoadObject(), memory(), mutable_memory(), and UpdateObjectBitmap().

◆ cpu_callbacks_

emu::CpuCallbacks yaze::zelda3::DungeonObjectRenderer::cpu_callbacks_
private

Definition at line 99 of file object_renderer.h.

◆ ppu

emu::Ppu yaze::zelda3::DungeonObjectRenderer::ppu {memory_}
private

Definition at line 100 of file object_renderer.h.

◆ cpu

emu::Cpu yaze::zelda3::DungeonObjectRenderer::cpu {memory_, cpu_callbacks_}
private

Definition at line 101 of file object_renderer.h.

Referenced by ConfigureObject(), and RenderObject().

◆ bitmap_

gfx::Bitmap yaze::zelda3::DungeonObjectRenderer::bitmap_
private

Definition at line 103 of file object_renderer.h.

Referenced by bitmap(), SetPalette(), and UpdateObjectBitmap().


The documentation for this class was generated from the following files: