#pragma once
#include <stdint.h>

namespace debug
{
    #define MEMTAG_NONE     0x00
    #define MEMTAG_DATA     0x01
    #define MEMTAG_INST     0x02
    #define MEMTAG_CODE     0x04
    #define MEMTAG_IGNORE   0x08
    #define MEMTAG_TDATA    0x10
    #define MEMTAG_TINST    0x20
    #define MEMTAG_TREPEAT  0x40
    #define MEMTAG_MODIFIED 0x80

    #define MEMTAG_KNOWN    0x07
    #define MEMTAG_TOUCHED  0x70

    uint8_t getTag(uint16_t address);
    void setTag(uint16_t address, uint8_t value);

    void onInstructionExecute(uint16_t address);
    void onMemRead(uint16_t address, bool code=false);
    void onMemWrite(uint16_t address);

    void init();
    void show();
    void focus();
    void hide();

    void pause();
    void stop();
    void cont();
    const bool debugging();
    const bool paused();

    void refresh();
    void sendToConsole(const char* text);
    void sendToConsoleLog(const char *text);
    void sendMoreToConsoleLog(const char *text);
    void DeleteCharConsole();
    void executeConsole();

    const bool isbreak(const uint16_t address, const uint8_t type=1);
    uint32_t next();
    uint32_t stepout();

    void savestate(const char *filename);
    void loadstate(const char *filename);

    void setcursor(const uint16_t address);
    void cursorfwd();
    void cursorback();

    void useOpcode(const uint8_t opcode, const uint8_t base);
    void clearUsedOpcodes();
    void markUsedOpcodes();
    const int getNumOpcodesUsed();
    void printOpcodesUsed();

    void search(const char *seq=nullptr);
    
    namespace history
    {
        void store();
        void gototop();
        void goforward();
        void goback();
    }
}