123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104 |
- <html><head>
- <title>PICO-8 Cartridge</title>
- <meta name="viewport" content="width=device-width, user-scalable=no">
- <script type="text/javascript">
-
-
-
-
-
- var p8_allow_mobile_menu = true;
-
-
- var p8_autoplay = false;
-
-
- var pico8_state = [];
-
-
-
- var pico8_buttons = [0, 0, 0, 0, 0, 0, 0, 0];
-
- var pico8_mouse = [];
-
- var pico8_gamepads = {};
- pico8_gamepads.count = 0;
-
- var pico8_gpio = new Array(128);
-
-
-
- var pico8_audio_context;
-
- p8_gfx_dat={
- "p8b_pause1": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAOUlEQVRIx2NgGPbg/8cX/0F46FtAM4vobgHVLRowC6hm0YBbQLFFoxaM4FQ0dHPy0C1Nh26NNugBAAnizNiMfvbGAAAAAElFTkSuQmCC",
- "p8b_controls":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAQ0lEQVRIx2NgGAXEgP8fX/ynBaap4XBLhqcF1IyfYWQBrZLz0LEAlzqqxQFVLcAmT3MLqJqTaW7B4CqLaF4fjIIBBwBL/B2vqtPVIwAAAABJRU5ErkJggg==",
- "p8b_full":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAN0lEQVRIx2NgGPLg/8cX/2mJ6WcBrUJm4CwgOSgGrQVEB8WoBaMWDGMLhm5OHnql6dCt0YY8AAA9oZm+9Z9xQAAAAABJRU5ErkJggg==",
- "p8b_pause0":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAKUlEQVRIx2NgGHbg/8cX/7FhctWNWjBqwagFoxaMWjBqwagF5Fkw5AAAPaGZvsIUtXUAAAAASUVORK5CYII=",
- "p8b_sound0":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAANklEQVRIx2NgGDHg/8cX/5Hx0LEA3cChYwEugwavBcRG4qgFoxYMZwuGfk4efqXp8KnRBj0AAMz7cLDnG4FeAAAAAElFTkSuQmCC",
- "p8b_sound1":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAPUlEQVRIx2NgGDHg/8cX/5Hx0LEA3cChYwEugwhZQLQDqG4BsZFIKMhGLRi1YChbMPRz8vArTYdPjTboAQCSVgpXUWQAMAAAAABJRU5ErkJggg==",
- "p8b_close":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAU0lEQVRIx2NkoDFgpJsF/z+++I8iwS9BkuW49A+cBcRaREgf/Swg1SJi1dHfAkIG4EyOOIJy4Cwg1iJCiWDUAvItGLqpaOjm5KFfmg79Gm3ItioAl+mAGVYIZUUAAAAASUVORK5CYII=",
- "controls_left_panel":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAEI0lEQVR42u3dMU7DQBCG0Tjam9DTcP8jpEmfswS5iHBhAsLxev/hvQY6pGXyZRTQ+nQCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHqbHEEtl+vt7hS+fLy/mXHBQqxEi/6aI/AiFW9SnB2BWDkDBAtAsADBAhAsAMECBAtAsAAECxAsAMECECxAsAAEC0CwONJ8tYvrXRAsImK19j0IFsPGSrQQLCJiNV+et7xAT7QQLIaN1dr3ooVgMWysRAvBIipWooVgERUr0UKwiIqVaCFYRMVKtBAsomIlWggWUbESLQSLqFiJFoJFVKxEC8EiKlaihWARFSvRQrDYJSSVfhaCBSBYAIIFCBbAHpoj4Bl/scOGBWDD4lX8iwE2LADBAgQLQLAABAsQLADBAhAsQLAABAtAsADBAhAsAMECBAtAsAAECxAsAMECECxAsAA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+eSYQWLzceY1CpttgE92S8AOBxZIu7PUnRvcEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwwL/cvBIh09+hJAAAAABJRU5ErkJggg==",
- };
-
-
- document.addEventListener('touchstart', {});
- document.addEventListener('touchmove', {});
- document.addEventListener('touchend', {});
-
-
- var p8_dropped_cart = null;
- var p8_dropped_cart_name = "";
- function p8_drop_file(e)
- {
-
-
- e.stopPropagation();
- e.preventDefault();
- if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files[0])
- {
-
- reader = new FileReader();
- reader.onload = function (event) {
- p8_dropped_cart_name = e.dataTransfer.files[0].name;
- p8_dropped_cart = reader.result;
-
- e.stopPropagation();
- e.preventDefault();
- };
- reader.readAsDataURL(e.dataTransfer.files[0]);
- codo_command = 9;
- }
- else
- {
-
- txt = e.dataTransfer.getData('Text');
- if (txt){
- p8_dropped_cart_name = "untitled.p8.png";
- p8_dropped_cart = txt;
- codo_command = 9;
- }
- }
- }
- function nop(evt) {
- evt.stopPropagation();
- evt.preventDefault();
- }
- function dragover(evt) {
- evt.stopPropagation();
- evt.preventDefault();
- Module.pico8DragOver();
- }
- function dragstop(evt) {
- evt.stopPropagation();
- evt.preventDefault();
- Module.pico8DragStop();
- }
-
- var p8_buttons_hash = -1;
- function p8_update_button_icons()
- {
-
- if (!p8_is_running)
- {
- requestAnimationFrame(p8_update_button_icons);
- return;
- }
- var is_fullscreen=(document.fullscreenElement || document.mozFullScreenElement || document.webkitIsFullScreen || document.msFullscreenElement);
-
-
- var hash = 0;
- hash = pico8_state.sound_volume;
- if (pico8_state.is_paused) hash += 0x100;
- if (p8_touch_detected) hash += 0x200;
- if (is_fullscreen) hash += 0x400;
- if (p8_buttons_hash == hash)
- {
- requestAnimationFrame(p8_update_button_icons);
- return;
- }
-
- p8_buttons_hash = hash;
-
- els = document.getElementsByClassName('p8_menu_button');
- for (i = 0; i < els.length; i++)
- {
- el = els[i];
- index = el.id;
- if (index == 'p8b_sound') index += (pico8_state.sound_volume == 0 ? "0" : "1");
- if (index == 'p8b_pause') index += (pico8_state.is_paused > 0 ? "1" : "0");
- new_str = '<img width=24 height=24 style="pointer-events:none" src="'+p8_gfx_dat[index]+'">';
- if (el.innerHTML != new_str)
- el.innerHTML = new_str;
-
-
- var is_visible = p8_is_running;
- if ((!p8_touch_detected || !p8_allow_mobile_menu) && el.parentElement.id == "p8_menu_buttons_touch")
- is_visible = false;
- if (p8_touch_detected && el.parentElement.id == "p8_menu_buttons")
- is_visible = false;
- if (is_fullscreen)
- is_visible = false;
- if (is_visible)
- el.style.display="";
- else
- el.style.display="none";
- }
- requestAnimationFrame(p8_update_button_icons);
- }
- function abs(x)
- {
- return x < 0 ? -x : x;
- }
-
-
- function pico8_buttons_event(e, step)
- {
- if (!p8_is_running) return;
-
- pico8_buttons[0] = 0;
- if (step == 2 && typeof(pico8_mouse) !== 'undefined')
- {
- pico8_mouse[2] = 0;
- }
-
- var num = 0;
- if (e.touches) num = e.touches.length;
- if (num == 0 && typeof(pico8_mouse) !== 'undefined')
- {
-
- pico8_mouse[2] = 0;
- }
-
- for (var i = 0; i < num; i++)
- {
- var touch = e.touches[i];
- var x = touch.clientX;
- var y = touch.clientY;
- var w = window.innerWidth;
- var h = window.innerHeight;
- var r = Math.min(w,h) / 12;
- if (r > 40) r = 40;
-
- let canvas = document.getElementById("canvas");
- if (p8_touch_detected)
- if (typeof(pico8_mouse) !== 'undefined')
- if (canvas)
- {
- var rect = canvas.getBoundingClientRect();
-
- if (x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom)
- {
- pico8_mouse = [
- Math.floor((x - rect.left) * 128 / (rect.right - rect.left)),
- Math.floor((y - rect.top) * 128 / (rect.bottom - rect.top)),
- step < 2 ? 1 : 0
- ];
-
- }else
- {
- pico8_mouse[2] = 0;
- }
- }
-
-
- b = 0;
- if (y < h - r*8)
- {
-
- }
- else
- {
- e.preventDefault();
- if ((y < h - r*6) && y > (h - r*8))
- {
-
-
- if (x > w - r*3)
- b |= 0x40;
- }
- else if (x < w/2 && x < r*6)
- {
-
- mask = 0xf;
- var cx = 0 + r*3;
- var cy = h - r*3;
- deadzone = r/3;
- var dx = x - cx;
- var dy = y - cy;
- if (abs(dx) > abs(dy) * 0.6)
- {
- if (dx < -deadzone) b |= 0x1;
- if (dx > deadzone) b |= 0x2;
- }
- if (abs(dy) > abs(dx) * 0.6)
- {
- if (dy < -deadzone) b |= 0x4;
- if (dy > deadzone) b |= 0x8;
- }
- }
- else if (x > w - r*6)
- {
-
-
- mask = 0x30;
-
-
- if ( (h-y) > (w-x) * 0.8) b |= 0x10;
- if ( (w-x) > (h-y) * 0.8) b |= 0x20;
- }
- }
- pico8_buttons[0] |= b;
-
- }
- }
-
- var p8_update_layout_hash = -1;
- var last_windowed_container_height = 512;
- var p8_layout_frames = 0;
- function p8_update_layout()
- {
- var canvas = document.getElementById("canvas");
- var p8_playarea = document.getElementById("p8_playarea");
- var p8_container = document.getElementById("p8_container");
- var p8_frame = document.getElementById("p8_frame");
- var csize = 512;
- var margin_top = 0;
- var margin_left = 0;
-
- if (!canvas || !p8_playarea || !p8_container || !p8_frame)
- {
- p8_update_layout_hash = -1;
- requestAnimationFrame(p8_update_layout);
- return;
- }
- p8_layout_frames ++;
-
-
- var is_fullscreen=(document.fullscreenElement || document.mozFullScreenElement || document.webkitIsFullScreen || document.msFullscreenElement);
- var frame_width = p8_frame.offsetWidth;
- var frame_height = p8_frame.offsetHeight;
- if (is_fullscreen)
- {
-
- frame_width = window.innerWidth;
- frame_height = window.innerHeight;
- }
- else{
-
- frame_width = Math.min(frame_width, window.innerWidth);
- frame_height = Math.min(frame_height, window.innerHeight);
- }
-
- csize = Math.min(frame_width,frame_height);
-
- if (p8_touch_detected && p8_is_running)
- {
- var longest_side = Math.max(window.innerWidth,window.innerHeight);
- csize = Math.min(csize, longest_side * 2/3);
- }
-
-
- if (frame_width >= 512 && frame_height >= 512)
- {
- csize = (csize+1) & ~0x7f;
- }
-
-
- if (!is_fullscreen && p8_frame)
- csize = Math.min(csize, last_windowed_container_height);
-
- if (is_fullscreen)
- {
-
- margin_left = (frame_width - csize)/2;
- if (p8_touch_detected)
- {
- if (window.innerWidth < window.innerHeight)
- {
-
- margin_top = Math.min(40, frame_height - csize);
- }
- else
- {
-
- margin_top = (frame_height - csize)/4;
- }
- }
- else{
-
- margin_top = (frame_height - csize)/2;
- }
- }
-
- var update_hash = csize + margin_top * 1000.3 + margin_left * 0.001 + frame_width * 333.33 + frame_height * 772.15134;
- if (is_fullscreen) update_hash += 0.1237;
-
-
- if (p8_layout_frames < 180 || p8_layout_frames == 60*5 || p8_layout_frames == 60*8 )
- update_hash = p8_layout_frames;
- if (!is_fullscreen)
- if (!p8_touch_detected)
- if (p8_update_layout_hash == update_hash)
- {
-
- requestAnimationFrame(p8_update_layout);
- return;
- }
- p8_update_layout_hash = update_hash;
-
- if (!is_fullscreen && p8_frame)
- last_windowed_container_height = p8_frame.parentNode.parentNode.offsetHeight;
-
-
-
- if (p8_touch_detected && p8_is_running && document.body.clientWidth < document.body.clientHeight)
- p8_playarea.style.marginTop = p8_allow_mobile_menu ? 32 : 8;
- else if (p8_touch_detected && p8_is_running)
- p8_playarea.style.marginTop = (document.body.clientHeight - csize) / 4;
- else
- p8_playarea.style.marginTop = "";
- canvas.style.width = csize;
- canvas.style.height = csize;
-
- canvas.style.marginLeft = margin_left;
- canvas.style.marginTop = margin_top;
- p8_container.style.width = csize;
- p8_container.style.height = csize;
-
- el = document.getElementById("p8_menu_buttons");
- el.style.marginTop = csize - el.offsetHeight;
- if (p8_touch_detected && p8_is_running)
- {
-
-
- canvas.style.pointerEvents = "none";
- p8_container.style.marginTop = "0px";
-
-
-
- var w = window.innerWidth;
- var h = window.innerHeight;
- var r = Math.min(w,h) / 12;
- if (r > 40) r = 40;
- el = document.getElementById("controls_right_panel");
- el.style.left = w-r*6;
- el.style.top = h-r*7;
- el.style.width = r*6;
- el.style.height = r*7;
- if (el.getAttribute("src") != p8_gfx_dat["controls_right_panel"])
- el.setAttribute("src", p8_gfx_dat["controls_right_panel"]);
- el = document.getElementById("controls_left_panel");
- el.style.left = 0;
- el.style.top = h-r*6;
- el.style.width = r*6;
- el.style.height = r*6;
- if (el.getAttribute("src") != p8_gfx_dat["controls_left_panel"])
- el.setAttribute("src", p8_gfx_dat["controls_left_panel"]);
-
-
-
- document.getElementById("touch_controls_gfx").style.display="table";
- document.getElementById("touch_controls_background").style.display="table";
- }
- else{
- document.getElementById("touch_controls_gfx").style.display="none";
- document.getElementById("touch_controls_background").style.display="none";
- }
- if (!p8_is_running)
- {
- p8_playarea.style.display="none";
- p8_container.style.display="flex";
- p8_container.style.marginTop="auto";
- el = document.getElementById("p8_start_button");
- if (el) el.style.display="flex";
- }
- requestAnimationFrame(p8_update_layout);
- }
- var p8_touch_detected = false;
- addEventListener("touchstart", function(event)
- {
- p8_touch_detected = true;
-
- el = document.getElementById("codo_textarea");
- if (el && el.style.display != "none"){
- el.style.display="none";
- }
- }, {passive: true});
- function p8_create_audio_context()
- {
- if (pico8_audio_context)
- {
- try {
- pico8_audio_context.resume();
- }
- catch(err) {
- console.log("** pico8_audio_context.resume() failed");
- }
- return;
- }
- var webAudioAPI = window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.oAudioContext || window.msAudioContext;
- if (webAudioAPI)
- {
- pico8_audio_context = new webAudioAPI;
-
- if (pico8_audio_context)
- {
- try {
- var dummy_source_sfx = pico8_audio_context.createBufferSource();
- dummy_source_sfx.buffer = pico8_audio_context.createBuffer(1, 1, 22050);
- dummy_source_sfx.connect(pico8_audio_context.destination);
- dummy_source_sfx.start(1, 0.25);
-
- }
- catch(err) {
- console.log("** dummy_source_sfx.start(1, 0.25) failed");
- }
- }
- }
- }
- function p8_close_cart()
- {
-
- window.location.hash = "";
- }
- var p8_is_running = false;
- var p8_script = null;
- var Module = null;
- function p8_run_cart()
- {
- if (p8_is_running) return;
- p8_is_running = true;
-
- if (p8_touch_detected)
- {
- el = document.getElementById("body_0");
- el2 = document.getElementById("p8_frame_0");
- if (el && el2)
- {
- el.style.display="none";
- el.parentNode.appendChild(el2);
- }
- }
-
- p8_create_audio_context();
-
- els = document.getElementsByClassName('p8_controller_area');
- for (i = 0; i < els.length; i++)
- els[i].style.display="";
-
-
- addEventListener("touchstart", function(event){ pico8_buttons_event(event, 0); }, {passive: false});
- addEventListener("touchmove", function(event){ pico8_buttons_event(event, 1); }, {passive: false});
- addEventListener("touchend", function(event){ pico8_buttons_event(event, 2); }, {passive: false});
-
- e = document.createElement("script");
- p8_script = e;
- e.onload = function(){
-
-
- el = document.getElementById("p8_playarea");
- if (el) el.style.display="table";
- if (typeof(p8_update_layout_hash) !== 'undefined')
- p8_update_layout_hash = -77;
- if (typeof(p8_buttons_hash) !== 'undefined')
- p8_buttons_hash = -33;
- }
- e.type = "application/javascript";
- e.src = "shmup.js";
- e.id = "e_script";
-
- document.body.appendChild(e);
-
- el = document.getElementById("p8_start_button");
- if (el) el.style.display="none";
-
-
- if (p8_touch_detected)
- {
- window.location.hash = "#playing";
- window.onhashchange = function()
- {
- if (window.location.hash.search("playing") < 0)
- window.location.reload();
- }
- }
-
- {
- let canvas = p8_document().getElementById("canvas");
- if (canvas)
- {
- canvas.addEventListener('dragenter', dragover, false);
- canvas.addEventListener('dragover', dragover, false);
- canvas.addEventListener('dragleave', dragstop, false);
- canvas.addEventListener('drop', nop, false);
- canvas.addEventListener('drop', p8_drop_file, false);
- }
- }
- }
-
-
-
- var P8_BUTTON_O = {action:'button', code: 0x10};
- var P8_BUTTON_X = {action:'button', code: 0x20};
- var P8_DPAD_LEFT = {action:'button', code: 0x1};
- var P8_DPAD_RIGHT = {action:'button', code: 0x2};
- var P8_DPAD_UP = {action:'button', code: 0x4};
- var P8_DPAD_DOWN = {action:'button', code: 0x8};
- var P8_MENU = {action:'menu'};
- var P8_NO_ACTION = {action:'none'};
- var P8_BUTTON_MAPPING = [
-
- P8_BUTTON_O,
- P8_BUTTON_X,
- P8_BUTTON_X,
- P8_BUTTON_O,
- P8_NO_ACTION,
- P8_NO_ACTION,
- P8_NO_ACTION,
- P8_NO_ACTION,
- P8_MENU,
- P8_MENU,
- P8_NO_ACTION,
- P8_NO_ACTION,
- P8_DPAD_UP,
- P8_DPAD_DOWN,
- P8_DPAD_LEFT,
- P8_DPAD_RIGHT,
- ];
-
-
-
- var pico8_gamepads_mapping = [];
- function p8_unassign_gamepad(gamepad_index) {
- if (pico8_gamepads_mapping[gamepad_index] == null) {
- return;
- }
- pico8_buttons[pico8_gamepads_mapping[gamepad_index]] = 0;
- pico8_gamepads_mapping[gamepad_index] = null;
- }
- function p8_first_player_without_gamepad(max_players) {
- var allocated_players = pico8_gamepads_mapping.filter(function(x) { return x != null; });
- var sorted_players = Array.from(allocated_players).sort();
- for (var desired = 0; desired < sorted_players.length && desired < max_players; ++desired) {
- if (desired != sorted_players[desired]) {
- return desired;
- }
- }
- if (sorted_players.length < max_players) {
- return sorted_players.length;
- }
- return null;
- }
- function p8_assign_gamepad_to_player(gamepad_index, player_index) {
- p8_unassign_gamepad(gamepad_index);
- pico8_gamepads_mapping[gamepad_index] = player_index;
- }
- function p8_convert_standard_gamepad_to_button_state(gamepad, axis_threshold, button_threshold) {
-
-
-
-
-
-
-
- if (!gamepad || !gamepad.axes || !gamepad.buttons) {
- return {
- button_state: 0,
- menu_button: false,
- any_button: false
- };
- }
- function button_state_from_axis(axis, low_state, high_state, default_state) {
- if (axis && axis < -axis_threshold) return low_state;
- if (axis && axis > axis_threshold) return high_state;
- return default_state;
- }
- var axes_actions = [
- button_state_from_axis(gamepad.axes[0], P8_DPAD_LEFT, P8_DPAD_RIGHT, P8_NO_ACTION),
- button_state_from_axis(gamepad.axes[1], P8_DPAD_UP, P8_DPAD_DOWN, P8_NO_ACTION),
- ];
- var button_actions = gamepad.buttons.map(function (button, index) {
- var pressed = button.value > button_threshold || button.pressed;
- if (!pressed) return P8_NO_ACTION;
- return P8_BUTTON_MAPPING[index] || P8_NO_ACTION;
- });
- var all_actions = axes_actions.concat(button_actions);
-
- var menu_button = button_actions.some(function (action) { return action.action == 'menu'; });
- var button_state = (all_actions
- .filter(function (a) { return a.action == 'button'; })
- .map(function (a) { return a.code; })
- .reduce(function (result, code) { return result | code; }, 0)
- );
- var any_button = gamepad.buttons.some(function (button) {
- return button.value > button_threshold || button.pressed;
- });
- any_button |= button_state;
- return {
- button_state,
- menu_button,
- any_button
- };
- }
-
-
-
- function p8_convert_unmapped_gamepad_to_button_state(gamepad, axis_threshold, button_threshold) {
- if (!gamepad || !gamepad.axes || !gamepad.buttons) {
- return {
- button_state: 0,
- menu_button: false,
- any_button: false
- };
- }
- var button_state = 0;
- if (gamepad.axes[0] && gamepad.axes[0] < -axis_threshold) button_state |= 0x1;
- if (gamepad.axes[0] && gamepad.axes[0] > axis_threshold) button_state |= 0x2;
- if (gamepad.axes[1] && gamepad.axes[1] < -axis_threshold) button_state |= 0x4;
- if (gamepad.axes[1] && gamepad.axes[1] > axis_threshold) button_state |= 0x8;
-
- for (j = 0; j < gamepad.buttons.length; j++)
- if (gamepad.buttons[j].value > 0 || gamepad.buttons[j].pressed)
- {
- if (j < 4)
- button_state |= (0x10 << (((j+1)/2)&1));
- else if (j >= 6 && j <= 8)
- button_state |= 0x40;
- }
- var menu_button = button_state & 0x40;
- var any_button = gamepad.buttons.some(function (button) {
- return button.value > button_threshold || button.pressed;
- });
- any_button |= button_state;
-
- return {
- button_state,
- menu_button,
- any_button
- };
- }
-
-
-
- function p8_update_gamepads() {
- var axis_threshold = 0.3;
- var button_threshold = 0.5;
- var max_players = 8;
- var gps = navigator.getGamepads() || navigator.webkitGetGamepads();
- if (!gps) return;
-
- gps = Array.from(gps);
- pico8_gamepads.count = gps.length;
- while (gps.length > pico8_gamepads_mapping.length) {
- pico8_gamepads_mapping.push(null);
- }
- var menu_button = false;
- var gamepad_states = gps.map(function (gp) {
- return (gp && gp.mapping == "standard") ?
- p8_convert_standard_gamepad_to_button_state(gp, axis_threshold, button_threshold) :
- p8_convert_unmapped_gamepad_to_button_state(gp, axis_threshold, button_threshold);
- });
-
-
- gps.forEach(function (gp, i) { if (!gp || !gp.connected) { p8_unassign_gamepad(i); }});
-
- gamepad_states.forEach(function (state, i) {
- if (state.any_button && pico8_gamepads_mapping[i] == null) {
- var first_free_player = p8_first_player_without_gamepad(max_players);
- p8_assign_gamepad_to_player(i, first_free_player);
- }
- });
-
- gamepad_states.forEach(function (gamepad_state, i) {
- if (pico8_gamepads_mapping[i] != null) {
- pico8_buttons[pico8_gamepads_mapping[i]] = gamepad_state.button_state;
- }
- });
-
-
-
- if (gamepad_states.some(function (state) { return state.menu_button; })) {
- pico8_buttons[0] |= 0x40;
- }
- requestAnimationFrame(p8_update_gamepads);
- }
- requestAnimationFrame(p8_update_gamepads);
-
-
-
- document.addEventListener('keydown',
- function (event) {
- event = event || window.event;
- if (!p8_is_running) return;
- if (pico8_state.has_focus == 1)
- if ([32, 37, 38, 39, 40, 77, 82, 80, 9].indexOf(event.keyCode) > -1)
- if (event.preventDefault) event.preventDefault();
- },{passive: false});
-
- function p8_give_focus()
- {
- el = (typeof codo_textarea === 'undefined') ? document.getElementById("codo_textarea") : codo_textarea;
- if (el)
- {
- el.focus();
- el.select();
- }
- }
- function p8_request_fullscreen() {
- var is_fullscreen=(document.fullscreenElement || document.mozFullScreenElement || document.webkitIsFullScreen || document.msFullscreenElement);
- if (is_fullscreen)
- {
- if (document.exitFullscreen) {
- document.exitFullscreen();
- } else if (document.webkitExitFullscreen) {
- document.webkitExitFullscreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen();
- }
- return;
- }
-
- var el = document.getElementById("p8_playarea");
- if ( el.requestFullscreen ) {
- el.requestFullscreen();
- } else if ( el.mozRequestFullScreen ) {
- el.mozRequestFullScreen();
- } else if ( el.webkitRequestFullScreen ) {
- el.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );
- }
- }
- </script>
- <STYLE TYPE="text/css">
- </STYLE>
- </head>
- <body style="padding:0px; margin:0px; background-color:#222; color:#ccc">
- <div id="body_0">
- <div id="p8_frame_0" style="max-width:800px; max-height:800px; margin:auto;">
- <div id="p8_frame" style="display:flex; width:100%; max-width:95vw; height:100vw; max-height:95vh; margin:auto;">
- <div id="p8_menu_buttons_touch" style="position:absolute; width:100%; z-index:10; left:0px;">
- <div class="p8_menu_button" id="p8b_full" style="float:left;margin-left:10px" onClick="p8_give_focus(); p8_request_fullscreen();"></div>
- <div class="p8_menu_button" id="p8b_sound" style="float:left;margin-left:10px" onClick="p8_give_focus(); p8_create_audio_context(); Module.pico8ToggleSound();"></div>
- <div class="p8_menu_button" id="p8b_close" style="float:right; margin-right:10px" onClick="p8_close_cart();"></div>
- </div>
- <div id="p8_container"
- style="margin:auto; display:table;"
- onclick="p8_create_audio_context(); p8_run_cart();">
- <div id="p8_start_button" class="p8_start_button" style="width:100%; height:100%; display:flex;">
- <img width=80 height=80 style="margin:auto;"
- src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAABpklEQVR42u3au23DQBCEYUXOXIGKcujQXUgFuA0XIKgW90Q9oEAg+Ljd27vd2RsCf058gEDqhofPj+OB6SMCAQlIQAIyAhKQgARkBAQDnM6XSRsB7/2e/tSA0//12fCAKsQX3ntDA4oRFwBRIc0AixE38BAhTQGLEAsBUSDNAXcRhYDRIZsAPlp99VECRoXsDpgN0g0wC6Q7IDpkGEBUyG6A0+vKBtkdMBukG2AWSHdAdMgwgKiQ4QDRIMMCokCGB4wOCQPYFVKw2cABNocUjl6wgE0gFashPKAZpHJ2TQNYBVmxW6cDFENWDv9pAUshCVgJScBKSAISkD9hPkT4GkNAMdzepyj8Kye852EBLe51CZHHWQK4JcThD1SlcHPEYY/0a+A0n6SkGZV6w6WZNb3g4Id1b7hwgGhwYQBR4dwB0eHcALPAdQfMBhcOEA0uDCAqnDsgOpwbYBa4poA/31+rZYFrBriFpwGMCtcEcA9PAhgdzhywBK8EEQXOFFCCtwaIBmcGKMWbI6LCmQBq8R6hw5kAMgISkIAEJCAjIAEJSEBGQI9ukV7lRn9nD+gAAAAASUVORK5CYII="/>
- </div>
- <div id="p8_playarea" style="display:none; margin:auto;
- -webkit-user-select:none; -moz-user-select: none; user-select: none; -webkit-touch-callout:none;
- ">
- <div id="touch_controls_background"
- style=" pointer-events:none; display:none; background-color:#000;
- position:fixed; top:0px; left:0px; border:0; width:100vw; height:100vh">
-  
- </div>
- <div style="display:flex; position:relative">
-
- <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault();" >
- </canvas>
- <div class=p8_menu_buttons id="p8_menu_buttons" style="margin-left:10px;">
- <div class="p8_menu_button" style="position:absolute; bottom:125px" id="p8b_controls" onClick="p8_give_focus(); Module.pico8ToggleControlMenu();"></div>
- <div class="p8_menu_button" style="position:absolute; bottom:90px" id="p8b_pause" onClick="p8_give_focus(); Module.pico8TogglePaused(); p8_update_layout_hash = -22;"></div>
- <div class="p8_menu_button" style="position:absolute; bottom:55px" id="p8b_sound" onClick="p8_give_focus(); p8_create_audio_context(); Module.pico8ToggleSound();"></div>
- <div class="p8_menu_button" style="position:absolute; bottom:20px" id="p8b_full" onClick="p8_give_focus(); p8_request_fullscreen();"></div>
- </div>
- </div>
-
- <div id="touch_controls_gfx"
- style=" pointer-events:none; display:table;
- position:fixed; top:0px; left:0px; border:0; width:100vw; height:100vh">
- <img src="" id="controls_right_panel" style="position:absolute; opacity:0.5;">
- <img src="" id="controls_left_panel" style="position:absolute; opacity:0.5;">
-
-
- </div>
-
-
- <textarea id="codo_textarea" class="emscripten" style="display:none; position:absolute; left:-9999px; height:0px; overflow:hidden"></textarea>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript">
- p8_update_layout();
- p8_update_button_icons();
- var canvas = document.getElementById("canvas");
- Module = {};
- Module.canvas = canvas;
-
-
- if (p8_autoplay)
- {
- var temp_context = new AudioContext();
- temp_context.onstatechange = function ()
- {
- if (temp_context.state=='running')
- {
- p8_run_cart();
- temp_context.close();
- }
- };
- }
-
-
-
- canvas.addEventListener("click", function()
- {
- if (!p8_touch_detected)
- if (pico8_state.request_pointer_lock)
- canvas.requestPointerLock();
- });
-
- </script>
- </div>
- </body></html>
|