Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to WittyMediaServer. Versions follow [semantic versioning](h

## Unreleased

- **Choosing a core is one picker.** On a game's page, **Change core** beside the core that plays it; in **Settings → Consoles & cores**, **Change core** on each console. Each core says what it's good at (accuracy, speed or a balance of the two), where it runs and how it draws on your server, whether it needs a BIOS file of your own and whether it's installed. Choosing one that isn't installed installs it, with its progress, then uses it. It works on a phone, with a mouse, and with a TV remote or controller, and closes with ×, Escape, B or Back, or a tap outside. A game's own core is set the same way, or left to its console's. During a game, the player can open the same picker (`chooseCore`), which offers to restart on the new core: in-game saves stay, and save states stay with the core that made them.
- **Nine more cores to choose from**, each offered only where a build is published: QuickNES for NES; today's bsnes for Super Nintendo; Gearboy for Game Boy; VBA-M and gpSP for Game Boy Advance; Beetle PCE and Beetle SuperGrafx for PC Engine; Beetle Lynx for Lynx (which needs your own `lynxboot.img`); and RACE for Neo Geo Pocket. They come with the next WittyPlay. bsnes played 16 retail Super Nintendo games here, special chips included, with no firmware files.
- **For apps:** `GET /gaming/consoles/{console}/core` and `GET /gaming/games/{id}/core` give the picker's `choices`, and `GET /gaming/cores/{id}/install` how far an install has got. `GET /games/consoles` gives each core's `coreAbout`. See [Choosing a core](docs/GAMING-API.md#choosing-a-core).

- **WittyTV keeps playing in the background.** Switching to another tab or minimising the window no longer stops a channel: the guide's preview carries on with its sound, and a player that goes quiet in the background tells the server it's still there, so the channel isn't stopped behind it. **Keep playing when this tab is in the background**, in WittyTV's look and in the player's settings, turns it off for one device; then a channel stops when you switch away, freeing a tuner, and starts again when you come back. Administrators choose what new devices start with under **Options**. Apps get the same default as `backgroundPlay` in the guide and tune answers.
- **On a Mac whose WittyPlay can use the graphics card, PlayStation 2 plays on Play!, on the card.** LRPS2 comes first for PlayStation 2, but can't use a Mac's card, so it would still have drawn on the processor, which can't keep a Gran Turismo 4 race at full speed. A game Play! can't open still goes on to LRPS2, and someone who chose LRPS2 keeps it.
- **Comics whose pages are PNGs called .jpg get their cover.** Several public-domain comics name their PNG pages `000.jpg`, and the server's picture tool chose how to read a picture by its name, so their covers failed during scans ("bits 193 is invalid", "unsupported coding type") and the comics had none. It now reads what a picture really is from its first bytes, for every book and comic cover.
Expand Down
4 changes: 3 additions & 1 deletion docs/CLIENT-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ See [LIBRARY-TRANSCODING.md](LIBRARY-TRANSCODING.md).
| `GET /play/{sid}/screenshot` | user | The current picture as a PNG. |
| `GET /gaming` | admin | Gaming. |
| `POST /gaming/cores/{id}/install` | admin | Core install. |
| `GET /gaming/cores/{id}/install` | admin | How far an install under way has got: `{installing, received, total}` in bytes, `total` 0 when the download server gave no size. An older WittyPlay always answers `installing: false`. |
| `DELETE /gaming/cores/{id}` | admin | Core remove. |
| `DELETE /gaming/unpacked` | admin | Empty the unpacked games cache. |
| `GET /gaming/custom` | admin | Custom cores and consoles: whether they're on, what's here, the cores folder and the audit log. |
Expand All @@ -1808,8 +1809,9 @@ See [LIBRARY-TRANSCODING.md](LIBRARY-TRANSCODING.md).
| `POST /gaming/custom/consoles` | admin | Add a custom console. |
| `PUT /gaming/custom/consoles/{id}` | admin | Change a custom console. |
| `DELETE /gaming/custom/consoles/{id}` | admin | Remove a custom console. |
| `GET /gaming/consoles/{console}/core` | admin | A console's cores for the core picker, installed or not, and its default: see [Choosing a core](GAMING-API.md#choosing-a-core). |
| `PUT /gaming/consoles/{console}/core` | admin | Choose a console's core. |
| `GET /gaming/games/{id}/core` | admin | What plays a game, and how each core has gone on it. |
| `GET /gaming/games/{id}/core` | admin | What plays a game, and how each core has gone on it: the picker's `choices`, and `options`, the installed ones, for older clients. |
| `PUT /gaming/games/{id}/core` | admin | Choose a core for one game. |
| `GET /reach/{nonce}` | none | Reach. |
| `DELETE /users/{id}/2fa` | admin | User two factor reset. |
Expand Down
30 changes: 26 additions & 4 deletions docs/GAMES.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ The core downloads from buildbot.libretro.com, the libretro project's build serv

Cores on this list that are already in a RetroArch folder on the same machine are found and used.

If a game won't load on the chosen core, the other installed cores for that console are tried. To change a console's core, use the choice on its card. Administrators can pick a core for one game on that game's page, which also shows how each core has gone on it.
If a game won't load on the chosen core, the other installed cores for that console are tried.

**Choosing another core.** Press **Change core** on a console's card, or beside the core on a game's page to change it for that game alone. Each core says what it's good at (accuracy, speed or a balance of the two), how it draws on your server and where else it runs, whether it needs a BIOS file of your own, and whether it's installed. Choose one that isn't, read its license, and press **Install and use**: it downloads, with its progress, and plays from the next start. On a game's page the picker also shows how each core has gone on that game. Your in-game saves stay whichever core plays a game, but a save state only loads in the core that made it, so states from another core wait until you switch back.

| Console | First choice | Needs a graphics card | BIOS file |
|---|---|---|---|
Expand All @@ -151,7 +153,27 @@ If a game won't load on the chosen core, the other installed cores for that cons
| Dreamcast | Flycast | Yes | Optional |
| Nintendo 3DS | Azahar | Yes | No |

Each card lists the other cores offered, with their licenses. Non-commercial cores are never offered.
Each card lists the other cores offered, with their licenses:

| Console | Other cores |
|---|---|
| NES, Famicom | Nestopia UE, Mesen, QuickNES |
| Super Nintendo | bsnes 2014 Performance, Mesen-S, bsnes |
| Game Boy, Color | SameBoy, mGBA, Gearboy |
| Game Boy Advance | VBA Next, VBA-M, gpSP |
| Mega Drive, Genesis | ClownMDEmu |
| Master System, Game Gear | SMS Plus GX |
| PlayStation | Beetle PSX, SwanStation, Beetle PSX HW (the last three need a BIOS file) |
| PC Engine | Beetle PCE, Beetle SuperGrafx |
| Atari 2600 | Stella |
| Lynx | Beetle Lynx (needs `lynxboot.img`) |
| Neo Geo Pocket | RACE |
| Nintendo DS | DeSmuME |
| Nintendo 64 | ParaLLEl N64 |
| PlayStation 2 | Play! |
| Nintendo 3DS | Panda3DS |

Non-commercial cores, such as Snes9x, Genesis Plus GX and PicoDrive, are never offered.

Each core also says which server platforms it runs on, and how it draws on yours: on a graphics card, by the processor, or not at all. A core that isn't published for your server's platform isn't offered to install: Beetle Supafaust, for example, has no build for macOS, so a Mac server suggests bsnes 2014 Performance for Super Nintendo instead. Every device plays whatever your server can run, since the server runs the game and streams it.

Expand Down Expand Up @@ -185,13 +207,13 @@ You can also put files straight in the BIOS folder named on that page. A PlaySta
| Console | File names | Used for |
|---|---|---|
| PlayStation 2 | `scph39001.bin`, or any other model's BIOS image | LRPS2 needs one, and any region will do. With a whole set, a game starts on one from its own region, or a late first-generation US model |
| PlayStation | `scph5501.bin`, `scph5500.bin`, `scph5502.bin` | US, Japanese and European consoles. PCSX ReARMed runs most games without one |
| PlayStation | `scph5501.bin`, `scph5500.bin`, `scph5502.bin` | US, Japanese and European consoles. PCSX ReARMed runs most games without one; Beetle PSX and SwanStation need one |
| NES | `disksys.rom` | Famicom Disk System games |
| Super Nintendo | `BS-X.bin` | Satellaview games in `.bs` files, on Mesen-S |
| Game Boy Advance | `gba_bios.bin` | Better accuracy |
| PC Engine | `syscard3.pce` | CD games |
| Atari 7800 | `7800 BIOS (U).rom` | The start-up screen |
| Lynx | `lynxboot.img` | Most games |
| Lynx | `lynxboot.img` | Most games on Handy; Beetle Lynx needs it |
| Nintendo DS | `bios7.bin`, `bios9.bin`, `firmware.bin` | Accuracy, and the start-up menu, on melonDS |
| Dreamcast | `dc/dc_boot.bin`, `dc/dc_flash.bin` | Better compatibility, and the console's settings |

Expand Down
38 changes: 38 additions & 0 deletions docs/GAMING-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,44 @@ with no build for this server answers 409 `{error, noBuild: true, platform, alte
`macos/arm64` and `alternative` is `{id, name, console}`: a core that plays the same console here. If the download
server answers 404 anyway, the answer is 502 with the same fields.

### Choosing a core

What a core picker needs, for an administrator: a console's default (`GET /gaming/consoles/{console}/core`) or one
game's own core (`GET /gaming/games/{id}/core`). Both answer:

| Field | Meaning |
|---|---|
| `console` | The console's id |
| `choice` | The core chosen at this level (the game's own, or the console's default), or `""` for none |
| `consoleDefault` | For a game: its console's default, or none |
| `effective` | The core that plays now, once a missing BIOS or graphics card is taken into account; `""` when none would |
| `canDownload` | This server's platform has prebuilt cores to install |
| `choices` | Every core that can play the console, in the server's order of preference, then the administrator's own |

Each choice is `{id, name, license, installed, source, canInstall, recommended, strength, about, support, bios}`:

| Field | Meaning |
|---|---|
| `installed`, `source` | It's on this server, and from where: `installed`, `retroarch`, `system` or `custom` |
| `canInstall` | It isn't installed, and installing it here would work: published for this platform, able to draw here, and this platform has downloads |
| `recommended` | The one this server would pick: the first published for this platform that can draw here |
| `strength` | What it's chosen for beside the console's other cores: `accuracy`, `speed` or `balanced`. None for a console's only core, or a custom one |
| `about` | One line on what it's good at, such as "The most accurate, and plays every game. Uses more of the processor." |
| `support` | `{here, platforms}`, as `coreSupport` above |
| `bios` | When it won't start without a BIOS file of the owner's own: `{files, found}`, any one of `files` |
| `starts`, `failures`, `seconds`, `lastError`, `best` | For a game: how it has gone on that game |

`GET /games/consoles` gives the same `strength` and `about` for each core as `coreAbout`, for anyone.

To choose a core that isn't installed: `POST /gaming/cores/{id}/install`, then the `PUT` beside the `GET` with
`{core}`, which only takes an installed core. While the install runs, `GET /gaming/cores/{id}/install` answers
`{installing, received, total}` in bytes (`total` 0 when the download server gave no size; a core with support files,
such as PPSSPP, counts again from 0 for those). The website asks about four times a second. An older WittyPlay module
always answers `installing: false`; show the install as under way without a size.

A save state is made by one core and only loads in that core; in-game saves (battery saves and memory cards) stay with
the game. `GET /games/{id}/saves` says which core made each state (`core`, its name).

**A game in an archive** has to be unpacked before it starts, which can take minutes for a large disc on a small server.
`POST /games/{id}/play` takes that long, which is fine as long as your HTTP client's timeout allows it. To show
progress, call `POST /games/{id}/prepare` about once a second until `state` is `ready`, and then call play:
Expand Down
2 changes: 2 additions & 0 deletions docs/SECURITY-ROUTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ Every `/api/...` route is also served as `/api/v1/...`. `HEAD` is served whereve
| `PUT /api/game-background/image` | Signed-in | own. PNG, JPEG or WebP of at most 10 MB and 24 megapixels, drawn again as a new JPEG |
| `GET /api/gaming` | Admin | Nothing further |
| `POST /api/gaming/cores/{id}/install` | Admin | Core id format. Offered by this server |
| `GET /api/gaming/cores/{id}/install` | Admin | Core id format. Reads only how far its download has got |
| `DELETE /api/gaming/cores/{id}` | Admin | Core id format. Installed by this server |
| `DELETE /api/gaming/unpacked` | Admin | Nothing further |
| `GET /api/games/settings/schema` | Signed-in | Nothing: fixed description |
Expand Down Expand Up @@ -533,6 +534,7 @@ Every `/api/...` route is also served as `/api/v1/...`. `HEAD` is served whereve
| `POST /api/gaming/custom/consoles` | Admin | Custom cores on. Console JSON size and fields |
| `PUT /api/gaming/custom/consoles/{id}` | Admin | Custom cores on. Console JSON size and fields |
| `DELETE /api/gaming/custom/consoles/{id}` | Admin | No library is set to it |
| `GET /api/gaming/consoles/{console}/core` | Admin | Known console |
| `PUT /api/gaming/consoles/{console}/core` | Admin | Known console. Core allowed for it |
| `GET /api/gaming/games/{id}/core` | Admin | A game |
| `PUT /api/gaming/games/{id}/core` | Admin | A game. Core allowed for it |
Expand Down
76 changes: 76 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -17546,6 +17546,44 @@
}
},
"/gaming/consoles/{console}/core": {
"get": {
"operationId": "getGamingConsolesConsoleCore",
"parameters": [
{
"in": "path",
"name": "console",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
},
"description": "choice, effective, canDownload and choices: see GAMING-API.md, Choosing a core."
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"security": [
{
"bearer": []
}
],
"summary": "A console's cores for the core picker, installed or not, and its default.",
"tags": [
"Games"
],
"x-wms-auth": "admin"
},
"put": {
"operationId": "putGamingConsolesConsoleCore",
"parameters": [
Expand Down Expand Up @@ -17639,6 +17677,44 @@
}
},
"/gaming/cores/{id}/install": {
"get": {
"operationId": "getGamingCoresIdInstall",
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
},
"description": "installing, received and total, in bytes."
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"security": [
{
"bearer": []
}
],
"summary": "How far an install under way has got.",
"tags": [
"Server"
],
"x-wms-auth": "admin"
},
"post": {
"operationId": "postGamingCoresIdInstall",
"parameters": [
Expand Down
12 changes: 12 additions & 0 deletions internal/play/cores/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion internal/server/api_games.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (s *Server) gameRoutes(m routes) {
s.gameProfileRoutes(m)
m.Handle("GET /api/gaming", s.requireAdmin(s.handleGaming))
m.Handle("POST /api/gaming/cores/{id}/install", s.requireAdmin(s.handleCoreInstall))
m.Handle("GET /api/gaming/cores/{id}/install", s.requireAdmin(s.handleCoreInstallProgress))
m.Handle("DELETE /api/gaming/cores/{id}", s.requireAdmin(s.handleCoreRemove))
m.Handle("DELETE /api/gaming/unpacked", s.requireAdmin(s.handleUnpackedClear))
s.gameOptionRoutes(m)
Expand Down Expand Up @@ -333,7 +334,10 @@ type consoleView struct {
// CoreSupport is, for each core on offer, the server platforms it runs on and how it draws
// on each, and here. Every device plays what any of them runs: the server streams it.
CoreSupport map[string]coreSupport `json:"coreSupport,omitempty"`
Pad wittyplay.PadLayout `json:"pad"`
// CoreAbout is, for each core on offer, what it's good at beside the console's others
// (core_notes.go).
CoreAbout map[string]coreNote `json:"coreAbout,omitempty"`
Pad wittyplay.PadLayout `json:"pad"`
// Count: with ?library=<id>, how many games that library holds for this console.
Count int `json:"count,omitempty"`
// Era, years, how its games come and what it can do (game_traits.go).
Expand Down Expand Up @@ -391,6 +395,12 @@ func (s *Server) consoleViews(ctx context.Context) []consoleView {
noGPU = *gpuWhy
}
v.CoreSupport[want.ID] = coreSupportFor(want.ID, gpuCore, noGPU)
if n := coreNoteFor(want.ID); n != nil {
if v.CoreAbout == nil {
v.CoreAbout = map[string]coreNote{}
}
v.CoreAbout[want.ID] = *n
}
}
v.NeedsGPU = len(c.Cores) > 0 && len(v.GPUCores) == len(c.Cores)
for _, got := range all {
Expand Down
Loading
Loading