ReactOS 0.4.15-dev-8100-g1887773
vbe.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "cpu/cpu.h"
#include "bios32p.h"
#include "hardware/video/svga.h"
#include "vbe.h"
#include "io.h"
Include dependency graph for vbe.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PCVBE_MODE VbeGetModeByNumber (WORD Number)
 
static VOID VbeSetExtendedRegisters (PSVGA_REGISTERS Registers)
 
BOOLEAN WINAPI VbeSetExtendedVideoMode (BYTE ModeNumber)
 
VOID WINAPI VbeResetExtendedRegisters (VOID)
 
VOID WINAPI VbeService (LPWORD Stack)
 
BOOLEAN VbeInitialize (VOID)
 

Variables

static const VBE_MODE_INFO VbeMode_640x480x256_Info
 
static SVGA_REGISTERS VbeMode_640x480x256_Registers
 
static const VBE_MODE_INFO VbeMode_800x600x256_Info
 
static SVGA_REGISTERS VbeMode_800x600x256_Registers
 
static const VBE_MODE Modes [VBE_MODE_COUNT]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file vbe.c.

Function Documentation

◆ VbeGetModeByNumber()

PCVBE_MODE VbeGetModeByNumber ( WORD  Number)

Definition at line 220 of file vbe.c.

221{
222 INT i;
223
224 Number &= 0x1FF;
225
226 /* Find the mode */
227 for (i = 0; i < VBE_MODE_COUNT; i++)
228 {
229 if ((!(Number & 0x100) && (Number == Modes[i].Number))
230 || ((Number & 0x100) && (Number== Modes[i].VesaNumber)))
231 {
232 return &Modes[i];
233 }
234 }
235
236 return NULL;
237}
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
#define VBE_MODE_COUNT
Definition: vbe.h:19
int32_t INT
Definition: typedefs.h:58

Referenced by VbeService(), and VbeSetExtendedVideoMode().

◆ VbeInitialize()

BOOLEAN VbeInitialize ( VOID  )

Definition at line 763 of file vbe.c.

764{
766 BYTE SeqIndex = IOReadB(VGA_SEQ_INDEX);
767
768 /* Store the OEM name */
770
771 /* Unlock SVGA extensions on the card */
774
775 /* Check if it worked */
777
778 IOWriteB(VGA_SEQ_INDEX, SeqIndex);
779 return Success;
780}
unsigned char BOOLEAN
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define FAR_POINTER(x)
Definition: emulator.h:35
@ Success
Definition: eventcreate.c:712
#define OEM_NAME
Definition: vbe.h:16
#define OEM_NAME_PTR
Definition: vbe.h:17
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
#define VGA_SEQ_DATA
Definition: svga.h:56
#define VGA_SEQ_INDEX
Definition: svga.h:55
@ SVGA_SEQ_UNLOCK_REG
Definition: svga.h:137
#define SVGA_SEQ_UNLOCKED
Definition: svga.h:117
unsigned char BYTE
Definition: xxhash.c:193

Referenced by VidBiosPost().

◆ VbeResetExtendedRegisters()

VOID WINAPI VbeResetExtendedRegisters ( VOID  )

Definition at line 380 of file vbe.c.

381{
382 BYTE i;
383
384 /* Disable interrupts */
385 BOOLEAN Interrupts = getIF();
386 setIF(0);
387
388 /* Turn the video off */
391
392 /* Synchronous reset on */
395
396 /* Clear the extended sequencer registers, except for the VCLKs and MCLK */
398 {
400 && (i < SVGA_SEQ_VCLK0_NUMERATOR_REG || i > SVGA_SEQ_VCLK3_NUMERATOR_REG))
401 {
403 IOWriteB(VGA_SEQ_DATA, 0x00);
404 }
405 }
406
407 /* Reset the VCLKs */
409 IOWriteB(VGA_SEQ_DATA, 0x66);
411 IOWriteB(VGA_SEQ_DATA, 0x3B);
412
414 IOWriteB(VGA_SEQ_DATA, 0x5B);
416 IOWriteB(VGA_SEQ_DATA, 0x2F);
417
419 IOWriteB(VGA_SEQ_DATA, 0x45);
421 IOWriteB(VGA_SEQ_DATA, 0x30);
422
424 IOWriteB(VGA_SEQ_DATA, 0x7E);
426 IOWriteB(VGA_SEQ_DATA, 0x33);
427
428 /* Reset the MCLK */
430 IOWriteB(VGA_SEQ_DATA, 0x1C);
431
432 /* Synchronous reset off */
435
436 /* Reset the extended CRTC registers */
438 {
439 if ((i < SVGA_CRTC_UNUSED0_REG || i > SVGA_CRTC_UNUSED6_REG) && i != SVGA_CRTC_UNUSED7_REG)
440 {
442 IOWriteB(VGA_CRTC_DATA, 0x00);
443 }
444 }
445
446 /* Reset the extended GC registers */
448 {
450 && (i < SVGA_GC_UNUSED1_REG || i > SVGA_GC_UNUSED10_REG))
451 {
453 IOWriteB(VGA_GC_DATA, 0x00);
454 }
455 }
456
457 /*
458 * And finally, reset the hidden register. This requires 4 dummy reads from
459 * the DAC mask register.
460 */
461 for (i = 0; i < 4; i++) IOReadB(VGA_DAC_MASK);
462 IOWriteB(VGA_DAC_MASK, 0x00);
463
464 /* Turn the video on */
467
468 /* Restore interrupts */
469 setIF(Interrupts);
470}
#define VGA_DAC_MASK
Definition: svga.h:58
#define VGA_GC_DATA
Definition: svga.h:69
@ SVGA_CRTC_INTERLACE_END_REG
Definition: svga.h:229
@ SVGA_CRTC_UNUSED7_REG
Definition: svga.h:242
@ SVGA_CRTC_MAX_REG
Definition: svga.h:244
@ SVGA_CRTC_UNUSED6_REG
Definition: svga.h:240
@ SVGA_GC_MAX_REG
Definition: svga.h:321
@ SVGA_GC_UNUSED11_REG
Definition: svga.h:312
@ SVGA_GC_UNUSED0_REG
Definition: svga.h:284
@ SVGA_GC_OFFSET_0_REG
Definition: svga.h:278
@ SVGA_GC_UNUSED10_REG
Definition: svga.h:300
@ SVGA_SEQ_VCLK1_DENOMINATOR_REG
Definition: svga.h:159
@ SVGA_SEQ_VCLK0_DENOMINATOR_REG
Definition: svga.h:158
@ SVGA_SEQ_VCLK2_NUMERATOR_REG
Definition: svga.h:144
@ SVGA_SEQ_EXT_MODE_REG
Definition: svga.h:138
@ VGA_SEQ_MAX_REG
Definition: svga.h:136
@ SVGA_SEQ_VCLK3_NUMERATOR_REG
Definition: svga.h:145
@ SVGA_SEQ_VCLK3_DENOMINATOR_REG
Definition: svga.h:161
@ SVGA_SEQ_MCLK_REG
Definition: svga.h:162
@ VGA_SEQ_CLOCK_REG
Definition: svga.h:132
@ VGA_SEQ_RESET_REG
Definition: svga.h:131
@ SVGA_SEQ_VCLK2_DENOMINATOR_REG
Definition: svga.h:160
@ SVGA_SEQ_VCLK0_NUMERATOR_REG
Definition: svga.h:142
@ SVGA_SEQ_VCLK1_NUMERATOR_REG
Definition: svga.h:143
#define VGA_GC_INDEX
Definition: svga.h:68
#define VGA_SEQ_CLOCK_SD
Definition: svga.h:108
#define VGA_SEQ_RESET_SR
Definition: svga.h:101
#define VGA_SEQ_RESET_AR
Definition: svga.h:100
VOID WINAPI setIF(ULONG)
Definition: registers.c:643
ULONG WINAPI getIF(VOID)
Definition: registers.c:636
#define VGA_CRTC_DATA
Definition: vidbios.h:115
#define VGA_CRTC_INDEX
Definition: vidbios.h:114

Referenced by VidBiosSetVideoMode().

◆ VbeService()

VOID WINAPI VbeService ( LPWORD  Stack)

Definition at line 472 of file vbe.c.

473{
474 INT i;
475
476 switch (getAL())
477 {
478 /* Get VBE Information */
479 case 0x00:
480 {
482 PWORD Data = (PWORD)&Info;
483
484 /* Function recognized */
485 setAL(0x4F);
486
488 Info.Signature = 'ASEV';
489 Info.Version = 0x0102;
490 Info.OemName = OEM_NAME_PTR;
491 Info.Capabilities = 0;
492 Info.ModeList = MAKELONG(LOWORD(getDI()
493 + FIELD_OFFSET(VBE_INFORMATION, ModeListBuffer)),
494 getES());
495 Info.VideoMemory = HIWORD(SVGA_BANK_SIZE * VGA_NUM_BANKS);
496
497 /* Fill the mode list */
498 for (i = 0; i < VBE_MODE_COUNT; i++)
499 {
500 /* Some modes don't have VESA numbers */
501 if (Modes[i].VesaNumber != 0xFFFF)
502 {
503 Info.ModeListBuffer[i] = Modes[i].VesaNumber;
504 }
505 }
506
507 Info.ModeListBuffer[VBE_MODE_COUNT] = 0xFFFF;
508
509 /* Copy the data to the caller */
510 for (i = 0; i < sizeof(VBE_INFORMATION) / sizeof(WORD); i++)
511 {
512 *(PWORD)SEG_OFF_TO_PTR(getES(), LOWORD(getDI() + i * 2)) = Data[i];
513 }
514
515 setAH(0);
516 break;
517 }
518
519 /* Get VBE Mode Information */
520 case 0x01:
521 {
523 PWORD Data = NULL;
524
525 /* Function recognized */
526 setAL(0x4F);
527
528 if (Mode == NULL)
529 {
530 /* Mode not found */
531 setAH(1);
532 break;
533 }
534
535 Data = (PWORD)Mode->Info;
536 if (Data == NULL)
537 {
538 DPRINT1("WARNING: The mode information for mode %02X (%03X) is missing!\n",
539 Mode->Number,
540 Mode->VesaNumber);
541
542 setAH(1);
543 break;
544 }
545
546 /* Clear the buffer */
547 for (i = 0; i < 128; i++)
548 {
549 *(PWORD)SEG_OFF_TO_PTR(getES(), LOWORD(getDI() + i * 2)) = 0;
550 }
551
552 /* Copy the data to the caller */
553 for (i = 0; i < sizeof(VBE_MODE_INFO) / sizeof(WORD); i++)
554 {
555 *(PWORD)SEG_OFF_TO_PTR(getES(), LOWORD(getDI() + i * 2)) = Data[i];
556 }
557
558 setAH(0);
559 break;
560 }
561
562 /* Set VBE Mode */
563 case 0x02:
564 {
565 WORD VesaNumber = getBX();
566 setAL(0x4F);
567
568 if (VesaNumber <= BIOS_MAX_VIDEO_MODE)
569 {
570 /* Call the VGA BIOS */
571 setAH(0x00);
572 setAL(VesaNumber);
574
575 setAH(Bda->VideoMode != VesaNumber);
576 }
577 else
578 {
579 /* This is an extended video mode */
580 PCVBE_MODE Mode = VbeGetModeByNumber(VesaNumber);
581
582 if (Mode) setAH(!VbeSetExtendedVideoMode(Mode->Number));
583 else setAH(1);
584 }
585
586 break;
587 }
588
589 /* Get Current VBE Mode */
590 case 0x03:
591 {
593
594 setAL(0x4F);
595
596 if (Mode)
597 {
598 setBX(Mode->VesaNumber != 0xFFFF
599 ? Mode->VesaNumber : Mode->Number);
600 setAH(0);
601 }
602 else
603 {
604 setAH(1);
605 }
606
607 break;
608 }
609
610 /* CPU Video Memory Control */
611 case 0x05:
612 {
613 BYTE Window = getBL();
614 BYTE OldGcIndex = IOReadB(VGA_GC_INDEX);
615
616 switch (getBH())
617 {
618 /* Select Memory Window */
619 case 0:
620 {
621 setAL(0x4F);
622
623 if (getDH() != 0)
624 {
625 /* Offset too high */
626 setAH(1);
627 break;
628 }
629
632
633 setAH(0);
634 break;
635 }
636
637 /* Return Memory Window */
638 case 1:
639 {
642
643 setAX(0x004F);
644 break;
645 }
646
647 default:
648 {
649 DPRINT1("VESA INT 0x10, AL = 0x05, Unknown subfunction: 0x%02X\n", getBH());
650 }
651 }
652
653 IOWriteB(VGA_GC_INDEX, OldGcIndex);
654 break;
655 }
656
657 /* Get/Set Display Start */
658 case 0x07:
659 {
660 DWORD StartAddress;
661 BYTE Value;
663 BYTE OldCrtcIndex = IOReadB(VGA_CRTC_INDEX_COLOR);
664
665 if (getBL() & 0x80)
666 {
667 /* Wait for a vertical retrace */
669 {
670 setCF(1);
671 break;
672 }
673
674 setCF(0);
675 }
676
677 switch (getBL() & 0x7F)
678 {
679 /* Set Display Start */
680 case 0x00:
681 {
682 setAL(0x4F);
683
684 if (Mode == NULL || Mode->Info == NULL)
685 {
686 /* This is not a VBE mode */
687 // TODO: Support anyway, perhaps? It can be done.
688 setAH(0x01);
689 break;
690 }
691
692 StartAddress = getCX() + getDX() * Mode->Info->BytesPerScanline;
693
696 Value &= ~SVGA_CRTC_EXT_ADDR_BIT19;
697 Value |= (StartAddress >> 12) & SVGA_CRTC_EXT_ADDR_BIT19;
699
703 Value |= (StartAddress >> 16) & SVGA_CRTC_EXT_ADDR_BIT16;
704 Value |= (StartAddress >> 15) & SVGA_CRTC_EXT_ADDR_BITS1718;
706
708 IOWriteB(VGA_CRTC_DATA_COLOR, (StartAddress >> 8) & 0xFF);
710 IOWriteB(VGA_CRTC_DATA_COLOR, StartAddress & 0xFF);
711
712 setAH(0);
713 break;
714 }
715
716 /* Get Display Start */
717 case 0x01:
718 {
719 setAL(0x4F);
720 StartAddress = 0;
721
722 if (Mode == NULL || Mode->Info == NULL)
723 {
724 /* This is not a VBE mode */
725 // TODO: Support anyway, perhaps? It can be done.
726 setAH(0x01);
727 break;
728 }
729
731 StartAddress = (IOReadB(VGA_CRTC_DATA_COLOR) & SVGA_CRTC_EXT_ADDR_BIT19) << 12;
732
735 StartAddress |= (Value & SVGA_CRTC_EXT_ADDR_BIT16) << 16;
736 StartAddress |= (Value & SVGA_CRTC_EXT_ADDR_BITS1718) << 15;
737
739 StartAddress |= IOReadB(VGA_CRTC_DATA_COLOR) << 8;
741 StartAddress |= IOReadB(VGA_CRTC_DATA_COLOR);
742
743 setCX(StartAddress % Mode->Info->BytesPerScanline);
744 setDX(StartAddress / Mode->Info->BytesPerScanline);
745
746 setAH(0);
747 break;
748 }
749 }
750
751 IOWriteB(VGA_CRTC_INDEX_COLOR, OldCrtcIndex);
752 break;
753 }
754
755 default:
756 {
757 DPRINT1("VESA BIOS Extensions function %02Xh NOT IMPLEMENTED!\n", getAL());
758 break;
759 }
760 }
761}
#define DPRINT1
Definition: precomp.h:8
CALLBACK16 BiosContext
Definition: bios32.c:45
#define SEG_OFF_TO_PTR(seg, off)
Definition: emulator.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_In_ ULONG Mode
Definition: hubbusif.h:303
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
if(dx< 0)
Definition: linetemp.h:194
#define LOWORD(l)
Definition: pedump.c:82
WORD * PWORD
Definition: pedump.c:67
BYTE VideoMode
Definition: bios.h:59
Definition: window.c:28
Definition: vbe.h:98
WORD VesaNumber
Definition: vbe.h:100
PCVBE_MODE VbeGetModeByNumber(WORD Number)
Definition: vbe.c:220
BOOLEAN WINAPI VbeSetExtendedVideoMode(BYTE ModeNumber)
Definition: vbe.c:356
struct _VBE_MODE_INFO VBE_MODE_INFO
struct _VBE_INFORMATION VBE_INFORMATION
PBIOS_DATA_AREA Bda
Definition: bios.c:42
#define VGA_INSTAT1_READ_COLOR
Definition: svga.h:45
#define SVGA_CRTC_EXT_ADDR_BIT16
Definition: svga.h:193
#define VGA_STAT_VRETRACE
Definition: svga.h:92
#define VGA_CRTC_INDEX_COLOR
Definition: svga.h:65
#define SVGA_CRTC_EXT_ADDR_BIT19
Definition: svga.h:199
#define VGA_CRTC_DATA_COLOR
Definition: svga.h:66
@ VGA_CRTC_START_ADDR_LOW_REG
Definition: svga.h:216
@ SVGA_CRTC_OVERLAY_REG
Definition: svga.h:233
@ VGA_CRTC_START_ADDR_HIGH_REG
Definition: svga.h:215
@ SVGA_CRTC_EXT_DISPLAY_REG
Definition: svga.h:231
#define VGA_NUM_BANKS
Definition: svga.h:14
@ SVGA_GC_OFFSET_1_REG
Definition: svga.h:279
#define SVGA_BANK_SIZE
Definition: svga.h:31
#define SVGA_CRTC_EXT_ADDR_BITS1718
Definition: svga.h:195
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
VOID WINAPI setBX(USHORT)
Definition: registers.c:177
UCHAR WINAPI getBH(VOID)
Definition: registers.c:184
VOID WINAPI setCX(USHORT)
Definition: registers.c:235
VOID WINAPI setDX(USHORT)
Definition: registers.c:293
USHORT WINAPI getBX(VOID)
Definition: registers.c:170
VOID WINAPI setAL(UCHAR)
Definition: registers.c:149
UCHAR WINAPI getAL(VOID)
Definition: registers.c:142
VOID WINAPI setCF(ULONG)
Definition: registers.c:573
VOID WINAPI setAH(UCHAR)
Definition: registers.c:135
USHORT WINAPI getCX(VOID)
Definition: registers.c:228
USHORT WINAPI getDX(VOID)
Definition: registers.c:286
USHORT WINAPI getES(VOID)
Definition: registers.c:522
USHORT WINAPI getDI(VOID)
Definition: registers.c:434
UCHAR WINAPI getDL(VOID)
Definition: registers.c:314
UCHAR WINAPI getBL(VOID)
Definition: registers.c:198
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
UCHAR WINAPI getDH(VOID)
Definition: registers.c:300
#define BIOS_MAX_VIDEO_MODE
Definition: vidbios.h:20
#define BIOS_VIDEO_INTERRUPT
Definition: vidbios.h:15
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define ZeroMemory
Definition: winbase.h:1712

Referenced by VidBiosVideoService().

◆ VbeSetExtendedRegisters()

static VOID VbeSetExtendedRegisters ( PSVGA_REGISTERS  Registers)
static

Definition at line 240 of file vbe.c.

241{
242 UINT i;
243
244 /* Disable interrupts */
245 BOOLEAN Interrupts = getIF();
246 setIF(0);
247
248 /*
249 * Set the CRT base address according to the selected mode,
250 * monochrome or color. The following macros:
251 * VGA_INSTAT1_READ, VGA_CRTC_INDEX and VGA_CRTC_DATA are then
252 * used to access the correct VGA I/O ports.
253 */
254 Bda->CrtBasePort = (Registers->Misc & 0x01) ? VGA_CRTC_INDEX_COLOR
256 /* Bit 1 indicates whether display is color (0) or monochrome (1) */
257 Bda->VGAOptions = (Bda->VGAOptions & 0xFD) | (!(Registers->Misc & 0x01) << 1);
258 Bda->CrtModeControl = (Bda->CrtModeControl & 0xFB) | (!(Registers->Misc & 0x01) << 1);
259
260 /* Update blink bit in BDA */
262 Bda->CrtModeControl |= (1 << 5);
263 else
264 Bda->CrtModeControl &= ~(1 << 5);
265
266 /* Turn the video off */
269
270 /* Write the misc register */
271 IOWriteB(VGA_MISC_WRITE, Registers->Misc);
272
273 /* Synchronous reset on */
276
277 /* Write the sequencer registers */
278 for (i = 1; i < SVGA_SEQ_MAX_REG; i++)
279 {
281 {
283 IOWriteB(VGA_SEQ_DATA , Registers->Sequencer[i]);
284 }
285 }
286
287 /* Synchronous reset off */
290
291 /* Unlock CRTC registers 0-7 */
296 // Make sure they remain unlocked
297 Registers->CRT[VGA_CRTC_END_HORZ_BLANKING_REG] |= 0x80;
298 Registers->CRT[VGA_CRTC_END_VERT_RETRACE_REG] &= ~0x80;
299
300 /* Write the CRTC registers */
301 for (i = 0; i < SVGA_CRTC_MAX_REG; i++)
302 {
303 if ((i < SVGA_CRTC_UNUSED0_REG || i > SVGA_CRTC_UNUSED6_REG) && i != SVGA_CRTC_UNUSED7_REG)
304 {
306 IOWriteB(VGA_CRTC_DATA , Registers->CRT[i]);
307 }
308 }
309
310 /* Write the GC registers */
311 for (i = 0; i < SVGA_GC_MAX_REG; i++)
312 {
314 && (i < SVGA_GC_UNUSED1_REG || i > SVGA_GC_UNUSED10_REG))
315 {
317 IOWriteB(VGA_GC_DATA , Registers->Graphics[i]);
318 }
319 }
320
321 /* Write the AC registers */
322 for (i = 0; i < VGA_AC_MAX_REG; i++)
323 {
324 /* Write the index */
325 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
327
328 /* Write the data */
329 IOWriteB(VGA_AC_WRITE, Registers->Attribute[i]);
330 }
331
332 /* Perform 4 dummy reads from the DAC mask to access the hidden register */
333 for (i = 0; i < 4; i++) IOReadB(VGA_DAC_MASK);
334
335 /* Set the hidden register */
336 IOWriteB(VGA_DAC_MASK, Registers->Hidden);
337
338 /* Set the PEL mask */
339 IOWriteB(VGA_DAC_MASK, 0xFF);
340
341 /* Enable screen and disable palette access */
342 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
343 IOWriteB(VGA_AC_INDEX, 0x20);
344
345 /* Turn the video on */
348
349 /* Restore interrupts */
350 setIF(Interrupts);
351}
unsigned int UINT
Definition: ndis.h:50
BYTE CrtModeControl
Definition: bios.h:68
WORD CrtBasePort
Definition: bios.h:67
BYTE VGAOptions
Definition: bios.h:91
UCHAR Sequencer[SVGA_SEQ_MAX_REG]
Definition: svga.h:379
UCHAR Hidden
Definition: svga.h:378
UCHAR CRT[SVGA_CRTC_MAX_REG]
Definition: svga.h:380
UCHAR Graphics[SVGA_GC_MAX_REG]
Definition: svga.h:381
UCHAR Misc
Definition: svga.h:377
UCHAR Attribute[VGA_AC_MAX_REG]
Definition: svga.h:382
#define VGA_MISC_WRITE
Definition: svga.h:40
@ VGA_AC_MAX_REG
Definition: svga.h:362
@ VGA_AC_CONTROL_REG
Definition: svga.h:357
#define VGA_AC_WRITE
Definition: svga.h:52
#define VGA_AC_INDEX
Definition: svga.h:51
#define VGA_CRTC_INDEX_MONO
Definition: svga.h:63
@ VGA_CRTC_END_VERT_RETRACE_REG
Definition: svga.h:220
@ VGA_CRTC_END_HORZ_BLANKING_REG
Definition: svga.h:206
@ SVGA_SEQ_MAX_REG
Definition: svga.h:163
#define VGA_AC_CONTROL_BLINK
Definition: svga.h:334
#define VGA_INSTAT1_READ
Definition: vidbios.h:113

Referenced by VbeSetExtendedVideoMode().

◆ VbeSetExtendedVideoMode()

BOOLEAN WINAPI VbeSetExtendedVideoMode ( BYTE  ModeNumber)

Definition at line 356 of file vbe.c.

357{
358 PCVBE_MODE Mode = VbeGetModeByNumber(ModeNumber);
359 if (Mode == NULL) return FALSE;
360
361 /* At this point, Mode->Registers shouldn't be NULL unless the mode is unimplemented */
362 if (Mode->Registers == NULL)
363 {
364 DPRINT1("Extended video mode %02X still UNIMPLEMENTED.\n", ModeNumber);
365 return FALSE;
366 }
367
368 /* Set the registers */
369 VbeSetExtendedRegisters(Mode->Registers);
370
371 /* Update the current video mode in the BDA */
372 Bda->VideoMode = ModeNumber;
373
374 /* Clear the screen */
376
377 return TRUE;
378}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static VOID VbeSetExtendedRegisters(PSVGA_REGISTERS Registers)
Definition: vbe.c:240
VOID VgaClearMemory(VOID)
Definition: svga.c:2074

Referenced by VbeService(), and VidBiosSetVideoMode().

Variable Documentation

◆ Modes

const VBE_MODE Modes[VBE_MODE_COUNT]
static
Initial value:
=
{
{ 0x14, 0xFFFF, NULL , NULL },
{ 0x54, 0x10A , NULL , NULL },
{ 0x55, 0x109 , NULL , NULL },
{ 0x58, 0x102 , NULL , NULL },
{ 0x5D, 0x104 , NULL , NULL },
{ 0x5E, 0x100 , NULL , NULL },
{ 0x60, 0x105 , NULL , NULL },
{ 0x64, 0x111 , NULL , NULL },
{ 0x65, 0x114 , NULL , NULL },
{ 0x66, 0x110 , NULL , NULL },
{ 0x67, 0x113 , NULL , NULL },
{ 0x68, 0x116 , NULL , NULL },
{ 0x69, 0x119 , NULL , NULL },
{ 0x6C, 0x106 , NULL , NULL },
{ 0x6D, 0x107 , NULL , NULL },
{ 0x71, 0x112 , NULL , NULL },
{ 0x72, 0xFFFF, NULL , NULL },
{ 0x73, 0xFFFF, NULL , NULL },
{ 0x74, 0x117 , NULL , NULL },
{ 0x75, 0x11A , NULL , NULL },
{ 0x76, 0xFFFF, NULL , NULL },
{ 0x78, 0x115 , NULL , NULL },
{ 0x79, 0x118 , NULL , NULL },
}
static SVGA_REGISTERS VbeMode_640x480x256_Registers
Definition: vbe.c:69
static SVGA_REGISTERS VbeMode_800x600x256_Registers
Definition: vbe.c:150
static const VBE_MODE_INFO VbeMode_640x480x256_Info
Definition: vbe.c:27
static const VBE_MODE_INFO VbeMode_800x600x256_Info
Definition: vbe.c:108

Definition at line 189 of file vbe.c.

Referenced by ddraw7_StartModeTest(), GetAvailableModes(), Pc98VidQueryNumAvailModes(), VbeGetModeByNumber(), VBEQueryNumAvailModes(), VbeService(), and XboxVmpQueryNumAvailModes().

◆ VbeMode_640x480x256_Info

const VBE_MODE_INFO VbeMode_640x480x256_Info
static

Definition at line 27 of file vbe.c.

◆ VbeMode_640x480x256_Registers

SVGA_REGISTERS VbeMode_640x480x256_Registers
static

Definition at line 69 of file vbe.c.

◆ VbeMode_800x600x256_Info

const VBE_MODE_INFO VbeMode_800x600x256_Info
static

Definition at line 108 of file vbe.c.

◆ VbeMode_800x600x256_Registers

SVGA_REGISTERS VbeMode_800x600x256_Registers
static

Definition at line 150 of file vbe.c.