changed ks/ftm to be more compliant with KS system
This commit is contained in:
parent
f5dda5d74d
commit
2266b9497c
@ -5,8 +5,7 @@
|
||||
Derived from the plain CP/M version.
|
||||
|
||||
Copyright (c) 2012-2020 Miguel Garcia / FloppySoftware, Spain.
|
||||
|
||||
VT100 color version by Anna Christina Naß <acn@acn.wtf>
|
||||
Color version by Anna Christina Naß <acn@acn.wtf>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
@ -22,6 +21,12 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Author's contact:
|
||||
|
||||
www.floppysoftware.es
|
||||
cpm-connections.blogspot.com
|
||||
floppysoftware@gmail.com
|
||||
|
||||
To compile with MESCC:
|
||||
|
||||
cc ftm
|
||||
@ -29,6 +34,20 @@
|
||||
zsm ftm
|
||||
hextocom ftm
|
||||
|
||||
Usage:
|
||||
|
||||
ftm [tty_name]
|
||||
If no tty_name is given, VT100COL is
|
||||
|
||||
Revisions:
|
||||
|
||||
11 Sep 2012 : v1.0 : Initial version for Amstrad PCW & Samaruc GUI.
|
||||
26 Jul 2013 : v1.2 : Adapted to Samaruc v1.5.
|
||||
16 Feb 2014 : v1.3 : Adapted to last changes in Samaruc.
|
||||
09 Jul 2014 : v1.4 : CP/M version.
|
||||
07 Apr 2020 : v2.0 : Adapted to KS library for CP/M.
|
||||
21 Apr 2020 : v2.1 : Added color option (by Anna Christina Naß <acn@acn.wtf>
|
||||
|
||||
Notes:
|
||||
|
||||
LEVELS: 1 2 3 NOTES
|
||||
@ -50,7 +69,7 @@
|
||||
#include <ctype.h>
|
||||
#include <sprintf.h>
|
||||
|
||||
/* KS library
|
||||
/* KS libraries
|
||||
*/
|
||||
#include "ks.h"
|
||||
|
||||
@ -104,7 +123,32 @@ int argc, argv[]; /* char *argv[] - unsupported by MESCC */
|
||||
|
||||
/* Init KS
|
||||
*/
|
||||
KsHello(0);
|
||||
if(argc == 1) {
|
||||
KsHello(KS_VT100COL);
|
||||
}
|
||||
else {
|
||||
if(strcmp(argv[1], "/?")==0) {
|
||||
tty_s = KsGetNames();
|
||||
tty_n = KsGetHowMany();
|
||||
|
||||
puts("Usage: ftm [tty_name]\n");
|
||||
puts("Supported TTY names:");
|
||||
|
||||
for(i = 0; i < tty_n; ++i) {
|
||||
putchar('\t'); puts(tty_s[i]);
|
||||
}
|
||||
|
||||
puts("If no tty_name is given, VT100COL (VT100 with color) is used.");
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(KsHello(KsGetCode(argv[1])) == -1) {
|
||||
puts("Unknown TTY name.\n\nRun 'ftm' to know supported TTYs.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup
|
||||
*/
|
||||
@ -123,7 +167,6 @@ int argc, argv[]; /* char *argv[] - unsupported by MESCC */
|
||||
*/
|
||||
Setup()
|
||||
{
|
||||
|
||||
int i; BYTE *p;
|
||||
|
||||
/* Build array to help in calculation of adjacent squares
|
||||
@ -159,21 +202,25 @@ Setup()
|
||||
Copyright()
|
||||
{
|
||||
int r;
|
||||
char str[80];
|
||||
char str[100];
|
||||
|
||||
KsClear();
|
||||
|
||||
sprintf(str, "%sFind %sThat %sMine%s!%s\n", FGBRED, FGBCYN, FGBBLU, FGBYEL, RESET);
|
||||
KsPosCursor(r = 0, 32);
|
||||
KsPutStr(str);
|
||||
//KsCenterStr(r = 0, "Find That Mine!\n");
|
||||
KsCenterStr(++r , "v2.0 for CP/M & Z80\n\n");
|
||||
if(KsCan(KS_CAN_COLOR)) {
|
||||
//sprintf(str, "%sFind %sThat %sMine%s!%s\n", KsFgCol(RED), KsFgCol(CYN), KsFgCol(BLU), KsFgCol(YEL), KsResetAttr());
|
||||
KsPosCursor(r = 2, 32);
|
||||
KsFgCol(BRED); KsPutStr("Find "); KsFgCol(BCYN); KsPutStr("That "); KsFgCol(BBLU); KsPutStr("Mine"); KsFgCol(BYEL); KsPutStr("!\n"); KsResetAttr();
|
||||
}
|
||||
else {
|
||||
KsCenterStr(r = 2, "Find That Mine!\n");
|
||||
}
|
||||
KsCenterStr(++r , "v2.1 for CP/M & Z80\n\n");
|
||||
++r;
|
||||
KsCenterStr(++r ,"A minesweeper type game.\n");
|
||||
++r;
|
||||
KsCenterStr(++r ,"(c) 2012-2020 Miguel Garcia / Floppy Software, Spain.\n");
|
||||
KsCenterStr(++r ,"www.floppysoftware.es\n");
|
||||
KsCenterStr(++r ,"VT100 color version by acn@acn.wtf\n\n");
|
||||
KsCenterStr(++r ,"color version by acn@acn.wtf\n\n");
|
||||
}
|
||||
|
||||
/* Select and play a level
|
||||
@ -485,8 +532,11 @@ int row, col;
|
||||
ShowBoard()
|
||||
{
|
||||
int r, c;
|
||||
int col;
|
||||
col = KsCan(KS_CAN_COLOR);
|
||||
|
||||
KsClear();
|
||||
PrStr("\n\n");
|
||||
|
||||
PrStr("\t ");
|
||||
for(c = 0; c < brd_cols; ++c) {
|
||||
@ -494,15 +544,20 @@ ShowBoard()
|
||||
}
|
||||
PrCh('\n');
|
||||
|
||||
PrStr(FGBGRY);
|
||||
PrStr("\t "); PrCh(201);
|
||||
PrChTimes(205, brd_cols + brd_cols + 1);
|
||||
PrCh(187); PrCh('\n');
|
||||
PrStr(RESET);
|
||||
if(col) KsFgCol(BBLK);
|
||||
PrStr("\t +");
|
||||
PrChTimes('-', brd_cols + brd_cols + 1);
|
||||
PrCh('+'); PrCh('\n');
|
||||
if(col) KsResetAttr();
|
||||
|
||||
for(r = 0; r < brd_rows; ++r)
|
||||
{
|
||||
PrCh('\t'); PrCh('0' + r); PrStr(FGBGRY); PrCh(186); PrStr(RESET);
|
||||
PrCh('\t'); PrCh('0' + r);
|
||||
if(col) {
|
||||
KsFgCol(BBLK); PrCh('|'); KsResetAttr();
|
||||
}
|
||||
else
|
||||
PrCh('|');
|
||||
|
||||
for(c = 0; c < brd_cols; ++c)
|
||||
{
|
||||
@ -511,37 +566,55 @@ ShowBoard()
|
||||
if(TstVis(r, c))
|
||||
{
|
||||
if(GetCount(r, c)) {
|
||||
if(col) {
|
||||
switch(GetCount(r, c))
|
||||
{
|
||||
case 1: PrStr(FGBBLU); break;
|
||||
case 2: PrStr(FGGRN); break;
|
||||
case 3: PrStr(FGBRED); break;
|
||||
case 4: PrStr(FGBLU); break;
|
||||
case 5: PrStr(FGRED); break;
|
||||
default: PrStr(FGCYN); break;
|
||||
case 1: KsFgCol(BBLU); break;
|
||||
case 2: KsFgCol(GRN); break;
|
||||
case 3: KsFgCol(BRED); break;
|
||||
case 4: KsFgCol(BLU); break;
|
||||
case 5: KsFgCol(RED); break;
|
||||
default: KsFgCol(CYN); break;
|
||||
}
|
||||
PrCh('0' + GetCount(r, c));
|
||||
PrStr(RESET);
|
||||
KsResetAttr();
|
||||
}
|
||||
else {
|
||||
else
|
||||
PrCh('0' + GetCount(r, c));
|
||||
}
|
||||
else
|
||||
PrCh(SPR_BLANK);
|
||||
}
|
||||
}
|
||||
else if(gameover)
|
||||
{
|
||||
if(TstMine(r, c)) {
|
||||
if(TstMine(r, c))
|
||||
{
|
||||
if(TstFlag(r, c)) {
|
||||
PrStr(FGRED); PrCh(SPR_FLAG); PrStr(RESET);
|
||||
if(col) {
|
||||
KsFgCol(RED);
|
||||
PrCh(SPR_FLAG);
|
||||
KsResetAttr();
|
||||
} else
|
||||
PrCh(SPR_FLAG);
|
||||
}
|
||||
else {
|
||||
PrStr(FGRED); PrCh(SPR_MINE); PrStr(RESET);
|
||||
if(col) {
|
||||
KsFgCol(RED);
|
||||
PrCh(SPR_MINE);
|
||||
KsResetAttr();
|
||||
} else
|
||||
PrCh(SPR_MINE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(TstFlag(r, c))
|
||||
else if(TstFlag(r, c))
|
||||
PrCh(SPR_ERR);
|
||||
else
|
||||
PrStr(FGBGRY); PrCh(SPR_UNK); PrStr(RESET);
|
||||
else {
|
||||
if(col) {
|
||||
KsFgCol(BBLK);
|
||||
PrCh(SPR_UNK);
|
||||
KsResetAttr();
|
||||
} else
|
||||
PrCh(SPR_UNK);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -555,16 +628,25 @@ ShowBoard()
|
||||
PrCh(SPR_UNK);
|
||||
#else
|
||||
if(TstFlag(r, c)) {
|
||||
PrStr(FGRED); PrCh(SPR_FLAG); PrStr(RESET);
|
||||
if(col) KsFgCol(RED);
|
||||
PrCh(SPR_FLAG);
|
||||
if(col) KsResetAttr();
|
||||
}
|
||||
else {
|
||||
PrStr(FGBGRY); PrCh(SPR_UNK); PrStr(RESET);
|
||||
if(col) KsFgCol(BBLK);
|
||||
PrCh(SPR_UNK);
|
||||
if(col) KsResetAttr();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
PrCh(' '); PrStr(FGBGRY); PrCh(186); PrStr(RESET); PrCh('0' + r);
|
||||
if(col) {
|
||||
PrCh(' '); KsFgCol(BBLK); PrCh('|'); KsResetAttr(); PrCh('0' + r);
|
||||
}
|
||||
else {
|
||||
PrCh(' '); PrCh('|'); PrCh('0' + r);
|
||||
}
|
||||
|
||||
switch(r)
|
||||
{
|
||||
@ -605,11 +687,11 @@ ShowBoard()
|
||||
PrCh('\n');
|
||||
}
|
||||
|
||||
PrStr(FGBGRY);
|
||||
PrStr("\t "); PrCh(200);
|
||||
PrChTimes(205, brd_cols + brd_cols + 1);
|
||||
PrCh(188); PrCh('\n');
|
||||
PrStr(RESET);
|
||||
if(col) KsFgCol(BBLK);
|
||||
PrStr("\t +");
|
||||
PrChTimes('-', brd_cols + brd_cols + 1);
|
||||
PrCh('+'); PrCh('\n');
|
||||
if(col) KsResetAttr();
|
||||
|
||||
PrStr("\t ");
|
||||
for(c = 0; c < brd_cols; ++c) {
|
||||
|
Binary file not shown.
@ -1,19 +1,28 @@
|
||||
/**
|
||||
* KSvt100
|
||||
* @file
|
||||
* @brief Keyboard & screen functions library for CP/M & MESCC.
|
||||
*
|
||||
* This library offers a common interface for keyboard and screen devices
|
||||
* using VT100 control codes
|
||||
* under CP/M.
|
||||
*
|
||||
* This is a stripped down version of KS to only support VT100, but includes
|
||||
* color codes
|
||||
* Supported TTYs:
|
||||
* - KS_VT52 for generic VT52 80x24
|
||||
* - KS_VT100 for generic VT100 80x25
|
||||
* - KS_PCW for Amstrad PCW 90x31
|
||||
* - KS_CPC for Amstrad CPC 24x80 under CP/M Plus
|
||||
* - KS_SPECTRUM for Spectrum +3 51x23
|
||||
* - KS_KAYPRO for Kaypro 24x80
|
||||
*
|
||||
* Capabilities:
|
||||
* - KS_CAN_HIDE can hide & show cursor
|
||||
* - KS_CAN_REVERSE can reverse text
|
||||
* - KS_CAN_UNDERLINE can underline text
|
||||
*/
|
||||
|
||||
/* ks.h
|
||||
|
||||
Keyboard & screen functions library for CP/M & MESCC - Mike's Enhanced Small C Compiler.
|
||||
|
||||
Stripped down version for VT100+color by Anna Christina Naß <acn@acn.wtf>
|
||||
|
||||
Copyright (c) 2016, 2017 Miguel I. Garcia Lopez / FloppySoftware, Spain
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
@ -29,45 +38,82 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Author's contact:
|
||||
|
||||
www.floppysoftware.es
|
||||
cpm-connections.blogspot.com
|
||||
floppysoftware@gmail.com
|
||||
|
||||
Revisions:
|
||||
|
||||
03 Sep 2016 : Work begins.
|
||||
29 Sep 2016 : Rename functions.
|
||||
03 Oct 2016 : Reworked KsInit() and others. Added support for reverse and underline.
|
||||
14 Jul 2017 : Added TTY names.
|
||||
07 Apr 2020 : TTY names in uppercase.
|
||||
08 Apr 2020 : Added KsGetNames(), KsGetHowMany().
|
||||
*/
|
||||
|
||||
int xks_rows = 25; // Screen rows
|
||||
int xks_cols = 80; // Screen columns
|
||||
BYTE *xks_clrscr = "\e[H\e[J"; // Clear screen
|
||||
BYTE *xks_poscur = "\e[%r;%cH"; // Position cursor
|
||||
BYTE *xks_shwcur = "\e[?25h"; // Show cursor
|
||||
BYTE *xks_hidcur = "\e[?25l"; // Hide cursor
|
||||
BYTE *xks_yrever = "\e[7m"; // Reverse on
|
||||
BYTE *xks_nrever = "\e[m"; // Reverse off
|
||||
BYTE *xks_yuline = "\e[4m"; // Underline on
|
||||
BYTE *xks_nuline = "\e[m"; // Underline off
|
||||
/* Public defines
|
||||
--------------
|
||||
*/
|
||||
#define KS_VT52 0
|
||||
#define KS_VT100 1
|
||||
#define KS_PCW 2
|
||||
#define KS_CPC 3
|
||||
#define KS_SPECTRUM 4
|
||||
#define KS_KAYPRO 5
|
||||
#define KS_VT100COL 6
|
||||
|
||||
#define RESET "\e[0m" // reset all attributes
|
||||
#define FGBLK "\e[30m" // black
|
||||
#define FGRED "\e[31m" // red
|
||||
#define FGGRN "\e[32m" // green
|
||||
#define FGYEL "\e[33m" // yellow
|
||||
#define FGBLU "\e[34m" // blue
|
||||
#define FGMAG "\e[35m" // magenta
|
||||
#define FGCYN "\e[36m" // cyan
|
||||
#define FGWHT "\e[37m" // white/gray
|
||||
#define FGBGRY "\e[30;1m" // gray ("bright black")
|
||||
#define FGBRED "\e[31;1m" // bright red
|
||||
#define FGBGRN "\e[32;1m" // bright green
|
||||
#define FGBYEL "\e[33;1m" // bright yellow
|
||||
#define FGBBLU "\e[34;1m" // bright blue
|
||||
#define FGBMAG "\e[35;1m" // bright magenta
|
||||
#define FGBCYN "\e[36;1m" // bright cyan
|
||||
#define FGBWHT "\e[37;1m" // bright white
|
||||
#define BGBLK "\e[40m" // black
|
||||
#define BGRED "\e[41m" // red
|
||||
#define BGGRN "\e[42m" // green
|
||||
#define BGYEL "\e[43m" // yellow
|
||||
#define BGBLU "\e[44m" // blue
|
||||
#define BGMAG "\e[45m" // magenta
|
||||
#define BGCYN "\e[46m" // cyan
|
||||
#define BGWHT "\e[47m" // white
|
||||
#define KS_CAN_HIDE 0 // Can hide & show cursor
|
||||
#define KS_CAN_REVERSE 1 // Can reverse text
|
||||
#define KS_CAN_UNDERLINE 2 // Can underline text
|
||||
#define KS_CAN_COLOR 3 // Can display color
|
||||
|
||||
/* Define color numbers
|
||||
--------------------
|
||||
*/
|
||||
// usable as foreground + background colors:
|
||||
#define BLK 0 // black
|
||||
#define RED 1 // red
|
||||
#define GRN 2 // green
|
||||
#define YEL 3 // yellow
|
||||
#define BLU 4 // blue
|
||||
#define MAG 5 // magenta
|
||||
#define CYN 6 // cyan
|
||||
#define WHT 7 // gray
|
||||
// the following colors are "bright" colors, these do not work as background colors
|
||||
#define BBLK 8 // dark gray ("bright black")
|
||||
#define BRED 9 // bright red
|
||||
#define BGRN 10 // bright green
|
||||
#define BYEL 11 // bright yellow
|
||||
#define BBLU 12 // bright blue
|
||||
#define BMAG 13 // bright magenta
|
||||
#define BCYN 14 // bright cyan
|
||||
#define BWHT 15 // bright white
|
||||
|
||||
/* Private defines
|
||||
---------------
|
||||
*/
|
||||
#define XKS_TTYS 7 // Number of supported TTYs
|
||||
|
||||
/* Private globals
|
||||
---------------
|
||||
*/
|
||||
WORD xks_names[XKS_TTYS]; // TTY names by code -- char *xks_names[]
|
||||
|
||||
int xks_rows; // Screen rows
|
||||
int xks_cols; // Screen columns
|
||||
BYTE *xks_clrscr; // Clear screen
|
||||
BYTE *xks_poscur; // Position cursor
|
||||
BYTE *xks_shwcur; // Show cursor
|
||||
BYTE *xks_hidcur; // Hide cursor
|
||||
BYTE *xks_yrever; // Reverse on
|
||||
BYTE *xks_nrever; // Reverse off
|
||||
BYTE *xks_yuline; // Underline on
|
||||
BYTE *xks_nuline; // Underline off
|
||||
int xks_color; // TTY can display color
|
||||
|
||||
/**
|
||||
* @fn int KsHello(char *tty_name)
|
||||
@ -81,6 +127,73 @@ int code;
|
||||
{
|
||||
// Setup BIOS jumps, etc.
|
||||
xKsInit();
|
||||
|
||||
xks_color = FALSE;
|
||||
|
||||
// Setup TTY
|
||||
switch(code) {
|
||||
case KS_VT52 :
|
||||
xKsInit24x80();
|
||||
xks_clrscr = "\eH\eJ";
|
||||
xks_poscur = "A\eY%r%c";
|
||||
break;
|
||||
|
||||
case KS_VT100 :
|
||||
xks_rows = 25;
|
||||
xks_cols = 80;
|
||||
xks_clrscr = "\e[H\e[J";
|
||||
xks_poscur = "B\e[%r;%cH";
|
||||
xks_yrever = "\e[7m";
|
||||
xks_nrever = "\e[m";
|
||||
xks_yuline = "\e[4m";
|
||||
xks_nuline = "\e[m";
|
||||
break;
|
||||
|
||||
case KS_PCW :
|
||||
xks_rows = 31;
|
||||
xks_cols = 90;
|
||||
xKsInitAmstrad();
|
||||
break;
|
||||
|
||||
case KS_CPC :
|
||||
xKsInit24x80();
|
||||
xKsInitAmstrad();
|
||||
break;
|
||||
|
||||
case KS_SPECTRUM :
|
||||
xks_rows = 23;
|
||||
xks_cols = 51;
|
||||
xKsInitAmstrad();
|
||||
|
||||
KsPutRawCh('\e'); KsPutRawCh('3'); KsPutRawCh(1);
|
||||
break;
|
||||
|
||||
case KS_KAYPRO :
|
||||
xKsInit24x80();
|
||||
xks_clrscr = "?"; *xks_clrscr = 26; // ^Z
|
||||
xks_poscur = "A\e=%r%c";
|
||||
break;
|
||||
|
||||
case KS_VT100COL :
|
||||
xks_rows = 25;
|
||||
xks_cols = 80;
|
||||
xks_clrscr = "\e[H\e[J";
|
||||
xks_poscur = "B\e[%r;%cH";
|
||||
xks_shwcur = "\e[?25h";
|
||||
xks_hidcur = "\e[?25l";
|
||||
xks_yrever = "\e[7m";
|
||||
xks_nrever = "\e[m";
|
||||
xks_yuline = "\e[4m";
|
||||
xks_nuline = "\e[m";
|
||||
xks_color = TRUE;
|
||||
break;
|
||||
|
||||
default :
|
||||
// Unknown tty code
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Success
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -104,12 +217,21 @@ KsBye()
|
||||
KsGetCode(name)
|
||||
char *name;
|
||||
{
|
||||
if(strcmp(name, "VT100")) {
|
||||
return 0;
|
||||
int i;
|
||||
|
||||
if(!xks_names[0]) {
|
||||
xKsNames();
|
||||
}
|
||||
else {
|
||||
|
||||
for(i = 0; i < XKS_TTYS; ++i) {
|
||||
if(!strcmp(name, xks_names[i])) {
|
||||
// Found
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// Unknown tty name
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,12 +244,17 @@ char *name;
|
||||
KsGetName(code)
|
||||
int code;
|
||||
{
|
||||
if(code==0) {
|
||||
return "VT100";
|
||||
if(!xks_names[0]) {
|
||||
xKsNames();
|
||||
}
|
||||
else {
|
||||
|
||||
if(code >= 0 && code < XKS_TTYS) {
|
||||
// Found
|
||||
return xks_names[code];
|
||||
}
|
||||
|
||||
// Unknown tty code
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,8 +265,10 @@ int code;
|
||||
*/
|
||||
KsGetNames()
|
||||
{
|
||||
WORD xks_names[1];
|
||||
xks_names[0] = "VT100";
|
||||
if(!xks_names[0]) {
|
||||
xKsNames();
|
||||
}
|
||||
|
||||
return xks_names;
|
||||
}
|
||||
|
||||
@ -151,7 +280,7 @@ KsGetNames()
|
||||
*/
|
||||
KsGetHowMany()
|
||||
{
|
||||
return 1;
|
||||
return XKS_TTYS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,15 +303,42 @@ int row, col;
|
||||
{
|
||||
char *p; int v;
|
||||
|
||||
for(p = xks_poscur; *p; ++p) {
|
||||
for(p = xks_poscur + 1; *p; ++p) {
|
||||
if(*p != '%') {
|
||||
KsPutRawCh(*p);
|
||||
}
|
||||
else {
|
||||
v = (*(++p) == 'r' ? row : col);
|
||||
|
||||
if(*xks_poscur == 'A') {
|
||||
// A
|
||||
KsPutRawCh(32 + v);
|
||||
}
|
||||
else {
|
||||
// B
|
||||
xKsPutDec(1 + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn int KsCan(int cap)
|
||||
* @brief Check if the TTY has a capability.
|
||||
* @param cap - capatility code
|
||||
* @return 0 on NO, other on YES
|
||||
*/
|
||||
KsCan(cap)
|
||||
int cap;
|
||||
{
|
||||
switch(cap) {
|
||||
case KS_CAN_HIDE : return xks_shwcur != NULL;
|
||||
case KS_CAN_REVERSE : return xks_yrever != NULL;
|
||||
case KS_CAN_UNDERLINE : return xks_yuline != NULL;
|
||||
case KS_CAN_COLOR : return xks_color;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,6 +382,68 @@ int toggle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn char *KsFgCol(int color)
|
||||
* @brief Set foreground color
|
||||
* If the TTY does not have this capability, does nothing.
|
||||
* @param color - color number, see #defines
|
||||
*/
|
||||
KsFgCol(color)
|
||||
int color;
|
||||
{
|
||||
char rc[12];
|
||||
if(xks_color) {
|
||||
if(color<8) {
|
||||
sprintf(rc, "\e[3%dm", color);
|
||||
KsPutStr(rc);
|
||||
}
|
||||
if(color>=8) {
|
||||
sprintf(rc, "\e[3%d;1m", color-8); // bright colors begin at 8
|
||||
KsPutStr(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void KsBgCol(int color)
|
||||
* @brief Set background color
|
||||
* If the TTY does not have this capability, does nothing.
|
||||
* @param color - color number, see #defines
|
||||
*/
|
||||
KsBgCol(color)
|
||||
int color;
|
||||
{
|
||||
char str[6];
|
||||
if(xks_color) {
|
||||
sprintf(str, "\e[4%dm", color);
|
||||
KsPutStr(str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void KsResetAttr()
|
||||
* If the TTY does not support color, does nothing
|
||||
* @brief Resets all attributes
|
||||
*/
|
||||
KsResetAttr()
|
||||
{
|
||||
if(xks_color)
|
||||
KsPutStr("\e[m");
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void KsCenterStr(int row, char *s)
|
||||
* @brief Print a string centered on screen.
|
||||
* @param row - screen row
|
||||
* @param s - string
|
||||
*/
|
||||
KsCenterStr(row, s)
|
||||
int row; char *s;
|
||||
{
|
||||
KsPosCursor(row, (KsGetCols() - strlen(s)) / 2);
|
||||
KsPutStr(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn int KsGetRows(void)
|
||||
* @brief Get TTY rows.
|
||||
@ -246,19 +464,6 @@ KsGetCols()
|
||||
return xks_cols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void KsCenterStr(int row, char *s)
|
||||
* @brief Print a string centered on screen.
|
||||
* @param row - screen row
|
||||
* @param s - string
|
||||
*/
|
||||
KsCenterStr(row, s)
|
||||
int row; char *s;
|
||||
{
|
||||
KsPosCursor(row, (KsGetCols() - strlen(s)) / 2);
|
||||
KsPutStr(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void KsPutRawCh(int ch)
|
||||
* @brief Send a character to the TTY.
|
||||
@ -364,6 +569,38 @@ xKsConOut
|
||||
jp 0 ; BIOS ConOut
|
||||
#endasm
|
||||
|
||||
// void xKsNames(void) : Set TTY names.
|
||||
xKsNames()
|
||||
{
|
||||
xks_names[KS_VT52] = "VT52";
|
||||
xks_names[KS_VT100] = "VT100";
|
||||
xks_names[KS_PCW] = "PCW";
|
||||
xks_names[KS_CPC] = "CPC";
|
||||
xks_names[KS_SPECTRUM] = "SPECTRUM";
|
||||
xks_names[KS_KAYPRO] = "KAYPRO";
|
||||
xks_names[KS_VT100COL] = "VT100COL";
|
||||
}
|
||||
|
||||
// void xKsInit24x80(void) : Set TTY to 24 rows and 80 columns.
|
||||
xKsInit24x80()
|
||||
{
|
||||
xks_rows = 24;
|
||||
xks_cols = 80;
|
||||
}
|
||||
|
||||
// void xKsInitAmstrad(void) : Set generic Amstrad mode.
|
||||
xKsInitAmstrad()
|
||||
{
|
||||
xks_clrscr = "\eH\eE";
|
||||
xks_poscur = "A\eY%r%c";
|
||||
xks_shwcur = "\ee";
|
||||
xks_hidcur = "\ef";
|
||||
xks_yrever = "\ep";
|
||||
xks_nrever = "\eq";
|
||||
xks_yuline = "\er";
|
||||
xks_nuline = "\eu";
|
||||
}
|
||||
|
||||
// void xKsPutDec(int num) : Send positive decimal number to TTY.
|
||||
xKsPutDec(num)
|
||||
int num;
|
||||
|
Loading…
Reference in New Issue
Block a user