Repository navigation
Expand file tree
/
Copy pathscreen.cpp
More file actions
80 lines (65 loc) · 2.05 KB
/
Copy pathscreen.cpp
File metadata and controls
80 lines (65 loc) · 2.05 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
#include <stdint.h>
#include <machine.h>
#include <memory.h>
#include <display.h>
#include <debugging.h>
#include <ram.h>
#include "screen.h"
// this routine attempts to minimise the amount of screen updating
// required whenever the display-related softswitches change:
// page - page1 / page2
// text - text / graphics
// mixed - mixed / full-screen
// hgr - lores / hires graphics
void Screen::on_mode_change(uint8_t mode) {
if (mode == _mode) return;
bool text = (mode >> 3) & 1, mixed = (mode >> 2) & 1, hgr = mode & 1;
bool top_hgr = !text && hgr, btm_text = text || mixed;
hires.set_top_active(top_hgr);
lores.set_top_active(!top_hgr);
hires.set_btm_active(!btm_text && hgr);
lores.set_btm_active(btm_text);
uint8_t diff = mode ^ _mode;
if (diff & 0b1011) { // skip if only "mixed" changed
if (text)
lores.redraw(0, SPLIT_LINE, true);
else if (hgr)
hires.redraw(0, SPLIT_LINE);
else
lores.redraw(0, SPLIT_LINE, false);
}
// redraw bottom if any of text/graphics, mixed/full or page2/1 changes
// _or_ if hires/lores flips _and_ in full-screen graphics mode
// i.e., skip if in mixed mode and hires/lores changes
if ((diff & 0b1110) || ((diff & 0x01) && !btm_text)) {
if (btm_text)
lores.redraw(SPLIT_LINE, SCREEN_LINES, true);
else if (hgr)
hires.redraw(SPLIT_LINE, SCREEN_LINES);
else
lores.redraw(SPLIT_LINE, SCREEN_LINES, false);
}
_mode = mode;
}
// forced redraw on restore from checkpoint
void Screen::redraw(uint8_t mode) {
bool text = (mode >> 3) & 1, mixed = (mode >> 2) & 1, hgr = mode & 1;
bool top_hgr = !text && hgr, btm_text = text || mixed;
hires.set_top_active(top_hgr);
lores.set_top_active(!top_hgr);
hires.set_btm_active(!btm_text && hgr);
lores.set_btm_active(btm_text);
if (text)
lores.redraw(0, SPLIT_LINE, true);
else if (hgr)
hires.redraw(0, SPLIT_LINE);
else
lores.redraw(0, SPLIT_LINE, false);
if (btm_text)
lores.redraw(SPLIT_LINE, SCREEN_LINES, true);
else if (hgr)
hires.redraw(SPLIT_LINE, SCREEN_LINES);
else
lores.redraw(SPLIT_LINE, SCREEN_LINES, false);
_mode = mode;
}