The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
ZXScreen.h
Go to the documentation of this file.
1
2/* **************************************************************************/
24#ifndef ZXSCREEN
25#define ZXSCREEN
26
27#include <string>
28#include <functional>
29#include <algorithm>
30#include <utility>
31#include <limits>
37
38namespace zxeco
39{
40
41/******************************************************************************
42*
43* Class: At
44*
45*******************************************************************************/
46
48
50class At: public CharCursor
51{
52 public:
53
54 using CharCursor::CharCursor;
55
56 At(const CharCursor & cc):CharCursor{cc} {}
57 At(CharCursor && cc):CharCursor{std::move(cc)} {}
58 At & operator=(const CharCursor & cc) { return(*this = cc); }
59 At & operator=(CharCursor && cc) { return(*this = std::move(cc)); }
60};
61
62
63/******************************************************************************
64*
65* Class: Screen
66*
67*******************************************************************************/
68
70
88class Screen
89{
90 public:
91
92 /* -------------- Types, consts., etc. -------------- */
95 using ExpandToken = std::function< std::string(uint8_t c)>;
97
100
103
104 static constexpr size_t kFontSize =
105 static_cast<size_t>(CHRFIRSTGB - CHRSPC) * 8;
107
109
111 {
112 using PrintItem = std::function< bool(const std::string &) >;
118 using GetNewKeyboard = std::function< void(const Keyboard &,
119 Keyboard &, Membrane &,
120 std::string &) >;
126 using Play = std::function< void(const Beep &) >;
131 using CheckInput = std::function< bool(const std::string &) >;
139 };
140
141
143
156 template <unsigned SW, unsigned SH>
158 {
159 public:
160
161 ScaledTextPrinter(Screen & scr, bool perfectchars = true);
163
172 ScaledTextPrinter(const ScaledTextPrinter &) = delete;
174 ScaledTextPrinter & operator=(const ScaledTextPrinter &) = delete;
176
177
179 Screen & underlyingScreen(void) noexcept { return(scr_); }
180
181 const CharArea & scaledDimensions(void) const noexcept
183 { return(scldims_); }
184
185 Colors & colors(void) noexcept { return(cols_); }
187
188 void setCursor(const CharCursor & stc);
190
191 const CharCursor & getCursor(void) const noexcept { return(cur_); }
193
194 PixRect getCursorRect(void) const noexcept;
196
197 void print(const std::string & txt);
199
208 void print(const uint8_t * bitmap);
210
218 private:
219
220 static constexpr size_t kWidthInBytes = static_cast<size_t>(SW);
221 static constexpr size_t kHeightInScans =
222 static_cast<size_t>(charDistToPixelDist(SH));
223 static constexpr size_t kLenBM = kWidthInBytes * kHeightInScans;
224
225 Screen & scr_;
226 const bool perfectchars_;
227 CharArea scldims_;
228 CharCursor cur_;
229 Colors cols_;
230
231 void incCursor(void);
232 Bitmap getBitmap(uint8_t c);
233 };
234
241 static void fillInitialFontBitmaps(uint8_t * p);
243
244 static void fillInitialUDGBitmaps(uint8_t * p);
246
247 static std::pair<CharArea,size_t> printArea(const CharArea & area,
248 const std::string & txt,
249 const ExpandToken & expandtoken=
252
259 static CharArea areaForPrint(const std::string & txt,
260 const ExpandToken & expandtoken =
263
266 { auto res = printArea(CharArea{std::numeric_limits<CharDist>::max(),
267 std::numeric_limits<CharDist>::max()},
268 txt,expandtoken);
269 return(res.first); }
270
277 Screen(const CharArea & dimensions = {SCREENCOLS,SCREENROWS},
278 const ExpandToken expandtoken = kInvExpandToken);
280
288 Screen(uint8_t * bitmap, uint8_t * attrmap,
289 const CharArea & dimensions = {SCREENCOLS,SCREENROWS},
290 const ExpandToken expandtoken = kInvExpandToken);
292
299 Screen(Screen & oth, const CharRect & region,
300 const ExpandToken expandtoken = kInvExpandToken);
302
308 Screen(const Screen &) = delete;
309 Screen & operator=(const Screen &) = delete;
310 Screen(Screen &&) = delete;
311 Screen & operator=(Screen &&) = delete;
312
313 virtual ~Screen(void);
315
322 const DoubleArea & info(void) const noexcept { return(myinfo_); }
324
325 const ExpandToken & expandToken(void) const noexcept {return(expandtoken_);}
327
328 CharArea entireCharArea(void) const { return(myinfo_.chararea); }
330
332 { return(CharRect{{0,0},entireCharArea()}); }
334
337 const CharRect & subRegion(void) const noexcept { return(subregion_); }
340 bool inside(const CharRect & r) const noexcept
342 { return(! ((r.corner.x >= myinfo_.chararea.width) ||
343 (r.corner.y >= myinfo_.chararea.height) ||
344 (r.corner.x + r.area.width > myinfo_.chararea.width) ||
345 (r.corner.y + r.area.height > myinfo_.chararea.height))); }
347 void cls(void);
349
362 void scrollUp(PixelDist howmany = 8, PixelCoord upperrow = 0);
364
378 void scrollUpAttrs(CharDist howmany = 1, CharCoord upperrow = 0);
380
400 void setBorder(BasicColor c) noexcept { mybordercol_ = c; }
403 BasicColor border(void) const noexcept { return(mybordercol_); }
406 Colors & colors(void) noexcept { return(currcmodes_); }
408
422 DoubleGraphic & graphic(void) noexcept { return(mymap_); }
425 const DoubleGraphic & graphic(void) const noexcept { return(mymap_); }
427
434 const uint8_t * currentFontBitmap(void) const noexcept { return(pfont_); }
437 void changeFontBitmap(const uint8_t * pfont) noexcept { pfont_ = pfont; }
439
451 void copyFontBitmap(uint8_t * dest) const;
453
456 const uint8_t * currentUDGsBitmap(void) const noexcept { return(pudgs_); }
458
459 void changeUDGsBitmap(const uint8_t * pudgs) noexcept { pudgs_ = pudgs; }
461
465 uint8_t recognizeCharInFont(const Bitmap & charbitmap,
466 uint8_t howmany = CHRFIRSTGB - CHRSPC,
467 bool evenwithinv = true) const;
469
483 uint8_t recognizeCharInGrBlocks(const Bitmap & charbitmap) const;
485
495 uint8_t attrForPrints(const CharCursor & pos, const Colors & desired) const;
497
505 uint8_t attrForPrints(size_t offset, const Colors & desired) const;
510 void setTextCursor(const CharCursor & pos) { cursor_ = pos; }
512
520 const CharCursor & getTextCursor(void) const noexcept { return(cursor_); }
522
523 void put(uint8_t c)
525
528 { if ((c >= CHRSPC) &&
529 (c < CHRFIRSTTOKEN)) putChar(c,cursor_,currcmodes_);
530 else putChar(CHRINVALID,cursor_,currcmodes_); }
532 void putChar(const uint8_t * d) { putCharBitmap(d,cursor_,currcmodes_); }
534
535 size_t print(const std::string & txt, size_t printmax = 0)
536
564 { size_t prmax{printmax};
565 return(printRaw(txt,cursor_,currcmodes_,true,prmax)); }
566
567 size_t printSize(const std::string & txt, CharCursor & cur,
568 CharArea & area, size_t & nscrlls) const;
570
576 Screen & operator<<(const std::string & txt)
577 { print(txt); return(*this); }
578 Screen & operator<<(uint8_t c) // also for char
579 { print(std::string(1,static_cast<char>(c))); return(*this); }
581 { setTextCursor(at); return(*this); }
583 { print(zxString(CHRPAPER,static_cast<uint8_t>(p))); return(*this); }
585 { print(zxString(CHRINK,static_cast<uint8_t>(i))); return(*this); }
587 { print(zxString(CHRBRIGHT,static_cast<uint8_t>(b))); return(*this); }
589 { print(zxString(CHRFLASH,static_cast<uint8_t>(f))); return(*this); }
591 { print(zxString(CHRINVERSE,static_cast<uint8_t>(i))); return(*this); }
593 { print(zxString(CHROVER,static_cast<uint8_t>(o))); return(*this); }
594
595 void printRectangle(const CharRect & rect, char c,
596 const Colors * cmc = nullptr);
598
607 bool flatInput_printItem(const std::string & item);
609
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{});
623
647 bool validPixel(const PixCursor & pos) const noexcept
649 { return((pos.x < myinfo_.pixarea.width) &&
650 (pos.y < myinfo_.pixarea.height)); }
651
652 bool point(const PixCursor & pos) const;
654
656 void plot(const PixCursor & pos, const Colors * cmc = nullptr);
658
690 const PixCursor & lastPlot(void) const noexcept { return(lastplot_); }
692
693 void draw(IntDist incx, IntDist incy, const Colors * cmc = nullptr);
695
708 void draw(IntDist incx, IntDist incy, double arc,
709 const Colors * cmc = nullptr);
711
742 void circle(const PixCursor & center, PixelDist r,
743 const Colors * cmc = nullptr);
745
761 void rectangle(const PixRect & rect, const Colors * cmc = nullptr);
763
770 private:
771
772 static const std::vector< std::string > TOKENTEXTS;
773 static const LinearGraphic::GraphOp GRAPHOPSFORMODES_[2][2];
774
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,
781 double w1,
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,
788 double h1,
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;
793
794 ExpandToken expandtoken_;
795 DoubleGraphic mymap_;
796 const DoubleArea myinfo_;
797 const CharRect subregion_;
798 BasicColor mybordercol_;
799 Colors currcmodes_;
800 CharCursor cursor_;
801 PixCursor lastplot_;
802 const uint8_t * pfont_;
803 const uint8_t * pudgs_;
804
805 size_t adjustCursorToPrint(CharCursor & cur, bool scroll = true) noexcept;
806 void putChar(uint8_t c, const CharCursor & cur, const Colors & cmc);
807 void putCharBitmap(const uint8_t * bitmap,
808 const CharCursor & cur, const Colors & cmc);
809 size_t printRaw(const std::string & txt, CharCursor & cur, Colors & cols,
810 bool printit, size_t & maxprint,
811 CharArea * printbound = nullptr,
812 size_t * printlength = nullptr);
813 uint8_t attrForPlots(const PixCursor & pos,
814 bool colorsembedded,
815 const Colors & cmc) const;
816 void plotWithAttrColors(const PixCursor & pos, bool colorsembedded,
817 const Colors & cmc);
818 bool drawHoriz(PixelDist incx, bool colorsembedded,
819 const Colors & cmc);
820 bool drawVert(PixelDist incy, bool colorsembedded,
821 const Colors & cmc);
822 bool drawWithAttrColors(IntDist incx, IntDist incy, bool colorsembedded,
823 const Colors & cmc);
824 double yCoordInPlane(double y) const noexcept
825 { return(static_cast<double>(myinfo_.pixarea.height - 1) - y); }
826 bool drawArc(IntDist xi0, IntDist yi0, IntDist xi1, IntDist yi1, double g,
827 bool colorsembedded, const Colors &cmc);
828 bool drawWithAttrColors(IntDist incx, IntDist incy, double arc,
829 bool colorsembedded,
830 const Colors &cmc);
831 bool drawCircleWithAttrColors(const PixCursor & center, PixelDist r,
832 bool colorsembedded,
833 const Colors &cmc);
834
835};
836
837
838/******************************************************************************
839*
840* Class: BASICScreen
841*
842*******************************************************************************/
843
845
912{
913 public:
914
915 /* @name -------------- Types, consts., etc. -------------- */
918 using KeyWait = std::function < Keyboard (void) >;
920
923 {
928
929 ScrollInfo(void):acceptedScroll{true},
931 newlineDone{false} {}
932
933 bool add(const ScrollInfo & si1) noexcept
935 { acceptedScroll = acceptedScroll && si1.acceptedScroll;
936 howmanyScrolls += si1.howmanyScrolls;
937 newlineDone = newlineDone || si1.newlineDone;
938 return(acceptedScroll); }
939
940 std::string to_string(void) const
942 { return(std::string{"ScrollInfo("} +
943 (acceptedScroll ? "no-break" : "BREAK") + ", " +
944 std::to_string(howmanyScrolls) + " scrolls, " +
945 (newlineDone ? "no-nl" : "NEWLINE") + ")"); }
946 };
947
948 static const CharDist kInitialRowsK = 2;
950
953
957 /* @name -------------- Class methods -------------- */
960 static void checkChannel(char c, const std::string & place = "")
962
963 { if ((c != 'S') && (c != 'K'))
964 RUNTIMEEXCEP("Invalid channel '" + std::string{c} + "'"); }
965
969 /* @name -------------- Constructors -------------- */
972 BASICScreen(Screen & scr, const KeyWait & keywait =
973 [](void) -> Keyboard
974 {
975 return(Keyboard{});
976 });
978
990 BASICScreen(const BASICScreen &) = delete;
994
995 virtual ~BASICScreen(void) = default;
996
1000 /* @name -------------- Transformations to flat coordinates ------------- */
1003 size_t flatBitmap(size_t offset) const;
1005
1010 size_t flatAttrmap(size_t offset) const { return(offset); }
1012
1017 CharCursor flatTextCoords(char channel, const CharCursor & pos) const;
1019
1023 PixCursor flatPixelCoords(const PixCursor & pos) const;
1025
1030 /* @name ----------- Transformations from flat coordinates -------------- */
1033 size_t nonflatBitmap(size_t offset) const;
1035
1040 size_t nonflatAttrmap(size_t offset) const { return(offset); }
1042
1047 CharCursor nonflatTextCoords(char channel, const CharCursor & pos) const;
1049
1052 PixCursor nonflatPixelCoords(const PixCursor & pos) const;
1054
1059 /* @name -------------- General methods -------------- */
1062 Screen & flat(void) const { return(screen_); }
1064
1065 void reset(void);
1067
1072 void resetChannelK(void) { resetK(true); }
1077 CharDist scrollCnt(void) const noexcept { return(howmanyuntilaskscroll_); }
1079
1082 void setScrollCnt(CharDist newcnt) { howmanyuntilaskscroll_ = newcnt; }
1084
1089 /* @name -------------- Color methods -------------- */
1092 void fillKColors(BasicColor b, Colors & colors) const;
1094
1095 void changeGlobalColors(char channel, const Colors & newcols);
1101 void getGlobalColors(char channel, Colors & colors) const;
1103
1104 void restoreGlobalColors(char channel);
1106
1110 /* @name -------------- Cursor methods -------------- */
1113 void changeChannel(char c);
1115
1123 char getChannel(void) const { return(curch_); }
1125
1126 void setTextCursor(char channel, const CharCursor & pos);
1132 CharCursor getTextCursor(char ch = 0x00) const;
1134
1136 bool columnAtLeft(void) const { return(getTextCursor().x == 0); }
1138
1142 /* @name -------------- Text printing methods -------------- */
1145 ScrollInfo print(const std::string & txt);
1147
1159 void moveNewLine(void) { advanceCursor(true); }
1161
1168 /* -------------- Drawing methods -------------- */
1171 void plot(const PixCursor & pos, const Colors * cmc = nullptr);
1173
1175 void draw(IntDist incx, IntDist incy, const Colors * cmc = nullptr);
1177
1179 void draw(IntDist incx, IntDist incy, double arc,
1180 const Colors * cmc = nullptr);
1182
1184 void circle(const PixCursor & center, PixelDist r,
1185 const Colors * cmc = nullptr);
1187
1189 bool point(const PixCursor & pos) const
1191
1192 {// in the original ZX, the K area is ignored for drawing/plotting
1193 return(screen_.point(flatPixelCoords(pos))); }
1194
1198 /* @name -------------- Input methods -------------- */
1201 bool originalInput_printItem(const std::string & txt);
1203
1218 std::string input(bool withquotes, const Keyboard & k0,
1220 const Screen::InputCallbacks::Play & cbp,
1223
1234 /* @name -------------- Miscellaneous methods -------------- */
1237 std::string to_string(void) const;
1239
1244 private:
1245
1246 Screen & screen_;
1247 KeyWait keywait_;
1248
1249 char curch_;
1250
1251 CharDist initflatfirstrowofK_; // in the flat model
1252 CharDist curflatfirstrowofK_; // in the flat model
1253 CharCursor curflatK_; // in the flat model
1254 Colors globalattrsK_;
1255 Colors curattrsK_;
1256
1257 CharCursor curflatS_; // in the flat model
1258 Colors globalattrsS_,curattrsS_;
1259 CharDist howmanyuntilaskscroll_;
1260
1261
1262 CharCursor & curCurChannel(char c)
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)
1276 { screen_.setTextCursor(curCurChannel(c)); }
1277 void getCursorChannel(char c)
1278 { curCurChannel(c) = screen_.getTextCursor(); }
1279 void printSpcRect(const CharRect & rect);
1280 void resetS(void);
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);
1292
1293};
1294
1295
1296
1297
1298
1299
1300/*============================================================================
1301
1302 TEMPLATE IMPLEMENTATIONS
1303
1304==============================================================================*/
1305
1306
1307
1308/*****************************************************************************
1309*
1310* Template subclass: Screen::ScaledTextPrinter
1311*
1312*******************************************************************************/
1313
1314template <unsigned SCW, unsigned SCH>
1315void Screen::ScaledTextPrinter<SCW,SCH>::incCursor(void)
1316{
1317 ++cur_.x;
1318 if (cur_.x >= scldims_.width)
1319 {
1320 cur_.x = 0;
1321 ++cur_.y;
1322 if (cur_.y >= scldims_.height) return;
1323 }
1324}
1325
1326template <unsigned SCW, unsigned SCH>
1327Bitmap Screen::ScaledTextPrinter<SCW,SCH>::getBitmap(uint8_t c)
1328// Return an already scaled bitmap if SCW == 1 (hald-width) and perfectchars_
1329{
1330 if ((c < CHRSPC) || (c > CHRLASTGB)) c = CHRINVALID;
1331
1332 if constexpr(SCW == 0) // compile-time #if -> half width chars
1333 {
1334 // just to be created in that template case
1335 static const uint8_t kPerfectFont[] =
1336 { // by Andrew Owen 2007 (except noted modifications):
1337 // https://chuntey.wordpress.com/2010/01/08/64-column-print/
1338 // 2 chars into each 8-byte chunk, each one in 4 bits
1339 0x00,0x02,0x02,0x02,0x02,0x00,0x02,0x00, // spc, ! -> 32 and 33
1340 0x00,0x55,0x57,0x05,0x05,0x07,0x05,0x00, // # modified
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, // pound modified
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, // { modified
1385 0x00,0x26,0x22,0x22,0x21,0x22,0x22,0x06, // } modified
1386 0x00,0x56,0xA9,0x06,0x04,0x06,0x09,0x06
1387 };
1388
1389 if (perfectchars_ && (c < CHRFIRSTGB))
1390 {
1391 Bitmap g{CharPixArea{1,8}};
1392 c = c - CHRSPC;
1393 size_t ind8 = (static_cast<size_t>(c) / 2) * 8;
1394 bool leftorright = (c % 2) == 0; // 0-left, 1-right
1395 uint8_t by;
1396 for (size_t boff = 0; boff < 8; ++boff)
1397 {
1398 by = kPerfectFont[ind8++];
1399 if (leftorright) by = (by & 0xF0);// must scale to the high nibb
1400 else by = (by & 0x0F) << 4;
1401 g.setByteUnsafe(boff,by);
1402 }
1403 return(g);
1404 }
1405 }
1406
1407 Bitmap gprev{c,const_cast<uint8_t *>(scr_.pfont_)}; // no owner
1408
1409 return(Bitmap{gprev,{{0,0},{1,8}}}); // get ownership
1410}
1411
1412template <unsigned SCW, unsigned SCH>
1414 bool perfectchars):
1415 scr_{scr},
1416 perfectchars_{perfectchars},
1417 cur_{0,0},
1418 scldims_{scr.entireCharArea()},
1419 cols_{scr.colors()}
1420{
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");
1424
1425 if constexpr(SCW == 0) scldims_.width *= 2;
1426 else
1427 {
1428 scldims_.width /= SCW;
1429 scldims_.height /= SCH;
1430 }
1431}
1432
1433template <unsigned SCW, unsigned SCH>
1435{
1436 if (!CharRect{{0,0},scldims_}.contains(stc))
1437 RUNTIMEEXCEP("Tried to put scaled cursor out of screen");
1438 cur_ = stc;
1439}
1440
1441template <unsigned SCW, unsigned SCH>
1443{
1444 if constexpr(SCW == 0) // compile-time #if -> half width chars
1445 {
1446 auto px = static_cast<PixelCoord>( pixelOfCharX(cur_.x / 2) +
1447 ((cur_.x % 2) == 1 ? 4 : 0) );
1448 auto py = pixelOfCharY(cur_.y);
1449 return(PixRect{{px,py},{4,8}});
1450 }
1451 else
1452 {
1453 auto px = pixelOfCharX(cur_.x * SCW);
1454 auto py = pixelOfCharY(cur_.y * SCH);
1455 return(PixRect{{px,py},
1456 {static_cast<PixelDist>(SCW * 8),
1457 static_cast<PixelDist>(SCH * 8)}});
1458 }
1459}
1460
1461template <unsigned SCW, unsigned SCH>
1463{
1464 if constexpr(SCW == 0) // compile-time #if -> half width chars
1465 {
1466 for (size_t f = 0; f < txt.size(); ++f)
1467 {
1468 // get bitmap
1469 uint8_t c = txt[f];
1470 auto g = getBitmap(c); // ownership in G, already scaled if perfect
1471 if ((!perfectchars_) || (c >= CHRFIRSTGB))
1472 {
1473 // halve the G bitmap automatically onto high nibble of G
1474 uint8_t bh,bhr,mask1,mask2,pls;
1475 for (uint8_t b = 0; b < 8; ++b)
1476 {
1477 bh = g.getByteUnsafe(b);
1478 bhr = 0;
1479 mask1 = 0b01000000;
1480 mask2 = 0b10000000;
1481 pls = 1;
1482 for (uint8_t d = 0; d < 8; d += 2)
1483 {
1484 bhr |= ((bh & mask1) << pls);
1485 if (!ISGRAPHICBLOCK(c))
1486 {
1487 bhr |= ((bh & mask2) << pls);
1488 mask2 >>= 2;
1489 }
1490 mask1 >>= 2;
1491 ++pls;
1492 }
1493 g.setByteUnsafe(b,bhr);
1494 }
1495 }
1496
1497 // print it
1498 print(g.getAllBytes());
1499 }
1500 }
1501 else
1502 {
1503 static uint8_t bm[kLenBM];
1504 for (size_t f = 0; f < txt.size(); ++f)
1505 {
1506 // get bitmap
1507 uint8_t c = txt[f];
1508 auto g = getBitmap(c);
1509
1510 // scale the bitmap
1511 if constexpr(SCW != 1) std::fill(bm,bm + kLenBM,0);
1512 size_t off{0};
1513 for (size_t scan = 0; scan < 8; ++scan)
1514 {
1515 uint8_t b = g.getByteUnsafe(scan);
1516 if constexpr(SCW == 1) bm[off++] = b;
1517 else
1518 {
1519 size_t oldoff{off};
1520 uint8_t mask = 0b10000000;
1521 int8_t atbit = 7;
1522 for (uint8_t bi = 0; bi < 8; ++bi)
1523 {
1524 uint8_t bivat0 = (b & mask) >> (7-bi);
1525 for (unsigned f = 0; f < SCW; ++f)
1526 {
1527 bm[off] |= bivat0 << static_cast<uint8_t>(atbit);
1528 --atbit;
1529 if (atbit < 0)
1530 {
1531 ++off;
1532 atbit = 7;
1533 }
1534 }
1535 mask >>= 1;
1536 }
1537 for (unsigned f = 0; f < SCH-1; ++f)
1538 {
1539 std::copy(bm + oldoff, bm + oldoff + kWidthInBytes,
1540 bm + off);
1541 off += kWidthInBytes;
1542 }
1543 }
1544 }
1545
1546 // print it
1547 print(bm);
1548 }
1549 }
1550}
1551
1552template <unsigned SCW, unsigned SCH>
1554{
1555 if constexpr(SCW == 0) // compile-time #if
1556 {
1557 Bitmap g{{1,8}}; // empty, to be filled
1558
1559 uint8_t invmask = 0x00;
1560 if (cols_.inverse())
1561 {
1562 if (cur_.x % 2) invmask = 0x0f;
1563 else invmask = 0xf0;
1564 }
1565 if (cur_.x % 2)
1566 for (uint8_t b = 0; b < 8; ++b)
1567 g.setByteUnsafe(b,(bitmap[b] >> 4) ^ invmask);
1568 else
1569 for (uint8_t b = 0; b < 8; ++b)
1570 g.setByteUnsafe(b,(bitmap[b] & 0xf0) ^ invmask);
1571
1572 // put char
1573 static const Bitmap gleft{138}; // solid nibble to the left
1574 static const Bitmap gright{133}; // solid nibble to the right
1575 auto & grscr = scr_.graphic();
1576 CharPixCursor cpcur{getCharPixCursor(cur_)};
1577 cpcur.x /= 2;
1578 if (cols_.over())
1579 grscr.bitmap.merge(g,cpcur,LinearGraphic::GraphOp::XOR);
1580 else
1581 {
1582 grscr.bitmap.merge(cur_.x % 2 ? gleft : gright,
1584 grscr.bitmap.merge(g,cpcur,LinearGraphic::GraphOp::OR);
1585 }
1586 CharCursor cccur{cur_};
1587 cccur.x /= 2;
1588 grscr.attrmap.setByte(cccur,scr_.attrForPrints(cccur,cols_));
1589 }
1590 else
1591 {
1592 Bitmap g{{static_cast<CharDist>(kWidthInBytes),
1593 static_cast<CharDist>(kHeightInScans)}}; // empty, to fill
1594
1595 uint8_t invmask = cols_.inverse() ? 0xff : 0x00;
1596 for (size_t f = 0; f < g.size(); ++f)
1597 g.setByteUnsafe(f,bitmap[f] ^ invmask);
1598
1599 // put char
1600 auto & grscr = scr_.graphic();
1601 CharCursor cccur{cur_};
1602 cccur.x *= SCW;
1603 cccur.y *= SCH;
1604 CharPixCursor cpcur{getCharPixCursor(cccur)};
1605 grscr.bitmap.merge(g,cpcur,cols_.over() ? LinearGraphic::GraphOp::XOR :
1607 for (CharDist row = 0; row < SCH; ++row)
1608 for (CharDist col = 0; col < SCW; ++col)
1609 {
1610 grscr.attrmap.setByte(cccur,scr_.attrForPrints(cccur,cols_));
1611 ++cccur.x;
1612 if ((col == SCW - 1) ||
1613 (cccur.x >= scr_.entireCharArea().width))
1614 {
1615 cccur.x = cur_.x * SCW;
1616 ++cccur.y;
1617 if (cccur.y >= scr_.entireCharArea().height)
1618 { row = SCH; break; }
1619 }
1620 }
1621 }
1622
1623 incCursor();
1624}
1625
1626
1627
1628} // end namespace zxeco
1629
1630#endif
1631
1632 // ZXScreen
1634
1635
#define RUNTIMEEXCEP(txt)
Raise a runtime exception with the given std::string TXT + additional info.
Definition: CppAddons.h:93
std::string zxString(uint8_t cc)
Return a string composed of the ZX control code CC (no arguments).
Definition: ZXChars.h:121
One of the 8 basic colors of the ZX, not considering bright or flash.
Definition: ZXColors.h:154
A value of bright that is different to the same value of flash, inv or over.
Definition: ZXColors.h:100
Color specification for a character cell, plus modes of printing.
Definition: ZXColors.h:420
A value of flash that is different to the same value of bright, inv or over.
Definition: ZXColors.h:83
A printcolor for ink as a different type from a color for paper.
Definition: ZXColors.h:302
A value of inv that is different to the same value of flash, bright or over.
Definition: ZXColors.h:117
A value of over that is different to the same value of flash, bright or inv.
Definition: ZXColors.h:134
A printcolor for paper as a different type from a color for ink.
Definition: ZXColors.h:293
CharArea chararea
Char resolution.
Definition: ZXGraphics.h:772
Cursor< PixelCoordT, PixelCoordT > PixCursor
Shortcut for this kind of cursor.
Definition: ZXGraphics.h:471
constexpr CharDist SCREENCOLS
Number of columns in the screen of the original ZX.
Definition: ZXGraphics.h:235
Area< CharDistT, CharDistT > CharArea
Shortcut for this kind of area.
Definition: ZXGraphics.h:605
WidthType::type width
width of the area.
Definition: ZXGraphics.h:512
constexpr CharDist SCREENROWS
Number of rows in the screen of the original ZX.
Definition: ZXGraphics.h:232
Area< CharDistT, PixelDistT > CharPixArea
Shortcut for this kind of area.
Definition: ZXGraphics.h:611
constexpr PixelCoord pixelOfCharX(CharCoord cc) noexcept
Conversion from an x-CharCoord to PixelCoord.
Definition: ZXGraphics.h:167
void setByteUnsafe(size_t offset, uint8_t b) noexcept
Change the byte at the given offset without checking anything.
PixArea pixarea
Pixel resolution.
Definition: ZXGraphics.h:773
constexpr PixelCoord pixelOfCharY(CharCoord cc) noexcept
Conversion from a y-CharCoord to PixelCoord.
Definition: ZXGraphics.h:173
CharPixCursor getCharPixCursor(const CharCursor &cc)
Convert a char cursor to a char-pix cursor placed at the top of the former.
Definition: ZXGraphics.h:489
GraphOp
Possible operations on Graphics.
Definition: ZXGraphics.h:841
bool contains(const cursor_type &cur) const noexcept
Return TRUE if CUR is inside the rectangle.
Definition: ZXGraphics.h:1557
uint16_t PixelDist
A distance measured in screen pixels.
Definition: ZXGraphics.h:96
uint16_t CharCoord
Represent both x and y screen char coordinates.
Definition: ZXGraphics.h:94
HeightType::type height
height of the area.
Definition: ZXGraphics.h:513
constexpr PixelDist charDistToPixelDist(CharDist pc) noexcept
Conversion from CharDist to PixelDist.
Definition: ZXGraphics.h:215
Rect< CharDistT, CharDistT > CharRect
Shortcut for this kind of rectangle.
Definition: ZXGraphics.h:735
uint16_t PixelCoord
Represent both x and y screen pix coordinates.
Definition: ZXGraphics.h:93
int16_t IntDist
Positive and negative distances on screen.
Definition: ZXGraphics.h:99
Cursor< CharCoordT, CharCoordT > CharCursor
Shortcut for this kind of cursor.
Definition: ZXGraphics.h:468
WidthType::type x
Coordinate in width (horizontally).
Definition: ZXGraphics.h:365
uint16_t CharDist
A distance meadured in screen chars.
Definition: ZXGraphics.h:97
@ 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.
Definition: ZXGraphics.h:1151
A cursor on screen that uses the given coordinates resolution.
Definition: ZXGraphics.h:359
An area with both char and pixel resolutions, possibly synchronized.
Definition: ZXGraphics.h:769
A bitmap plus an attrmap, possibly synchronized.
Definition: ZXGraphics.h:1250
The ZX keyboard as it behaves (for typing) under the ZX operating system.
Definition: ZXKeyboard.h:427
The zx keyboard as a membrane. Useful for games and those sort of things.
Definition: ZXKeyboard.h:219
char getChannel(void) const
Return the current channel.
Definition: ZXScreen.h:1119
Screen & operator<<(const CharCursor &at)
Calculate the attr to put at POS for getting DESIRED colors there.
Definition: ZXScreen.h:576
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.
Definition: ZXScreen.h:402
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.
Definition: ZXScreen.h:580
const CharArea & scaledDimensions(void) const noexcept
< Return the scaled dimensions of the screen with this printer.
Definition: ZXScreen.h:181
bool inside(const CharRect &r) const noexcept
< Return TRUE if the given rectangle is inside the screen entirely.
Definition: ZXScreen.h:339
std::string to_string(void) const
< Return a string with the info about this object.
Definition: ZXScreen.h:940
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
Definition: ZXScreen.h:116
const DoubleArea & info(void) const noexcept
Return a read-only reference to the info of this Screen.
Definition: ZXScreen.h:322
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.
Definition: ZXScreen.h:328
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.
Definition: ZXScreen.h:185
std::function< Keyboard(void) > KeyWait
Routine that waits for a key press and return the resulting keyboard.
Definition: ZXScreen.h:919
bool point(const PixCursor &pos) const
< Return TRUE if the given point is on or FALSE if it is off.
Definition: ZXScreen.h:1184
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.
Definition: ZXScreen.h:101
CheckInput checkInput
Callback to check input validity.
Definition: ZXScreen.h:138
const CharCursor & getTextCursor(void) const noexcept
Get the current cursor position for printing in flat model coordinates.
Definition: ZXScreen.h:516
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.
Definition: ZXScreen.h:433
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.
Definition: ZXScreen.h:927
void putChar(const uint8_t *d)
Put the 1-char bitmap D (8 bytes) exactly as in put().
Definition: ZXScreen.h:528
static CharArea areaForPrint(const std::string &txt, const ExpandToken &expandtoken=kNudeExpandToken)
Fill from the given address the ZX original 32-127 character bitmaps.
Definition: ZXScreen.h:259
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.
Definition: ZXScreen.h:572
Screen & operator<<(Paper p)
Calculate the attr to put at POS for getting DESIRED colors there.
Definition: ZXScreen.h:578
void resetChannelK(void)
Reset cursors, size and contents of channel K to its initial values.
Definition: ZXScreen.h:1070
CharDist scrollCnt(void) const noexcept
Return how many scrolls will be done (+1) before asking.
Definition: ZXScreen.h:1074
ScaledTextPrinter & operator=(ScaledTextPrinter &&)=delete
Return a reference to the underlying Screen.
const PixCursor & lastPlot(void) const noexcept
Return the coordinates of the last plot.
Definition: ZXScreen.h:686
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.
Definition: ZXScreen.h:531
static const CharDist kInitialRowsK
Number of character rows initially in the K channel.
Definition: ZXScreen.h:948
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.
Definition: ZXScreen.h:1010
size_t howmanyScrolls
How many one-text-line scrolls were done.
Definition: ZXScreen.h:926
Screen(const Screen &)=delete
Default constructor with given dimensions (cannot be empty area).
GetNewKeyboard getNewKeyboard
Callback to get changes in keyboard.
Definition: ZXScreen.h:136
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.
Definition: ZXScreen.h:336
void put(uint8_t c)
Calculate the attr to put at POS for getting DESIRED colors there.
Definition: ZXScreen.h:519
std::function< std::string(uint8_t c)> ExpandToken
User's routine that must expand a given token code into the token text.
Definition: ZXScreen.h:96
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 &region, 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.
Definition: ZXScreen.h:191
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.
Definition: ZXScreen.h:588
bool add(const ScrollInfo &si1) noexcept
< Add the info of SI1 to this, returning the breaking of scrolls.
Definition: ZXScreen.h:933
std::function< bool(const std::string &) > CheckInput
Definition: ZXScreen.h:132
void print(const std::string &txt)
Print the given text at the current scaled position.
Definition: ZXScreen.h:1462
bool columnAtLeft(void) const
TRUE if the current non-flat column at the current channel is at left.
Definition: ZXScreen.h:1132
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.
Definition: ZXScreen.h:436
static const ExpandToken kInvExpandToken
Expand token routine that always generates CHRINVALID as expansion.
Definition: ZXScreen.h:98
Screen & operator<<(Inverse i)
Calculate the attr to put at POS for getting DESIRED colors there.
Definition: ZXScreen.h:586
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.
Definition: ZXScreen.h:405
CharRect entireCharRect(void) const
Return a CharRect covering the whole screen.
Definition: ZXScreen.h:331
static void checkChannel(char c, const std::string &place="")
Definition: ZXScreen.h:960
Screen & operator<<(Bright b)
Calculate the attr to put at POS for getting DESIRED colors there.
Definition: ZXScreen.h:582
const ExpandToken & expandToken(void) const noexcept
Return a read-only reference to the expand token routine.
Definition: ZXScreen.h:325
bool validPixel(const PixCursor &pos) const noexcept
< Return TRUE if the given coordinates are inside the bitmap.
Definition: ZXScreen.h:643
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. *‍/.
Definition: ZXScreen.h:1060
Play play
Callback to play keyboard clics.
Definition: ZXScreen.h:137
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.
Definition: ZXScreen.h:104
static const PixelDist kInitialHeightK
Number of pixel rows initially in the K channel.
Definition: ZXScreen.h:951
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.
Definition: ZXScreen.h:135
const uint8_t * currentUDGsBitmap(void) const noexcept
Return the current UDGs bitmap, or nullptr if it is the ZX original one.
Definition: ZXScreen.h:454
void circle(const PixCursor &center, PixelDist r, const Colors *cmc=nullptr)
Draw the given circle using original, non-flat ZX plot coordinates.
void circle(const PixCursor &center, 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
Definition: ZXScreen.h:129
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.
Definition: ZXScreen.h:1434
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.
Definition: ZXScreen.h:1078
void changeUDGsBitmap(const uint8_t *pudgs) noexcept
Set to PUDGS the memory address where UDGs are defined.
Definition: ZXScreen.h:457
DoubleGraphic & graphic(void) noexcept
Return a reference to the bitmap + attrmap of this Screen.
Definition: ZXScreen.h:421
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.
Definition: ZXScreen.h:399
virtual ~Screen(void)
Destroy the Screen.
std::function< void(const Keyboard &, Keyboard &, Membrane &, std::string &) > GetNewKeyboard
Definition: ZXScreen.h:124
void moveNewLine(void)
Move text cursor to a new line without printing CHRENTER.
Definition: ZXScreen.h:1155
void setTextCursor(const CharCursor &pos)
Set the cursor for printing at the given flat model coordinates.
Definition: ZXScreen.h:507
PixRect getCursorRect(void) const noexcept
Return the pixel rectangle of the cursor.
Definition: ZXScreen.h:1442
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.
Definition: ZXScreen.h:1039
ScaledTextPrinter(Screen &scr, bool perfectchars=true)
Create a scaled text printer for the given screen; cursor at 0,0.
Definition: ZXScreen.h:1413
Screen & operator<<(Flash f)
Calculate the attr to put at POS for getting DESIRED colors there.
Definition: ZXScreen.h:584
Just a shorter renaming of CharCursor.
Definition: ZXScreen.h:51
This class decorates Screen to get the original BASIC screen model of the ZX.
Definition: ZXScreen.h:912
The class that provides the main support for managing the ZX screen.
Definition: ZXScreen.h:89
A class for printing with scaled characters.
Definition: ZXScreen.h:158
Info produced after a scroll or some movements of the text cursor.
Definition: ZXScreen.h:923
Callbacks used in input.
Definition: ZXScreen.h:111
A zx beep sound.
Definition: ZXSound.h:102
The main namespace of the library, that spans across all the zx modules.
Definition: ZXChars.h:31
constexpr uint8_t CHRLASTGB
last graphic-block char
Definition: ZXChars.h:73
constexpr bool ISGRAPHICBLOCK(uint8_t c) noexcept
Return TRUE if C is a graphic block character. *‍/.
Definition: ZXChars.h:100
constexpr uint8_t CHRFIRSTGB
first graphic-block char
Definition: ZXChars.h:72
Key
A single key in the zx keyboard.
Definition: ZXKeyboard.h:48
constexpr uint8_t CHRPAPER
paper (control code; 1 arg)
Definition: ZXChars.h:54
constexpr uint8_t CHROVER
over (control code; 1 arg)
Definition: ZXChars.h:58
constexpr uint8_t CHRINVERSE
inverse (control code; 1 arg)
Definition: ZXChars.h:57
constexpr uint8_t CHRFLASH
flash (control code; 1 arg)
Definition: ZXChars.h:55
constexpr uint8_t CHRSPC
space
Definition: ZXChars.h:43
constexpr uint8_t CHRINVALID
invalid mark char
Definition: ZXChars.h:68
constexpr uint8_t CHRINK
ink (control code; 1 arg)
Definition: ZXChars.h:53
constexpr uint8_t CHRFIRSTTOKEN
first token char
Definition: ZXChars.h:76
constexpr uint8_t CHRBRIGHT
bright (control code; 1 arg)
Definition: ZXChars.h:56