-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_text_test.c
More file actions
1032 lines (796 loc) · 63.5 KB
/
Copy pathlib_text_test.c
File metadata and controls
1032 lines (796 loc) · 63.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* lib_text_test.c
*
* Created on: Feb 19, 2022
* Author: micahbly
*/
/*****************************************************************************/
/* Includes */
/*****************************************************************************/
// unit testing framework
#include "minunit.h"
// project includes
// class being tested
#include "lib_text.h"
// C includes
// A2560 includes
#include <mb/a2560_platform.h>
#include <mb/lib_general.h>
#include <mb/lib_sys.h>
/*****************************************************************************/
/* Definitions */
/*****************************************************************************/
/*****************************************************************************/
/* Enumerations */
/*****************************************************************************/
/*****************************************************************************/
/* Global Variables */
/*****************************************************************************/
System* the_system;
/*****************************************************************************/
/* Private Function Prototypes */
/*****************************************************************************/
// test using sys_kbd_scancode() instead of a channel driver - TEMP - BAD
boolean keyboard_test_2(void);
// test using channel driver - TEMP - BAD
boolean keyboard_test(void);
/*****************************************************************************/
/* Private Function Definitions */
/*****************************************************************************/
// test using sys_kbd_scancode() instead of a channel driver - TEMP - BAD
boolean keyboard_test_2(void)
{
// LOGIC:
// page 34 of FoenixMCP Manual
// try a simple loop that just keeps banging on the keyboard scanner
// keys return their keycode when pushed, and their keyboard + 128 when released.
unsigned short the_code;
do
{
the_code = sys_kbd_scancode();
if (the_code > 127)
{
DEBUG_OUT(("%s %d: key released: code=%u, keycode=%u", __func__, __LINE__, the_code, the_code & 0xF0));
// handle_event_key_up()
}
else
{
DEBUG_OUT(("%s %d: key pressed: code=%u", __func__, __LINE__, the_code));
}
} while (the_code != 0);
return true;
}
// test using channel driver - TEMP - BAD
boolean keyboard_test(void)
{
signed short bytes_read = 0;
signed short bytes_requested = 5;
static unsigned char keyboard_buff[256];
unsigned char* the_keyboard_buff = keyboard_buff;
signed short the_channel_id;
signed short the_device_id = 0;
boolean stop = false;
signed int y = 30;
// Text_DrawStringAtXY(ID_CHANNEL_B, 0, y++, (char*)"Trying to open keyboard device...", FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
DEBUG_OUT(("%s %d: Trying to open keyboard device...", __func__, __LINE__));
// open keyboard console for reading. Console is on device 0 and 1.
the_channel_id = sys_chan_open(the_device_id, (unsigned char*)"", 1);
if (the_channel_id < 0)
{
//DEBUG_OUT(("%s %d: Failed to open channel for device %i. Error# %i", __func__, __LINE__, the_device_id, the_channel_id));
//Text_DrawStringAtXY(ID_CHANNEL_A, 0, y++, (char*)"Failed to open keyboard device", FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
DEBUG_OUT(("%s %d: Failed to open keyboard device. proceeding anyway...", __func__, __LINE__));
// return false;
}
else
{
//Text_DrawStringAtXY(ID_CHANNEL_A, 0, y++, (char*)"Opened keyboard device", FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
DEBUG_OUT(("%s %d: Opened keyboard device", __func__, __LINE__));
}
sys_chan_flush(the_channel_id);
//Text_DrawStringAtXY(ID_CHANNEL_A, 0, y++, (char*)"flushed channel", FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
DEBUG_OUT(("%s %d: Flushed channel", __func__, __LINE__));
if ( ((sys_chan_status(the_channel_id) & CDEV_STAT_ERROR) == 1) )
{
//Text_DrawStringAtXY(ID_CHANNEL_A, 0, y++, (char*)"channel status had error (0x01)", FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
DEBUG_OUT(("%s %d: channel status had error (0x01)", __func__, __LINE__));
return false;
}
else
{
//Text_DrawStringAtXY(ID_CHANNEL_A, 0, y++, (char*)"channel status says no error condition", FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
DEBUG_OUT(("%s %d: channel status says no error condition", __func__, __LINE__));
}
// read and type characters to screen until there is an channel error, or the char typed is tab
while ( ((sys_chan_status(the_channel_id) & CDEV_STAT_ERROR) == 0) && !stop)
{
unsigned char the_char;
//bytes_read = sys_chan_read(the_channel_id, the_keyboard_buff, bytes_requested);
the_char = sys_chan_read_b(the_channel_id);
bytes_read++;
if (the_char == '\t')
{
stop = true;
}
else
{
Text_SetCharAtXY(ID_CHANNEL_A, bytes_read, 40, the_char);
}
//Text_DrawStringAtXY(ID_CHANNEL_A, 0, 40, (char*)the_keyboard_buff, FG_COLOR_DK_BLUE, BG_COLOR_YELLOW);
}
// close channel
sys_chan_close(the_channel_id);
return true;
}
/*****************************************************************************/
/* MinUnit Function Defintions */
/*****************************************************************************/
void text_test_setup(void) // this is called EVERY test
{
// foo = 7;
// bar = 4;
//
}
void text_test_teardown(void) // this is called EVERY test
{
}
MU_TEST(text_test_block_copy)
{
char* buffer1;
char* buffer2;
// these test pass, but visually, copying from screen A to B or vice versa doesn't work well right now
// these reason has to do with different # of columns/rows.
// TODO: re-write these tests to copy to an off-screen location. have a different offscreen buffer with some preprerated text. copy that to screen. then copy original buffer back to screen.
// TODO: if function is necessary, device a smarter, dedicated buffer to screen copy that accounts for width of copied buffer and width of target screen.
mu_assert( (buffer1 = (char*)calloc(the_system->screen_[ID_CHANNEL_A]->text_mem_cols_ * the_system->screen_[ID_CHANNEL_A]->text_mem_rows_, sizeof(char)) ) != NULL, "could not alloc space for screen buffer 1");
mu_assert( (buffer2 = (char*)calloc(the_system->screen_[ID_CHANNEL_A]->text_mem_cols_ * the_system->screen_[ID_CHANNEL_A]->text_mem_rows_, sizeof(char)) ) != NULL, "could not alloc space for screen buffer 2");
// copy text on channel B, to off-screen buffer 1
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_B], buffer1, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy chan B char to buffer 1" );
// copy text on channel A, to off-screen buffer 2
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_A], buffer2, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy chan A char to buffer 2" );
// copy text in offscreen buffer 1, to channel A
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_A], buffer1, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy buffer1 to chan A char" );
// copy text in offscreen buffer 2, to channel B
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_B], buffer2, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy buffer2 to chan B char" );
// copy attr on channel B, to off-screen buffer 1
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_B], buffer1, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy chan B attr to buffer 1" );
// copy attr on channel A, to off-screen buffer 2
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_A], buffer2, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy chan A attr to buffer 2" );
// copy attr in offscreen buffer 1, to channel A
mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_A], buffer1, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy buffer1 to chan A attr" );
// copy attr in offscreen buffer 2, to channel B
// mu_assert( Text_CopyScreen(the_system->screen_[ID_CHANNEL_B], buffer2, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy buffer2 to chan B attr" );
// // copy text on channel B, to off-screen buffer 1
// mu_assert( Text_CopyCharMemFromScreen(the_system->screen_[ID_CHANNEL_B], buffer1) == true, "Could not copy chan B char to buffer 1" );
//
// // copy text on channel A, to off-screen buffer 2
// mu_assert( Text_CopyCharMemFromScreen(the_system->screen_[ID_CHANNEL_A], buffer2) == true, "Could not copy chan A char to buffer 2" );
//
// // copy text in offscreen buffer 1, to channel A
// mu_assert( Text_CopyCharMemToScreen(the_system->screen_[ID_CHANNEL_A], buffer1) == true, "Could not copy buffer1 to chan A char" );
//
// // copy text in offscreen buffer 2, to channel B
// mu_assert( Text_CopyCharMemToScreen(the_system->screen_[ID_CHANNEL_B], buffer2) == true, "Could not copy buffer2 to chan B char" );
//
// // copy attr on channel B, to off-screen buffer 1
// mu_assert( Text_CopyAttrMemFromScreen(the_system->screen_[ID_CHANNEL_B], buffer1) == true, "Could not copy chan B attr to buffer 1" );
//
// // copy attr on channel A, to off-screen buffer 2
// mu_assert( Text_CopyAttrMemFromScreen(the_system->screen_[ID_CHANNEL_A], buffer2) == true, "Could not copy chan A attr to buffer 2" );
//
// // copy attr in offscreen buffer 1, to channel A
// mu_assert( Text_CopyAttrMemToScreen(the_system->screen_[ID_CHANNEL_A], buffer1) == true, "Could not copy buffer1 to chan A attr" );
//
// // copy attr in offscreen buffer 2, to channel B
// mu_assert( Text_CopyAttrMemToScreen(the_system->screen_[ID_CHANNEL_B], buffer2) == true, "Could not copy buffer2 to chan B attr" );
free(buffer1);
free(buffer2);
}
MU_TEST(text_test_block_copy_box)
{
signed int x;
signed int y;
signed int h_line_len;
signed int v_line_len;
char* buffer1;
char* buffer2;
x = 45;
y = 4;
h_line_len = 6;
v_line_len = 6;
// get out 2 buffers that are the full size of the screens. this block copy is designed to use same offsets as a normal sized screen.
mu_assert( (buffer1 = (char*)calloc(the_system->screen_[ID_CHANNEL_A]->text_mem_cols_ * the_system->screen_[ID_CHANNEL_A]->text_mem_rows_, sizeof(char)) ) != NULL, "could not alloc space for screen buffer 1");
mu_assert( (buffer2 = (char*)calloc(the_system->screen_[ID_CHANNEL_A]->text_mem_cols_ * the_system->screen_[ID_CHANNEL_A]->text_mem_rows_, sizeof(char)) ) != NULL, "could not alloc space for screen buffer 2");
// copy text on channel B, to off-screen buffer 1
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_B], buffer1, x, y, x+h_line_len, y+v_line_len, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy box of chan B char to buffer 1" );
// copy text on channel A, to off-screen buffer 2
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_A], buffer2, 0, 0, 71, 8, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy box of chan A char to buffer 2" );
// copy text in offscreen buffer 1, to channel A
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_A], buffer1, x, y, x+h_line_len, y+v_line_len, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy box of buffer1 to chan A char" );
// copy text in offscreen buffer 2, to channel B
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_B], buffer2, 0, 0, 71, 8, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_CHAR == true), "Could not copy box of buffer2 to chan B char" );
// copy attr on channel B, to off-screen buffer 1
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_B], buffer1, x, y, x+h_line_len, y+v_line_len, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy box of chan B attr to buffer 1" );
// copy attr on channel A, to off-screen buffer 2
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_A], buffer2, 0, 0, 71, 8, SCREEN_COPY_FROM_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy box of chan A attr to buffer 2" );
// copy attr in offscreen buffer 1, to channel A
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_A], buffer1, x, y, x+h_line_len, y+v_line_len, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy box of buffer1 to chan A attr" );
// copy attr in offscreen buffer 2, to channel B
mu_assert( Text_CopyMemBox(the_system->screen_[ID_CHANNEL_B], buffer2, 0, 0, 71, 8, SCREEN_COPY_TO_SCREEN, SCREEN_FOR_TEXT_ATTR == true), "Could not copy box of buffer2 to chan B attr" );
free(buffer1);
free(buffer2);
}
MU_TEST(text_test_fill_text)
{
mu_assert( Text_FillCharMem(the_system->screen_[ID_CHANNEL_A], 'Z'), "Could not fill character memory in channel A" );
mu_assert( Text_FillCharMem(the_system->screen_[ID_CHANNEL_B], 4), "Could not fill character memory in channel B" );
// 4 = diamond. good mix of fore/back color
// bad values
mu_assert( Text_FillCharMem(NULL, 4) == false, "Text_FillCharMem accepted bad parameter" );
}
MU_TEST(text_test_fill_attr)
{
mu_assert( Text_FillAttrMem(the_system->screen_[ID_CHANNEL_A], 127), "Could not fill attribute memory in channel A" );
mu_assert( Text_FillAttrMem(the_system->screen_[ID_CHANNEL_B], 148), "Could not fill attribute memory in channel B" );
// illegal values
mu_assert( Text_FillAttrMem(NULL, 148) == false, "Text_FillAttrMem accepted bad parameter" );
// 31=black on white
// 64=dark blue on black
// 96=dark cyan on black
// 112=medium gray on black
// 128=medium gray on black
// 138=black on light green
// 139=black on bright yellow
// 140=gray? on medium blue
// 141=gray? on pink
// 142=gray? on light cyan
// 143=black/gray? on white
// 15=black on white
// 144=red on black
// 16=dark red on black
// 145=light red on dark red
// 17=dark red on dark red
// 146=light red on medium green
// 18=dark red on medium green
// 147=light red on olive
// 19=dark red on medium green?
// 148=light red on dark blue
}
MU_TEST(text_test_fill_box)
{
// good values
mu_assert( Text_FillBoxSlow(the_system->screen_[ID_CHANNEL_A], 0, 6, 15, 8, CH_CHECKERED1, COLOR_BLACK, BG_COLOR_WHITE, CHAR_AND_ATTR) == true, "Text_FillBoxSlow failed" );
mu_assert( Text_FillBoxSlow(the_system->screen_[ID_CHANNEL_A], 21, 5, 39, 7, CH_CHECKERED2, COLOR_DK_RED, COLOR_RED, CHAR_AND_ATTR) == true, "Text_FillBoxSlow failed" );
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_A], 3, 6, 67, 50, CH_CHECKERED3, COLOR_GREEN, COLOR_DK_GREEN) == true, "Text_FillBox failed" );
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_B], 21, 21, 40, 40, CH_CHECKERED3, COLOR_YELLOW, COLOR_DK_YELLOW) == true, "Text_FillBox failed" );
// bad values
mu_assert( Text_FillBoxSlow(NULL, 0, 6, 15, 8, CH_CHECKERED1, COLOR_VIOLET, COLOR_CYAN, CHAR_AND_ATTR) == false, "Text_FillBoxSlow accepted an illegal screen ID" );
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_B], -67, 6, 72, 30, CH_CHECKERED3, COLOR_BLUE, COLOR_DK_BLUE) == false, "Text_FillBoxSlow accepted an illegal x coord" );
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_B], 450000, 6, 72, 30, CH_CHECKERED3, COLOR_BLUE, COLOR_DK_BLUE) == false, "Text_FillBoxSlow accepted an illegal x coord" );
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_B], 5, -6, 72, 30, CH_CHECKERED3, COLOR_BLUE, COLOR_DK_BLUE) == false, "Text_FillBoxSlow accepted an illegal y coord" );
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_B], 5, 6000, 72, 30, CH_CHECKERED3, COLOR_BLUE, COLOR_DK_BLUE) == false, "Text_FillBoxSlow accepted an illegal y coord" );
}
MU_TEST(text_test_invert_box)
{
signed int i;
for (i = 0; i < 999; i++)
{
mu_assert( Text_InvertBox(the_system->screen_[ID_CHANNEL_B], 0, 6, 15, 8), "Could not invert color of a box" );
}
mu_assert( Text_InvertBox(the_system->screen_[ID_CHANNEL_B], 50, 13, 71, 16), "Could not invert color of a box" );
// bad values
mu_assert( Text_InvertBox(NULL, 50, 13, 71, 16) == false, "Text_InvertBox accepted an illegal screen ID" );
mu_assert( Text_InvertBox(the_system->screen_[ID_CHANNEL_B], 50, 13, 1500, 16) == false, "Text_InvertBox accepted illegal rect coordinates" );
mu_assert( Text_InvertBox(the_system->screen_[ID_CHANNEL_B], 71, 16, 50, 10) == false, "Text_InvertBox accepted illegal rect coordinates" );
}
MU_TEST(text_test_font_overwrite)
{
mu_assert( Text_UpdateFontData(the_system->screen_[ID_CHANNEL_A], (char*)0x000000), "Could not replace font data for channel A" );
mu_assert( Text_UpdateFontData(the_system->screen_[ID_CHANNEL_B], (char*)0x000000), "Could not replace font data for channel B" );
// bad values
mu_assert( Text_UpdateFontData(NULL, (char*)0x000000) == false, "Text_UpdateFontData accepted an illegal screen ID" );
}
MU_TEST(text_test_show_font)
{
mu_assert( Text_ShowFontChars(the_system->screen_[ID_CHANNEL_A], 10), "Could not show font chars for channel A" );
mu_assert( Text_ShowFontChars(the_system->screen_[ID_CHANNEL_B], 10), "Could not show font chars for channel B" );
// bad values
mu_assert( Text_ShowFontChars(NULL, 10) == false, " accepted an illegal screen ID" );
}
//test char placement
MU_TEST(text_test_char_placement)
{
signed int x;
signed int y;
for (y = 4; y < 40; y = y+2)
{
for (x = 0; x < 50; x++)
{
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], x, y, 'X'), "text char placement failed" );
}
}
// bad values
mu_assert( Text_SetCharAtXY(NULL, 0, 0, 'X') == false, "Text_SetCharAtXY accepted illegal screen ID" );
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], -1, 3, 'b') == false, "Text_SetCharAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], -1, -1, 'c') == false, "Text_SetCharAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], 0, -1, 'd') == false, "Text_SetCharAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], 500, 4, 'e') == false, "Text_SetCharAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], 500, 500, 'f') == false, "Text_SetCharAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], 0, 500, 'g') == false, "Text_SetCharAtXY accepted illegal coordinates" );
}
// char and color writing
MU_TEST(text_test_char_and_attr_writing)
{
// same story here: 4 or so works ok, add more, and it's likely to crash.
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 0, 4, 33, FG_COLOR_BLACK, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 1, 4, 34, FG_COLOR_DK_RED, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 2, 4, 35, FG_COLOR_GREEN, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 3, 4, 36, FG_COLOR_BLUE, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 4, 4, 37, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 5, 4, 38, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 6, 4, 39, FG_COLOR_VIOLET, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 7, 4, 40, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 8, 4, 41, COLOR_BLACK, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 9, 4, 42, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 10, 4, 43, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 11, 4, 44, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 12, 4, 45, FG_COLOR_DK_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 13, 4, 46, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 14, 4, 47, FG_COLOR_WHITE, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 15, 4, 48, COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 0, 5, 33, FG_COLOR_WHITE, BG_COLOR_BLACK) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 1, 5, 34, FG_COLOR_WHITE, BG_COLOR_DK_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 2, 5, 35, FG_COLOR_WHITE, BG_COLOR_GREEN) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 3, 5, 36, FG_COLOR_WHITE, BG_COLOR_BLUE) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 4, 4, 37, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 5, 5, 38, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 6, 5, 39, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 7, 5, 40, FG_COLOR_WHITE, BG_COLOR_DK_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 8, 5, 41, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 9, 5, 42, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 10, 5, 43, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 11, 5, 44, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 12, 5, 45, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 13, 5, 46, FG_COLOR_WHITE, COLOR_RED) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 14, 5, 47, FG_COLOR_WHITE, BG_COLOR_LT_GRAY) == true, "Text_SetCharAndColorAtXY failed" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_B], 15, 5, 48, FG_COLOR_WHITE, BG_COLOR_WHITE) == true, "Text_SetCharAndColorAtXY failed" );
// bad values
mu_assert( Text_SetCharAndColorAtXY(NULL, 0, 0, 'X', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal screen ID" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], -1, 3, 'b', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], -1, -1, 'c', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 0, -1, 'd', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 500, 4, 'e', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 500, 500, 'f', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 0, 500, 'g', FG_COLOR_WHITE, BG_COLOR_WHITE) == false, "Text_SetCharAndColorAtXY accepted illegal coordinates" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 1, 1, 'h', -1, 1) == false, "Text_SetCharAndColorAtXY accepted illegal color value" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 1, 1, 'i', 17, 1) == false, "Text_SetCharAndColorAtXY accepted illegal color value" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 1, 1, 'j', 1, -54) == false, "Text_SetCharAndColorAtXY accepted illegal color value" );
mu_assert( Text_SetCharAndColorAtXY(the_system->screen_[ID_CHANNEL_A], 1, 1, 'k', 1, 23) == false, "Text_SetCharAndColorAtXY accepted illegal color value" );
}
// test char and color reading
MU_TEST(text_test_char_and_attr_reading)
{
unsigned char the_color;
unsigned char the_value;
unsigned char the_char;
unsigned char the_attribute_value;
signed int x;
signed int y;
x = 0;
y = 6;
the_attribute_value = ((COLOR_ORANGE << 4) | BG_COLOR_WHITE);
// set known chars and colors to test again
Text_SetAttrAtXY(the_system->screen_[ID_CHANNEL_A], x, y, FG_COLOR_WHITE, BG_COLOR_BLACK);
Text_SetAttrAtXY(the_system->screen_[ID_CHANNEL_A], x+1, y, FG_COLOR_VIOLET, BG_COLOR_DK_GRAY);
Text_SetAttrAtXY(the_system->screen_[ID_CHANNEL_A], x+2, y, COLOR_ORANGE, BG_COLOR_WHITE);
Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], x, y, CH_DIAMOND);
Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], x+1, y, CH_CLUB);
Text_SetCharAtXY(the_system->screen_[ID_CHANNEL_A], x+2, y, CH_SPADE);
mu_assert( (the_color = Text_GetForeColorAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == FG_COLOR_WHITE, "Text_GetForeColorAtXY failed" );
mu_assert( (the_color = Text_GetBackColorAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == BG_COLOR_BLACK, "Text_GetBackColorAtXY failed" );
x++;
mu_assert( (the_color = Text_GetForeColorAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == FG_COLOR_VIOLET, "Text_GetForeColorAtXY failed" );
mu_assert( (the_color = Text_GetBackColorAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == BG_COLOR_DK_GRAY, "Text_GetBackColorAtXY failed" );
x++;
mu_assert( (the_color = Text_GetAttrAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == the_attribute_value, "Text_GetAttrAtXY failed");
x = 0;
mu_assert( (the_char = Text_GetCharAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == CH_DIAMOND, "Text_GetCharAtXY failed");
x++;
mu_assert( (the_char = Text_GetCharAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == CH_CLUB, "Text_GetCharAtXY failed");
x++;
mu_assert( (the_char = Text_GetCharAtXY(the_system->screen_[ID_CHANNEL_A], x, y)) == CH_SPADE, "Text_GetCharAtXY failed");
}
MU_TEST(text_test_line_drawing)
{
signed int x;
signed int y;
signed int line_len;
unsigned char the_char;
// good values
x = 20;
y = 4;
line_len = 20;
the_char = CH_WALL_H;
mu_assert( Text_DrawHLine(the_system->screen_[ID_CHANNEL_A], x, y, line_len, the_char, FG_COLOR_GREEN, BG_COLOR_BLACK, CHAR_ONLY) == true, "Text_DrawHLine failed" );
y = 8;
mu_assert( Text_DrawHLine(the_system->screen_[ID_CHANNEL_A], x, y, line_len, the_char, FG_COLOR_GREEN, BG_COLOR_BLACK, CHAR_AND_ATTR) == true, "Text_DrawHLine failed" );
y = 4;
line_len = 4;
the_char = CH_WALL_V;
mu_assert( Text_DrawVLine(the_system->screen_[ID_CHANNEL_A], x, y, line_len, the_char, BG_COLOR_YELLOW, BG_COLOR_BLACK, ATTR_ONLY) == true, "Text_DrawVLine failed" );
x = x + 20;
mu_assert( Text_DrawVLine(the_system->screen_[ID_CHANNEL_A], x, y, line_len, the_char, BG_COLOR_YELLOW, BG_COLOR_BLACK, CHAR_AND_ATTR) == true, "Text_DrawVLine failed" );
// bad values
mu_assert( Text_DrawVLine(NULL, x, y, line_len, the_char, COLOR_DK_RED, COLOR_RED, CHAR_AND_ATTR) == false, "Text_DrawVLine accepted illegal screen ID" );
mu_assert( Text_DrawVLine(the_system->screen_[ID_CHANNEL_B], -1, y, line_len, the_char, COLOR_DK_RED, COLOR_RED, CHAR_AND_ATTR) == false, "Text_DrawVLine accepted illegal x coord" );
mu_assert( Text_DrawVLine(the_system->screen_[ID_CHANNEL_B], x, 425, line_len, the_char, COLOR_DK_RED, COLOR_RED, CHAR_AND_ATTR) == false, "Text_DrawVLine accepted illegal y coord" );
}
MU_TEST(text_test_basic_box_coords)
{
signed int x;
signed int y;
signed int h_line_len;
signed int v_line_len;
unsigned char the_char;
x = 45;
y = 4;
h_line_len = 6;
v_line_len = 6;
the_char = CH_CHECKERED1;
// good values
mu_assert( Text_DrawBoxCoords(the_system->screen_[ID_CHANNEL_A], x, y, x + h_line_len, y + v_line_len, the_char, FG_COLOR_LT_GRAY, BG_COLOR_DK_GRAY, CHAR_AND_ATTR) == true, "Text_DrawBoxCoords failed" );
// bad values
}
MU_TEST(text_test_basic_box_hw)
{
signed int x;
signed int y;
signed int h_line_len;
signed int v_line_len;
unsigned char the_char;
x = 60;
y = 6;
h_line_len = 6;
v_line_len = 6;
the_char = CH_CHECKERED3;
// good values
mu_assert(Text_DrawBox(the_system->screen_[ID_CHANNEL_A], x, y, h_line_len, v_line_len, the_char, FG_COLOR_CYAN, BG_COLOR_DK_CYAN, CHAR_AND_ATTR) == true, "Text_DrawBox failed" );
x += 7;
y += 2;
mu_assert(Text_DrawBox(the_system->screen_[ID_CHANNEL_A], x, y, h_line_len-2, v_line_len+5, --the_char, FG_COLOR_CYAN, BG_COLOR_DK_CYAN, CHAR_AND_ATTR) == true, "Text_DrawBox failed" );
// bad values
mu_assert(Text_DrawBox(the_system->screen_[ID_CHANNEL_B], -10, y, h_line_len, v_line_len, the_char, FG_COLOR_CYAN, BG_COLOR_DK_CYAN, CHAR_AND_ATTR) == false, "Text_DrawBox accepted illegal x coord" );
}
MU_TEST(text_test_fancy_box)
{
signed int x1;
signed int y1;
signed int x2;
signed int y2;
// signed int h_line_len;
// signed int v_line_len;
char* the_message;
// good values
the_message = General_StrlcpyWithAlloc((char*)"\nThe Anecdote\n\nBill Atkinson worked mostly at home, but whenever he made significant progress he rushed in to Apple to show it off to anyone who would appreciate it. This time, he visited the Macintosh offices at Texaco Towers to show off his brand new oval routines in Quickdraw, which were implemented using a really clever algorithm.\n\nBill had added new code to QuickDraw (which was still called LisaGraf at this point) to draw circles and ovals very quickly. That was a bit hard to do on the Macintosh, since the math for circles usually involved taking square roots, and the 68000 processor in the Lisa and Macintosh didn't support floating point operations. But Bill had come up with a clever way to do the circle calculation that only used addition and subtraction, not even multiplication or division, which the 68000 could do, but was kind of slow at.\n\nBill's technique used the fact the sum of a sequence of odd numbers is always the next perfect square (For example, 1 + 3 = 4, 1 + 3 + 5 = 9, 1 + 3 + 5 + 7 = 16, etc). So he could figure out when to bump the dependent coordinate value by iterating in a loop until a threshold was exceeded. This allowed QuickDraw to draw ovals very quickly.\n\nBill fired up his demo and it quickly filled the Lisa screen with randomly-sized ovals, faster than you thought was possible. But something was bothering Steve Jobs. 'Well, circles and ovals are good, but how about drawing rectangles with rounded corners? Can we do that now, too?'\n\n'No, there's no way to do that. In fact it would be really hard to do, and I don't think we really need it'. I think Bill was a little miffed that Steve wasn't raving over the fast ovals and still wanted more.\n\nSteve suddenly got more intense. 'Rectangles with rounded corners are everywhere! Just look around this room!'. And sure enough, there were lots of them, like the whiteboard and some of the desks and tables. Then he pointed out the window. 'And look outside, there's even more, practically everywhere you look!'. He even persuaded Bill to take a quick walk around the block with him, pointing out every rectangle with rounded corners that he could find.\n\n\nWhen Steve and Bill passed a no-parking sign with rounded corners, it did the trick. 'OK, I give up', Bill pleaded. 'I'll see if it's as hard as I thought.' He went back home to work on it.\n\nBill returned to Texaco Towers the following afternoon, with a big smile on his face. His demo was now drawing rectangles with beautifully rounded corners blisteringly fast, almost at the speed of plain rectangles. When he added the code to LisaGraf, he named the new primitive 'RoundRects'. Over the next few months, roundrects worked their way into various parts of the user interface, and soon became indispensable.\n\nThe Code\n\nAuthor: Bill Atkinson\nYear: 1981\n\nQuickDraw is the Macintosh library for creating bit-mapped graphics, which was used by MacPaint and other applications. It consists of a total of 17,101 lines in 36 files, all written in assembler language for the 68000.\n\n .INCLUDE GRAFTYPES.TEXT\n;-----------------------------------------------------------\n;\n;\n; **** **** ***** *** ***** ***\n; * * * * * * * * * *\n; * * * * * * * *\n; **** **** *** * * ***\n; * * * * * * * *\n; * * * * * * * * * *\n; * * * * ***** *** * ***\n;\n;\n; procedures for operating on RoundRects.\n;\n;\n .PROC StdRRect,4\n .REF CheckPic,DPutPicByte,PutPicVerb,PutPicLong,PutPicRect\n .REF PutOval,PushVerb,DrawArc\n;---------------------------------------------------------------\n;\n; PROCEDURE StdRRect(verb: GrafVerb; r: Rect; ovWd,ovHt: INTEGER);\n;\n; A6 OFFSETS OF PARAMS AFTER LINK:\n;\nPARAMSIZE .EQU 10\nVERB .EQU PARAMSIZE+8-2 ;GRAFVERB\nRECT .EQU VERB-4 ;LONG, ADDR OF RECT\nOVWD .EQU RECT-2 ;WORD\nOVHT .EQU OVWD-2 ;WORD\n LINK A6,#0 ;NO LOCALS\n MOVEM.L D7/A3-A4,-(SP) ;SAVE REGS\n MOVE.B VERB(A6),D7 ;GET VERB\n JSR CHECKPIC ;SET UP A4,A3 AND CHECK PICSAVE\n BLE.S NOTPIC ;BRANCH IF NOT PICSAVE\n MOVE.B D7,-(SP) ;PUSH VERB\n JSR PutPicVerb ;PUT ADDIONAL PARAMS TO THEPIC\n;\n; CHECK FOR NEW OVAL SIZE\n;\n MOVE.L PICSAVE(A3),A0 ;GET PICSAVE HANDLE\n MOVE.L (A0),A0 ;DE-REFERENCE PICSAVE\n MOVE.L OVHT(A6),D0 ;GET OVWD AND OVHT\n CMP.L PICOVSIZE(A0),D0 ;SAME AS CURRENT OVAL SIZE ?\n BEQ.S OVALOK ;YES, CONTINUE\n MOVE.L D0,PICOVSIZE(A0) ;NO, UPDATE STATE VARIABLE\n MOVE.L D0,-(SP) ;PUSH OVSIZE FOR PutPicLong CALL\n MOVEQ #$0B,D0\n JSR DPutPicByte ;PUT OVSIZE OPCODE\n JSR PutPicLong ;PUT NEW OVAL SIZE DATA\nOVALOK MOVEQ #$40,D0 ;PUT RRECT NOUN IN HI NIBBLE\n ADD D7,D0 ;PUT VERB IN LO NIBBLE\n MOVE.B D0,-(SP) ;PUSH OPCODE\n MOVE.L RECT(A6),-(SP) ;PUSH ADDR OF RECT\n JSR PutPicRect ;PUT OPCODE AND RECTANGLE\nNOTPIC MOVE.L RECT(A6),-(SP) ;PUSH ADDR OF RECT\n CLR.B -(SP) ;PUSH HOLLOW = FALSE\n TST.B D7 ;IS VERB FRAME ?\n BNE.S DOIT ;NO, CONTINUE\n TST.L RGNSAVE(A3) ;YES, IS RGNSAVE TRUE ?\n BEQ.S NOTRGN ;NO, CONTINUE\n MOVE.L RECT(A6),-(SP) ;YES, PUSH ADDR OF RECT\n MOVE.L OVHT(A6),-(SP) ;PUSH OVWD, OVHT\n MOVE.L RGNBUF(A4),-(SP) ;PUSH RGNBUF\n PEA RGNINDEX(A4) ;PUSH VAR RGNINDEX\n PEA RGNMAX(A4) ;PUSH VAR RGNMAX\n JSR PutOval ;ADD AN OVAL TO THERGN\nNOTRGN MOVE.B #1,(SP) ;REPLACE, PUSH HOLLOW = TRUE\nDOIT MOVE.L OVHT(A6),-(SP) ;PUSH OVWD,OVHT\n JSR PushVerb ;PUSH MODE AND PATTERN\n CLR -(SP) ;PUSH STARTANGLE = 0\n MOVE #360,-(SP) ;PUSH ARCANGLE = 360", 80*60+1);
// the_message = General_StrlcpyWithAlloc((char*)"\nThe Anecdote\n\nBill Atkinson worked mostly at home, but whenever he made significant progress he rushed in to Apple to show it off to anyone who would appreciate it. This time, he visited the Macintosh offices at Texaco Towers to show off his brand new oval routines in Quickdraw, which were implemented using a really clever algorithm.\n\nBill had added new code to QuickDraw", 80*60+1);
// the_message = General_StrlcpyWithAlloc((char*)"\n\n\nLINE ONE\n\nLINE TWO", 80*60+1);
// the_message = General_StrlcpyWithAlloc((char*)"THISISAREALLYBIGWORDBIGGERTHANANYYOUCANTHINK_OF_OR_AT_LEAST_I_THINK_SO", 80*60+1);
// draw huge on channel A screen
x1 = 2;
y1 = 2;
x2 = 98;
y2 = 73;
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_A], x1+1, y1+1, x2-1, y2-1, CH_CHECKERED1, BG_COLOR_CYAN, BG_COLOR_DK_BLUE) == true, "Text_FillBox failed" );
mu_assert(Text_DrawBoxCoordsFancy(the_system->screen_[ID_CHANNEL_A], x1, y1, x2, y2, FG_COLOR_LT_GRAY, BG_COLOR_BLACK) == true, "Text_DrawBoxCoordsFancy failed" );
x1 = 3;
y1 = 3;
x2 = 97;
y2 = 72;
mu_assert(Text_DrawStringInBox(the_system->screen_[ID_CHANNEL_A], x1, y1, x2, y2, the_message, FG_COLOR_WHITE, BG_COLOR_BLACK, NULL) != NULL, "Text_DrawStringInBox failed" );
// medium box on chan B
x1 = 12;
y1 = 4;
x2 = 68;
y2 = 51;
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_A], x1+1, y1+1, x2-1, y2-1, CH_CHECKERED3, FG_COLOR_LT_GRAY, BG_COLOR_WHITE) == true, "Text_FillBox failed" );
mu_assert(Text_DrawBoxCoordsFancy(the_system->screen_[ID_CHANNEL_A], x1, y1, x2, y2, FG_COLOR_LT_GRAY, BG_COLOR_DK_GRAY) == true, "Text_DrawBoxCoordsFancy failed" );
x1 = 13;
y1 = 5;
x2 = 67;
y2 = 50;
mu_assert(Text_DrawStringInBox(the_system->screen_[ID_CHANNEL_A], x1, y1, x2, y2, the_message, FG_COLOR_BLACK, BG_COLOR_WHITE, NULL) != NULL, "Text_DrawStringInBox failed" );
// small box on chan B
x1 = 39;
y1 = 19;
x2 = 71;
y2 = 41;
mu_assert( Text_FillBox(the_system->screen_[ID_CHANNEL_A], x1+1, y1+1, x2-1, y2-1, CH_CHECKERED1, BG_COLOR_CYAN, BG_COLOR_DK_BLUE) == true, "Text_FillBox failed" );
mu_assert(Text_DrawBoxCoordsFancy(the_system->screen_[ID_CHANNEL_A], x1, y1, x2, y2, FG_COLOR_LT_GRAY, BG_COLOR_BLACK) == true, "Text_DrawBoxCoordsFancy failed" );
x1 = 40;
y1 = 20;
x2 = 70;
y2 = 40;
mu_assert(Text_DrawStringInBox(the_system->screen_[ID_CHANNEL_A], x1, y1, x2, y2, the_message, FG_COLOR_WHITE, BG_COLOR_BLACK, NULL) != NULL, "Text_DrawStringInBox failed" );
}
MU_TEST(text_test_draw_string)
{
char* the_message;
// good values
mu_assert((the_message = General_StrlcpyWithAlloc((char*)"this is a string", 250)) != NULL, "General_StrlcpyWithAlloc returned NULL" );
mu_assert_string_eq("this is a string", (char*)the_message);
mu_assert(Text_DrawStringAtXY(the_system->screen_[ID_CHANNEL_B], 0, 5, the_message, FG_COLOR_YELLOW, BG_COLOR_DK_BLUE) == true, "Text_DrawStringAtXY failed" );
mu_assert(Text_DrawStringAtXY(the_system->screen_[ID_CHANNEL_B], 67, 4, the_message, FG_COLOR_DK_BLUE, BG_COLOR_YELLOW) == true, "Text_DrawStringAtXY failed" );
// bad values
mu_assert(Text_DrawStringAtXY(the_system->screen_[ID_CHANNEL_B], -1, 0, the_message, FG_COLOR_DK_BLUE, BG_COLOR_YELLOW) == false, "Text_DrawBoxCoordsFancy accepted illegal x coord" );
}
MU_TEST(text_test_draw_string_in_box)
{
char* the_message;
// good values
//mu_assert((the_message = General_StrlcpyWithAlloc((char*)"This is a short sentence.", 80*60+1)) != NULL, "General_StrlcpyWithAlloc returned NULL" );
//mu_assert((the_message = General_StrlcpyWithAlloc((char*)"This is a short sentence. Many are shorter. Like this. Heyo! Hello-Goodbye!", 80*60+1)) != NULL, "General_StrlcpyWithAlloc returned NULL" );
// mu_assert((the_message = General_StrlcpyWithAlloc((char*)"This is a longish sentence but others are longer. Many are shorter. Like this. oooooh, what a nice thingamajig you've got there.", 80*60+1)) != NULL, "General_StrlcpyWithAlloc returned NULL" );
the_message = General_StrlcpyWithAlloc((char*)"\nThe Anecdote\n\nBill Atkinson worked mostly at home, but whenever he made significant progress he rushed in to Apple to show it off to anyone who would appreciate it. This time, he visited the Macintosh offices at Texaco Towers to show off his brand new oval routines in Quickdraw, which were implemented using a really clever algorithm.\n\nBill had added new code to QuickDraw (which was still called LisaGraf at this point) to draw circles and ovals very quickly. That was a bit hard to do on the Macintosh, since the math for circles usually involved taking square roots, and the 68000 processor in the Lisa and Macintosh didn't support floating point operations. But Bill had come up with a clever way to do the circle calculation that only used addition and subtraction, not even multiplication or division, which the 68000 could do, but was kind of slow at.\n\nBill's technique used the fact the sum of a sequence of odd numbers is always the next perfect square (For example, 1 + 3 = 4, 1 + 3 + 5 = 9, 1 + 3 + 5 + 7 = 16, etc). So he could figure out when to bump the dependent coordinate value by iterating in a loop until a threshold was exceeded. This allowed QuickDraw to draw ovals very quickly.\n\nBill fired up his demo and it quickly filled the Lisa screen with randomly-sized ovals, faster than you thought was possible. But something was bothering Steve Jobs. 'Well, circles and ovals are good, but how about drawing rectangles with rounded corners? Can we do that now, too?'\n\n'No, there's no way to do that. In fact it would be really hard to do, and I don't think we really need it'. I think Bill was a little miffed that Steve wasn't raving over the fast ovals and still wanted more.\n\nSteve suddenly got more intense. 'Rectangles with rounded corners are everywhere! Just look around this room!'. And sure enough, there were lots of them, like the whiteboard and some of the desks and tables. Then he pointed out the window. 'And look outside, there's even more, practically everywhere you look!'. He even persuaded Bill to take a quick walk around the block with him, pointing out every rectangle with rounded corners that he could find.\n\n\nWhen Steve and Bill passed a no-parking sign with rounded corners, it did the trick. 'OK, I give up', Bill pleaded. 'I'll see if it's as hard as I thought.' He went back home to work on it.\n\nBill returned to Texaco Towers the following afternoon, with a big smile on his face. His demo was now drawing rectangles with beautifully rounded corners blisteringly fast, almost at the speed of plain rectangles. When he added the code to LisaGraf, he named the new primitive 'RoundRects'. Over the next few months, roundrects worked their way into various parts of the user interface, and soon became indispensable.\n\nThe Code\n\nAuthor: Bill Atkinson\nYear: 1981\n\nQuickDraw is the Macintosh library for creating bit-mapped graphics, which was used by MacPaint and other applications. It consists of a total of 17,101 lines in 36 files, all written in assembler language for the 68000.\n\n .INCLUDE GRAFTYPES.TEXT\n;-----------------------------------------------------------\n;\n;\n; **** **** ***** *** ***** ***\n; * * * * * * * * * *\n; * * * * * * * *\n; **** **** *** * * ***\n; * * * * * * * *\n; * * * * * * * * * *\n; * * * * ***** *** * ***\n;\n;\n; procedures for operating on RoundRects.\n;\n;\n .PROC StdRRect,4\n .REF CheckPic,DPutPicByte,PutPicVerb,PutPicLong,PutPicRect\n .REF PutOval,PushVerb,DrawArc\n;---------------------------------------------------------------\n;\n; PROCEDURE StdRRect(verb: GrafVerb; r: Rect; ovWd,ovHt: INTEGER);\n;\n; A6 OFFSETS OF PARAMS AFTER LINK:\n;\nPARAMSIZE .EQU 10\nVERB .EQU PARAMSIZE+8-2 ;GRAFVERB\nRECT .EQU VERB-4 ;LONG, ADDR OF RECT\nOVWD .EQU RECT-2 ;WORD\nOVHT .EQU OVWD-2 ;WORD\n LINK A6,#0 ;NO LOCALS\n MOVEM.L D7/A3-A4,-(SP) ;SAVE REGS\n MOVE.B VERB(A6),D7 ;GET VERB\n JSR CHECKPIC ;SET UP A4,A3 AND CHECK PICSAVE\n BLE.S NOTPIC ;BRANCH IF NOT PICSAVE\n MOVE.B D7,-(SP) ;PUSH VERB\n JSR PutPicVerb ;PUT ADDIONAL PARAMS TO THEPIC\n;\n; CHECK FOR NEW OVAL SIZE\n;\n MOVE.L PICSAVE(A3),A0 ;GET PICSAVE HANDLE\n MOVE.L (A0),A0 ;DE-REFERENCE PICSAVE\n MOVE.L OVHT(A6),D0 ;GET OVWD AND OVHT\n CMP.L PICOVSIZE(A0),D0 ;SAME AS CURRENT OVAL SIZE ?\n BEQ.S OVALOK ;YES, CONTINUE\n MOVE.L D0,PICOVSIZE(A0) ;NO, UPDATE STATE VARIABLE\n MOVE.L D0,-(SP) ;PUSH OVSIZE FOR PutPicLong CALL\n MOVEQ #$0B,D0\n JSR DPutPicByte ;PUT OVSIZE OPCODE\n JSR PutPicLong ;PUT NEW OVAL SIZE DATA\nOVALOK MOVEQ #$40,D0 ;PUT RRECT NOUN IN HI NIBBLE\n ADD D7,D0 ;PUT VERB IN LO NIBBLE\n MOVE.B D0,-(SP) ;PUSH OPCODE\n MOVE.L RECT(A6),-(SP) ;PUSH ADDR OF RECT\n JSR PutPicRect ;PUT OPCODE AND RECTANGLE\nNOTPIC MOVE.L RECT(A6),-(SP) ;PUSH ADDR OF RECT\n CLR.B -(SP) ;PUSH HOLLOW = FALSE\n TST.B D7 ;IS VERB FRAME ?\n BNE.S DOIT ;NO, CONTINUE\n TST.L RGNSAVE(A3) ;YES, IS RGNSAVE TRUE ?\n BEQ.S NOTRGN ;NO, CONTINUE\n MOVE.L RECT(A6),-(SP) ;YES, PUSH ADDR OF RECT\n MOVE.L OVHT(A6),-(SP) ;PUSH OVWD, OVHT\n MOVE.L RGNBUF(A4),-(SP) ;PUSH RGNBUF\n PEA RGNINDEX(A4) ;PUSH VAR RGNINDEX\n PEA RGNMAX(A4) ;PUSH VAR RGNMAX\n JSR PutOval ;ADD AN OVAL TO THERGN\nNOTRGN MOVE.B #1,(SP) ;REPLACE, PUSH HOLLOW = TRUE\nDOIT MOVE.L OVHT(A6),-(SP) ;PUSH OVWD,OVHT\n JSR PushVerb ;PUSH MODE AND PATTERN\n CLR -(SP) ;PUSH STARTANGLE = 0\n MOVE #360,-(SP) ;PUSH ARCANGLE = 360", 80*60+1);
// the_message = General_StrlcpyWithAlloc((char*)"\nThe Anecdote\n\nBill Atkinson worked mostly at home, but whenever he made significant progress he rushed in to Apple to show it off to anyone who would appreciate it. This time, he visited the Macintosh offices at Texaco Towers to show off his brand new oval routines in Quickdraw, which were implemented using a really clever algorithm.\n\nBill had added new code to QuickDraw", 80*60+1);
// the_message = General_StrlcpyWithAlloc((char*)"\n\n\nLINE ONE\n\nLINE TWO", 80*60+1);
// the_message = General_StrlcpyWithAlloc((char*)"THISISAREALLYBIGWORDBIGGERTHANANYYOUCANTHINK_OF_OR_AT_LEAST_I_THINK_SO", 80*60+1);
mu_assert(Text_DrawStringInBox(the_system->screen_[ID_CHANNEL_A], 3, 6, 67, 50, the_message, FG_COLOR_BLACK, BG_COLOR_WHITE, NULL) != NULL, "Text_DrawStringInBox failed" );
mu_assert(Text_DrawStringInBox(the_system->screen_[ID_CHANNEL_B], 21, 21, 40, 40, the_message, FG_COLOR_WHITE, BG_COLOR_BLACK, NULL) != NULL, "Text_DrawStringInBox failed" );
}
MU_TEST(font_replace_test)
{
// until file objects available in emulator, need to embed data to test font replacement.
// this is a remapped C64 font for code page 437
// Exported using VChar64 v0.2.4
// Total bytes: 2048
unsigned char testfont[] = {
0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x0f,0x0f,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0x36,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00,
0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x18,0x18,0x66,0x66,0x18,0x18,0x3c,0x00,
0x08,0x1c,0x3e,0x7f,0x7f,0x1c,0x3e,0x00,0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
0xff,0xc3,0x81,0x81,0x81,0x81,0xc3,0xff,0x00,0x3c,0x7e,0x66,0x66,0x7e,0x3c,0x00,
0xff,0xc3,0x81,0x99,0x99,0x81,0xc3,0xff,0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,
0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0x00,0x00,
0xff,0xff,0xfc,0xc1,0x89,0xc9,0xc9,0xff,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,
0xf7,0xe3,0xc1,0x80,0x80,0xe3,0xc1,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,
0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,
0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,
0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xff,0xff,0xff,0x1f,0x0f,0xc7,0xe7,0xe7,
0xe7,0xe7,0xe3,0xf0,0xf8,0xff,0xff,0xff,0x00,0x10,0x30,0x7f,0x7f,0x30,0x10,0x00,
0x00,0x00,0x00,0x00,0x0f,0x0f,0x0f,0x0f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x03,0x07,0x0e,0x1c,0x38,0x70,0xe0,0xc0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x18,0x00,
0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0xff,0x66,0xff,0x66,0x66,0x00,
0x18,0x3e,0x60,0x3c,0x06,0x7c,0x18,0x00,0x62,0x66,0x0c,0x18,0x30,0x66,0x46,0x00,
0x3c,0x66,0x3c,0x38,0x67,0x66,0x3f,0x00,0x06,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,
0x0c,0x18,0x30,0x30,0x30,0x18,0x0c,0x00,0x30,0x18,0x0c,0x0c,0x0c,0x18,0x30,0x00,
0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x00,
0x3c,0x66,0x6e,0x76,0x66,0x66,0x3c,0x00,0x18,0x18,0x38,0x18,0x18,0x18,0x7e,0x00,
0x3c,0x66,0x06,0x0c,0x30,0x60,0x7e,0x00,0x3c,0x66,0x06,0x1c,0x06,0x66,0x3c,0x00,
0x06,0x0e,0x1e,0x66,0x7f,0x06,0x06,0x00,0x7e,0x60,0x7c,0x06,0x06,0x66,0x3c,0x00,
0x3c,0x66,0x60,0x7c,0x66,0x66,0x3c,0x00,0x7e,0x66,0x0c,0x18,0x18,0x18,0x18,0x00,
0x3c,0x66,0x66,0x3c,0x66,0x66,0x3c,0x00,0x3c,0x66,0x66,0x3e,0x06,0x66,0x3c,0x00,
0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x18,0x30,
0x0e,0x18,0x30,0x60,0x30,0x18,0x0e,0x00,0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,
0x70,0x18,0x0c,0x06,0x0c,0x18,0x70,0x00,0x3c,0x66,0x06,0x0c,0x18,0x00,0x18,0x00,
0x3c,0x66,0x6e,0x6e,0x60,0x62,0x3c,0x00,0x18,0x3c,0x66,0x7e,0x66,0x66,0x66,0x00,
0x7c,0x66,0x66,0x7c,0x66,0x66,0x7c,0x00,0x3c,0x66,0x60,0x60,0x60,0x66,0x3c,0x00,
0x78,0x6c,0x66,0x66,0x66,0x6c,0x78,0x00,0x7e,0x60,0x60,0x78,0x60,0x60,0x7e,0x00,
0x7e,0x60,0x60,0x78,0x60,0x60,0x60,0x00,0x3c,0x66,0x60,0x6e,0x66,0x66,0x3c,0x00,
0x66,0x66,0x66,0x7e,0x66,0x66,0x66,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,
0x1e,0x0c,0x0c,0x0c,0x0c,0x6c,0x38,0x00,0x66,0x6c,0x78,0x70,0x78,0x6c,0x66,0x00,
0x60,0x60,0x60,0x60,0x60,0x60,0x7e,0x00,0x63,0x77,0x7f,0x6b,0x63,0x63,0x63,0x00,
0x66,0x76,0x7e,0x7e,0x6e,0x66,0x66,0x00,0x3c,0x66,0x66,0x66,0x66,0x66,0x3c,0x00,
0x7c,0x66,0x66,0x7c,0x60,0x60,0x60,0x00,0x3c,0x66,0x66,0x66,0x66,0x3c,0x0e,0x00,
0x7c,0x66,0x66,0x7c,0x78,0x6c,0x66,0x00,0x3c,0x66,0x60,0x3c,0x06,0x66,0x3c,0x00,
0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x00,
0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,
0x66,0x66,0x3c,0x18,0x3c,0x66,0x66,0x00,0x66,0x66,0x66,0x3c,0x18,0x18,0x18,0x00,
0x7e,0x06,0x0c,0x18,0x30,0x60,0x7e,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,
0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0x03,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,
0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0x00,0x00,0x00,0xe0,0xf0,0x38,0x18,0x18,0x00,0x00,0x3c,0x06,0x3e,0x66,0x3e,0x00,
0x00,0x60,0x60,0x7c,0x66,0x66,0x7c,0x00,0x00,0x00,0x3c,0x60,0x60,0x60,0x3c,0x00,
0x00,0x06,0x06,0x3e,0x66,0x66,0x3e,0x00,0x00,0x00,0x3c,0x66,0x7e,0x60,0x3c,0x00,
0x00,0x0e,0x18,0x3e,0x18,0x18,0x18,0x00,0x00,0x00,0x3e,0x66,0x66,0x3e,0x06,0x7c,
0x00,0x60,0x60,0x7c,0x66,0x66,0x66,0x00,0x00,0x18,0x00,0x38,0x18,0x18,0x3c,0x00,
0x00,0x06,0x00,0x06,0x06,0x06,0x06,0x3c,0x00,0x60,0x60,0x6c,0x78,0x6c,0x66,0x00,
0x00,0x38,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x66,0x7f,0x7f,0x6b,0x63,0x00,
0x00,0x00,0x7c,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x3c,0x66,0x66,0x66,0x3c,0x00,
0x00,0x00,0x7c,0x66,0x66,0x7c,0x60,0x60,0x00,0x00,0x3e,0x66,0x66,0x3e,0x06,0x06,
0x00,0x00,0x7c,0x66,0x60,0x60,0x60,0x00,0x00,0x00,0x3e,0x60,0x3c,0x06,0x7c,0x00,
0x00,0x18,0x7e,0x18,0x18,0x18,0x0e,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x00,
0x00,0x00,0x66,0x66,0x66,0x3c,0x18,0x00,0x00,0x00,0x63,0x6b,0x7f,0x3e,0x36,0x00,
0x00,0x00,0x66,0x3c,0x18,0x3c,0x66,0x00,0x00,0x00,0x66,0x66,0x66,0x3e,0x0c,0x78,
0x00,0x00,0x7e,0x0c,0x18,0x30,0x7e,0x00,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x18,0x18,0x18,0xff,0xff,0x00,0x00,0x00,
0x0c,0x12,0x30,0x7c,0x30,0x62,0xfc,0x00,0x01,0x03,0x06,0x6c,0x78,0x70,0x60,0x00,
0xff,0xff,0xff,0xe0,0xe0,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0x00,0x00,0xff,0xff,0xff,
0xff,0xff,0xff,0x00,0x00,0xe7,0xe7,0xe7,0x3f,0x3f,0xcf,0xcf,0x3f,0x3f,0xcf,0xcf,
0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe7,0xe7,0xc7,0x0f,0x1f,0xff,0xff,0xff,
0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xfc,
0xfc,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x00,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
0x00,0x00,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0,
0x00,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xf0,0xc9,0x80,0x80,0x80,0xc1,0xe3,0xf7,0xff,
0x9f,0x9f,0x9f,0x9f,0x9f,0x9f,0x9f,0x9f,0xff,0xff,0xff,0xf8,0xf0,0xe3,0xe7,0xe7,
0x3c,0x18,0x81,0xc3,0xc3,0x81,0x18,0x3c,0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00,
0xe7,0xe7,0x99,0x99,0xe7,0xe7,0xc3,0xff,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,
0xf7,0xe3,0xc1,0x80,0xc1,0xe3,0xf7,0xff,0xe7,0xe7,0xe7,0x00,0x00,0xe7,0xe7,0xe7,
0xc0,0xc0,0x30,0x30,0xc0,0xc0,0x30,0x30,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x18,0x18,0x18,0x1f,0x1f,0x18,0x18,0x18,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,
0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
0x33,0x33,0xcc,0xcc,0x33,0x33,0xcc,0xcc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
0xff,0xff,0xff,0xff,0x33,0x33,0xcc,0xcc,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xe7,0xe7,0xe7,0xe0,0xe0,0xe7,0xe7,0xe7,
0xff,0xff,0xff,0xff,0xf0,0xf0,0xf0,0xf0,0xe7,0xe7,0xe7,0xe0,0xe0,0xff,0xff,0xff,
0xff,0xff,0xff,0x07,0x07,0xe7,0xe7,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x33,0x33,0xcc,0xcc,0x33,0x33,0xcc,0xcc,0x33,0x99,0xcc,0x66,0x33,0x99,0xcc,0x66,
0xcc,0xcc,0x33,0x33,0xcc,0xcc,0x33,0x33,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0xf8,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0xff,0xff,0x18,0x18,0x18,
0xe7,0xe7,0xe7,0x07,0x07,0xe7,0xe7,0xe7,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,
0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xff,0xff,0xff,0xff,0x0f,0x0f,0x0f,0x0f,
0xf0,0xf0,0xf0,0xf0,0xff,0xff,0xff,0xff,0xe7,0xe7,0xe7,0x07,0x07,0xff,0xff,0xff,
0x0f,0x0f,0x0f,0x0f,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xf8,0xf8,0x18,0x18,0x18,
0x18,0x18,0x18,0x1f,0x1f,0x00,0x00,0x00,0xc0,0xc0,0x30,0x30,0xc0,0xc0,0x30,0x30,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,
0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x1c,0x0f,0x07,0x00,0x00,0x00,0x18,0x18,0x38,0xf0,0xe0,0x00,0x00,0x00,
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0xff,0xff,0x03,0x03,0x03,0x03,0x03,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x07,0x0f,0x1c,0x18,0x18,
0xc3,0xe7,0x7e,0x3c,0x3c,0x7e,0xe7,0xc3,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x00,0x00,0x00,0x00,0xcc,0xcc,0x33,0x33,0x18,0x18,0x18,0xf8,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x1f,0x1f,0x18,0x18,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
0x00,0x00,0x03,0x3e,0x76,0x36,0x36,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0xcc,0xcc,0x33,0x33,0xcc,0xcc,0x33,0x33,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x00,0x00,0x00,0x00,0xcc,0xcc,0x33,0x33,0xcc,0x99,0x33,0x66,0xcc,0x99,0x33,0x66,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x18,0x18,0x18,0x1f,0x1f,0x18,0x18,0x18,
0x00,0x00,0x00,0x00,0x0f,0x0f,0x0f,0x0f,0x18,0x18,0x18,0x1f,0x1f,0x00,0x00,0x00,
0x00,0x00,0x00,0xf8,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0x00,0x00,0x00,0x1f,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0xf8,0x18,0x18,0x18,
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0x03,0x03,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xf0,
0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0xf8,0xf8,0x00,0x00,0x00,
0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x0f,0x0f,
};
unsigned char* the_new_font_data = testfont;
// mu_assert(Text_UpdateFontData(the_system->screen_[ID_CHANNEL_A], (char*)the_new_font_data) == true, "Failed to update font data for Channel A" );
mu_assert(Text_UpdateFontData(the_system->screen_[ID_CHANNEL_B], (char*)the_new_font_data) == true, "Failed to update font data for Channel B" );
}
// **** speed tests
MU_TEST(text_test_hline_speed)
{
long start1;
long end1;
long start2;
long end2;
signed int x;
signed int y;
signed int line_len;
unsigned char the_char;
signed int i;
signed int num_passes = 90;
signed int j;
signed int num_cycles = 10;
x = 1;
y = 1;
line_len = 120;
the_char = CH_WALL_H;
// test speed of first variant
start1 = mu_timer_real();
for (j = 0; j < num_cycles; j++)
{
for (i=0; i < num_passes; i++)
{
mu_assert( Text_DrawHLineSlow(the_system->screen_[ID_CHANNEL_A], x, y + i, line_len, the_char, FG_COLOR_GREEN, BG_COLOR_BLACK, CHAR_ONLY) == true, "Text_DrawHLine failed" );
}
}
end1 = mu_timer_real();
// test speed of second variant
x++;
start2 = mu_timer_real();
for (j = 0; j < num_cycles; j++)
{
for (i=0; i < num_passes; i++)
{
mu_assert( Text_DrawHLine(the_system->screen_[ID_CHANNEL_A], x, y + i, line_len, the_char, FG_COLOR_RED, BG_COLOR_BLACK, CHAR_ONLY) == true, "Text_DrawHLine failed" );
}
}
end2 = mu_timer_real();
printf("\nSpeed results: first routine completed in %li ticks; second in %li ticks\n", end1 - start1, end2 - start2);
// run again, with different values
x = 1;
y = 1;
line_len = 120;
the_char = CH_WALL_H;
// test speed of first variant
start1 = mu_timer_real();
for (j = 0; j < num_cycles; j++)
{
for (i=0; i < num_passes; i++)
{
mu_assert( Text_DrawHLineSlow(the_system->screen_[ID_CHANNEL_A], x, y + i, line_len, the_char, FG_COLOR_GREEN, BG_COLOR_BLACK, CHAR_AND_ATTR) == true, "Text_DrawHLine failed" );
}
}
end1 = mu_timer_real();
// test speed of second variant
x++;
start2 = mu_timer_real();
for (j = 0; j < num_cycles; j++)
{
for (i=0; i < num_passes; i++)
{
mu_assert( Text_DrawHLine(the_system->screen_[ID_CHANNEL_A], x, y + i, line_len, the_char, FG_COLOR_RED, BG_COLOR_BLACK, CHAR_AND_ATTR) == true, "Text_DrawHLine failed" );
}
}
end2 = mu_timer_real();
printf("\nSpeed results: first routine completed in %li ticks; second in %li ticks\n", end1 - start1, end2 - start2);
}
// speed tests
MU_TEST_SUITE(text_test_suite_speed)
{
MU_SUITE_CONFIGURE(&text_test_setup, &text_test_teardown);
MU_RUN_TEST(text_test_hline_speed);
}
// unit tests
MU_TEST_SUITE(text_test_suite_units)
{
MU_SUITE_CONFIGURE(&text_test_setup, &text_test_teardown);
MU_RUN_TEST(text_test_fill_text);
MU_RUN_TEST(text_test_fill_attr);
MU_RUN_TEST(text_test_fill_box);
MU_RUN_TEST(text_test_show_font);
MU_RUN_TEST(text_test_char_placement);
MU_RUN_TEST(text_test_block_copy_box);
// MU_RUN_TEST(text_test_font_overwrite);
// MU_RUN_TEST(text_test_update_font);
MU_RUN_TEST(text_test_char_and_attr_writing);
MU_RUN_TEST(text_test_char_and_attr_reading);
MU_RUN_TEST(text_test_line_drawing);
MU_RUN_TEST(text_test_basic_box_coords);
MU_RUN_TEST(text_test_basic_box_hw);
MU_RUN_TEST(text_test_fancy_box);
MU_RUN_TEST(text_test_draw_string);
MU_RUN_TEST(text_test_draw_string_in_box);
MU_RUN_TEST(text_test_invert_box);