# kz80_ws - WordStar Clone for Z80
A WordStar-compatible text editor for the RetroShield Z80. This project generates a Z80 ROM binary that implements a classic WordStar-style text editor with VT100 terminal output.
## Features
- **Classic WordStar key bindings** - Familiar control key sequences for navigation and editing
- **VT100/ANSI terminal support** - Works with any VT100-compatible terminal
- **Block operations** - Mark, copy, move, and delete text blocks
- **File operations** - Save files to SD card storage (via RetroShield I/O)
- **Help system** - Built-in help screen (^J)
- **Status bar** - Shows filename, cursor position, insert/overwrite mode, and modified indicator
- **WordStar file format** - Authentic file format with high-bit word markers
## Building
### Prerequisites
- Rust toolchain (1.70 or later)
- The `retroshield-z80-workbench` crate (automatically fetched from crates.io)
### Build and Generate ROM
```bash
cargo build --release
./target/release/kz80_ws output.bin
```
Or simply:
```bash
cargo run -- output.bin
```
This generates a Z80 ROM binary file (~4KB) that can be loaded into a RetroShield Z80 or compatible emulator.
### Running in the Emulator
```bash
# Using the RetroShield emulator
../emulator/rust/target/release/retroshield output.bin
# Or with the TUI debugger (recommended)
../emulator/rust/target/release/retroshield_tui --vt220 output.bin
# Or with the C emulator
../emulator/retroshield output.bin
```
## Key Bindings
### Cursor Movement
| ^E | Cursor up |
| ^X | Cursor down |
| ^S | Cursor left |
| ^D | Cursor right |
| ^A | Word left |
| ^F | Word right |
| ^QS | Beginning of line |
| ^QD | End of line |
| ^QR | Top of file |
| ^QC | End of file |
Arrow keys are also supported via VT100 escape sequences.
### Editing
| ^G | Delete character right |
| DEL/^H | Delete character left (backspace) |
| ^Y | Delete entire line |
| ^N | Insert new line |
| ^V | Toggle insert/overwrite mode |
| Enter | New line |
### Block Operations (^K prefix)
| ^KB | Mark block begin |
| ^KK | Mark block end |
| ^KC | Copy block to cursor position |
| ^KV | Move block to cursor position |
| ^KY | Delete marked block |
### File Operations (^K prefix)
| ^KS | Save file |
| ^KD | Save and exit |
| ^KQ | Quit without saving |
### Quick Commands (^Q prefix)
| ^QR | Go to top of file |
| ^QC | Go to end of file |
| ^QS | Go to start of line |
| ^QD | Go to end of line |
| ^QF | Find text |
### Other
| ^J | Show help screen |
| ESC | Escape key prefix (for arrow keys) |
## Screen Layout
```
+------------------------------------------------------------------+