annotate src/common/Text.cpp @ 598:0b4ff504157d

merge.
author Robert McIntyre <rlm@mit.edu>
date Sun, 02 Sep 2012 06:37:11 -0500
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 /* FCE Ultra - NES/Famicom Emulator
rlm@1 2 *
rlm@1 3 * Copyright notice for this file:
rlm@1 4 * Copyright (C) 2002 Ben Parnell
rlm@1 5 *
rlm@1 6 * This program is free software; you can redistribute it and/or modify
rlm@1 7 * it under the terms of the GNU General Public License as published by
rlm@1 8 * the Free Software Foundation; either version 2 of the License, or
rlm@1 9 * (at your option) any later version.
rlm@1 10 *
rlm@1 11 * This program is distributed in the hope that it will be useful,
rlm@1 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rlm@1 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rlm@1 14 * GNU General Public License for more details.
rlm@1 15 *
rlm@1 16 * You should have received a copy of the GNU General Public License
rlm@1 17 * along with this program; if not, write to the Free Software
rlm@1 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
rlm@1 19 */
rlm@1 20
rlm@1 21 /* Code originally from fceu/drawing.h file, adapted by Forgotten
rlm@1 22 */
rlm@1 23 #include "System.h"
rlm@1 24
rlm@1 25 bool outlinedText = true, transparentText = false;
rlm@1 26 int textColor = 0, textMethod = 1;
rlm@1 27
rlm@1 28 extern u32 RGB_LOW_BITS_MASK;
rlm@1 29
rlm@1 30 static const u8 fontdata2[2048] = {
rlm@1 31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff,
rlm@1 32 0xc3, 0xe7, 0xff, 0x7e, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00,
rlm@1 33 0x1c,
rlm@1 34 0x3e, 0x1c, 0x7f, 0x7f, 0x3e, 0x1c, 0x3e, 0x08, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x3e, 0x00, 0x00, 0x18, 0x3c, 0x3c,
rlm@1 35 0x18,
rlm@1 36 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0xff, 0xc3,
rlm@1 37 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xf0, 0xe0, 0xf0, 0xbe, 0x33, 0x33, 0x33, 0x1e, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18,
rlm@1 38 0x7e,
rlm@1 39 0x18, 0xfc, 0xcc, 0xfc, 0x0c, 0x0c, 0x0e, 0x0f, 0x07, 0xfe, 0xc6, 0xfe, 0xc6, 0xc6, 0xe6, 0x67, 0x03, 0x99, 0x5a, 0x3c,
rlm@1 40 0xe7,
rlm@1 41 0xe7, 0x3c, 0x5a, 0x99, 0x01, 0x07, 0x1f, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x40, 0x70, 0x7c, 0x7f, 0x7c, 0x70, 0x40, 0x00,
rlm@1 42 0x18,
rlm@1 43 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, 0xfe, 0xdb, 0xdb, 0xde, 0xd8,
rlm@1 44 0xd8,
rlm@1 45 0xd8, 0x00, 0x7c, 0xc6, 0x1c, 0x36, 0x36, 0x1c, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c,
rlm@1 46 0x7e,
rlm@1 47 0x18, 0x7e, 0x3c, 0x18, 0xff, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18,
rlm@1 48 0x00,
rlm@1 49 0x00, 0x18, 0x30, 0x7f, 0x30, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x06, 0x7f, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
rlm@1 50 0x03,
rlm@1 51 0x7f, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00,
rlm@1 52 0xff,
rlm@1 53 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
rlm@1 54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1e, 0x1e, 0x0c, 0x0c, 0x00, 0x0c, 0x00, 0x36, 0x36, 0x36, 0x00,
rlm@1 55 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7f, 0x36, 0x7f, 0x36, 0x36, 0x00, 0x0c, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x0c, 0x00,
rlm@1 56 0x00,
rlm@1 57 0x63, 0x33, 0x18, 0x0c, 0x66, 0x63, 0x00, 0x1c, 0x36, 0x1c, 0x6e, 0x3b, 0x33, 0x6e, 0x00, 0x06, 0x06, 0x03, 0x00, 0x00,
rlm@1 58 0x00,
rlm@1 59 0x00, 0x00, 0x18, 0x0c, 0x06, 0x06, 0x06, 0x0c, 0x18, 0x00, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x66,
rlm@1 60 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
rlm@1 61 0x0c,
rlm@1 62 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x60, 0x30, 0x18,
rlm@1 63 0x0c,
rlm@1 64 0x06, 0x03, 0x01, 0x00, 0x3e, 0x63, 0x73, 0x7b, 0x6f, 0x67, 0x3e, 0x00, 0x0c, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x3f, 0x00,
rlm@1 65 0x1e,
rlm@1 66 0x33, 0x30, 0x1c, 0x06, 0x33, 0x3f, 0x00, 0x1e, 0x33, 0x30, 0x1c, 0x30, 0x33, 0x1e, 0x00, 0x38, 0x3c, 0x36, 0x33, 0x7f,
rlm@1 67 0x30,
rlm@1 68 0x78, 0x00, 0x3f, 0x03, 0x1f, 0x30, 0x30, 0x33, 0x1e, 0x00, 0x1c, 0x06, 0x03, 0x1f, 0x33, 0x33, 0x1e, 0x00, 0x3f, 0x33,
rlm@1 69 0x30,
rlm@1 70 0x18, 0x0c, 0x0c, 0x0c, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x33, 0x3e, 0x30, 0x18, 0x0e,
rlm@1 71 0x00,
rlm@1 72 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x18, 0x0c, 0x06, 0x03,
rlm@1 73 0x06,
rlm@1 74 0x0c, 0x18, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x1e,
rlm@1 75 0x33,
rlm@1 76 0x30, 0x18, 0x0c, 0x00, 0x0c, 0x00,
rlm@1 77 0x3e, 0x63, 0x7b, 0x7b, 0x7b, 0x03, 0x1e, 0x00, 0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00, 0x3f, 0x66, 0x66, 0x3e,
rlm@1 78 0x66, 0x66, 0x3f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3c, 0x00, 0x1f, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1f, 0x00,
rlm@1 79 0x7f,
rlm@1 80 0x46, 0x16, 0x1e, 0x16, 0x46, 0x7f, 0x00, 0x7f, 0x46, 0x16, 0x1e, 0x16, 0x06, 0x0f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x73,
rlm@1 81 0x66,
rlm@1 82 0x7c, 0x00, 0x33, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x33, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x78, 0x30,
rlm@1 83 0x30, 0x30, 0x33, 0x33, 0x1e, 0x00, 0x67, 0x66, 0x36, 0x1e, 0x36, 0x66, 0x67, 0x00, 0x0f, 0x06, 0x06, 0x06, 0x46, 0x66,
rlm@1 84 0x7f,
rlm@1 85 0x00, 0x63, 0x77, 0x7f, 0x7f, 0x6b, 0x63, 0x63, 0x00, 0x63, 0x67, 0x6f, 0x7b, 0x73, 0x63, 0x63, 0x00, 0x1c, 0x36, 0x63,
rlm@1 86 0x63,
rlm@1 87 0x63, 0x36, 0x1c, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x06, 0x06, 0x0f, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x3b, 0x1e, 0x38, 0x00,
rlm@1 88 0x3f,
rlm@1 89 0x66, 0x66, 0x3e, 0x36, 0x66, 0x67, 0x00, 0x1e, 0x33, 0x07, 0x0e, 0x38, 0x33, 0x1e, 0x00, 0x3f, 0x2d, 0x0c, 0x0c, 0x0c,
rlm@1 90 0x0c,
rlm@1 91 0x1e, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x63, 0x63,
rlm@1 92 0x63,
rlm@1 93 0x6b, 0x7f, 0x77, 0x63, 0x00, 0x63, 0x63, 0x36, 0x1c, 0x1c, 0x36, 0x63, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x0c, 0x1e,
rlm@1 94 0x00,
rlm@1 95 0x7f, 0x63, 0x31, 0x18, 0x4c, 0x66, 0x7f, 0x00, 0x1e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1e, 0x00, 0x03, 0x06, 0x0c, 0x18,
rlm@1 96 0x30,
rlm@1 97 0x60, 0x40, 0x00, 0x1e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1e, 0x00, 0x08, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
rlm@1 98 0x00,
rlm@1 99 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
rlm@1 100 0x0c, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x6e, 0x00, 0x07, 0x06, 0x06, 0x3e,
rlm@1 101 0x66, 0x66, 0x3b, 0x00, 0x00, 0x00, 0x1e, 0x33, 0x03, 0x33, 0x1e, 0x00, 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6e, 0x00,
rlm@1 102 0x00,
rlm@1 103 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x1c, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x6e, 0x33, 0x33,
rlm@1 104 0x3e,
rlm@1 105 0x30, 0x1f, 0x07, 0x06, 0x36, 0x6e, 0x66, 0x66, 0x67, 0x00, 0x0c, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x30, 0x00,
rlm@1 106 0x30, 0x30, 0x30, 0x33, 0x33, 0x1e, 0x07, 0x06, 0x66, 0x36, 0x1e, 0x36, 0x67, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
rlm@1 107 0x1e,
rlm@1 108 0x00, 0x00, 0x00, 0x33, 0x7f, 0x7f, 0x6b, 0x63, 0x00, 0x00, 0x00, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, 0x1e,
rlm@1 109 0x33,
rlm@1 110 0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x3b, 0x66, 0x66, 0x3e, 0x06, 0x0f, 0x00, 0x00, 0x6e, 0x33, 0x33, 0x3e, 0x30, 0x78,
rlm@1 111 0x00,
rlm@1 112 0x00, 0x3b, 0x6e, 0x66, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x00, 0x08, 0x0c, 0x3e, 0x0c, 0x0c,
rlm@1 113 0x2c,
rlm@1 114 0x18, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6e, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x00, 0x00,
rlm@1 115 0x63,
rlm@1 116 0x6b, 0x7f, 0x7f, 0x36, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x3e, 0x30,
rlm@1 117 0x1f,
rlm@1 118 0x00, 0x00, 0x3f, 0x19, 0x0c, 0x26, 0x3f, 0x00, 0x38, 0x0c, 0x0c, 0x07, 0x0c, 0x0c, 0x38, 0x00, 0x18, 0x18, 0x18, 0x00,
rlm@1 119 0x18,
rlm@1 120 0x18, 0x18, 0x00, 0x07, 0x0c, 0x0c, 0x38, 0x0c, 0x0c, 0x07, 0x00, 0x6e, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
rlm@1 121 0x08,
rlm@1 122 0x1c, 0x36, 0x63, 0x63, 0x7f, 0x00,
rlm@1 123 0x1e, 0x33, 0x03, 0x33, 0x1e, 0x18, 0x30, 0x1e, 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x38, 0x00, 0x1e, 0x33,
rlm@1 124 0x3f, 0x03, 0x1e, 0x00, 0x7e, 0xc3, 0x3c, 0x60, 0x7c, 0x66, 0xfc, 0x00, 0x33, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00,
rlm@1 125 0x07,
rlm@1 126 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x0c, 0x0c, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x00, 0x00, 0x1e, 0x03, 0x03,
rlm@1 127 0x1e,
rlm@1 128 0x30, 0x1c, 0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x06, 0x3c, 0x00, 0x33, 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x07, 0x00,
rlm@1 129 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x33, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x3e, 0x63, 0x1c, 0x18, 0x18, 0x18,
rlm@1 130 0x3c,
rlm@1 131 0x00, 0x07, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x63, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x63, 0x00, 0x0c, 0x0c, 0x00,
rlm@1 132 0x1e,
rlm@1 133 0x33, 0x3f, 0x33, 0x00, 0x38, 0x00, 0x3f, 0x06, 0x1e, 0x06, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x30, 0xfe, 0x33, 0xfe, 0x00,
rlm@1 134 0x7c,
rlm@1 135 0x36, 0x33, 0x7f, 0x33, 0x33, 0x73, 0x00, 0x1e, 0x33, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x33, 0x00, 0x1e, 0x33,
rlm@1 136 0x33,
rlm@1 137 0x1e, 0x00, 0x00, 0x07, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x07,
rlm@1 138 0x00,
rlm@1 139 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x33, 0x00, 0x33, 0x33, 0x3e, 0x30, 0x1f, 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18,
rlm@1 140 0x00,
rlm@1 141 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x00, 0x18, 0x18, 0x7e, 0x03, 0x03, 0x7e, 0x18, 0x18, 0x1c, 0x36, 0x26, 0x0f,
rlm@1 142 0x06,
rlm@1 143 0x67, 0x3f, 0x00, 0x33, 0x33, 0x1e, 0x3f, 0x0c, 0x3f, 0x0c, 0x0c, 0x1f, 0x33, 0x33, 0x5f, 0x63, 0xf3, 0x63, 0xe3, 0x70,
rlm@1 144 0xd8,
rlm@1 145 0x18, 0x3c, 0x18, 0x18, 0x1b, 0x0e,
rlm@1 146 0x38, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x1c, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x38, 0x00, 0x1e,
rlm@1 147 0x33, 0x33, 0x1e, 0x00, 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x33, 0x33, 0x33, 0x00,
rlm@1 148 0x3f,
rlm@1 149 0x00, 0x33, 0x37, 0x3f, 0x3b, 0x33, 0x00, 0x3c, 0x36, 0x36, 0x7c, 0x00, 0x7e, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00,
rlm@1 150 0x3e,
rlm@1 151 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x06, 0x03, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
rlm@1 152 0x00, 0x3f, 0x30, 0x30, 0x00, 0x00, 0xc3, 0x63, 0x33, 0x7b, 0xcc, 0x66, 0x33, 0xf0, 0xc3, 0x63, 0x33, 0xdb, 0xec, 0xf6,
rlm@1 153 0xf3,
rlm@1 154 0xc0, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, 0x00, 0x33, 0x66,
rlm@1 155 0xcc,
rlm@1 156 0x66, 0x33, 0x00, 0x00, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55,
rlm@1 157 0xdb,
rlm@1 158 0xee, 0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f,
rlm@1 159 0x18,
rlm@1 160 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x6c, 0x6c, 0x6c, 0x00, 0x00,
rlm@1 161 0x00,
rlm@1 162 0x00, 0x7f, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6f, 0x60, 0x6f, 0x6c, 0x6c,
rlm@1 163 0x6c,
rlm@1 164 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x7f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x60,
rlm@1 165 0x7f,
rlm@1 166 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0x7f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00,
rlm@1 167 0x00,
rlm@1 168 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18,
rlm@1 169 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
rlm@1 170 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
rlm@1 171 0x18,
rlm@1 172 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6c, 0x6c, 0xec,
rlm@1 173 0x6c,
rlm@1 174 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c,
rlm@1 175 0xef, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xec, 0x6c,
rlm@1 176 0x6c,
rlm@1 177 0x6c, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xef, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x18, 0x18, 0xff,
rlm@1 178 0x00,
rlm@1 179 0xff, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
rlm@1 180 0x00,
rlm@1 181 0x00, 0x00, 0x00, 0xff, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xfc, 0x00, 0x00, 0x00, 0x18, 0x18, 0xf8, 0x18, 0xf8,
rlm@1 182 0x00,
rlm@1 183 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c,
rlm@1 184 0x6c,
rlm@1 185 0x6c, 0xff, 0x6c, 0x6c, 0x6c, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00,
rlm@1 186 0x00,
rlm@1 187 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
rlm@1 188 0xff,
rlm@1 189 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff,
rlm@1 190 0xff,
rlm@1 191 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
rlm@1 192 0x00, 0x00, 0x6e, 0x3b, 0x13, 0x3b, 0x6e, 0x00, 0x00, 0x1e, 0x33, 0x1f, 0x33, 0x1f, 0x03, 0x03, 0x00, 0x3f, 0x33, 0x03,
rlm@1 193 0x03, 0x03, 0x03, 0x00, 0x00, 0x7f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x3f, 0x33, 0x06, 0x0c, 0x06, 0x33, 0x3f, 0x00,
rlm@1 194 0x00,
rlm@1 195 0x00, 0x7e, 0x1b, 0x1b, 0x1b, 0x0e, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x03, 0x00, 0x6e, 0x3b, 0x18, 0x18,
rlm@1 196 0x18,
rlm@1 197 0x18, 0x00, 0x3f, 0x0c, 0x1e, 0x33, 0x33, 0x1e, 0x0c, 0x3f, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x36, 0x1c, 0x00, 0x1c, 0x36,
rlm@1 198 0x63, 0x63, 0x36, 0x36, 0x77, 0x00, 0x38, 0x0c, 0x18, 0x3e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e,
rlm@1 199 0x00,
rlm@1 200 0x00, 0x60, 0x30, 0x7e, 0xdb, 0xdb, 0x7e, 0x06, 0x03, 0x1c, 0x06, 0x03, 0x1f, 0x03, 0x06, 0x1c, 0x00, 0x1e, 0x33, 0x33,
rlm@1 201 0x33,
rlm@1 202 0x33, 0x33, 0x33, 0x00, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x3f, 0x00,
rlm@1 203 0x06,
rlm@1 204 0x0c, 0x18, 0x0c, 0x06, 0x00, 0x3f, 0x00, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x00, 0x3f, 0x00, 0x70, 0xd8, 0xd8, 0x18, 0x18,
rlm@1 205 0x18,
rlm@1 206 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1b, 0x1b, 0x0e, 0x0c, 0x0c, 0x00, 0x3f, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x6e,
rlm@1 207 0x3b,
rlm@1 208 0x00, 0x6e, 0x3b, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
rlm@1 209 0x00,
rlm@1 210 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xf0, 0x30, 0x30, 0x30, 0x37, 0x36, 0x3c, 0x38, 0x1e, 0x36, 0x36, 0x36,
rlm@1 211 0x36,
rlm@1 212 0x00, 0x00, 0x00, 0x0e, 0x18, 0x0c, 0x06, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00,
rlm@1 213 0x00,
rlm@1 214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
rlm@1 215 };
rlm@1 216
rlm@1 217 static void calcColors(const int colorNum, int & lo, int & hi, int & out)
rlm@1 218 {
rlm@1 219 int redLo, redHi, greenLo, greenHi, blueLo, blueHi;
rlm@1 220
rlm@1 221 if (colorNum == 0 || colorNum == 1 || colorNum == 2 || colorNum == 6) // white, red, yellow, or magenta
rlm@1 222 redLo = (0xf) << systemRedShift, redHi = (0x1f) << systemRedShift;
rlm@1 223 else
rlm@1 224 redLo = redHi = 0;
rlm@1 225
rlm@1 226 if (colorNum == 0 || colorNum == 2 || colorNum == 3 || colorNum == 4) // white, yellow, green, or cyan
rlm@1 227 greenLo = (0xf) << systemGreenShift, greenHi = (0x1f) << systemGreenShift;
rlm@1 228 else
rlm@1 229 greenLo = greenHi = 0;
rlm@1 230
rlm@1 231 if (colorNum == 0 || colorNum == 4 || colorNum == 5 || colorNum == 6) // white, cyan, blue, or magenta
rlm@1 232 blueLo = (0xf) << systemBlueShift, blueHi = (0x1f) << systemBlueShift;
rlm@1 233 else
rlm@1 234 blueLo = blueHi = 0;
rlm@1 235
rlm@1 236 lo = redLo + greenLo + blueLo;
rlm@1 237 hi = redHi + greenHi + blueHi;
rlm@1 238
rlm@1 239 if (colorNum == 7) // black
rlm@1 240 out = 0xffffffff; // white border
rlm@1 241 else
rlm@1 242 out = 0; // black border
rlm@1 243 }
rlm@1 244
rlm@1 245 int lastColID = 0;
rlm@1 246 static void progressColorList(const char *& colorList, int & lo, int & hi, int & out)
rlm@1 247 {
rlm@1 248 if (*colorList)
rlm@1 249 {
rlm@1 250 if (*colorList != lastColID)
rlm@1 251 {
rlm@1 252 calcColors((int)(*colorList)-1, lo, hi, out);
rlm@1 253 lastColID = *colorList;
rlm@1 254 }
rlm@1 255 colorList++;
rlm@1 256 }
rlm@1 257 else
rlm@1 258 {
rlm@1 259 colorList = NULL;
rlm@1 260 }
rlm@1 261 }
rlm@1 262
rlm@1 263 static void drawTextInternal(u8 *screen, int pitch, int x, int y,
rlm@1 264 const char *string, bool trans, const char *colorList = NULL)
rlm@1 265 {
rlm@1 266 if (colorList && !*colorList)
rlm@1 267 colorList = NULL;
rlm@1 268
rlm@1 269 int loCol, hiCol, outCol;
rlm@1 270 calcColors(textColor, loCol, hiCol, outCol);
rlm@1 271
rlm@1 272 lastColID = 0;
rlm@1 273
rlm@1 274 const static int xd [8] = {-1, 0, 1, 1, 1, 0, -1, -1};
rlm@1 275 const static int yd [8] = {-1, -1, -1, 0, 1, 1, 1, 0};
rlm@1 276
rlm@1 277 screen += y*pitch;
rlm@1 278 int inc = 2;
rlm@1 279 switch (systemColorDepth)
rlm@1 280 {
rlm@1 281 case 24:
rlm@1 282 inc = 3;
rlm@1 283 break;
rlm@1 284 case 32:
rlm@1 285 inc = 4;
rlm@1 286 break;
rlm@1 287 }
rlm@1 288 screen += x*inc;
rlm@1 289
rlm@1 290 int xpos = x;
rlm@1 291 switch (systemColorDepth)
rlm@1 292 {
rlm@1 293 case 16:
rlm@1 294 {
rlm@1 295 while (*string)
rlm@1 296 {
rlm@1 297 char c = *string++;
rlm@1 298 u8 * scr = screen;
rlm@1 299
rlm@1 300 if (colorList)
rlm@1 301 progressColorList(colorList, loCol, hiCol, outCol);
rlm@1 302
rlm@1 303 u16 mask = u16(~RGB_LOW_BITS_MASK);
rlm@1 304 u16 *s = (u16 *)scr;
rlm@1 305 for (int h = 0-1; h < 8+1; h++)
rlm@1 306 {
rlm@1 307 for (int w = 0-1; w < 8+1; w++, s++)
rlm@1 308 {
rlm@1 309 int on = (h < 0 || w < 0 || h >= 8 || w >= 8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1;
rlm@1 310
rlm@1 311 int border = 0;
rlm@1 312 if (outlinedText)
rlm@1 313 for (int i = 0; i < 8; i++)
rlm@1 314 {
rlm@1 315 int h2 = h+yd[i], w2 = w+xd[i];
rlm@1 316 border = (h2 < 0 || w2 < 0 || h2 >= 8 || w2 >= 8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1;
rlm@1 317 if (border)
rlm@1 318 break;
rlm@1 319 }
rlm@1 320
rlm@1 321 if (trans)
rlm@1 322 {
rlm@1 323 if (on)
rlm@1 324 *s = loCol +
rlm@1 325 ((*s & mask) >>1);
rlm@1 326 else if (border)
rlm@1 327 {
rlm@1 328 *s = outCol +
rlm@1 329 ((*s & mask) >>1);
rlm@1 330 }
rlm@1 331 }
rlm@1 332 else
rlm@1 333 {
rlm@1 334 if (on)
rlm@1 335 *s = hiCol;
rlm@1 336 else if (border)
rlm@1 337 *s = outCol;
rlm@1 338 }
rlm@1 339 }
rlm@1 340 scr += pitch;
rlm@1 341 s = (u16 *)scr;
rlm@1 342 }
rlm@1 343 screen += inc*8;
rlm@1 344
rlm@1 345 xpos += 8;
rlm@1 346 if (xpos+8 > pitch>>1) // cut off text at right boundary
rlm@1 347 break;
rlm@1 348 }
rlm@1 349 break;
rlm@1 350 }
rlm@1 351 case 24: // TODO: verify this code's correctness
rlm@1 352 {
rlm@1 353 while (*string)
rlm@1 354 {
rlm@1 355 char c = *string++;
rlm@1 356 u8 * scr = screen;
rlm@1 357
rlm@1 358 if (colorList)
rlm@1 359 progressColorList(colorList, loCol, hiCol, outCol);
rlm@1 360
rlm@1 361 int h, w;
rlm@1 362 u8 *s = (u8 *)scr;
rlm@1 363 for (h = 0-1; h < 8+1; h++)
rlm@1 364 {
rlm@1 365 for (w = 0-1; w < 8+1; w++, s++)
rlm@1 366 {
rlm@1 367 int on = (h < 0 || w < 0 || h >= 8 || w >= 8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1;
rlm@1 368
rlm@1 369 int border = 0;
rlm@1 370 if (outlinedText)
rlm@1 371 for (int i = 0; i < 8; i++)
rlm@1 372 {
rlm@1 373 int h2 = h+yd[i], w2 = w+xd[i];
rlm@1 374 border = (h2 < 0 || w2 < 0 || h2 >= 8 || w2 >= 8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1;
rlm@1 375 if (border)
rlm@1 376 break;
rlm@1 377 }
rlm@1 378
rlm@1 379 if (trans)
rlm@1 380 {
rlm@1 381 if (on)
rlm@1 382 {
rlm@1 383 u32 color = hiCol;
rlm@1 384 *s = ((color & 255)>>1)+(*s>>1);
rlm@1 385 *(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
rlm@1 386 *(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
rlm@1 387 }
rlm@1 388 else if (border)
rlm@1 389 {
rlm@1 390 u32 color = outCol;
rlm@1 391 *s = ((color & 255)>>1)+(*s>>1);
rlm@1 392 *(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
rlm@1 393 *(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
rlm@1 394 }
rlm@1 395 }
rlm@1 396 else
rlm@1 397 {
rlm@1 398 if (on)
rlm@1 399 {
rlm@1 400 u32 color = hiCol;
rlm@1 401 *s = (color & 255);
rlm@1 402 *(s+1) = (color >> 8) & 255;
rlm@1 403 *(s+2) = (color >> 16) & 255;
rlm@1 404 }
rlm@1 405 else if (border)
rlm@1 406 {
rlm@1 407 u32 color = outCol;
rlm@1 408 *s = (color & 255);
rlm@1 409 *(s+1) = (color >> 8) & 255;
rlm@1 410 *(s+2) = (color >> 16) & 255;
rlm@1 411 }
rlm@1 412 }
rlm@1 413 }
rlm@1 414 scr += pitch;
rlm@1 415 s = (u8 *)scr;
rlm@1 416 }
rlm@1 417 screen += inc*8;
rlm@1 418
rlm@1 419 xpos += 8;
rlm@1 420 if (xpos+8 > pitch/3) // cut off text at right boundary
rlm@1 421 break;
rlm@1 422 }
rlm@1 423 break;
rlm@1 424 }
rlm@1 425 case 32:
rlm@1 426 {
rlm@1 427 while (*string)
rlm@1 428 {
rlm@1 429 char c = *string++;
rlm@1 430 u8 * scr = screen;
rlm@1 431
rlm@1 432 if (colorList)
rlm@1 433 progressColorList(colorList, loCol, hiCol, outCol);
rlm@1 434
rlm@1 435 int h, w;
rlm@1 436 u32 mask = 0xfefefe;
rlm@1 437 u32 *s = (u32 *)scr;
rlm@1 438 for (h = 0-1; h < 8+1; h++)
rlm@1 439 {
rlm@1 440 for (w = 0-1; w < 8+1; w++, s++)
rlm@1 441 {
rlm@1 442 int on = (h < 0 || w < 0 || h >= 8 || w >= 8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1;
rlm@1 443
rlm@1 444 int border = 0;
rlm@1 445 if (outlinedText)
rlm@1 446 for (int i = 0; i < 8; i++)
rlm@1 447 {
rlm@1 448 int h2 = h+yd[i], w2 = w+xd[i];
rlm@1 449 border = (h2 < 0 || w2 < 0 || h2 >= 8 || w2 >= 8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1;
rlm@1 450 if (border)
rlm@1 451 break;
rlm@1 452 }
rlm@1 453
rlm@1 454 if (trans)
rlm@1 455 {
rlm@1 456 if (on)
rlm@1 457 *s = loCol +
rlm@1 458 ((*s & mask)>>1);
rlm@1 459 else if (border)
rlm@1 460 {
rlm@1 461 *s = outCol +
rlm@1 462 ((*s & mask)>>1);
rlm@1 463 }
rlm@1 464 }
rlm@1 465 else
rlm@1 466 {
rlm@1 467 if (on)
rlm@1 468 *s = hiCol;
rlm@1 469 else if (border)
rlm@1 470 *s = outCol;
rlm@1 471 }
rlm@1 472 }
rlm@1 473 scr += pitch;
rlm@1 474 s = (u32 *)scr;
rlm@1 475 }
rlm@1 476 screen += inc*8;
rlm@1 477
rlm@1 478 xpos += 8;
rlm@1 479 if (xpos+8 > pitch>>2) // cut off text at right boundary
rlm@1 480 break;
rlm@1 481 }
rlm@1 482 break;
rlm@1 483 }
rlm@1 484 }
rlm@1 485 }
rlm@1 486
rlm@1 487 void drawText(u8 *screen, int pitch, int x, int y, const char *string, const char *colorList)
rlm@1 488 {
rlm@1 489 drawTextInternal(screen, pitch, x, y, string, transparentText, colorList);
rlm@1 490 }
rlm@1 491
rlm@1 492 void drawTextTransp(u8 *screen, int pitch, int x, int y, const char *string, const char *colorList)
rlm@1 493 {
rlm@1 494 drawTextInternal(screen, pitch, x, y, string, true, colorList);
rlm@1 495 }
rlm@1 496