- function write_gfx_char() rewritten
[vgabios.git] / vbe.c
blob4ba5ebf74bbd1abcf901afb7b07a35b0bcf8a29b
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
42 // enable unsupported modi in the mode_info list (ie >8bpp)
43 //#define LIST_UNSUPPORTED_MODI
46 #include "vbe.h"
47 #include "vbetables.h"
50 // The current OEM Software Revision of this VBE Bios
51 #define VBE_OEM_SOFTWARE_REV 0x0002;
53 #define VBEInfoData ((VbeInfoBlock *) 0)
55 extern char vbebios_copyright;
56 extern char vbebios_vendor_name;
57 extern char vbebios_product_name;
58 extern char vbebios_product_revision;
60 // FIXME: find out why we cannot use the dynamic list generation (due to a bug somewhere)
61 //#define DYN_LIST
63 #ifndef DYN_LIST
64 extern Bit16u vbebios_mode_list;
65 #endif
67 ASM_START
68 // FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
69 _vbebios_copyright:
70 .ascii "Bochs/Plex86 VBE(C) 2002 Jeroen Janssen <japj@darius.demon.nl>"
71 .byte 0x00
73 _vbebios_vendor_name:
74 .ascii "Bochs/Plex86 Developers"
75 .byte 0x00
77 _vbebios_product_name:
78 .ascii "Bochs/Plex86 VBE Adapter"
79 .byte 0x00
81 _vbebios_product_revision:
82 .ascii "$Id$"
83 .byte 0x00
85 _vbebios_info_string:
86 .ascii "Bochs VBE Display Adapter enabled"
87 .byte 0x0a,0x0d
88 .byte 0x0a,0x0d
89 .byte 0x00
91 _no_vbebios_info_string:
92 .ascii "NO Bochs VBE Support available!"
93 .byte 0x0a,0x0d
94 .byte 0x0a,0x0d
95 .byte 0x00
98 #ifndef DYN_LIST
99 // FIXME: for each new mode add a statement here
100 // at least until dynamic list creation is working
101 _vbebios_mode_list:
103 #ifdef LIST_UNSUPPORTED_MODI
104 .word VBE_VESA_MODE_640X480X565
105 .word VBE_VESA_MODE_800X600X565
106 .word VBE_VESA_MODE_640X480X888
107 .word VBE_VESA_MODE_800X600X888
108 .word VBE_OWN_MODE_800X600X8888
109 .word VBE_OWN_MODE_1024X768X8888
110 #endif
112 .word VBE_VESA_MODE_640X400X8
113 .word VBE_VESA_MODE_640X480X8
114 .word VBE_VESA_MODE_800X600X4
115 .word VBE_VESA_MODE_800X600X8
116 .word VBE_VESA_MODE_1024X768X8
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_enable()
177 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
178 return inw(VBE_DISPI_IOPORT_DATA);
181 void dispi_set_enable(enable)
182 Bit16u enable;
184 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
185 outw(VBE_DISPI_IOPORT_DATA,enable);
188 static void dispi_set_bank(bank)
189 Bit16u bank;
191 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
192 outw(VBE_DISPI_IOPORT_DATA,bank);
195 static Bit16u dispi_get_bank()
197 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
198 return inw(VBE_DISPI_IOPORT_DATA);
201 static void dispi_set_bank_farcall()
203 ASM_START
204 cmp bx,#0x0100
205 je dispi_set_bank_farcall_get
206 or bx,bx
207 jnz dispi_set_bank_farcall_error
208 push dx
209 mov ax,# VBE_DISPI_INDEX_BANK
210 mov dx,# VBE_DISPI_IOPORT_INDEX
211 out dx,ax
212 pop ax
213 mov dx,# VBE_DISPI_IOPORT_DATA
214 out dx,ax
215 retf
216 dispi_set_bank_farcall_get:
217 mov ax,# VBE_DISPI_INDEX_BANK
218 mov dx,# VBE_DISPI_IOPORT_INDEX
219 out dx,ax
220 mov dx,# VBE_DISPI_IOPORT_DATA
221 in ax,dx
222 mov dx,ax
223 retf
224 dispi_set_bank_farcall_error:
225 mov ax,#0x014F
226 retf
227 ASM_END
230 static void dispi_set_x_offset(offset)
231 Bit16u offset;
233 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
234 outw(VBE_DISPI_IOPORT_DATA,offset);
237 static Bit16u dispi_get_x_offset()
239 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
240 return inw(VBE_DISPI_IOPORT_DATA);
243 static void dispi_set_y_offset(offset)
244 Bit16u offset;
246 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
247 outw(VBE_DISPI_IOPORT_DATA,offset);
250 static Bit16u dispi_get_y_offset()
252 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
253 return inw(VBE_DISPI_IOPORT_DATA);
256 static void dispi_set_virt_width(width)
257 Bit16u width;
259 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
260 outw(VBE_DISPI_IOPORT_DATA,width);
263 static Bit16u dispi_get_virt_width()
265 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
266 return inw(VBE_DISPI_IOPORT_DATA);
269 static void dispi_set_virt_height(height)
270 Bit16u height;
272 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
273 outw(VBE_DISPI_IOPORT_DATA,height);
276 static Bit16u dispi_get_virt_height()
278 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
279 return inw(VBE_DISPI_IOPORT_DATA);
283 // ModeInfo helper function
284 static ModeInfoListItem* mode_info_find_mode(mode, using_lfb)
285 Bit16u mode; Boolean using_lfb;
287 ModeInfoListItem *cur_info=&mode_info_list;
289 while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST)
291 if (cur_info->mode == mode)
293 if (!using_lfb)
295 return cur_info;
297 else if (cur_info->info.ModeAttributes & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
299 return cur_info;
301 else
303 cur_info++;
306 else
308 cur_info++;
312 return 0;
315 /** Has VBE display - Returns true if VBE display detected
318 Boolean vbe_has_vbe_display()
320 dispi_set_id(VBE_DISPI_ID1);
322 return (dispi_get_id()==VBE_DISPI_ID1);
325 /** VBE Init - Initialise the Vesa Bios Extension Code
327 * This function does a sanity check on the host side display code interface.
329 void vbe_init()
331 Bit16u dispi_id;
333 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
334 outw(VBE_DISPI_IOPORT_DATA,VBE_DISPI_ID0);
336 dispi_id=inw(VBE_DISPI_IOPORT_DATA);
338 if (dispi_id!=VBE_DISPI_ID0)
340 //FIXME this results in a 'rombios.c' line panic, but it's actually a 'vbe.c' panic
341 ASM_START
342 HALT(__LINE__)
343 ASM_END
345 //#ifdef DEBUG
346 printf("VBE Bios $Id$\n");
347 //#endif
350 /** VBE Display Info - Display information on screen about the VBE
352 void vbe_display_info()
354 // Check for VBE display extension in Bochs
355 if (vbe_has_vbe_display())
357 ASM_START
358 mov ax,#0xc000
359 mov ds,ax
360 mov si,#_vbebios_info_string
361 call _display_string
362 ASM_END
364 else
366 ASM_START
367 mov ax,#0xc000
368 mov ds,ax
369 mov si,#_no_vbebios_info_string
370 call _display_string
371 ASM_END
376 /** Function 00h - Return VBE Controller Information
378 * Input:
379 * AX = 4F00h
380 * ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
381 * (VbeSignature should be VBE2 when VBE 2.0 information is desired and
382 * the info block is 512 bytes in size)
383 * Output:
384 * AX = VBE Return Status
387 void vbe_biosfn_return_controller_information(AX, ES, DI)
388 Bit16u *AX;Bit16u ES;Bit16u DI;
390 Bit16u ss=get_SS();
391 VbeInfoBlock vbe_info_block;
392 Bit16u status;
393 Bit16u result;
394 Bit16u vbe2_info;
395 #ifdef DYN_LIST
396 Bit16u *video_mode_list;
397 #endif
398 Bit16u cur_mode=0;
399 ModeInfoListItem *cur_info=&mode_info_list;
401 status = read_word(ss, AX);
403 #ifdef DEBUG
404 printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES,DI,status);
405 #endif
407 vbe2_info = 0;
408 #ifdef VBE2_NO_VESA_CHECK
409 #else
410 // get vbe_info_block into local variable
411 memcpyb(ss, &vbe_info_block, ES, DI, sizeof(vbe_info_block));
413 // check for VBE2 signature
414 if (((vbe_info_block.VbeSignature[0] == 'V') &&
415 (vbe_info_block.VbeSignature[1] == 'B') &&
416 (vbe_info_block.VbeSignature[2] == 'E') &&
417 (vbe_info_block.VbeSignature[3] == '2')) ||
419 ((vbe_info_block.VbeSignature[0] == 'V') &&
420 (vbe_info_block.VbeSignature[1] == 'E') &&
421 (vbe_info_block.VbeSignature[2] == 'S') &&
422 (vbe_info_block.VbeSignature[3] == 'A')) )
424 vbe2_info = 1;
425 #ifdef DEBUG
426 printf("VBE correct VESA/VBE2 signature found\n");
427 #endif
429 #endif
431 // VBE Signature
432 vbe_info_block.VbeSignature[0] = 'V';
433 vbe_info_block.VbeSignature[1] = 'E';
434 vbe_info_block.VbeSignature[2] = 'S';
435 vbe_info_block.VbeSignature[3] = 'A';
437 // VBE Version supported
438 vbe_info_block.VbeVersion = 0x0200;
440 // OEM String
441 vbe_info_block.OemStringPtr_Seg = 0xc000;
442 vbe_info_block.OemStringPtr_Off = &vbebios_copyright;
444 // Capabilities
445 vbe_info_block.Capabilities[0] = 0;
446 vbe_info_block.Capabilities[1] = 0;
447 vbe_info_block.Capabilities[2] = 0;
448 vbe_info_block.Capabilities[3] = 0;
450 #ifdef DYN_LIST
451 // FIXME: This doesn't work correctly somehow?
452 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list)
453 vbe_info_block.VideoModePtr_Seg= ES ;//0xc000;
454 vbe_info_block.VideoModePtr_Off= DI + 34;//&(VBEInfoData->Reserved);//&vbebios_mode_list;
455 #else
456 // VBE Video Mode Pointer (staticly in rom)
457 vbe_info_block.VideoModePtr_Seg = 0xc000;
458 vbe_info_block.VideoModePtr_Off = &vbebios_mode_list;
460 #endif
462 #ifdef DYN_LIST
464 // video_mode_list=(Bit16u*)&(vbe_info_block.Reserved);
468 #ifdef DEBUG
469 printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
470 #endif
471 // *video_mode_list=cur_info->mode;
472 vbe_info_block.Reserved[cur_mode] = cur_info->mode;
474 cur_info++;
475 //video_mode_list++;
476 cur_mode++;
477 } while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST);
479 // Add vesa mode list terminator
480 vbe_info_block.Reserved[cur_mode] = VBE_VESA_MODE_END_OF_LIST;
481 #endif
483 // VBE Total Memory (in 64b blocks)
484 vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
486 if (vbe2_info)
488 // OEM Stuff
489 vbe_info_block.OemSoftwareRev = VBE_OEM_SOFTWARE_REV;
490 vbe_info_block.OemVendorNamePtr_Seg = 0xc000;
491 vbe_info_block.OemVendorNamePtr_Off = &vbebios_vendor_name;
492 vbe_info_block.OemProductNamePtr_Seg = 0xc000;
493 vbe_info_block.OemProductNamePtr_Off = &vbebios_product_name;
494 vbe_info_block.OemProductRevPtr_Seg = 0xc000;
495 vbe_info_block.OemProductRevPtr_Off = &vbebios_product_revision;
497 // copy updates in vbe_info_block back
498 memcpyb(ES, DI, ss, &vbe_info_block, sizeof(vbe_info_block));
500 else
502 // copy updates in vbe_info_block back (VBE 1.x compatibility)
503 memcpyb(ES, DI, ss, &vbe_info_block, 256);
506 result = 0x4f;
508 write_word(ss, AX, result);
512 /** Function 01h - Return VBE Mode Information
514 * Input:
515 * AX = 4F01h
516 * CX = Mode Number
517 * ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
518 * Output:
519 * AX = VBE Return Status
522 void vbe_biosfn_return_mode_information(AX, CX, ES, DI)
523 Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
525 Bit16u result=0x0100;
526 Bit16u ss=get_SS();
527 ModeInfoBlock info;
528 ModeInfoListItem *cur_info;
529 Boolean using_lfb;
531 #ifdef DEBUG
532 printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
533 #endif
535 using_lfb=((CX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
537 CX = (CX & 0x1ff);
539 cur_info = mode_info_find_mode(CX, using_lfb, &cur_info);
541 if (cur_info != 0)
543 #ifdef DEBUG
544 printf("VBE found mode %x\n",CX);
545 #endif
546 memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
547 memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
548 if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) {
549 info.WinFuncPtr = 0xC0000000UL;
550 *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
553 result = 0x4f;
555 else
557 #ifdef DEBUG
558 printf("VBE *NOT* found mode %x\n",CX);
559 #endif
560 result = 0x100;
563 if (result == 0x4f)
565 // copy updates in mode_info_block back
566 memcpyb(ES, DI, ss, &info, sizeof(info));
569 write_word(ss, AX, result);
572 /** Function 02h - Set VBE Mode
574 * Input:
575 * AX = 4F02h
576 * BX = Desired Mode to set
577 * ES:DI = Pointer to CRTCInfoBlock structure
578 * Output:
579 * AX = VBE Return Status
582 void vbe_biosfn_set_mode(AX, BX, ES, DI)
583 Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u DI;
585 Bit16u ss = get_SS();
586 Bit16u result;
587 ModeInfoListItem *cur_info;
588 Boolean using_lfb;
590 using_lfb=((BX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
592 BX = (BX & 0x1ff);
594 //result=read_word(ss,AX);
596 // check for non vesa mode
597 if (BX<VBE_MODE_VESA_DEFINED)
599 Bit8u mode;
601 dispi_set_enable(VBE_DISPI_DISABLED);
602 // call the vgabios in order to set the video mode
603 // this allows for going back to textmode with a VBE call (some applications expect that to work)
605 mode=(BX & 0xff);
606 biosfn_set_video_mode(mode);
607 result = 0x4f;
610 cur_info = mode_info_find_mode(BX, using_lfb, &cur_info);
612 if (cur_info != 0)
614 #ifdef DEBUG
615 printf("VBE found mode %x, setting:\n", BX);
616 printf("\txres%x yres%x bpp%x\n",
617 cur_info->info.XResolution,
618 cur_info->info.YResolution,
619 cur_info->info.BitsPerPixel);
620 #endif
621 // FIXME: this is here so we can do some testing
622 // at least until bochs host side display is up & running
623 // (we're using the 'standard' 320x200x256 vga mode as if it
624 // were a vesa mode)
626 if (cur_info->info.BitsPerPixel <= 8)
628 // we have a 4bpp or 8bpp mode, preparing to set it
630 // first disable current mode (when switching between vesa modi)
631 dispi_set_enable(VBE_DISPI_DISABLED);
633 if (cur_info->mode == VBE_VESA_MODE_800X600X4)
635 biosfn_set_video_mode(0x6a);
638 dispi_set_xres(cur_info->info.XResolution);
639 dispi_set_yres(cur_info->info.YResolution);
640 dispi_set_bpp((cur_info->info.BitsPerPixel == 8)?VBE_DISPI_BPP_8:VBE_DISPI_BPP_4);
641 dispi_set_bank(0);
642 dispi_set_enable(VBE_DISPI_ENABLED);
644 // FIXME: store current mode in BIOS data area
646 result = 0x4f;
649 //FIXME: new resolutions will need special code (per bpp)
651 else
653 #ifdef DEBUG
654 printf("VBE *NOT* found mode %x\n" , BX);
655 #endif
656 result = 0x100;
658 // FIXME: redirect non VBE modi to normal VGA bios operation
659 // (switch back to VGA mode
660 if (BX == 3)
661 result = 0x4f;
664 write_word(ss, AX, result);
667 /** Function 03h - Return Current VBE Mode
669 * Input:
670 * AX = 4F03h
671 * Output:
672 * AX = VBE Return Status
673 * BX = Current VBE Mode
676 void vbe_biosfn_return_current_mode(AX, BX)
677 Bit16u *AX;Bit16u *BX;
679 Bit16u ss=get_SS();
680 Bit16u mode=0xffff;
682 #ifdef DEBUG
683 printf("VBE vbe_biosfn_return_current_mode\n");
684 #endif
686 if(dispi_get_enable())
688 // FIXME: get current mode from BIOS data area
690 else
692 mode=read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE);
694 write_word(ss, AX, 0x4f);
695 write_word(ss, BX, mode);
699 /** Function 04h - Save/Restore State
701 * Input:
702 * AX = 4F04h
703 * DL = 00h Return Save/Restore State buffer size
704 * 01h Save State
705 * 02h Restore State
706 * CX = Requested states
707 * ES:BX = Pointer to buffer (if DL <> 00h)
708 * Output:
709 * AX = VBE Return Status
710 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
713 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX)
718 /** Function 05h - Display Window Control
720 * Input:
721 * AX = 4F05h
722 * (16-bit) BH = 00h Set memory window
723 * = 01h Get memory window
724 * BL = Window number
725 * = 00h Window A
726 * = 01h Window B
727 * DX = Window number in video memory in window
728 * granularity units (Set Memory Window only)
729 * Note:
730 * If this function is called while in a linear frame buffer mode,
731 * this function must fail with completion code AH=03h
733 * Output:
734 * AX = VBE Return Status
735 * DX = Window number in window granularity units
736 * (Get Memory Window only)
738 void vbe_biosfn_display_window_control(AX,BX,DX)
739 Bit16u *AX;Bit16u BX;Bit16u *DX;
741 Bit16u ss = get_SS();
742 Bit16u window = read_word(ss, DX);
743 Bit16u result = 0x014f;
745 if (BX==0x0000)
747 dispi_set_bank(window);
748 result = 0x4f;
750 else if (BX==0x0100)
752 window = dispi_get_bank();
753 write_word(ss, DX, result);
754 result = 0x4f;
756 write_word(ss, AX, result);
760 /** Function 06h - Set/Get Logical Scan Line Length
762 * Input:
763 * AX = 4F06h
764 * BL = 00h Set Scan Line Length in Pixels
765 * = 01h Get Scan Line Length
766 * = 02h Set Scan Line Length in Bytes
767 * = 03h Get Maximum Scan Line Length
768 * CX = If BL=00h Desired Width in Pixels
769 * If BL=02h Desired Width in Bytes
770 * (Ignored for Get Functions)
772 * Output:
773 * AX = VBE Return Status
774 * BX = Bytes Per Scan Line
775 * CX = Actual Pixels Per Scan Line
776 * (truncated to nearest complete pixel)
777 * DX = Maximum Number of Scan Lines
779 void vbe_biosfn_set_get_logical_scan_line_length(AX,BX,CX,DX)
780 Bit16u *AX;Bit16u *BX;Bit16u *DX;Bit16u *DX;
782 Bit16u ss=get_SS();
783 Bit16u result=0x100;
784 Bit16u width = read_word(ss, CX);
785 Bit16u cmd = read_word(ss, BX);
787 // check bl
788 if ( ((cmd & 0xff) == 0x00) || ((cmd & 0xff) == 0x02) )
790 // set scan line lenght in pixels(0x00) or bytes (0x00)
791 Bit16u new_width;
792 Bit16u new_height;
794 dispi_set_virt_width(width);
795 new_width=dispi_get_virt_width();
796 new_height=dispi_get_virt_height();
798 if (new_width!=width)
800 #ifdef DEBUG
801 printf("* VBE width adjusted\n");
802 #endif
804 // notify width adjusted
805 result=0x024f;
807 else
809 result=0x4f;
812 // FIXME: adjust for higher bpp (in bytes)
813 write_word(ss,BX,new_width);
814 write_word(ss,CX,new_width);
815 write_word(ss,DX,new_height);
818 write_word(ss, AX, result);
822 /** Function 07h - Set/Get Display Start
824 * Input(16-bit):
825 * AX = 4F07h
826 * BH = 00h Reserved and must be 00h
827 * BL = 00h Set Display Start
828 * = 01h Get Display Start
829 * = 02h Schedule Display Start (Alternate)
830 * = 03h Schedule Stereoscopic Display Start
831 * = 04h Get Scheduled Display Start Status
832 * = 05h Enable Stereoscopic Mode
833 * = 06h Disable Stereoscopic Mode
834 * = 80h Set Display Start during Vertical Retrace
835 * = 82h Set Display Start during Vertical Retrace (Alternate)
836 * = 83h Set Stereoscopic Display Start during Vertical Retrace
837 * ECX = If BL=02h/82h Display Start Address in bytes
838 * If BL=03h/83h Left Image Start Address in bytes
839 * EDX = If BL=03h/83h Right Image Start Address in bytes
840 * CX = If BL=00h/80h First Displayed Pixel In Scan Line
841 * DX = If BL=00h/80h First Displayed Scan Line
843 * Output:
844 * AX = VBE Return Status
845 * BH = If BL=01h Reserved and will be 0
846 * CX = If BL=01h First Displayed Pixel In Scan Line
847 * If BL=04h 0 if flip has not occurred, not 0 if it has
848 * DX = If BL=01h First Displayed Scan Line
850 * Input(32-bit):
851 * BH = 00h Reserved and must be 00h
852 * BL = 00h Set Display Start
853 * = 80h Set Display Start during Vertical Retrace
854 * CX = Bits 0-15 of display start address
855 * DX = Bits 16-31 of display start address
856 * ES = Selector for memory mapped registers
858 void vbe_biosfn_set_get_display_start(AX,BX,CX,DX)
859 Bit16u *AX;Bit16u BX;Bit16u CX;Bit16u DX;
861 Bit16u ss=get_SS();
862 Bit16u result=0x100;
863 #ifdef DEBUG
864 // printf("VBE vbe_biosfn_set_get_display_start\n");
865 #endif
867 // check for set display start
868 if ((GET_BL()==0x00) || (GET_BL()==0x80))
870 // 0x80 is during vertical retrace - is also used by sdd vbetest during multibuffering
871 #ifdef DEBUG
872 // printf("VBE vbe_biosfn_set_get_display_start CX%x DX%x\n",CX,DX);
873 #endif
875 dispi_set_x_offset(CX);
876 dispi_set_y_offset(DX);
877 result = 0x4f;
880 write_word(ss, AX, result);
884 /** Function 08h - Set/Get Dac Palette Format
886 * Input:
887 * AX = 4F08h
888 * Output:
889 * AX = VBE Return Status
891 * FIXME: incomplete API description, Input & Output
893 void vbe_biosfn_set_get_dac_palette_format(AX)
898 /** Function 09h - Set/Get Palette Data
900 * Input:
901 * AX = 4F09h
902 * Output:
903 * AX = VBE Return Status
905 * FIXME: incomplete API description, Input & Output
907 void vbe_biosfn_set_get_palette_data(AX)
911 /** Function 0Ah - Return VBE Protected Mode Interface
913 * Input:
914 * AX = 4F0Ah
915 * Output:
916 * AX = VBE Return Status
918 * FIXME: incomplete API description, Input & Output
920 void vbe_biosfn_return_protected_mode_interface(AX)