Initial commit. Builds to skeleton.

This commit is contained in:
Thomas Cherryhomes 2019-01-25 16:09:42 -06:00
commit 7ee21c7d1a
23 changed files with 9086 additions and 0 deletions

25
CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
# To use this example as a standalone project using CMake:
# mkdir build
# cd build
# cmake .. -DCMAKE_TOOLCHAIN_FILE=path/to/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake
# make
cmake_minimum_required(VERSION 2.8)
add_application(PLATOTERM
help.c
io.c
keyboard.c
main.c
protocol.c
screen.c
terminal.c
touch.c
trace.c
)
target_link_libraries(PLATOTERM "-lm")
# save 200KB of code by removing unused stuff
set_target_properties(PLATOTERM PROPERTIES LINK_FLAGS "-Wl,-gc-sections")

4
build.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=~/Retro68/Retro68build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake && make && cp PLATOTERM.dsk /mnt/d/BasiliskII/

486
font.h Normal file
View File

@ -0,0 +1,486 @@
/**
* Font definitions for font memories M0 and M1
*/
unsigned char font[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x20 space */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10, /* 0x21 ! */
0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x28,0x28,0x28,0x00,0x00, /* 0x22 " */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x28,0x28,0xfe,0x28,0xfe, /* 0x23 # */
0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x7c,0x92,0x90,0x7c, /* 0x24 $ */
0x12,0x92,0x7c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x40,0xa2,0xa4,0x48,0x10, /* 0x25 % */
0x24,0x4a,0x8a,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x50,0x50,0x20,0x62, /* 0x26 & */
0x92,0x8c,0x8c,0x72,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x10,0x00,0x00, /* 0x27 ' */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x04,0x08,0x08,0x08, /* 0x28 ( */
0x08,0x08,0x08,0x04,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x20,0x20,0x20, /* 0x29 ) */
0x20,0x20,0x20,0x40,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x54,0x28, /* 0x2a * */
0x28,0x54,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10, /* 0x2b + */
0x7c,0x10,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x2c , */
0x00,0x00,0x30,0x30,0x10,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x2d - */
0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x2e . */
0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x08, /* 0x2f / */
0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3a,0x44,0x4c,0x54, /* 0x30 0 */
0x54,0x64,0x44,0xb8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x30,0x10,0x10, /* 0x31 1 */
0x10,0x10,0x10,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x44,0x04,0x08, /* 0x32 2 */
0x10,0x20,0x40,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x44,0x04,0x18, /* 0x33 3 */
0x04,0x04,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x04,0x0c,0x14,0x24, /* 0x34 4 */
0x7e,0x04,0x04,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7c,0x40,0x40,0x78, /* 0x35 5 */
0x04,0x04,0x08,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x20,0x40,0x78, /* 0x36 6 */
0x44,0x44,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7c,0x04,0x08,0x08, /* 0x37 7 */
0x10,0x10,0x20,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x44,0x44,0x38, /* 0x38 8 */
0x44,0x44,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x44,0x44,0x44, /* 0x39 9 */
0x3c,0x04,0x08,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30, /* 0x3a : */
0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30, /* 0x3b ; */
0x00,0x00,0x30,0x30,0x10,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x20, /* 0x3c < */
0x40,0x20,0x10,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c, /* 0x3d = */
0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x20,0x10,0x08, /* 0x3e > */
0x04,0x08,0x10,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x44,0x04,0x08, /* 0x3f ? */
0x10,0x10,0x00,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x9a, /* 0x40 @ */
0xaa,0xaa,0x9c,0x40,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x82,0x82,0xfe, /* 0x41 A */
0x82,0x82,0x82,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xf8,0x84,0x84,0xfc,0x82, /* 0x42 B */
0x82,0x82,0x82,0xfc,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3c,0x42,0x80,0x80,0x80, /* 0x43 C */
0x80,0x80,0x42,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xf0,0x88,0x84,0x84,0x84, /* 0x44 D */
0x84,0x84,0x88,0xf0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x80,0x80,0x80,0xf8, /* 0x45 E */
0x80,0x80,0x80,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x80,0x80,0x80,0xf0, /* 0x46 F */
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3c,0x42,0x80,0x80,0x80, /* 0x47 G */
0x8e,0x82,0x42,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x82,0x82,0xfe, /* 0x48 H */
0x82,0x82,0x82,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x10,0x10,0x10,0x10, /* 0x49 I */
0x10,0x10,0x10,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3e,0x08,0x08,0x08,0x08, /* 0x4a J */
0x08,0x08,0x88,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x84,0x88,0x90,0xa0, /* 0x4b K */
0xd0,0x88,0x84,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80, /* 0x4c L */
0x80,0x80,0x80,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0xc6,0xaa,0x92,0x82, /* 0x4d M */
0x82,0x82,0x82,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0xc2,0xa2,0xa2,0x92, /* 0x4e N */
0x8a,0x8a,0x86,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82, /* 0x4f O */
0x82,0x82,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfc,0x82,0x82,0x82,0xfc, /* 0x50 P */
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82, /* 0x51 Q */
0x82,0x82,0x44,0x38,0x10,0x0c,0x00,0x00,
0x00,0x00,0x00,0xfc,0x82,0x82,0x82,0xfc, /* 0x52 R */
0x90,0x88,0x84,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x80,0x80,0x7c, /* 0x53 S */
0x02,0x02,0x82,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x10,0x10,0x10,0x10, /* 0x54 T */
0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x82,0x82,0x82, /* 0x55 U */
0x82,0x82,0x82,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x44,0x44,0x44, /* 0x56 V */
0x28,0x28,0x10,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x82,0x92,0x92, /* 0x57 W */
0x92,0x92,0xaa,0x44,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x44,0x28,0x10, /* 0x58 X */
0x28,0x44,0x82,0x82,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x44,0x28,0x10, /* 0x59 Y */
0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x82,0x04,0x08,0x10, /* 0x5a Z */
0x20,0x40,0x82,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0e,0x08,0x08,0x08,0x08, /* 0x5b [ */
0x08,0x08,0x08,0x08,0x0e,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40, /* 0x5c \ */
0x20,0x10,0x08,0x04,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0xe0,0x20,0x20,0x20,0x20, /* 0x5d ] */
0x20,0x20,0x20,0x20,0xe0,0x00,0x00,0x00,
0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00, /* 0x5e ^ */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x5f _ */
0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,
0x00,0x40,0x20,0x10,0x00,0x00,0x00,0x00, /* 0x60 ` */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x04, /* 0x61 a */
0x7c,0x84,0x84,0x7a,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0xb8,0xc4, /* 0x62 b */
0x82,0x82,0xc4,0xb8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x42, /* 0x63 c */
0x80,0x80,0x42,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x02,0x02,0x3a,0x46, /* 0x64 d */
0x82,0x82,0x46,0x3a,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x42, /* 0x65 e */
0xfe,0x80,0x40,0x3e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0c,0x12,0x10,0x38,0x10, /* 0x66 f */
0x10,0x10,0x10,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0x84, /* 0x67 g */
0x84,0x78,0x80,0x7c,0x82,0x7c,0x00,0x00,
0x00,0x00,0x00,0xc0,0x40,0x40,0x5c,0x62, /* 0x68 h */
0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x00,0x00,0x30,0x10, /* 0x69 i */
0x10,0x10,0x10,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x00,0x00,0x30,0x10, /* 0x6a j */
0x10,0x10,0x10,0x10,0x10,0x10,0x60,0x00,
0x00,0x00,0x00,0xc0,0x40,0x40,0x4c,0x50, /* 0x6b k */
0x60,0x50,0x48,0xc6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x30,0x10,0x10,0x10,0x10, /* 0x6c l */
0x10,0x10,0x10,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x92, /* 0x6d m */
0x92,0x92,0x92,0x92,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xdc,0x62, /* 0x6e n */
0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44, /* 0x6f o */
0x82,0x82,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xc4, /* 0x70 p */
0x82,0x82,0xc4,0xb8,0x80,0x80,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3a,0x46, /* 0x71 q */
0x82,0x82,0x46,0x3a,0x02,0x02,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xdc,0x62, /* 0x72 r */
0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x80, /* 0x73 s */
0x7c,0x02,0x82,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x20,0x20,0xfc,0x20, /* 0x74 t */
0x20,0x20,0x20,0x1c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x84, /* 0x75 u */
0x84,0x84,0x84,0x7a,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xc6,0x44, /* 0x76 v */
0x28,0x28,0x10,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x92, /* 0x77 w */
0x92,0x92,0xaa,0x44,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0x24, /* 0x78 x */
0x18,0x18,0x24,0x42,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x82, /* 0x79 y */
0x82,0x44,0x28,0x10,0x20,0x40,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x88, /* 0x7a z */
0x10,0x20,0x44,0xfc,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x08,0x08,0x08,0x08, /* 0x7b { */
0x10,0x08,0x08,0x08,0x08,0x06,0x00,0x00,
0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x00, /* 0x7c | */
0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xc0,0x20,0x20,0x20,0x20, /* 0x7d } */
0x10,0x20,0x20,0x20,0x20,0xc0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x7e ~ */
0x32,0x4c,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c, /* 0x7f box */
0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xa0 space */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x08, /* 0xa1 ! = slant */
0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00, /* 0xa2 " = equivalent */
0x7c,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x32,0x4c,0x00,0x00,0x00,0x00, /* 0xa3 # = tilde */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x5e, /* 0xa4 $ = assignment */
0x80,0x5e,0x30,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x04,0xfe, /* 0xa5 % = not equal */
0x10,0xfe,0x40,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x38,0x7c, /* 0xa6 & = up arrow */
0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0c, /* 0xa7 ' = right arrow */
0xfe,0x0c,0x08,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10, /* 0xa8 ( = down arrow */
0x10,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x60, /* 0xa9 ) = left arrow */
0xfe,0x60,0x20,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x18, /* 0xaa * = multiply */
0x18,0x24,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x40,0x20,0x10,0x08, /* 0xab + = cap sigma */
0x10,0x20,0x40,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x10,0x28,0x28, /* 0xac , = cap delta */
0x44,0x44,0x82,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x44, /* 0xad - = union */
0x44,0x38,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44, /* 0xae . = intersection */
0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00, /* 0xaf / = divide */
0x7c,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x92, /* 0xb0 0 = alpha */
0x94,0x88,0x98,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x24,0x44,0x78, /* 0xb1 1 = beta */
0x44,0x42,0x42,0x7c,0x40,0x40,0x80,0x00,
0x00,0x00,0x00,0x30,0x48,0x44,0x20,0x30, /* 0xb2 2 = delta */
0x48,0x44,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x40,0x20,0x20,0x10,0x10, /* 0xb3 3 = lambda */
0x28,0x28,0x44,0x44,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x24, /* 0xb4 4 = micro */
0x24,0x24,0x24,0x3a,0x20,0x20,0xc0,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x7c,0xa8, /* 0xb5 5 = pi */
0x28,0x28,0x28,0x28,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x12, /* 0xb6 6 = rho */
0x22,0x22,0x64,0x58,0x40,0x80,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x50, /* 0xb7 7 = sigma */
0x88,0x88,0x88,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x82, /* 0xb8 8 = omega */
0x92,0x92,0x92,0x6c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0c,0x30,0xc0,0x30, /* 0xb9 9 = less than or equal */
0x0c,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x18,0x06,0x18, /* 0xba : = greater than or equal */
0x60,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x82,0x82,0xfe, /* 0xbb ; = cap theta */
0x82,0x82,0x44,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x04,0x08,0x18,0x28, /* 0xbc < = left embed */
0x48,0x28,0x18,0x0c,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x30,0x48,0x48,0x30,0x00, /* 0xbd = = degree */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x20,0x30,0x28, /* 0xbe > = right embed */
0x24,0x28,0x30,0x60,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0xc0,0xa0,0x90,0x48,0x24, /* 0xbf ? = arrow */
0x12,0x24,0x48,0x90,0xa0,0xc0,0x00,0x00,
0x00,0x00,0xfe,0x00,0x00,0x3c,0x42,0x80, /* 0xc0 @ = center of copyright */
0x80,0x42,0x3c,0x00,0x00,0xfe,0x00,0x00,
0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x00, /* 0xc1 A = umlaut */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x44, /* 0xc2 B = box */
0x44,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x48, /* 0xc3 C = dot product */
0x48,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x38,0x7c, /* 0xc4 D = diamond */
0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x82,0x44,0x28, /* 0xc5 E = cross product */
0x10,0x28,0x44,0x82,0x00,0x00,0x00,0x00,
0x00,0x04,0x08,0x10,0x00,0x00,0x00,0x00, /* 0xc6 F = acute accent */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xc7 G = cedilla */
0x00,0x00,0x00,0x04,0x08,0x10,0x00,0x00,
0x00,0x44,0x28,0x10,0x00,0x00,0x00,0x00, /* 0xc8 H = hacek */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x38,0x7c, /* 0xc9 I = universal separator */
0x10,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10, /* 0xca J = vertical bar */
0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xcb K */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xcc L */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xcd M */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xce N */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xcf O */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd0 P */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd1 Q */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd2 R */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd3 S */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd4 T */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd5 U */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd6 V */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd7 W */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd8 X */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xd9 Y */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xda Z */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xdb [ */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xdc \ */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xdd ] */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xde ^ */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0xdf _ */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

3367
help.c Normal file

File diff suppressed because it is too large Load Diff

11
help.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef HELP_H
#define HELP_H
#include "protocol.h"
/**
* help_init(void) - Initialize and draw help
*/
void help_init(void);
#endif /* HELP_H */

67
io.c Executable file
View File

@ -0,0 +1,67 @@
#include "io.h"
#include "protocol.h"
#include "terminal.h"
#define true 1
#define false 0
extern unsigned char trace_active;
void io_init(void)
{
}
void io_send_byte(unsigned char b)
{
}
void io_main(void)
{
}
/**
* io_send_string(str,len)
* Send string to port.
*/
void io_send_string(const char* str, int len)
{
}
/**
* io_set_baud(int baud) - Set baud rate
*/
void io_set_baud(int baud)
{
}
/**
* io_hang_up(void) - Hang up modem
*/
void io_hang_up(void)
{
}
/**
* io_send_cr(void)
*/
void io_send_cr(void)
{
}
/**
* io_send_dial(void) - Send dial string to modem
*/
void io_send_dial(void)
{
}
/**
* io_send_back_out(void) - send back out
*/
void io_send_back_out(void)
{
}
void io_done()
{
}

67
io.h Executable file
View File

@ -0,0 +1,67 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* io.h - Input/output functions (serial/ethernet)
*/
#ifndef IO_H
#define IO_H
#define XON 0x11
#define XOFF 0x13
/**
* io_init() - Set-up the I/O
*/
void io_init(void);
/**
* io_send_byte(b) - Send specified byte out
*/
void io_send_byte(unsigned char b);
/**
* io_send_string(str,len)
* Send string to port.
*/
void io_send_string(const char* str, int len);
/**
* io_main() - The IO main loop
*/
void io_main(void);
/**
* io_set_baud(int baud) - Set baud rate
*/
void io_set_baud(int baud);
/**
* io_hang_up(void) - Hang up modem
*/
void io_hang_up(void);
/**
* io_send_cr(void)
*/
void io_send_cr(void);
/**
* io_send_dial(void) - send dial string
*/
void io_send_dial(void);
/**
* io_send_back_out(void) - send back out
*/
void io_send_back_out(void);
/**
* io_done() - Called to close I/O
*/
void io_done(void);
#endif /* IO_H */

400
key.h Normal file
View File

@ -0,0 +1,400 @@
/**
*
* KEY_H generated by mk_ascii_key_h.c
*/
#include "plato_key.h"
int key_to_pkey[]={
PKEY_NOKEY, /* 0x00 NUL */
PKEY_NOKEY, /* 0x01 CTRL-A */
PKEY_NOKEY, /* 0x02 CTRL-B */
PKEY_NOKEY, /* 0x03 CTRL-C */
PKEY_NOKEY, /* 0x04 CTRL-D */
PKEY_NOKEY, /* 0x05 CTRL-E */
PKEY_NOKEY, /* 0x06 CTRL-F */
PKEY_NOKEY, /* 0x07 CTRL-G */
PKEY_NOKEY, /* 0x08 CTRL-H */
PKEY_TAB, /* 0x09 CTRL-I */
PKEY_NOKEY, /* 0x0a CTRL-J */
PKEY_NOKEY, /* 0x0b CTRL-K */
PKEY_NOKEY, /* 0x0c CTRL-L */
PKEY_NEXT, /* 0x0d CTRL-M */
PKEY_NOKEY, /* 0x0e CTRL-N */
PKEY_NOKEY, /* 0x0f CTRL-O */
PKEY_NOKEY, /* 0x10 CTRL-P */
PKEY_NOKEY, /* 0x11 CTRL-Q */
PKEY_NOKEY, /* 0x12 CTRL-R */
PKEY_NOKEY, /* 0x13 CTRL-S */
PKEY_NOKEY, /* 0x14 CTRL-T */
PKEY_NOKEY, /* 0x15 CTRL-U */
PKEY_NOKEY, /* 0x16 CTRL-V */
PKEY_NOKEY, /* 0x17 CTRL-W */
PKEY_NOKEY, /* 0x18 CTRL-X */
PKEY_NOKEY, /* 0x19 CTRL-Y */
PKEY_NOKEY, /* 0x1a CTRL-Z */
PKEY_ASSIGN, /* 0x1b ESC */
PKEY_NOKEY, /* 0x1c */
PKEY_NOKEY, /* 0x1d */
PKEY_NOKEY, /* 0x1e */
PKEY_NOKEY, /* 0x1f */
PKEY_SPACE, /* 0x20 SPACE */
PKEY_EXCLAMATION, /* 0x21 ! */
PKEY_QUOTE, /* 0x22 " */
PKEY_POUND, /* 0x23 # */
PKEY_DOLLAR, /* 0x24 $ */
PKEY_PERCENT, /* 0x25 % */
PKEY_AMPERSAND, /* 0x26 & */
PKEY_APOSTROPHE, /* 0x27 ' */
PKEY_PARENTHESIS_LEFT, /* 0x28 ( */
PKEY_PARENTHESIS_RIGHT, /* 0x29 ) */
PKEY_ASTERISK, /* 0x2a * */
PKEY_PLUS, /* 0x2b + */
PKEY_COMMA, /* 0x2c , */
PKEY_MINUS, /* 0x2d - */
PKEY_PERIOD, /* 0x2e . */
PKEY_SLASH, /* 0x2f / */
PKEY_0, /* 0x30 0 */
PKEY_1, /* 0x31 1 */
PKEY_2, /* 0x32 2 */
PKEY_3, /* 0x33 3 */
PKEY_4, /* 0x34 4 */
PKEY_5, /* 0x35 5 */
PKEY_6, /* 0x36 6 */
PKEY_7, /* 0x37 7 */
PKEY_8, /* 0x38 8 */
PKEY_9, /* 0x39 9 */
PKEY_COLON, /* 0x3a : */
PKEY_SEMICOLON, /* 0x3b ; */
PKEY_LESS_THAN, /* 0x3c < */
PKEY_EQUALS, /* 0x3d = */
PKEY_GREATER_THAN, /* 0x3e > */
PKEY_QUESTION_MARK, /* 0x3f ? */
PKEY_AT, /* 0x40 @ */
PKEY_A, /* 0x41 A */
PKEY_B, /* 0x42 B */
PKEY_C, /* 0x43 C */
PKEY_D, /* 0x44 D */
PKEY_E, /* 0x45 E */
PKEY_F, /* 0x46 F */
PKEY_G, /* 0x47 G */
PKEY_H, /* 0x48 H */
PKEY_I, /* 0x49 I */
PKEY_J, /* 0x4a J */
PKEY_K, /* 0x4b K */
PKEY_L, /* 0x4c L */
PKEY_M, /* 0x4d M */
PKEY_N, /* 0x4e N */
PKEY_O, /* 0x4f O */
PKEY_P, /* 0x50 P */
PKEY_Q, /* 0x51 Q */
PKEY_R, /* 0x52 R */
PKEY_S, /* 0x53 S */
PKEY_T, /* 0x54 T */
PKEY_U, /* 0x55 U */
PKEY_V, /* 0x56 V */
PKEY_W, /* 0x57 W */
PKEY_X, /* 0x58 X */
PKEY_Y, /* 0x59 Y */
PKEY_Z, /* 0x5a Z */
PKEY_BRACKET_LEFT, /* 0x5b [ */
PKEY_SLASH, /* 0x5c / */
PKEY_BRACKET_RIGHT, /* 0x5d ] */
PKEY_CIRCUMFLEX, /* 0x5e ^ */
PKEY_UNDERSCORE, /* 0x5f _ */
PKEY_GRAVE, /* 0x60 ` */
PKEY_a, /* 0x61 a */
PKEY_b, /* 0x62 b */
PKEY_c, /* 0x63 c */
PKEY_d, /* 0x64 d */
PKEY_e, /* 0x65 e */
PKEY_f, /* 0x66 f */
PKEY_g, /* 0x67 g */
PKEY_h, /* 0x68 h */
PKEY_i, /* 0x69 i */
PKEY_j, /* 0x6a j */
PKEY_k, /* 0x6b k */
PKEY_l, /* 0x6c l */
PKEY_m, /* 0x6d m */
PKEY_n, /* 0x6e n */
PKEY_o, /* 0x6f o */
PKEY_p, /* 0x70 p */
PKEY_q, /* 0x71 q */
PKEY_r, /* 0x72 r */
PKEY_s, /* 0x73 s */
PKEY_t, /* 0x74 t */
PKEY_u, /* 0x75 u */
PKEY_v, /* 0x76 v */
PKEY_w, /* 0x77 w */
PKEY_x, /* 0x78 x */
PKEY_y, /* 0x79 y */
PKEY_z, /* 0x7a z */
PKEY_LEFT_CURLY_BRACE, /* 0x7b { */
PKEY_BAR, /* 0x7c | */
PKEY_RIGHT_CURLY_BRACE, /* 0x7d } */
PKEY_TILDE, /* 0x7e ~ */
PKEY_ERASE, /* 0x7f DEL */
};
/* CTRL key mappings, |= 0x80 for shifted ctrl-keys */
/* HELP is handled by a scancode/shift state override */
/* NEXT/NEXT1 is handled by a scancode/shift state override */
int ctrl_key_to_pkey[]={
PKEY_NOKEY, /* 0x00 NUL */
PKEY_ANS, /* 0x01 CTRL-A */
PKEY_BACK, /* 0x02 CTRL-B */
PKEY_COPY, /* 0x03 CTRL-C */
PKEY_DATA, /* 0x04 CTRL-D */
PKEY_EDIT, /* 0x05 CTRL-E */
PKEY_FONT, /* 0x06 CTRL-F */
PKEY_DIVIDE, /* 0x07 CTRL-G */
PKEY_ERASE, /* 0x08 CTRL-H */
PKEY_NOKEY, /* 0x09 CTRL-I */
PKEY_NOKEY, /* 0x0a CTRL-J */
PKEY_NOKEY, /* 0x0b CTRL-K */
PKEY_LAB, /* 0x0c CTRL-L */
PKEY_NEXT, /* 0x0d CTRL-M */
PKEY_NEXT, /* 0x0e CTRL-N */
PKEY_BACK, /* 0x0f CTRL-O */
PKEY_SUPER, /* 0x10 CTRL-P */
PKEY_SQUARE, /* 0x11 CTRL-Q */
PKEY_ERASE, /* 0x12 CTRL-R */
PKEY_STOP, /* 0x13 CTRL-S */
PKEY_TERM, /* 0x14 CTRL-T */
PKEY_NOKEY, /* 0x15 CTRL-U */
PKEY_NOKEY, /* 0x16 CTRL-V */
PKEY_NOKEY, /* 0x17 CTRL-W */
PKEY_MULTIPLY, /* 0x18 CTRL-X */
PKEY_SUB, /* 0x19 CTRL-Y */
PKEY_NOKEY, /* 0x1a CTRL-Z */
PKEY_NOKEY, /* 0x1b ESC */
PKEY_NOKEY, /* 0x1c */
PKEY_NOKEY, /* 0x1d */
PKEY_NOKEY, /* 0x1e */
PKEY_NOKEY, /* 0x1f */
PKEY_BACKSPACE, /* 0x20 SPACE */
PKEY_NOKEY, /* 0x21 ! */
PKEY_NOKEY, /* 0x22 " */
PKEY_NOKEY, /* 0x23 # */
PKEY_NOKEY, /* 0x24 $ */
PKEY_NOKEY, /* 0x25 % */
PKEY_NOKEY, /* 0x26 & */
PKEY_NOKEY, /* 0x27 ' */
PKEY_NOKEY, /* 0x28 ( */
PKEY_NOKEY, /* 0x29 ) */
PKEY_NOKEY, /* 0x2a * */
PKEY_SIGMA, /* 0x2b + */
PKEY_NOKEY, /* 0x2c , */
PKEY_DELTA, /* 0x2d - */
PKEY_NOKEY, /* 0x2e . */
PKEY_NOKEY, /* 0x2f / */
PKEY_NOKEY, /* 0x30 0 */
PKEY_NOKEY, /* 0x31 1 */
PKEY_NOKEY, /* 0x32 2 */
PKEY_NOKEY, /* 0x33 3 */
PKEY_NOKEY, /* 0x34 4 */
PKEY_NOKEY, /* 0x35 5 */
PKEY_NOKEY, /* 0x36 6 */
PKEY_NOKEY, /* 0x37 7 */
PKEY_NOKEY, /* 0x38 8 */
PKEY_NOKEY, /* 0x39 9 */
PKEY_NOKEY, /* 0x3a : */
PKEY_NOKEY, /* 0x3b ; */
PKEY_NOKEY, /* 0x3c < */
PKEY_NOKEY, /* 0x3d = */
PKEY_NOKEY, /* 0x3e > */
PKEY_NOKEY, /* 0x3f ? */
PKEY_NOKEY, /* 0x40 @ */
PKEY_NOKEY, /* 0x41 A */
PKEY_NOKEY, /* 0x42 B */
PKEY_NOKEY, /* 0x43 C */
PKEY_NOKEY, /* 0x44 D */
PKEY_NOKEY, /* 0x45 E */
PKEY_NOKEY, /* 0x46 F */
PKEY_NOKEY, /* 0x47 G */
PKEY_NOKEY, /* 0x48 H */
PKEY_NOKEY, /* 0x49 I */
PKEY_NOKEY, /* 0x4a J */
PKEY_NOKEY, /* 0x4b K */
PKEY_NOKEY, /* 0x4c L */
PKEY_NOKEY, /* 0x4d M */
PKEY_NOKEY, /* 0x4e N */
PKEY_NOKEY, /* 0x4f O */
PKEY_NOKEY, /* 0x50 P */
PKEY_NOKEY, /* 0x51 Q */
PKEY_NOKEY, /* 0x52 R */
PKEY_NOKEY, /* 0x53 S */
PKEY_NOKEY, /* 0x54 T */
PKEY_NOKEY, /* 0x55 U */
PKEY_NOKEY, /* 0x56 V */
PKEY_NOKEY, /* 0x57 W */
PKEY_NOKEY, /* 0x58 X */
PKEY_NOKEY, /* 0x59 Y */
PKEY_NOKEY, /* 0x5a Z */
PKEY_NOKEY, /* 0x5b [ */
PKEY_NOKEY, /* 0x5c / */
PKEY_NOKEY, /* 0x5d ] */
PKEY_NOKEY, /* 0x5e ^ */
PKEY_NOKEY, /* 0x5f _ */
PKEY_NOKEY, /* 0x60 ` */
PKEY_NOKEY, /* 0x61 a */
PKEY_NOKEY, /* 0x62 b */
PKEY_NOKEY, /* 0x63 c */
PKEY_NOKEY, /* 0x64 d */
PKEY_NOKEY, /* 0x65 e */
PKEY_NOKEY, /* 0x66 f */
PKEY_NOKEY, /* 0x67 g */
PKEY_NOKEY, /* 0x68 h */
PKEY_NOKEY, /* 0x69 i */
PKEY_NOKEY, /* 0x6a j */
PKEY_NOKEY, /* 0x6b k */
PKEY_NOKEY, /* 0x6c l */
PKEY_NOKEY, /* 0x6d m */
PKEY_NOKEY, /* 0x6e n */
PKEY_NOKEY, /* 0x6f o */
PKEY_NOKEY, /* 0x70 p */
PKEY_NOKEY, /* 0x71 q */
PKEY_NOKEY, /* 0x72 r */
PKEY_NOKEY, /* 0x73 s */
PKEY_NOKEY, /* 0x74 t */
PKEY_NOKEY, /* 0x75 u */
PKEY_NOKEY, /* 0x76 v */
PKEY_NOKEY, /* 0x77 w */
PKEY_NOKEY, /* 0x78 x */
PKEY_NOKEY, /* 0x79 y */
PKEY_NOKEY, /* 0x7a z */
PKEY_NOKEY, /* 0x7b { */
PKEY_NOKEY, /* 0x7c | */
PKEY_NOKEY, /* 0x7d } */
PKEY_NOKEY, /* 0x7e ~ */
PKEY_NOKEY, /* 0x7f DEL */
PKEY_NOKEY, /* 0x80 */
PKEY_ANS, /* 0x81 */
PKEY_BACK1, /* 0x82 */
PKEY_COPY1, /* 0x83 */
PKEY_DATA1, /* 0x84 */
PKEY_EDIT1, /* 0x85 */
PKEY_FONT, /* 0x86 */
PKEY_INTERSECT, /* 0x87 */
PKEY_HELP1, /* 0x88 */
PKEY_NOKEY, /* 0x89 */
PKEY_NOKEY, /* 0x8A */
PKEY_NOKEY, /* 0x8B */
PKEY_LAB1, /* 0x8C */
PKEY_MICRO, /* 0x8D */
PKEY_NEXT1, /* 0x8E */
PKEY_NOKEY, /* 0x8F */
PKEY_SUPER1, /* 0x90 */
PKEY_ACCESS, /* 0x91 */
PKEY_ERASE1, /* 0x92 */
PKEY_STOP1, /* 0x93 */
PKEY_TERM, /* 0x94 */
PKEY_NOKEY, /* 0x95 */
PKEY_NOKEY, /* 0x96 */
PKEY_NOKEY, /* 0x97 */
PKEY_NOKEY, /* 0x98 */
PKEY_SUB1, /* 0x99 */
PKEY_NOKEY, /* 0x9A */
PKEY_NOKEY, /* 0x9B */
PKEY_NOKEY, /* 0x9C */
PKEY_NOKEY, /* 0x9D */
PKEY_NOKEY, /* 0x9E */
PKEY_NOKEY, /* 0x9F */
PKEY_NOKEY, /* 0xA0 */
PKEY_NOKEY, /* 0xA1 */
PKEY_NOKEY, /* 0xA2 */
PKEY_NOKEY, /* 0xA3 */
PKEY_NOKEY, /* 0xA4 */
PKEY_NOKEY, /* 0xA5 */
PKEY_NOKEY, /* 0xA6 */
PKEY_NOKEY, /* 0xA7 */
PKEY_NOKEY, /* 0xA8 */
PKEY_NOKEY, /* 0xA9 */
PKEY_NOKEY, /* 0xAA */
PKEY_NOKEY, /* 0xAB */
PKEY_NOKEY, /* 0xAC */
PKEY_NOKEY, /* 0xAD */
PKEY_NOKEY, /* 0xAE */
PKEY_NOKEY, /* 0xAF */
PKEY_NOKEY, /* 0xB0 */
PKEY_NOKEY, /* 0xB1 */
PKEY_NOKEY, /* 0xB2 */
PKEY_NOKEY, /* 0xB3 */
PKEY_NOKEY, /* 0xB4 */
PKEY_NOKEY, /* 0xB5 */
PKEY_NOKEY, /* 0xB6 */
PKEY_NOKEY, /* 0xB7 */
PKEY_NOKEY, /* 0xB8 */
PKEY_NOKEY, /* 0xB9 */
PKEY_NOKEY, /* 0xBA */
PKEY_NOKEY, /* 0xBB */
PKEY_NOKEY, /* 0xBC */
PKEY_NOKEY, /* 0xBD */
PKEY_NOKEY, /* 0xBE */
PKEY_NOKEY, /* 0xBF */
PKEY_NOKEY, /* 0xC0 */
PKEY_NOKEY, /* 0xC1 */
PKEY_NOKEY, /* 0xC2 */
PKEY_NOKEY, /* 0xC3 */
PKEY_NOKEY, /* 0xC4 */
PKEY_NOKEY, /* 0xC5 */
PKEY_NOKEY, /* 0xC6 */
PKEY_NOKEY, /* 0xC7 */
PKEY_NOKEY, /* 0xC8 */
PKEY_NOKEY, /* 0xC9 */
PKEY_NOKEY, /* 0xCA */
PKEY_NOKEY, /* 0xCB */
PKEY_NOKEY, /* 0xCC */
PKEY_NOKEY, /* 0xCD */
PKEY_NOKEY, /* 0xCE */
PKEY_NOKEY, /* 0xCF */
PKEY_NOKEY, /* 0xD0 */
PKEY_NOKEY, /* 0xD1 */
PKEY_NOKEY, /* 0xD2 */
PKEY_NOKEY, /* 0xD3 */
PKEY_NOKEY, /* 0xD4 */
PKEY_NOKEY, /* 0xD5 */
PKEY_NOKEY, /* 0xD6 */
PKEY_NOKEY, /* 0xD7 */
PKEY_NOKEY, /* 0xD8 */
PKEY_NOKEY, /* 0xD9 */
PKEY_NOKEY, /* 0xDA */
PKEY_NOKEY, /* 0xDB */
PKEY_NOKEY, /* 0xDC */
PKEY_NOKEY, /* 0xDD */
PKEY_NOKEY, /* 0xDE */
PKEY_NOKEY, /* 0xDF */
PKEY_NOKEY, /* 0xE0 */
PKEY_NOKEY, /* 0xE1 */
PKEY_NOKEY, /* 0xE2 */
PKEY_NOKEY, /* 0xE3 */
PKEY_NOKEY, /* 0xE4 */
PKEY_NOKEY, /* 0xE5 */
PKEY_NOKEY, /* 0xE6 */
PKEY_NOKEY, /* 0xE7 */
PKEY_NOKEY, /* 0xE8 */
PKEY_NOKEY, /* 0xE9 */
PKEY_NOKEY, /* 0xEA */
PKEY_NOKEY, /* 0xEB */
PKEY_NOKEY, /* 0xEC */
PKEY_NOKEY, /* 0xED */
PKEY_NOKEY, /* 0xEE */
PKEY_NOKEY, /* 0xEF */
PKEY_NOKEY, /* 0xF0 */
PKEY_NOKEY, /* 0xF1 */
PKEY_NOKEY, /* 0xF2 */
PKEY_NOKEY, /* 0xF3 */
PKEY_NOKEY, /* 0xF4 */
PKEY_NOKEY, /* 0xF5 */
PKEY_NOKEY, /* 0xF6 */
PKEY_NOKEY, /* 0xF7 */
PKEY_NOKEY, /* 0xF8 */
PKEY_NOKEY, /* 0xF9 */
PKEY_NOKEY, /* 0xFA */
PKEY_NOKEY, /* 0xFB */
PKEY_NOKEY, /* 0xFC */
PKEY_NOKEY, /* 0xFD */
PKEY_NOKEY, /* 0xFE */
PKEY_NOKEY, /* 0xFF */
};

26
keyboard.c Executable file
View File

@ -0,0 +1,26 @@
#include "keyboard.h"
#include "key.h"
#include "protocol.h"
#include "io.h"
#include "screen.h"
#include "trace.h"
#define true 1
#define false 0
extern unsigned char running;
extern unsigned char help_active;
extern char tmp[64];
void keyboard_out(int platoKey)
{
}
void keyboard_main(void)
{
}
void keyboard_out_tty(int ch)
{
}

31
keyboard.h Executable file
View File

@ -0,0 +1,31 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* keyboard.h - Keyboard functions
*/
#ifndef KEYBOARD_H
#define KEYBOARD_H
/**
* keyboard_out - If platoKey < 0x7f, pass off to protocol
* directly. Otherwise, platoKey is an access key, and the
* ACCESS key must be sent, followed by the particular
* access key from PTAT_ACCESS.
*/
void keyboard_out(int platoKey);
/**
* keyboard_main - Handle the keyboard presses
*/
void keyboard_main(void);
/**
* keyboard_out_tty - keyboard output to serial I/O in TTY mode
*/
void keyboard_out_tty(int ch);
#endif

38
main.c Executable file
View File

@ -0,0 +1,38 @@
#include "protocol.h"
#include "screen.h"
#include "io.h"
#include "terminal.h"
#include "keyboard.h"
#include "touch.h"
#include "splash.h"
#include "help.h"
#define true 1
#define false 0
unsigned char already_started=false;
unsigned char running=false;
void main(void)
{
screen_init();
touch_init();
help_init();
NoEcho=padT;
ShowPLATO(splash,sizeof(splash));
NoEcho=padF;
terminal_initial_position();
io_init();
running=true;
screen_show_dial();
screen_greeting();
while (running==true)
{
keyboard_main();
io_main();
touch_main();
}
io_done();
touch_done();
screen_done();
}

252
plato_key.h Normal file
View File

@ -0,0 +1,252 @@
/**
* plato_key.h
* PLATO specific key mappings
* used by key.h
* this define table is ordered as in s0ascers document.
*/
#ifndef PLATO_KEY_H
#define PLATO_KEY_H
#define PKEY_a 0x41
#define PKEY_A 0x61
#define PKEY_b 0x42
#define PKEY_B 0x62
#define PKEY_c 0x43
#define PKEY_C 0x63
#define PKEY_d 0x44
#define PKEY_D 0x64
#define PKEY_e 0x45
#define PKEY_E 0x65
#define PKEY_f 0x46
#define PKEY_F 0x66
#define PKEY_g 0x47
#define PKEY_G 0x67
#define PKEY_h 0x48
#define PKEY_H 0x68
#define PKEY_i 0x49
#define PKEY_I 0x69
#define PKEY_j 0x4a
#define PKEY_J 0x6a
#define PKEY_k 0x4b
#define PKEY_K 0x6b
#define PKEY_l 0x4c
#define PKEY_L 0x6C
#define PKEY_m 0x4d
#define PKEY_M 0x6d
#define PKEY_n 0x4e
#define PKEY_N 0x6e
#define PKEY_o 0x4f
#define PKEY_O 0x6f
#define PKEY_p 0x50
#define PKEY_P 0x70
#define PKEY_q 0x51
#define PKEY_Q 0x71
#define PKEY_r 0x52
#define PKEY_R 0x72
#define PKEY_s 0x53
#define PKEY_S 0x73
#define PKEY_t 0x54
#define PKEY_T 0x74
#define PKEY_u 0x55
#define PKEY_U 0x75
#define PKEY_v 0x56
#define PKEY_V 0x76
#define PKEY_w 0x57
#define PKEY_W 0x77
#define PKEY_x 0x58
#define PKEY_X 0x78
#define PKEY_y 0x59
#define PKEY_Y 0x79
#define PKEY_z 0x5a
#define PKEY_Z 0x7A
#define PKEY_0 0x00
#define PKEY_LESS_THAN 0x20
#define PKEY_1 0x01
#define PKEY_GREATER_THAN 0x21
#define PKEY_2 0x02
#define PKEY_BRACKET_LEFT 0x22
#define PKEY_3 0x03
#define PKEY_BRACKET_RIGHT 0x23
#define PKEY_4 0x04
#define PKEY_DOLLAR 0x24
#define PKEY_5 0x05
#define PKEY_PERCENT 0x25
#define PKEY_6 0x06
#define PKEY_UNDERSCORE 0x26
#define PKEY_7 0x07
#define PKEY_APOSTROPHE 0x27
#define PKEY_8 0x08
#define PKEY_ASTERISK 0x28
#define PKEY_9 0x09
#define PKEY_PARENTHESIS_LEFT 0x29
#define PKEY_EQUALS 0x5B
#define PKEY_PARENTHESIS_RIGHT 0x7B
#define PKEY_PLUS 0x0E
#define PKEY_SIGMA 0x2E
#define PKEY_ASSIGN 0x0D
#define PKEY_SHIFT 0x2D
#define PKEY_MINUS 0x0F
#define PKEY_DELTA 0x2F
#define PKEY_DIVIDE 0x0B
#define PKEY_INTERSECT 0x2B
#define PKEY_MULTIPLY 0x0A
#define PKEY_UNION 0x2A
#define PKEY_SEMICOLON 0x5c
#define PKEY_COLON 0x7c
#define PKEY_PERIOD 0x5e
#define PKEY_EXCLAMATION 0x7e
#define PKEY_COMMA 0x5f
#define PKEY_QUOTE 0x7f
#define PKEY_SLASH 0x5d
#define PKEY_QUESTION_MARK 0x7d
#define PKEY_SUPER 0x10
#define PKEY_SUPER1 0x30
#define PKEY_SUB 0x11
#define PKEY_SUB1 0x31
#define PKEY_ANS 0x12
#define PKEY_TERM 0x32
#define PKEY_COPY 0x1B
#define PKEY_COPY1 0x3B
#define PKEY_TAB 0x0c
#define PKEY_CR 0x2c
#define PKEY_ERASE 0x13
#define PKEY_ERASE1 0x33
#define PKEY_MICRO 0x14
#define PKEY_FONT 0x34
#define PKEY_HELP 0x15
#define PKEY_HELP1 0x35
#define PKEY_SQUARE 0x1C
#define PKEY_ACCESS 0x3C
#define PKEY_NEXT 0x16
#define PKEY_NEXT1 0x36
#define PKEY_EDIT 0x17
#define PKEY_EDIT1 0x37
#define PKEY_BACK 0x18
#define PKEY_BACK1 0x38
#define PKEY_LAB 0x1D
#define PKEY_LAB1 0x3D
#define PKEY_DATA 0x19
#define PKEY_DATA1 0x39
#define PKEY_STOP 0x1a
#define PKEY_STOP1 0x3a
#define PKEY_SPACE 0x40
#define PKEY_BACKSPACE 0x60
#define PKEY_PRINT 0x1F
#define PKEY_PRINT1 0x3F
#define PKEY_NOKEY 0xFF /* no key mapping */
/* The following keys require an ACCESS key combination */
#define PKEY_ALPHA 0x80
#define PKEY_BETA 0x81
#define PKEY_CEDILLA 0x82
#define PKEY_LOWERCASE_DELTA 0x83
#define PKEY_ACUTE_ACCENT 0x84
#define PKEY_LOWERCASE_AE 0x85
#define PKEY_LOWERCASE_OE 0x86
#define PKEY_LOWERCASE_A_WITH_RING 0x87
#define PKEY_LOWERCASE_A_WITH_DIAERESIS 0x88
#define PKEY_LAMBDA 0x89
#define PKEY_MU 0x8A
#define PKEY_TILDE 0x8B
#define PKEY_DEGREE 0x8C
#define PKEY_PI 0x8D
#define PKEY_GRAVE 0x8E
#define PKEY_RHO 0x8F
#define PKEY_LOWERCASE_SIGMA 0x90
#define PKEY_THETA 0x91
#define PKEY_DIARESIS 0x92
#define PKEY_HACEK 0x93
#define PKEY_CAPITAL_PI 0x94
#define PKEY_CIRCUMFLEX 0x95
#define PKEY_LEFT_EMBED 0x96
#define PKEY_RIGHT_EMBED 0x97
#define PKEY_AT 0x98
#define PKEY_ARROW 0x99
#define PKEY_AMPERSAND 0x9A
#define PKEY_INTERPUNCT 0x9B
#define PKEY_LOWER_TILDE 0x9C
#define PKEY_DELIMITER 0x9D
#define PKEY_BACKSLASH 0x9E
#define PKEY_NOT_EQUAL 0x9F
#define PKEY_LOWERCASE_O_WITH_DIARESIS 0xA0
#define PKEY_LEFT_ARROW 0xA1
#define PKEY_DOWN_ARROW 0xA2
#define PKEY_RIGHT_ARROW 0xA3
#define PKEY_UP_ARROW 0xA4
#define PKEY_COPYRIGHT 0xA5
#define PKEY_DIAMOND 0xA6
#define PKEY_UPPERCASE_AE 0xA7
#define PKEY_UPPERCASE_OE 0xA8
#define PKEY_BAR 0xA9
#define PKEY_UPPERCASE_A_WITH_RING 0xAA
#define PKEY_UPPERCASE_A_WITH_DIAERESIS 0xAB
#define PKEY_ACCESS_SQUARE 0xAC
#define PKEY_UPPERCASE_O_WITH_DIARESIS 0xAD
#define PKEY_LESS_THAN_OR_EQUAL 0xAE
#define PKEY_GREATER_THAN_OR_EQUAL 0xAF
#define PKEY_LEFT_CURLY_BRACE 0xB0
#define PKEY_RIGHT_CURLY_BRACE 0xB1
#define PKEY_POUND 0xB2
#define PKEY_BIG_CROSS 0xB3
#define PKEY_EQUIVALENT 0xB4
/* ACCESS Key combinations. */
static const unsigned char ACCESS_KEYS[] = {
PKEY_a, /* 0x80 a ɑ alpha */
PKEY_B, /* 0x81 b ß beta */
PKEY_c, /* 0x82 c cedilla */
PKEY_d, /* 0x83 d δ delta */
PKEY_e, /* 0x84 e ' acute accent */
PKEY_g, /* 0x85 g æ ae */
PKEY_h, /* 0x86 h oe oe */
PKEY_j, /* 0x87 j å a with ring */
PKEY_k, /* 0x88 k ä a with diaeresis */
PKEY_l, /* 0x89 l ƛ lambda */
PKEY_m, /* 0x8A m μ mu */
PKEY_n, /* 0x8B n ~ tilde */
PKEY_o, /* 0x8C o ° degree */
PKEY_p, /* 0x8D p π pi */
0x51, /* 0x8E q ` grave */
PKEY_r, /* 0x8F r ρ rho */
PKEY_s, /* 0x90 s σ sigma */
PKEY_t, /* 0x91 t θ theta */
PKEY_u, /* 0x92 u ¨ diaeresis */
PKEY_v, /* 0x93 v hacek (upside down circumflex) */
PKEY_w, /* 0x94 w ϖ capital pi */
PKEY_x, /* 0x95 x ^ circumflex */
PKEY_0, /* 0x96 0 l-embed */
PKEY_1, /* 0x97 1 r-embed */
PKEY_5, /* 0x98 5 @ */
PKEY_6, /* 0x99 6 arrow */
PKEY_PLUS, /* 0x9a + & */
0x26, /* 0x9b & interpunct */
PKEY_COLON, /* 0x9c : ~ lower tilde */
0x5f, /* 0x9d , delimiter */
PKEY_SLASH, /* 0x9e / \ */
PKEY_EQUALS, /* 0x9f = not equal */
PKEY_y, /* 0xA0 y ö */
0x61, /* 0xA1 A left arrow */
0x78, /* 0xA2 X down arrow */
0x64, /* 0xA3 D right arrow */
0x77, /* 0xA4 W up arrow */
0x63, /* 0xA5 C © */
0x66, /* 0xA6 F ♦ */
0x67, /* 0xA7 G Æ */
0x68, /* 0xA8 H OE */
0x69, /* 0xA9 I | */
0x6A, /* 0xAA J Å */
0x6B, /* 0xAB K Ä */
0x6F, /* 0xAC O SQUARE */
0x79, /* 0xAD Y Ö */
0x20, /* 0xAE < ≤ */
0x21, /* 0xAF > ≥ */
0x5B, /* 0xB0 [ { */
PKEY_SLASH, /* 0xB1 ] } */
0x24, /* 0xB2 $ # */
0x9a, /* 0xB3 & big cross */
0x7B /* 0xB4 EQUIVALENT */
};
#endif /* PLATO_KEY_H */

987
protocol.c Executable file
View File

@ -0,0 +1,987 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
* This file written by Steve Peltz. Copyright notice preserved.
* and this code has been used with permission, and can be considered
* public domain.
*
* protocol.c - Protocol decoder functions
*/
/* Copyright (c) 1990 by Steve Peltz */
#include "protocol.h"
#define true 1
#define false 0
#define BSIZE 64
static padBool EscFlag; /* Currently in an escape sequence */
static Mode PMode, /* Mode */
CMode; /* Command */
static unsigned short SubMode; /* Block/Line modes */
static DataType PType, /* Mode type */
CType; /* Current type */
static unsigned short Phase; /* Phase of current type */
static padWord theWord; /* Data received for various data types */
static padByte theChar;
static padByte rawChar;
static padByte lastChar;
static padRGB theColor;
static unsigned short LowX, /* Previous coordinates received */
HiX, LowY, HiY;
static padPt CurCoord; /* Current coordinate */
static padWord Margin; /* Margin for CR */
static padWord MemAddr; /* Load address for program data */
static unsigned short CharCnt; /* Current count for loading chars */
static charData Char; /* Character data */
static padByte charBuff[BSIZE];
static unsigned short charCount; /* Count of characters currently buffered */
static padPt charCoord;
extern unsigned char terminal_get_features(void);
extern unsigned char terminal_get_type(void);
extern unsigned char terminal_get_subtype(void);
extern unsigned char terminal_get_load_file(void);
extern unsigned char terminal_get_configuration(void);
extern unsigned short terminal_get_char_address(void);
extern padByte terminal_mem_read(padWord addr);
extern padByte terminal_ext_in(void);
extern void screen_wait(void);
extern void screen_beep(void);
extern void io_send_byte(unsigned char b);
extern void screen_block_draw(padPt* Coord1, padPt* Coord2);
extern void screen_dot_draw(padPt* Coord);
extern void screen_line_draw(padPt* Coord1, padPt* Coord2);
extern void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count);
extern void screen_tty_char(padByte theChar);
extern void screen_foreground(padRGB* theColor);
extern void screen_background(padRGB* theColor);
extern void screen_paint(padPt* Coord);
extern void terminal_mem_load(padWord addr, padWord value);
extern void terminal_char_load(padWord charnum, charData theChar);
extern void terminal_mode_5(padWord value);
extern void terminal_mode_6(padWord value);
extern void terminal_mode_7(padWord value);
extern void touch_allow(padBool allow);
extern void terminal_ext_allow(padBool allow);
extern void terminal_set_ext_in(padWord device);
extern void terminal_set_ext_out(padWord device);
extern void terminal_ext_out(padByte value);
extern void screen_clear(void);
extern void terminal_set_tty(void);
extern void terminal_set_plato(void);
#ifdef PROTOCOL_DEBUG
extern void log(const char* format, ...);
#endif
static padByte PTAT0[128] = { /* PLATO to ASCII lookup table */
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* original mapping */
0x38, 0x39, 0x26, 0x60, 0x0a, 0x5e, 0x2b, 0x2d,
0x13, 0x04, 0x07, 0x08, 0x7b, 0x0b, 0x0d, 0x1a,
0x02, 0x12, 0x01, 0x03, 0x7d, 0x0c, 0x83, 0x85,
0x3c, 0x3e, 0x5b, 0x5d, 0x24, 0x25, 0x5f, 0x7c,
0x2a, 0x28, 0x40, 0x27, 0x1c, 0x5c, 0x23, 0x7e,
0x17, 0x05, 0x14, 0x19, 0x7f, 0x09, 0x1e, 0x18,
0x0e, 0x1d, 0x11, 0x16, 0x00, 0x0f, 0x87, 0x88,
0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x3d, 0x3b, 0x2f, 0x2e, 0x2c,
0x1f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x29, 0x3a, 0x3f, 0x21, 0x22
};
static padByte PTAT1[128] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* flow control mapping */
0x38, 0x39, 0x26, 0x60, 0x09, 0x5e, 0x2b, 0x2d,
0x17, 0x04, 0x07, 0x08, 0x7b, 0x0b, 0x0d, 0x1a,
0x02, 0x12, 0x01, 0x03, 0x7d, 0x0c, 0x83, 0x85,
0x3c, 0x3e, 0x5b, 0x5d, 0x24, 0x25, 0x5f, 0x27,
0x2a, 0x28, 0x40, 0x7c, 0x1c, 0x5c, 0x23, 0x7e,
0x97, 0x84, 0x14, 0x19, 0x7f, 0x0a, 0x1e, 0x18,
0x0e, 0x1d, 0x05, 0x16, 0x9d, 0x0f, 0x87, 0x88,
0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x3d, 0x3b, 0x2f, 0x2e, 0x2c,
0x1f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x29, 0x3a, 0x3f, 0x21, 0x22
};
/* externally referenced variables */
padPt PLATOSize={512,512}; /* Logical screen size */
CharMem CurMem; /* Font to plot in */
padBool TTY, /* TTY mode */
FlowControl, /* Flow control on */
ModeBold, /* Character plotting conditions */
Rotate, Reverse;
DispMode CurMode; /* Current PLATO plotting mode */
padBool FastText; /* Indicate to main program if text optimizations can be done. */
padBool NoEcho=padF;
/*----------------------------------------------*
* InitPAD, InitTTY, InitPLATO *
* *
* Called to initialize PAD variables. *
* Calls back to external routines to *
* set up proper plotting conditions. *
*----------------------------------------------*/
void
InitPAD (void)
{
InitTTY ();
}
void
InitTTY (void)
{
charCount = 0;
EscFlag = false;
TTY = true;
FastText = true;
FlowControl = false;
terminal_set_tty();
}
void
InitPLATO (void)
{
if (TTY)
InitPLATOx ();
}
void
InitPLATOx (void)
{
charCount = 0;
EscFlag = false;
TTY = false;
terminal_set_plato ();
SetMode (mAlpha, tByte);
LowX = 0;
HiX = 0;
LowY = 0;
HiY = 0;
CurCoord.x = 0;
CurCoord.y = 0;
MemAddr = 0;
CharCnt = 0;
Margin = 0;
ModeBold = false;
Rotate = false;
Reverse = false;
FastText = true;
CurMem = M0;
CurMode = ModeRewrite;
}
/*----------------------------------------------*
* Key *
* *
* Send a 10-bit internal key. If a keyset *
* key, translate, else send as escaped *
* sequence. *
*----------------------------------------------*/
void
Key (padWord theKey)
{
if (theKey >> 7)
{
io_send_byte (0x1b);
io_send_byte (0x40 | (theKey & 0x3f));
io_send_byte (0x60 | ((theKey >> 6) & 0x0f));
}
else
{
if (FlowControl == 0)
theKey = PTAT0[theKey];
else
theKey = PTAT1[theKey];
if (theKey & 0x80)
{
io_send_byte (0x1b);
io_send_byte (theKey & 0x7f);
}
else
io_send_byte (theKey);
}
}
/*----------------------------------------------*
* Touch *
* *
* Send a touch key (01yyyyxxxx). *
*----------------------------------------------*/
void Touch(padPt* where)
{
io_send_byte(0x1b);
io_send_byte(0x1f);
io_send_byte(0x40 + (where->x & 0x1f));
io_send_byte(0x40 + ((where->x >> 5) & 0x0f));
io_send_byte(0x40 + (where->y & 0x1f));
io_send_byte(0x40 + ((where->y >> 5) & 0x0f));
Key(0x100 | ((where->x >> 1) & 0xF0) |
((where->y >> 5) & 0x0F));
}
/*----------------------------------------------*
* Ext *
* *
* Send an external key (10xxxxxxxx). *
*----------------------------------------------*/
void
Ext (padWord theKey)
{
Key (0x200 | (theKey & 0xFF));
}
/*----------------------------------------------*
* Echo *
* *
* Send an echo key (001xxxxxx). *
*----------------------------------------------*/
void
Echo (padWord theKey)
{
if (NoEcho==padT)
return;
Key (0x080 | theKey);
}
/*----------------------------------------------*
* SetCommand, SetMode *
* *
* Set state machine variables. *
*----------------------------------------------*/
void
SetCommand (Mode theMode, DataType theType)
{
CMode = theMode;
CType = theType;
Phase = 0;
}
void
SetMode (Mode theMode, DataType theType)
{
PMode = theMode;
PType = theType;
SubMode = 0;
SetCommand (theMode, theType);
}
/*----------------------------------------------*
* FixXY *
* *
* Move location by offset, then make sure *
* it is still on the screen. *
*----------------------------------------------*/
void
FixXY (short DX, short DY)
{
if (ModeBold)
{
DX = DX * 2;
DY = DY * 2;
}
if (Reverse)
DX = -DX;
if (Rotate)
{
CurCoord.x = CurCoord.x + DY;
CurCoord.y = CurCoord.y + DX;
}
else
{
CurCoord.x = CurCoord.x + DX;
CurCoord.y = CurCoord.y + DY;
}
if (CurCoord.x < 0)
CurCoord.x += PLATOSize.x;
else if (CurCoord.x >= PLATOSize.x)
CurCoord.x -= PLATOSize.x;
if (CurCoord.y < 0)
CurCoord.y += PLATOSize.y;
else if (CurCoord.y >= PLATOSize.y)
CurCoord.y -= PLATOSize.y;
}
/*----------------------------------------------*
* Superx, Subx, etc. *
* *
* Various character positioning commands. *
*----------------------------------------------*/
void
Superx (void)
{
FixXY (0, 5);
}
void
Subx (void)
{
FixXY (0, -5);
}
void
Marginx (void)
{
if (Rotate)
Margin = CurCoord.y;
else
Margin = CurCoord.x;
}
void
BSx (void)
{
FixXY (-8, 0);
}
void
HTx (void)
{
FixXY (8, 0);
}
void
LFx (void)
{
FixXY (0, -16);
}
void
VTx (void)
{
FixXY (0, 16);
}
void
FFx (void)
{
CurCoord.y = 0;
CurCoord.x = 0;
LFx ();
}
void
CRx (void)
{
if (Rotate)
CurCoord.y = Margin;
else
CurCoord.x = Margin;
LFx ();
}
/*----------------------------------------------*
* LoadCoordx *
* *
* Assemble completed coordinate. *
*----------------------------------------------*/
void
LoadCoordx (padPt * SetCoord)
{
SetCoord->x = (HiX << 5) + LowX;
SetCoord->y = (HiY << 5) + LowY;
}
/*----------------------------------------------*
* Blockx, Pointx, Linex, Alphax *
* *
* Plot the specified item at the *
* current location. *
*----------------------------------------------*/
void
Blockx (void)
{
padPt NewCoord;
if (SubMode == 0)
{
LoadCoordx (&CurCoord);
SubMode = 1;
}
else
{
LoadCoordx (&NewCoord);
screen_block_draw (&CurCoord, &NewCoord);
SubMode = 0;
CurCoord.y-=15;
CurCoord.x+=16;
}
}
void
Pointx (void)
{
LoadCoordx (&CurCoord);
screen_dot_draw (&CurCoord);
}
void
Linex (void)
{
padPt OldCoord;
if (SubMode == 0)
{
LoadCoordx (&CurCoord);
SubMode = 1;
}
else
{
OldCoord.y = CurCoord.y;
OldCoord.x = CurCoord.x;
LoadCoordx (&CurCoord);
screen_line_draw (&OldCoord, &CurCoord);
}
}
void
Alphax (void)
{
if (charCount == 0)
charCoord = CurCoord;
charBuff[charCount++] = theChar;
HTx ();
if (charCount >= BSIZE)
{
screen_char_draw (&charCoord, charBuff, charCount);
charCount = 0;
}
}
/*----------------------------------------------*
* LoadEchox *
* *
* Echo responses to system. *
*----------------------------------------------*/
void
LoadEchox (void)
{
theWord &= 0x7f;
switch (theWord)
{
case 0x52:
FlowControl=true;
if (FlowControl)
Echo (0x53); /* flow control on */
else
Echo (0x52); /* flow control not on */
break;
case 0x60: /* Inquire about ascii specific features. */
Echo (terminal_get_features());
break;
case 0x70:
Echo (terminal_get_type ()); /* terminal type */
break;
case 0x71:
Echo (terminal_get_subtype()); /* subtype */
break;
case 0x72:
Echo (terminal_get_load_file ()); /* load file */
break;
case 0x73:
Echo (terminal_get_configuration ()); /* configuration */
break;
case 0x7A:
Key (0x3FF); /* send backout */
break;
case 0x7B:
screen_beep ();
break; /* beep */
case 0x7D:
Echo (terminal_mem_read (MemAddr) & 0x7F);
break;
default:
Echo (theWord); /* normal echo */
break;
}
}
void
LoadAddrx (void)
{
MemAddr = theWord;
CharCnt = 0;
}
void
LoadCharx (void)
{
Char[CharCnt] = theWord;
if (CharCnt < 7)
CharCnt++;
else
{
terminal_char_load ((((MemAddr - terminal_get_char_address ()) >> 4) & 0x7f), Char);
CharCnt = 0;
MemAddr += 16;
}
}
void
LoadMemx (void)
{
terminal_mem_load (MemAddr, theWord);
MemAddr += 2;
}
void
SSFx (void)
{
padByte device;
device = (theWord >> 10) & 0xFF;
if (device == 1)
{
terminal_ext_allow ((theWord >> 3) & 1);
touch_allow ((theWord >> 5) & 1);
}
else if ((theWord >> 9) & 1)
{
terminal_set_ext_in (device);
if (!((theWord >> 8) & 1))
Ext (terminal_ext_in ());
}
else
{
terminal_set_ext_out (device);
if (!((theWord >> 8) & 1))
terminal_ext_out (theWord & 0xFF);
}
}
void
Externalx (void)
{
terminal_ext_out ((theWord >> 8) & 0xFF);
terminal_ext_out (theWord & 0xFF);
}
void
GoMode (void)
{
switch (CMode)
{
case mBlock:
Blockx ();
break;
case mPoint:
Pointx ();
break;
case mLine:
Linex ();
break;
case mAlpha:
Alphax ();
break;
case mLoadCoord:
LoadCoordx (&CurCoord);
break;
case mLoadAddr:
LoadAddrx ();
break;
case mSSF:
SSFx ();
break;
case mExternal:
Externalx ();
break;
case mLoadEcho:
LoadEchox ();
break;
case mLoadChar:
LoadCharx ();
break;
case mLoadMem:
LoadMemx ();
break;
case mMode5:
terminal_mode_5 (theWord);
break;
case mMode6:
terminal_mode_6 (theWord);
break;
case mMode7:
terminal_mode_7 (theWord);
break;
case mFore:
screen_foreground(&theColor);
break;
case mBack:
screen_background(&theColor);
break;
case mPaint:
screen_paint(&CurCoord);
break;
}
CMode = PMode;
CType = PType;
Phase = 0;
}
void
GoWord (void)
{
switch (Phase)
{
case 0:
theWord = theChar & 0x3F;
Phase = 1;
break;
case 1:
theWord |= ((theChar & 0x3F) << 6);
Phase = 2;
break;
case 2:
theWord |= ((theChar & 0x3F) << 12);
GoMode ();
break;
}
}
void
GoCoord (void)
{
unsigned short CoordType, CoordValue;
CoordValue = theChar & 0x1F;
CoordType = ((theChar >> 5) & 3);
switch (CoordType)
{
case 1:
switch (Phase)
{
case 0:
HiY = CoordValue;
break;
case 1:
HiX = CoordValue;
break;
}
Phase = 1;
break;
case 2:
LowX = CoordValue;
GoMode ();
break;
case 3:
LowY = CoordValue;
Phase = 1;
break;
}
}
void
GoColor (void)
{
switch (Phase)
{
case 0:
theColor.blue = (theChar & 0x3f);
break;
case 1:
theColor.blue |= (theChar & 0x03) << 6;
theColor.green = (theChar & 0x3c) >> 2;
break;
case 2:
theColor.green |= (theChar & 0x0f) << 4;
theColor.red = (theChar & 0x30) >> 4;
break;
case 3:
theColor.red |= (theChar & 0x3f) << 2;
break;
}
if (Phase < 3)
Phase++;
else
GoMode ();
}
void
GoPaint (void)
{
if (Phase == 0)
Phase = 1;
else
GoMode ();
}
void
DataChar (void)
{
switch (CType)
{
case tByte:
Alphax ();
break;
case tWord:
GoWord ();
break;
case tCoord:
GoCoord ();
break;
case tColor:
GoColor ();
break;
case tPaint:
GoPaint ();
break;
}
}
void
ShowPLATO (padByte *buff, unsigned short count)
{
while (count--)
{
theChar = *buff++;
if (lastChar==0xFF && theChar==0xFF)
{
lastChar=0;
}
else
{
rawChar=theChar;
theChar &=0x7F;
if (TTY)
{
if (!EscFlag)
screen_tty_char (theChar);
else if (theChar == 0x02)
InitPLATOx ();
}
else if (EscFlag)
{
switch (theChar)
{
case 0x03:
InitTTY ();
break;
case 0x0C:
screen_clear ();
break;
case 0x11:
CurMode = ModeInverse;
SetFast();
break;
case 0x12:
CurMode = ModeWrite;
SetFast();
break;
case 0x13:
CurMode = ModeErase;
SetFast();
break;
case 0x14:
CurMode = ModeRewrite;
SetFast();
break;
case 0x32:
SetCommand (mLoadCoord, tCoord);
break;
case 0x40:
Superx ();
break;
case 0x41:
Subx ();
break;
case 0x42:
CurMem = M0;
break;
case 0x43:
CurMem = M1;
break;
case 0x44:
CurMem = M2;
break;
case 0x45:
CurMem = M3;
break;
case 0x4A:
Rotate = false;
SetFast();
break;
case 0x4B:
Rotate = true;
SetFast();
break;
case 0x4C:
Reverse = false;
SetFast();
break;
case 0x4D:
Reverse = true;
SetFast();
break;
case 0x4E:
ModeBold = false;
SetFast();
break;
case 0x4F:
ModeBold = true;
SetFast();
break;
case 0x50:
SetMode (mLoadChar, tWord);
break;
case 0x51:
SetCommand (mSSF, tWord);
break;
case 0x52:
SetCommand (mExternal, tWord);
break;
case 0x53:
SetMode (mLoadMem, tWord);
break;
case 0x54:
SetMode (mMode5, tWord);
break;
case 0x55:
SetMode (mMode6, tWord);
break;
case 0x56:
SetMode (mMode7, tWord);
break;
case 0x57:
SetCommand (mLoadAddr, tWord);
break;
case 0x59:
SetCommand (mLoadEcho, tWord);
break;
case 0x5A:
Marginx ();
break;
case 0x61:
SetCommand (mFore, tColor);
break;
case 0x62:
SetCommand (mBack, tColor);
break;
case 0x63:
SetCommand (mPaint, tPaint);
break;
}
}
else if (theChar < 0x20)
{
if (charCount > 0)
{
screen_char_draw (&charCoord, charBuff, charCount);
charCount = 0;
}
switch (theChar)
{
case 0x00:
screen_wait();
case 0x08:
BSx ();
break;
case 0x09:
HTx ();
break;
case 0x0A:
LFx ();
break;
case 0x0B:
VTx ();
break;
case 0x0C:
FFx ();
break;
case 0x0D:
CRx ();
break;
case 0x19:
SetMode (mBlock, tCoord);
break;
case 0x1C:
SetMode (mPoint, tCoord);
break;
case 0x1D:
SetMode (mLine, tCoord);
break;
case 0x1F:
SetMode (mAlpha, tByte);
break;
}
}
else
DataChar ();
EscFlag = (theChar == 0x1B);
lastChar=rawChar;
}
}
if (charCount > 0)
{
screen_char_draw (&charCoord, charBuff, charCount);
charCount = 0;
}
}
/**
* SetFast()
* Toggle fast text output if mode = write or erase, and no rotate or bold
*/
void SetFast(void)
{
FastText = (((CurMode == ModeWrite) || (CurMode == ModeErase)) && ((Rotate == padF) && (ModeBold == padF)));
}

95
protocol.h Executable file
View File

@ -0,0 +1,95 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
* This file written by Steve Peltz. Copyright notice preserved.
* and this code has been used with permission, and can be considered
* public domain.
*
* protocol.h - Protocol decoder functions
*/
/* Copyright (c) 1990 by Steve Peltz */
#ifndef PROTOCOL_H
#define PROTOCOL_H
#define ACCESS 0x3c
typedef unsigned char padByte;
typedef enum {padF, padT} padBool;
typedef unsigned char padChar;
typedef short padWord;
typedef padWord charData[8];
typedef struct {
padByte red,
green,
blue;
} padRGB;
typedef struct {
padWord x,
y;
} padPt;
typedef enum {ModeWrite, ModeErase, ModeRewrite, ModeInverse} DispMode;
typedef enum {M0, M1, M2, M3} CharMem;
typedef enum { mBlock, mPoint, mLine, mAlpha, mLoadCoord, mLoadChar, mSSF,
mExternal, mLoadMem, mMode5, mMode6, mMode7, mLoadAddr,
mLoadEcho, mFore, mBack, mPaint } Mode;
typedef enum { tByte, tWord, tCoord, tColor, tPaint } DataType;
extern padPt PLATOSize;
extern CharMem CurMem;
extern padBool TTY,
FlowControl,
ModeBold,
Rotate,
Reverse;
extern DispMode CurMode;
extern padBool NoEcho;
void InitPAD(void);
void InitTTY(void);
void InitPLATO(void);
void InitPLATOx(void);
void Key(padWord theKey);
void Touch(padPt* where);
void Ext(padWord theKey);
void Echo(padWord theKey);
void SetCommand(Mode theMode, DataType theType);
void SetMode(Mode theMode, DataType theType);
void FixXY(short DX, short DY);
void Superx(void);
void Subx(void);
void Marginx(void);
void BSx(void);
void HTx(void);
void LFx(void);
void VTx(void);
void FFx(void);
void CRx(void);
void LoadCoordx(padPt* SetCoord);
void Blockx(void);
void Pointx(void);
void Linex(void);
void Alphax(void);
void LoadEchox(void);
void LoadAddrx(void);
void LoadCharx(void);
void LoadMemx(void);
void SSFx(void);
void Externalx(void);
void GoMode(void);
void GoWord(void);
void GoCoord(void);
void GoColor(void);
void GoPaint(void);
void DataChar(void);
void ShowPLATO(padByte* buff, unsigned short count);
void SetFast(void);
#endif

599
screen.c Normal file
View File

@ -0,0 +1,599 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "screen.h"
#include "font.h"
#include "protocol.h"
#include "io.h"
#define true 1
#define false 0
#define FONTPTR(a) (a<<4)
#define X(x) (x)
#define Y(y) (y^0x1FF)
char tmp[64];
int previousMode;
unsigned char CharWide=8;
unsigned char CharHigh=16;
padPt TTYLoc;
padPt statusLoc={0,0};
unsigned char fontm23[2048];
extern padBool FastText; /* protocol.c */
padRGB palette[16];
unsigned long current_foreground=1;
unsigned long current_background=0;
padRGB current_foreground_rgb={255,255,255};
padRGB current_background_rgb={0,0,0};
int highest_color_index;
padRGB palette_help[16];
padRGB palette_backup[16];
unsigned long current_foreground_backup=1;
unsigned long current_background_backup=0;
padRGB current_foreground_rgb_backup={255,255,255};
padRGB current_background_rgb_backup={0,0,0};
int highest_color_index_backup;
unsigned char help_active=false;
/**
* screen_init() - Set up the screen
*/
void screen_init(void)
{
}
/**
* screen_update_colors() - Set the terminal colors
*/
void screen_update_colors(void)
{
}
/**
* screen_clear_palette - Clear the palette
*/
void screen_clear_palette(void)
{
int i;
for (i=0;i<8;i++)
{
palette[i].red=0;
palette[i].green=0;
palette[i].blue=0;
}
}
/**
* screen_wait(void) - Sleep for approx 16.67ms
*/
void screen_wait(void)
{
}
/**
* screen_beep(void) - Beep the terminal
*/
void screen_beep(void)
{
}
/**
* screen_clear - Clear the screen
*/
void screen_clear(void)
{
}
/**
* screen_color_matching(color) - return index of matching color, or a new index,
* if not found.
*/
unsigned char screen_color_matching(padRGB* theColor)
{
unsigned char i;
for (i=0;i<8;i++)
{
if (i>highest_color_index)
{
palette[i].red=theColor->red;
palette[i].green=theColor->green;
palette[i].blue=theColor->blue;
highest_color_index++;
return i;
}
else
{
if ((palette[i].red==theColor->red) &&
(palette[i].green==theColor->green) &&
(palette[i].blue==theColor->blue))
{
return i;
}
}
}
}
/**
* screen_foreground - set foreground color
*/
void screen_foreground(padRGB* theColor)
{
current_foreground_rgb.red=theColor->red;
current_foreground_rgb.green=theColor->green;
current_foreground_rgb.blue=theColor->blue;
current_foreground=screen_color_matching(theColor);
screen_update_colors();
}
/**
* screen_background - set background_color
*/
void screen_background(padRGB* theColor)
{
current_background_rgb.red=theColor->red;
current_background_rgb.green=theColor->green;
current_background_rgb.blue=theColor->blue;
current_background=screen_color_matching(theColor);
screen_update_colors();
}
/**
* screen_current_color(void) - Set the current pen mode
*/
int screen_current_color(void)
{
if (CurMode==ModeInverse || CurMode==ModeErase)
return current_background;
else
return current_foreground;
}
/**
* screen_block_draw(Coord1, Coord2) - Perform a block fill from Coord1 to Coord2
*/
void screen_block_draw(padPt* Coord1, padPt* Coord2)
{
}
/**
* screen_dot_draw(Coord) - Plot a mode 0 pixel
*/
void screen_dot_draw(padPt* Coord)
{
}
/**
* screen_line_draw(Coord1, Coord2) - Draw a mode 1 line
*/
void screen_line_draw(padPt* Coord1, padPt* Coord2)
{
}
/**
* screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
*/
void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
{
short offset; /* due to negative offsets */
unsigned short x; /* Current X and Y coordinates */
unsigned short y;
unsigned short* px; /* Pointers to X and Y coordinates used for actual plotting */
unsigned short* py;
unsigned char i; /* current character counter */
unsigned char a; /* current character byte */
unsigned char j,k; /* loop counters */
char b; /* current character row bit signed */
unsigned char width=8;
unsigned char height=16;
unsigned char FONT_SIZE_X=8;
unsigned char FONT_SIZE_Y=16;
unsigned short deltaX=1;
unsigned short deltaY=1;
unsigned char mainColor=1;
unsigned char altColor=0;
unsigned char *p;
unsigned char* curfont;
switch(CurMem)
{
case M0:
curfont=font;
offset=-32;
break;
case M1:
curfont=font;
offset=64;
break;
case M2:
curfont=fontm23;
offset=-32;
break;
case M3:
curfont=fontm23;
offset=32;
break;
}
if (CurMode==ModeRewrite)
{
altColor=current_background;
}
else if (CurMode==ModeInverse)
{
altColor=current_foreground;
}
if (CurMode==ModeErase || CurMode==ModeInverse)
mainColor=current_background;
else
mainColor=current_foreground;
x=X(Coord->x&0x1FF);
if (ModeBold)
y=Y((Coord->y)+30&0x1FF);
else
y=Y((Coord->y)+15&0x1FF);
if (FastText==padF)
{
goto chardraw_with_fries;
}
/* the diet chardraw routine - fast text output. */
for (i=0;i<count;++i)
{
a=*ch;
++ch;
a+=offset;
p=&curfont[FONTPTR(a)];
for (j=0;j<FONT_SIZE_Y;++j)
{
b=*p;
for (k=0;k<FONT_SIZE_X;++k)
{
if (b<0) /* check sign bit. */
{
/* pset(x,y,mainColor); */
}
++x;
b<<=1;
}
++y;
x-=width;
++p;
}
x+=width;
y-=height;
}
return;
chardraw_with_fries:
if (Rotate)
{
deltaX=-abs(deltaX);
width=-abs(width);
px=&y;
py=&x;
}
else
{
px=&x;
py=&y;
}
if (ModeBold)
{
deltaX = deltaY = 2;
width<<=1;
height<<=1;
}
for (i=0;i<count;++i)
{
a=*ch;
++ch;
a+=offset;
p=&curfont[FONTPTR(a)];
for (j=0;j<FONT_SIZE_Y;++j)
{
b=*p;
if (Rotate)
{
px=&y;
py=&x;
}
else
{
px=&x;
py=&y;
}
for (k=0;k<FONT_SIZE_X;++k)
{
if (b<0) /* check sign bit. */
{
if (ModeBold)
{
/* pset(*px+1,*py,mainColor); */
/* pset(*px,*py+1,mainColor); */
/* pset(*px+1,*py+1,mainColor); */
}
/* pset(*px,*py,mainColor); */
}
else
{
if (CurMode==ModeInverse || CurMode==ModeRewrite)
{
if (ModeBold)
{
/* pset(*px+1,*py,altColor); */
/* pset(*px,*py+1,altColor); */
/* pset(*px+1,*py+1,altColor); */
}
/* pset(*px,*py,altColor); */
}
}
x += deltaX;
b<<=1;
}
y+=deltaY;
x-=width;
++p;
}
Coord->x+=width;
x+=width;
y-=height;
}
return;
}
/**
* screen_tty_char - Called to plot chars when in tty mode
*/
void screen_tty_char(padByte theChar)
{
if ((theChar >= 0x20) && (theChar < 0x7F)) {
screen_char_draw(&TTYLoc, &theChar, 1);
TTYLoc.x += CharWide;
}
else if ((theChar == 0x0b)) /* Vertical Tab */
{
TTYLoc.y += CharHigh;
}
else if ((theChar == 0x08) && (TTYLoc.x > 7)) /* backspace */
{
padPt ec1,ec2;
TTYLoc.x -= CharWide;
ec1.x=TTYLoc.x;
ec1.y=TTYLoc.y;
ec2.x=TTYLoc.x+CharWide;
ec2.y=TTYLoc.y+CharHigh;
CurMode=ModeErase;
screen_block_draw(&ec1,&ec2);
CurMode=ModeRewrite;
}
else if (theChar == 0x0A) /* line feed */
TTYLoc.y -= CharHigh;
else if (theChar == 0x0D) /* carriage return */
TTYLoc.x = 0;
if (TTYLoc.x + CharWide > 511) { /* wrap at right side */
TTYLoc.x = 0;
TTYLoc.y -= CharHigh;
}
if (TTYLoc.y < 0) {
screen_clear();
TTYLoc.y=495;
}
}
/**
* screen_paint - Called to paint at location.
*/
void screen_paint(padPt* Coord)
{
}
/**
* screen_clear_status(void)
* Clear status area
*/
void screen_clear_status(void)
{
}
/**
* screen_show_status(msg)
*/
void screen_show_status(unsigned char* msg)
{
int previous_foreground=current_foreground;
int previous_background=current_background;
padPt coord={0,0};
screen_clear_status();
current_foreground=0;
current_background=1;
screen_char_draw(&coord,msg,strlen(msg));
current_foreground=previous_foreground;
current_background=previous_background;
}
/**
* screen_show_baud_rate - Show baud rate
*/
void screen_show_baud_rate(int baud)
{
sprintf(tmp,"%d Baud",baud);
screen_show_status(tmp);
}
/**
* screen_show_dial - Show dial in TTY mode
*/
void screen_show_dial(void)
{
}
/**
* screen_show_hang_up - Show hang-up message
*/
void screen_show_hang_up(void)
{
screen_show_status("Hanging up...");
}
/**
* screen_show_dialing_status - Show dialing status.
*/
void screen_show_dialing_status(void)
{
screen_show_status("Dialing...");
}
/**
* screen_help_save_palette(void) - Save initial help palette
* for future restore by screen_help_restore_palette(void)
*/
void screen_help_save_palette(void)
{
int i;
for (i=0;i<16;i++)
{
palette_help[i].red=palette[i].red;
palette_help[i].green=palette[i].green;
palette_help[i].blue=palette[i].blue;
}
}
/**
* screen_help_restore_palette(void) - Restore the help
* palette, because the help screen is visible.
*/
void screen_help_restore_palette(void)
{
int i;
for (i=0;i<16;i++)
{
palette[i].red=palette_help[i].red;
palette[i].green=palette_help[i].green;
palette[i].blue=palette_help[i].blue;
}
screen_update_colors();
}
/**
* screen_save_palette(void) - Save current screen palette state
* for restore by screen_restore_palette(void)
*/
void screen_save_palette(void)
{
int i;
current_foreground_backup=current_foreground;
current_background_backup=current_background;
current_foreground_rgb_backup.red=current_foreground_rgb.red;
current_foreground_rgb_backup.green=current_foreground_rgb.green;
current_foreground_rgb_backup.blue=current_foreground_rgb.blue;
current_background_rgb_backup.red=current_background_rgb.red;
current_background_rgb_backup.green=current_background_rgb.green;
current_background_rgb_backup.blue=current_background_rgb.blue;
highest_color_index_backup=highest_color_index;
for (i=0;i<16;i++)
{
palette_backup[i].red=palette[i].red;
palette_backup[i].green=palette[i].green;
palette_backup[i].blue=palette[i].blue;
}
}
/**
* screen_restore_palette(void) - Restore current screen palette
* upon return from help screen.
*/
void screen_restore_palette(void)
{
int i;
current_foreground=current_foreground_backup;
current_background=current_background_backup;
current_foreground_rgb.red=current_foreground_rgb_backup.red;
current_foreground_rgb.green=current_foreground_rgb_backup.green;
current_foreground_rgb.blue=current_foreground_rgb_backup.blue;
current_background_rgb.red=current_background_rgb_backup.red;
current_background_rgb.green=current_background_rgb_backup.green;
current_background_rgb.blue=current_background_rgb_backup.blue;
highest_color_index=highest_color_index_backup;
for (i=0;i<16;i++)
{
palette[i].red=palette_backup[i].red;
palette[i].green=palette_backup[i].green;
palette[i].blue=palette_backup[i].blue;
}
screen_update_colors();
}
/**
* screen_show_help - SHow help
*/
void screen_show_help(void)
{
}
/**
* screen_trace_status - Show trace status
*/
void screen_trace_status(const char* status)
{
char tmp_status_msg[13];
sprintf(tmp_status_msg,"TRACE: %s",status);
screen_show_status(tmp_status_msg);
}
/**
* screen_help_mode_status(void)
* Put help mode status at bottom of help screen
*/
void screen_help_mode_status(void)
{
screen_show_status("HELP Mode - Press any key to return to terminal.");
}
/**
* screen_greeting(void)
* show initial greeting
*/
void screen_greeting(void)
{
/* sprintf(tmp,"v1.0 Ready - %5d baud - Press HELP for keys.",config.baud); */
screen_show_status(tmp);
}
/**
* screen_done()
* Close down TGI
*/
void screen_done(void)
{
}

168
screen.h Executable file
View File

@ -0,0 +1,168 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* screen.h - Display output functions
*/
#ifndef SCREEN_H
#define SCREEN_H
#include "protocol.h"
/**
* screen_init() - Set up the screen
*/
void screen_init(void);
/**
* screen_update_colors() - Set the terminal colors
*/
void screen_update_colors(void);
/**
* screen_wait(void) - Sleep for approx 16.67ms
*/
void screen_wait(void);
/**
* screen_beep(void) - Beep the terminal
*/
void screen_beep(void);
/**
* screen_clear_palette - Clear the palette
*/
void screen_clear_palette(void);
/**
* screen_clear - Clear the screen
*/
void screen_clear(void);
/**
* screen_current_color(void) - Set the current pen mode
*/
int screen_current_color(void);
/**
* screen_block_draw(Coord1, Coord2) - Perform a block fill from Coord1 to Coord2
*/
void screen_block_draw(padPt* Coord1, padPt* Coord2);
/**
* screen_dot_draw(Coord) - Plot a mode 0 pixel
*/
void screen_dot_draw(padPt* Coord);
/**
* screen_line_draw(Coord1, Coord2) - Draw a mode 1 line
*/
void screen_line_draw(padPt* Coord1, padPt* Coord2);
/**
* screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
*/
void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count);
/**
* screen_tty_char - Called to plot chars when in tty mode
*/
void screen_tty_char(unsigned char theChar);
/**
* screen_color_matching(color) - return index of matching color, or a new index,
* if not found.
*/
unsigned char screen_color_matching(padRGB* theColor);
/**
* screen_foreground - Called to set foreground color.
*/
void screen_foreground(padRGB* theColor);
/**
* screen_background - Called to set foreground color.
*/
void screen_background(padRGB* theColor);
/**
* screen_paint - Called to paint at location.
*/
void screen_paint(padPt* Coord);
/**
* screen_show_baud_rate - Show baud rate
*/
void screen_show_baud_rate(int baud);
/**
* screen_show_hang_up - Show hang-up message
*/
void screen_show_hang_up(void);
/**
* screen_show_dial - Show dial in TTY mode
*/
void screen_show_dial(void);
/**
* screen_show_dialing_status - Show dialing status.
*/
void screen_show_dialing_status(void);
/**
* screen_help_save_palette(void) - Save initial help palette
* for future restore by screen_help_restore_palette(void)
*/
void screen_help_save_palette(void);
/**
* screen_help_restore_palette(void) - Restore the help
* palette, because the help screen is visible.
*/
void screen_help_restore_palette(void);
/**
* screen_save_palette(void) - Save current screen palette state
* for restore by screen_restore_palette(void)
*/
void screen_save_palette(void);
/**
* screen_restore_palette(void) - Restore current screen palette
* upon return from help screen.
*/
void screen_restore_palette(void);
/**
* screen_show_help - SHow help
*/
void screen_show_help(void);
/**
* screen_trace_status - Show trace status
*/
void screen_trace_status(const char* status);
/**
* screen_help_mode_status(void)
* Put help mode status at bottom of help screen
*/
void screen_help_mode_status(void);
/**
* screen_greeting(void)
* show initial greeting
*/
void screen_greeting(void);
/**
* screen_done()
* Close down TGI
*/
void screen_done(void);
#endif /* SCREEN_H */

1940
splash.h Executable file

File diff suppressed because it is too large Load Diff

246
terminal.c Executable file
View File

@ -0,0 +1,246 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* terminal.c - Terminal state functions
*/
/* Some functions are intentionally stubbed. */
#pragma warn(unused-param, off)
#include <string.h>
#include "terminal.h"
#include "screen.h"
#include "protocol.h"
/**
* ASCII Features to return in Features
*/
#define ASC_ZFGT 0x01
#define ASC_ZPCKEYS 0x02
#define ASC_ZKERMIT 0x04
#define ASC_ZWINDOW 0x08
#define true 1
#define false 0
/**
* protocol.c externals
*/
extern CharMem CurMem;
extern padBool TTY;
extern padBool ModeBold;
extern padBool Rotate;
extern padBool Reverse;
extern DispMode CurMode;
extern padBool FlowControl;
/**
* screen.c externals
*/
extern unsigned char CharWide;
extern unsigned char CharHigh;
extern padPt TTYLoc;
extern unsigned char already_started;
#define FONTPTR(a) (a<<4)
extern unsigned char fontm23[2048];
static unsigned char BTAB[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
static unsigned char u;
static unsigned char curr_word;
/**
* terminal_init()
* Initialize terminal state
*/
void terminal_init(void)
{
terminal_set_tty();
}
/**
* terminal_initial_position()
* Set terminal initial position after splash screen.
*/
void terminal_initial_position(void)
{
TTYLoc.x=0;
TTYLoc.y=239; }
/**
* terminal_set_tty(void) - Switch to TTY mode
*/
void terminal_set_tty(void)
{
if (already_started)
screen_clear();
TTY=true;
ModeBold=padF;
Rotate=padF;
Reverse=padF;
CurMem=M0;
CurMode=ModeRewrite;
/* CurMode=ModeWrite; /\* For speed reasons. *\/ */
CharWide=8;
CharHigh=16;
TTYLoc.x = 0;
TTYLoc.y = 495;
screen_show_status("TTY Mode");
}
/**
* terminal_set_plato(void) - Switch to PLATO mode
*/
void terminal_set_plato(void)
{
TTY=false;
screen_clear();
screen_show_status("PLATO Mode");
}
/**
* terminal_get_features(void) - Inquire about terminal ASCII features
*/
unsigned char terminal_get_features(void)
{
return ASC_ZFGT; /* This terminal can do Fine Grained Touch (FGT) */
}
/**
* terminal_get_type(void) - Return the appropriate terminal type
*/
unsigned char terminal_get_type(void)
{
return 12; /* ASCII terminal type */
}
/**
* terminal_get_subtype(void) - Return the appropriate terminal subtype
*/
unsigned char terminal_get_subtype(void)
{
return 1; /* ASCII terminal subtype IST-III */
}
/**
* terminal_get_load_file(void) - Return the appropriate terminal loadfile (should just be 0)
*/
unsigned char terminal_get_load_file(void)
{
return 0; /* This terminal does not load its resident from the PLATO system. */
}
/**
* terminal_get_configuration(void) - Return the terminal configuration
*/
unsigned char terminal_get_configuration(void)
{
return 0x40; /* Touch panel is present. */
}
/**
* terminal_get_char_address(void) - Return the base address of the character set.
*/
unsigned short terminal_get_char_address(void)
{
return 0x3000; /* What the? Shouldn't this be 0x3800? */
}
/**
* terminal_mem_read - Read a byte of program memory.
* not needed for our terminal, but must
* be decoded.
*/
padByte terminal_mem_read(padWord addr)
{
return (0xFF);
}
/**
* terminal_mem_load - Write a byte to non-character memory.
* not needed for our terminal, but must be decoded.
*/
void terminal_mem_load(padWord addr, padWord value)
{
/* Not Implemented */
}
/**
* Mode5, 6, and 7 are basically stubbed.
*/
void terminal_mode_5(padWord value)
{
}
void terminal_mode_6(padWord value)
{
}
void terminal_mode_7(padWord value)
{
}
/**
* terminal_ext_allow - External Input allowed. Not implemented.
*/
void terminal_ext_allow(padBool allow)
{
/* Not Implemented */
}
/**
* terminal_set_ext_in - Set which device to get input from.
* Not implemented
*/
void terminal_set_ext_in(padWord device)
{
}
/**
* terminal_set_ext_out - Set which device to send external data to.
* Not implemented
*/
void terminal_set_ext_out(padWord device)
{
}
/**
* terminal_ext_in - get an external input from selected device.
* Not implemented.
*/
padByte terminal_ext_in(void)
{
return 0;
}
/**
* terminal_ext_out - Send an external output to selected device
* Not implemented.
*/
void terminal_ext_out(padByte value)
{
}
/**
* terminal_char_load - Store a character into the user definable
* character set.
*/
void terminal_char_load(padWord charnum, charData theChar)
{
memset(&fontm23[FONTPTR(charnum)],0,16);
for (curr_word=0;curr_word<8;curr_word++)
{
for (u=16; u-->0; )
{
if (theChar[curr_word] & 1<<u)
{
fontm23[FONTPTR(charnum)+u^0x0f&0x0f]|=BTAB[curr_word];
}
}
}
}

122
terminal.h Executable file
View File

@ -0,0 +1,122 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* terminal.c - Terminal state functions
*/
#ifndef TERMINAL_H
#define TERMINAL_H
#include "protocol.h"
/**
* terminal_init()
* Initialize terminal state
*/
void terminal_init(void);
/**
* terminal_initial_position()
* Set terminal initial position after splash screen.
*/
void terminal_initial_position(void);
/**
* terminal_set_tty(void) - Switch to TTY mode
*/
void terminal_set_tty(void);
/**
* terminal_set_plato(void) - Switch to PLATO mode
*/
void terminal_set_plato(void);
/**
* terminal_get_features(void) - Inquire about terminal ASCII features
*/
unsigned char terminal_get_features(void);
/**
* terminal_get_type(void) - Return the appropriate terminal type
*/
unsigned char terminal_get_type(void);
/**
* terminal_get_subtype(void) - Return the appropriate terminal subtype
*/
unsigned char terminal_get_subtype(void);
/**
* terminal_get_load_file(void) - Return the appropriate terminal loadfile (should just be 0)
*/
unsigned char terminal_get_load_file(void);
/**
* terminal_get_configuration(void) - Return the terminal configuration
*/
unsigned char terminal_get_configuration(void);
/**
* terminal_get_char_address(void) - Return the base address of the character set.
*/
unsigned short terminal_get_char_address(void);
/**
* terminal_mem_read - Read a byte of program memory.
* not needed for our terminal, but must
* be decoded.
*/
padByte terminal_mem_read(padWord addr);
/**
* terminal_mem_load - Write a byte to non-character memory.
* not needed for our terminal, but must be decoded.
*/
void terminal_mem_load(padWord addr, padWord value);
/**
* terminal_char_load - Store a character into the user definable
* character set.
*/
void terminal_char_load(padWord charnum, charData theChar);
/**
* terminal_mode_5, 6, and 7 are basically stubbed.
*/
void terminal_mode_5(padWord value);
void terminal_mode_6(padWord value);
void terminal_mode_7(padWord value);
/**
* terminal_ext_allow - External Input allowed. Not implemented.
*/
void terminal_ext_allow(padBool allow);
/**
* terminal_set_ext_in - Set which device to get input from.
* Not implemented
*/
void terminal_set_ext_in(padWord device);
/**
* terminal_set_ext_out - Set which device to send external data to.
* Not implemented
*/
void terminal_set_ext_out(padWord device);
/**
* terminal_ext_in - get an external input from selected device.
* Not implemented.
*/
padByte terminal_ext_in(void);
/**
* terminal_ext_out - Send an external output to selected device
* Not implemented.
*/
void terminal_ext_out(padByte value);
#endif

39
touch.c Normal file
View File

@ -0,0 +1,39 @@
#include "touch.h"
#include "screen.h"
#define X(x) (x)
#define Y(y) (y^0x1FF)
padBool lmb=padF;
padBool lastlmb=padF; /* left mouse button state */
padBool isAllowed;
/**
* touch_init(void)
* Initiialize mouse
*/
void touch_init(void)
{
}
/**
* enable/disable mouse cursor
*/
void touch_allow(padBool allow)
{
}
padBool touch_lmb(void)
{
}
void touch_main(void)
{
}
/**
* touch done
*/
void touch_done(void)
{
}

33
touch.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef TOUCH_H
#define TOUCH_H
#include "protocol.h"
/**
* touch_init(void)
* Initiialize mouse
*/
void touch_init(void);
/**
* enable/disable mouse cursor
*/
void touch_allow(padBool allow);
/**
* Is left mouse button pressed?
*/
padBool touch_lmb(void);
/**
* Get mouse position, and if LMB pressed, send touch event.
*/
void touch_main(void);
/**
* touch done
*/
void touch_done(void);
#endif /* TOUCH_H */

52
trace.c Normal file
View File

@ -0,0 +1,52 @@
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* trace.c - Trace output functions.
*/
#include <string.h>
#include "protocol.h"
#define true 1
#define false 0
#define TRACE_FILE "trace.txt"
unsigned char trace_active=false;
static int trace_handle;
/**
* trace_open(void)
* Open trace file trace.txt
*/
void trace_open(void)
{
}
/**
* trace_append(buf, len)
* Append data from ShowPLATO into buffer
*/
void trace_append(padByte* buf, int len)
{
}
/**
* trace_close(void)
* Close trace file.
*/
void trace_close(void)
{
}
/**
* trace_toggle(void)
* Toggle trace on/off
*/
void trace_toggle(void)
{
}

31
trace.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef TRACE_H
#define TRACE_H
/**
* PLATOTerm64 - A PLATO Terminal for the Commodore 64
* Based on Steve Peltz's PAD
*
* Author: Thomas Cherryhomes <thom.cherryhomes at gmail dot com>
*
* trace.h - Trace output functions.
*/
/**
* trace_open(void)
* Open trace file trace.txt
*/
void trace_open(void);
/**
* trace_append(buf, len)
* Append data from ShowPLATO into buffer
*/
void trace_append(padByte* buf, int len);
/**
* trace_close(void)
* Close trace file.
*/
void trace_close(void);
#endif /* TRACE_H */