x68kText.c revision ba64b02e
1/* $NetBSD: x68kText.c,v 1.1 2014/03/01 19:34:47 tsutsui Exp $ */ 2/*------------------------------------------------------------------------- 3 * Copyright (c) 1996 Yasushi Yamasaki 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Yasushi Yamasaki 17 * 4. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 *-----------------------------------------------------------------------*/ 31 32#include "x68k.h" 33#include "mi.h" 34#include "micmap.h" 35#include "fb.h" 36 37/*------------------------------------------------------------------------- 38 * function "x68kTextOpen" [ X68kFBProc function ] 39 * 40 * purpose: call common frame buffer opening procedure 41 * and enable TVRAM simultaneous access mode 42 * argument: (X68kScreenRec *)pPriv : X68k private screen record 43 * returns: (Bool): TRUE if succeeded 44 * FALSE otherwise 45 *-----------------------------------------------------------------------*/ 46static u_short r21; 47static u_short tpal0; 48static u_short tpal15; 49 50Bool 51x68kTextOpen(X68kScreenRec *pPriv) 52{ 53 if( !x68kFbCommonOpen(pPriv, "/dev/grf0") ) 54 return FALSE; 55 56 /* enable TVRAM simultaneous access mode */ 57 r21 = pPriv->reg->crtc.r21; 58 pPriv->reg->crtc.r21 = 0x01f0; 59 60 /* initialize scroll registers */ 61 pPriv->reg->crtc.r10 = pPriv->reg->crtc.r11 = 0; 62 63 tpal0 = pPriv->reg->tpal[0]; 64 tpal15 = pPriv->reg->tpal[15]; 65 66 pPriv->reg->tpal[0] = 0; 67 pPriv->reg->tpal[15] = 0xFFFE; 68 69 return TRUE; 70} 71 72/*------------------------------------------------------------------------- 73 * function "x68kTextClose" [ X68kFBProc function ] 74 * 75 * purpose: close text frame buffer 76 * argument: nothing 77 * returns: nothing 78 *-----------------------------------------------------------------------*/ 79void 80x68kTextClose(X68kScreenRec *pPriv) 81{ 82 pPriv->reg->crtc.r21 = r21; /* recover TVRAM mode */ 83 pPriv->reg->tpal[0] = tpal0; 84 pPriv->reg->tpal[15] = tpal15; 85 x68kFbCommonClose(pPriv); 86} 87 88/*------------------------------------------------------------------------- 89 * function "x68kTextInit" [ called by DIX AddScreen ] 90 * 91 * purpose: initialize text frame buffer 92 * argument: (int)screen : screen index 93 * (ScreenPtr)pScreen : DIX screen record 94 * (int)argc, (char **)argv : standard C arguments 95 * returns: (Bool) TRUE if succeeded 96 * FALSE otherwise 97 *-----------------------------------------------------------------------*/ 98Bool 99x68kTextInit(int screen, ScreenPtr pScreen, int argc, char *argv[]) 100{ 101 X68kScreenRec *pPriv; 102 103 /* get private screen record set by X68KConfig */ 104 pPriv = x68kGetScreenRecByType(X68K_FB_TEXT); 105 106 if ( !dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, 0) ) { 107 Error("dixRegisterPrivateKey failed"); 108 return FALSE; 109 } 110 x68kSetScreenPrivate(pScreen, pPriv); 111 112 if ( !fbScreenInit(pScreen, pPriv->fb, 113 pPriv->scr_width, pPriv->scr_height, 114 pPriv->dpi, pPriv->dpi, pPriv->fb_width, 1) ) 115 return FALSE; 116 pScreen->whitePixel = 1; 117 pScreen->blackPixel = 0; 118 if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) ) 119 return FALSE; 120 if ( !miCreateDefColormap(pScreen) ) 121 return FALSE; 122 pScreen->SaveScreen = x68kSaveScreen; 123 124 return TRUE; 125} 126 127/* EOF x68kText.c */ 128