2 this.mainWindowCanvas = null;
3 this.mainWindowContext = null;
4 this.mainWindowBufferCanvas = document.createElement('canvas');
5 this.mainWindowBufferContext = this.mainWindowBufferCanvas.getContext("2d");
7 this.mainWindowBufferCanvas.width = 640;
8 this.mainWindowBufferCanvas.height = 480;
9 this.initCanvas(this.mainWindowBufferCanvas);
11 WebCPU_API.prototype = {
12 executeAPI: function(env){
13 var r = env.registers.Integer;
18 this.API_openWin(env, r[0x31], r[0x32])
22 this.API_flushWin(env, r[0x31], r[0x32], r[0x33], r[0x34])
26 this.API_drawPoint(env, r[0x31], r[0x32], r[0x33], r[0x34]);
30 this.API_drawLine(env, r[0x31], r[0x32], r[0x33], r[0x34], r[0x35], r[0x36]);
34 this.API_fillRect(env, r[0x31], r[0x32], r[0x33], r[0x34], r[0x35], r[0x36]);
38 this.API_fillOval(env, r[0x31], r[0x32], r[0x33], r[0x34], r[0x35], r[0x36]);
41 throw new WebCPU_Exception(0, ["Unknown API Number " + APIID.toString(16)]);
43 env.goToPointerRegister(0x30);
55 setMainWindowCanvasDOMObject: function(obj){
56 this.mainWindowCanvas = obj;
57 if(this.mainWindowCanvas){
58 this.mainWindowContext = this.mainWindowCanvas.getContext('2d')
59 this.initCanvas(this.mainWindowCanvas);
61 this.mainWindowContext = null;
64 initCanvas: function(c){
65 var d = c.getContext('2d');
66 d.fillStyle = "rgba(0,0,0,1)";
67 d.strokeStyle = "rgba(255, 255, 255, 1)";
70 d.fillRect(0, 0, c.width, c.height);
73 API_openWin: function(env, xSize, ySize){
74 env.message("junkApi_openWin();\n", 20);
75 this.mainWindowCanvas.width = xSize;
76 this.mainWindowCanvas.height = ySize;
77 this.mainWindowBufferCanvas.width = xSize;
78 this.mainWindowBufferCanvas.height = ySize;
80 API_flushWin: function(env, xSize, ySize, x0, y0){
81 env.message("junkApi_flushWin();\n", 20);
82 this.mainWindowContext.drawImage(this.mainWindowBufferCanvas, x0, y0, xSize, ySize, 0, 0, xSize, ySize);
84 API_drawPoint: function(env, mode, x, y, col){
85 env.message("junkApi_drawPoint();\n", 20);
86 if((mode & 0x04) != 0){
87 col = this.colorTable[col];
89 this.mainWindowBufferContext.fillStyle = "#" + ("000000" + col.toString(16)).slice(-6).toUpperCase();
90 this.mainWindowBufferContext.fillRect(x, y, 1, 1);
92 API_drawLine: function(env, mode, x0, y0, x1, y1, col){
93 env.message("junkApi_drawLine();\n", 20);
95 if((mode & 0x04) != 0){
96 col = this.colorTable[col];
99 this.mainWindowBufferContext.strokeStyle = "#" + ("000000" + col.toString(16)).slice(-6).toUpperCase();
100 this.mainWindowBufferContext.beginPath();
101 this.mainWindowBufferContext.moveTo(x0, y0);
102 this.mainWindowBufferContext.lineTo(x1, y1);
103 this.mainWindowBufferContext.closePath();
104 this.mainWindowBufferContext.stroke();
106 API_fillRect: function(env, mode, xSize, ySize, x0, y0, col){
107 env.message("junkApi_fillRect();\n", 20);
109 if((mode & 0x04) != 0){
110 col = this.colorTable[col];
113 this.mainWindowBufferContext.fillStyle = "#" + ("000000" + col.toString(16)).slice(-6).toUpperCase();
114 this.mainWindowBufferContext.fillRect(x0, y0, xSize, ySize);
116 API_fillOval: function(env, mode, xSize, ySize, x0, y0, col){
117 env.message("junkApi_fillRect();\n", 20);
119 if((mode & 0x04) != 0){
120 col = this.colorTable[col];
123 this.mainWindowBufferContext.fillStyle = "#" + ("000000" + col.toString(16)).slice(-6).toUpperCase();
124 this.mainWindowBufferContext.fillEllipse(x0, y0, xSize, ySize);