Skip to content

Commit 170a084

Browse files
committed
New page-mode test
1 parent 3467002 commit 170a084

File tree

5 files changed

+485
-1
lines changed

5 files changed

+485
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ dkms.conf
5757

5858
# debug information files
5959
*.dwo
60+
61+
.vscode/mcp.json

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"current_test": "refresh-rate",
2+
"current_test": "page-mode",
33
"files.exclude": {
44
"**/*.o": true,
55
"**/*.so": true,

page-mode/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include ../shared/lynxcc65.mak
2+
3+
CFLAGS += -I../shared
4+
5+
target = page-mode.lnx
6+
symbols = page-mode.sym
7+
objects = tests.o main.o
8+
9+
all: $(target)
10+
11+
$(target) : $(objects)
12+
$(CL) -Ln $(symbols) -t $(SYS) -o $@ $(objects) lynx.lib
13+
14+
clean:
15+
$(RM) -f $(objects) $(target)

page-mode/main.c

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#include <lynx.h>
2+
#include <tgi.h>
3+
#include <6502.h>
4+
#include <stdint.h>
5+
#include "util.h"
6+
7+
#define RESULT_COUNT 6
8+
#define TEST_COUNT 6
9+
10+
extern void run_tests(void);
11+
static void init(void);
12+
static void paint_results(void);
13+
static void paint_debug_results(void);
14+
static void loop_forever(void);
15+
16+
extern volatile uint8_t g_results[RESULT_COUNT];
17+
18+
static const expected_result_t k_expected_results[RESULT_COUNT] =
19+
{
20+
EXPECT(0x35),
21+
EXPECT(0x41),
22+
EXPECT(0x69),
23+
EXPECT(0x81),
24+
EXPECT(0x74, 0x75),
25+
EXPECT(0x81),
26+
};
27+
28+
static const uint8_t k_test_offsets[TEST_COUNT] = { 0, 1, 2, 3, 4, 5 };
29+
static const uint8_t k_test_counts[TEST_COUNT] = { 1, 1, 1, 1, 1, 1 };
30+
31+
static const char* k_test_names[TEST_COUNT] =
32+
{
33+
"NOP PM ON",
34+
"NOP PM OFF",
35+
"LDX PM ON",
36+
"LDX PM OFF",
37+
"MEM PM ON",
38+
"MEM PM OFF"
39+
};
40+
41+
void main(void)
42+
{
43+
run_tests();
44+
init();
45+
paint_results();
46+
paint_debug_results();
47+
loop_forever();
48+
}
49+
50+
static void init(void)
51+
{
52+
tgi_install(tgi_static_stddrv);
53+
tgi_init();
54+
55+
CLI();
56+
57+
while (tgi_busy()) { }
58+
tgi_clear();
59+
}
60+
61+
static void paint_results(void)
62+
{
63+
char buf[4];
64+
int t;
65+
int y = 9;
66+
int x = 9;
67+
int x_result = 9 * 12;
68+
69+
for (t = 0; t < TEST_COUNT; ++t)
70+
{
71+
uint8_t off = k_test_offsets[t];
72+
uint8_t cnt = k_test_counts[t];
73+
int pass = 1;
74+
int fail_index = -1;
75+
int i;
76+
77+
for (i = 0; i < cnt; ++i)
78+
{
79+
if (!is_valid_result(g_results[off + i], &k_expected_results[off + i]))
80+
{
81+
pass = 0;
82+
fail_index = i;
83+
break;
84+
}
85+
}
86+
87+
tgi_setcolor(COLOR_YELLOW);
88+
tgi_outtextxy(x, y, k_test_names[t]);
89+
90+
if (pass)
91+
{
92+
tgi_setcolor(COLOR_LIGHTGREEN);
93+
tgi_outtextxy(x + x_result, y, "PASS");
94+
}
95+
else
96+
{
97+
98+
tgi_setcolor(COLOR_RED);
99+
100+
if (fail_index + 1 >= 10)
101+
{
102+
buf[0] = '0' + ((fail_index + 1) / 10);
103+
buf[1] = '0' + ((fail_index + 1) % 10);
104+
buf[2] = 0;
105+
}
106+
else
107+
{
108+
buf[0] = '0' + (fail_index + 1);
109+
buf[1] = 0;
110+
}
111+
112+
tgi_outtextxy(x + x_result, y, buf);
113+
}
114+
115+
y += 9;
116+
}
117+
}
118+
119+
static void paint_debug_results(void)
120+
{
121+
char buf[4];
122+
int i;
123+
int y = 9 * 9;
124+
int x = 0;
125+
126+
tgi_setcolor(COLOR_WHITE);
127+
128+
for (i = 0; i < RESULT_COUNT; ++i)
129+
{
130+
hex2(buf, g_results[i]);
131+
tgi_outtextxy(x, y, buf);
132+
x += 18;
133+
134+
if ((i + 1) % 9 == 0)
135+
{
136+
y += 9;
137+
x = 0;
138+
}
139+
}
140+
}
141+
142+
static void loop_forever(void)
143+
{
144+
tgi_updatedisplay();
145+
for (;;) ;
146+
}

0 commit comments

Comments
 (0)