From 674904814e47c6a0ecd7292aaa13558c6af1aa5c Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Sun, 3 Feb 2019 12:39:12 -0600 Subject: [PATCH] put in rest of menu update code. --- CMakeLists.txt | 1 + PLATOTERM.r | 4 +-- io.c | 19 +++++------ main.c | 5 +-- screen.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 100 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d9f7b..dc15442 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ add_application(PLATOTERM terminal.c touch.c trace.c + config.c CREATOR "PLTO" ) target_link_libraries(PLATOTERM "-lm") diff --git a/PLATOTERM.r b/PLATOTERM.r index f36dac7..cc964da 100755 --- a/PLATOTERM.r +++ b/PLATOTERM.r @@ -48,10 +48,10 @@ resource 'MENU' (130) { resource 'MENU' (131) { 131, textMenuProc; - 0, enabled; + allEnabled, enabled; "Settings"; { - "300 baud", noIcon, "3", noMark, plain; + "300 baud", noIcon, "3", noMark, Plain; "1200 baud", noIcon, "1", noMark, plain; "2400 baud", noIcon, "2", noMark, plain; "9600 baud", noIcon, "6", noMark, plain; diff --git a/io.c b/io.c index 7497e74..92cd683 100755 --- a/io.c +++ b/io.c @@ -4,6 +4,7 @@ #include "io.h" #include "protocol.h" #include "terminal.h" +#include "config.h" #define true 1 #define false 0 @@ -11,6 +12,7 @@ #define SERIAL_BUFFER_SIZE 16000 extern unsigned char trace_active; +extern ConfigInfo config; extern void done(void); short driverIn; @@ -33,18 +35,10 @@ void io_init(void) handshake.fInX=0; SerHShake(driverIn,&handshake); - SerReset(driverOut,baud57600+stop10+noParity+data8); + io_set_baud(config.baud); serial_buffer=NewPtr(SERIAL_BUFFER_SIZE); - /* if (serial_buffer!=noErr) */ - /* done(); */ - SerSetBuf(driverIn,serial_buffer,SERIAL_BUFFER_SIZE); - paramBlock.ioCRefNum=driverIn; - paramBlock.csCode=kSERDHandshakeRS232; - PBControl((ParmBlkPtr)¶mBlock,false); - paramBlock.csCode=kSERDAssertDTR; - PBControl((ParmBlkPtr)¶mBlock,false); } void io_send_byte(unsigned char b) @@ -81,6 +75,13 @@ void io_send_string(const char* str, int len) */ void io_set_baud(int baud) { + SerReset(driverOut,baud+stop10+noParity+data8); + paramBlock.ioCRefNum=driverIn; + paramBlock.csCode=kSERDHandshakeRS232; + PBControl((ParmBlkPtr)¶mBlock,false); + paramBlock.csCode=kSERDAssertDTR; + PBControl((ParmBlkPtr)¶mBlock,false); + config.baud=baud; } /** diff --git a/main.c b/main.c index d5567ab..d56a830 100755 --- a/main.c +++ b/main.c @@ -5,7 +5,7 @@ #include "keyboard.h" #include "touch.h" #include "splash.h" -#include "help.h" +#include "config.h" #define true 1 #define false 0 @@ -22,14 +22,15 @@ void done(void) void main(void) { + config_init(); screen_init(); touch_init(); - help_init(); NoEcho=padT; ShowPLATO(splash,sizeof(splash)); NoEcho=padF; terminal_initial_position(); io_init(); + screen_update_menus(); running=true; while (running==true) { diff --git a/screen.c b/screen.c index 8fe7c9e..df006db 100644 --- a/screen.c +++ b/screen.c @@ -16,6 +16,8 @@ #include "io.h" #include "keyboard.h" #include "touch.h" +#include "config.h" +#include "terminal.h" #define true 1 #define false 0 @@ -45,6 +47,7 @@ static AEEventHandlerUPP oappUPP, odocUPP, pdocUPP, quitUPP; extern unsigned char running; static long sysv; extern void done(void); +extern ConfigInfo config; /* Apple Event Handler callbacks */ @@ -174,6 +177,50 @@ void screen_about_dialog(void) */ void screen_update_menus(void) { + int i; + + /* Update PLATO/TTY mode selector. */ + CheckItem(GetMenuHandle(129),1,false); + CheckItem(GetMenuHandle(129),2,false); + + if (TTY) + { + CheckItem(GetMenuHandle(129),2,true); + } + else + { + CheckItem(GetMenuHandle(129),1,true); + } + + /* Update baud rate selector. */ + for (i=1;i<8;i++) + { + CheckItem(GetMenuHandle(131),i,false); + } + switch (config.baud) + { + case 300: + CheckItem(GetMenuHandle(131),1,true); + break; + case 1200: + CheckItem(GetMenuHandle(131),2,true); + break; + case 2400: + CheckItem(GetMenuHandle(131),3,true); + break; + case 9600: + CheckItem(GetMenuHandle(131),4,true); + break; + case 19200: + CheckItem(GetMenuHandle(131),5,true); + break; + case 38400: + CheckItem(GetMenuHandle(131),6,true); + break; + case 57600: + CheckItem(GetMenuHandle(131),7,true); + break; + } } /** @@ -201,14 +248,49 @@ void screen_menu_command(long menu_command) { switch(menuItem) { - + case 1: + terminal_set_plato(); + break; + case 2: + terminal_set_tty(); + break; + case 4: + io_hang_up(); + break; case 5: done(); break; } } - + else if (menuID == 131) + { + switch(menuItem) + { + case 1: + io_set_baud(300); + break; + case 2: + io_set_baud(1200); + break; + case 3: + io_set_baud(2400); + break; + case 4: + io_set_baud(9600); + break; + case 5: + io_set_baud(19200); + break; + case 6: + io_set_baud(38400); + break; + case 7: + io_set_baud(57600); + break; + } + } HiliteMenu(0); + screen_update_menus(); } /**