|
@@ -23,6 +23,291 @@
|
|
#include "ascii.h"
|
|
#include "ascii.h"
|
|
#include "util.h"
|
|
#include "util.h"
|
|
|
|
|
|
|
|
+#ifdef PAL_WIN95
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * Portions based on:
|
|
|
|
+ *
|
|
|
|
+ * YH - Console Chinese Environment -
|
|
|
|
+ * Copyright (C) 1999 Red Flag Linux (office@sonata.iscas.ac.cn)
|
|
|
|
+ *
|
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions
|
|
|
|
+ * are met:
|
|
|
|
+ * 1. Redistributions of source code must retain the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY RED FLAG LINUX ``AS IS'' AND ANY
|
|
|
|
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
|
|
|
|
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
+ * SUCH DAMAGE.
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * Portions based on:
|
|
|
|
+ *
|
|
|
|
+ * KON2 - Kanji ON Console -
|
|
|
|
+ * Copyright (C) 1992-1996 Takashi MANABE (manabe@papilio.tutics.tut.ac.jp)
|
|
|
|
+ *
|
|
|
|
+ * CCE - Console Chinese Environment -
|
|
|
|
+ * Copyright (C) 1998-1999 Rui He (herui@cs.duke.edu)
|
|
|
|
+ *
|
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions
|
|
|
|
+ * are met:
|
|
|
|
+ * 1. Redistributions of source code must retain the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY TAKASHI MANABE ``AS IS'' AND ANY
|
|
|
|
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
|
|
|
|
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
+ * SUCH DAMAGE.
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include "gbfont.h"
|
|
|
|
+#include "big5font.h"
|
|
|
|
+
|
|
|
|
+static BOOL fIsBig5 = FALSE;
|
|
|
|
+
|
|
|
|
+INT
|
|
|
|
+PAL_InitFont(
|
|
|
|
+ VOID
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+ Purpose:
|
|
|
|
+
|
|
|
|
+ Load the font files.
|
|
|
|
+
|
|
|
|
+ Parameters:
|
|
|
|
+
|
|
|
|
+ None.
|
|
|
|
+
|
|
|
|
+ Return value:
|
|
|
|
+
|
|
|
|
+ 0 if succeed, -1 if cannot allocate memory, -2 if cannot load files.
|
|
|
|
+
|
|
|
|
+--*/
|
|
|
|
+{
|
|
|
|
+ FILE *fp;
|
|
|
|
+
|
|
|
|
+ fp = fopen(PAL_PREFIX "word.dat", "rb");
|
|
|
|
+ if (!fp)
|
|
|
|
+ {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fseek(fp, 0x1E, SEEK_SET);
|
|
|
|
+ if (fgetc(fp) == 0xAA)
|
|
|
|
+ {
|
|
|
|
+ fIsBig5 = TRUE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fclose(fp);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+VOID
|
|
|
|
+PAL_FreeFont(
|
|
|
|
+ VOID
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+ Purpose:
|
|
|
|
+
|
|
|
|
+ Free the memory used for fonts.
|
|
|
|
+
|
|
|
|
+ Parameters:
|
|
|
|
+
|
|
|
|
+ None.
|
|
|
|
+
|
|
|
|
+ Return value:
|
|
|
|
+
|
|
|
|
+ None.
|
|
|
|
+
|
|
|
|
+--*/
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static BOOL is_gb(unsigned char b1, unsigned char b2)
|
|
|
|
+{
|
|
|
|
+ if (b1 < 0xa1 || b1 > 0xfe)
|
|
|
|
+ return FALSE;
|
|
|
|
+ if (b2 < 0xa1 || b2 > 0xfe)
|
|
|
|
+ return FALSE;
|
|
|
|
+ return TRUE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+VOID
|
|
|
|
+PAL_DrawCharOnSurface(
|
|
|
|
+ WORD wChar,
|
|
|
|
+ SDL_Surface *lpSurface,
|
|
|
|
+ PAL_POS pos,
|
|
|
|
+ BYTE bColor
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+ Purpose:
|
|
|
|
+
|
|
|
|
+ Draw a BIG-5 Chinese character on a surface.
|
|
|
|
+
|
|
|
|
+ Parameters:
|
|
|
|
+
|
|
|
|
+ [IN] wChar - the character to be drawn (in GB2312/BIG5).
|
|
|
|
+
|
|
|
|
+ [OUT] lpSurface - the destination surface.
|
|
|
|
+
|
|
|
|
+ [IN] pos - the destination location of the surface.
|
|
|
|
+
|
|
|
|
+ [IN] bColor - the color of the character.
|
|
|
|
+
|
|
|
|
+ Return value:
|
|
|
|
+
|
|
|
|
+ None.
|
|
|
|
+
|
|
|
|
+--*/
|
|
|
|
+{
|
|
|
|
+ int i, j, dx;
|
|
|
|
+ int x = PAL_X(pos), y = PAL_Y(pos);
|
|
|
|
+ LPBYTE pChar;
|
|
|
|
+ BYTE ch1, ch2;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (lpSurface == NULL)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ch1 = wChar & 0xff;
|
|
|
|
+ ch2 = wChar >> 8;
|
|
|
|
+
|
|
|
|
+ if (fIsBig5)
|
|
|
|
+ {
|
|
|
|
+ if (ch2 < 0xa1)
|
|
|
|
+ pChar = &big5font[((ch1 - 0xA1) * 157 + ch2 - 0x40) << 5] + 8;
|
|
|
|
+ else
|
|
|
|
+ pChar = &big5font[((ch1 - 0xA1) * 157 + 63 + ch2 - 0xA1) << 5] + 8;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (!is_gb(ch1, ch2))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ pChar = &gbfont[((ch1 - 0xa1) * 94 + (ch2 - 0xa1)) * 32];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (pChar == NULL) return;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (y > lpSurface->h) return;
|
|
|
|
+
|
|
|
|
+ y *= lpSurface->pitch;
|
|
|
|
+ for (i = 0; i < 32; i++)
|
|
|
|
+ {
|
|
|
|
+ dx = x + ((i & 1) << 3);
|
|
|
|
+ for (j = 0; j < 8; j++)
|
|
|
|
+ {
|
|
|
|
+ if (pChar[i] & (1 << (7 - j)))
|
|
|
|
+ {
|
|
|
|
+ if (dx < lpSurface->w)
|
|
|
|
+ ((LPBYTE)(lpSurface->pixels))[y + dx] = bColor;
|
|
|
|
+ }
|
|
|
|
+ dx++;
|
|
|
|
+ }
|
|
|
|
+ y += (i & 1) * lpSurface->pitch;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+VOID
|
|
|
|
+PAL_DrawASCIICharOnSurface(
|
|
|
|
+ BYTE bChar,
|
|
|
|
+ SDL_Surface *lpSurface,
|
|
|
|
+ PAL_POS pos,
|
|
|
|
+ BYTE bColor
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+ Purpose:
|
|
|
|
+
|
|
|
|
+ Draw a ASCII character on a surface.
|
|
|
|
+
|
|
|
|
+ Parameters:
|
|
|
|
+
|
|
|
|
+ [IN] bChar - the character to be drawn.
|
|
|
|
+
|
|
|
|
+ [OUT] lpSurface - the destination surface.
|
|
|
|
+
|
|
|
|
+ [IN] pos - the destination location of the surface.
|
|
|
|
+
|
|
|
|
+ [IN] bColor - the color of the character.
|
|
|
|
+
|
|
|
|
+ Return value:
|
|
|
|
+
|
|
|
|
+ None.
|
|
|
|
+
|
|
|
|
+--*/
|
|
|
|
+{
|
|
|
|
+ int i, j, dx;
|
|
|
|
+ int x = PAL_X(pos), y = PAL_Y(pos);
|
|
|
|
+ LPBYTE pChar;
|
|
|
|
+
|
|
|
|
+ pChar = &iso_font[(int)(bChar & ~128) * 15];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (lpSurface == NULL)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ y *= lpSurface->pitch;
|
|
|
|
+ for (i = 0; i < 15; i++)
|
|
|
|
+ {
|
|
|
|
+ dx = x;
|
|
|
|
+ for (j = 0; j < 8; j++)
|
|
|
|
+ {
|
|
|
|
+ if (pChar[i] & (1 << j))
|
|
|
|
+ {
|
|
|
|
+ ((LPBYTE)(lpSurface->pixels))[y + dx] = bColor;
|
|
|
|
+ }
|
|
|
|
+ dx++;
|
|
|
|
+ }
|
|
|
|
+ y += lpSurface->pitch;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#else
|
|
|
|
+
|
|
typedef struct tagFont
|
|
typedef struct tagFont
|
|
{
|
|
{
|
|
LPWORD lpBufChar;
|
|
LPWORD lpBufChar;
|
|
@@ -289,3 +574,5 @@ PAL_DrawASCIICharOnSurface(
|
|
y += lpSurface->pitch;
|
|
y += lpSurface->pitch;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+#endif
|