"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.GlobalContext = void 0;
const Z64CORE = __importStar(require("../importsZ64"));
class GlobalContext {
    ModLoader;
    viewStruct;
    instance = Z64CORE.Z64.Z64_GLOBAL_PTR;
    save_context = Z64CORE.Z64.Z64_SAVE;
    continue_state;
    jsonFields = ['scene', 'room', 'framecount'];
    constructor(ModLoader) {
        this.ModLoader = ModLoader;
        this.viewStruct = new Z64CORE.Z64.viewStruct(ModLoader);
    }
    get transitionState() {
        return this.ModLoader.emulator.rdramReadPtr8(this.instance, 0x18875);
    }
    get scene() {
        return this.ModLoader.emulator.rdramReadPtr16(this.instance, 0xA4);
    }
    get scene_framecount() {
        return this.ModLoader.emulator.rdramReadPtr32(this.instance, 0x18840);
    }
    get room() {
        return this.ModLoader.emulator.rdramReadPtr8(this.instance, 0x186EC);
    }
    get liveSceneData_switch() {
        return this.ModLoader.emulator.rdramReadPtrBuffer(this.instance, 0x01CA0 + 0x1B8, 0x10);
    }
    set liveSceneData_switch(buf) {
        this.ModLoader.emulator.rdramWritePtrBuffer(this.instance, 0x01CA0 + 0x1B8, buf);
    }
    get liveSceneData_chests() {
        return this.ModLoader.emulator.rdramReadPtrBuffer(this.instance, 0x01CA0 + 0x1C8, 0x4);
    }
    set liveSceneData_chests(buf) {
        this.ModLoader.emulator.rdramWritePtrBuffer(this.instance, 0x01CA0 + 0x1C8, buf);
    }
    get liveSceneData_clear() {
        return this.ModLoader.emulator.rdramReadPtrBuffer(this.instance, 0x01CA0 + 0x1CC, 0x4);
    }
    set liveSceneData_clear(buf) {
        this.ModLoader.emulator.rdramWritePtrBuffer(this.instance, 0x01CA0 + 0x1CC, buf);
    }
    get liveSceneData_temp() {
        return this.ModLoader.emulator.rdramReadPtrBuffer(this.instance, 0x01CA0 + 0x1D0, 0x4);
    }
    set liveSceneData_temp(buf) {
        this.ModLoader.emulator.rdramWritePtrBuffer(this.instance, 0x01CA0 + 0x1D0, buf);
    }
    get liveSceneData_collectable() {
        return this.ModLoader.emulator.rdramReadPtrBuffer(this.instance, 0x01CA0 + 0x1D4, 0x10);
    }
    set liveSceneData_collectable(buf) {
        this.ModLoader.emulator.rdramWritePtrBuffer(this.instance, 0x01CA0 + 0x1D4, buf);
    }
    getSaveDataForCurrentScene() {
        return this.ModLoader.emulator.rdramReadBuffer(Z64CORE.Z64.Z64_SAVE + 0x00F8 + this.scene * 0x1c, 0x1c);
    }
    writeSaveDataForCurrentScene(buf) {
        if (buf.byteLength === 0x1c) {
            this.ModLoader.emulator.rdramWriteBuffer(Z64CORE.Z64.Z64_SAVE + 0x00F8 + this.scene * 0x1c, buf);
        }
    }
}
exports.GlobalContext = GlobalContext;
//# sourceMappingURL=GlobalContext.js.map