What does this Pascal code set the VGA card in?

90 Views Asked by At

I have this Pascal code. It seems to enter mode X, but seems to be wider or different.

What is this video mode called, or is it standard Mode X?

{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
{INIT: Configure VGA to mode ???}
 
    asm
        mov     ax,13h
        int     10h
    end;
{  if not InGraphicsMode then}
    InitVGA;
 
 
 
{    SetWidth (1610 shr 1);
        mov     ax, BYTES_PER_LINE shr 1
        push    ax
 
        pop     ax
 
}
 
    asm
                                 {3d4}
{        mov     dx, CRTC_INDEX
        mov     ax, 13h
        out     dx, al
        inc     dx
        in al,dx
        mov bl,al
}
        mov     dx, CRTC_INDEX {3d4 0x13 offset or logical width}
        mov     ax, 13h
        out     dx, al
        inc     dx
        mov al,bl
        add al,5   {0x28 to 0x2D???}
mov al,02Dh {0B4h} {028h}
mov al,02Dh
{05Ah}
        out     dx, al
    end;
 
 
 
 
    asm
     {underline}
        mov     dx, CRTC_INDEX
        mov     al, UNDERLINE
        out     dx, al
        inc     dx
        in      al, dx
        and     al, not 40h
mov al,0
        out     dx, al
 
 
    {mode control}
        dec     dx
        mov     al, MODE_CONTROL
        out     dx, al
        inc     dx
        in      al, dx
        or      al, 40h
mov al,0E3h
        out     dx, al
    end;
 
 
 
 
    asm
     {memory mode}
        mov     dx, SC_INDEX
        mov     al, MEMORY_MODE
        out     dx, al
        inc     dx
        in      al, dx
        and     al, not 8
        or      al, 4
mov al,6
        out     dx, al
 
    {graphics mode}
        mov     dx, GC_INDEX {0x3CE}
        mov     al, GRAPHICS_MODE
        out     dx, al
        inc     dx
        in      al, dx
        and     al, not 10h
mov al,40h
        out     dx, al
        dec     dx
 
   {miscellaneous}
        mov     al, MISCELLANEOUS
        out     dx, al
        inc     dx
        in      al, dx
        and     al, not 2
MOV AL,0E1h
        out     dx, al
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    {vertical retrace end, turn off write protect}
      mov dx,03D4h
      mov ax,02C11h
      mov ax,00E11h
      out dx,ax
 
 
    {vertical total}
      mov ax,00D06h
      mov ax,0BF06h
      out dx,ax
 
{overflow register}
      mov ax,03E07h
      mov ax,01F07h
      out dx,ax
 
{vertical retrace start}
      mov ax,0EA10h
      mov ax,09C10h
      out dx,ax
 
{vertical display enable end}
      mov ax,0DF12h
      mov ax,08E12h
      out dx,ax
 
 
{start vertical blanking}
      mov ax,0E715h
      mov ax,09615h
      out dx,ax
 
 
{end vertical blanking}
      mov ax,00616h
      mov ax,0B916h
      out dx,ax
 
 
 
{vertical retrace end AND wr.prot}
      mov ax,0AC11h
      mov ax,08E11h
      out dx,ax
 
 
    end;
 
 
 
 
 
 
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}
{END:  Configure VGA to mode ???}

It comes from Wiering Mario. http://www.wieringsoftware.nl/mario/

Cleaned code: http://190.53.102.175/api.7z In the directory api\usr_CACHE_\mario for Turbo Pascal and api\usr_CACHE_\mario_\DJGPP for DJGPP/C/NASM.

I was looking at VGA256.PAS, and it seems that the width of the mode is 360, but I think that Mode X was 320x240.

1

There are 1 best solutions below

0
Kai Burghardt On

int 0x10 is the video interrupt in a traditional IBM PC BIOS. The video interrupt provides access to many graphics-related functions indexed via the ah (“accumulator high”, i. e. the upper 8 bits of the 16-bit wide accumulator) register.

Here, there is a mov ax, 0x13. This is equivalent to mov ah, 0x00/mov al, 0x13. Thus the selected function is 0x00: graphics mode initialization. The requested mode is 0x13. With MCGA and VGA graphics cards, this is the 320 px × 200 px graphics mode with 256 colors.

Later, there are interactions with the CRTC (Cathode Ray Tube Controller) giving you the impression of an even wider display. For safe operations, the electrons in a CRT display should hit the screen (as opposed to the tube’s walls). Here, the programmer exploits the fact that a certain safety margin is installed. Altering the timings stretches the apparent width of pixels, the size of the video memory (in Bytes, and thus the resolution) remains the same.