delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/03/18:06:47

From: Plasmid125 AT aol DOT com
Date: Sat, 3 May 1997 17:48:35 -0400 (EDT)
Message-ID: <970503174835_1785485903@emout03.mail.aol.com>
To: djgpp AT delorie DOT com
Subject: RE: What's Mode-X
MIME-Version: 1.0

--PART.BOUNDARY.0.22054.emout03.mail.aol.com.862696114
Content-ID: <0_22054_862696115 AT emout03 DOT mail DOT aol DOT com DOT 4442>
Content-type: text/plain

> Hi,
> 
> What's ModeX?  Is it the SVGA modes (i.e. 640x480x256, 800x600x65536,etc.)?
> 
> Thanks!
> Bye!

Mode-X is a term first coined by Michael Abrash.  He discovered this video
mode independently, however he was not the first to discover it.  He was
merely the first to name it and release code in Dr. Dobb's Journal.  Mode-X
is a 320x240x256-color mode.  It has several advantages because of it's
square pixels (1:1 aspect ratio) and its page size makes it ideal for
page-flipping.  With the use of latches and off-screen memory, you may copy
images four pixels at a time.  Attached is a all-assembly code to select
Mode-X (You wouldn't want to cheat and use allegro now would you?)
it is C near-callable as void Set320x240Mode(void).  ENJOY!  
~Chris Myers (3D.Mug)


--PART.BOUNDARY.0.22054.emout03.mail.aol.com.862696114
Content-ID: <0_22054_862696115 AT emout03 DOT mail DOT aol DOT com DOT 4443>
Content-type: text/plain;
	name="L32-1.ASM"
Content-Transfer-Encoding: quoted-printable

; Mode X (320x240, 256 colors) mode set routine. Works on all VGAs.
; ****************************************************************
; * Revised 6/19/91 to select correct clock; fixes vertical roll *
; * problems on fixed-frequency (IBM 851X-type) monitors.        *
; ****************************************************************
; C near-callable as:
;       void Set320x240Mode(void);
; Tested with TASM 4.0 by Jim Mischel 12/16/94.
; Modified from public-domain mode set code by John Bridges.
=0D
SC_INDEX equ    03c4h   ;Sequence Controller Index
CRTC_INDEX equ  03d4h   ;CRT Controller Index
MISC_OUTPUT equ 03c2h   ;Miscellaneous Output register
SCREEN_SEG equ  0a000h  ;segment of display memory in mode X
=0D
        .model  small
        .data
; Index/data pairs for CRT Controller registers that differ between
; mode 13h and mode X.
CRTParms label  word
        dw      00d06h  ;vertical total
        dw      03e07h  ;overflow (bit 8 of vertical counts)
        dw      04109h  ;cell height (2 to double-scan)
        dw      0ea10h  ;v sync start
        dw      0ac11h  ;v sync end and protect cr0-cr7
        dw      0df12h  ;vertical displayed
        dw      00014h  ;turn off dword mode
        dw      0e715h  ;v blank start
        dw      00616h  ;v blank end
        dw      0e317h  ;turn on byte mode
CRT_PARM_LENGTH equ     (($-CRTParms)/2)
=0D
        .code
        public  _Set320x240Mode
_Set320x240Mode proc    near
        push    bp      ;preserve caller's stack frame
        push    si      ;preserve C register vars
        push    di      ; (don't count on BIOS preserving anything)
=0D
        mov     ax,13h  ;let the BIOS set standard 256-color
        int     10h     ; mode (320x200 linear)
=0D
        mov     dx,SC_INDEX
        mov     ax,0604h
        out     dx,ax   ;disable chain4 mode
        mov     ax,0100h
        out     dx,ax   ;synchronous reset while setting Misc Output
                        ; for safety, even though clock unchanged
        mov     dx,MISC_OUTPUT
        mov     al,0e3h
        out     dx,al   ;select 25 MHz dot clock & 60 Hz scanning rate
=0D
        mov     dx,SC_INDEX
        mov     ax,0300h
        out     dx,ax   ;undo reset (restart sequencer)
=0D
        mov     dx,CRTC_INDEX ;reprogram the CRT Controller
        mov     al,11h  ;VSync End reg contains register write
        out     dx,al   ; protect bit
        inc     dx      ;CRT Controller Data register
        in      al,dx   ;get current VSync End register setting
        and     al,7fh  ;remove write protect on various
        out     dx,al   ; CRTC registers
        dec     dx      ;CRT Controller Index
        cld
        mov     si,offset CRTParms ;point to CRT parameter table
        mov     cx,CRT_PARM_LENGTH ;# of table entries
SetCRTParmsLoop:
        lodsw           ;get the next CRT Index/Data pair
        out     dx,ax   ;set the next CRT Index/Data pair
        loop    SetCRTParmsLoop
=0D
        mov     dx,SC_INDEX
        mov     ax,0f02h
        out     dx,ax   ;enable writes to all four planes
        mov     ax,SCREEN_SEG ;now clear all display memory, 8 pixels
        mov     es,ax         ; at a time
        sub     di,di   ;point ES:DI to display memory
        sub     ax,ax   ;clear to zero-value pixels
        mov     cx,8000h ;# of words in display memory
        rep     stosw   ;clear all of display memory
=0D
        pop     di      ;restore C register vars
        pop     si
        pop     bp      ;restore caller's stack frame
        ret
_Set320x240Mode endp
        end
=0D

--PART.BOUNDARY.0.22054.emout03.mail.aol.com.862696114--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019