- LFB flag now stored in the register VBE_DISPI_INDEX_ENABLE
[vgabios.git] / vbe.c
blobf7c3cd1b22cd9b1c728468dd82a0f871fc865a46
1 // ============================================================================================
2 //
3 // Copyright (C) 2002 Jeroen Janssen
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 //
19 // ============================================================================================
20 //
21 // This VBE is part of the VGA Bios specific to the plex86/bochs Emulated VGA card.
22 // You can NOT drive any physical vga card with it.
24 // ============================================================================================
25 //
26 // This VBE Bios is based on information taken from :
27 // - VESA BIOS EXTENSION (VBE) Core Functions Standard Version 3.0 located at www.vesa.org
29 // ============================================================================================
32 // defines available
33 // enable LFB support (depends upon bochs-vbe-lfb patch)
34 #define VBE_HAVE_LFB
36 // disable VESA/VBE2 check in vbe info
37 //#define VBE2_NO_VESA_CHECK
39 // dynamicly generate a mode_info list
40 //#define DYN_LIST
43 #include "vbe.h"
44 #include "vbetables.h"
47 // The current OEM Software Revision of this VBE Bios
48 #define VBE_OEM_SOFTWARE_REV 0x0002;
50 #define VBEInfoData ((VbeInfoBlock *) 0)
52 extern char vbebios_copyright;
53 extern char vbebios_vendor_name;
54 extern char vbebios_product_name;
55 extern char vbebios_product_revision;
57 // FIXME: find out why we cannot use the dynamic list generation (due to a bug somewhere)
58 //#define DYN_LIST
60 #ifndef DYN_LIST
61 extern Bit16u vbebios_mode_list;
62 #endif
64 ASM_START
65 // FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
66 _vbebios_copyright:
67 .ascii "Bochs/Plex86 VBE(C) 2003 Jeroen Janssen <japj@darius.demon.nl>"
68 .byte 0x00
70 _vbebios_vendor_name:
71 .ascii "Bochs/Plex86 Developers"
72 .byte 0x00
74 _vbebios_product_name:
75 .ascii "Bochs/Plex86 VBE Adapter"
76 .byte 0x00
78 _vbebios_product_revision:
79 .ascii "$Id$"
80 .byte 0x00
82 _vbebios_info_string:
83 .ascii "Bochs VBE Display Adapter enabled"
84 .byte 0x0a,0x0d
85 .byte 0x0a,0x0d
86 .byte 0x00
88 _no_vbebios_info_string:
89 .ascii "NO Bochs VBE Support available!"
90 .byte 0x0a,0x0d
91 .byte 0x0a,0x0d
92 .byte 0x00
95 #ifndef DYN_LIST
96 // FIXME: for each new mode add a statement here
97 // at least until dynamic list creation is working
98 _vbebios_mode_list:
100 .word VBE_VESA_MODE_640X400X8
101 .word VBE_VESA_MODE_640X480X8
102 .word VBE_VESA_MODE_800X600X4
103 .word VBE_VESA_MODE_800X600X8
104 .word VBE_VESA_MODE_1024X768X8
105 .word VBE_VESA_MODE_640X480X1555
106 .word VBE_VESA_MODE_640X480X565
107 .word VBE_VESA_MODE_640X480X888
108 .word VBE_VESA_MODE_800X600X1555
109 .word VBE_VESA_MODE_800X600X565
110 .word VBE_VESA_MODE_800X600X888
111 .word VBE_VESA_MODE_1024X768X1555
112 .word VBE_VESA_MODE_1024X768X565
113 .word VBE_VESA_MODE_1024X768X888
114 .word VBE_OWN_MODE_640X480X8888
115 .word VBE_OWN_MODE_800X600X8888
116 .word VBE_OWN_MODE_1024X768X8888
117 .word VBE_OWN_MODE_320X200X8
118 .word VBE_VESA_MODE_END_OF_LIST
119 #endif
121 ASM_END
123 // from rombios.c
124 #define PANIC_PORT 0x501
126 ASM_START
127 MACRO HALT
128 ;; the HALT macro is called with the line number of the HALT call.
129 ;; The line number is then sent to the PANIC_PORT, causing Bochs to
130 ;; print a BX_PANIC message. This will normally halt the simulation
131 ;; with a message such as "BIOS panic at rombios.c, line 4091".
132 ;; However, users can choose to make panics non-fatal and continue.
133 mov dx,#PANIC_PORT
134 mov ax,#?1
135 out dx,ax
136 MEND
137 ASM_END
139 // DISPI ioport functions
140 // FIXME: what if no VBE host side code?
141 static Bit16u dispi_get_id()
143 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
144 return inw(VBE_DISPI_IOPORT_DATA);
147 static void dispi_set_id(id)
148 Bit16u id;
150 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
151 outw(VBE_DISPI_IOPORT_DATA,id);
154 static void dispi_set_xres(xres)
155 Bit16u xres;
157 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_XRES);
158 outw(VBE_DISPI_IOPORT_DATA,xres);
161 static void dispi_set_yres(yres)
162 Bit16u yres;
164 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_YRES);
165 outw(VBE_DISPI_IOPORT_DATA,yres);
168 static void dispi_set_bpp(bpp)
169 Bit16u bpp;
171 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
172 outw(VBE_DISPI_IOPORT_DATA,bpp);
175 static Bit16u dispi_get_bpp()
177 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
178 return inw(VBE_DISPI_IOPORT_DATA);
181 static Bit16u dispi_get_enable()
183 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
184 return inw(VBE_DISPI_IOPORT_DATA);
187 void dispi_set_enable(enable)
188 Bit16u enable;
190 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
191 outw(VBE_DISPI_IOPORT_DATA,enable);
194 static void dispi_set_bank(bank)
195 Bit16u bank;
197 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
198 outw(VBE_DISPI_IOPORT_DATA,bank);
201 static Bit16u dispi_get_bank()
203 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
204 return inw(VBE_DISPI_IOPORT_DATA);
207 static void dispi_set_bank_farcall()
209 ASM_START
210 cmp bx,#0x0100
211 je dispi_set_bank_farcall_get
212 or bx,bx
213 jnz dispi_set_bank_farcall_error
214 push dx
215 mov ax,# VBE_DISPI_INDEX_BANK
216 mov dx,# VBE_DISPI_IOPORT_INDEX
217 out dx,ax
218 pop ax
219 mov dx,# VBE_DISPI_IOPORT_DATA
220 out dx,ax
221 retf
222 dispi_set_bank_farcall_get:
223 mov ax,# VBE_DISPI_INDEX_BANK
224 mov dx,# VBE_DISPI_IOPORT_INDEX
225 out dx,ax
226 mov dx,# VBE_DISPI_IOPORT_DATA
227 in ax,dx
228 mov dx,ax
229 retf
230 dispi_set_bank_farcall_error:
231 mov ax,#0x014F
232 retf
233 ASM_END
236 static void dispi_set_x_offset(offset)
237 Bit16u offset;
239 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
240 outw(VBE_DISPI_IOPORT_DATA,offset);
243 static Bit16u dispi_get_x_offset()
245 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
246 return inw(VBE_DISPI_IOPORT_DATA);
249 static void dispi_set_y_offset(offset)
250 Bit16u offset;
252 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
253 outw(VBE_DISPI_IOPORT_DATA,offset);
256 static Bit16u dispi_get_y_offset()
258 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
259 return inw(VBE_DISPI_IOPORT_DATA);
262 static void dispi_set_virt_width(width)
263 Bit16u width;
265 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
266 outw(VBE_DISPI_IOPORT_DATA,width);
269 static Bit16u dispi_get_virt_width()
271 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
272 return inw(VBE_DISPI_IOPORT_DATA);
275 static void dispi_set_virt_height(height)
276 Bit16u height;
278 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
279 outw(VBE_DISPI_IOPORT_DATA,height);
282 static Bit16u dispi_get_virt_height()
284 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
285 return inw(VBE_DISPI_IOPORT_DATA);
289 // ModeInfo helper function
290 static ModeInfoListItem* mode_info_find_mode(mode, using_lfb)
291 Bit16u mode; Boolean using_lfb;
293 ModeInfoListItem *cur_info=&mode_info_list;
295 while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST)
297 if (cur_info->mode == mode)
299 if (!using_lfb)
301 return cur_info;
303 else if (cur_info->info.ModeAttributes & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
305 return cur_info;
307 else
309 cur_info++;
312 else
314 cur_info++;
318 return 0;
321 /** Has VBE display - Returns true if VBE display detected
324 Boolean vbe_has_vbe_display()
326 dispi_set_id(VBE_DISPI_ID2);
328 return (dispi_get_id()==VBE_DISPI_ID2);
331 /** VBE Init - Initialise the Vesa Bios Extension Code
333 * This function does a sanity check on the host side display code interface.
335 void vbe_init()
337 Bit16u dispi_id;
339 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
340 outw(VBE_DISPI_IOPORT_DATA,VBE_DISPI_ID0);
342 dispi_id=inw(VBE_DISPI_IOPORT_DATA);
344 if (dispi_id!=VBE_DISPI_ID0)
346 //FIXME this results in a 'rombios.c' line panic, but it's actually a 'vbe.c' panic
347 ASM_START
348 HALT(__LINE__)
349 ASM_END
351 //#ifdef DEBUG
352 printf("VBE Bios $Id$\n");
353 //#endif
356 /** VBE Display Info - Display information on screen about the VBE
358 void vbe_display_info()
360 // Check for VBE display extension in Bochs
361 if (vbe_has_vbe_display())
363 ASM_START
364 mov ax,#0xc000
365 mov ds,ax
366 mov si,#_vbebios_info_string
367 call _display_string
368 ASM_END
370 else
372 ASM_START
373 mov ax,#0xc000
374 mov ds,ax
375 mov si,#_no_vbebios_info_string
376 call _display_string
377 ASM_END
382 /** Function 00h - Return VBE Controller Information
384 * Input:
385 * AX = 4F00h
386 * ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
387 * (VbeSignature should be VBE2 when VBE 2.0 information is desired and
388 * the info block is 512 bytes in size)
389 * Output:
390 * AX = VBE Return Status
393 void vbe_biosfn_return_controller_information(AX, ES, DI)
394 Bit16u *AX;Bit16u ES;Bit16u DI;
396 Bit16u ss=get_SS();
397 VbeInfoBlock vbe_info_block;
398 Bit16u status;
399 Bit16u result;
400 Bit16u vbe2_info;
401 #ifdef DYN_LIST
402 Bit16u *video_mode_list;
403 #endif
404 Bit16u cur_mode=0;
405 ModeInfoListItem *cur_info=&mode_info_list;
407 status = read_word(ss, AX);
409 #ifdef DEBUG
410 printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES,DI,status);
411 #endif
413 vbe2_info = 0;
414 #ifdef VBE2_NO_VESA_CHECK
415 #else
416 // get vbe_info_block into local variable
417 memcpyb(ss, &vbe_info_block, ES, DI, sizeof(vbe_info_block));
419 // check for VBE2 signature
420 if (((vbe_info_block.VbeSignature[0] == 'V') &&
421 (vbe_info_block.VbeSignature[1] == 'B') &&
422 (vbe_info_block.VbeSignature[2] == 'E') &&
423 (vbe_info_block.VbeSignature[3] == '2')) ||
425 ((vbe_info_block.VbeSignature[0] == 'V') &&
426 (vbe_info_block.VbeSignature[1] == 'E') &&
427 (vbe_info_block.VbeSignature[2] == 'S') &&
428 (vbe_info_block.VbeSignature[3] == 'A')) )
430 vbe2_info = 1;
431 #ifdef DEBUG
432 printf("VBE correct VESA/VBE2 signature found\n");
433 #endif
435 #endif
437 // VBE Signature
438 vbe_info_block.VbeSignature[0] = 'V';
439 vbe_info_block.VbeSignature[1] = 'E';
440 vbe_info_block.VbeSignature[2] = 'S';
441 vbe_info_block.VbeSignature[3] = 'A';
443 // VBE Version supported
444 vbe_info_block.VbeVersion = 0x0200;
446 // OEM String
447 vbe_info_block.OemStringPtr_Seg = 0xc000;
448 vbe_info_block.OemStringPtr_Off = &vbebios_copyright;
450 // Capabilities
451 vbe_info_block.Capabilities[0] = 0;
452 vbe_info_block.Capabilities[1] = 0;
453 vbe_info_block.Capabilities[2] = 0;
454 vbe_info_block.Capabilities[3] = 0;
456 #ifdef DYN_LIST
457 // FIXME: This doesn't work correctly somehow?
458 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list)
459 vbe_info_block.VideoModePtr_Seg= ES ;//0xc000;
460 vbe_info_block.VideoModePtr_Off= DI + 34;//&(VBEInfoData->Reserved);//&vbebios_mode_list;
461 #else
462 // VBE Video Mode Pointer (staticly in rom)
463 vbe_info_block.VideoModePtr_Seg = 0xc000;
464 vbe_info_block.VideoModePtr_Off = &vbebios_mode_list;
466 #endif
468 #ifdef DYN_LIST
470 // video_mode_list=(Bit16u*)&(vbe_info_block.Reserved);
474 #ifdef DEBUG
475 printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
476 #endif
477 // *video_mode_list=cur_info->mode;
478 vbe_info_block.Reserved[cur_mode] = cur_info->mode;
480 cur_info++;
481 //video_mode_list++;
482 cur_mode++;
483 } while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST);
485 // Add vesa mode list terminator
486 vbe_info_block.Reserved[cur_mode] = VBE_VESA_MODE_END_OF_LIST;
487 #endif
489 // VBE Total Memory (in 64b blocks)
490 vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
492 if (vbe2_info)
494 // OEM Stuff
495 vbe_info_block.OemSoftwareRev = VBE_OEM_SOFTWARE_REV;
496 vbe_info_block.OemVendorNamePtr_Seg = 0xc000;
497 vbe_info_block.OemVendorNamePtr_Off = &vbebios_vendor_name;
498 vbe_info_block.OemProductNamePtr_Seg = 0xc000;
499 vbe_info_block.OemProductNamePtr_Off = &vbebios_product_name;
500 vbe_info_block.OemProductRevPtr_Seg = 0xc000;
501 vbe_info_block.OemProductRevPtr_Off = &vbebios_product_revision;
503 // copy updates in vbe_info_block back
504 memcpyb(ES, DI, ss, &vbe_info_block, sizeof(vbe_info_block));
506 else
508 // copy updates in vbe_info_block back (VBE 1.x compatibility)
509 memcpyb(ES, DI, ss, &vbe_info_block, 256);
512 result = 0x4f;
514 write_word(ss, AX, result);
518 /** Function 01h - Return VBE Mode Information
520 * Input:
521 * AX = 4F01h
522 * CX = Mode Number
523 * ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
524 * Output:
525 * AX = VBE Return Status
528 void vbe_biosfn_return_mode_information(AX, CX, ES, DI)
529 Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
531 Bit16u result=0x0100;
532 Bit16u ss=get_SS();
533 ModeInfoBlock info;
534 ModeInfoListItem *cur_info;
535 Boolean using_lfb;
537 #ifdef DEBUG
538 printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
539 #endif
541 using_lfb=((CX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
543 CX = (CX & 0x1ff);
545 cur_info = mode_info_find_mode(CX, using_lfb, &cur_info);
547 if (cur_info != 0)
549 #ifdef DEBUG
550 printf("VBE found mode %x\n",CX);
551 #endif
552 memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
553 memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
554 if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) {
555 info.WinFuncPtr = 0xC0000000UL;
556 *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
559 result = 0x4f;
561 else
563 #ifdef DEBUG
564 printf("VBE *NOT* found mode %x\n",CX);
565 #endif
566 result = 0x100;
569 if (result == 0x4f)
571 // copy updates in mode_info_block back
572 memcpyb(ES, DI, ss, &info, sizeof(info));
575 write_word(ss, AX, result);
578 /** Function 02h - Set VBE Mode
580 * Input:
581 * AX = 4F02h
582 * BX = Desired Mode to set
583 * ES:DI = Pointer to CRTCInfoBlock structure
584 * Output:
585 * AX = VBE Return Status
588 void vbe_biosfn_set_mode(AX, BX, ES, DI)
589 Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u DI;
591 Bit16u ss = get_SS();
592 Bit16u result;
593 ModeInfoListItem *cur_info;
594 Boolean using_lfb;
595 Bit8u no_clear;
596 Bit8u lfb_flag;
598 using_lfb=((BX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
599 lfb_flag=using_lfb?VBE_DISPI_LFB_ENABLED:0;
600 no_clear=((BX & VBE_MODE_PRESERVE_DISPLAY_MEMORY) == VBE_MODE_PRESERVE_DISPLAY_MEMORY)?VBE_DISPI_NOCLEARMEM:0;
602 BX = (BX & 0x1ff);
604 //result=read_word(ss,AX);
606 // check for non vesa mode
607 if (BX<VBE_MODE_VESA_DEFINED)
609 Bit8u mode;
611 dispi_set_enable(VBE_DISPI_DISABLED);
612 // call the vgabios in order to set the video mode
613 // this allows for going back to textmode with a VBE call (some applications expect that to work)
615 mode=(BX & 0xff);
616 biosfn_set_video_mode(mode);
617 result = 0x4f;
620 cur_info = mode_info_find_mode(BX, using_lfb, &cur_info);
622 if (cur_info != 0)
624 #ifdef DEBUG
625 printf("VBE found mode %x, setting:\n", BX);
626 printf("\txres%x yres%x bpp%x\n",
627 cur_info->info.XResolution,
628 cur_info->info.YResolution,
629 cur_info->info.BitsPerPixel);
630 #endif
632 // first disable current mode (when switching between vesa modi)
633 dispi_set_enable(VBE_DISPI_DISABLED);
635 if (cur_info->mode == VBE_VESA_MODE_800X600X4)
637 biosfn_set_video_mode(0x6a);
640 dispi_set_xres(cur_info->info.XResolution);
641 dispi_set_yres(cur_info->info.YResolution);
642 dispi_set_bpp(cur_info->info.BitsPerPixel);
643 dispi_set_bank(0);
644 dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag);
646 // FIXME: store current mode in BIOS data area
648 result = 0x4f;
650 else
652 #ifdef DEBUG
653 printf("VBE *NOT* found mode %x\n" , BX);
654 #endif
655 result = 0x100;
657 // FIXME: redirect non VBE modi to normal VGA bios operation
658 // (switch back to VGA mode
659 if (BX == 3)
660 result = 0x4f;
663 write_word(ss, AX, result);
666 /** Function 03h - Return Current VBE Mode
668 * Input:
669 * AX = 4F03h
670 * Output:
671 * AX = VBE Return Status
672 * BX = Current VBE Mode
675 void vbe_biosfn_return_current_mode(AX, BX)
676 Bit16u *AX;Bit16u *BX;
678 Bit16u ss=get_SS();
679 Bit16u mode=0xffff;
681 #ifdef DEBUG
682 printf("VBE vbe_biosfn_return_current_mode\n");
683 #endif
685 if(dispi_get_enable())
687 // FIXME: get current mode from BIOS data area
689 else
691 mode=read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE);
693 write_word(ss, AX, 0x4f);
694 write_word(ss, BX, mode);
698 /** Function 04h - Save/Restore State
700 * Input:
701 * AX = 4F04h
702 * DL = 00h Return Save/Restore State buffer size
703 * 01h Save State
704 * 02h Restore State
705 * CX = Requested states
706 * ES:BX = Pointer to buffer (if DL <> 00h)
707 * Output:
708 * AX = VBE Return Status
709 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
712 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX)
717 /** Function 05h - Display Window Control
719 * Input:
720 * AX = 4F05h
721 * (16-bit) BH = 00h Set memory window
722 * = 01h Get memory window
723 * BL = Window number
724 * = 00h Window A
725 * = 01h Window B
726 * DX = Window number in video memory in window
727 * granularity units (Set Memory Window only)
728 * Note:
729 * If this function is called while in a linear frame buffer mode,
730 * this function must fail with completion code AH=03h
732 * Output:
733 * AX = VBE Return Status
734 * DX = Window number in window granularity units
735 * (Get Memory Window only)
737 void vbe_biosfn_display_window_control(AX,BX,DX)
738 Bit16u *AX;Bit16u BX;Bit16u *DX;
740 Bit16u ss = get_SS();
741 Bit16u window = read_word(ss, DX);
742 Bit16u result = 0x014f;
744 if (BX==0x0000)
746 dispi_set_bank(window);
747 result = 0x4f;
749 else if (BX==0x0100)
751 window = dispi_get_bank();
752 write_word(ss, DX, result);
753 result = 0x4f;
755 write_word(ss, AX, result);
759 /** Function 06h - Set/Get Logical Scan Line Length
761 * Input:
762 * AX = 4F06h
763 * BL = 00h Set Scan Line Length in Pixels
764 * = 01h Get Scan Line Length
765 * = 02h Set Scan Line Length in Bytes
766 * = 03h Get Maximum Scan Line Length
767 * CX = If BL=00h Desired Width in Pixels
768 * If BL=02h Desired Width in Bytes
769 * (Ignored for Get Functions)
771 * Output:
772 * AX = VBE Return Status
773 * BX = Bytes Per Scan Line
774 * CX = Actual Pixels Per Scan Line
775 * (truncated to nearest complete pixel)
776 * DX = Maximum Number of Scan Lines
778 void vbe_biosfn_set_get_logical_scan_line_length(AX,BX,CX,DX)
779 Bit16u *AX;Bit16u *BX;Bit16u *DX;Bit16u *DX;
781 Bit16u ss=get_SS();
782 Bit16u result=0x100;
783 Bit16u width = read_word(ss, CX);
784 Bit16u cmd = read_word(ss, BX);
785 Bit8u bytespp = dispi_get_bpp()/8;
787 // check bl
788 if ( ((cmd & 0xff) == 0x00) || ((cmd & 0xff) == 0x02) )
790 // set scan line lenght in pixels(0x00) or bytes (0x02)
791 Bit16u new_width;
792 Bit16u new_height;
794 if ( ((cmd & 0xff) == 0x02) && (bytespp > 1) )
796 width/=bytespp;
798 dispi_set_virt_width(width);
799 new_width=dispi_get_virt_width();
800 new_height=dispi_get_virt_height();
802 if (new_width!=width)
804 #ifdef DEBUG
805 printf("* VBE width adjusted\n");
806 #endif
808 // notify width adjusted
809 result=0x024f;
811 else
813 result=0x4f;
816 write_word(ss,BX,new_width*bytespp);
817 write_word(ss,CX,new_width);
818 write_word(ss,DX,new_height);
821 write_word(ss, AX, result);
825 /** Function 07h - Set/Get Display Start
827 * Input(16-bit):
828 * AX = 4F07h
829 * BH = 00h Reserved and must be 00h
830 * BL = 00h Set Display Start
831 * = 01h Get Display Start
832 * = 02h Schedule Display Start (Alternate)
833 * = 03h Schedule Stereoscopic Display Start
834 * = 04h Get Scheduled Display Start Status
835 * = 05h Enable Stereoscopic Mode
836 * = 06h Disable Stereoscopic Mode
837 * = 80h Set Display Start during Vertical Retrace
838 * = 82h Set Display Start during Vertical Retrace (Alternate)
839 * = 83h Set Stereoscopic Display Start during Vertical Retrace
840 * ECX = If BL=02h/82h Display Start Address in bytes
841 * If BL=03h/83h Left Image Start Address in bytes
842 * EDX = If BL=03h/83h Right Image Start Address in bytes
843 * CX = If BL=00h/80h First Displayed Pixel In Scan Line
844 * DX = If BL=00h/80h First Displayed Scan Line
846 * Output:
847 * AX = VBE Return Status
848 * BH = If BL=01h Reserved and will be 0
849 * CX = If BL=01h First Displayed Pixel In Scan Line
850 * If BL=04h 0 if flip has not occurred, not 0 if it has
851 * DX = If BL=01h First Displayed Scan Line
853 * Input(32-bit):
854 * BH = 00h Reserved and must be 00h
855 * BL = 00h Set Display Start
856 * = 80h Set Display Start during Vertical Retrace
857 * CX = Bits 0-15 of display start address
858 * DX = Bits 16-31 of display start address
859 * ES = Selector for memory mapped registers
861 void vbe_biosfn_set_get_display_start(AX,BX,CX,DX)
862 Bit16u *AX;Bit16u BX;Bit16u CX;Bit16u DX;
864 Bit16u ss=get_SS();
865 Bit16u result=0x100;
866 #ifdef DEBUG
867 // printf("VBE vbe_biosfn_set_get_display_start\n");
868 #endif
870 // check for set display start
871 if ((GET_BL()==0x00) || (GET_BL()==0x80))
873 // 0x80 is during vertical retrace - is also used by sdd vbetest during multibuffering
874 #ifdef DEBUG
875 // printf("VBE vbe_biosfn_set_get_display_start CX%x DX%x\n",CX,DX);
876 #endif
878 dispi_set_x_offset(CX);
879 dispi_set_y_offset(DX);
880 result = 0x4f;
883 write_word(ss, AX, result);
887 /** Function 08h - Set/Get Dac Palette Format
889 * Input:
890 * AX = 4F08h
891 * Output:
892 * AX = VBE Return Status
894 * FIXME: incomplete API description, Input & Output
896 void vbe_biosfn_set_get_dac_palette_format(AX)
901 /** Function 09h - Set/Get Palette Data
903 * Input:
904 * AX = 4F09h
905 * Output:
906 * AX = VBE Return Status
908 * FIXME: incomplete API description, Input & Output
910 void vbe_biosfn_set_get_palette_data(AX)
914 /** Function 0Ah - Return VBE Protected Mode Interface
916 * Input:
917 * AX = 4F0Ah
918 * Output:
919 * AX = VBE Return Status
921 * FIXME: incomplete API description, Input & Output
923 void vbe_biosfn_return_protected_mode_interface(AX)