yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze_debug_inspector.cc File Reference

WASM debug inspector for yaze - palette, overworld, and emulator access. More...

#include <emscripten.h>
#include <emscripten/bind.h>
#include <atomic>
#include <iomanip>
#include <sstream>
#include <unordered_map>
#include "yaze.h"
#include "app/emu/emulator.h"
#include "app/emu/snes.h"
#include "app/emu/video/ppu.h"
#include "app/gfx/resource/arena.h"
#include "rom/rom.h"
#include "zelda3/dungeon/palette_debug.h"
#include "zelda3/game_data.h"
#include "app/editor/editor_manager.h"
#include "app/editor/editor.h"
#include "app/editor/agent/agent_session.h"
#include "app/editor/agent/agent_editor.h"
#include "app/editor/agent/agent_chat.h"
#include "cli/service/agent/conversational_agent_service.h"
#include "cli/service/ai/common.h"
#include "nlohmann/json.hpp"

Go to the source code of this file.

Namespaces

namespace  yaze
 
namespace  yaze::cli
 Namespace for the command line interface.
 
namespace  yaze::app
 
namespace  anonymous_namespace{yaze_debug_inspector.cc}
 

Functions

Romyaze::cli::GetGlobalRom ()
 
yaze::emu::Emulatoryaze::app::GetGlobalEmulator ()
 
yaze::editor::EditorManageryaze::app::GetGlobalEditorManager ()
 
const char * Z3edProcessCommand (const char *command)
 
yaze::emu::Emulatoranonymous_namespace{yaze_debug_inspector.cc}::GetGlobalEmulator ()
 
yaze::editor::EditorManageranonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager ()
 
 anonymous_namespace{yaze_debug_inspector.cc}::EM_JS (void, CallJsAiDriver,(const char *history_json), { if(window.yaze &&window.yaze.ai &&window.yaze.ai.processAgentRequest) { window.yaze.ai.processAgentRequest(UTF8ToString(history_json));} else { console.error("AI Driver not found in window.yaze.ai.processAgentRequest");} })
 
nlohmann::json anonymous_namespace{yaze_debug_inspector.cc}::MessageToJson (const yaze::cli::agent::ChatMessage &msg)
 
std::string anonymous_namespace{yaze_debug_inspector.cc}::registerExternalAiDriver ()
 
void anonymous_namespace{yaze_debug_inspector.cc}::onExternalAiResponse (std::string response_json)
 
yaze::editor::EditorType anonymous_namespace{yaze_debug_inspector.cc}::ParseEditorType (const std::string &name)
 
std::string getEditorState ()
 
std::string executeCommand (std::string command)
 
std::string switchToEditor (std::string editor_name)
 
std::string switchToEditorAsync (std::string editor_name)
 Switch to an editor asynchronously with operation tracking.
 
std::string getOperationStatus (uint32_t op_id)
 Get the status of an async operation.
 
std::string showPanel (std::string card_id)
 Show a card by ID.
 
std::string hidePanel (std::string card_id)
 Hide a card by ID.
 
std::string togglePanel (std::string card_id)
 Toggle a card's visibility.
 
std::string getPanelState ()
 Get the visibility state of all cards.
 
std::string getPanelsInCategory (std::string category)
 Get cards in a specific category.
 
std::string showPanelGroup (std::string group_name)
 Show a predefined group of cards.
 
std::string hidePanelGroup (std::string group_name)
 Hide a predefined group of cards.
 
std::string getPanelGroups ()
 Get available card groups.
 
bool isTreeViewMode ()
 Check if tree view mode is enabled.
 
std::string setTreeViewMode (bool enabled)
 Set tree view mode.
 
std::string toggleTreeViewMode ()
 Toggle tree view mode.
 
std::string getSidebarState ()
 Get sidebar state including view mode and width.
 
std::string openRightPanel (std::string panel_name)
 Open a specific right panel.
 
std::string closeRightPanel ()
 Close the currently open right panel.
 
std::string toggleRightPanel (std::string panel_name)
 Toggle a specific right panel.
 
std::string getRightPanelState ()
 Get the state of the right panel.
 
std::string getDungeonPaletteEvents ()
 
std::string getColorComparisons ()
 
std::string samplePixelAt (int x, int y)
 
void clearPaletteDebugEvents ()
 
std::string getFullPaletteState ()
 
std::string getPaletteData ()
 
std::string getEventTimeline ()
 
std::string getDiagnosticSummary ()
 
std::string getHypothesisAnalysis ()
 
std::string getArenaStatus ()
 
std::string getGfxSheetInfo (int index)
 
std::string getRomStatus ()
 
std::string readRomBytes (int address, int count)
 
std::string getRomPaletteGroup (const std::string &group_name, int palette_index)
 
std::string getOverworldMapInfo (int map_id)
 
std::string getOverworldTileInfo (int map_id, int tile_x, int tile_y)
 
std::string getEmulatorStatus ()
 Get the current emulator status including CPU state.
 
std::string readEmulatorMemory (int address, int count)
 Read memory from the emulator's WRAM.
 
std::string getEmulatorVideoState ()
 Get PPU (video) state from the emulator.
 
std::string getYazeVersion ()
 
std::string getRomSessions ()
 
std::string getFileManagerDebugInfo ()
 
void resumeAudioContext ()
 
std::string getGraphicsDiagnostics ()
 
std::string getFullDebugState ()
 
 EMSCRIPTEN_BINDINGS (yaze_debug_inspector)
 

Variables

std::atomic< uint32_t > anonymous_namespace{yaze_debug_inspector.cc}::g_operation_counter {0}
 
std::unordered_map< uint32_t, std::string > anonymous_namespace{yaze_debug_inspector.cc}::g_pending_operations
 

Detailed Description

WASM debug inspector for yaze - palette, overworld, and emulator access.

This file provides JavaScript bindings for debugging infrastructure used by Gemini/Antigravity AI integration to analyze rendering issues and game state.

Definition in file yaze_debug_inspector.cc.

Function Documentation

◆ Z3edProcessCommand()

const char * Z3edProcessCommand ( const char * command)

Referenced by executeCommand().

◆ getEditorState()

std::string getEditorState ( )

Definition at line 237 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager(), yaze::editor::kDungeon, and yaze::editor::kEditorNames.

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ executeCommand()

std::string executeCommand ( std::string command)

Definition at line 262 of file yaze_debug_inspector.cc.

References Z3edProcessCommand().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ switchToEditor()

std::string switchToEditor ( std::string editor_name)

◆ switchToEditorAsync()

std::string switchToEditorAsync ( std::string editor_name)

Switch to an editor asynchronously with operation tracking.

Returns an operation ID that can be polled with getOperationStatus(). The operation completes on the next ImGui frame when the deferred action executes.

Parameters
editor_nameName of the editor to switch to
Returns
JSON with op_id and initial status, or error

Definition at line 312 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::g_operation_counter, anonymous_namespace{yaze_debug_inspector.cc}::g_pending_operations, yaze::app::GetGlobalEditorManager(), yaze::editor::kAgent, yaze::editor::kSettings, yaze::editor::kUnknown, and anonymous_namespace{yaze_debug_inspector.cc}::ParseEditorType().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getOperationStatus()

std::string getOperationStatus ( uint32_t op_id)

Get the status of an async operation.

Parameters
op_idThe operation ID returned by switchToEditorAsync
Returns
JSON with status: "pending", "completed:EditorName", or "error:message"

Definition at line 365 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::g_pending_operations.

Referenced by EMSCRIPTEN_BINDINGS().

◆ showPanel()

std::string showPanel ( std::string card_id)

Show a card by ID.

Parameters
card_idPanel identifier (e.g., "dungeon.room_selector")
Returns
JSON with success status

Definition at line 427 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ hidePanel()

std::string hidePanel ( std::string card_id)

Hide a card by ID.

Definition at line 448 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ togglePanel()

std::string togglePanel ( std::string card_id)

Toggle a card's visibility.

Definition at line 467 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getPanelState()

std::string getPanelState ( )

Get the visibility state of all cards.

Returns
JSON with all cards, their visibility, and categories

Definition at line 498 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getPanelsInCategory()

std::string getPanelsInCategory ( std::string category)

Get cards in a specific category.

Definition at line 540 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ showPanelGroup()

std::string showPanelGroup ( std::string group_name)

Show a predefined group of cards.

Definition at line 574 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ hidePanelGroup()

std::string hidePanelGroup ( std::string group_name)

Hide a predefined group of cards.

Definition at line 606 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getPanelGroups()

std::string getPanelGroups ( )

Get available card groups.

Definition at line 641 of file yaze_debug_inspector.cc.

Referenced by EMSCRIPTEN_BINDINGS().

◆ isTreeViewMode()

bool isTreeViewMode ( )

Check if tree view mode is enabled.

Definition at line 671 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ setTreeViewMode()

std::string setTreeViewMode ( bool enabled)

Set tree view mode.

Definition at line 681 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ toggleTreeViewMode()

std::string toggleTreeViewMode ( )

Toggle tree view mode.

Definition at line 695 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getSidebarState()

std::string getSidebarState ( )

Get sidebar state including view mode and width.

Definition at line 710 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager(), yaze::editor::PanelManager::GetSidebarWidth(), and yaze::editor::PanelManager::GetSidePanelWidth().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ openRightPanel()

std::string openRightPanel ( std::string panel_name)

Open a specific right panel.

Definition at line 743 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ closeRightPanel()

std::string closeRightPanel ( )

Close the currently open right panel.

Definition at line 778 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ toggleRightPanel()

std::string toggleRightPanel ( std::string panel_name)

Toggle a specific right panel.

Definition at line 796 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getRightPanelState()

std::string getRightPanelState ( )

Get the state of the right panel.

Definition at line 834 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getDungeonPaletteEvents()

std::string getDungeonPaletteEvents ( )

Definition at line 882 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getColorComparisons()

std::string getColorComparisons ( )

Definition at line 886 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ samplePixelAt()

std::string samplePixelAt ( int x,
int y )

Definition at line 890 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ clearPaletteDebugEvents()

void clearPaletteDebugEvents ( )

Definition at line 894 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Clear(), and yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getFullPaletteState()

std::string getFullPaletteState ( )

Definition at line 899 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS(), and getFullDebugState().

Here is the call graph for this function:

◆ getPaletteData()

std::string getPaletteData ( )

Definition at line 903 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getEventTimeline()

std::string getEventTimeline ( )

Definition at line 907 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getDiagnosticSummary()

std::string getDiagnosticSummary ( )

Definition at line 911 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS(), and getFullDebugState().

Here is the call graph for this function:

◆ getHypothesisAnalysis()

std::string getHypothesisAnalysis ( )

Definition at line 915 of file yaze_debug_inspector.cc.

References yaze::zelda3::PaletteDebugger::Get().

Referenced by EMSCRIPTEN_BINDINGS(), and getFullDebugState().

Here is the call graph for this function:

◆ getArenaStatus()

std::string getArenaStatus ( )

Definition at line 923 of file yaze_debug_inspector.cc.

References yaze::gfx::Arena::Get().

Referenced by EMSCRIPTEN_BINDINGS(), and getFullDebugState().

Here is the call graph for this function:

◆ getGfxSheetInfo()

std::string getGfxSheetInfo ( int index)

Definition at line 952 of file yaze_debug_inspector.cc.

References yaze::gfx::Arena::Get().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getRomStatus()

std::string getRomStatus ( )

Definition at line 987 of file yaze_debug_inspector.cc.

References yaze::cli::GetGlobalRom().

Referenced by EMSCRIPTEN_BINDINGS(), and getFullDebugState().

Here is the call graph for this function:

◆ readRomBytes()

std::string readRomBytes ( int address,
int count )

Definition at line 1005 of file yaze_debug_inspector.cc.

References yaze::cli::GetGlobalRom().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getRomPaletteGroup()

std::string getRomPaletteGroup ( const std::string & group_name,
int palette_index )

◆ getOverworldMapInfo()

std::string getOverworldMapInfo ( int map_id)

Definition at line 1081 of file yaze_debug_inspector.cc.

References yaze::cli::GetGlobalRom().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getOverworldTileInfo()

std::string getOverworldTileInfo ( int map_id,
int tile_x,
int tile_y )

Definition at line 1124 of file yaze_debug_inspector.cc.

References yaze::cli::GetGlobalRom().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getEmulatorStatus()

std::string getEmulatorStatus ( )

Get the current emulator status including CPU state.

Returns JSON with:

  • initialized: whether the emulator is ready
  • running: whether the emulator is currently executing
  • cpu: register values (A, X, Y, SP, PC, D, DB, PB, P/status)
  • cycles: total cycles executed
  • fps: current frames per second

CPU status flags (P register):

  • N (0x80): Negative
  • V (0x40): Overflow
  • M (0x20): Accumulator size (0=16-bit, 1=8-bit)
  • X (0x10): Index size (0=16-bit, 1=8-bit)
  • D (0x08): Decimal mode
  • I (0x04): IRQ disable
  • Z (0x02): Zero
  • C (0x01): Carry
  • E: Emulation mode (6502 compatibility)

Definition at line 1169 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetGlobalEmulator().

Referenced by EMSCRIPTEN_BINDINGS(), and getFullDebugState().

Here is the call graph for this function:

◆ readEmulatorMemory()

std::string readEmulatorMemory ( int address,
int count )

Read memory from the emulator's WRAM.

Parameters
addressStarting address (SNES address space, e.g., 0x7E0000 for WRAM)
countNumber of bytes to read (max 256)
Returns
JSON with address, count, and bytes array

Memory map reference:

  • $7E0000-$7E1FFF: Low RAM (first 8KB, mirrored in banks $00-$3F)
  • $7E2000-$7FFFFF: High RAM (additional ~120KB)
  • $7F0000-$7FFFFF: Extended RAM (second 64KB bank)

Definition at line 1244 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetGlobalEmulator().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getEmulatorVideoState()

std::string getEmulatorVideoState ( )

Get PPU (video) state from the emulator.

Returns JSON with:

  • current_scanline: Current rendering scanline
  • h_pos / v_pos: Horizontal/vertical position
  • mode: Current BG mode (0-7)
  • brightness: Screen brightness level
  • forced_blank: Whether screen is blanked
  • overscan: Whether overscan is enabled
  • interlace: Whether interlacing is enabled

Definition at line 1296 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetGlobalEmulator().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getYazeVersion()

std::string getYazeVersion ( )

Definition at line 1341 of file yaze_debug_inspector.cc.

References YAZE_VERSION_STRING.

Referenced by EMSCRIPTEN_BINDINGS().

◆ getRomSessions()

std::string getRomSessions ( )

Definition at line 1345 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getFileManagerDebugInfo()

std::string getFileManagerDebugInfo ( )

Definition at line 1377 of file yaze_debug_inspector.cc.

References yaze::app::GetGlobalEditorManager(), and yaze::cli::GetGlobalRom().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ resumeAudioContext()

void resumeAudioContext ( )

Definition at line 1417 of file yaze_debug_inspector.cc.

References anonymous_namespace{yaze_debug_inspector.cc}::GetGlobalEmulator().

Referenced by EMSCRIPTEN_BINDINGS().

Here is the call graph for this function:

◆ getGraphicsDiagnostics()

std::string getGraphicsDiagnostics ( )

Definition at line 1428 of file yaze_debug_inspector.cc.

References yaze::cli::GetGlobalRom().

Here is the call graph for this function:

◆ getFullDebugState()

◆ EMSCRIPTEN_BINDINGS()