-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmultiplex_display.ice
142 lines (131 loc) · 5.44 KB
/
multiplex_display.ice
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
algorithm multiplex_display(
input uint10 pix_x,
input uint10 pix_y,
input uint1 pix_active,
input uint1 pix_vblank,
output! uint8 pix_red,
output! uint8 pix_green,
output! uint8 pix_blue,
// DISPLAY ORDER AND COLOUR/BW MODE
input uint2 display_order,
input uint1 colour,
// BACKGROUND
input uint8 background_p,
// TILEMAPS
input uint6 lower_tilemap_p,
input uint1 lower_tilemap_display,
input uint6 upper_tilemap_p,
input uint1 upper_tilemap_display,
// SPRITES
input uint6 lower_sprites_p,
input uint1 lower_sprites_display,
input uint6 upper_sprites_p,
input uint1 upper_sprites_display,
// BITMAP
input uint6 bitmap_p,
input uint1 bitmap_display,
// CHARACTER MAP
input uint6 character_map_p,
input uint1 character_map_display,
// TERMINAL
input uint1 terminal_p,
input uint1 terminal_display
) <autorun,reginputs> {
uint6 pixel = uninitialised;
selectlayer LAYER(
display_order <: display_order,
terminal_display <: terminal_display,
terminal <: terminal_p,
character_map_display <: character_map_display,
character_map <: character_map_p,
upper_sprites_display <: upper_sprites_display,
upper_sprites <: upper_sprites_p,
bitmap_display <: bitmap_display,
bitmap <: bitmap_p,
lower_sprites_display <: lower_sprites_display,
lower_sprites <: lower_sprites_p,
lower_tilemap_display <: lower_tilemap_display,
lower_tilemap <: lower_tilemap_p,
upper_tilemap_display <: upper_tilemap_display,
upper_tilemap <: upper_tilemap_p,
background <: background_p,
pix :> pixel
);
// SELECT COLOUR OR BLACK AND WHITE
uint8 grey <: { pixel[0,6], pixel[0,2] };
pix_red := { {4{pixel[4,2]}} }; pix_green := { {4{pixel[2,2]}} }; pix_blue := { {4{pixel[0,2]}} };
always {
if( ~colour ) {
pix_red = grey;
pix_green = grey;
pix_blue = grey;
}
}
}
// CHOOSE LAY TO DISPLAY
algorithm selectlayer(
input uint2 display_order,
input uint1 terminal_display,
input uint1 terminal,
input uint1 character_map_display,
input uint6 character_map,
input uint1 upper_sprites_display,
input uint6 upper_sprites,
input uint1 bitmap_display,
input uint6 bitmap,
input uint1 lower_sprites_display,
input uint6 lower_sprites,
input uint1 lower_tilemap_display,
input uint6 lower_tilemap,
input uint1 upper_tilemap_display,
input uint6 upper_tilemap,
input uint6 background,
output! uint6 pix
) <autorun> {
// CONVERT TERMINAL COLOUR TO BLUE OR WHITE
uint6 terminalcolour <: { {4{terminal}}, 2b11 };
always {
switch( display_order ) {
case 0: { // BACKGROUND -> LOWER TILEMAP -> UPPER TILEMAP -> LOWER_SPRITES -> BITMAP -> UPPER_SPRITES -> CHARACTER_MAP -> TERMINAL
pix = ( terminal_display ) ? terminalcolour :
( character_map_display ) ? character_map :
( upper_sprites_display ) ? upper_sprites :
( bitmap_display ) ? bitmap :
( lower_sprites_display ) ? lower_sprites :
( upper_tilemap_display ) ? upper_tilemap :
( lower_tilemap_display ) ? lower_tilemap :
background;
}
case 1: { // BACKGROUND -> LOWER TILEMAP -> UPPER TILEMAP -> BITMAP -> LOWER_SPRITES -> UPPER_SPRITES -> CHARACTER_MAP -> TERMINAL
pix = ( terminal_display ) ? terminalcolour :
( character_map_display ) ? character_map :
( upper_sprites_display ) ? upper_sprites :
( lower_sprites_display ) ? lower_sprites :
( bitmap_display ) ? bitmap :
( upper_tilemap_display ) ? upper_tilemap :
( lower_tilemap_display ) ? lower_tilemap :
background;
}
case 2: { // BACKGROUND -> BITMAP -> LOWER TILEMAP -> UPPER TILEMAP -> LOWER_SPRITES -> UPPER_SPRITES -> CHARACTER_MAP -> TERMINAL
pix = ( terminal_display ) ? terminalcolour :
( character_map_display ) ? character_map :
( upper_sprites_display ) ? upper_sprites :
( lower_sprites_display ) ? lower_sprites :
( upper_tilemap_display ) ? upper_tilemap :
( lower_tilemap_display ) ? lower_tilemap :
( bitmap_display ) ? bitmap :
background;
}
case 3: { // BACKGROUND -> LOWER TILEMAP -> UPPER TILEMAP -> LOWER_SPRITES -> UPPER_SPRITES -> BITMAP -> CHARACTER_MAP -> TERMINAL
pix = ( terminal_display ) ? terminalcolour :
( character_map_display ) ? character_map :
( bitmap_display ) ? bitmap :
( upper_sprites_display ) ? upper_sprites :
( lower_sprites_display ) ? lower_sprites :
( upper_tilemap_display ) ? upper_tilemap :
( lower_tilemap_display ) ? lower_tilemap :
background;
}
}
}
}