var addr_power = 0x8033B21E if(mem.u8[addr_power] < 1) { mem.u8[addr_power] = 8 }
mem.bindvar(this, 0x8033B21E, 'power', u8) if(power < 1) { power = 8 }
var mario = mem.bindvars({}, [ [0x8033B1B0, 'y', float], [0x8033B21E, 'power', u8] ]) mario.power = 5 mario.y = 500.00
var marioPos = mem.bindstruct(this, 0x8033B1AC, { x: float, y: float, z: float })
const Player = mem.typedef( { health: u32, x: float, y: float, z: float }) Player.prototype.move = function(x, y, z) { this.x = x this.y = y this.z = z } Player.prototype.heal = function() { this.health = 100; } var player = new Player(0x8033B1AC) player.move(100, 200, 300) player.heal()
var crc1 = rom.u32[0x00000010] var crc2 = rom.u32[0x00000014]
var romName = rom.getstring(0x00000020) console.log('Internal ROM name: ' + romName)
events.onexec(0x802CB1C0, function() { console.log('CPU is calling 0x802CB1C0') })
events.onexec(ADDR_ANY, function(addr)) { // Log every step! console.log('CPU is executing ' + addr.hex()) })
events.onread(0x8033B1B0, function() { console.log('CPU is reading 8033B1B0') })
const addr_range_rom = {start: 0xB0000000, end: 0xB6000000} events.onread(addr_range_rom, function(addr) { console.log('CPU is reading ROM ' + addr) })
events.onwrite(0x8033B1B0, function() { console.log('CPU is modifying 8033B1B0') })
events.onwrite({0xB0000000, 0x90000000}, function(addr) { console.log(gpr.pc.hex() + ': wrote to cartridge ' + addr.hex()); })
events.ondraw(function() { console.log('Frame drawn') })
var callbackId = events.onexec(0x80000180, function() { // Only invoked once console.log('Interrupt fired') events.remove(callbackId) })
events.onexec(0x802CB1C0, function() { if(gpr.a0 == 0) { console.log('0 passed to 0x802CB1C0, breaking') debug.breakhere() } })
console.print('Hello world\n')
console.log('Hello', 'world')
alert('Hello world') // Blocks the script's thread events.onexec(0x80000180, function() { alert('Interrupt fired!') // Blocks the emulation thread })
events.ondraw(function() { screen.print(20, 20, "power: ' + mem.u8[0x8033B21E]) })
events.onexec(0x802CB1C0, function() { if(gpr.a0 == 2) { gpr.a0 = 3 } })
events.onexec(0x802CB1C0, function() { if(gpr.f0 == 2.0) { gpr.f0 = 3.0 } })
var server = new Server({port: 80})
server.on('connection', function(socket) { socket.on('data', function(data) { socket.write('hello') }) })
ADDR_ANY 0x00000000 : 0x100000000 Any 32-bit address ADDR_ANY_KUSEG 0x00000000 : 0x80000000 MIPS user mode TLB mapped segment ADDR_ANY_KSEG0 0x80000000 : 0xA0000000 MIPS cached unmapped segment ADDR_ANY_KSEG1 0xA0000000 : 0xC0000000 MIPS uncached unmapped segment ADDR_ANY_KSEG2 0xC0000000 : 0x100000000 MIPS kernel mode TLB mapped segment ADDR_ANY_RDRAM 0x80000000 : 0x80800000 Cached RDRAM ADDR_ANY_RDRAM_UNC 0xA0000000 : 0xA0800000 Uncached RDRAM ADDR_ANY_CART_ROM 0x90000000 : 0x96000000 Cached cartridge ROM ADDR_ANY_CART_ROM_UNC 0xB0000000 : 0xB6000000 Uncached cartridge ROM
var sm64EntryPC = rom.u32[0x00000008] console.log("Entry: " + sm64EntryPC.hex()) // "Entry: 80246000"