lucky / index 5.html
Studytime171's picture
Duplicate from Studytime171/Lalitgangwani
89610f7
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>GBA Mobile - Max Controls</title>
<link rel="stylesheet" href="resources/main.css">
<style>
/* Prevent all scrolling and browser gestures */
body, html {
overflow: hidden;
position: fixed;
width: 100%;
height: 100%;
background: #000;
margin: 0;
padding: 0;
user-select: none;
-webkit-user-select: none;
}
#screen {
display: block;
margin: 0 auto;
max-width: 100%;
height: auto;
background-color: #000;
image-rendering: pixelated;
}
/* CONTROL OVERLAY - Sits on top of everything */
#touch-controls {
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
z-index: 999999;
pointer-events: none; /* Allows clicks to pass through empty space */
}
.t-btn {
position: absolute;
background: rgba(255, 255, 255, 0.15);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-family: sans-serif;
pointer-events: auto; /* Buttons catch touches */
touch-action: none;
}
.t-btn:active { background: rgba(255, 0, 0, 0.5); }
/* D-PAD (Joystick Style) */
.dpad { width: 60px; height: 60px; border-radius: 10px; }
#t-up { bottom: 160px; left: 70px; }
#t-down { bottom: 40px; left: 70px; }
#t-left { bottom: 100px; left: 10px; }
#t-right { bottom: 100px; left: 130px; }
/* ACTION BUTTONS */
.action { width: 80px; height: 80px; border-radius: 50%; font-size: 24px; }
#t-a { bottom: 110px; right: 20px; background: rgba(255, 0, 0, 0.3); }
#t-b { bottom: 60px; right: 110px; background: rgba(255, 255, 0, 0.3); }
/* SHOULDER BUTTONS */
.shoulder { width: 100px; height: 45px; border-radius: 5px; top: 10px; }
#t-l { left: 10px; }
#t-r { right: 10px; }
/* MULTIPLE START BUTTONS (Redundancy) */
.menu-btn { width: 70px; height: 35px; border-radius: 5px; font-size: 11px; background: rgba(0, 255, 0, 0.2); }
#t-select { bottom: 20px; left: 50%; margin-left: -80px; }
#t-start-1 { bottom: 20px; left: 50%; margin-left: 10px; } /* Center Bottom */
#t-start-2 { bottom: 200px; right: 20px; } /* Near A Button */
#t-start-3 { bottom: 200px; left: 20px; } /* Near D-Pad */
#controls { color: white; text-align: center; padding-top: 10px; }
.hidden { display: none; }
</style>
<script src="js/util.js"></script>
<script src="js/core.js"></script>
<script src="js/arm.js"></script>
<script src="js/thumb.js"></script>
<script src="js/mmu.js"></script>
<script src="js/io.js"></script>
<script src="js/audio.js"></script>
<script src="js/video.js"></script>
<script src="js/video/proxy.js"></script>
<script src="js/video/software.js"></script>
<script src="js/irq.js"></script>
<script src="js/keypad.js"></script>
<script src="js/sio.js"></script>
<script src="js/savedata.js"></script>
<script src="js/gpio.js"></script>
<script src="js/gba.js"></script>
<script src="resources/xhr.js"></script>
<script>
var gba;
try {
gba = new GameBoyAdvance();
gba.keypad.eatInput = true;
} catch (exception) {
gba = null;
}
window.onload = function() {
if (gba) {
var canvas = document.getElementById('screen');
gba.setCanvas(canvas);
loadRom('resources/bios.bin', function(bios) {
gba.setBios(bios);
});
initTouchGamepad();
}
}
function initTouchGamepad() {
// Mapping to keypad.js indices: A=0, B=1, SELECT=2, START=3, RIGHT=4, LEFT=5, UP=6, DOWN=7, R=8, L=9
const map = {
't-a': 0, 't-b': 1, 't-select': 2,
't-start-1': 3, 't-start-2': 3, 't-start-3': 3, // All three trigger START
't-right': 4, 't-left': 5, 't-up': 6, 't-down': 7,
't-r': 8, 't-l': 9
};
Object.keys(map).forEach(id => {
const el = document.getElementById(id);
if (!el) return;
const keyCode = map[id];
const press = (e) => {
e.preventDefault();
// Critical for iOS/Android Sound
if (gba.audio.context && gba.audio.context.state === 'suspended') {
gba.audio.context.resume();
}
gba.keypad.keydown(keyCode);
};
const release = (e) => {
e.preventDefault();
gba.keypad.keyup(keyCode);
};
el.addEventListener('touchstart', press, {passive: false});
el.addEventListener('touchend', release, {passive: false});
});
}
function run(file) {
gba.loadRomFromFile(file, function(result) {
if (result) {
document.getElementById('preload').style.display = 'none';
document.getElementById('ingame').classList.remove('hidden');
gba.runStable();
}
});
}
</script>
</head>
<body>
<canvas id="screen" width="480" height="320"></canvas>
<div id="touch-controls">
<div class="t-btn dpad" id="t-up"></div>
<div class="t-btn dpad" id="t-down"></div>
<div class="t-btn dpad" id="t-left"></div>
<div class="t-btn dpad" id="t-right"></div>
<div class="t-btn action" id="t-a">A</div>
<div class="t-btn action" id="t-b">B</div>
<div class="t-btn shoulder" id="t-l">L</div>
<div class="t-btn shoulder" id="t-r">R</div>
<div class="t-btn menu-btn" id="t-select">SELECT</div>
<div class="t-btn menu-btn" id="t-start-1">START 1</div>
<div class="t-btn menu-btn" id="t-start-2">START 2</div>
<div class="t-btn menu-btn" id="t-start-3">START 3</div>
</div>
<section id="controls">
<div id="preload">
<button class="bigbutton" onclick="document.getElementById('loader').click()">SELECT ROM</button>
<input id="loader" type="file" accept=".gba" onchange="run(this.files[0]);" style="display:none;">
</div>
</section>
</body>
</html>