Revision 122
xpm pingus
lab5.c | ||
---|---|---|
185 | 185 |
return 1; |
186 | 186 |
}; |
187 | 187 |
|
188 |
|
|
189 |
|
|
190 |
|
|
191 | 188 |
uint16_t W = get_XRes()/no_rectangles; |
192 | 189 |
uint16_t H = get_YRes()/no_rectangles; |
193 | 190 |
|
... | ... | |
272 | 269 |
} |
273 | 270 |
|
274 | 271 |
int(video_test_xpm)(xpm_map_t xpm, uint16_t x, uint16_t y) { |
275 |
/* To be completed */ |
|
276 |
printf("%s(%8p, %u, %u): under construction\n", __func__, xpm, x, y); |
|
272 |
int r; |
|
273 |
if ((r = get_permissions_first_mbyte())) |
|
274 |
panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
277 | 275 |
|
278 |
return 1; |
|
276 |
if (vbe_get_mode_information(INDEXED_1024_768)) { |
|
277 |
printf("%s: failed to get information for mode %x.\n", __func__, INDEXED_1024_768); |
|
278 |
if (vg_exit()) |
|
279 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
280 |
return 1; |
|
281 |
} |
|
282 |
|
|
283 |
map_vram(); // if function fails it aborts program |
|
284 |
|
|
285 |
if (set_graphics_mode(INDEXED_1024_768)) { |
|
286 |
printf("%s: failed to set graphic mode %x.\n", __func__, INDEXED_1024_768); |
|
287 |
if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
288 |
return 1; |
|
289 |
}; |
|
290 |
|
|
291 |
enum xpm_image_type type = XPM_INDEXED; |
|
292 |
xpm_image_t img; |
|
293 |
|
|
294 |
uint8_t *map = xpm_load(xpm, type, &img); |
|
295 |
|
|
296 |
for (int i = 0; i < img.width; i++) { |
|
297 |
for (int j = 0; j < img.height; j++) { |
|
298 |
set_pixel(x + i, y + j, map[i + j * img.width]); |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
/// loop stuff |
|
303 |
int ipc_status; |
|
304 |
message msg; |
|
305 |
/// Keyboard interrupt handling |
|
306 |
uint8_t kbc_irq_bit = KBC_IRQ; |
|
307 |
int kbc_id = 0; |
|
308 |
int kbc_irq = BIT(kbc_irq_bit); |
|
309 |
if (subscribe_kbc_interrupt(kbc_irq_bit, &kbc_id)) { |
|
310 |
if (vg_exit()) { |
|
311 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
312 |
if (free_memory()) printf("%s: lm_free failed\n", __func__); |
|
313 |
} |
|
314 |
return 1; |
|
315 |
} |
|
316 |
/// cycle |
|
317 |
int good = 1; |
|
318 |
while (good) { |
|
319 |
/* Get a request message. */ |
|
320 |
if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { |
|
321 |
printf("driver_receive failed with %d", r); |
|
322 |
continue; |
|
323 |
} |
|
324 |
if (is_ipc_notify(ipc_status)) { /* received notification */ |
|
325 |
switch (_ENDPOINT_P(msg.m_source)) { |
|
326 |
case HARDWARE: /* hardware interrupt notification */ |
|
327 |
if (msg.m_notify.interrupts & kbc_irq) { /* subscribed interrupt */ |
|
328 |
kbc_ih(); |
|
329 |
if (scancode[0] == ESC_BREAK_CODE) good = 0; |
|
330 |
} |
|
331 |
break; |
|
332 |
default: |
|
333 |
break; /* no other notifications expected: do nothing */ |
|
334 |
} |
|
335 |
} else { /* received standart message, not a notification */ |
|
336 |
/* no standart message expected: do nothing */ |
|
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
if (unsubscribe_interrupt(&kbc_id)) { |
|
341 |
if (vg_exit()) { |
|
342 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
343 |
if (free_memory()) printf("%s: lm_free failed\n", __func__); |
|
344 |
} |
|
345 |
return 1; |
|
346 |
}; |
|
347 |
|
|
348 |
if (vg_exit()) { |
|
349 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
350 |
if (free_memory()) printf("%s: lm_free failed\n", __func__); |
|
351 |
return 1; |
|
352 |
} |
|
353 |
|
|
354 |
if (free_memory()) { |
|
355 |
printf("%s: lm_free failed\n", __func__); |
|
356 |
return 1; |
|
357 |
} |
|
358 |
|
|
359 |
return 0; |
|
279 | 360 |
} |
280 | 361 |
|
281 | 362 |
int(video_test_move)(xpm_map_t xpm, uint16_t xi, uint16_t yi, uint16_t xf, uint16_t yf, int16_t speed, uint8_t fr_rate) { |
... | ... | |
284 | 365 |
} |
285 | 366 |
|
286 | 367 |
int(video_test_controller)() { |
287 |
/* To be completed */ |
|
288 |
printf("%s(): under construction\n", __func__); |
|
289 | 368 |
|
369 |
|
|
370 |
|
|
290 | 371 |
return 1; |
291 | 372 |
} |
Also available in: Unified diff