4 <meta http-equiv="X-UA-Compatible" content="IE=9">
6 <title>ELCC-IDE</title>
7 <style type="text/css">
12 font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
17 border: 2px dashed #bbb;
24 <script type="text/javascript" src="./header.js" charset="UTF-8"></script>
25 <script type="text/javascript">
28 var mainCompiler = null;
29 var codeTextArea = null;
30 var debugMessageTextArea = null;
31 var maxDebugMessageLength = 0x1000;
35 debugMessageTextArea = document.getElementById('debugMessageText');
36 mainCPU = new WebCPU();
37 mainCompiler = new ELCHNOSCompiler(messageOut, document.getElementById('downloadBox'));
39 mainCPU.setMainWindowCanvasDOMObject("mainWindowCanvas");
42 // Setup the dnd listeners.
43 var dropZone = document.getElementById('fileDropZone');
44 dropZone.addEventListener('dragover', handleDragOver, false);
45 dropZone.addEventListener('drop', handleFileSelect, false);
47 //Enable Tab key in textarea
48 codeTextArea = document.getElementById('codeText');
49 //http://d.hatena.ne.jp/hokaccha/20111028/1319814792
50 codeTextArea.addEventListener("keydown", function(e) {
51 if (e.keyCode === 9) {
55 var pos = elem.selectionStart;
56 elem.value = val.substr(0, pos) + '\t' + val.substr(pos, val.length);
57 elem.setSelectionRange(pos + 1, pos + 1);
63 function messageOut(s){
64 var str = debugMessageTextArea.value + s;
65 if(str.length > maxDebugMessageLength){
66 str = str.slice(str.length - (maxDebugMessageLength >> 1));
68 debugMessageTextArea.value = str;
69 debugMessageTextArea.scrollTop = debugMessageTextArea.scrollHeight;
73 debugMessageTextArea.value += "****Compile Started****\n";
74 binStr = mainCompiler.compile(codeTextArea.value);
76 messageOut("*\n****Compile Succeeded!****\n*\n");
78 messageOut("*\n****Compile Failed...****\n*\n");
84 mainCPU.loadBinaryText(binStr);
87 messageOut("run: No available binary.\n");
91 function showAssembly(){
93 mainCPU.loadBinaryText(binStr);
95 messageOut("showAssembly: No available binary.\n");
99 function enableDebugMode(){
100 mainCPU.setDebugMessageDOMObject("debugMessageText");
101 mainCPU.message("****Debug mode enabled.\n");
104 function disableDebugMode(){
105 mainCPU.message("****Debug mode disabled.\n");
106 mainCPU.setDebugMessageDOMObject(null);
109 // http://www.html5rocks.com/ja/tutorials/file/dndfiles/
110 function handleFileSelect(evt){
111 evt.stopPropagation();
112 evt.preventDefault();
114 var files = evt.dataTransfer.files; // FileList object.
116 // files is a FileList of File objects. List some properties.
118 for(var i = 0, f; f = files[i]; i++){
119 output.push('<li><strong>', escape(f.name), '</strong> ', f.size, ' bytes, last modified: ', f.lastModifiedDate.toLocaleDateString(), '</li>');
120 var r = new FileReader();
121 r.onload = (function(file){
123 codeTextArea.value = r.result;
130 function handleDragOver(evt){
131 evt.stopPropagation();
132 evt.preventDefault();
133 evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
139 <div style="float:left;">
141 <canvas id="mainWindowCanvas" width="640" height="480" style="border:1px solid #000000;"></canvas>
143 <textarea id="debugMessageText" cols="66" rows="16"></textarea>
144 <form onsubmit="return false;">
145 <button onclick="compile();">Compile</button>
146 <button onclick="showAssembly();">Show Assembly</button>
147 <button onclick="run();">Run</button>
148 <button onclick="mainCPU.stopFlag = true;">Break</button>
150 <button onclick="enableDebugMode();">EnableDebugMode</button>
151 <button onclick="disableDebugMode();">DisableDebugMode</button>
152 <button onclick="mainCPU.showIntegerRegister();">ShowIntegerRegister</button>
153 <button onclick="mainCPU.showPointerRegister();">ShowPointerRegister</button>
155 <button onclick="if(binStr){ mainCompiler.saveBinary(); }">Create bin.ose</button>
159 <div id="downloadBox"></div>
161 <div style="float:left;">
163 <textarea id="codeText" cols="80" rows="48" wrap="off">
164 unsigned char table[32] = {
165 196, 100, 187, 61, 164, 29, 129, 9,
166 90, 5, 53, 17, 23, 44, 7, 81,
167 7, 119, 23, 156, 53, 183, 90, 195,
168 129, 191, 164, 171, 187, 139, 196, 100,
171 procedure inline drawLine(int mode, x0, y0, x1, y1, col){
173 REMARK 05 0100000003;
188 int x0, y0, x1, y1, col, i, j;
189 unsigned char *p, *q;
192 for (i = 0; i != 15; i++) {
199 for (j = -8; j != 8; j++) {
209 drawLine(1 + 4, x0, y0, x1, y1, col);
215 <div id="fileDropZone">Drop SourceCode.elc here</div>