Set the memory window and return the offset */
| 270 | |
| 271 | /* Set the memory window and return the offset */ |
| 272 | static unsigned long |
| 273 | vesa_SetWindow(int window, unsigned long offset) |
| 274 | { |
| 275 | /* If the desired offset is already within the window, leave the window |
| 276 | as it is and return the address based on the current window position. |
| 277 | This minimizes the use of the window switch function. |
| 278 | |
| 279 | On the first call to the function, vesa_win_pos[window] == 0xFFFFFFFF, |
| 280 | the offset will always be less than this, and the BIOS will always be |
| 281 | called. */ |
| 282 | |
| 283 | unsigned long pos = vesa_win_pos[window]; |
| 284 | if (offset < pos || pos + vesa_win_size <= offset) { |
| 285 | __dpmi_regs regs; |
| 286 | |
| 287 | memset(®s, 0, sizeof(regs)); |
| 288 | regs.x.ax = 0x4F05; |
| 289 | regs.h.bh = 0x00; |
| 290 | regs.h.bl = window; |
| 291 | regs.x.dx = offset / vesa_win_gran; |
| 292 | pos = regs.x.dx * vesa_win_gran; |
| 293 | |
| 294 | if (vesa_win_func != 0) { |
| 295 | regs.x.cs = vesa_win_func >> 16; |
| 296 | regs.x.ip = vesa_win_func & 0xFFFF; |
| 297 | (void) __dpmi_simulate_real_mode_procedure_retf(®s); |
| 298 | } else { |
| 299 | (void) __dpmi_int(VIDEO_BIOS, ®s); |
| 300 | } |
| 301 | vesa_win_pos[window] = pos; |
| 302 | } |
| 303 | |
| 304 | offset = offset - vesa_win_pos[window] + vesa_win_addr[window]; |
| 305 | /* Keep from crashing the system if some malfunction gives us a bad |
| 306 | offset */ |
| 307 | if (offset < 0xA0000 || offset > 0xBFFFF) { |
| 308 | vesa_SwitchMode(MODETEXT); |
| 309 | fprintf(stderr, "Abort: offset=%08lX\n", offset); |
| 310 | exit(1); |
| 311 | } |
| 312 | return offset; |
| 313 | } |
| 314 | |
| 315 | static unsigned long |
| 316 | vesa_ReadPixel32(unsigned x, unsigned y) |
no test coverage detected