54 using CharCursor::CharCursor;
58 At & operator=(
const CharCursor & cc) {
return(*
this = cc); }
59 At & operator=(
CharCursor && cc) {
return(*
this = std::move(cc)); }
112 using PrintItem = std::function< bool(
const std::string &) >;
131 using CheckInput = std::function< bool(
const std::string &) >;
156 template <
unsigned SW,
unsigned SH>
179 Screen & underlyingScreen(
void)
noexcept {
return(scr_); }
183 {
return(scldims_); }
197 void print(
const std::string & txt);
208 void print(
const uint8_t * bitmap);
220 static constexpr size_t kWidthInBytes =
static_cast<size_t>(SW);
221 static constexpr size_t kHeightInScans =
223 static constexpr size_t kLenBM = kWidthInBytes * kHeightInScans;
226 const bool perfectchars_;
231 void incCursor(
void);
232 Bitmap getBitmap(uint8_t c);
248 const std::string & txt,
267 std::numeric_limits<CharDist>::max()},
288 Screen(uint8_t * bitmap, uint8_t * attrmap,
467 bool evenwithinv =
true)
const;
505 uint8_t
attrForPrints(
size_t offset,
const Colors & desired)
const;
532 void putChar(
const uint8_t * d) { putCharBitmap(d,cursor_,currcmodes_); }
535 size_t print(
const std::string & txt,
size_t printmax = 0)
564 {
size_t prmax{printmax};
565 return(printRaw(txt,cursor_,currcmodes_,
true,prmax)); }
568 CharArea & area,
size_t & nscrlls)
const;
577 {
print(txt);
return(*
this); }
579 {
print(std::string(1,
static_cast<char>(c)));
return(*
this); }
596 const Colors * cmc =
nullptr);
618 void input(std::string & res,
const InputCallbacks & callbacks,
619 const CharCursor & pos,
const Colors & c0,
const Keyboard & k0,
620 bool withquotes,
CharDist maxscrolls,
size_t maxlen = 0,
621 const Beep & b = Beep{});
709 const Colors * cmc =
nullptr);
743 const Colors * cmc =
nullptr);
772 static const std::vector< std::string > TOKENTEXTS;
775 static uint8_t changeBitsByPlot(uint8_t oldbyte, uint8_t maskbit,
776 bool inverse,
bool over)
noexcept;
777 static void clipSegmentLeft(
double xd0,
double yd0,
double dxdy,
778 double & xd1,
double & yd1)
779 { yd1 = -xd0 / dxdy + yd0; xd1 = 0.0; }
780 static void clipSegmentRight(
double xd0,
double yd0,
double dxdy,
782 double & xd1,
double & yd1)
783 { yd1 = (w1 - xd0) / dxdy + yd0; xd1 = w1; }
784 static void clipSegmentTop(
double xd0,
double yd0,
double dxdy,
785 double & xd1,
double & yd1)
786 { xd1 = -yd0 * dxdy + xd0; yd1 = 0.0; }
787 static void clipSegmentBottom(
double xd0,
double yd0,
double dxdy,
789 double & xd1,
double & yd1)
790 { xd1 = (h1 - yd0) * dxdy + xd0; yd1 = h1; }
791 static double angleWithChordError(
double r);
792 static void advanceCursor(
CharCursor & cur,
bool newline =
false) noexcept;
795 DoubleGraphic mymap_;
796 const DoubleArea myinfo_;
798 BasicColor mybordercol_;
802 const uint8_t * pfont_;
803 const uint8_t * pudgs_;
805 size_t adjustCursorToPrint(
CharCursor & cur,
bool scroll = true) noexcept;
807 void putCharBitmap(const uint8_t * bitmap,
809 size_t printRaw(const std::
string & txt,
CharCursor & cur, Colors & cols,
810 bool printit,
size_t & maxprint,
812 size_t * printlength =
nullptr);
813 uint8_t attrForPlots(const
PixCursor & pos,
815 const Colors & cmc) const;
816 void plotWithAttrColors(const
PixCursor & pos,
bool colorsembedded,
818 bool drawHoriz(
PixelDist incx,
bool colorsembedded,
820 bool drawVert(
PixelDist incy,
bool colorsembedded,
822 bool drawWithAttrColors(
IntDist incx,
IntDist incy,
bool colorsembedded,
824 double yCoordInPlane(
double y) const noexcept
825 {
return(
static_cast<double>(myinfo_.pixarea.height - 1) - y); }
827 bool colorsembedded,
const Colors &cmc);
942 {
return(std::string{
"ScrollInfo("} +
963 {
if ((c !=
'S') && (c !=
'K'))
964 RUNTIMEEXCEP(
"Invalid channel '" + std::string{c} +
"'"); }
1062 Screen &
flat(
void)
const {
return(screen_); }
1092 void fillKColors(BasicColor b, Colors & colors)
const;
1123 char getChannel(
void)
const {
return(curch_); }
1145 ScrollInfo
print(
const std::string & txt);
1171 void plot(
const PixCursor & pos,
const Colors * cmc =
nullptr);
1180 const Colors * cmc =
nullptr);
1185 const Colors * cmc =
nullptr);
1258 Colors globalattrsS_,curattrsS_;
1263 {
return(c ==
'S' ? curflatS_ : curflatK_);}
1264 Colors & curColorsChannel(
char c)
1265 {
return(c ==
'S' ? curattrsS_ : curattrsK_);}
1266 Colors & globalColorsChannel(
char c)
1267 {
return(c ==
'S' ? globalattrsS_ : globalattrsK_);}
1268 void useGlobalAttrsOfChannel(
char c)
1269 { screen_.
colors() = (c ==
'S' ? globalattrsS_ : globalattrsK_); }
1270 void useCurrentAttrsOfChannel(
char c)
1271 { screen_.
colors() = (c ==
'S' ? curattrsS_ : curattrsK_); }
1272 void getCurrentAttrsOfChannel(
char c)
1273 {
if (c==
'S') curattrsS_ = screen_.
colors();
1274 else curattrsK_ = screen_.
colors(); }
1275 void useCursorChannel(
char c)
1277 void getCursorChannel(
char c)
1279 void printSpcRect(
const CharRect & rect);
1281 void resetK(
bool byinput =
false);
1282 Key printMsgK(
const std::string & msg);
1283 ScrollInfo scrollIfNeededS(
void);
1284 ScrollInfo scrollIfNeededK(
void);
1285 ScrollInfo scrollIfNeeded(
void)
1286 {
if (curch_ ==
'S')
return(scrollIfNeededS());
1287 else return(scrollIfNeededK()); }
1288 ScrollInfo adjustCursorToPrint(
void)
noexcept;
1289 ScrollInfo advanceCursor(
bool newline =
false) noexcept;
1290 ScrollInfo printNonCtrlChar(uint8_t c);
1291 ScrollInfo printCtrlChar(uint8_t c, uint8_t p1 = 0, uint8_t p2 = 0);
1314template <
unsigned SCW,
unsigned SCH>
1315void Screen::ScaledTextPrinter<SCW,SCH>::incCursor(
void)
1318 if (cur_.x >= scldims_.width)
1322 if (cur_.y >= scldims_.height)
return;
1326template <
unsigned SCW,
unsigned SCH>
1327Bitmap Screen::ScaledTextPrinter<SCW,SCH>::getBitmap(uint8_t c)
1332 if constexpr(SCW == 0)
1335 static const uint8_t kPerfectFont[] =
1339 0x00,0x02,0x02,0x02,0x02,0x00,0x02,0x00,
1340 0x00,0x55,0x57,0x05,0x05,0x07,0x05,0x00,
1341 0x00,0x25,0x71,0x62,0x32,0x74,0x25,0x00,
1342 0x00,0x22,0x42,0x30,0x50,0x50,0x30,0x00,
1343 0x00,0x14,0x22,0x41,0x41,0x41,0x22,0x14,
1344 0x00,0x20,0x70,0x22,0x57,0x02,0x00,0x00,
1345 0x00,0x00,0x00,0x00,0x07,0x00,0x20,0x20,
1346 0x00,0x01,0x01,0x02,0x02,0x04,0x14,0x00,
1347 0x00,0x22,0x56,0x52,0x52,0x52,0x27,0x00,
1348 0x00,0x27,0x51,0x12,0x21,0x45,0x72,0x00,
1349 0x00,0x57,0x54,0x56,0x71,0x15,0x12,0x00,
1350 0x00,0x17,0x21,0x61,0x52,0x52,0x22,0x00,
1351 0x00,0x22,0x55,0x25,0x53,0x52,0x24,0x00,
1352 0x00,0x00,0x00,0x22,0x00,0x00,0x22,0x02,
1353 0x00,0x00,0x10,0x27,0x40,0x27,0x10,0x00,
1354 0x00,0x02,0x45,0x21,0x12,0x20,0x42,0x00,
1355 0x00,0x23,0x55,0x75,0x77,0x45,0x35,0x00,
1356 0x00,0x63,0x54,0x64,0x54,0x54,0x63,0x00,
1357 0x00,0x67,0x54,0x56,0x54,0x54,0x67,0x00,
1358 0x00,0x73,0x44,0x64,0x45,0x45,0x43,0x00,
1359 0x00,0x57,0x52,0x72,0x52,0x52,0x57,0x00,
1360 0x00,0x35,0x15,0x16,0x55,0x55,0x25,0x00,
1361 0x00,0x45,0x47,0x45,0x45,0x45,0x75,0x00,
1362 0x00,0x62,0x55,0x55,0x55,0x55,0x52,0x00,
1363 0x00,0x62,0x55,0x55,0x65,0x45,0x43,0x00,
1364 0x00,0x63,0x54,0x52,0x61,0x55,0x52,0x00,
1365 0x00,0x75,0x25,0x25,0x25,0x25,0x22,0x00,
1366 0x00,0x55,0x55,0x55,0x55,0x27,0x25,0x00,
1367 0x00,0x55,0x55,0x25,0x22,0x52,0x52,0x00,
1368 0x00,0x73,0x12,0x22,0x22,0x42,0x72,0x03,
1369 0x00,0x46,0x42,0x22,0x22,0x12,0x12,0x06,
1370 0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x0F,
1371 0x00,0xE0,0x80,0x43,0xE5,0x85,0xE3,0x00,
1372 0x00,0x40,0x40,0x63,0x54,0x54,0x63,0x00,
1373 0x00,0x10,0x10,0x32,0x55,0x56,0x33,0x00,
1374 0x00,0x10,0x20,0x73,0x25,0x25,0x43,0x06,
1375 0x00,0x42,0x40,0x66,0x52,0x52,0x57,0x00,
1376 0x00,0x14,0x04,0x35,0x16,0x15,0x55,0x20,
1377 0x00,0x60,0x20,0x25,0x27,0x25,0x75,0x00,
1378 0x00,0x00,0x00,0x62,0x55,0x55,0x52,0x00,
1379 0x00,0x00,0x00,0x63,0x55,0x55,0x63,0x41,
1380 0x00,0x00,0x00,0x53,0x66,0x43,0x46,0x00,
1381 0x00,0x00,0x20,0x75,0x25,0x25,0x12,0x00,
1382 0x00,0x00,0x00,0x55,0x55,0x27,0x25,0x00,
1383 0x00,0x00,0x00,0x55,0x25,0x25,0x53,0x06,
1384 0x00,0x03,0x02,0x72,0x34,0x62,0x72,0x03,
1385 0x00,0x26,0x22,0x22,0x21,0x22,0x22,0x06,
1386 0x00,0x56,0xA9,0x06,0x04,0x06,0x09,0x06
1393 size_t ind8 = (
static_cast<size_t>(c) / 2) * 8;
1394 bool leftorright = (c % 2) == 0;
1396 for (
size_t boff = 0; boff < 8; ++boff)
1398 by = kPerfectFont[ind8++];
1399 if (leftorright) by = (by & 0xF0);
1400 else by = (by & 0x0F) << 4;
1401 g.setByteUnsafe(boff,by);
1407 Bitmap gprev{c,
const_cast<uint8_t *
>(scr_.pfont_)};
1409 return(Bitmap{gprev,{{0,0},{1,8}}});
1412template <
unsigned SCW,
unsigned SCH>
1416 perfectchars_{perfectchars},
1418 scldims_{scr.entireCharArea()},
1421 static_assert(SCH > 0,
"SCH parameter in ScaledTextPrinter must be > 0");
1422 static_assert(((SCW == 0) && (SCH == 1)) || (SCH > 0),
1423 "SCH must be 1 if SCW is 0 in ScaledTextPrinter");
1425 if constexpr(SCW == 0) scldims_.
width *= 2;
1428 scldims_.
width /= SCW;
1433template <
unsigned SCW,
unsigned SCH>
1437 RUNTIMEEXCEP(
"Tried to put scaled cursor out of screen");
1441template <
unsigned SCW,
unsigned SCH>
1444 if constexpr(SCW == 0)
1447 ((cur_.x % 2) == 1 ? 4 : 0) );
1449 return(
PixRect{{px,py},{4,8}});
1461template <
unsigned SCW,
unsigned SCH>
1464 if constexpr(SCW == 0)
1466 for (
size_t f = 0; f < txt.size(); ++f)
1470 auto g = getBitmap(c);
1474 uint8_t bh,bhr,mask1,mask2,pls;
1475 for (uint8_t b = 0; b < 8; ++b)
1477 bh = g.getByteUnsafe(b);
1482 for (uint8_t d = 0; d < 8; d += 2)
1484 bhr |= ((bh & mask1) << pls);
1487 bhr |= ((bh & mask2) << pls);
1493 g.setByteUnsafe(b,bhr);
1498 print(g.getAllBytes());
1503 static uint8_t bm[kLenBM];
1504 for (
size_t f = 0; f < txt.size(); ++f)
1508 auto g = getBitmap(c);
1511 if constexpr(SCW != 1) std::fill(bm,bm + kLenBM,0);
1513 for (
size_t scan = 0; scan < 8; ++scan)
1515 uint8_t b = g.getByteUnsafe(scan);
1516 if constexpr(SCW == 1) bm[off++] = b;
1520 uint8_t mask = 0b10000000;
1522 for (uint8_t bi = 0; bi < 8; ++bi)
1524 uint8_t bivat0 = (b & mask) >> (7-bi);
1525 for (
unsigned f = 0; f < SCW; ++f)
1527 bm[off] |= bivat0 << static_cast<uint8_t>(atbit);
1537 for (
unsigned f = 0; f < SCH-1; ++f)
1539 std::copy(bm + oldoff, bm + oldoff + kWidthInBytes,
1541 off += kWidthInBytes;
1552template <
unsigned SCW,
unsigned SCH>
1555 if constexpr(SCW == 0)
1559 uint8_t invmask = 0x00;
1560 if (cols_.inverse())
1562 if (cur_.x % 2) invmask = 0x0f;
1563 else invmask = 0xf0;
1566 for (uint8_t b = 0; b < 8; ++b)
1569 for (uint8_t b = 0; b < 8; ++b)
1570 g.setByteUnsafe(b,(bitmap[b] & 0xf0) ^ invmask);
1573 static const Bitmap gleft{138};
1574 static const Bitmap gright{133};
1575 auto & grscr = scr_.graphic();
1582 grscr.bitmap.merge(cur_.x % 2 ? gleft : gright,
1588 grscr.attrmap.setByte(cccur,scr_.attrForPrints(cccur,cols_));
1593 static_cast<CharDist>(kHeightInScans)}};
1595 uint8_t invmask = cols_.inverse() ? 0xff : 0x00;
1596 for (
size_t f = 0; f < g.size(); ++f)
1600 auto & grscr = scr_.graphic();
1607 for (
CharDist row = 0; row < SCH; ++row)
1608 for (
CharDist col = 0; col < SCW; ++col)
1610 grscr.attrmap.setByte(cccur,scr_.attrForPrints(cccur,cols_));
1612 if ((col == SCW - 1) ||
1613 (cccur.x >= scr_.entireCharArea().width))
1615 cccur.x = cur_.x * SCW;
1617 if (cccur.y >= scr_.entireCharArea().height)
1618 { row = SCH;
break; }
#define RUNTIMEEXCEP(txt)
Raise a runtime exception with the given std::string TXT + additional info.
std::string zxString(uint8_t cc)
Return a string composed of the ZX control code CC (no arguments).
One of the 8 basic colors of the ZX, not considering bright or flash.
A value of bright that is different to the same value of flash, inv or over.
Color specification for a character cell, plus modes of printing.
A value of flash that is different to the same value of bright, inv or over.
A printcolor for ink as a different type from a color for paper.
A value of inv that is different to the same value of flash, bright or over.
A value of over that is different to the same value of flash, bright or inv.
A printcolor for paper as a different type from a color for ink.
CharArea chararea
Char resolution.
Cursor< PixelCoordT, PixelCoordT > PixCursor
Shortcut for this kind of cursor.
constexpr CharDist SCREENCOLS
Number of columns in the screen of the original ZX.
Area< CharDistT, CharDistT > CharArea
Shortcut for this kind of area.
WidthType::type width
width of the area.
constexpr CharDist SCREENROWS
Number of rows in the screen of the original ZX.
Area< CharDistT, PixelDistT > CharPixArea
Shortcut for this kind of area.
constexpr PixelCoord pixelOfCharX(CharCoord cc) noexcept
Conversion from an x-CharCoord to PixelCoord.
void setByteUnsafe(size_t offset, uint8_t b) noexcept
Change the byte at the given offset without checking anything.
PixArea pixarea
Pixel resolution.
constexpr PixelCoord pixelOfCharY(CharCoord cc) noexcept
Conversion from a y-CharCoord to PixelCoord.
CharPixCursor getCharPixCursor(const CharCursor &cc)
Convert a char cursor to a char-pix cursor placed at the top of the former.
GraphOp
Possible operations on Graphics.
bool contains(const cursor_type &cur) const noexcept
Return TRUE if CUR is inside the rectangle.
uint16_t PixelDist
A distance measured in screen pixels.
uint16_t CharCoord
Represent both x and y screen char coordinates.
HeightType::type height
height of the area.
constexpr PixelDist charDistToPixelDist(CharDist pc) noexcept
Conversion from CharDist to PixelDist.
Rect< CharDistT, CharDistT > CharRect
Shortcut for this kind of rectangle.
uint16_t PixelCoord
Represent both x and y screen pix coordinates.
int16_t IntDist
Positive and negative distances on screen.
Cursor< CharCoordT, CharCoordT > CharCursor
Shortcut for this kind of cursor.
WidthType::type x
Coordinate in width (horizontally).
uint16_t CharDist
A distance meadured in screen chars.
@ OR
OR the graphic and the screen content.
@ AND
AND the graphic and the screen content.
@ XOR
XOR the graphic and the screen content.
@ COPY
put the graphic on the screen (substitution)
A graphic that contains a bitmap, i.e., it has pixel resolution in height.
A cursor on screen that uses the given coordinates resolution.
An area with both char and pixel resolutions, possibly synchronized.
A bitmap plus an attrmap, possibly synchronized.
The ZX keyboard as it behaves (for typing) under the ZX operating system.
The zx keyboard as a membrane. Useful for games and those sort of things.
char getChannel(void) const
Return the current channel.
Screen & operator<<(const CharCursor &at)
Calculate the attr to put at POS for getting DESIRED colors there.
void changeChannel(char c)
Set current channel to C (either 'K' or 'S') without changing cursor.
CharCursor nonflatTextCoords(char channel, const CharCursor &pos) const
Return POS transformed from flat model to the given channel.
BasicColor border(void) const noexcept
Get the current border color.
static void fillInitialFontBitmaps(uint8_t *p)
Fill from the given address the ZX original 32-127 character bitmaps.
void fillKColors(BasicColor b, Colors &colors) const
Fill COLORS with colors for K channel calculated from border color B.
PixCursor nonflatPixelCoords(const PixCursor &pos) const
Return POS transformed from flat into non-flat coords.
bool flatInput_printItem(const std::string &item)
Callback needed for doing input in the flat model version.
BASICScreen(Screen &scr, const KeyWait &keywait=[](void) -> Keyboard { return(Keyboard{});})
Constructor: decorates an existing Screen object.
Screen & operator<<(Ink i)
Calculate the attr to put at POS for getting DESIRED colors there.
const CharArea & scaledDimensions(void) const noexcept
< Return the scaled dimensions of the screen with this printer.
bool inside(const CharRect &r) const noexcept
< Return TRUE if the given rectangle is inside the screen entirely.
std::string to_string(void) const
< Return a string with the info about this object.
CharCursor flatTextCoords(char channel, const CharCursor &pos) const
Return a version of POS (that corresponds to CHANNEL) in the flat model.
void getGlobalColors(char channel, Colors &colors) const
Fill COLS with a copy of the global colors in the given channel.
std::function< bool(const std::string &) > PrintItem
const DoubleArea & info(void) const noexcept
Return a read-only reference to the info of this Screen.
std::string input(bool withquotes, const Keyboard &k0, const Screen::InputCallbacks::GetNewKeyboard &cbk, const Screen::InputCallbacks::Play &cbp, const Screen::InputCallbacks::CheckInput &cnci)
Do input in the original mode.
size_t printSize(const std::string &txt, CharCursor &cur, CharArea &area, size_t &nscrlls) const
Do a fake printing of TXT at position CUR to calculate printing size.
CharArea entireCharArea(void) const
Return a CharArea covering the whole screen.
void draw(IntDist incx, IntDist incy, const Colors *cmc=nullptr)
Draw a straight line.
Screen(uint8_t *bitmap, uint8_t *attrmap, const CharArea &dimensions={SCREENCOLS, SCREENROWS}, const ExpandToken expandtoken=kInvExpandToken)
Constructor that does not create the bitmap/attrmap, but uses external.
void plot(const PixCursor &pos, const Colors *cmc=nullptr)
Plot the given point using original, non-flat ZX plot coordinates.
Colors & colors(void) noexcept
Return a reference to the current colors to read and write them.
std::function< Keyboard(void) > KeyWait
Routine that waits for a key press and return the resulting keyboard.
bool point(const PixCursor &pos) const
< Return TRUE if the given point is on or FALSE if it is off.
void scrollUp(PixelDist howmany=8, PixelCoord upperrow=0)
Scroll the bitmap HOWMANY pixels up from UPPERROW, & maybe the attrmap.
virtual ~BASICScreen(void)=default
Constructor: decorates an existing Screen object.
static const ExpandToken kNudeExpandToken
Expand token that return token text without trailing/leading spaces.
CheckInput checkInput
Callback to check input validity.
const CharCursor & getTextCursor(void) const noexcept
Get the current cursor position for printing in flat model coordinates.
void setTextCursor(char channel, const CharCursor &pos)
Set the channel to CHANNEL and put the cursor where requested.
const uint8_t * currentFontBitmap(void) const noexcept
Return the current font bitmap, or nullptr if it is the ZX original one.
void printRectangle(const CharRect &rect, char c, const Colors *cmc=nullptr)
Fill the given rectangle with the given char with given colors.
bool newlineDone
TRUE if there has been any newline movement.
void putChar(const uint8_t *d)
Put the 1-char bitmap D (8 bytes) exactly as in put().
static CharArea areaForPrint(const std::string &txt, const ExpandToken &expandtoken=kNudeExpandToken)
Fill from the given address the ZX original 32-127 character bitmaps.
BASICScreen(const BASICScreen &)=delete
Constructor: decorates an existing Screen object.
void restoreGlobalColors(char channel)
Set the current, local colors in the channel to the global ones.
Screen & operator<<(const std::string &txt)
Calculate the attr to put at POS for getting DESIRED colors there.
Screen & operator<<(Paper p)
Calculate the attr to put at POS for getting DESIRED colors there.
void resetChannelK(void)
Reset cursors, size and contents of channel K to its initial values.
CharDist scrollCnt(void) const noexcept
Return how many scrolls will be done (+1) before asking.
ScaledTextPrinter & operator=(ScaledTextPrinter &&)=delete
Return a reference to the underlying Screen.
const PixCursor & lastPlot(void) const noexcept
Return the coordinates of the last plot.
Screen(const CharArea &dimensions={SCREENCOLS, SCREENROWS}, const ExpandToken expandtoken=kInvExpandToken)
Default constructor with given dimensions (cannot be empty area).
void draw(IntDist incx, IntDist incy, const Colors *cmc=nullptr)
Draw the given line using original, non-flat ZX plot increments.
void cls(void)
Clear the Screen by putting all bitmap to 0 and attrs as current color.
size_t print(const std::string &txt, size_t printmax=0)
Calculate the attr to put at POS for getting DESIRED colors there.
static const CharDist kInitialRowsK
Number of character rows initially in the K channel.
uint8_t attrForPrints(const CharCursor &pos, const Colors &desired) const
Calculate the attr to put at POS for getting DESIRED colors there.
size_t flatAttrmap(size_t offset) const
Return an attrmap offset in the flat model given the non-flat one.
size_t howmanyScrolls
How many one-text-line scrolls were done.
Screen(const Screen &)=delete
Default constructor with given dimensions (cannot be empty area).
GetNewKeyboard getNewKeyboard
Callback to get changes in keyboard.
void input(std::string &res, const InputCallbacks &callbacks, const CharCursor &pos, const Colors &c0, const Keyboard &k0, bool withquotes, CharDist maxscrolls, size_t maxlen=0, const Beep &b=Beep{})
Do input like the ZX, storing the resulting string into RES.
void reset(void)
Set the K and S channels to their initial cursors and sizes, as in CLS.
const CharRect & subRegion(void) const noexcept
Return the region within a containing Screen, or empty if not contained.
void put(uint8_t c)
Calculate the attr to put at POS for getting DESIRED colors there.
std::function< std::string(uint8_t c)> ExpandToken
User's routine that must expand a given token code into the token text.
static void fillInitialUDGBitmaps(uint8_t *p)
Fill from the given address the original ZX UDG bitmaps.
std::string to_string(void) const
Return a text with info about the current state of the decorator.
Screen(Screen &oth, const CharRect ®ion, const ExpandToken expandtoken=kInvExpandToken)
Constructor of a subscreen covering a (non-empty area) region of anothr.
void copyFontBitmap(uint8_t *dest) const
Copy all the characters from the current font bitmap into DEST.
const CharCursor & getCursor(void) const noexcept
Return the current scaled cursor.
void changeGlobalColors(char channel, const Colors &newcols)
Change the global colors in the given channel to NEWCOLS.
bool originalInput_printItem(const std::string &txt)
Callback routine for using in Screen::input() that respects this model.
static std::pair< CharArea, size_t > printArea(const CharArea &area, const std::string &txt, const ExpandToken &expandtoken=kNudeExpandToken)
Return the space occupied by TXT if printed at (0,0) within AREA.
size_t flatBitmap(size_t offset) const
Return a bitmap offset in the flat model given the non-flat one.
void rectangle(const PixRect &rect, const Colors *cmc=nullptr)
Draw a 1-pixel thick rectangular contour.
Screen & operator<<(Over o)
Calculate the attr to put at POS for getting DESIRED colors there.
bool add(const ScrollInfo &si1) noexcept
< Add the info of SI1 to this, returning the breaking of scrolls.
std::function< bool(const std::string &) > CheckInput
void print(const std::string &txt)
Print the given text at the current scaled position.
bool columnAtLeft(void) const
TRUE if the current non-flat column at the current channel is at left.
BASICScreen & operator=(const BASICScreen &)=delete
Constructor: decorates an existing Screen object.
BASICScreen & operator=(BASICScreen &&)=delete
Constructor: decorates an existing Screen object.
void changeFontBitmap(const uint8_t *pfont) noexcept
Change the bitmap for the font used to print characters 32-127.
static const ExpandToken kInvExpandToken
Expand token routine that always generates CHRINVALID as expansion.
Screen & operator<<(Inverse i)
Calculate the attr to put at POS for getting DESIRED colors there.
void plot(const PixCursor &pos, const Colors *cmc=nullptr)
Equivalent to the original Spectrum BASIC plot command.
Colors & colors(void) noexcept
Get reference to the current colors that can be used to write and read.
CharRect entireCharRect(void) const
Return a CharRect covering the whole screen.
static void checkChannel(char c, const std::string &place="")
Screen & operator<<(Bright b)
Calculate the attr to put at POS for getting DESIRED colors there.
const ExpandToken & expandToken(void) const noexcept
Return a read-only reference to the expand token routine.
bool validPixel(const PixCursor &pos) const noexcept
< Return TRUE if the given coordinates are inside the bitmap.
void scrollUpAttrs(CharDist howmany=1, CharCoord upperrow=0)
Scroll HOWMANY rows of chars in the attrmap starting at UPPERROW.
Screen & flat(void) const
Return a reference to the underlying flat screen. */.
Play play
Callback to play keyboard clics.
Screen(Screen &&)=delete
Default constructor with given dimensions (cannot be empty area).
static constexpr size_t kFontSize
Size in bytes of all bitmaps of a font.
static const PixelDist kInitialHeightK
Number of pixel rows initially in the K channel.
size_t nonflatBitmap(size_t offset) const
Return a bitmap offset in the non-flat model given the flat one.
ScrollInfo print(const std::string &txt)
Print a string, possibly containing ctrl chars, in the current channel.
PrintItem printItem
Callback to print items in the screen.
const uint8_t * currentUDGsBitmap(void) const noexcept
Return the current UDGs bitmap, or nullptr if it is the ZX original one.
void circle(const PixCursor ¢er, PixelDist r, const Colors *cmc=nullptr)
Draw the given circle using original, non-flat ZX plot coordinates.
void circle(const PixCursor ¢er, PixelDist r, const Colors *cmc=nullptr)
Draw a circle.
BASICScreen(BASICScreen &&)=delete
Constructor: decorates an existing Screen object.
bool point(const PixCursor &pos) const
Return TRUE if the given pixel has ink color; otherwise return FALSE.
std::function< void(const Beep &) > Play
Screen & operator=(const Screen &)=delete
Default constructor with given dimensions (cannot be empty area).
void setCursor(const CharCursor &stc)
Put the current scaled cursor at STC or throw if out of screen.
PixCursor flatPixelCoords(const PixCursor &pos) const
Return a version of POS in the flat model.
Screen & operator=(Screen &&)=delete
Default constructor with given dimensions (cannot be empty area).
void setScrollCnt(CharDist newcnt)
Change to NEWCNT the current count of scrolls to do wihout asking.
void changeUDGsBitmap(const uint8_t *pudgs) noexcept
Set to PUDGS the memory address where UDGs are defined.
DoubleGraphic & graphic(void) noexcept
Return a reference to the bitmap + attrmap of this Screen.
CharCursor getTextCursor(char ch=0x00) const
Return the non-flat text cursor of the given channel ('S' or 'K').
void setBorder(BasicColor c) noexcept
Change the border color.
virtual ~Screen(void)
Destroy the Screen.
std::function< void(const Keyboard &, Keyboard &, Membrane &, std::string &) > GetNewKeyboard
void moveNewLine(void)
Move text cursor to a new line without printing CHRENTER.
void setTextCursor(const CharCursor &pos)
Set the cursor for printing at the given flat model coordinates.
PixRect getCursorRect(void) const noexcept
Return the pixel rectangle of the cursor.
uint8_t recognizeCharInGrBlocks(const Bitmap &charbitmap) const
The same as recognizeCharInFont() but for a ZX graphic block.
uint8_t recognizeCharInFont(const Bitmap &charbitmap, uint8_t howmany=CHRFIRSTGB - CHRSPC, bool evenwithinv=true) const
Return the ASCII code of a char in the current font that has that bitmp.
size_t nonflatAttrmap(size_t offset) const
Return an attrmap offset in the non-flat model given the flat one.
ScaledTextPrinter(Screen &scr, bool perfectchars=true)
Create a scaled text printer for the given screen; cursor at 0,0.
Screen & operator<<(Flash f)
Calculate the attr to put at POS for getting DESIRED colors there.
Just a shorter renaming of CharCursor.
This class decorates Screen to get the original BASIC screen model of the ZX.
The class that provides the main support for managing the ZX screen.
A class for printing with scaled characters.
The main namespace of the library, that spans across all the zx modules.
constexpr uint8_t CHRLASTGB
last graphic-block char
constexpr bool ISGRAPHICBLOCK(uint8_t c) noexcept
Return TRUE if C is a graphic block character. */.
constexpr uint8_t CHRFIRSTGB
first graphic-block char
Key
A single key in the zx keyboard.
constexpr uint8_t CHRPAPER
paper (control code; 1 arg)
constexpr uint8_t CHROVER
over (control code; 1 arg)
constexpr uint8_t CHRINVERSE
inverse (control code; 1 arg)
constexpr uint8_t CHRFLASH
flash (control code; 1 arg)
constexpr uint8_t CHRSPC
space
constexpr uint8_t CHRINVALID
invalid mark char
constexpr uint8_t CHRINK
ink (control code; 1 arg)
constexpr uint8_t CHRFIRSTTOKEN
first token char
constexpr uint8_t CHRBRIGHT
bright (control code; 1 arg)