UbixOS V2 2.0

ogprintf.cc
Go to the documentation of this file.
1 /*-
2 * Copyright (c) 2002-2018 The UbixOS Project.
3 * All rights reserved.
4 *
5 * This was developed by Christopher W. Olsen for the UbixOS Project.
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright notice, this list of
11 * conditions, the following disclaimer and the list of authors.
12 * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13 * conditions, the following disclaimer and the list of authors in the documentation and/or
14 * other materials provided with the distribution.
15 * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16 * endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 extern "C" {
30
31 #include <objgfx40/objgfx40.h>
32 #include <objgfx40/ogFont.h>
33 #include <sde/ogDisplay_UbixOS.h>
34
35 #include <ubixos/vitals.h>
36
37 static int screenRow = 0x0;
38 static int screenCol = 0x1;
39
40 int ogPrintf(char *ch) {
41 int i = 0x0;
42 int bufHeight;
43
44 ogSurface *screen = (ogDisplay_UbixOS *) systemVitals->screen;
45 ogBitFont *font = (ogBitFont *) systemVitals->font;
46
47 char *s = 0;
48 s = ch;
49
50 while ('\0' != s[i]) {
51 switch (s[i]) {
52 case '\t':
53 screenCol += 3;
54 break;
55 case '\b':
56 if (screenCol > 0)
57 --screenCol;
58 case '\n':
59 screenCol = 0;
60
61 bufHeight = ((screen->ogGetMaxY() + 1) / font->GetHeight()) - 1;
62 if (screenRow < bufHeight)
63 ++screenRow;
64 else {
65 screen->ogCopyBuf(0, 0, *screen, 0, font->GetHeight(), screen->ogGetMaxX(), screen->ogGetMaxY());
66 screen->ogFillRect(0, bufHeight * font->GetHeight() + 1, screen->ogGetMaxX(), screen->ogGetMaxY(), screen->ogPack(122, 140, 163));
67 }
68 break;
69 default:
70 font->PutChar(*screen, screenCol * font->GetWidth(), screenRow * font->GetHeight(), s[i]);
71 break;
72 } /* switch */
73
74 ++screenCol;
75 ++i;
76
77 } /* while */
78
79 return 0;
80 } // ogPrintf
81
82 }
ogDisplay_UbixOS.h
ogDisplay_UbixOS
Definition: ogDisplay_UbixOS.h:89
systemVitals
vitalsNode * systemVitals
Definition: vitals.c:35
vitals.h
vitalsStruct::font
void * font
Definition: vitals.h:48
ogPrintf
int ogPrintf(char *ch)
Definition: ogprintf.cc:40
vitalsStruct::screen
void * screen
Definition: vitals.h:47