ReactOS  0.4.14-dev-614-gbfd8a84
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 }
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
int32_t INT
Definition: typedefs.h:56
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
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
#define VBE_MODE_COUNT
Definition: vbe.h:19

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 }
#define OEM_NAME_PTR
Definition: vbe.h:17
#define SVGA_SEQ_UNLOCKED
Definition: svga.h:117
#define VGA_SEQ_INDEX
Definition: svga.h:55
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
unsigned char BOOLEAN
#define FAR_POINTER(x)
Definition: emulator.h:31
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
#define OEM_NAME
Definition: vbe.h:16
unsigned char BYTE
Definition: mem.h:68
#define VGA_SEQ_DATA
Definition: svga.h:56
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

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_SEQ_CLOCK_SD
Definition: svga.h:108
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
#define VGA_SEQ_RESET_AR
Definition: svga.h:100
#define VGA_SEQ_INDEX
Definition: svga.h:55
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
unsigned char BOOLEAN
#define VGA_GC_INDEX
Definition: svga.h:68
#define VGA_GC_DATA
Definition: svga.h:69
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
unsigned char BYTE
Definition: mem.h:68
ULONG WINAPI getIF(VOID)
Definition: registers.c:636
#define VGA_SEQ_DATA
Definition: svga.h:56
#define VGA_DAC_MASK
Definition: svga.h:58
VOID WINAPI setIF(ULONG)
Definition: registers.c:643
#define VGA_SEQ_RESET_SR
Definition: svga.h:101
#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 
487  ZeroMemory(&Info, sizeof(VBE_INFORMATION));
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  DPRINT("VESA INT 0x10, AL = 0x05, Unknown subfunction: %02X", 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 
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 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define VGA_CRTC_INDEX_COLOR
Definition: svga.h:65
USHORT WINAPI getBX(VOID)
Definition: registers.c:170
Definition: vbe.h:97
_In_ ULONG Mode
Definition: hubbusif.h:303
USHORT WINAPI getCX(VOID)
Definition: registers.c:228
VOID WINAPI setAH(UCHAR)
Definition: registers.c:135
BYTE VideoMode
Definition: bios.h:59
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
VOID WINAPI setAL(UCHAR)
Definition: registers.c:149
PBIOS_DATA_AREA Bda
Definition: bios.c:42
#define ZeroMemory
Definition: winbase.h:1642
UCHAR WINAPI getAL(VOID)
Definition: registers.c:142
UCHAR WINAPI getDH(VOID)
Definition: registers.c:300
#define SEG_OFF_TO_PTR(seg, off)
Definition: emulator.h:28
int32_t INT
Definition: typedefs.h:56
UCHAR WINAPI getDL(VOID)
Definition: registers.c:314
struct TraceInfo Info
#define BIOS_VIDEO_INTERRUPT
Definition: vidbios.h:15
#define SVGA_CRTC_EXT_ADDR_BIT19
Definition: svga.h:199
Definition: window.c:28
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
#define OEM_NAME_PTR
Definition: vbe.h:17
VOID WINAPI setCF(ULONG)
Definition: registers.c:573
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define SVGA_CRTC_EXT_ADDR_BITS1718
Definition: svga.h:195
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN WINAPI VbeSetExtendedVideoMode(BYTE ModeNumber)
Definition: vbe.c:356
WORD VesaNumber
Definition: vbe.h:100
#define VGA_GC_INDEX
Definition: svga.h:68
#define VGA_GC_DATA
Definition: svga.h:69
WORD * PWORD
Definition: pedump.c:67
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
if(!(yy_init))
Definition: macro.lex.yy.c:714
USHORT WINAPI getES(VOID)
Definition: registers.c:522
CALLBACK16 BiosContext
Definition: bios32.c:45
#define VGA_CRTC_DATA_COLOR
Definition: svga.h:66
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
UCHAR WINAPI getBH(VOID)
Definition: registers.c:184
VOID WINAPI setDX(USHORT)
Definition: registers.c:293
#define VGA_NUM_BANKS
Definition: svga.h:14
PCVBE_MODE VbeGetModeByNumber(WORD Number)
Definition: vbe.c:220
USHORT WINAPI getDX(VOID)
Definition: registers.c:286
unsigned char BYTE
Definition: mem.h:68
VOID WINAPI setBX(USHORT)
Definition: registers.c:177
#define VGA_INSTAT1_READ_COLOR
Definition: svga.h:45
UCHAR WINAPI getBL(VOID)
Definition: registers.c:198
#define BIOS_MAX_VIDEO_MODE
Definition: vidbios.h:20
struct _VBE_INFORMATION VBE_INFORMATION
USHORT WINAPI getDI(VOID)
Definition: registers.c:434
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define VBE_MODE_COUNT
Definition: vbe.h:19
VOID WINAPI setCX(USHORT)
Definition: registers.c:235
#define VGA_STAT_VRETRACE
Definition: svga.h:92
#define DPRINT1
Definition: precomp.h:8
struct _VBE_MODE_INFO VBE_MODE_INFO
#define SVGA_BANK_SIZE
Definition: svga.h:31
#define HIWORD(l)
Definition: typedefs.h:246
#define SVGA_CRTC_EXT_ADDR_BIT16
Definition: svga.h:193
#define LOWORD(l)
Definition: pedump.c:82

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  {
280  if (i != VGA_SEQ_MAX_REG && i != SVGA_SEQ_UNLOCK_REG)
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 }
#define VGA_CRTC_INDEX_COLOR
Definition: svga.h:65
UCHAR Attribute[VGA_AC_MAX_REG]
Definition: svga.h:382
#define VGA_SEQ_CLOCK_SD
Definition: svga.h:108
PBIOS_DATA_AREA Bda
Definition: bios.c:42
#define VGA_MISC_WRITE
Definition: svga.h:40
WORD CrtBasePort
Definition: bios.h:67
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
#define VGA_AC_INDEX
Definition: svga.h:51
#define VGA_INSTAT1_READ
Definition: vidbios.h:113
#define VGA_SEQ_RESET_AR
Definition: svga.h:100
#define VGA_SEQ_INDEX
Definition: svga.h:55
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
unsigned char BOOLEAN
#define VGA_AC_WRITE
Definition: svga.h:52
#define VGA_GC_INDEX
Definition: svga.h:68
#define VGA_GC_DATA
Definition: svga.h:69
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
UCHAR Hidden
Definition: svga.h:378
UCHAR CRT[SVGA_CRTC_MAX_REG]
Definition: svga.h:380
UCHAR Sequencer[SVGA_SEQ_MAX_REG]
Definition: svga.h:379
ULONG WINAPI getIF(VOID)
Definition: registers.c:636
BYTE CrtModeControl
Definition: bios.h:68
#define VGA_SEQ_DATA
Definition: svga.h:56
UCHAR Misc
Definition: svga.h:377
BYTE VGAOptions
Definition: bios.h:91
#define VGA_DAC_MASK
Definition: svga.h:58
unsigned int UINT
Definition: ndis.h:50
#define VGA_CRTC_INDEX_MONO
Definition: svga.h:63
VOID WINAPI setIF(ULONG)
Definition: registers.c:643
#define VGA_SEQ_RESET_SR
Definition: svga.h:101
#define VGA_CRTC_DATA
Definition: vidbios.h:115
#define VGA_CRTC_INDEX
Definition: vidbios.h:114
#define VGA_AC_CONTROL_BLINK
Definition: svga.h:334
UCHAR Graphics[SVGA_GC_MAX_REG]
Definition: svga.h:381

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 */
375  VgaClearMemory();
376 
377  return TRUE;
378 }
#define TRUE
Definition: types.h:120
Definition: vbe.h:97
_In_ ULONG Mode
Definition: hubbusif.h:303
BYTE VideoMode
Definition: bios.h:59
PBIOS_DATA_AREA Bda
Definition: bios.c:42
VOID VgaClearMemory(VOID)
Definition: svga.c:2074
static VOID VbeSetExtendedRegisters(PSVGA_REGISTERS Registers)
Definition: vbe.c:240
smooth NULL
Definition: ftsmooth.c:416
PCVBE_MODE VbeGetModeByNumber(WORD Number)
Definition: vbe.c:220
#define DPRINT1
Definition: precomp.h:8

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
smooth NULL
Definition: ftsmooth.c:416
static const VBE_MODE_INFO VbeMode_640x480x256_Info
Definition: vbe.c:27
static SVGA_REGISTERS VbeMode_800x600x256_Registers
Definition: vbe.c:150
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(), 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.