libc8
CHIP-8 utility library
Loading...
Searching...
No Matches
debug.c File Reference
#include "debug.h"
#include "../chip8.h"
#include "../decode.h"
#include "../font.h"
#include "util.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Functions

int c8_debug_repl (C8 *c8)
 Debug command line loop.
 
int c8_has_breakpoint (C8 *c8, uint16_t pc)
 Check if breakpoint exists at address pc.
 

Variables

const char * c8_args []
 
const char * c8_cmds []
 

Detailed Description

Note
NOT EXPORTED

Stuff related to debug mode.

Function Documentation

◆ c8_debug_repl()

int c8_debug_repl ( C8 c8)

Debug command line loop.

This function parses user commands from stdin and prints the result until one of the following conditions is met:

  • continue command is evaluated (return C8_DEBUG_CONTINUE)
  • quit command is evaluated (return C8_DEBUG_QUIT)
  • next command is evaluated (return C8_DEBUG_STEP)
Parameters
c8the current CHIP-8 state
Returns
C8_DEBUG_CONTINUE, C8_DEBUG_STEP, or C8_DEBUG_QUIT

◆ c8_has_breakpoint()

int c8_has_breakpoint ( C8 c8,
uint16_t  pc 
)

Check if breakpoint exists at address pc.

This function checks if there is a breakpoint set at the specified program counter (pc) address in the C8 structure. It returns 1 if a breakpoint exists at that address, and 0 if no breakpoint is set.

Parameters
c8C8 to check breakpoints of
pcaddress to check for breakpoint at
Returns
1 if yes, 0 if no

Variable Documentation

◆ c8_args

const char* c8_args[]
Initial value:
= {
"SP", "DT", "ST", "PC", "I", "VK", "stack", "bg", "fg", "sfont", "bfont", "quirks",
}

These are string values of all possible argument, ordered to match the C8_Argument enumerator.

◆ c8_cmds

const char* c8_cmds[]
Initial value:
= {
"break", "rmbreak", "continue", "next", "set", "load",
"save", "print", "help", "quit", "loadflags", "saveflags",
}

These are string values of all possible commands, ordered to match the C8_Command enumerator.