- functions biosfn_get_video_mode() and biosfn_read_display_code() rewritten
[vgabios.git] / vbe.c
blob179a9ebc0608ede0bd3f53db68fb0fd707f5742a
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 extern char vbebios_copyright;
51 extern char vbebios_vendor_name;
52 extern char vbebios_product_name;
53 extern char vbebios_product_revision;
55 #ifndef DYN_LIST
56 extern Bit16u vbebios_mode_list;
57 #endif
59 ASM_START
60 // FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
61 _vbebios_copyright:
62 .ascii "Bochs/Plex86 VBE(C) 2003 Jeroen Janssen <japj@darius.demon.nl>"
63 .byte 0x00
65 _vbebios_vendor_name:
66 .ascii "Bochs/Plex86 Developers"
67 .byte 0x00
69 _vbebios_product_name:
70 .ascii "Bochs/Plex86 VBE Adapter"
71 .byte 0x00
73 _vbebios_product_revision:
74 .ascii "$Id$"
75 .byte 0x00
77 _vbebios_info_string:
78 .ascii "Bochs VBE Display Adapter enabled"
79 .byte 0x0a,0x0d
80 .byte 0x0a,0x0d
81 .byte 0x00
83 _no_vbebios_info_string:
84 .ascii "NO Bochs VBE Support available!"
85 .byte 0x0a,0x0d
86 .byte 0x0a,0x0d
87 .byte 0x00
90 #ifndef DYN_LIST
91 // FIXME: for each new mode add a statement here
92 // at least until dynamic list creation is working
93 _vbebios_mode_list:
95 .word VBE_VESA_MODE_640X400X8
96 .word VBE_VESA_MODE_640X480X8
97 .word VBE_VESA_MODE_800X600X4
98 .word VBE_VESA_MODE_800X600X8
99 .word VBE_VESA_MODE_1024X768X8
100 .word VBE_VESA_MODE_640X480X1555
101 .word VBE_VESA_MODE_640X480X565
102 .word VBE_VESA_MODE_640X480X888
103 .word VBE_VESA_MODE_800X600X1555
104 .word VBE_VESA_MODE_800X600X565
105 .word VBE_VESA_MODE_800X600X888
106 .word VBE_VESA_MODE_1024X768X1555
107 .word VBE_VESA_MODE_1024X768X565
108 .word VBE_VESA_MODE_1024X768X888
109 .word VBE_OWN_MODE_640X480X8888
110 .word VBE_OWN_MODE_800X600X8888
111 .word VBE_OWN_MODE_1024X768X8888
112 .word VBE_OWN_MODE_320X200X8
113 .word VBE_VESA_MODE_END_OF_LIST
114 #endif
116 ASM_END
118 // from rombios.c
119 #define PANIC_PORT 0x501
121 ASM_START
122 MACRO HALT
123 ;; the HALT macro is called with the line number of the HALT call.
124 ;; The line number is then sent to the PANIC_PORT, causing Bochs to
125 ;; print a BX_PANIC message. This will normally halt the simulation
126 ;; with a message such as "BIOS panic at rombios.c, line 4091".
127 ;; However, users can choose to make panics non-fatal and continue.
128 mov dx,#PANIC_PORT
129 mov ax,#?1
130 out dx,ax
131 MEND
132 ASM_END
134 // DISPI ioport functions
135 // FIXME: what if no VBE host side code?
136 static Bit16u dispi_get_id()
138 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
139 return inw(VBE_DISPI_IOPORT_DATA);
142 static void dispi_set_id(id)
143 Bit16u id;
145 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
146 outw(VBE_DISPI_IOPORT_DATA,id);
149 static void dispi_set_xres(xres)
150 Bit16u xres;
152 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_XRES);
153 outw(VBE_DISPI_IOPORT_DATA,xres);
156 static void dispi_set_yres(yres)
157 Bit16u yres;
159 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_YRES);
160 outw(VBE_DISPI_IOPORT_DATA,yres);
163 static void dispi_set_bpp(bpp)
164 Bit16u bpp;
166 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
167 outw(VBE_DISPI_IOPORT_DATA,bpp);
170 static Bit16u dispi_get_bpp()
172 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
173 return inw(VBE_DISPI_IOPORT_DATA);
176 static Bit16u dispi_get_max_bpp()
178 Bit16u max_bpp, vbe_enable;
180 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
181 vbe_enable = inw(VBE_DISPI_IOPORT_DATA);
182 outw(VBE_DISPI_IOPORT_DATA,vbe_enable|VBE_DISPI_GETCAPS);
183 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
184 max_bpp = inw(VBE_DISPI_IOPORT_DATA);
185 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
186 outw(VBE_DISPI_IOPORT_DATA,vbe_enable);
187 return max_bpp;
190 static Bit16u dispi_get_enable()
192 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
193 return inw(VBE_DISPI_IOPORT_DATA);
196 void dispi_set_enable(enable)
197 Bit16u enable;
199 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
200 outw(VBE_DISPI_IOPORT_DATA,enable);
203 static void dispi_set_bank(bank)
204 Bit16u bank;
206 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
207 outw(VBE_DISPI_IOPORT_DATA,bank);
210 static Bit16u dispi_get_bank()
212 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
213 return inw(VBE_DISPI_IOPORT_DATA);
216 static void dispi_set_bank_farcall()
218 ASM_START
219 cmp bx,#0x0100
220 je dispi_set_bank_farcall_get
221 or bx,bx
222 jnz dispi_set_bank_farcall_error
223 push dx
224 mov ax,# VBE_DISPI_INDEX_BANK
225 mov dx,# VBE_DISPI_IOPORT_INDEX
226 out dx,ax
227 pop ax
228 mov dx,# VBE_DISPI_IOPORT_DATA
229 out dx,ax
230 retf
231 dispi_set_bank_farcall_get:
232 mov ax,# VBE_DISPI_INDEX_BANK
233 mov dx,# VBE_DISPI_IOPORT_INDEX
234 out dx,ax
235 mov dx,# VBE_DISPI_IOPORT_DATA
236 in ax,dx
237 mov dx,ax
238 retf
239 dispi_set_bank_farcall_error:
240 mov ax,#0x014F
241 retf
242 ASM_END
245 static void dispi_set_x_offset(offset)
246 Bit16u offset;
248 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
249 outw(VBE_DISPI_IOPORT_DATA,offset);
252 static Bit16u dispi_get_x_offset()
254 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
255 return inw(VBE_DISPI_IOPORT_DATA);
258 static void dispi_set_y_offset(offset)
259 Bit16u offset;
261 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
262 outw(VBE_DISPI_IOPORT_DATA,offset);
265 static Bit16u dispi_get_y_offset()
267 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
268 return inw(VBE_DISPI_IOPORT_DATA);
271 static void dispi_set_virt_width(width)
272 Bit16u width;
274 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
275 outw(VBE_DISPI_IOPORT_DATA,width);
278 static Bit16u dispi_get_virt_width()
280 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
281 return inw(VBE_DISPI_IOPORT_DATA);
284 static void dispi_set_virt_height(height)
285 Bit16u height;
287 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
288 outw(VBE_DISPI_IOPORT_DATA,height);
291 static Bit16u dispi_get_virt_height()
293 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
294 return inw(VBE_DISPI_IOPORT_DATA);
298 // ModeInfo helper function
299 static ModeInfoListItem* mode_info_find_mode(mode, using_lfb)
300 Bit16u mode; Boolean using_lfb;
302 ModeInfoListItem *cur_info=&mode_info_list;
304 while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST)
306 if (cur_info->mode == mode)
308 if (!using_lfb)
310 return cur_info;
312 else if (cur_info->info.ModeAttributes & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
314 return cur_info;
316 else
318 cur_info++;
321 else
323 cur_info++;
327 return 0;
330 /** Has VBE display - Returns true if VBE display detected
333 Boolean vbe_has_vbe_display()
335 return read_byte(BIOSMEM_SEG,BIOSMEM_VBE_FLAG);
338 /** VBE Init - Initialise the Vesa Bios Extension Code
340 * This function does a sanity check on the host side display code interface.
342 void vbe_init()
344 Bit16u dispi_id;
346 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
347 outw(VBE_DISPI_IOPORT_DATA,VBE_DISPI_ID0);
349 dispi_id=inw(VBE_DISPI_IOPORT_DATA);
351 if (dispi_id==VBE_DISPI_ID0)
353 write_byte(BIOSMEM_SEG,BIOSMEM_VBE_FLAG,0x01);
354 dispi_set_id(VBE_DISPI_ID3);
356 printf("VBE Bios $Id$\n");
359 /** VBE Display Info - Display information on screen about the VBE
361 void vbe_display_info()
363 // Check for VBE display extension in Bochs
364 if (vbe_has_vbe_display())
366 ASM_START
367 mov ax,#0xc000
368 mov ds,ax
369 mov si,#_vbebios_info_string
370 call _display_string
371 ASM_END
373 else
375 ASM_START
376 mov ax,#0xc000
377 mov ds,ax
378 mov si,#_no_vbebios_info_string
379 call _display_string
380 ASM_END
385 /** Function 00h - Return VBE Controller Information
387 * Input:
388 * AX = 4F00h
389 * ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
390 * (VbeSignature should be VBE2 when VBE 2.0 information is desired and
391 * the info block is 512 bytes in size)
392 * Output:
393 * AX = VBE Return Status
396 void vbe_biosfn_return_controller_information(AX, ES, DI)
397 Bit16u *AX;Bit16u ES;Bit16u DI;
399 Bit16u ss=get_SS();
400 VbeInfoBlock vbe_info_block;
401 Bit16u status;
402 Bit16u result;
403 Bit16u vbe2_info;
404 Bit16u cur_mode=0;
405 Bit16u cur_ptr=34;
406 ModeInfoListItem *cur_info=&mode_info_list;
408 status = read_word(ss, AX);
410 #ifdef DEBUG
411 printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES,DI,status);
412 #endif
414 vbe2_info = 0;
415 #ifdef VBE2_NO_VESA_CHECK
416 #else
417 // get vbe_info_block into local variable
418 memcpyb(ss, &vbe_info_block, ES, DI, sizeof(vbe_info_block));
420 // check for VBE2 signature
421 if (((vbe_info_block.VbeSignature[0] == 'V') &&
422 (vbe_info_block.VbeSignature[1] == 'B') &&
423 (vbe_info_block.VbeSignature[2] == 'E') &&
424 (vbe_info_block.VbeSignature[3] == '2')) ||
426 ((vbe_info_block.VbeSignature[0] == 'V') &&
427 (vbe_info_block.VbeSignature[1] == 'E') &&
428 (vbe_info_block.VbeSignature[2] == 'S') &&
429 (vbe_info_block.VbeSignature[3] == 'A')) )
431 vbe2_info = 1;
432 #ifdef DEBUG
433 printf("VBE correct VESA/VBE2 signature found\n");
434 #endif
436 #endif
438 // VBE Signature
439 vbe_info_block.VbeSignature[0] = 'V';
440 vbe_info_block.VbeSignature[1] = 'E';
441 vbe_info_block.VbeSignature[2] = 'S';
442 vbe_info_block.VbeSignature[3] = 'A';
444 // VBE Version supported
445 vbe_info_block.VbeVersion = 0x0200;
447 // OEM String
448 vbe_info_block.OemStringPtr_Seg = 0xc000;
449 vbe_info_block.OemStringPtr_Off = &vbebios_copyright;
451 // Capabilities
452 vbe_info_block.Capabilities[0] = 0;
453 vbe_info_block.Capabilities[1] = 0;
454 vbe_info_block.Capabilities[2] = 0;
455 vbe_info_block.Capabilities[3] = 0;
457 #ifdef DYN_LIST
458 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list)
459 vbe_info_block.VideoModePtr_Seg= ES ;
460 vbe_info_block.VideoModePtr_Off= DI + 34;
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;
465 #endif
467 // VBE Total Memory (in 64b blocks)
468 vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
470 if (vbe2_info)
472 // OEM Stuff
473 vbe_info_block.OemSoftwareRev = VBE_OEM_SOFTWARE_REV;
474 vbe_info_block.OemVendorNamePtr_Seg = 0xc000;
475 vbe_info_block.OemVendorNamePtr_Off = &vbebios_vendor_name;
476 vbe_info_block.OemProductNamePtr_Seg = 0xc000;
477 vbe_info_block.OemProductNamePtr_Off = &vbebios_product_name;
478 vbe_info_block.OemProductRevPtr_Seg = 0xc000;
479 vbe_info_block.OemProductRevPtr_Off = &vbebios_product_revision;
481 // copy updates in vbe_info_block back
482 memcpyb(ES, DI, ss, &vbe_info_block, sizeof(vbe_info_block));
484 else
486 // copy updates in vbe_info_block back (VBE 1.x compatibility)
487 memcpyb(ES, DI, ss, &vbe_info_block, 256);
490 #ifdef DYN_LIST
493 if (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) {
494 #ifdef DEBUG
495 printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
496 #endif
497 write_word(ES, DI + cur_ptr, cur_info->mode);
498 cur_mode++;
499 cur_ptr+=2;
501 cur_info++;
502 } while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST);
504 // Add vesa mode list terminator
505 write_word(ES, DI + cur_ptr, cur_info->mode);
506 #endif
508 result = 0x4f;
510 write_word(ss, AX, result);
514 /** Function 01h - Return VBE Mode Information
516 * Input:
517 * AX = 4F01h
518 * CX = Mode Number
519 * ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
520 * Output:
521 * AX = VBE Return Status
524 void vbe_biosfn_return_mode_information(AX, CX, ES, DI)
525 Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
527 Bit16u result=0x0100;
528 Bit16u ss=get_SS();
529 ModeInfoBlock info;
530 ModeInfoListItem *cur_info;
531 Boolean using_lfb;
533 #ifdef DEBUG
534 printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
535 #endif
537 using_lfb=((CX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
539 CX = (CX & 0x1ff);
541 cur_info = mode_info_find_mode(CX, using_lfb, &cur_info);
543 if (cur_info != 0)
545 #ifdef DEBUG
546 printf("VBE found mode %x\n",CX);
547 #endif
548 memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
549 memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
550 if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) {
551 info.WinFuncPtr = 0xC0000000UL;
552 *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
555 result = 0x4f;
557 else
559 #ifdef DEBUG
560 printf("VBE *NOT* found mode %x\n",CX);
561 #endif
562 result = 0x100;
565 if (result == 0x4f)
567 // copy updates in mode_info_block back
568 memcpyb(ES, DI, ss, &info, sizeof(info));
571 write_word(ss, AX, result);
574 /** Function 02h - Set VBE Mode
576 * Input:
577 * AX = 4F02h
578 * BX = Desired Mode to set
579 * ES:DI = Pointer to CRTCInfoBlock structure
580 * Output:
581 * AX = VBE Return Status
584 void vbe_biosfn_set_mode(AX, BX, ES, DI)
585 Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u DI;
587 Bit16u ss = get_SS();
588 Bit16u result;
589 ModeInfoListItem *cur_info;
590 Boolean using_lfb;
591 Bit8u no_clear;
592 Bit8u lfb_flag;
594 using_lfb=((BX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
595 lfb_flag=using_lfb?VBE_DISPI_LFB_ENABLED:0;
596 no_clear=((BX & VBE_MODE_PRESERVE_DISPLAY_MEMORY) == VBE_MODE_PRESERVE_DISPLAY_MEMORY)?VBE_DISPI_NOCLEARMEM:0;
598 BX = (BX & 0x1ff);
600 //result=read_word(ss,AX);
602 // check for non vesa mode
603 if (BX<VBE_MODE_VESA_DEFINED)
605 Bit8u mode;
607 dispi_set_enable(VBE_DISPI_DISABLED);
608 // call the vgabios in order to set the video mode
609 // this allows for going back to textmode with a VBE call (some applications expect that to work)
611 mode=(BX & 0xff);
612 biosfn_set_video_mode(mode);
613 result = 0x4f;
616 cur_info = mode_info_find_mode(BX, using_lfb, &cur_info);
618 if (cur_info != 0)
620 #ifdef DEBUG
621 printf("VBE found mode %x, setting:\n", BX);
622 printf("\txres%x yres%x bpp%x\n",
623 cur_info->info.XResolution,
624 cur_info->info.YResolution,
625 cur_info->info.BitsPerPixel);
626 #endif
628 // first disable current mode (when switching between vesa modi)
629 dispi_set_enable(VBE_DISPI_DISABLED);
631 if (cur_info->mode == VBE_VESA_MODE_800X600X4)
633 biosfn_set_video_mode(0x6a);
636 dispi_set_xres(cur_info->info.XResolution);
637 dispi_set_yres(cur_info->info.YResolution);
638 dispi_set_bpp(cur_info->info.BitsPerPixel);
639 dispi_set_bank(0);
640 dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag);
642 write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX);
643 write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,(0x60 | no_clear));
645 result = 0x4f;
647 else
649 #ifdef DEBUG
650 printf("VBE *NOT* found mode %x\n" , BX);
651 #endif
652 result = 0x100;
654 // FIXME: redirect non VBE modi to normal VGA bios operation
655 // (switch back to VGA mode
656 if (BX == 3)
657 result = 0x4f;
660 write_word(ss, AX, result);
663 /** Function 03h - Return Current VBE Mode
665 * Input:
666 * AX = 4F03h
667 * Output:
668 * AX = VBE Return Status
669 * BX = Current VBE Mode
672 void vbe_biosfn_return_current_mode(AX, BX)
673 Bit16u *AX;Bit16u *BX;
675 Bit16u ss=get_SS();
676 Bit16u mode;
678 #ifdef DEBUG
679 printf("VBE vbe_biosfn_return_current_mode\n");
680 #endif
682 if(dispi_get_enable())
684 mode=read_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE);
686 else
688 mode=read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE);
690 write_word(ss, AX, 0x4f);
691 write_word(ss, BX, mode);
695 /** Function 04h - Save/Restore State
697 * Input:
698 * AX = 4F04h
699 * DL = 00h Return Save/Restore State buffer size
700 * 01h Save State
701 * 02h Restore State
702 * CX = Requested states
703 * ES:BX = Pointer to buffer (if DL <> 00h)
704 * Output:
705 * AX = VBE Return Status
706 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
709 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX)
714 /** Function 05h - Display Window Control
716 * Input:
717 * AX = 4F05h
718 * (16-bit) BH = 00h Set memory window
719 * = 01h Get memory window
720 * BL = Window number
721 * = 00h Window A
722 * = 01h Window B
723 * DX = Window number in video memory in window
724 * granularity units (Set Memory Window only)
725 * Note:
726 * If this function is called while in a linear frame buffer mode,
727 * this function must fail with completion code AH=03h
729 * Output:
730 * AX = VBE Return Status
731 * DX = Window number in window granularity units
732 * (Get Memory Window only)
734 void vbe_biosfn_display_window_control(AX,BX,DX)
735 Bit16u *AX;Bit16u BX;Bit16u *DX;
737 Bit16u ss = get_SS();
738 Bit16u window = read_word(ss, DX);
739 Bit16u result = 0x014f;
741 if (BX==0x0000)
743 dispi_set_bank(window);
744 result = 0x4f;
746 else if (BX==0x0100)
748 window = dispi_get_bank();
749 write_word(ss, DX, result);
750 result = 0x4f;
752 write_word(ss, AX, result);
756 /** Function 06h - Set/Get Logical Scan Line Length
758 * Input:
759 * AX = 4F06h
760 * BL = 00h Set Scan Line Length in Pixels
761 * = 01h Get Scan Line Length
762 * = 02h Set Scan Line Length in Bytes
763 * = 03h Get Maximum Scan Line Length
764 * CX = If BL=00h Desired Width in Pixels
765 * If BL=02h Desired Width in Bytes
766 * (Ignored for Get Functions)
768 * Output:
769 * AX = VBE Return Status
770 * BX = Bytes Per Scan Line
771 * CX = Actual Pixels Per Scan Line
772 * (truncated to nearest complete pixel)
773 * DX = Maximum Number of Scan Lines
775 void vbe_biosfn_set_get_logical_scan_line_length(AX,BX,CX,DX)
776 Bit16u *AX;Bit16u *BX;Bit16u *DX;Bit16u *DX;
778 Bit16u ss=get_SS();
779 Bit16u result=0x100;
780 Bit16u width = read_word(ss, CX);
781 Bit16u cmd = read_word(ss, BX);
782 Bit8u bytespp = dispi_get_bpp()/8;
784 // check bl
785 if ( ((cmd & 0xff) == 0x00) || ((cmd & 0xff) == 0x02) )
787 // set scan line lenght in pixels(0x00) or bytes (0x02)
788 Bit16u new_width;
789 Bit16u new_height;
791 if ( ((cmd & 0xff) == 0x02) && (bytespp > 1) )
793 width/=bytespp;
795 dispi_set_virt_width(width);
796 new_width=dispi_get_virt_width();
797 new_height=dispi_get_virt_height();
799 if (new_width!=width)
801 #ifdef DEBUG
802 printf("* VBE width adjusted\n");
803 #endif
805 // notify width adjusted
806 result=0x024f;
808 else
810 result=0x4f;
813 write_word(ss,BX,new_width*bytespp);
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)