c2527a0a66
Context:
The Freenove plays a screen+buttons "livre dont vous etes le heros".
The PLIP retro phone has no screen, so we want a phone-native version:
an audio choose-your-own-adventure where the narrator reads the passage
and its numbered choices, and the player dials a digit to choose.
Approach:
A self-contained plip_gamebook module reads a phone audio pack from the
SD (narration WAVs already include the spoken "faites le N" prompts),
plays passages through the earpiece, and maps each dialed digit to a
choice. It hooks into the existing conversation state machine and the
existing dialer (rotary/DTMF) — fully offline, no model, no network.
Changes:
- New plip_gamebook.c/.h: loads /sdcard/gamebook/{library.json,
menu.wav, <id>.json, <id>_<passage>.wav}; pickup plays the story
menu, digit picks a story, then each passage plays its WAV and a
dialed digit jumps to that choice; an ending + any digit returns to
the menu. Interrupts narration so a dial is instant.
- conversation.c: new STATE_GAMEBOOK; off-hook from idle launches the
gamebook when a pack is on the SD (else the normal dialtone/NPC flow,
so the phone still works without a pack); each dialed digit is fed to
the gamebook; go_idle() tears it down on hang-up.
- CMakeLists: build plip_gamebook.c.
Impact:
With a phone pack staged on its SD, the PLIP becomes an audio gamebook:
pick up, dial to choose your story and your path, hang up to stop.
Non-breaking when no pack is present. Builds clean.
45 lines
1.7 KiB
C
45 lines
1.7 KiB
C
#pragma once
|
|
// plip_gamebook — "livre dont vous êtes le héros" AUDIO pour le téléphone PLIP.
|
|
//
|
|
// Pas d'écran : tout passe par l'écouteur. On décroche, le narrateur lit le
|
|
// menu des histoires ("pour le dragon, faites le 1..."), on compose un chiffre
|
|
// au cadran pour choisir une histoire, puis à chaque passage le narrateur lit
|
|
// le texte ET les choix numérotés ("pour examiner la machine, faites le 1..."),
|
|
// et on compose le chiffre du choix. Raccrocher arrête tout.
|
|
//
|
|
// Lit /sdcard/gamebook/{library.json, menu.wav, <id>.json, <id>_<passage>.wav}
|
|
// (pack audio "téléphone" produit par tools/gamebook/build_phone_gamebook.py,
|
|
// où la narration des WAV inclut déjà les invites "faites le N"). 100% local,
|
|
// aucun modèle, aucun réseau.
|
|
//
|
|
// Intégration : conversation.c lance plip_gamebook_begin() au décroché (si un
|
|
// pack est présent sur la SD), pousse chaque chiffre composé via
|
|
// plip_gamebook_feed_digit(), et appelle plip_gamebook_end() au raccroché.
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// La SD est-elle montée et un pack gamebook présent ? (à tester au décroché)
|
|
bool plip_gamebook_available(void);
|
|
|
|
// Démarre le mode livre-jeu : charge la bibliothèque et joue le menu audio.
|
|
void plip_gamebook_begin(void);
|
|
|
|
// Traite un chiffre composé (0..9). Menu → choisit l'histoire ; en histoire →
|
|
// choisit la réponse ; sur une fin → 0 revient au menu. Interrompt la
|
|
// narration en cours pour enchaîner.
|
|
void plip_gamebook_feed_digit(int digit);
|
|
|
|
// Quitte le mode livre-jeu (raccroché) : stoppe l'audio, libère la mémoire.
|
|
void plip_gamebook_end(void);
|
|
|
|
// Vrai tant qu'une partie est en cours.
|
|
bool plip_gamebook_active(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|