/*
* Copyright (c) 1993 Markus Wild
* Copyright (c) 1993 Lutz Vieweg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Lutz Vieweg.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _GRF_RTREG_H
#define _GRF_RTREG_H
/*
* This driver for the MacroSystem Retina board was only possible,
* because MacroSystem provided information about the pecularities
* of the board. THANKS! Competition in Europe among gfx board
* manufacturers is rather tough, so Lutz Vieweg, who wrote the
* initial driver, has made an agreement with MS not to document
* the driver source (see also his comment below).
* -> ALL comments and register defines after
* -> " -------------- START OF CODE -------------- "
* -> have been added by myself (mw) from studying the publically
* -> available "NCR 77C22E+" Data Manual
*/
/*
* This code offers low-level routines to access the Retina graphics-board
* manufactured by MS MacroSystem GmbH from within NetBSD for the Amiga.
*
* Thanks to MacroSystem for providing me with the necessary information
* to create these routines. The sparse documentation of this code
* results from the agreements between MS and me.
*/
#if 0
/* these are in dev/devices.h */
/* definitions to find the autoconfig-board under
AmigaDOS */
/*
For more information on the structure entries take a look at
grf_rt.cc and ite_rt.cc.
*/
struct MonDef {
/* first the general monitor characteristics */
unsigned long FQ;
unsigned char FLG;
unsigned short MW; /* screen width in pixels */
/* has to be at least a multiple of 8, */
/* has to be a multiple of 64 in 256-color mode */
/* if you want to use some great tricks */
/* to speed up the vertical scrolling */
unsigned short MH; /* screen height in pixels */
unsigned short HBS;
unsigned short HSS;
unsigned short HSE;
unsigned short HBE;
unsigned short HT;
unsigned short VBS;
unsigned short VSS;
unsigned short VSE;
unsigned short VBE;
unsigned short VT;
unsigned short DEP; /* Color-depth, 4 for text-mode */
/* 8 enables 256-color graphics-mode, */
/* 16 and 24bit gfx not supported yet */
unsigned char * PAL; /* points to 16*3 byte RGB-palette data */
/* use LoadPalette() to set colors 0..255 */
/* in 256-color-gfx mode */
/* all following entries are font-specific in
text mode. Make sure your monitor
parameters are calculated for the
appropriate font width and height!
*/
unsigned short TX; /* Text-mode (DEP=4): */
/* screen-width in characters */
/* currently, TX has to be a */
/* multiple of 16! */
/* Gfx-mode (DEP > 4) */
/* "logical" screen-width, */
/* use values > MW to allow */
/* hardware-panning */
/* has to be a multiple of 8 */
unsigned short TY; /* Text-mode: */
/* screen-height in characters */
/* Gfx-mode: "logical" screen */
/* height for panning */
/* the following values are currently unused for gfx-mode */
unsigned short XY; /* TX*TY (speeds up some calcs.) */
unsigned short FX; /* font-width (valid values: 4,7-16) */
unsigned short FY; /* font-height (valid range: 1-32) */
unsigned char * FData; /* pointer to the font-data */
/* The font data is simply an array of bytes defining
the chars in ascending order, line by line. If your
font is wider than 8 pixel, FData has to be an
array of words. */
unsigned short FLo; /* lowest character defined */
unsigned short FHi; /* highest char. defined */
};
#if 0
/* Some ready-made MonDef structures are available in grf_rt.cc */
/* text-screen resolutions wider than 1024 are currently damaged.
The VRAM access seems to become unstable at higher resolutions.
This may hopefully be subject of change.
*/
/* WARNING: THE FOLLOWING MONITOR MODES EXCEED THE 90-MHz LIMIT THE PROCESSOR
HAS BEEN SPECIFIED FOR. USE AT YOUR OWN RISK (AND THINK ABOUT
MOUNTING SOME COOLING DEVICE AT THE PROCESSOR AND RAMDAC)! */
extern struct MonDef MON_1280_1024_60;
extern struct MonDef MON_1280_1024_69;
/* Default monitor (change if this is too much for your monitor :-)) */
#define DEFAULT_MONDEF MON_768_600_80
#else
/* nothing exported for now... */
#endif
/* a standard 16-color palette is available in grf_rt.cc
and used by the standard monitor-definitions above */
extern unsigned char NCRStdPalette[];
This routine initialises the Retina hardware, opens a
text- or gfx-mode screen, depending on the value of MonDef.DEP,
and sets the cursor to position 0.
It takes as arguments a pointer to the hardware-base
address as it is denoted in the DevConf structure
of the AmigaDOS, and a pointer to a struct MonDef
which describes the screen-mode parameters.
The routine returns 0 if it was unable to open the screen,
or an unsigned char * to the display/attribute memory
when it succeeded. The organisation of the display memory
is a little strange in text-mode (Intel-typically...) :
Byte 00 01 02 03 04 05 06 etc.
Char0 Attr0 -- -- Char1 Attr1 -- etc.
You may set a character and its associated attribute byte
with a single word-access, or you may perform to byte writes
for the char and attribute. Each 2. word has no meaning,
and writes to these locations are ignored.
The attribute byte for each character has the following
structure:
Were FORE is the foreground-color index (0-15) and
BACK is the background color index (0-7). BLINK
enables blinking for the associated character.
The higher 8 colors in the standard palette are
lighter than the lower 8, so you may see FORE3 as
an intensity bit. If FORE == 1 or FORE == 9 and
BACK == 0 the character is underlined. Since I don't
think this looks good, it will probably change in a
future release.
There's no routine "SetChar" or "SetAttr" provided,
because I think it's so trivial... a function call
would be pure overhead. As an example, a routine
to set the char code and attribute at position x,y:
(assumed the value returned by InitNCR was stored
into "DispMem", the actual MonDef struct * is hold
in "MDef")
void SetChar(unsigned char chr, unsigned char attr,
unsigned short x, unsigned short y) {
In Gfx-mode, the memory organisation is rather simple,
1 byte per pixel in 256-color mode, one pixel after
each other, line by line.
Currently, InitNCR() disables the Retina VBLANK IRQ,
but beware: When running the Retina WB-Emu under
AmigaDOS, the VBLANK IRQ is ENABLED.
void SetCursorPos(unsigned short pos);
This routine sets the hardware-cursor position
to the screen location pos. pos can be calculated
as (x + y * md->TY).
Text-mode only!
void ScreenUp(void);
A somewhat optimized routine that scrolls the whole
screen up one row. A good idea to compile this piece
of code with optimization enabled.
Text-mode only!
void ScreenDown(void);
A somewhat optimized routine that scrolls the whole
screen down one row. A good idea to compile this piece
of code with optimization enabled.
Text-mode only!
unsigned char * SetSegmentPtr(unsigned long address);
Sets the beginning of the 64k-memory segment to the
address specified by the unsigned long. If address MOD 64
is != 0, the return value will point to the segments
start in the Amiga address space + (address MOD 64).
Don't use more than (65536-64) bytes in the segment
you set if you aren't sure that (address MOD 64) == 0.
See retina.doc from MS for further information.
void ClearScreen(unsigned char color);
Fills the whole screen with "color" - 256-color mode only!
Loads the palette-registers. "pal" points to an array of unsigned char
triplets, for the red, green and blue component. "firstcol" determines the
number of the first palette-register to load (256 available). "colors"
is the number of colors you want to put in the palette registers.
Allows you to set a single color in the palette, "colornum" is the number
of the palette entry (256 available), "red", "green" and "blue" are the
three components.
void SetPanning(unsigned short xoff, unsigned short yoff);
Moves the logical coordinate (xoff, yoff) to the upper left corner
of your screen. Of course, you shouldn't specify excess values that would
show garbage in the lower right area of your screen... SetPanning()
does NOT check for boundaries.
*/
NOTE: there are some registers that have different addresses when
in mono or color mode. We only support color mode, and thus
some addresses won't work in mono-mode! */
/* Video DAC (these are *pure* guesses from the usage of these registers,
I don't have a data sheet for this chip:-/) */
#define VDAC_REG_D 0x800d /* well.. */
#define VDAC_REG_SELECT 0x8001 /* perhaps.. */
#define VDAC_REG_DATA 0x8003 /* dito.. */
#define WGfx(ba, idx, val) \
do { vgaw(ba, GCT_ADDRESS, idx); vgaw(ba, GCT_ADDRESS_W , val); } while (0)
#define WSeq(ba, idx, val) \
do { vgaw(ba, SEQ_ADDRESS, idx); vgaw(ba, SEQ_ADDRESS_W , val); } while (0)
#define WCrt(ba, idx, val) \
do { vgaw(ba, CRT_ADDRESS, idx); vgaw(ba, CRT_ADDRESS_W , val); } while (0)
#define WAttr(ba, idx, val) \
do { vgaw(ba, ACT_ADDRESS, idx); vgaw(ba, ACT_ADDRESS_W, val); } while (0)
#define Map(m) \
do { WGfx(ba, GCT_ID_READ_MAP_SELECT, m & 3 ); WSeq(ba, SEQ_ID_MAP_MASK, (1 << (m & 3))); } while (0)