Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IodineGBA/core/graphics/RendererShim.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GameBoyAdvanceGraphicsRendererShim.prototype.shareDynamicBuffers = function () {
});
}
//Wake up the producer "GPU" thread:
Atomics.wake(gfxCounters, 2, 1);
Atomics.notify(gfxCounters, 2, 1);
}
GameBoyAdvanceGraphicsRendererShim.prototype.pushCommand = function (command, data) {
command = command | 0;
Expand Down
6 changes: 5 additions & 1 deletion IodineGBA/includes/TypedArrayShim.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ if (typeof Atomics == "object") {
if (typeof Atomics.futexWait == "function" && typeof Atomics.wait == "undefined") {
//Polyfill in deprecated call names:
Atomics.wait = Atomics.futexWait;
Atomics.wake = Atomics.futexWake;
Atomics.notify = Atomics.futexWake;
}
else if (typeof Atomics.wake == "function" && typeof Atomics.notify == "undefined") {
//Polyfill in deprecated call names:
Atomics.notify = Atomics.wake;
}
}
77 changes: 0 additions & 77 deletions user_scripts/CoreGlueCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ function initTimer() {
IodineGUI.coreTimerID = setInterval(function () {
IodineGUI.Iodine.timerCallback(((+(new Date()).getTime()) - (+IodineGUI.startTime)) >>> 0);
}, IodineGUI.defaults.timerRate | 0);
findRealClock();
}
function calculateTiming() {
IodineGUI.Iodine.setIntervalRate(+IodineGUI.defaults.timerRate);
findRealClock();
}
function startTimer() {
IodineGUI.coreTimerID = setInterval(function () {
Expand All @@ -155,81 +153,6 @@ function updateTimer(newRate) {
}
}
}
function findRealClock() {
var count = 0;
var startTime = +(new Date()).getTime();
var realTimer = setInterval(function () {
if (!IodineGUI.suspended) {
count = ((count | 0) + 1) | 0;
if (count == 20) {
var timeDiff = ((+(new Date()).getTime()) - (+startTime)) >>> 0;
var trueRate = timeDiff / 20;
if ((+trueRate) > 17) {
count = 0;
}
else {
var delta = +((+trueRate) - (IodineGUI.defaults.timerRate | 0));
if ((IodineGUI.defaults.timerRate | 0) == 16) {
if (delta > -0.1 && delta < 0.1) {
clearInterval(realTimer);
}
else if ((trueRate - 1000/64) > -0.1 && (trueRate - 1000/64) < 0.1) {
IodineGUI.Iodine.setIntervalRate(1000/64);
clearInterval(realTimer);
}
else if ((trueRate - 50/3) > -0.1 && (trueRate - 50/3) < 0.1) {
IodineGUI.Iodine.setIntervalRate(50/3);
clearInterval(realTimer);
}
else {
count = 0;
}
}
else if ((IodineGUI.defaults.timerRate | 0) == 4) {
if (delta > -0.1 && delta < 0.1) {
clearInterval(realTimer);
}
else if ((trueRate - 25/6) > -0.1 && (trueRate - 25/6) < 0.1) {
IodineGUI.Iodine.setIntervalRate(25/6);
clearInterval(realTimer);
}
else {
count = 0;
}
}
else if ((IodineGUI.defaults.timerRate | 0) == 8) {
if (delta > -0.1 && delta < 0.1) {
clearInterval(realTimer);
}
else if ((trueRate - 25/3) > -0.1 && (trueRate - 25/3) < 0.1) {
IodineGUI.Iodine.setIntervalRate(25/3);
clearInterval(realTimer);
}
else {
count = 0;
}
}
else {
if (delta > -0.1 && delta < 0.1) {
clearInterval(realTimer);
}
else if (trueRate < 16) {
IodineGUI.Iodine.setIntervalRate(+trueRate);
clearInterval(realTimer);
}
else {
count = 0;
}
}

}
}
}
else {
count = 0;
}
}, IodineGUI.defaults.timerRate | 0);
}
function registerBlitterHandler() {
IodineGUI.Blitter = new GfxGlueCode(240, 160);
IodineGUI.Blitter.attachCanvas(document.getElementById("emulator_target"));
Expand Down
2 changes: 1 addition & 1 deletion user_scripts/WorkerGfxGlueCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ IodineGBAWorkerGfxShim.prototype.graphicsHeartBeat = function () {
//Copy the buffer out to local:
this.consumeGraphicsBuffer();
//Wake up the producer thread:
Atomics.wake(gfxCounters, 2, 1);
Atomics.notify(gfxCounters, 2, 1);
}
}
IodineGBAWorkerGfxShim.prototype.consumeGraphicsBuffer = function () {
Expand Down
2 changes: 1 addition & 1 deletion user_scripts/WorkerGlueCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ IodineGBAWorkerShim.prototype.graphicsHeartBeat = function () {
//Copy the buffer out to local:
this.consumeGraphicsBuffer();
//Wake up the producer thread:
Atomics.wake(this.gfxCounters, 2, 1);
Atomics.notify(this.gfxCounters, 2, 1);
}
}
IodineGBAWorkerShim.prototype.consumeGraphicsBuffer = function () {
Expand Down