…Show last 199 lines
61 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0101 - scroller
62 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0110 - scroller
63 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0111 - scroller
64
65 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1000 - logo
66 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1001 - logo
67
68 // Logo before scroller
69 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1010 - logo
70 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1011 - logo
71 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1100 - logo (before scroller)
72 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1101 - logo (before scroller)
73 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1110 - logo (before scroller)
74 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1111 - logo (before scroller)
75};
76
77RGB palette2[16] = {
78 {0x00 >> 2, 0x00 >> 2, 0x00 >> 2}, // 0000 -
79 {0xff >> 2, 0x00 >> 2, 0x00 >> 2}, // 0001 - background
80
81 {0x00 >> 2, 0xff >> 2, 0x00 >> 2}, // 0010 - banner
82 {0x00 >> 2, 0xff >> 2, 0x00 >> 2}, // 0011 - banner
83
84 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0100 - scroller
85 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0101 - scroller
86 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0110 - scroller
87 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 0111 - scroller
88
89 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1000 - logo
90 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1001 - logo
91
92 // Logo behind scroller
93 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1010 - logo
94 {0xff >> 2, 0xff >> 2, 0xff >> 2}, // 1011 - logo
95 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 1100 - logo (behind scroller)
96 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 1101 - logo (behind scroller)
97 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 1110 - logo (behind scroller)
98 {0x00 >> 2, 0x00 >> 2, 0xff >> 2}, // 1111 - logo (behind scroller)
99};
100
101unsigned char far *_video_mem = (unsigned char far*)0xA0000000L;
102
103void set_mode(unsigned short mode)
104{
105 _asm {
106 mov ax,mode
107 int 0x10
108 }
109}
110
111void load_palette(RGB *palette, int colors)
112{
113 unsigned short pal_seg = FP_SEG(palette);
114 unsigned short pal_off = FP_OFF(palette);
115 unsigned short len = colors * 3;
116
117 _asm {
118 xor bl,bl
119 pal_loop:
120 mov dx,VGA_INPUT_STATUS
121 in al,dx
122
123 mov dx,VGA_ATTRIBUTE_INDEX
124 mov al,bl
125 out dx,al
126 out dx,al
127
128 inc bl
129 cmp bl,10h
130 jb pal_loop
131
132 mov dx,VGA_ATTRIBUTE_INDEX
133 mov al,20h
134 out dx,al
135
136 // Select color zero and write the palette data.
137
138 mov dx,VGA_PALETTE_INDEX
139 xor al,al
140 out dx,al
141
142 mov ax,pal_seg
143 mov ds,ax
144 mov si,pal_off
145 mov cx,len
146
147 inc dx
148 rep outsb
149 }
150}
151
152void select_plane(unsigned short plane)
153{
154 outpw(VGA_SEQUENCER_INDEX, (plane << 8) + VGA_MAP_MASK);
155}
156
157void draw_rect(int x, int y, int width, int height, unsigned char pattern)
158{
159 int i;
160 int w = width >> 3;
161
162 char *video = _video_mem + (y * (SCREEN_WIDTH / 8)) + (x >> 3);
163
164 for (i = y; i < y + height; i++) {
165 memset(video, pattern, w);
166
167 video += SCREEN_WIDTH / 8;
168 }
169}
170
171void draw_background()
172{
173 int r, x, y;
174 unsigned char color;
175
176 select_plane(PLANE_0);
177
178 for (r = 0; r < SCREEN_HEIGHT / TILE_SIZE; r++) {
179 color = r % 2;
180
181 for (y = 0; y < TILE_SIZE; y++) {
182 for (x = 0; x < SCREEN_WIDTH / 8; x += 2) {
183 if (color) {
184 int o = (r * TILE_SIZE + y) * (SCREEN_WIDTH / 8) + x;
185
186 _video_mem[o + 0] = 0xff;
187 _video_mem[o + 1] = 0xff;
188 }
189
190 color ^= 1;
191 }
192 }
193 }
194}
195
196void draw_banner()
197{
198 select_plane(PLANE_1);
199
200 draw_rect( 8, 0, 32, SCREEN_HEIGHT, 0xff);
201 draw_rect(SCREEN_WIDTH - 40, 0, 32, SCREEN_HEIGHT, 0xff);
202}
203
204void draw_scroller()
205{
206 select_plane(PLANE_2);
207
208 draw_rect(0, 64, SCREEN_WIDTH, 24, 0xff);
209 draw_rect(0, 112, SCREEN_WIDTH, 24, 0xff);
210}
211
212void draw_logo()
213{
214 select_plane(PLANE_3);
215
216 draw_rect(96, 48, 128, 104, 0xff);
217
218}
219
220void main()
221{
222 int pal = 0;
223
224 set_mode(0x0d);
225
226 load_palette(&palette1, sizeof(palette1) / sizeof(RGB));
227
228 draw_background();
229 draw_banner();
230 draw_scroller();
231 draw_logo();
232
233 while(1) {
234 if (kbhit()) {
235 int key = getch();
236
237 if (key == 27) {
238 break;
239 }
240
241 switch (key) {
242 case KEY_SPACE:
243 pal ^= 1;
244
245 if (pal == 0) {
246 load_palette(&palette1, sizeof(palette1) / sizeof(RGB));
247 }
248 else {
249 load_palette(&palette2, sizeof(palette2) / sizeof(RGB));
250 }
251
252 break;
253 }
254 }
255 }
256
257 set_mode(0x03);
258}