mirror of
https://github.com/tschak909/platotermClassicMac.git
synced 2024-12-26 20:30:00 +00:00
fix key mapping. Work on exit code. Implement beep. Ensure that character size not accidentally reset after initial sizing.
This commit is contained in:
parent
e5f56c5b72
commit
a7bbae82e0
21
io.c
21
io.c
@ -1,5 +1,6 @@
|
||||
#include <Devices.h>
|
||||
#include <Serial.h>
|
||||
#include <OSUtils.h>
|
||||
#include "io.h"
|
||||
#include "protocol.h"
|
||||
#include "terminal.h"
|
||||
@ -16,6 +17,7 @@ short driverIn;
|
||||
short driverOut;
|
||||
SerShk handshake;
|
||||
Ptr serial_buffer;
|
||||
CntrlParam paramBlock;
|
||||
|
||||
void io_init(void)
|
||||
{
|
||||
@ -25,7 +27,7 @@ void io_init(void)
|
||||
done();
|
||||
|
||||
handshake.fXOn=0;
|
||||
handshake.fCTS=0;
|
||||
handshake.fCTS=1;
|
||||
handshake.errs=0;
|
||||
handshake.evts=0;
|
||||
handshake.fInX=0;
|
||||
@ -34,10 +36,15 @@ void io_init(void)
|
||||
SerReset(driverOut,baud57600+stop10+noParity+data8);
|
||||
serial_buffer=NewPtr(SERIAL_BUFFER_SIZE);
|
||||
|
||||
if (serial_buffer!=noErr)
|
||||
done();
|
||||
/* if (serial_buffer!=noErr) */
|
||||
/* done(); */
|
||||
|
||||
SerSetBuf(driverIn,serial_buffer,SERIAL_BUFFER_SIZE);
|
||||
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 +88,11 @@ void io_set_baud(int baud)
|
||||
*/
|
||||
void io_hang_up(void)
|
||||
{
|
||||
paramBlock.csCode=kSERDNegateDTR;
|
||||
PBControl((ParmBlkPtr)¶mBlock,false);
|
||||
Delay(100,NULL);
|
||||
paramBlock.csCode=kSERDAssertDTR;
|
||||
PBControl((ParmBlkPtr)¶mBlock,false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,6 +120,7 @@ void io_done()
|
||||
{
|
||||
if (serial_buffer!=NULL)
|
||||
{
|
||||
io_hang_up();
|
||||
SerSetBuf(driverIn,NULL,0);
|
||||
DisposePtr(serial_buffer);
|
||||
serial_buffer=NULL;
|
||||
|
2
key.h
2
key.h
@ -14,7 +14,7 @@ int key_to_pkey[]={
|
||||
PKEY_NOKEY, /* 0x05 CTRL-E */
|
||||
PKEY_NOKEY, /* 0x06 CTRL-F */
|
||||
PKEY_NOKEY, /* 0x07 CTRL-G */
|
||||
PKEY_NOKEY, /* 0x08 CTRL-H */
|
||||
PKEY_ERASE, /* 0x08 CTRL-H */
|
||||
PKEY_TAB, /* 0x09 CTRL-I */
|
||||
PKEY_NOKEY, /* 0x0a CTRL-J */
|
||||
PKEY_NOKEY, /* 0x0b CTRL-K */
|
||||
|
59
keyboard.c
59
keyboard.c
@ -4,6 +4,7 @@
|
||||
#include "io.h"
|
||||
#include "screen.h"
|
||||
#include "trace.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
@ -32,19 +33,73 @@ void keyboard_out(int platoKey)
|
||||
void keyboard_main(EventRecord* e)
|
||||
{
|
||||
unsigned char key;
|
||||
unsigned char code;
|
||||
key=e->message&0x7F;
|
||||
code=((e->message)>>8)&0x7F;
|
||||
if (TTY)
|
||||
{
|
||||
keyboard_out_tty(key);
|
||||
if (e->modifiers & cmdKey)
|
||||
{
|
||||
if (key=='h')
|
||||
{
|
||||
TTY=padT;
|
||||
io_hang_up();
|
||||
}
|
||||
else if (key=='t')
|
||||
{
|
||||
terminal_set_tty();
|
||||
}
|
||||
else if (key=='p')
|
||||
{
|
||||
terminal_set_plato();
|
||||
}
|
||||
}
|
||||
else
|
||||
keyboard_out_tty(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e->modifiers & 4096) /* CTRL key*/
|
||||
if (e->modifiers & cmdKey)
|
||||
{
|
||||
if (key=='h')
|
||||
{
|
||||
terminal_set_tty();
|
||||
io_hang_up();
|
||||
}
|
||||
else if (key=='t')
|
||||
{
|
||||
terminal_set_tty();
|
||||
}
|
||||
else if (key=='p')
|
||||
{
|
||||
terminal_set_plato();
|
||||
}
|
||||
}
|
||||
else if (e->modifiers & 4096) /* CTRL key*/
|
||||
{
|
||||
if (e->modifiers & 512)
|
||||
key|=0x80;
|
||||
keyboard_out(ctrl_key_to_pkey[key]);
|
||||
}
|
||||
else if ((e->modifiers & 512) && key==0x0d)
|
||||
{
|
||||
keyboard_out(PKEY_NEXT1);
|
||||
}
|
||||
else if ((e->modifiers & 512) && key==0x08)
|
||||
{
|
||||
keyboard_out(PKEY_ERASE1);
|
||||
}
|
||||
else if ((e->modifiers & 4096) && code==0x04)
|
||||
{
|
||||
if (e->modifiers & 512)
|
||||
keyboard_out(PKEY_HELP1);
|
||||
else
|
||||
keyboard_out(PKEY_HELP);
|
||||
}
|
||||
else if ((e->modifiers & 4096) && code==0x2E)
|
||||
{
|
||||
keyboard_out(PKEY_MICRO);
|
||||
}
|
||||
else
|
||||
keyboard_out(key_to_pkey[key]);
|
||||
}
|
||||
|
1
main.c
1
main.c
@ -36,5 +36,6 @@ void main(void)
|
||||
screen_main(); /* keyboard_main() and touch_main() are called in here. */
|
||||
io_main();
|
||||
}
|
||||
done();
|
||||
}
|
||||
|
||||
|
5
screen.c
5
screen.c
@ -43,6 +43,7 @@ int windowHeight;
|
||||
static AEEventHandlerUPP oappUPP, odocUPP, pdocUPP, quitUPP;
|
||||
extern unsigned char running;
|
||||
static long sysv;
|
||||
extern void done(void);
|
||||
|
||||
/* Apple Event Handler callbacks */
|
||||
|
||||
@ -189,7 +190,7 @@ void screen_menu_command(long menu_command)
|
||||
{
|
||||
|
||||
case 1:
|
||||
ExitToShell();
|
||||
done();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -273,6 +274,7 @@ void screen_wait(void)
|
||||
*/
|
||||
void screen_beep(void)
|
||||
{
|
||||
SysBeep(5);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -650,4 +652,5 @@ void screen_paint(padPt* Coord)
|
||||
*/
|
||||
void screen_done(void)
|
||||
{
|
||||
ExitToShell();
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void terminal_set_tty(void)
|
||||
CurMem=M0;
|
||||
CurMode=ModeRewrite;
|
||||
CharWide=8;
|
||||
CharHigh=16;
|
||||
/* CharHigh=16; */
|
||||
TTYLoc.x = 0;
|
||||
TTYLoc.y = 495;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user