"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OotHelper = void 0;
const JSONTemplate_1 = require("modloader64_api/JSONTemplate");
const Z64API = __importStar(require("../../API/imports"));
const GameAliases_1 = require("../Common/types/GameAliases");
class OotHelper extends JSONTemplate_1.JSONTemplate {
    save;
    global;
    link;
    emu;
    constructor(save, global, link, memory) {
        super();
        this.save = save;
        this.global = global;
        this.link = link;
        this.emu = memory;
    }
    isTitleScreen() {
        return (this.save.index == 0xFF || this.save.index == 0xFEDC);
    }
    isSceneNumberValid() {
        return this.global.scene <= 0xFF;
    }
    isLinkEnteringLoadingZone() {
        let r = this.link.rawStateValue;
        return (r & 0x000000ff) === 1 || this.link.state === 5 /* Z64API.Z64.LinkState.LOADING_ZONE */ || this.link.state === 6 /* Z64API.Z64.LinkState.ENTERING_GROTTO */;
    }
    isPaused() {
        return this.emu.rdramRead16(GameAliases_1.Z64_PAUSED) !== 0x3;
    }
    isInterfaceShown() {
        return (this.emu.rdramRead8(GameAliases_1.Z64_GUI_SHOWN) === 0xff);
    }
    Player_InBlockingCsMode() {
        return ((this.link.rdramRead32(0x66C) & 0x20000080) !== 0) || (this.link.rdramRead8(0x0434) !== 0) || (this.emu.rdramReadPtr8(GameAliases_1.Z64_GLOBAL_PTR, 0x11E15) !== 0) ||
            ((this.link.rdramRead32(0x66C) & 1) !== 0) || ((this.link.rdramRead8(0x0682) & 0x80) !== 0) ||
            (this.emu.rdramRead16(GameAliases_1.Z64_SAVE + 0x13F0) !== 0);
    }
    toJSON() {
        let jsonObj = {};
        jsonObj['isTitleScreen'] = this.isTitleScreen();
        return jsonObj;
    }
}
exports.OotHelper = OotHelper;
//# sourceMappingURL=OotHelper.js.map