mirror of
https://github.com/siemens-mobile-hacks/pmb887x-emu-web.git
synced 2026-11-25 22:27:22 +00:00
page: a square-panel board gets its square screen box from the start
readPanel() needed width and height in [peripheral.LCD0], which many boards leave to qemu's panel model, naming only the type; the screen box then fell back to 132x176. For the 130x130 panels (l2f50250: the SL65 preset, lh15kah2: C65, C72) the box jumped at the first frame, and a later setAspect() stretched the last frame back into 3:4. readPanel() now falls back from the type to its size, a small table mirroring qemu/hw/lcd (lcd.c's 240x320 for the rest), the paint loop remembers the size the guest reported for the run's board, and a device the page applies itself (from the file name or the image) sets the aspect as a hand-picked one does. Review: WEB-12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
67d0864034
commit
fa28de34a8
4 changed files with 33 additions and 5 deletions
|
|
@ -354,7 +354,9 @@ thread is using them).
|
|||
for the network badge's status line and amounts).
|
||||
- The one thing CSS cannot know is the panel's aspect ratio, because that is
|
||||
board data: `setAspect()` publishes it as `--ar` on `.phone-panel` — from
|
||||
the board config, or from the guest's own framebuffer once it is running.
|
||||
the board config (its LCD0 size, or the size of the panel type it names),
|
||||
or from the guest's own framebuffer once it is running, which is then
|
||||
remembered for that board.
|
||||
That is the entire layout contribution of `app.js`.
|
||||
- A board with keys on one side only collapses the empty column
|
||||
(`.aux-keys-*:empty`), and `.phone-panel:has(.aux-keys-* button)` is what
|
||||
|
|
|
|||
|
|
@ -1172,6 +1172,7 @@ function applyDevice(dev) {
|
|||
}
|
||||
syncKeyboardToDevice(dev);
|
||||
refreshSiemensKeys();
|
||||
setAspect(); // a different phone, a different screen ratio
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2898,7 +2899,9 @@ function startPainting() {
|
|||
if (w <= 0 || h <= 0) return;
|
||||
if (canvas.width !== w || canvas.height !== h) {
|
||||
canvas.width = w; canvas.height = h;
|
||||
setAspect(); // the guest's panel ratio is the real one
|
||||
// the guest's panel ratio is the real one, for this board's later boots too
|
||||
if (ranDevice) panelCache.set(ranDevice, { w, h });
|
||||
setAspect();
|
||||
}
|
||||
const tPaint = performance.now();
|
||||
if (img?.width !== w || img.height !== h) {
|
||||
|
|
|
|||
|
|
@ -55,16 +55,28 @@ function paxPath(data) {
|
|||
|
||||
export const boardText = new Map(); // "siemens-s75.toml" -> file contents
|
||||
|
||||
// `[peripheral.LCD0] width/height` of the board or an include it `extends`
|
||||
// The size qemu's panel model (qemu/hw/lcd) gives a config that names only
|
||||
// the type; any other model takes lcd.c's default.
|
||||
const PANEL_SIZES = {
|
||||
l2f50250: [130, 130], lh15kah2: [130, 130], pcf8882: [132, 176], ssd1286: [132, 176],
|
||||
};
|
||||
const PANEL_DEFAULT = [240, 320];
|
||||
|
||||
// `[peripheral.LCD0] width/height` of the board or an include it `extends`,
|
||||
// else the size of the panel `type` it names
|
||||
export function readPanel(file) {
|
||||
let type = null;
|
||||
for (const [, txt] of boardChain(file)) {
|
||||
const sec = txt.match(/\[peripheral\.LCD0\]([\s\S]*?)(?=\n\[|$)/);
|
||||
if (!sec) continue;
|
||||
const w = sec[1].match(/^[ \t]*width[ \t]*=[ \t]*(\d+)/m);
|
||||
const h = sec[1].match(/^[ \t]*height[ \t]*=[ \t]*(\d+)/m);
|
||||
if (w && h) return { w: +w[1], h: +h[1] };
|
||||
type ??= sec[1].match(/^[ \t]*type[ \t]*=[ \t]*"([^"]+)"/m)?.[1] ?? null;
|
||||
}
|
||||
return null;
|
||||
if (!type) return null;
|
||||
const [w, h] = PANEL_SIZES[type] ?? PANEL_DEFAULT;
|
||||
return { w, h };
|
||||
}
|
||||
|
||||
// The same configs carry the device's real name in `[board] vendor/model`,
|
||||
|
|
|
|||
|
|
@ -121,11 +121,22 @@ test("boardHasDisplay: an LCD0 panel anywhere in the chain, with or without a si
|
|||
"chip.toml": '[board]\ncpu.type = "pmb8876"\n[peripheral.GIMMICK]\ntype = "s1d13732"\n# [peripheral.LCD0]\n',
|
||||
});
|
||||
assert.equal(boardHasDisplay("phone"), true);
|
||||
assert.equal(readPanel("phone.toml"), null);
|
||||
assert.equal(boardHasDisplay("chip"), false);
|
||||
assert.equal(boardHasDisplay("missing"), false);
|
||||
});
|
||||
|
||||
test("readPanel: a panel named by type alone has its model's size", () => {
|
||||
load({
|
||||
"s75.toml": 'extends = "include/sg2.toml"\n[board]\nmodel = "S75"\n',
|
||||
"include/sg2.toml": '[peripheral.LCD0]\ntype = "ssd1286"\nbus = "DIF"\n',
|
||||
"sl65.toml": 'extends = "include/sg2.toml"\n[peripheral.LCD0]\ntype = "l2f50250"\n',
|
||||
"big.toml": '[peripheral.LCD0]\ntype = "jbt6k71"\n',
|
||||
});
|
||||
assert.deepEqual(readPanel("s75.toml"), { w: 132, h: 176 });
|
||||
assert.deepEqual(readPanel("sl65.toml"), { w: 130, h: 130 }, "the board's own type before the include's");
|
||||
assert.deepEqual(readPanel("big.toml"), { w: 240, h: 320 }, "lcd.c's default");
|
||||
});
|
||||
|
||||
test("boardHasSimSlot: a slot in the board or an include, not in a comment", () => {
|
||||
load({
|
||||
"phone.toml": 'extends = "include/sg2.toml"\n[board]\nmodel = "S75"\n',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue