-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpages.h
129 lines (126 loc) · 5.7 KB
/
webpages.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const char gui[] PROGMEM =
"<html><head>\n"
"<meta name='viewport' content='width=device-width, initial-scale=1' />\n"
"<meta http-equiv='Cache-Control' content='no-cache, no-store, must-revalidate' />\n"
"<meta http-equiv='Pragma' content='no-cache' />\n"
"<meta http-equiv='Expires' content='0' />\n"
"<script src='VICII.js'></script>\n"
"</head>\n"
"<body>\n<h1 style='font-family:Lucida Console;font-size:32px;margin:0px;padding:0px'>Commodore C-64</h1>\n"
"<div id='fps' style='display:none'></div>"
//"<div id='fps' style='display:none;background-color:#FFFFAA;border:1px solid black;width:42px;height:24px;text-align:center;line-height:22px;font-size:12px;'>10 fps</div>"
"<canvas id='vicoutput' style='background-color:#333333;border:1px;width:384px;height:264px;'></canvas>\n"
//"<canvas id='vicoutput' style='background-color:#A4A4FE;border:1px;width:384px;height:264px;'></canvas>\n"
"<DIV id='Log' style='display:none'></div>\n"
//"<DIV id='Log' style='display:none;background-color:#FFFFAA;width:378px;height:80px;border:1px solid black;font-family:Lucida console;font-size:10px;padding:2px;overflow:auto;'></div>\n"
"<DIV id='PopUp'\n"
" style='display: none; position: absolute; left: 30px; top: 50px; border: solid black 1px; padding: 10px; background-color: rgb(240,240,240); text-align: justify; font-size: 12px; width: 360px;'\n"
" onclick='document.getElementById('PopUp').style.display = 'none''>\n"
"<SPAN id='PopUpText' style='font-family:Lucida Console;letter-spacing: 2px;'>TEXT</SPAN>\n"
"</DIV>\n"
"<div id='showkbd'><input type=text id='android' name=android></div>\n" // some tries to show android keyboard, but...
"<SCRIPT>\n"
" var target = document.getElementById('android');"
" target.focus();target.click(); \n" // Android "show keyboard" command
"document.getElementById('showkbd').style.visibility = 'hidden';\n"
"</SCRIPT>\n"
"</body></html>\n";
//Onready vindt alleen plaats als er iets wordt verzonden naar de browser!
//responeType arrayBuffer werkt niet goed!!! ALternatief is blob?
// " xmlhttp.responseType = 'arraybuffer';\n"
const char vicii[] PROGMEM =
"var canvas;\n"
"var ctx;\n"
"var VICRAM;\n"
"var RAM_SIZE=1025;\n"
"var interval;\n"
"var xmlhttp=new XMLHttpRequest();\n"
"function printLog(msg){var log=document.getElementById('Log');log.innerHTML=log.innerHTML+msg+'<br>';log.scrollTop = log.scrollHeight}\n"
"document.addEventListener('DOMContentLoaded',initCanvas,false);\n"
"var fC=0;\n"
"var cS=0;\n"
"setInterval(updateFPS,1000);\n"
"setInterval(function(){cS=!cS;},500);\n"
"function updateFPS(){\n"
" var fT = document.getElementById('fps');\n"
" fT.innerHTML=fC+ ' fps';\n"
" fC=0;"
"}\n"
"function initCanvas(){\n"
" printLog('initCanvas');\n"
" canvas = document.getElementById('vicoutput');\n"
" canvas.width=384;\n"
" canvas.height=264;\n"
" ctx = canvas.getContext('2d');\n"
" ctx.font = '12px Lucida Console';\n"
" VICRAM = new Uint8Array(RAM_SIZE);\n"
" refreshVICRAM();\n"
" document.addEventListener('keypress', keypress, false);\n"
"}\n"
"var isAlive=true;\n"
"var aliveTimer;\n"
"function alive( ){\n"
" if (!isAlive) {\n"
" xmlhttp.abort();refreshVICRAM();\n"
" printLog('Restarting connection');\n"
" }\n "
"}\n"
"function refreshVICRAM( ){\n"
// based on https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
" xmlhttp.onreadystatechange=function(){\n"
" if (xmlhttp.readyState==4 && xmlhttp.status==200){\n"
" isAlive=true;\n"
" var aB=xmlhttp.response;\n"
" if (aB){\n"
" VICRAM = new Uint8Array(aB);\n"
" refreshDisplay();\n"
" setTimeout(refreshVICRAM,0);\n"
" }\n"
" }\n"
" }\n"
" var tp='GET';\n"
" var url='/VICIIRefresh';\n"
" if (keyp.length>0) {tp='POST';url=url+keyp;}\n"
" keyp='';\n"
" xmlhttp.open(tp,url,true);\n"
" xmlhttp.setRequestHeader('Content-type','application/octet-stream');\n"
" xmlhttp.responseType='arraybuffer';\n"
" xmlhttp.send();\n"
" isAlive=false;\n"
" clearTimeout(aliveTimer);\n"
" aliveTimer=setTimeout(alive,3000);\n"
"}\n"
//https://www.c64-wiki.com/index.php/Color
"var pal=['#000000','#FFFFFF','#880000','#AAFFEE','#CC44CC','#00CC55','#0000AA','#EEEE77','#DD8855','#664400','#FF7777','#333333','#777777','#AAFF66','#0088FF','#BBBBBB'];\n"
"function refreshDisplay(){\n"
// " printLog('refreshDisplay');\n"
" var tcol=pal[VICRAM[4]];\n"//text color
" var fcol=pal[VICRAM[5]];\n"//frame/border color
" var bcol=pal[VICRAM[6]];\n"//back color
" ctx.fillStyle=fcol;\n"
" ctx.fillRect(0,0,384,264);\n"
" ctx.fillStyle=bcol;\n"
" ctx.fillRect(32,32,320,200);\n"
" ctx.font='10px Lucida console';\n"
" ctx.textBaseline='top';\n"
" ctx.textAlign='left';\n"
" ctx.fillStyle=tcol;\n"
" var petscii;\n"
" for (var col=0;col<40;col++){\n"
" for (var row=0;row<40;row++){\n"
" petscii=VICRAM[24+row*40+col];\n"//char rom starts at 24 offset
" if (petscii<32) petscii = petscii + 64;\n"
" ctx.fillText(String.fromCharCode(petscii),32+col*8,32+row*8);\n"
" }\n"
" }\n"
" if (cS) ctx.fillRect(32+VICRAM[1]*8,32+VICRAM[0]*8,8,8);\n"
" fC++;\n"
"}\n"
"var keyp='';\n"
"function keypress(e) {\n"
" var keyCode = e.keyCode;\n"
" if (keyp.length==0) {keyp=keyp+'?';}else{keyp=keyp+'&';}\n"
" keyp=keyp+'k='+keyCode.toString();\n"
// " printLog('keyDown: '+keyCode);\n"
"}\n"
;