segatools/dist/ekt/card_player.html
kyoubate-haruka 9c67f53902 Add support for Sangokushi Taisen and Eiketsu Taisen (#85)
This adds full support for the Taisen series of games, namely Sangokushi Taisen and Eiketsu Taisen.

Games added:
* Sangokushi Taisen (SDDD)
* Eiketsu Taisen (SDGY)

Devices added:
* CHC-320 printer (SGT)
* "Printer camera" (SGT, unsure what this actually really is)
* CX-7000 printer (EKT)
* Y3CR BD SIE F720MM (SGT, EKT)

Notable changes in the codebase:

* Renamed everything printer specific to seperate between CHC and CX.
* Many new function and registry hooks were added across the board.
* An error is now logged when segatools.ini (or the path in `SEGATOOLS_CONFIG_PATH`) cannot be found.
* Netenv now redirects UDP broadcasts targeted at the subnet that is specified in the keychip configuration. The terminal announces it's presence by broadcasting UDP to 192.168.189.255, this will be redirected to 255.255.255.255.
* Vfs now seperates between absolute and relative paths in `vfs_fixup_path` via an environment variable called `SEGATOOLS_VFS_RELATIVE_PATH`. This is needed because amcapture accesses files as workingdirectory-relative.
* The Y3 board emulation has support for external Y3 I/O dlls. The default implementation (y3ws) that comes with this is a websocket implementation. The docs are available under `doc\y3ws.txt` and a sample card player .html file is under `dist\ekt\card_player.html`. I already know one person that is hosting a massively improved version of it.
  * For websockets, my own websocket implementation is used as a subproject (MIT license): https://github.com/akechi-haruka/cwinwebsocket
  * For JSON, cJSON was embedded (MIT license): https://github.com/DaveGamble/cJSON
  * y3ws reads all printed cards from `DEVICE\print` by default including card back sides. It's up to the client to merge or skip them.

Remarks:
* SGT takes ~8 minutes to load. This seems to be intentional.
* SGT uses some weird TCP network implementation like IDZ. I have not bothered reversing that yet and I have confirmed everything working from the test menu.
* EKT will throw a network error if no terminal is found. You must run the terminal on another computer to be able to launch the satellite.
* EKT has a very bizzare speed glitch that will speed up the ingame unit movement by several 1000% and also slows down cutscene animations by 90%. When this effect is active, you also take a ton more damage than usual. I do not know what causes this and it seems PC specific.
* EKT is very stutter sensitive and will throw error 6401 (I/O timeout) at random when trying to alt+tab or have other things running.
* EKT features a livestream system called Enbu (or "Dojo Upload"). While you are in a match, regardless of vs. AI or another player, the game will record your screen and live-stream it to the Enbu server as defined by the game server's startup response. The application responsible for that, "AM Capture" will not limit it's recording to the game window, but also anything that overlays the game window (notifications, popups, alt+tabbed windows, web browsers, etc). Since this is live-streamed, killing the process will have no effect afterwards, as the frames showing unwanted things will already have been transmitted. To make people aware of this, a one-time dialog message will pop up when starting EKT. The flag for that is stored in the DEVICE folder.

Closes #25.

Co-authored-by: Dniel97 <Dniel97@noreply.gitea.tendokyu.moe>
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/85
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-02-26 19:31:45 +00:00

224 lines
5.9 KiB
HTML

<!-- very basic thing, I can't do UX/CSS/design, don't blame me, I'm a network engineer lmao -->
<!DOCTYPE html>
<html>
<head>
<title>Taisen Card Field</title>
</head>
<style>
html, body {
width: 99%;
height: 99%;
}
.playfield {
width: 79%;
height: 100%;
float: left;
border: 1px solid black;
}
.card_menu {
width: 20%;
height: 100%;
border: 1px solid black;
overflow-x: hidden;
overflow-y: scroll;
}
.card {
width: 200px;
transform: rotate(-90deg);
}
#playfield .card {
position: absolute;
}
#status {
margin-bottom: 50px;
}
</style>
<script>
var VERSION = 1;
var socket;
var state = 0;
var game_id;
var cards = [];
var current_card_fetch = 0;
function send(obj){
if (!socket){ return; }
var data = JSON.stringify(obj);
console.log("Sending: " + data);
socket.send(data);
}
function connect(){
socket = new WebSocket("ws://127.0.0.1:3594/y3io");
socket.onopen = function(e) {
document.getElementById("status").innerText = "Connected. Loading information...";
state = 0;
send({
version: VERSION,
command: "get_game_id"
});
};
socket.onmessage = function(event) {
console.log("Received: " + event.data);
handle_response(JSON.parse(event.data));
};
socket.onclose = function(event) {
state = -1;
document.getElementById("status").innerHTML = "Disconnected. <a href='javascript:window.location.reload();'>Reconnect</a>";
};
socket.onerror = function(error) {
console.log(error);
};
}
function handle_response(obj){
if (!obj.success){
alert("Error receiving data while in state " + state + ": " + obj.error);
socket.close();
return;
}
if (state == 0){
game_id = obj.game_id;
document.getElementById("status").innerText = "Connected to "+game_id+". Loading cards...";
state = 1;
send({
version: VERSION,
command: "get_cards"
});
} else if (state == 1){
cards = obj.cards;
document.getElementById("status").innerText = "Connected to "+game_id+". Loading card images...";
document.getElementById("cards").innerHTML = "";
document.getElementById("playfield").innerHTML = "";
current_card_fetch = 0;
state = 2;
if (cards.length > 0){
fetch_next_card();
} else {
document.getElementById("status").innerText = "Connected to "+game_id+". No cards available.";
}
} else if (state == 2){
cards[current_card_fetch].image = obj.data;
document.getElementById("cards").innerHTML += "<img class='card' src='data:image/bmp;base64, "+obj.data+"' onclick='spawn_card("+current_card_fetch+");' />";
if (++current_card_fetch >= cards.length){
document.getElementById("status").innerText = "Connected to "+game_id+".";
state = 3;
} else {
fetch_next_card();
}
}
}
function fetch_next_card(){
var p = cards[current_card_fetch].path;
if (!p.includes("_front")){
current_card_fetch++;
fetch_next_card();
return;
}
send({
version: VERSION,
command: "get_card_image",
path: p
});
}
function spawn_card(i){
if (state != 3){
return;
}
document.getElementById("playfield").innerHTML += "<img class='card' src='data:image/bmp;base64, "+cards[i].image+"' onmousedown='startMoving(event, this, "+i+");' />";
}
function update_pos(i, x, y){
if (state != 3){
return;
}
var panelHeight = 1272;
var panelWidth = 1260;
cards[i].x = panelHeight - ((y / window.screen.height) * panelHeight);
cards[i].y = panelWidth - ((x / window.screen.width) * panelWidth);
cards[i].rotation = 0;
var list = [];
for (var j = 0; j < cards.length; j++){
var c = cards[j];
if (c.x && c.y){
list.push({
card_id: c.card_id,
x: c.x,
y: c.y,
rotation: c.rotation
});
}
}
send({
version: VERSION,
command: "set_field",
cards: list
});
}
</script>
<script>
var mousePosition;
var offset = [-75,-75];
var div;
var current_card = -1;
var isDown = false;
function startMoving(e, el, card){
div = el;
isDown = true;
current_card = card;
offset = [
div.offsetLeft - e.clientX,
div.offsetTop - e.clientY
];
}
document.addEventListener('mouseup', function() {
isDown = false;
current_card = -1;
}, true);
document.addEventListener('mousemove', function(event) {
event.preventDefault();
if (isDown) {
mousePosition = {
x : event.clientX,
y : event.clientY
};
div.style.left = (mousePosition.x + offset[0]) + 'px';
div.style.top = (mousePosition.y + offset[1]) + 'px';
update_pos(current_card, event.clientX, event.clientY);
}
}, true);
</script>
<body onload="connect();">
<div id="playfield" class="playfield">
</div>
<div class="card_menu">
<div id="status">Please wait...</div>
<div id="cards">
</div>
</div>
</body>
</html>