Library — classic
SkillDev toolsz88dk classic library world: libsrc/target and classic trees, multi-CPU (8080/8085/gbz80/…), fgets_cons line input, hybrid CRT traps, isolation from newlib. Use when working on classic clib, 8085 products, or hybrid consoles.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Library — classic skill
What this skill tells your AI
The instructions your AI receives, as published by z88dk/z88dk in .agents/skills/library-classic/SKILL.md and read by ahel’s review.
1. Two library worlds (do not blur)
| World | Home | CPUs | Typical product |
|---|---|---|---|
| Classic | libsrc/target/<name>/ (historic fcntl/stdio/gfx) + libsrc/classic/ | Z80, IXIY, Z180, 8080, 8085, gbz80, … | *_clib.lib, cpm8085_clib.lib, … |
| Newlib | Was libsrc/newlib/target/<name>/; migrated → libsrc/target/<name>/ beside classic | Z80-class (-clib=new / sdcc_ix / sdcc_iy) | lib/clibs/{sccz80,sdcc_ix}/<target>.lib |
Hard rules
- Do not merge classic and newlib stdio cores or fcntl
openowners in one link without a designed bridge. - Prefer sharing device / thin driver layers, not cores.
- CLIB selects newlib; machine SUBTYPEs usually stay classic-owned (esp. CP/M’s 150+ machines).
- After a path move, put the target name in
MIGRATED_TARGETSinlibsrc/newlib/Makefileso builds use../target/<name>.
Mixed tree hazard: when newlib Z80+ sources land under libsrc/target/cpm/ next to classic multi-CPU code, isolation is list ownership (*.lst), never broad globs. Classic 8080/8085 images must never pull newlib objects (Z80-only opcodes / calling conventions).
Classic I/O patterns (from target work)
Hybrid classic+newlib consoles (rc2014-8085 lesson)
When a CRT mixes classic fgetc_cons/fputc_cons with newlib-style startup:
- FILE init flags must match classic expectations (
18/20=_IOSYSTEM|_IOREAD/_IOWRITE). - Wrong flags (
19/21with spurious_IOUNGETC) made firstgetcharreturn NUL. - Hybrid clib lists must not pull full newlib fcntl/stdio/threads.
- Build: classic
<stdio.h>must win include order (-I…/includebefore_DEVELOPMENT/common) when the hybrid needs classicstdin/stdoutobjects.
Cooked line input: newlib vs classic (general)
| World | Line API | Who echoes / edits |
|---|---|---|
| Newlib | POSIX getline / getdelim | console_01 (line mode, echo, BS, CR/LF cook) via tied oterm |
| Classic | No getline | fgets on stdin → fgets_cons (echo, DEL, optional soft cursor) |
| Classic raw | fgetc / fgetc_cons | No line editor — app must implement if needed |
Rules of thumb
getlineis newlib-only. Never expect it on 8080/8085 classic products.- One cook layer only. If the driver/
fgets_consalready echoes, do not also echo in app code (double echo). - Hybrid CRTs that only bind
fgetc_cons/fputc_consare raw. App-level line readers (e.g. shellya_getline) are compensating for classic, not for the CPU. - Prefer
fgets/fgets_conson classic instead of reimplementing line edit. On serial targets, disable soft cursor if needed (CLIB_DISABLE_FGETS_CURSOR=1— already set forrc2014-8085). - Align dual-CPU apps (Z80 newlib + 8085 classic) at a single call site with
#ifdef, not by linking newlib stdio into 8085 images.
Dual-port FILE* vs classic ttyin macros
| Newlib CRT | Classic hybrid (e.g. uart85) | |
|---|---|---|
| Second port | Real drivers: m4_rc_01_input_uartb(_ttyin, …) etc. | Often only stdin/out/err → primary UART/ACIA |
ttyin / ttyout in headers | extern FILE * | Classic macros → _sgoioblk[3]… slots |
| Meaning | Instantiated streams | Declaration/slots ≠ working UARTB console |
fgetc on classic special-cases stdin → fgetc_cons. Assigning input = ttyin does not create a second cooked port unless the CRT initialises that slot and a driver path exists. For dual-port on hybrid: either an active-console global in fgetc_cons, or real second-stream CRT work — do not copy newlib’s input = ttyin pattern blindly.
CP/M IOBYTE seeds (firmware shells)
Shell may seed bios_iobyte before handing off to CCP; BIOS copies it to page-0 IOBYTE.
- CON is low 2 bits (CRT vs TTY, etc.).
- Hardware-specific high bits (e.g. 8085 module LST → SOD) may require seeds like
0x81/0x80, not bare1/0. Match the BIOSlist/constdecode, not “Z80 values”.
Agent rules
- Classic 8080/8085 images must never pull newlib objects (Z80 opcodes / conventions).
- Isolation is list ownership (
*.lst), never broad globs over mixed trees. - Line input:
fgets→fgets_cons; nogetline. - Runtime:
libsrc/l/sccz80/7-8085/,8-8080/,8-gbz80/, … → crt0 libs inlib/clibs/.
Related
- Newlib world:
library-newlib - Layout:
style-libsrc-layout - Targets:
target-cpm,target-rc2014; host TIMER / suites use+test
Signals
- GitHub stars
- 1k
- Forks
- 206
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
library-classic- Source
- github.com/z88dk/z88dk