ReactOS  0.4.13-dev-698-g77671f0
vidbios32.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "cpu/bop.h"
#include "int32.h"
#include "vidbios32.h"
#include <bios/vidbios.h>
#include "bios32p.h"
Include dependency graph for vidbios32.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define BOP_VIDEO_INT   0x10
 

Functions

VOID WINAPI VidBiosVideoService (LPWORD Stack)
 
static VOID WINAPI VidBiosINT (LPWORD Stack)
 
BOOLEAN VidBios32Initialize (VOID)
 
VOID VidBios32Cleanup (VOID)
 

Macro Definition Documentation

◆ BOP_VIDEO_INT

#define BOP_VIDEO_INT   0x10

Definition at line 29 of file vidbios32.c.

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file vidbios32.c.

Function Documentation

◆ VidBios32Cleanup()

VOID VidBios32Cleanup ( VOID  )

Definition at line 67 of file vidbios32.c.

68 {
69  /* Unregister the BIOS support BOPs */
71 }
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
Definition: bop.c:29
smooth NULL
Definition: ftsmooth.c:416
#define BOP_VIDEO_INT
Definition: vidbios32.c:29

Referenced by Bios32Cleanup().

◆ VidBios32Initialize()

BOOLEAN VidBios32Initialize ( VOID  )

Definition at line 60 of file vidbios32.c.

61 {
62  /* Register the BIOS support BOPs */
64  return TRUE;
65 }
#define TRUE
Definition: types.h:120
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
Definition: bop.c:29
static VOID WINAPI VidBiosINT(LPWORD Stack)
Definition: vidbios32.c:34
#define BOP_VIDEO_INT
Definition: vidbios32.c:29

Referenced by VidBiosInitialize().

◆ VidBiosINT()

static VOID WINAPI VidBiosINT ( LPWORD  Stack)
static

Definition at line 34 of file vidbios32.c.

35 {
36  /*
37  * Set up a false stack to hardwire the BOP function (that can directly
38  * manipulate CPU registers) to the 32-bit interrupt function (which uses
39  * the stack to be able to modify the original CS:IP and FLAGS).
40  *
41  * See int32.h stack codes.
42  */
43  WORD EmuStack[4];
44  DWORD Flags = getEFLAGS();
45 
46  DPRINT1("Calling BOP VidBiosINT\n");
47 
48  EmuStack[STACK_FLAGS] = LOWORD(Flags);
49  EmuStack[STACK_CS] = getCS();
50  EmuStack[STACK_IP] = getIP();
51  EmuStack[STACK_INT_NUM] = BOP_VIDEO_INT;
52 
53  VidBiosVideoService(EmuStack);
54 
55  setIP(EmuStack[STACK_IP]);
56  setCS(EmuStack[STACK_CS]);
58 }
#define STACK_INT_NUM
Definition: int32.h:30
VOID WINAPI setIP(USHORT)
Definition: registers.c:471
VOID WINAPI VidBiosVideoService(LPWORD Stack)
Definition: vidbios.c:2947
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG WINAPI getEFLAGS(VOID)
Definition: registers.c:680
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define STACK_FLAGS
Definition: int32.h:35
USHORT WINAPI getIP(VOID)
Definition: registers.c:464
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WINAPI setEFLAGS(ULONG)
Definition: registers.c:687
#define STACK_CS
Definition: int32.h:34
VOID WINAPI setCS(USHORT)
Definition: registers.c:487
#define DPRINT1
Definition: precomp.h:8
#define HIWORD(l)
Definition: typedefs.h:246
#define BOP_VIDEO_INT
Definition: vidbios32.c:29
#define STACK_IP
Definition: int32.h:33
USHORT WINAPI getCS(VOID)
Definition: registers.c:480
#define LOWORD(l)
Definition: pedump.c:82

Referenced by VidBios32Initialize().

◆ VidBiosVideoService()

VOID WINAPI VidBiosVideoService ( LPWORD  Stack)

Definition at line 2947 of file vidbios.c.

2948 {
2949  switch (getAH())
2950  {
2951  /* Set Video Mode */
2952  case 0x00:
2953  {
2955  break;
2956  }
2957 
2958  /* Set Text-Mode Cursor Shape */
2959  case 0x01:
2960  {
2962  break;
2963  }
2964 
2965  /* Set Cursor Position */
2966  case 0x02:
2967  {
2968  BYTE Page = getBH();
2969 
2970  /* Validate the selected video page */
2971  if (Page >= BIOS_MAX_PAGES) break;
2972 
2973  VidBiosSetCursorPosition(getDH(), getDL(), Page);
2974  break;
2975  }
2976 
2977  /* Get Cursor Position and Shape */
2978  case 0x03:
2979  {
2980  BYTE Page = getBH();
2981 
2982  /* Validate the selected video page */
2983  if (Page == 0xFF) // Special case: use the current video page
2984  Page = Bda->VideoPage;
2985  else if (Page >= BIOS_MAX_PAGES)
2986  break;
2987 
2988  /* Return the result */
2990  setDX(Bda->CursorPosition[Page]);
2991  break;
2992  }
2993 
2994  /* Query Light Pen */
2995  case 0x04:
2996  {
2997  /*
2998  * On modern BIOSes, this function returns 0
2999  * so that we can ignore the other registers.
3000  */
3001  setAX(0);
3002  break;
3003  }
3004 
3005  /* Select Active Display Page */
3006  case 0x05:
3007  {
3009  break;
3010  }
3011 
3012  /* Scroll Window Up/Down */
3013  case 0x06:
3014  case 0x07:
3015  {
3016  SMALL_RECT Rectangle = { getCL(), getCH(), getDL(), getDH() };
3017 
3019  getAL(), Rectangle, Bda->VideoPage, getBH());
3020 
3021  break;
3022  }
3023 
3024  /* Read Character and Attribute at Cursor Position */
3025  case 0x08:
3026  {
3027  WORD CharData;
3028  BYTE Page = getBH();
3029  DWORD Offset;
3030 
3031  /* Validate the selected video page */
3032  if (Page == 0xFF) // Special case: use the current video page
3033  Page = Bda->VideoPage;
3034  else if (Page >= BIOS_MAX_PAGES)
3035  break;
3036 
3037  /* Find the offset of the character */
3038  Offset = Page * Bda->VideoPageSize +
3039  (HIBYTE(Bda->CursorPosition[Page]) * Bda->ScreenColumns +
3040  LOBYTE(Bda->CursorPosition[Page])) * 2;
3041 
3042  /* Read from the video memory */
3045  (LPVOID)&CharData,
3046  sizeof(WORD));
3047 
3048  /* Return the character data in AX */
3049  setAX(CharData);
3050 
3051  break;
3052  }
3053 
3054  /* Write Character and Attribute at Cursor Position */
3055  case 0x09:
3056  /* Write Character only (PCjr: + Attribute) at Cursor Position */
3057  case 0x0A:
3058  {
3059  WORD Counter = getCX();
3060  WORD CharData = MAKEWORD(getAL(), getBL());
3061  BOOLEAN UseAttr = (getAH() == 0x09);
3062  BYTE Page = getBH();
3063  BYTE Row, Column;
3064 
3065  /* Validate the selected video page */
3066  if (Page == 0xFF) // Special case: use the current video page
3067  Page = Bda->VideoPage;
3068  else if (Page >= BIOS_MAX_PAGES)
3069  break;
3070 
3071  /* Get the cursor position */
3072  VidBiosGetCursorPosition(&Row, &Column, Page);
3073 
3074  /* Write to video memory a certain number of times */
3075  while (Counter-- > 0)
3076  {
3077  /* Write the character and advance the position */
3078  VidBiosDrawGlyph(CharData, UseAttr, Page, Row, Column);
3079  Column++;
3080 
3081  /* Check if it passed the end of the row */
3082  if (Column >= Bda->ScreenColumns)
3083  {
3084  /* Return to the first column and go to the next line */
3085  Column = 0;
3086  Row++;
3087  }
3088 
3089  /* Contrary to the "Teletype Output" function, the screen is not scrolled */
3090  if (Row > Bda->ScreenRows)
3091  {
3092  Row = Bda->ScreenRows;
3093  }
3094  }
3095 
3096  break;
3097  }
3098 
3099  /* Set Video Colors */
3100  case 0x0B:
3101  {
3102  if (Bda->VideoMode < 0x04 || Bda->VideoMode > 0x06)
3103  {
3104  DPRINT1("BIOS Function INT 10h, AH = 0Bh, BH = 0x%02X is unsupported for non-CGA modes\n",
3105  getBH());
3106  break;
3107  }
3108 
3109  switch (getBH())
3110  {
3111  case 0x00: /* Set Background/Border Color */
3112  {
3113 #ifdef DOSBOX
3114  BYTE Index = getBL();
3115 
3116  /* See: http://www.bioscentral.com/misc/bda.htm */
3117  Bda->CrtColorPaletteMask = (Bda->CrtColorPaletteMask & 0xE0) | (Index & 0x1F);
3118 
3119  Index = ((Index << 1) & 0x10) | (Index & 0x7);
3120 
3121  /* Always set the overscan color */
3123 
3124  /* Don't set any extra colors when in text mode */
3125  if (Bda->VideoMode <= 0x03) break;
3126 
3128 
3129  Index = (Bda->CrtColorPaletteMask & 0x10) | 0x02 | ((Bda->CrtColorPaletteMask & 0x20) >> 5);
3130 
3132  Index += 2;
3134  Index += 2;
3136 #else
3137  /* Background/Border Color is modifiable via the first index */
3139 #endif
3140 
3141  /* Enable screen and disable palette access */
3142  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3143  IOWriteB(VGA_AC_INDEX, 0x20);
3144  break;
3145  }
3146 
3147  case 0x01: /* Set Palette */
3148  {
3149  BYTE Index = getBL();
3150 
3151  /* See: http://www.bioscentral.com/misc/bda.htm */
3152  /* Reset bit 5: foreground colors index (0: green/red/yellow; 1: cyan/magenta/white) */
3153  Bda->CrtColorPaletteMask = (Bda->CrtColorPaletteMask & 0xDF) | ((Index & 1) ? 0x20 : 0x00);
3154 
3155  /* Don't set any extra colors when in text mode */
3156  if (Bda->VideoMode <= 0x03) break;
3157 
3158  Index = (Bda->CrtColorPaletteMask & 0x10) | 0x02 | Index;
3159 
3161  Index += 2;
3163  Index += 2;
3165 
3166  /* Enable screen and disable palette access */
3167  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3168  IOWriteB(VGA_AC_INDEX, 0x20);
3169  break;
3170  }
3171 
3172  default:
3173  DPRINT1("BIOS Function INT 10h, AH = 0Bh, BH = 0x%02X NOT IMPLEMENTED\n",
3174  getAH(), getBH());
3175  break;
3176  }
3177 
3178  break;
3179  }
3180 
3181  /* Teletype Output */
3182  case 0x0E:
3183  {
3184  BYTE Page = getBH();
3185 
3186  /* Validate the selected video page */
3187  if (Page == 0xFF) // Special case: use the current video page
3188  Page = Bda->VideoPage;
3189  else if (Page >= BIOS_MAX_PAGES)
3190  break;
3191 
3193  break;
3194  }
3195 
3196  /* Get Current Video Mode */
3197  case 0x0F:
3198  {
3200  setBH(Bda->VideoPage);
3201  break;
3202  }
3203 
3204  /* Palette Control */
3205  case 0x10:
3206  {
3207  switch (getAL())
3208  {
3209  /* Set Single Palette Register */
3210  case 0x00:
3211  {
3213 
3214  /* Enable screen and disable palette access */
3215  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3216  IOWriteB(VGA_AC_INDEX, 0x20);
3217  break;
3218  }
3219 
3220  /* Set Overscan Color */
3221  case 0x01:
3222  {
3224 
3225  /* Enable screen and disable palette access */
3226  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3227  IOWriteB(VGA_AC_INDEX, 0x20);
3228  break;
3229  }
3230 
3231  /* Set All Palette Registers */
3232  case 0x02:
3233  {
3234  UINT i;
3236 
3237  /* Set the palette registers */
3238  for (i = 0; i <= VGA_AC_PAL_F_REG; i++)
3239  {
3241  }
3242 
3243  /* Set the overscan register */
3244  // VgaSetSinglePaletteRegister(VGA_AC_OVERSCAN_REG, Buffer[VGA_AC_PAL_F_REG + 1]);
3248 
3249  /* Enable screen and disable palette access */
3250  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3251  IOWriteB(VGA_AC_INDEX, 0x20);
3252  break;
3253  }
3254 
3255  /* Toggle Intensity/Blinking Bit */
3256  case 0x03:
3257  {
3258  /* Read the old AC mode control register value */
3259  BYTE VgaAcControlReg;
3260 
3263  VgaAcControlReg = IOReadB(VGA_AC_READ);
3264 
3265  /* Toggle the blinking bit and write the new value */
3266  if (getBL())
3267  {
3268  VgaAcControlReg |= VGA_AC_CONTROL_BLINK;
3269  Bda->CrtModeControl |= (1 << 5);
3270  }
3271  else
3272  {
3273  VgaAcControlReg &= ~VGA_AC_CONTROL_BLINK;
3274  Bda->CrtModeControl &= ~(1 << 5);
3275  }
3276 
3279  IOWriteB(VGA_AC_WRITE, VgaAcControlReg);
3280 
3281  /* Enable screen and disable palette access */
3282  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3283  IOWriteB(VGA_AC_INDEX, 0x20);
3284  break;
3285  }
3286 
3287  /* Get Single Palette Register */
3288  case 0x07:
3289  {
3290  /* Write the index */
3291  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3293 
3294  /* Read the data */
3296 
3297  /* Enable screen and disable palette access */
3298  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3299  IOWriteB(VGA_AC_INDEX, 0x20);
3300  break;
3301  }
3302 
3303  /* Get Overscan Color */
3304  case 0x08:
3305  {
3306  /* Write the index */
3307  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3309 
3310  /* Read the data */
3312 
3313  /* Enable screen and disable palette access */
3314  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3315  IOWriteB(VGA_AC_INDEX, 0x20);
3316  break;
3317  }
3318 
3319  /* Get All Palette Registers */
3320  case 0x09:
3321  {
3322  UINT i;
3324 
3325  /* Get the palette registers */
3326  for (i = 0; i <= VGA_AC_PAL_F_REG; i++)
3327  {
3328  /* Write the index */
3329  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3331 
3332  /* Read the data */
3334  }
3335 
3336  /* Get the overscan register */
3340 
3341  /* Enable screen and disable palette access */
3342  IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3343  IOWriteB(VGA_AC_INDEX, 0x20);
3344  break;
3345  }
3346 
3347  /* Set Individual DAC Register */
3348  case 0x10:
3349  {
3350  /* Write the index */
3351  // Certainly in BL and not in BX as said by Ralf Brown...
3353 
3354  /* Write the data in this order: Red, Green, Blue */
3358 
3359  break;
3360  }
3361 
3362  /* Set Block of DAC Registers */
3363  case 0x12:
3364  {
3365  UINT i;
3367 
3368  /* Write the index */
3369  // Certainly in BL and not in BX as said by Ralf Brown...
3371 
3372  for (i = 0; i < getCX(); i++)
3373  {
3374  /* Write the data in this order: Red, Green, Blue */
3378  }
3379 
3380  break;
3381  }
3382 
3383  /* Set Video DAC Color Page */
3384  case 0x13:
3385  {
3386  if (getBL() == 0)
3387  {
3388  /* Set the highest bit of the AC Mode Control register to BH */
3391  IOWriteB(VGA_AC_WRITE, (IOReadB(VGA_AC_READ) & 0x7F) | (getBH() << 7));
3392  }
3393  else if (getBL() == 1)
3394  {
3395  /* Set the AC Color Select register to BH */
3399  }
3400  else
3401  {
3402  DPRINT1("BIOS Palette Control Sub-sub-command BL = 0x%02X INVALID\n", getBL());
3403  }
3404 
3405  break;
3406  }
3407 
3408  /* Get Individual DAC Register */
3409  case 0x15:
3410  {
3411  /* Write the index */
3413 
3414  /* Read the data in this order: Red, Green, Blue */
3418 
3419  break;
3420  }
3421 
3422  /* Get Block of DAC Registers */
3423  case 0x17:
3424  {
3425  UINT i;
3427 
3428  /* Write the index */
3429  // Certainly in BL and not in BX as said by Ralf Brown...
3431 
3432  for (i = 0; i < getCX(); i++)
3433  {
3434  /* Write the data in this order: Red, Green, Blue */
3435  *Buffer++ = IOReadB(VGA_DAC_DATA);
3436  *Buffer++ = IOReadB(VGA_DAC_DATA);
3437  *Buffer++ = IOReadB(VGA_DAC_DATA);
3438  }
3439 
3440  break;
3441  }
3442 
3443  /* Set PEL Mask */
3444  case 0x18:
3445  {
3447  break;
3448  }
3449 
3450  /* Get PEL Mask */
3451  case 0x19:
3452  {
3454  break;
3455  }
3456 
3457  default:
3458  {
3459  DPRINT1("BIOS Palette Control Sub-command AL = 0x%02X NOT IMPLEMENTED\n",
3460  getAL());
3461  break;
3462  }
3463  }
3464 
3465  break;
3466  }
3467 
3468  /* Font Control */
3469  case 0x11:
3470  {
3471  switch (getAL())
3472  {
3473  // FIXME: At the moment we support only graphics-mode functions!
3474 
3475  /* Load User-specified Patterns (Character Set) for Text Mode */
3476  case 0x00:
3477  case 0x10: // FIXME: 0x1x performs a full mode reset
3478  {
3479  // FIXME: BL == ??
3480 
3481  /* Write the default font to the VGA font plane */
3482  // VgaWriteTextModeFont(0, Font8x8, ARRAYSIZE(Font8x8) / VGA_FONT_CHARACTERS);
3483 
3484  UNIMPLEMENTED;
3485  break;
3486  }
3487 
3488  /* Load ROM Monochrome 8x14 Patterns (Character Set) for Text Mode */
3489  case 0x01:
3490  case 0x11: // FIXME: 0x1x performs a full mode reset
3491  {
3492  // FIXME: BL == ??
3493 
3494  /* Write the default font to the VGA font plane */
3496 
3497  UNIMPLEMENTED;
3498  break;
3499  }
3500 
3501  /* Load ROM 8x8 Double-dot Patterns (Character Set) for Text Mode */
3502  case 0x02:
3503  case 0x12: // FIXME: 0x1x performs a full mode reset
3504  {
3505  // FIXME: BL == ??
3506 
3507  /* Write the default font to the VGA font plane */
3509 
3510  UNIMPLEMENTED;
3511  break;
3512  }
3513 
3514  /* Load ROM 8x16 Character Set for Text Mode */
3515  case 0x04:
3516  case 0x14: // FIXME: 0x1x performs a full mode reset
3517  {
3518  // FIXME: BL == ??
3519 
3520  /* Write the default font to the VGA font plane */
3522 
3523  UNIMPLEMENTED;
3524  break;
3525  }
3526 
3527  /* Set User 8x8 Graphics Chars (Setup INT 1Fh Vector) */
3528  case 0x20:
3529  {
3530  /* Update the BIOS INT 1Fh vector to user-defined ES:BP pointer */
3531  // Far pointer to the 8x8 characters 80h-FFh
3532  ((PULONG)BaseAddress)[0x1F] = MAKELONG(getBP(), getES());
3533  break;
3534  }
3535 
3536  /* Set User Graphics Characters */
3537  case 0x21:
3538  {
3539  /*
3540  * Update the BIOS INT 43h vector (far pointer
3541  * to the character range 00h-...)
3542  */
3543  ((PULONG)BaseAddress)[0x43] = MAKELONG(getBP(), getES());
3544 
3545  /* Update BDA */
3546  Bda->CharacterHeight = getCX();
3547  switch (getBL())
3548  {
3549  case 0x00: Bda->ScreenRows = getDL()-1; break;
3550  case 0x01: Bda->ScreenRows = 13; break;
3551  case 0x03: Bda->ScreenRows = 42; break;
3552  case 0x02:
3553  default : Bda->ScreenRows = 24; break;
3554  }
3555 
3556  break;
3557  }
3558 
3559  /* Setup ROM 8x14 Font for Graphics Mode */
3560  case 0x22:
3561  {
3562  /*
3563  * Update the BIOS INT 43h vector (far pointer
3564  * to the character range 00h-...)
3565  */
3567 
3568  /* Update BDA */
3569  Bda->CharacterHeight = 14;
3570  switch (getBL())
3571  {
3572  case 0x00: Bda->ScreenRows = getDL()-1; break;
3573  case 0x01: Bda->ScreenRows = 13; break;
3574  case 0x03: Bda->ScreenRows = 42; break;
3575  case 0x02:
3576  default : Bda->ScreenRows = 24; break;
3577  }
3578 
3579  break;
3580  }
3581 
3582  /* Setup ROM 8x8 Font for Graphics Mode */
3583  case 0x23:
3584  {
3585  /*
3586  * Update the BIOS INT 43h vector (far pointer
3587  * to the character range 00h-...)
3588  */
3590 
3591  /* Update BDA */
3592  Bda->CharacterHeight = 8;
3593  switch (getBL())
3594  {
3595  case 0x00: Bda->ScreenRows = getDL()-1; break;
3596  case 0x01: Bda->ScreenRows = 13; break;
3597  case 0x03: Bda->ScreenRows = 42; break;
3598  case 0x02:
3599  default : Bda->ScreenRows = 24; break;
3600  }
3601 
3602  break;
3603  }
3604 
3605  /* Setup ROM 8x16 Font for Graphics Mode */
3606  case 0x24:
3607  {
3608  /*
3609  * Update the BIOS INT 43h vector (far pointer
3610  * to the character range 00h-...).
3611  */
3613 
3614  /* Update BDA */
3615  Bda->CharacterHeight = 16;
3616  switch (getBL())
3617  {
3618  case 0x00: Bda->ScreenRows = getDL()-1; break;
3619  case 0x01: Bda->ScreenRows = 13; break;
3620  case 0x03: Bda->ScreenRows = 42; break;
3621  case 0x02:
3622  default : Bda->ScreenRows = 24; break;
3623  }
3624 
3625  break;
3626  }
3627 
3628  /* Get Current Character Font Information */
3629  case 0x30:
3630  {
3631  ULONG Address = NULL32;
3632 
3633  switch (getBH())
3634  {
3635  /* 00h - INT 0x1F pointer */
3636  case 0x00:
3637  Address = ((PULONG)BaseAddress)[0x1F];
3638  break;
3639 
3640  /* 01h - INT 0x43 pointer */
3641  case 0x01:
3642  Address = ((PULONG)BaseAddress)[0x43];
3643  break;
3644 
3645  /* 02h - 8x14 font */
3646  case 0x02:
3648  break;
3649 
3650  /* 03h - 8x8 font */
3651  case 0x03:
3653  break;
3654 
3655  /* 04h - 8x8 font, upper half */
3656  case 0x04:
3658  break;
3659 
3660  /* 05h - NOT IMPLEMENTED - 9x14 font */
3661  case 0x05:
3662  break;
3663 
3664  /* 06h - 8x16 font */
3665  case 0x06:
3667  break;
3668 
3669  /* 07h - NOT IMPLEMENTED - 9x16 font */
3670  case 0x07:
3671  break;
3672 
3673  default:
3674  DPRINT1("INT 10h, AL=30h Function BH = 0x%02X NOT IMPLEMENTED\n",
3675  getBH());
3676  }
3677 
3678  /* Return the data */
3679  setES(HIWORD(Address));
3680  setBP(LOWORD(Address));
3682  setDL(Bda->ScreenRows);
3683 
3684  break;
3685  }
3686 
3687  default:
3688  {
3689  DPRINT1("BIOS Font Control Sub-command AL = 0x%02X NOT IMPLEMENTED\n",
3690  getAL());
3691  }
3692  }
3693 
3694  break;
3695  }
3696 
3697  /* Alternate Function Select */
3698  case 0x12:
3699  {
3700  switch (getBL())
3701  {
3702  /* Get EGA/VGA Information */
3703  case 0x10:
3704  {
3705  setBH((Bda->VGAOptions & 0x02) >> 1); /* Color (0) or monochrome (1) display */
3706  setBL((Bda->VGAOptions & 0x60) >> 5); /* Video RAM size */
3707  setCH((Bda->VGASwitches & 0xF0) >> 4); /* Features settings */
3708  setCL( Bda->VGASwitches & 0x0F); /* Switches settings */
3709  break;
3710  }
3711 
3712  /* Enable/Disable Cursor Emulation */
3713  case 0x34:
3714  {
3715  BYTE State = getAL();
3716 
3717  /* Check for validity */
3718  if (State > 1) break;
3719 
3720  /*
3721  * Enable (State == 0) or disable (State == 1) cursor emulation.
3722  * Please read the WARNING in the 'VidBiosSetCursorShape'
3723  * function for more details.
3724  */
3725  Bda->VGAOptions = (Bda->VGAOptions & 0xFE) | (State & 0x01);
3726 
3727  /* Return success */
3728  setAL(0x12);
3729  break;
3730  }
3731 
3732  /* Enable/Disable screen refresh */
3733  case 0x36:
3734  {
3735  BYTE State = getAL();
3736  BYTE Clocking;
3737 
3738  /* Check for validity */
3739  if (State > 1) break;
3740 
3741  /* Turn the video on (State == 0) or off (State == 1) */
3743  Clocking = IOReadB(VGA_SEQ_DATA);
3744 
3745  if (State == 0)
3746  Clocking &= ~VGA_SEQ_CLOCK_SD;
3747  else
3748  Clocking |= VGA_SEQ_CLOCK_SD;
3749 
3750  IOWriteB(VGA_SEQ_DATA, Clocking);
3751 
3752  /* Return success */
3753  setAL(0x12);
3754  break;
3755  }
3756 
3757  default:
3758  {
3759  DPRINT1("BIOS Function INT 10h, AH = 12h (Alternate Function Select), BX = 0x%04X NOT IMPLEMENTED\n",
3760  getBX());
3761  break;
3762  }
3763  }
3764 
3765  break;
3766  }
3767 
3768  /* Write String */
3769  case 0x13:
3770  {
3772  WORD Counter = getCX();
3773  BYTE Row, Column;
3774  BYTE OldRow, OldColumn;
3775  CHAR Character;
3776  BYTE Attribute = getBL(); // Default attribute in case the string contains only characters.
3777  BYTE Page = getBH();
3778  BYTE Flags = getAL();
3779 
3780  /* Validate the selected video page */
3781  if (Page == 0xFF) // Special case: use the current video page
3782  Page = Bda->VideoPage;
3783  else if (Page >= BIOS_MAX_PAGES)
3784  break;
3785 
3786  /* Get the original cursor position */
3787  VidBiosGetCursorPosition(&OldRow, &OldColumn, Page);
3788 
3789  /* Set the new cursor position */
3790  Row = getDH();
3791  Column = getDL();
3792  if (Row == 0xFF) // Special case: use the current cursor position
3793  {
3794  Row = OldRow;
3795  Column = OldColumn;
3796  }
3797  VidBiosSetCursorPosition(Row, Column, Page);
3798 
3799  while (Counter-- > 0)
3800  {
3801  Character = *String++;
3802  if (Flags & 0x02) Attribute = *String++;
3803  VidBiosPrintCharacter(Character, Attribute, TRUE, Page);
3804  }
3805 
3806  /* Reset the cursor position to its original value if we don't want to update it */
3807  if (!(Flags & 0x01)) VidBiosSetCursorPosition(OldRow, OldColumn, Page);
3808 
3809  break;
3810  }
3811 
3812  /* Get/Set Display combination code */
3813  case 0x1A:
3814  {
3815  switch (getAL())
3816  {
3817  case 0x00: /* Get Display combination code */
3818  {
3820  setBH(0x00); // No alternate display
3821 
3822  /* Return success */
3823  setAL(0x1A);
3824  break;
3825  }
3826  case 0x01: /* Set Display combination code */
3827  {
3828  DPRINT1("Set Display combination code - Unsupported\n");
3829  break;
3830  }
3831  default:
3832  break;
3833  }
3834  break;
3835  }
3836 
3837  /* Functionality/State Information (VGA) */
3838  case 0x1B:
3839  {
3841 
3842  /* Check for only supported subfunction */
3843  if (getBX() != 0x0000)
3844  {
3845  DPRINT1("INT 10h, AH=1Bh, unsupported subfunction 0x%04x\n", getBX());
3846  break;
3847  }
3848 
3849  /* Fill the VGA dynamic functionality table with our information */
3850 
3852 
3853  Table->VideoMode = Bda->VideoMode;
3854  Table->ScreenColumns = Bda->ScreenColumns;
3855  Table->VideoPageSize = Bda->VideoPageSize;
3856  Table->VideoPageOffset = Bda->VideoPageOffset;
3857  RtlCopyMemory(Table->CursorPosition, Bda->CursorPosition, sizeof(Bda->CursorPosition));
3858  Table->CursorEndLine = Bda->CursorEndLine;
3859  Table->CursorStartLine = Bda->CursorStartLine;
3860  Table->VideoPage = Bda->VideoPage;
3861  Table->CrtBasePort = Bda->CrtBasePort;
3862  Table->CrtModeControl = Bda->CrtModeControl;
3863  Table->CrtColorPaletteMask = Bda->CrtColorPaletteMask;
3864  Table->ScreenRows = Bda->ScreenRows;
3865  Table->CharacterHeight = Bda->CharacterHeight;
3866 
3867  Table->VGADccIDActive = Bda->VGADccIDActive;
3868  Table->VGADccIDAlternate = 0x00; // No alternate display
3869  // Table->CurrModeSupportedColorsNum;
3870  // Table->CurrModeSupportedPagesNum;
3871  // Table->Scanlines;
3872  // Table->PrimaryCharTable;
3873  // Table->SecondaryCharTable;
3874  // Table->VGAFlags;
3875  Table->VGAAvailMemory = (Bda->VGAOptions & 0x60) >> 5;
3876  // Table->VGASavePtrStateFlags;
3877  // Table->VGADispInfo;
3878  UNIMPLEMENTED;
3879 
3880  /* Return success */
3881  setAL(0x1B);
3882  break;
3883  }
3884 
3885  /* VESA BIOS Extensions */
3886  case 0x4F:
3887  {
3888  if (VbeInitialized) VbeService(Stack);
3889  break;
3890  }
3891 
3892  default:
3893  {
3894  DPRINT1("BIOS Function INT 10h, AH = 0x%02X, AL = 0x%02X, BH = 0x%02X NOT IMPLEMENTED\n",
3895  getAH(), getAL(), getBH());
3896  }
3897  }
3898 }
signed char * PCHAR
Definition: retypes.h:7
#define VGA_SEQ_CLOCK_SD
Definition: svga.h:108
WORD CursorPosition[BIOS_MAX_PAGES]
Definition: bios.h:63
ASMGENDATA Table[]
Definition: genincdata.c:61
static VOID VidBiosPrintCharacter(CHAR Character, BYTE Attribute, BOOLEAN UseAttr, BYTE Page)
Definition: vidbios.c:2863
USHORT WINAPI getBX(VOID)
Definition: registers.c:170
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BYTE VideoPage
Definition: bios.h:66
VOID WINAPI setBL(UCHAR)
Definition: registers.c:205
VOID VgaWriteTextModeFont(UINT FontNumber, CONST UCHAR *FontData, UINT Height)
Definition: svga.c:2079
UCHAR WINAPI getCL(VOID)
Definition: registers.c:256
BYTE ScreenRows
Definition: bios.h:89
VOID WINAPI VbeService(LPWORD Stack)
Definition: vbe.c:472
WORD VideoPageOffset
Definition: bios.h:62
static BOOLEAN VbeInitialized
Definition: vidbios.c:1969
#define FONT_8x14_OFFSET
Definition: vidbios.h:32
#define LOBYTE(W)
Definition: jmemdos.c:487
#define BIOS_MAX_PAGES
Definition: vidbios.h:19
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define MAKEWORD(a, b)
Definition: typedefs.h:247
USHORT WINAPI getCX(VOID)
Definition: registers.c:228
VOID WINAPI setCH(UCHAR)
Definition: registers.c:249
BYTE VideoMode
Definition: bios.h:59
BYTE CursorStartLine
Definition: bios.h:65
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
char CHAR
Definition: xmlstorage.h:175
static VOID VidBiosDrawGlyph(WORD CharData, BOOLEAN UseAttr, BYTE Page, BYTE Row, BYTE Column)
Definition: vidbios.c:2619
#define HIBYTE(W)
Definition: jmemdos.c:486
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
VOID WINAPI setAL(UCHAR)
Definition: registers.c:149
PBIOS_DATA_AREA Bda
Definition: bios.c:42
BYTE VGASwitches
Definition: bios.h:92
UCHAR WINAPI getAH(VOID)
Definition: registers.c:128
static WCHAR String[]
Definition: stringtable.c:55
#define VGA_DAC_READ_INDEX
Definition: svga.h:59
WORD VideoPageSize
Definition: bios.h:61
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
UCHAR WINAPI getDL(VOID)
Definition: registers.c:314
WORD CrtBasePort
Definition: bios.h:67
VOID WINAPI setES(USHORT)
Definition: registers.c:529
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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
unsigned char * LPBYTE
Definition: typedefs.h:52
#define VGA_INSTAT1_READ
Definition: vidbios.h:113
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TEXT_VIDEO_SEG
Definition: vidbios.h:24
#define VGA_SEQ_INDEX
Definition: svga.h:55
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
WORD CharacterHeight
Definition: bios.h:90
#define MAKELONG(a, b)
Definition: typedefs.h:248
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
static __inline VOID VgaSetSinglePaletteRegister(BYTE Index, BYTE Value)
Definition: vidbios.c:2137
#define VGA_AC_WRITE
Definition: svga.h:52
#define FONT_8x8_OFFSET
Definition: vidbios.h:29
static BOOLEAN VidBiosSetVideoPage(BYTE PageNumber)
Definition: vidbios.c:2589
#define PCHAR
Definition: match.c:90
static VOID VidBiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page)
Definition: vidbios.c:2316
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
static BOOLEAN VidBiosScrollWindow(SCROLL_DIRECTION Direction, DWORD Amount, SMALL_RECT Rectangle, BYTE Page, BYTE FillAttribute)
Definition: vidbios.c:1973
USHORT WINAPI getES(VOID)
Definition: registers.c:522
static BYTE VidBiosGetVideoMode(VOID)
Definition: vidbios.c:2403
#define VGA_DAC_DATA
Definition: svga.h:61
static const UCHAR Index[8]
Definition: usbohci.c:18
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 setBP(USHORT)
Definition: registers.c:381
VOID WINAPI setDX(USHORT)
Definition: registers.c:293
#define TO_LINEAR(seg, off)
Definition: emulator.h:22
#define NULL32
Definition: ntvdm.h:70
USHORT WINAPI getDX(VOID)
Definition: registers.c:286
unsigned char BYTE
Definition: mem.h:68
VOID WINAPI setBH(UCHAR)
Definition: registers.c:191
WORD ScreenColumns
Definition: bios.h:60
BYTE CrtModeControl
Definition: bios.h:68
BYTE VGADccIDActive
Definition: bios.h:94
#define VGA_SEQ_DATA
Definition: svga.h:56
#define IS_TEXT_MODE(ModeNumber)
Definition: vidbios.c:1965
UCHAR WINAPI getBL(VOID)
Definition: registers.c:198
static __inline VOID VidBiosGetCursorPosition(PBYTE Row, PBYTE Column, BYTE Page)
Definition: vidbios.c:2310
BYTE VGAOptions
Definition: bios.h:91
USHORT WINAPI getDI(VOID)
Definition: registers.c:434
VOID WINAPI setDL(UCHAR)
Definition: registers.c:321
#define VGA_DAC_MASK
Definition: svga.h:58
#define VGA_FONT_CHARACTERS
Definition: svga.h:25
#define VGA_AC_READ
Definition: svga.h:53
#define VIDEO_STATE_INFO_OFFSET
Definition: vidbios.h:36
static CONST UCHAR Font8x8[VGA_FONT_CHARACTERS *8]
Definition: vidbios.c:632
#define FONT_8x16_OFFSET
Definition: vidbios.h:31
unsigned int * PULONG
Definition: retypes.h:1
static CONST UCHAR Font8x14[VGA_FONT_CHARACTERS *14]
Definition: vidbios.c:892
unsigned int UINT
Definition: ndis.h:50
VOID WINAPI setCX(USHORT)
Definition: registers.c:235
FAST486_STATE EmulatorContext
Definition: cpu.c:39
#define DPRINT1
Definition: precomp.h:8
static LARGE_INTEGER Counter
Definition: clock.c:43
static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
Definition: vidbios.c:2447
UCHAR WINAPI getCH(VOID)
Definition: registers.c:242
#define HIWORD(l)
Definition: typedefs.h:246
static CONST UCHAR Font8x16[VGA_FONT_CHARACTERS *16]
Definition: vidbios.c:1408
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
#define VIDEO_BIOS_DATA_SEG
Definition: vidbios.h:27
#define FONT_8x8_HIGH_OFFSET
Definition: vidbios.h:30
#define VGA_AC_CONTROL_BLINK
Definition: svga.h:334
USHORT WINAPI getBP(VOID)
Definition: registers.c:374
BYTE CrtColorPaletteMask
Definition: bios.h:69
#define VGA_DAC_WRITE_INDEX
Definition: svga.h:60
VOID WINAPI setCL(UCHAR)
Definition: registers.c:263
static VOID VidBiosSetCursorShape(WORD CursorStartEnd)
Definition: vidbios.c:2334
#define LOWORD(l)
Definition: pedump.c:82
VOID FASTCALL EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
Definition: memory.c:139
BYTE CursorEndLine
Definition: bios.h:64
VOID WINAPI setDH(UCHAR)
Definition: registers.c:307

Referenced by VidBiosINT().