1/* $NetBSD: x68kText.c,v 1.6 2021/03/11 12:08:57 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 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 *-----------------------------------------------------------------------*/ 26 27#include "x68k.h" 28#include "mi.h" 29#include "micmap.h" 30#include "fb.h" 31#include "os.h" 32 33/*------------------------------------------------------------------------- 34 * function "x68kTextOpen" [ X68kFBProc function ] 35 * 36 * purpose: call common frame buffer opening procedure 37 * and enable TVRAM simultaneous access mode 38 * argument: (X68kScreenRec *)pPriv : X68k private screen record 39 * returns: (Bool): TRUE if succeeded 40 * FALSE otherwise 41 *-----------------------------------------------------------------------*/ 42static uint16_t r21; 43static uint16_t tpal0; 44static uint16_t tpal15; 45 46Bool 47x68kTextOpen(X68kScreenRec *pPriv) 48{ 49 if( !x68kFbCommonOpen(pPriv, "/dev/grf0") ) 50 return FALSE; 51 52 /* enable TVRAM simultaneous access mode */ 53 r21 = pPriv->reg->crtc.r21; 54 pPriv->reg->crtc.r21 = 0x01f0; 55 56 /* initialize scroll registers */ 57 pPriv->reg->crtc.r10 = pPriv->reg->crtc.r11 = 0; 58 59 tpal0 = pPriv->reg->tpal[0]; 60 tpal15 = pPriv->reg->tpal[15]; 61 62 pPriv->reg->tpal[0] = 0; 63 pPriv->reg->tpal[15] = 0xFFFE; 64 65 return TRUE; 66} 67 68/*------------------------------------------------------------------------- 69 * function "x68kTextClose" [ X68kFBProc function ] 70 * 71 * purpose: close text frame buffer 72 * argument: nothing 73 * returns: nothing 74 *-----------------------------------------------------------------------*/ 75void 76x68kTextClose(X68kScreenRec *pPriv) 77{ 78 pPriv->reg->crtc.r21 = r21; /* recover TVRAM mode */ 79 pPriv->reg->tpal[0] = tpal0; 80 pPriv->reg->tpal[15] = tpal15; 81 x68kFbCommonClose(pPriv); 82} 83 84/*------------------------------------------------------------------------- 85 * function "x68kTextInit" [ called by DIX AddScreen ] 86 * 87 * purpose: initialize text frame buffer 88 * argument: (ScreenPtr)pScreen : DIX screen record 89 * (int)argc, (char **)argv : standard C arguments 90 * returns: (Bool) TRUE if succeeded 91 * FALSE otherwise 92 *-----------------------------------------------------------------------*/ 93Bool 94x68kTextInit(ScreenPtr pScreen, int argc, char *argv[]) 95{ 96 X68kScreenRec *pPriv; 97 98 /* get private screen record set by X68KConfig */ 99 pPriv = x68kGetScreenRecByType(X68K_FB_TEXT); 100 101 if ( !dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, 0) ) { 102 ErrorF("dixRegisterPrivateKey failed\n"); 103 return FALSE; 104 } 105 x68kSetScreenPrivate(pScreen, pPriv); 106 107 if ( !fbScreenInit(pScreen, pPriv->fb, 108 pPriv->scr_width, pPriv->scr_height, 109 pPriv->dpi, pPriv->dpi, pPriv->fb_width, 1) ) 110 return FALSE; 111 pScreen->whitePixel = 1; 112 pScreen->blackPixel = 0; 113 if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) ) 114 return FALSE; 115 if ( !miCreateDefColormap(pScreen) ) 116 return FALSE; 117 pScreen->SaveScreen = x68kSaveScreen; 118 119 return TRUE; 120} 121 122/* EOF x68kText.c */ 123