@@ -7,6 +7,38 @@ DISKARGS="-hard1 $HARDIMG -hard2 res/tests.hdv"
77
88apple2 .SetMonitorType (apple2 .MONITOR_TYPE_VIDEO7 )
99
10+ function IsMono ()
11+ emu .wait_next_frame ()
12+ -- https://docs.mamedev.org/luascript/ref-core.html#video-manager
13+ local pixels = manager .machine .video :snapshot_pixels ()
14+ local width , height = manager .machine .video :snapshot_size ()
15+
16+ -- TODO: Make this work with IIgs border
17+
18+ function pixel (x ,y )
19+ local a = string.byte (pixels , (x + y * width ) * 4 + 0 )
20+ local b = string.byte (pixels , (x + y * width ) * 4 + 1 )
21+ local g = string.byte (pixels , (x + y * width ) * 4 + 2 )
22+ local r = string.byte (pixels , (x + y * width ) * 4 + 3 )
23+ return r ,g ,b ,a
24+ end
25+
26+ for y = 0 ,height - 1 do
27+ for x = 0 ,width - 1 do
28+ local r ,g ,b ,a = pixel (x ,y )
29+ if r ~= g or r ~= b then
30+ return false
31+ end
32+ end
33+ end
34+
35+ return true
36+ end
37+
38+ function IsColor ()
39+ return not IsMono ()
40+ end
41+
1042test .Step (
1143 " Escape exits" ,
1244 function ()
@@ -35,26 +67,42 @@ test.Step(
3567 a2d .OpenPath (" /A2.DESKTOP/SAMPLE.MEDIA/MONARCH" )
3668 apple2 .SpaceKey ()
3769 a2d .WaitForRepaint ()
38- test .Snap ( " verify mono" )
70+ test .Expect ( IsMono (), " should be mono" )
3971 apple2 .SpaceKey ()
4072 a2d .WaitForRepaint ()
41- test .Snap ( " verify color" )
73+ test .Expect ( IsColor (), " should be color" )
4274 a2d .CloseWindow ()
4375end )
4476
4577test .Step (
4678 " .A2HR opens in mono" ,
4779 function ()
4880 a2d .OpenPath (" /TESTS/FILE.TYPES/HRMONO.A2HR" )
49- test .Snap ( " verify mono" )
81+ test .Expect ( IsMono (), " should be mono" )
5082 a2d .CloseWindow ()
5183end )
5284
5385test .Step (
5486 " .A2LC opens in color" ,
5587 function ()
5688 a2d .OpenPath (" /TESTS/FILE.TYPES/HRCOLOR.A2LC" )
57- test .Snap (" verify color" )
89+ test .Expect (IsColor (), " should be color" )
90+ a2d .CloseWindow ()
91+ end )
92+
93+ test .Step (
94+ " .A2FM opens in mono" ,
95+ function ()
96+ a2d .OpenPath (" /TESTS/FILE.TYPES/DHRMONO.A2FM" )
97+ test .Expect (IsMono (), " should be mono" )
98+ a2d .CloseWindow ()
99+ end )
100+
101+ test .Step (
102+ " .A2FC opens in color" ,
103+ function ()
104+ a2d .OpenPath (" /TESTS/FILE.TYPES/DHRCOLOR.A2FC" )
105+ test .Expect (IsColor (), " should be color" )
58106 a2d .CloseWindow ()
59107end )
60108
0 commit comments