x68kText.c revision 909daefd
1/* $NetBSD: x68kText.c,v 1.2 2016/08/30 07:50:55 mrg 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#include "os.h" 37 38/*------------------------------------------------------------------------- 39 * function "x68kTextOpen" [ X68kFBProc function ] 40 * 41 * purpose: call common frame buffer opening procedure 42 * and enable TVRAM simultaneous access mode 43 * argument: (X68kScreenRec *)pPriv : X68k private screen record 44 * returns: (Bool): TRUE if succeeded 45 * FALSE otherwise 46 *-----------------------------------------------------------------------*/ 47static u_short r21; 48static u_short tpal0; 49static u_short tpal15; 50 51Bool 52x68kTextOpen(X68kScreenRec *pPriv) 53{ 54 if( !x68kFbCommonOpen(pPriv, "/dev/grf0") ) 55 return FALSE; 56 57 /* enable TVRAM simultaneous access mode */ 58 r21 = pPriv->reg->crtc.r21; 59 pPriv->reg->crtc.r21 = 0x01f0; 60 61 /* initialize scroll registers */ 62 pPriv->reg->crtc.r10 = pPriv->reg->crtc.r11 = 0; 63 64 tpal0 = pPriv->reg->tpal[0]; 65 tpal15 = pPriv->reg->tpal[15]; 66 67 pPriv->reg->tpal[0] = 0; 68 pPriv->reg->tpal[15] = 0xFFFE; 69 70 return TRUE; 71} 72 73/*------------------------------------------------------------------------- 74 * function "x68kTextClose" [ X68kFBProc function ] 75 * 76 * purpose: close text frame buffer 77 * argument: nothing 78 * returns: nothing 79 *-----------------------------------------------------------------------*/ 80void 81x68kTextClose(X68kScreenRec *pPriv) 82{ 83 pPriv->reg->crtc.r21 = r21; /* recover TVRAM mode */ 84 pPriv->reg->tpal[0] = tpal0; 85 pPriv->reg->tpal[15] = tpal15; 86 x68kFbCommonClose(pPriv); 87} 88 89/*------------------------------------------------------------------------- 90 * function "x68kTextInit" [ called by DIX AddScreen ] 91 * 92 * purpose: initialize text frame buffer 93 * argument: (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(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 ErrorF("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