/******************************************************************************
*
* FILENAME: debugger.h
*
* DESCRIPTION: Debug interface declarations using Nuklear moveable windows
*
******************************************************************************/
#ifndef gui_debugger_h
#define gui_debugger_h

#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_STANDARD_IO
#define NK_INCLUDE_STANDARD_VARARGS
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT

#include "nuklear.h"

/* Debug state structure */
struct debug_state {
    int active;                     /* Debug mode active */
    struct nk_rect cpu_bounds;      /* CPU window position/size */
    struct nk_rect antic_bounds;    /* ANTIC window position/size */
    struct nk_rect gtia_bounds;     /* GTIA window position/size */
    struct nk_rect pokey_bounds;    /* POKEY window position/size */
    struct nk_rect control_bounds;  /* Control panel position/size */
    struct nk_rect video_bounds;    /* Video display position/size */

    /* Memory page selector */
    int mem_page;
    char mem_page_buf[3];

    /* Hex edit buffers for CPU registers */
    char pc_buf[5];
    char sp_buf[3];
    char a_buf[3];
    char x_buf[3];
    char y_buf[3];

    /* Execution control */
    int trace_enabled;
    int paused;
    int in_halt;   /* 1 while inside debugger_breakpoint_halt() event loop */
};

/* Public functions */
void debugger_init(void);
void debugger_show(void);
void debugger_hide(void);
void debugger_draw(struct nk_context *ctx, int window_w, int window_h);
int debugger_is_active(void);
int debugger_wants_input(void);
void debugger_breakpoint_halt(void);

#endif
