-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathAgi.ts
58 lines (53 loc) · 1.76 KB
/
Agi.ts
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
/*
Adventure Game Interpreter
Original IBM PC version by Jeff Stephenson and Cris Iden
of Sierra On-Line Inc. Around 1984-1989.
JavaScript version by Erik Sandberg, 2014 (30th-ish anniversary!).
This interpreter parses the original game resource files.
I do not provide these files as they are the intellectual property of Sierra.
This is not a straight port, but has been implemented from the specs
defined by Lance Ewing, Peter Kelly, Claudio Matsuoka, Stu George and David Symonds
at http://wiki.scummvm.org/index.php/AGI/Specifications
*/
namespace Agi {
export var palette: number[] = [
0x000000,
0x0000AA,
0x00AA00,
0x00AAAA,
0xAA0000,
0xAA00AA,
0xAA5500,
0xAAAAAA,
0x555555,
0x5555FF,
0x55FF55,
0x55FFFF,
0xFF5555,
0xFF55FF,
0xFFFF55,
0xFFFFFF
];
export var interpreter: Interpreter;
export function start(path: string, context: CanvasRenderingContext2D) {
Resources.load(path, () => {
interpreter = new Interpreter(context);
interpreter.start();
window.onkeypress = function (e) {
if (e.which != 13) {
interpreter.keyboardCharBuffer.push(e.which);
console.log("Keypress");
}
};
window.onkeydown = function (e) {
interpreter.keyboardSpecialBuffer.push(e.which);
console.log("keydown");
};
(function renderloop() {
//window.requestAnimationFrame(renderloop);
interpreter.cycle();
setTimeout(renderloop, (1000 / 20) * interpreter.variables[10]);
})();
});
}
}