<commit_before>/**
 * Created by hkamran on 12/18/2016.
 */
import {GameBoy} from './gameboy';
import {Cpu} from './cpu/cpu'

export class Debugger {
    public static status: boolean = false;
    private static memqueue = {};
    private static memmap : Element = document.getElementById("memory-table");
    private static gameboy: GameBoy;
    private static logLimit = 500;
    private static bgmap: Array<Number> = Array(0x800).fill(0);
    private static COLORS: string[] = [
        "#000000",
        "#515151",
        "#9e9e9e",
        "#dee0e2",
        "#a00000"
    ];
    private static ZOOM: number = 1.5;

    public static display(): void {
        let gameboy = Debugger.gameboy;

        if (gameboy == null) {
            return console.error("Error: Debugger doesn't have GameBoy set!");
        }

        Debugger.printLog();
        Debugger.printStack();

        //Print to screen
        document.getElementById('cpucycles').innerHTML = Cpu.CLOCK.main.toString();
        document.getElementById('ppucycles').innerHTML = gameboy.ppu.clock.toString();
        document.getElementById('ticks').innerHTML = gameboy.ticks.toString();
        document.getElementById('pc').innerHTML = "0x" + gameboy.cpu.registers.getPC().toString(16).toUpperCase();
        document.getElementById('sp').innerHTML = "0x" + gameboy.cpu.registers.getSP().toString(16).toUpperCase();

        document.getElementById('zero').innerHTML = "z: " + Number(gameboy.cpu.registers.getZeroFlag()).toString(2);
        document.getElementById('subtract').innerHTML = "s: " + Number(gameboy.cpu.registers.getSubtractFlag()).toString(2);
        document.getElementById('halfcarry').innerHTML = "h: " + Number(gameboy.cpu.registers.getHalfFlag()).toString(2);
        document.getElementById('fullcarry').innerHTML = "c: " + Number(gameboy.cpu.registers.getCarryFlag()).toString(2);

        document.getElementById('af').innerHTML = "0x" + gameboy.cpu.registers.getAF().toString(16).toUpperCase();
        document.getElementById('bc').innerHTML = "0x" + gameboy.cpu.registers.getBC().toString(16).toUpperCase();
        document.getElementById('de').innerHTML = "0x" + gameboy.cpu.registers.getDE().toString(16).toUpperCase();
        document.getElementById('hl').innerHTML = "0x" + gameboy.cpu.registers.getHL().toString(16).toUpperCase();

        if (gameboy.cpu.last) {
            document.getElementById('opcode').innerHTML = "0x" + gameboy.cpu.last.opcode.toString(16).toUpperCase();
            document.getElementById('opname').innerHTML = gameboy.cpu.last.operation.name.toUpperCase();
            document.getElementById('opmode').innerHTML = gameboy.cpu.last.operation.mode.name.toUpperCase();
            document.getElementById('opaddr').innerHTML = "0x" + gameboy.cpu.last.opaddr.toString(16).toUpperCase();
            document.getElementById('operand').innerHTML = gameboy.cpu.last.opaddr.toString(16).toUpperCase();
        }

        //PPU Register
        document.getElementById('lcdc').innerHTML = "0x" + gameboy.ppu.registers.lcdc.getAll().toString(16);
        document.getElementById('stat').innerHTML = "0x" + gameboy.ppu.registers.stat.getAll().toString(16);
        document.getElementById('ly').innerHTML = gameboy.ppu.registers.ly.toString();
        document.getElementById('scx').innerHTML = gameboy.ppu.registers.scx.toString();
        document.getElementById('scy').innerHTML = gameboy.ppu.registers.scy.toString();

        //Interrupts
        document.getElementById('ime').innerHTML = "0x" + gameboy.memory.interrupts.ime.toString(16);
        document.getElementById('if').innerHTML = "0x" + gameboy.memory.interrupts.if.toString(16);
        document.getElementById('ie').innerHTML = "0x" + gameboy.memory.interrupts.ie.toString(16);

        $('#tpf').change(function () {
            if ($(this).val()) {
                gameboy.tpf = Number.parseInt($(this).val().toString());
            }
        });

        if (gameboy.cartridge.type) {
            document.getElementById('url').innerHTML = gameboy.cartridge.url;
            document.getElementById('type').innerHTML = gameboy.cartridge.type.name;
        }
    }

    public static clearLog(): void {
        let log:Element = document.getElementsByClassName("log")[0];
        let ul = log.getElementsByTagName("ul")[0];<commit_msg>ly not displaying in debugger<commit_after>/**
 * Created by hkamran on 12/18/2016.
 */
import {GameBoy} from './gameboy';
import {Cpu} from './cpu/cpu'

export class Debugger {
    public static status: boolean = false;
    private static memqueue = {};
    private static memmap : Element = document.getElementById("memory-table");
    private static gameboy: GameBoy;
    private static logLimit = 500;
    private static bgmap: Array<Number> = Array(0x800).fill(0);
    private static COLORS: string[] = [
        "#000000",
        "#515151",
        "#9e9e9e",
        "#dee0e2",
        "#a00000"
    ];
    private static ZOOM: number = 1.5;

    public static display(): void {
        let gameboy = Debugger.gameboy;

        if (gameboy == null) {
            return console.error("Error: Debugger doesn't have GameBoy set!");
        }

        Debugger.printLog();
        Debugger.printStack();

        //Print to screen
        document.getElementById('cpucycles').innerHTML = Cpu.CLOCK.main.toString();
        document.getElementById('ppucycles').innerHTML = gameboy.ppu.clock.toString();
        document.getElementById('ticks').innerHTML = gameboy.ticks.toString();
        document.getElementById('pc').innerHTML = "0x" + gameboy.cpu.registers.getPC().toString(16).toUpperCase();
        document.getElementById('sp').innerHTML = "0x" + gameboy.cpu.registers.getSP().toString(16).toUpperCase();

        document.getElementById('zero').innerHTML = "z: " + Number(gameboy.cpu.registers.getZeroFlag()).toString(2);
        document.getElementById('subtract').innerHTML = "s: " + Number(gameboy.cpu.registers.getSubtractFlag()).toString(2);
        document.getElementById('halfcarry').innerHTML = "h: " + Number(gameboy.cpu.registers.getHalfFlag()).toString(2);
        document.getElementById('fullcarry').innerHTML = "c: " + Number(gameboy.cpu.registers.getCarryFlag()).toString(2);

        document.getElementById('af').innerHTML = "0x" + gameboy.cpu.registers.getAF().toString(16).toUpperCase();
        document.getElementById('bc').innerHTML = "0x" + gameboy.cpu.registers.getBC().toString(16).toUpperCase();
        document.getElementById('de').innerHTML = "0x" + gameboy.cpu.registers.getDE().toString(16).toUpperCase();
        document.getElementById('hl').innerHTML = "0x" + gameboy.cpu.registers.getHL().toString(16).toUpperCase();

        if (gameboy.cpu.last) {
            document.getElementById('opcode').innerHTML = "0x" + gameboy.cpu.last.opcode.toString(16).toUpperCase();
            document.getElementById('opname').innerHTML = gameboy.cpu.last.operation.name.toUpperCase();
            document.getElementById('opmode').innerHTML = gameboy.cpu.last.operation.mode.name.toUpperCase();
            document.getElementById('opaddr').innerHTML = "0x" + gameboy.cpu.last.opaddr.toString(16).toUpperCase();
            document.getElementById('operand').innerHTML = gameboy.cpu.last.opaddr.toString(16).toUpperCase();
        }

        //PPU Register
        document.getElementById('lcdc').innerHTML = "0x" + gameboy.ppu.registers.lcdc.getAll().toString(16);
        document.getElementById('stat').innerHTML = "0x" + gameboy.ppu.registers.stat.getAll().toString(16);
        document.getElementById('ly').innerHTML = gameboy.ppu.registers.ly.toString(16);
        document.getElementById('scx').innerHTML = gameboy.ppu.registers.scx.toString(16);
        document.getElementById('scy').innerHTML = gameboy.ppu.registers.scy.toString(16);

        //Interrupts
        document.getElementById('ime').innerHTML = "0x" + gameboy.memory.interrupts.ime.toString(16);
        document.getElementById('if').innerHTML = "0x" + gameboy.memory.interrupts.if.toString(16);
        document.getElementById('ie').innerHTML = "0x" + gameboy.memory.interrupts.ie.toString(16);

        $('#tpf').change(function () {
            if ($(this).val()) {
                gameboy.tpf = Number.parseInt($(this).val().toString());
            }
        });

        if (gameboy.cartridge.type) {
            document.getElementById('url').innerHTML = gameboy.cartridge.url;
            document.getElementById('type').innerHTML = gameboy.cartridge.type.name;
        }
    }

    public static clearLog(): void {
        let log:Element = document.getElementsByClassName("log")[0];
        let ul = log.getElementsByTagName("ul")[0];
{'fraction_non_alphanumeric': 0.16075541225241824, 'fraction_numerical': 0.020727775218793182, 'mean_word_length': 3.327354260089686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '618604', 'n_tokens_mistral': 2600, 'n_tokens_neox': 2481, 'n_words': 351}