Annotation of kernel/bsd/dev/ppc/kmGraphics.m, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /*
        !            26:  * Copyright (c) 1993 NeXT Computer, Inc.  All rights reserved.
        !            27:  *
        !            28:  * miniMon.c -- Machine-independent mini-monitor.
        !            29:  *
        !            30:  * HISTORY
        !            31:  * 04-Oct-1993         Curtis Galloway at NeXT
        !            32:  *     Created.
        !            33:  *
        !            34:  */
        !            35: 
        !            36: #import <mach/boolean.h>
        !            37: #import <bsd/dev/kmreg_com.h>
        !            38: #import "kmFontPriv.h"
        !            39: #import "ConsoleSupport.h"
        !            40: #import "kmDevice.h"
        !            41: #import "TimesItalic14.h"
        !            42: 
        !            43: #define TEXT_COLOR             KM_COLOR_BLACK
        !            44: 
        !            45: // in psuedoVGA 640 x 480 coords
        !            46: #define XMARGIN                        0
        !            47: 
        !            48: #define PANELWIDTH     352
        !            49: #define PANELHEIGHT    264
        !            50: #define TEXTYPOS       (186 + 21)
        !            51: 
        !            52: #define PANELTOP       ((480 - PANELHEIGHT) / 2)
        !            53: #define PANELLEFT      ((640 - PANELWIDTH) / 2)
        !            54: 
        !            55: #define TEXTBASELINE           (PANELTOP + TEXTYPOS)
        !            56: // rect to erase
        !            57: #define TEXTTOP                        (PANELTOP + TEXTYPOS - 20)
        !            58: #define TEXTLEFT               (PANELLEFT + 16)
        !            59: #define TEXTWIDTH              (PANELWIDTH - 32)
        !            60: #define TEXTHEIGHT             (PANELHEIGHT - 16 - (TEXTYPOS - 20))
        !            61: 
        !            62: 
        !            63: void
        !            64: kmDrawString( IOConsoleInfo *console, char * str )
        !            65: {
        !            66:        int lines;
        !            67:        char lastchar;
        !            68:        bitmap_t *bmp;
        !            69:        int deflead;
        !            70:        const unsigned char *string;
        !            71:         font_c_t *fontp = &Times_Italic_14;
        !            72:         int xpos, ypos;
        !            73: 
        !            74:        str = kmLocalizeString(str);
        !            75:        
        !            76:        for(lines = 0, string = str, lastchar = '\0'; *string; string++) {
        !            77:            lastchar = *string;
        !            78:            if (lastchar == '\n')
        !            79:                lines++;
        !            80:        }
        !            81:        if (lastchar != '\n')
        !            82:            lines++;
        !            83:        
        !            84:        deflead = fontp->bbx.height + (fontp->bbx.height + 9) / 10;
        !            85: 
        !            86:         ypos = TEXTBASELINE; // - ((deflead * (lines - 1)) / 2);
        !            87: 
        !            88:        for (string = str; *string; ) {
        !            89:            const char *line;
        !            90:            int len;
        !            91:            
        !            92:            /* Center this line */
        !            93:            for (line = string, len = 0; *line && (*line != '\n'); line++) {
        !            94:                 bmp = &fontp->bitmaps[(*line) - ENCODEBASE];
        !            95:                len += bmp->dwidth;
        !            96:            }
        !            97:             xpos = XMARGIN - len / 2;
        !            98: 
        !            99:            for (; *string; string++) {
        !           100:                if (*string == '\n') {
        !           101:                    string++;
        !           102:                    break;
        !           103:                }
        !           104:                 bmp = &fontp->bitmaps[(*string) - ENCODEBASE];
        !           105:                 BltPSBitmap( console, xpos, ypos, bmp, fontp->bits, TEXT_COLOR);
        !           106:                 xpos += bmp->dwidth;
        !           107:            }
        !           108:            ypos += deflead;
        !           109:        }
        !           110: }
        !           111: 
        !           112: @implementation kmDevice (KmGraphics)
        !           113: 
        !           114: - (void)graphicPanelString:(char *)str
        !           115: {
        !           116:     struct km_drawrect rect;
        !           117: 
        !           118:     if (fbMode != SCM_GRAPHIC)
        !           119:         return;
        !           120: 
        !           121:     rect.width = TEXTWIDTH;
        !           122:     rect.height = TEXTHEIGHT;
        !           123:     rect.x = TEXTLEFT;
        !           124:     rect.y = TEXTTOP;
        !           125:     rect.data.fill = (void *) KM_COLOR_LTGRAY;
        !           126:     (void)(*fbp[FB_DEV_NORMAL]->EraseRect)(fbp[FB_DEV_NORMAL], &rect);
        !           127: 
        !           128:     kmDrawString( fbp[FB_DEV_NORMAL], str);
        !           129: }
        !           130: 
        !           131: - (void)drawGraphicPanel:(GraphicPanelType) panelType
        !           132: {
        !           133: }
        !           134: 
        !           135: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.