From e1cf110542d2138fe5937cdaca9d39e7e0e955ae Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 17 Sep 2016 17:39:30 +0000 Subject: [PATCH] misc updates. git-svn-id: svn://qnap.local/TwoTerm/trunk@3139 5590a31f-7b70-45f8-8c82-aa3a8e5f4507 --- Emulators/GNOConsole.h | 2 +- Emulators/GNOConsole.mm | 4 ++-- Emulators/GSOSConsole.h | 2 +- Emulators/GSOSConsole.mm.ragel | 32 +++++++++++++++++--------------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Emulators/GNOConsole.h b/Emulators/GNOConsole.h index 618a762..6dc78b6 100644 --- a/Emulators/GNOConsole.h +++ b/Emulators/GNOConsole.h @@ -24,7 +24,7 @@ int _vp[4]; - int _cursorType; + Screen::CursorType _cursorType; } diff --git a/Emulators/GNOConsole.mm b/Emulators/GNOConsole.mm index c700f32..aa7af1e 100644 --- a/Emulators/GNOConsole.mm +++ b/Emulators/GNOConsole.mm @@ -207,7 +207,7 @@ enum { case CTRL('A'): // set cursor to flashing block. _cursorType = Screen::CursorTypeBlock; - screen->setCursorType((Screen::CursorType)_cursorType); + screen->setCursorType(_cursorType); break; case CTRL('B'): _cursorType = Screen::CursorTypeUnderscore; @@ -222,7 +222,7 @@ enum { case CTRL('E'): // cursor on - screen->setCursorType((Screen::CursorType)_cursorType); + screen->setCursorType(_cursorType); break; case CTRL('F'): diff --git a/Emulators/GSOSConsole.h b/Emulators/GSOSConsole.h index f933616..36671eb 100644 --- a/Emulators/GSOSConsole.h +++ b/Emulators/GSOSConsole.h @@ -19,7 +19,7 @@ std::vector _tpStack; - unsigned _scratch[4]; + int _scratch[4]; int _cursorType; bool _consLF; diff --git a/Emulators/GSOSConsole.mm.ragel b/Emulators/GSOSConsole.mm.ragel index 7687daf..aca9c81 100644 --- a/Emulators/GSOSConsole.mm.ragel +++ b/Emulators/GSOSConsole.mm.ragel @@ -11,16 +11,18 @@ #include "OutputChannel.h" #include "Screen.h" +#include "algorithm.h" + %%{ machine console; alphtype unsigned int; action nop {} - arg1 = any ${ _scratch[0] = (fc - 32) & 0xff; }; - arg2 = any ${ _scratch[1] = (fc - 32) & 0xff; }; - arg3 = any ${ _scratch[2] = (fc - 32) & 0xff; }; - arg4 = any ${ _scratch[3] = (fc - 32) & 0xff; }; + arg1 = any ${ _scratch[0] = (fc - 32); }; + arg2 = any ${ _scratch[1] = (fc - 32); }; + arg3 = any ${ _scratch[2] = (fc - 32); }; + arg4 = any ${ _scratch[3] = (fc - 32); }; main := ( 0x00 $nop @@ -38,12 +40,11 @@ // left, top, right, bottom - _scratch[0] = std::max(_scratch[0], 0u); - _scratch[1] = std::max(_scratch[1], 0u); - - _scratch[2] = std::max(_scratch[2]+1, 80u); - _scratch[3] = std::max(_scratch[3]+1, 24u); + _scratch[0] = clamp(_scratch[0], 0, 80-1); + _scratch[1] = clamp(_scratch[1], 0, 24-1); + _scratch[2] = clamp(_scratch[2], 0, 80-1)+1; + _scratch[3] = clamp(_scratch[3], 0, 24-1)+1; iRect r(_scratch[0], @@ -54,7 +55,7 @@ _textPort.frame = r; - screen->setCursor(&_textPort, _scratch[0], _scratch[1]); + screen->setCursor(&_textPort, 0, 0); } | 0x03 ${ @@ -83,7 +84,7 @@ | 0x06 any ${ /* set vertical position */ - unsigned n = fc - 32; + unsigned n = clamp(fc - 32, 0, 24-1); screen->setY(&_textPort, n); } @@ -139,7 +140,7 @@ | 0x10 any ${ /* DLE expansion */ if (_consDLE) { - unsigned count = (fc - 0x20) & 0xff; + unsigned count = (fc - 32) & 0xff; while (count--) screen->putc(&_textPort, ' '); } else { fhold; } @@ -156,7 +157,8 @@ | 0x14 any ${ /* set horizontal position */ - screen->setX(&_textPort, fc - 0x20); + unsigned n = clamp(fc - 32, 0, 80 - 1); + screen->setX(&_textPort, n); } | 0x15 any ${ @@ -214,8 +216,8 @@ | 0x1e arg1 arg2 ${ /* goto x y */ iPoint dca; - dca.x = _scratch[0]; - dca.y = _scratch[1]; + dca.x = clamp(_scratch[0], 0, 80 - 1); + dca.y = clamp(_scratch[1], 0, 24 - 1); screen->setCursor(&_textPort, dca); }