All files / src/lib/debugger readDebuggerSymbols.ts

25% Statements 3/12
100% Branches 0/0
0% Functions 0/5
18.18% Lines 2/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x   1x                                                
import { readFile } from "fs-extra";
 
export const readDebuggerSymbols = async (outputRoot: string) => {
  const noi = await readFile(`${outputRoot}/build/rom/game.noi`, "utf8");
 
  const memoryMap: Record<string, number> = Object.fromEntries(
    noi
      .split("\n")
      .map((r) => r.split(" ").slice(1, 3))
      .map((_, i, keys) => [keys[i][0], parseInt(keys[i][1], 16) & 0xffff])
  );
 
  const gameGlobals = await readFile(
    outputRoot + "/include/data/game_globals.i",
    "utf8"
  );
 
  const globalVariables: Record<string, number> = Object.fromEntries(
    gameGlobals
      .split("\n")
      .map((r) => r.split(" = "))
      .map((_, i, keys) => [keys[i][0], parseInt(keys[i][1], 10)])
  );
 
  return { memoryMap, globalVariables };
};