boytacean
Version:
A Game Boy emulator that is written in Rust.
1,573 lines (1,507 loc) • 102 kB
JavaScript
let wasm;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
function isLikeNone(x) {
return x === undefined || x === null;
}
let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedDataViewMemory0;
}
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8ArrayMemory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function passArrayJsValueToWasm0(array, malloc) {
const ptr = malloc(array.length * 4, 4) >>> 0;
const mem = getDataViewMemory0();
for (let i = 0; i < array.length; i++) {
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
}
WASM_VECTOR_LEN = array.length;
return ptr;
}
function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
}
/**
* @returns {bigint}
*/
export function timestamp() {
const ret = wasm.timestamp();
return BigInt.asUintN(64, ret);
}
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
*/
export const BootRom = Object.freeze({
Dmg: 0, "0": "Dmg",
Sgb: 1, "1": "Sgb",
DmgBootix: 2, "2": "DmgBootix",
MgbBootix: 3, "3": "MgbBootix",
Cgb: 4, "4": "Cgb",
CgbBoytacean: 5, "5": "CgbBoytacean",
Other: 6, "6": "Other",
None: 7, "7": "None",
});
/**
* @enum {0 | 128 | 192}
*/
export const CgbMode = Object.freeze({
NoCgb: 0, "0": "NoCgb",
CgbCompatible: 128, "128": "CgbCompatible",
CgbOnly: 192, "192": "CgbOnly",
});
/**
* @enum {0 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 100}
*/
export const GameBoyDevice = Object.freeze({
Cpu: 0, "0": "Cpu",
Mmu: 1, "1": "Mmu",
Ppu: 3, "3": "Ppu",
Apu: 4, "4": "Apu",
Dma: 5, "5": "Dma",
Pad: 6, "6": "Pad",
Timer: 7, "7": "Timer",
Serial: 8, "8": "Serial",
Unknown: 100, "100": "Unknown",
});
/**
* Enumeration that describes the multiple running
* @enum {1 | 2 | 3}
*/
export const GameBoyMode = Object.freeze({
Dmg: 1, "1": "Dmg",
Cgb: 2, "2": "Cgb",
Sgb: 3, "3": "Sgb",
});
/**
* @enum {0 | 1}
*/
export const GameBoySpeed = Object.freeze({
Normal: 0, "0": "Normal",
Double: 1, "1": "Double",
});
/**
* @enum {0 | 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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138}
*/
export const Licensee = Object.freeze({
Unknown: 0, "0": "Unknown",
None: 1, "1": "None",
Nintendo: 2, "2": "Nintendo",
Capcom: 3, "3": "Capcom",
HOTB: 4, "4": "HOTB",
Jaleco: 5, "5": "Jaleco",
CoconutsJapan: 6, "6": "CoconutsJapan",
EliteSystems: 7, "7": "EliteSystems",
EAElectronicArts: 8, "8": "EAElectronicArts",
HudsonSoft: 9, "9": "HudsonSoft",
ITCEntertainment: 10, "10": "ITCEntertainment",
Yanoman: 11, "11": "Yanoman",
JapanClary: 12, "12": "JapanClary",
VirginGamesLtd: 13, "13": "VirginGamesLtd",
PCMComplete: 14, "14": "PCMComplete",
SanX: 15, "15": "SanX",
Kemco: 16, "16": "Kemco",
SETACorporation: 17, "17": "SETACorporation",
Infogrames: 18, "18": "Infogrames",
Bandai: 19, "19": "Bandai",
NewLicensee: 20, "20": "NewLicensee",
Konami: 21, "21": "Konami",
HectorSoft: 22, "22": "HectorSoft",
Banpresto: 23, "23": "Banpresto",
EntertainmentI: 24, "24": "EntertainmentI",
Gremlin: 25, "25": "Gremlin",
UbiSoft: 26, "26": "UbiSoft",
Atlus: 27, "27": "Atlus",
MalibuInteractive: 28, "28": "MalibuInteractive",
Angel: 29, "29": "Angel",
SpectrumHoloby: 30, "30": "SpectrumHoloby",
Irem: 31, "31": "Irem",
USGold: 32, "32": "USGold",
Absolute: 33, "33": "Absolute",
AcclaimEntertainment: 34, "34": "AcclaimEntertainment",
Activision: 35, "35": "Activision",
SammyUSACorporation: 36, "36": "SammyUSACorporation",
GameTek: 37, "37": "GameTek",
ParkPlace: 38, "38": "ParkPlace",
LJN: 39, "39": "LJN",
Matchbox: 40, "40": "Matchbox",
MiltonBradleyCompany: 41, "41": "MiltonBradleyCompany",
Mindscape: 42, "42": "Mindscape",
Romstar: 43, "43": "Romstar",
NaxatSoft: 44, "44": "NaxatSoft",
Tradewest: 45, "45": "Tradewest",
TitusInteractive: 46, "46": "TitusInteractive",
OceanSoftware: 47, "47": "OceanSoftware",
EliteSystems2: 48, "48": "EliteSystems2",
ElectroBrain: 49, "49": "ElectroBrain",
InterplayEntertainment: 50, "50": "InterplayEntertainment",
Broderbund: 51, "51": "Broderbund",
SculpturedSoftware: 52, "52": "SculpturedSoftware",
TheSalesCurveLimited: 53, "53": "TheSalesCurveLimited",
THQ: 54, "54": "THQ",
Accolade: 55, "55": "Accolade",
TriffixEntertainment: 56, "56": "TriffixEntertainment",
Microprose: 57, "57": "Microprose",
MisawaEntertainment: 58, "58": "MisawaEntertainment",
Lozc: 59, "59": "Lozc",
TokumaShoten: 60, "60": "TokumaShoten",
BulletProofSoftware: 61, "61": "BulletProofSoftware",
VicTokai: 62, "62": "VicTokai",
Ape: 63, "63": "Ape",
IMax: 64, "64": "IMax",
Chunsoft: 65, "65": "Chunsoft",
VideoSystem: 66, "66": "VideoSystem",
TsubarayaProductions: 67, "67": "TsubarayaProductions",
Varie: 68, "68": "Varie",
YonezawaSpal: 69, "69": "YonezawaSpal",
Arc: 70, "70": "Arc",
NihonBussan: 71, "71": "NihonBussan",
Tecmo: 72, "72": "Tecmo",
Imagineer: 73, "73": "Imagineer",
Nova: 74, "74": "Nova",
HoriElectric: 75, "75": "HoriElectric",
Kawada: 76, "76": "Kawada",
Takara: 77, "77": "Takara",
TechnosJapan: 78, "78": "TechnosJapan",
ToeiAnimation: 79, "79": "ToeiAnimation",
Toho: 80, "80": "Toho",
Namco: 81, "81": "Namco",
ASCIICorporationOrNexsoft: 82, "82": "ASCIICorporationOrNexsoft",
SquareEnix: 83, "83": "SquareEnix",
HALLaboratory: 84, "84": "HALLaboratory",
SNK: 85, "85": "SNK",
PonyCanyon: 86, "86": "PonyCanyon",
CultureBrain: 87, "87": "CultureBrain",
Sunsoft: 88, "88": "Sunsoft",
SonyImagesoft: 89, "89": "SonyImagesoft",
SammyCorporation: 90, "90": "SammyCorporation",
Taito: 91, "91": "Taito",
Square: 92, "92": "Square",
DataEast: 93, "93": "DataEast",
Tonkinhouse: 94, "94": "Tonkinhouse",
Koei: 95, "95": "Koei",
UFL: 96, "96": "UFL",
Ultra: 97, "97": "Ultra",
Vap: 98, "98": "Vap",
UseCorporation: 99, "99": "UseCorporation",
Meldac: 100, "100": "Meldac",
PoneyCanyon: 101, "101": "PoneyCanyon",
Sofel: 102, "102": "Sofel",
Quest: 103, "103": "Quest",
SigmaEnterprises: 104, "104": "SigmaEnterprises",
ASKKodanshaCo: 105, "105": "ASKKodanshaCo",
CopyaSystem: 106, "106": "CopyaSystem",
Tomy: 107, "107": "Tomy",
NCS: 108, "108": "NCS",
Human: 109, "109": "Human",
Altron: 110, "110": "Altron",
TowaChiki: 111, "111": "TowaChiki",
Yutaka: 112, "112": "Yutaka",
Epcoh: 113, "113": "Epcoh",
Athena: 114, "114": "Athena",
AsmikAceEntertainment: 115, "115": "AsmikAceEntertainment",
Natsume: 116, "116": "Natsume",
KingRecords: 117, "117": "KingRecords",
EpicSonyRecords: 118, "118": "EpicSonyRecords",
IGS: 119, "119": "IGS",
AWave: 120, "120": "AWave",
ExtremeEntertainment: 121, "121": "ExtremeEntertainment",
NintendoResearchDevelopment1: 122, "122": "NintendoResearchDevelopment1",
BAI: 123, "123": "BAI",
KSS: 124, "124": "KSS",
PlanningOfficeWADA: 125, "125": "PlanningOfficeWADA",
Viacom: 126, "126": "Viacom",
HiTechExpressions: 127, "127": "HiTechExpressions",
Mattel: 128, "128": "Mattel",
LucasfilmGames: 129, "129": "LucasfilmGames",
TsukudaOriginal: 130, "130": "TsukudaOriginal",
ChunsoftCo: 131, "131": "ChunsoftCo",
OceanSoftwareAcclaimEntertainment: 132, "132": "OceanSoftwareAcclaimEntertainment",
Kaneko: 133, "133": "Kaneko",
PackInVideo: 134, "134": "PackInVideo",
BottomUp: 135, "135": "BottomUp",
KonamiYuGiOh: 136, "136": "KonamiYuGiOh",
MTO: 137, "137": "MTO",
Kodansha: 138, "138": "Kodansha",
});
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
*/
export const MbcType = Object.freeze({
NoMbc: 0, "0": "NoMbc",
Mbc1: 1, "1": "Mbc1",
Mbc2: 2, "2": "Mbc2",
Mbc3: 3, "3": "Mbc3",
Mbc5: 4, "4": "Mbc5",
Mbc6: 5, "5": "Mbc6",
Mbc7: 6, "6": "Mbc7",
Unknown: 7, "7": "Unknown",
});
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
*/
export const PadKey = Object.freeze({
Up: 0, "0": "Up",
Down: 1, "1": "Down",
Left: 2, "2": "Left",
Right: 3, "3": "Right",
Start: 4, "4": "Start",
Select: 5, "5": "Select",
A: 6, "6": "A",
B: 7, "7": "B",
});
/**
* @enum {0 | 1 | 2 | 3}
*/
export const PpuMode = Object.freeze({
HBlank: 0, "0": "HBlank",
VBlank: 1, "1": "VBlank",
OamRead: 2, "2": "OamRead",
VramRead: 3, "3": "VramRead",
});
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
*/
export const RamSize = Object.freeze({
NoRam: 0, "0": "NoRam",
Unused: 1, "1": "Unused",
Size8K: 2, "2": "Size8K",
Size16K: 3, "3": "Size16K",
Size32K: 4, "4": "Size32K",
Size64K: 5, "5": "Size64K",
Size128K: 6, "6": "Size128K",
SizeUnknown: 7, "7": "SizeUnknown",
});
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}
*/
export const Region = Object.freeze({
World: 0, "0": "World",
Japan: 1, "1": "Japan",
USA: 2, "2": "USA",
Europe: 3, "3": "Europe",
Spain: 4, "4": "Spain",
Italy: 5, "5": "Italy",
France: 6, "6": "France",
Germany: 7, "7": "Germany",
Korean: 8, "8": "Korean",
Australia: 9, "9": "Australia",
Unknown: 10, "10": "Unknown",
});
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
*/
export const RomSize = Object.freeze({
Size32K: 0, "0": "Size32K",
Size64K: 1, "1": "Size64K",
Size128K: 2, "2": "Size128K",
Size256K: 3, "3": "Size256K",
Size512K: 4, "4": "Size512K",
Size1M: 5, "5": "Size1M",
Size2M: 6, "6": "Size2M",
Size4M: 7, "7": "Size4M",
Size8M: 8, "8": "Size8M",
SizeUnknown: 9, "9": "SizeUnknown",
});
/**
* @enum {0 | 1 | 2 | 3 | 5 | 6 | 8 | 9 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 34 | 252 | 253 | 254 | 255 | 239}
*/
export const RomType = Object.freeze({
RomOnly: 0, "0": "RomOnly",
Mbc1: 1, "1": "Mbc1",
Mbc1Ram: 2, "2": "Mbc1Ram",
Mbc1RamBattery: 3, "3": "Mbc1RamBattery",
Mbc2: 5, "5": "Mbc2",
Mbc2Battery: 6, "6": "Mbc2Battery",
RomRam: 8, "8": "RomRam",
RomRamBattery: 9, "9": "RomRamBattery",
Mmm01: 11, "11": "Mmm01",
Mmm01Ram: 12, "12": "Mmm01Ram",
Mmm01RamBattery: 13, "13": "Mmm01RamBattery",
Mbc3TimerBattery: 15, "15": "Mbc3TimerBattery",
Mbc3TimerRamBattery: 16, "16": "Mbc3TimerRamBattery",
Mbc3: 17, "17": "Mbc3",
Mbc3Ram: 18, "18": "Mbc3Ram",
Mbc3RamBattery: 19, "19": "Mbc3RamBattery",
Mbc5: 25, "25": "Mbc5",
Mbc5Ram: 26, "26": "Mbc5Ram",
Mbc5RamBattery: 27, "27": "Mbc5RamBattery",
Mbc5Rumble: 28, "28": "Mbc5Rumble",
Mbc5RumbleRam: 29, "29": "Mbc5RumbleRam",
Mbc5RumbleRamBattery: 30, "30": "Mbc5RumbleRamBattery",
Mbc6: 32, "32": "Mbc6",
Mbc7SensorRumbleRamBattery: 34, "34": "Mbc7SensorRumbleRamBattery",
PocketCamera: 252, "252": "PocketCamera",
BandaiTama5: 253, "253": "BandaiTama5",
HuC3: 254, "254": "HuC3",
HuC1RamBattery: 255, "255": "HuC1RamBattery",
Unknown: 239, "239": "Unknown",
});
/**
* @enum {1 | 2 | 3}
*/
export const SaveStateFormat = Object.freeze({
/**
* Boytacean Save Compressed format (BOSC).
*
* This format uses the Zippy compression algorithm
* to compress the underlying BOS contents.
*
* The BOSC format is the default format for the
* save state.
*
* Using a compressed file format means that BESS out-of-the
* box compatibility is not possible.
*/
Bosc: 1, "1": "Bosc",
/**
* Boytacean Save format (uncompressed) (BOS).
*
* This format is the uncompressed version of the
* BOSC format.
*
* Using an uncompressed file format means that BESS
* out-of-the box compatibility is possible.
*/
Bos: 2, "2": "Bos",
/**
* Best Effort Save State format (BESS).
*
* This is an abstract payload opaque format created
* by the same people of Sameboy.
*/
Bess: 3, "3": "Bess",
});
/**
* @enum {0 | 3}
*/
export const SgbMode = Object.freeze({
NoSgb: 0, "0": "NoSgb",
SgbFunctions: 3, "3": "SgbFunctions",
});
/**
* Represents the different formats for the state storage
* and retrieval.
*
* Different formats will have different levels of detail
* and will require different amounts of data to be
* stored and retrieved.
* @enum {1 | 2 | 3}
*/
export const StateFormat = Object.freeze({
/**
* Minimal state format, meaning that only the most basic
* elements of the component will be stored and retrieved.
*/
Minimal: 1, "1": "Minimal",
/**
* Partial state format, meaning that only the essential
* elements of the component will be stored and retrieved.
* All the remaining data, should inferred or computed.
*/
Partial: 2, "2": "Partial",
/**
* Full state format, meaning that every single element
* of the component will be stored and retrieved. This
* should included redundant and calculated data.
*/
Full: 3, "3": "Full",
});
const BessStateFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_bessstate_free(ptr >>> 0, 1));
export class BessState {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BessState.prototype);
obj.__wbg_ptr = ptr;
BessStateFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BessStateFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bessstate_free(ptr, 0);
}
/**
* @returns {bigint}
*/
timestamp_wa() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bessstate_timestamp_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
return BigInt.asUintN(64, r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {string}
*/
agent_wa() {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bessstate_agent_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr1 = r0;
var len1 = r1;
if (r3) {
ptr1 = 0; len1 = 0;
throw takeObject(r2);
}
deferred2_0 = ptr1;
deferred2_1 = len1;
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {string}
*/
model_wa() {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bessstate_model_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr1 = r0;
var len1 = r1;
if (r3) {
ptr1 = 0; len1 = 0;
throw takeObject(r2);
}
deferred2_0 = ptr1;
deferred2_1 = len1;
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {string}
*/
title_wa() {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bessstate_title_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr1 = r0;
var len1 = r1;
if (r3) {
ptr1 = 0; len1 = 0;
throw takeObject(r2);
}
deferred2_0 = ptr1;
deferred2_1 = len1;
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {Uint8Array}
*/
image_eager_wa() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bessstate_image_eager_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {boolean}
*/
has_image_wa() {
const ret = wasm.bessstate_has_image_wa(this.__wbg_ptr);
return ret !== 0;
}
}
const BosStateFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_bosstate_free(ptr >>> 0, 1));
export class BosState {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BosState.prototype);
obj.__wbg_ptr = ptr;
BosStateFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BosStateFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bosstate_free(ptr, 0);
}
/**
* @returns {bigint}
*/
timestamp_wa() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bosstate_timestamp_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
return BigInt.asUintN(64, r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {string}
*/
agent_wa() {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bosstate_agent_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr1 = r0;
var len1 = r1;
if (r3) {
ptr1 = 0; len1 = 0;
throw takeObject(r2);
}
deferred2_0 = ptr1;
deferred2_1 = len1;
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {string}
*/
model_wa() {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bosstate_model_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr1 = r0;
var len1 = r1;
if (r3) {
ptr1 = 0; len1 = 0;
throw takeObject(r2);
}
deferred2_0 = ptr1;
deferred2_1 = len1;
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {string}
*/
title_wa() {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bosstate_title_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr1 = r0;
var len1 = r1;
if (r3) {
ptr1 = 0; len1 = 0;
throw takeObject(r2);
}
deferred2_0 = ptr1;
deferred2_1 = len1;
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {Uint8Array}
*/
image_eager_wa() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bosstate_image_eager_wa(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {boolean}
*/
has_image_wa() {
const ret = wasm.bosstate_has_image_wa(this.__wbg_ptr);
return ret !== 0;
}
}
const BoscStateFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_boscstate_free(ptr >>> 0, 1));
export class BoscState {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BoscState.prototype);
obj.__wbg_ptr = ptr;
BoscStateFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BoscStateFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_boscstate_free(ptr, 0);
}
}
const CartridgeFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_cartridge_free(ptr >>> 0, 1));
/**
* Structure that defines the ROM and ROM contents
* of a Game Boy cartridge. Should correctly address
* the specifics of all the major MBCs (Memory Bank
* Controllers).
*/
export class Cartridge {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(Cartridge.prototype);
obj.__wbg_ptr = ptr;
CartridgeFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
CartridgeFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_cartridge_free(ptr, 0);
}
/**
* @returns {string}
*/
title() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_title(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
}
}
/**
* @returns {Licensee}
*/
licensee() {
const ret = wasm.cartridge_licensee(this.__wbg_ptr);
return ret;
}
/**
* @returns {CgbMode}
*/
cgb_flag() {
const ret = wasm.cartridge_cgb_flag(this.__wbg_ptr);
return ret;
}
/**
* @returns {SgbMode}
*/
sgb_flag() {
const ret = wasm.cartridge_sgb_flag(this.__wbg_ptr);
return ret;
}
/**
* @returns {GameBoyMode}
*/
gb_mode() {
const ret = wasm.cartridge_gb_mode(this.__wbg_ptr);
return ret;
}
/**
* A cartridge is considered legacy (DMG only) if it does
* not have a CGB flag bit (bit 7 of 0x0143) set.
*
* These are the monochromatic only cartridges built
* for the original DMG Game Boy.
* @returns {boolean}
*/
is_legacy() {
const ret = wasm.cartridge_is_legacy(this.__wbg_ptr);
return ret !== 0;
}
/**
* @returns {RomType}
*/
rom_type() {
const ret = wasm.cartridge_rom_type(this.__wbg_ptr);
return ret;
}
/**
* @returns {RomSize}
*/
rom_size() {
const ret = wasm.cartridge_rom_size(this.__wbg_ptr);
return ret;
}
/**
* @returns {RamSize}
*/
ram_size() {
const ret = wasm.cartridge_ram_size(this.__wbg_ptr);
return ret;
}
/**
* @returns {string}
*/
rom_type_s() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_rom_type_s(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
}
}
/**
* @returns {string}
*/
rom_size_s() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_rom_size_s(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
}
}
/**
* @returns {string}
*/
ram_size_s() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_ram_size_s(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
}
}
/**
* @returns {Region}
*/
region() {
const ret = wasm.cartridge_region(this.__wbg_ptr);
return ret;
}
/**
* @returns {boolean}
*/
has_battery() {
const ret = wasm.cartridge_has_battery(this.__wbg_ptr);
return ret !== 0;
}
/**
* @returns {Uint8Array}
*/
rom_data_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_rom_data_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {Uint8Array}
*/
ram_data_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_ram_data_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @param {Uint8Array} data
*/
set_ram_data(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
wasm.cartridge_set_ram_data(this.__wbg_ptr, ptr0, len0);
}
clear_ram_data() {
wasm.cartridge_clear_ram_data(this.__wbg_ptr);
}
/**
* @param {GameGenie} game_genie
*/
attach_genie(game_genie) {
_assertClass(game_genie, GameGenie);
var ptr0 = game_genie.__destroy_into_raw();
wasm.cartridge_attach_genie(this.__wbg_ptr, ptr0);
}
detach_genie() {
wasm.cartridge_detach_genie(this.__wbg_ptr);
}
/**
* @param {GameShark} game_shark
*/
attach_shark(game_shark) {
_assertClass(game_shark, GameShark);
var ptr0 = game_shark.__destroy_into_raw();
wasm.cartridge_attach_shark(this.__wbg_ptr, ptr0);
}
detach_shark() {
wasm.cartridge_detach_shark(this.__wbg_ptr);
}
/**
* @returns {number}
*/
checksum() {
const ret = wasm.cartridge_checksum(this.__wbg_ptr);
return ret;
}
/**
* @returns {boolean}
*/
valid_checksum() {
const ret = wasm.cartridge_valid_checksum(this.__wbg_ptr);
return ret !== 0;
}
/**
* @param {number} column_length
* @returns {string}
*/
description(column_length) {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.cartridge_description(retptr, this.__wbg_ptr, column_length);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
}
}
}
const ClockFrameFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_clockframe_free(ptr >>> 0, 1));
export class ClockFrame {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(ClockFrame.prototype);
obj.__wbg_ptr = ptr;
ClockFrameFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
ClockFrameFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_clockframe_free(ptr, 0);
}
/**
* @returns {bigint}
*/
get cycles() {
const ret = wasm.__wbg_get_clockframe_cycles(this.__wbg_ptr);
return BigInt.asUintN(64, ret);
}
/**
* @param {bigint} arg0
*/
set cycles(arg0) {
wasm.__wbg_set_clockframe_cycles(this.__wbg_ptr, arg0);
}
/**
* @returns {number}
*/
get frames() {
const ret = wasm.__wbg_get_clockframe_frames(this.__wbg_ptr);
return ret;
}
/**
* @param {number} arg0
*/
set frames(arg0) {
wasm.__wbg_set_clockframe_frames(this.__wbg_ptr, arg0);
}
/**
* @returns {Uint8Array | undefined}
*/
frame_buffer_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.clockframe_frame_buffer_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
let v1;
if (r0 !== 0) {
v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
}
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const FromGbOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_fromgboptions_free(ptr >>> 0, 1));
export class FromGbOptions {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(FromGbOptions.prototype);
obj.__wbg_ptr = ptr;
FromGbOptionsFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
FromGbOptionsFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_fromgboptions_free(ptr, 0);
}
/**
* @param {boolean} thumbnail
* @param {StateFormat | null} [state_format]
* @param {string | null} [agent]
* @param {string | null} [agent_version]
* @returns {FromGbOptions}
*/
static new(thumbnail, state_format, agent, agent_version) {
var ptr0 = isLikeNone(agent) ? 0 : passStringToWasm0(agent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ptr1 = isLikeNone(agent_version) ? 0 : passStringToWasm0(agent_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
const ret = wasm.fromgboptions_new(thumbnail, isLikeNone(state_format) ? 0 : state_format, ptr0, len0, ptr1, len1);
return FromGbOptions.__wrap(ret);
}
}
const GameBoyFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_gameboy_free(ptr >>> 0, 1));
/**
* Top level structure that abstracts the usage of the
* Game Boy system under the Boytacean emulator.
*
* Should serve as the main entry-point API.
*/
export class GameBoy {
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
GameBoyFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_gameboy_free(ptr, 0);
}
/**
* @param {GameBoyMode | null} [mode]
*/
constructor(mode) {
const ret = wasm.gameboy_new(isLikeNone(mode) ? 0 : mode);
this.__wbg_ptr = ret >>> 0;
GameBoyFinalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* @param {Uint8Array} data
* @returns {boolean}
*/
static verify_rom(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.gameboy_verify_rom(ptr0, len0);
return ret !== 0;
}
reset() {
wasm.gameboy_reset(this.__wbg_ptr);
}
reset_cheats() {
wasm.gameboy_reset_cheats(this.__wbg_ptr);
}
reload() {
wasm.gameboy_reload(this.__wbg_ptr);
}
/**
* Advance the clock of the system by one tick, this will
* usually imply executing one CPU instruction and advancing
* all the other components of the system by the required
* amount of cycles.
*
* This method takes into account the current speed of the
* system (single or double) and will execute the required
* amount of cycles in the other components of the system
* accordingly.
*
* The amount of cycles executed by the CPU is returned.
* @returns {number}
*/
clock() {
const ret = wasm.gameboy_clock(this.__wbg_ptr);
return ret;
}
/**
* Risky function that will clock the CPU multiple times
* allowing an undefined number of cycles to be executed
* in the other Game Boy components.
*
* This can cause unwanted behaviour in components like
* the PPU where only one mode switch operation is expected
* per each clock call.
*
* At the end of this execution major synchronization issues
* may arise, so use with caution.
* @param {number} count
* @returns {number}
*/
clock_many(count) {
const ret = wasm.gameboy_clock_many(this.__wbg_ptr, count);
return ret;
}
/**
* Function equivalent to `clock()` but that allows pre-emptive
* breaking of the clock cycle loop if the PC (Program Counter)
* reaches the provided address, making sure that in such a situation
* the devices are not clocked.
* @param {number} addr
* @returns {number}
*/
clock_step(addr) {
const ret = wasm.gameboy_clock_step(this.__wbg_ptr, addr);
return ret;
}
/**
* Equivalent to `clock()` but allows the execution of multiple
* clock operations in a single call.
* @param {number} count
* @returns {bigint}
*/
clocks(count) {
const ret = wasm.gameboy_clocks(this.__wbg_ptr, count);
return BigInt.asUintN(64, ret);
}
/**
* Clocks the emulator until the limit of cycles that has been
* provided and returns the amount of cycles that have been
* clocked.
* @param {number} limit
* @returns {bigint}
*/
clocks_cycles(limit) {
const ret = wasm.gameboy_clocks_cycles(this.__wbg_ptr, limit);
return BigInt.asUintN(64, ret);
}
/**
* Clocks the emulator until the limit of cycles that has been
* provided and returns the amount of cycles that have been
* clocked together with the frame buffer of the PPU.
*
* Allows a caller to clock the emulator and at the same time
* retrieve the frame buffer of the PPU at the proper timing
* (on V-Blank).
*
* This method allows for complex foreign call optimizations
* by preventing the need to call the emulator clock multiple
* times to obtain the right frame buffer retrieval timing.
* @param {number} limit
* @returns {ClockFrame}
*/
clocks_frame_buffer(limit) {
const ret = wasm.gameboy_clocks_frame_buffer(this.__wbg_ptr, limit);
return ClockFrame.__wrap(ret);
}
/**
* @returns {number}
*/
next_frame() {
const ret = wasm.gameboy_next_frame(this.__wbg_ptr);
return ret >>> 0;
}
/**
* @param {number} addr
* @returns {number}
*/
step_to(addr) {
const ret = wasm.gameboy_step_to(this.__wbg_ptr, addr);
return ret >>> 0;
}
/**
* @param {PadKey} key
*/
key_press(key) {
wasm.gameboy_key_press(this.__wbg_ptr, key);
}
/**
* @param {PadKey} key
*/
key_lift(key) {
wasm.gameboy_key_lift(this.__wbg_ptr, key);
}
/**
* @returns {number}
*/
cpu_clock() {
const ret = wasm.gameboy_cpu_clock(this.__wbg_ptr);
return ret;
}
/**
* @param {number} cycles
*/
ppu_clock(cycles) {
wasm.gameboy_ppu_clock(this.__wbg_ptr, cycles);
}
/**
* @param {number} cycles
*/
apu_clock(cycles) {
wasm.gameboy_apu_clock(this.__wbg_ptr, cycles);
}
/**
* @param {number} cycles
*/
dma_clock(cycles) {
wasm.gameboy_dma_clock(this.__wbg_ptr, cycles);
}
/**
* @param {number} cycles
*/
timer_clock(cycles) {
wasm.gameboy_timer_clock(this.__wbg_ptr, cycles);
}
/**
* @param {number} cycles
*/
serial_clock(cycles) {
wasm.gameboy_serial_clock(this.__wbg_ptr, cycles);
}
/**
* @returns {number}
*/
ppu_ly() {
const ret = wasm.gameboy_ppu_ly(this.__wbg_ptr);
return ret;
}
/**
* @returns {PpuMode}
*/
ppu_mode() {
const ret = wasm.gameboy_ppu_mode(this.__wbg_ptr);
return ret;
}
/**
* @returns {number}
*/
ppu_frame() {
const ret = wasm.gameboy_ppu_frame(this.__wbg_ptr);
return ret;
}
/**
* Direct boot method that immediately jumps the machine
* to the post boot state, this will effectively skip the
* boot sequence and jump to the cartridge execution.
*/
boot() {
wasm.gameboy_boot(this.__wbg_ptr);
}
/**
* Unsafe load strategy that will panic the current system
* in case there are boot ROM loading issues.
* @param {boolean} boot
*/
load_unsafe(boot) {
wasm.gameboy_load_unsafe(this.__wbg_ptr, boot);
}
/**
* Loads the machine directly to after the boot execution state,
* setting the state of the system accordingly and updating the
* Program Counter (PC) to the post boot address (0x0100).
*
* Should allow the machine to jump to the cartridge (ROM) execution
* directly, skipping the boot sequence.
*
* Currently supports only DMG machines.
*/
load_boot_state() {
wasm.gameboy_boot(this.__wbg_ptr);
}
/**
* @returns {Uint8Array}
*/
vram_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.gameboy_hram_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {Uint8Array}
*/
hram_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.gameboy_hram_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {Uint8Array}
*/
frame_buffer_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.gameboy_frame_buffer_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {Uint8Array}
*/
frame_buffer_raw_eager() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.gameboy_frame_buffer_raw_eager(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);