-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0886ce9
Showing
22 changed files
with
3,879 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/ | ||
toolchains/ | ||
rg35xxplus/APPS/SimpleTerminal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
A STATEMENT ON LEGACY SUPPORT | ||
|
||
In the terminal world there is much cruft that comes from old and unsup‐ | ||
ported terminals that inherit incompatible modes and escape sequences | ||
which noone is able to know, except when he/she comes from that time and | ||
developed a graphical vt100 emulator at that time. | ||
|
||
One goal of st is to only support what is really needed. When you en‐ | ||
counter a sequence which you really need, implement it. But while you | ||
are at it, do not add the other cruft you might encounter while sneek‐ | ||
ing at other terminal emulators. History has bloated them and there is | ||
no real evidence that most of the sequences are used today. | ||
|
||
|
||
Christoph Lohmann <20h@r-36.net> | ||
2012-09-13T07:00:36.081271045+02:00 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
MIT/X Consortium License | ||
|
||
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com> | ||
© 2012 Roberto E. Vargas Caballero <k0ga at shike2 dot com> | ||
© 2012 Christoph Lohmann <20h at r-36 dot net> | ||
© 2009 Anselm R Garbe <garbeam at gmail dot com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# st - simple terminal | ||
# See LICENSE file for copyright and license details. | ||
|
||
include makefiles/config.mk | ||
|
||
ifeq ($(UNION_PLATFORM),rg35xxplus) | ||
include makefiles/config-rg35xxplus.mk | ||
else ifeq ($(UNION_PLATFORM),upscale) | ||
include makefiles/config-generic-linux-upscale.mk | ||
endif | ||
|
||
SRC = $(wildcard src/*.c) | ||
|
||
all: options build | ||
|
||
options: | ||
@echo st build options: | ||
@echo "UNION_PLATFORM = ${UNION_PLATFORM}" | ||
@echo "PREFIX = ${PREFIX}" | ||
@echo "CROSS_COMPILE = ${CROSS_COMPILE}" | ||
@echo "SYSROOT = ${SYSROOT}" | ||
@echo "CFLAGS = ${CFLAGS}" | ||
@echo "LDFLAGS = ${LDFLAGS}" | ||
@echo "CC = ${CC}" | ||
@echo "SRC = ${SRC}" | ||
@echo "VERSION = ${VERSION}" | ||
|
||
|
||
build: | ||
mkdir -p build | ||
${CC} -o build/SimpleTerminal ${SRC} ${CFLAGS} ${LDFLAGS} | ||
|
||
clean: | ||
@echo cleaning | ||
rm -rf build | ||
|
||
.PHONY: all options clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
st - simple terminal | ||
|
||
|
||
How to install: | ||
|
||
- Extract the downloaded zip file | ||
- Copy the files to "Roms/APPS/" folder | ||
|
||
How to run: | ||
|
||
- From your device main menu -> RA Game -> APPS -> SimpleTerminal (or SimpleTerminal-HighRes) | ||
|
||
|
||
|
||
-------------------- | ||
st is a simple virtual terminal emulator for X which sucks less. | ||
|
||
Modified to run on RS-97. | ||
=> line doubling to deal with the 320x480 resolution | ||
=> TTF fonts replaced by embedded pixel font (from TIC-80) | ||
=> onscreen keyboard (see keyboard.c for button bindings) | ||
|
||
Keys: | ||
- pad: select key | ||
- A: press key | ||
- B: toggles key (useful for shift/ctrl...) | ||
- L: is shift | ||
- R: is backspace | ||
- Y: change keyboard location (top/bottom) | ||
- X: show / hide keyboard | ||
- SELECT: quit | ||
|
||
|
||
Requirements | ||
------------ | ||
In order to build st you need the Xlib header files. | ||
|
||
Build | ||
------------ | ||
For generic linux: | ||
make | ||
|
||
For RG35XX Plus: | ||
./build-rg35xxplus.sh | ||
(or run inside rg35xxplus-toolchain docker container: UNION_PLATFORM=rg35xxplus make) | ||
|
||
For generic linux (with bigger window size) | ||
UNION_PLATFORM=upscale make | ||
|
||
|
||
Running st | ||
---------- | ||
|
||
./build/SimpleTerminal | ||
|
||
Run with High resolution | ||
HIGH_RES=1 ./build/SimpleTerminal | ||
|
||
|
||
If you don't install st, define TNAME to "xterm" in config.h or make sure to at | ||
least compile st terminfo entry with the following command: | ||
|
||
tic -s st.info | ||
|
||
It should print the path of the compiled terminfo entry. You can | ||
safely remove it if you don't plan to use st anymore. | ||
See the man page for additional details. | ||
|
||
Credits | ||
------- | ||
Based on Aurélien APTEL <aurelien dot aptel at gmail dot com> bt source code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
set -v | ||
|
||
PLATFORM=rg35xxplus | ||
HOST_WORKSPACE=$(pwd) | ||
|
||
if [ ! "$(docker images -q rg35xxplus-toolchain:latest 2> /dev/null)" ]; then | ||
echo 'toolchain image does not exist, building a new image' | ||
mkdir -p toolchains | ||
git clone https://github.com/haoict/union-$PLATFORM-toolchain/ toolchains/$PLATFORM-toolchain | ||
cd toolchains/$PLATFORM-toolchain && make .build | ||
cd $HOST_WORKSPACE | ||
fi | ||
|
||
docker run -it --rm -v $HOST_WORKSPACE:/root/workspace $PLATFORM-toolchain /bin/bash -c '. ~/.bashrc && cd /root/workspace && git config --global --add safe.directory /root/workspace && make && chmod 777 -R ./build' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
cp ./build/SimpleTerminal ./rg35xxplus/APPS/ | ||
rsync -rv ./rg35xxplus/APPS/* root@192.168.1.140:/mnt/mmc/Roms/APPS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INCS += -DUPSCALE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Simple Terminal config for RG35xx Plus | ||
# based on RG350 ver https://github.com/jamesofarrell/st-sdl | ||
# | ||
export LD_LIBRARY_PATH=/opt/rg35xxplus-toolchain/usr/lib | ||
|
||
PREFIX=/opt/rg35xxplus-toolchain/usr/arm-buildroot-linux-gnueabihf/sysroot/usr | ||
CROSS_COMPILE=/opt/rg35xxplus-toolchain/usr/bin/arm-buildroot-linux-gnueabihf- | ||
|
||
INCS += -DRG35XXPLUS | ||
|
||
CFLAGS += -marm -mtune=cortex-a53 -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Simple Terminal config | ||
# based on RG350 ver https://github.com/jamesofarrell/st-sdl | ||
# | ||
|
||
# st version | ||
GIT_SHA_FETCH := $(shell git rev-parse HEAD | cut -c 1-7) | ||
VERSION = "1.0.1-$(shell git rev-parse HEAD | cut -c 1-7)" | ||
|
||
# Customize below to fit your system | ||
|
||
# paths | ||
PREFIX = /usr | ||
CROSS_COMPILE = | ||
|
||
# compiler and linker | ||
CC = ${CROSS_COMPILE}gcc | ||
SYSROOT = $(shell ${CC} --print-sysroot) | ||
|
||
# includes and libs | ||
INCS = -I. -I${SYSROOT}/usr/include/SDL | ||
LIBS = -lc -L${SYSROOT}/usr/lib -lSDL -lpthread -Wl,-Bstatic,-lutil,-Bdynamic | ||
|
||
# flags | ||
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_GNU_SOURCE=1 -D_REENTRANT | ||
CFLAGS += -Os -Wall ${INCS} ${CPPFLAGS} -fPIC -std=gnu11 -flto -Wno-unused-result -Wno-unused-variable | ||
LDFLAGS += ${LIBS} -s |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
progdir=$(dirname "$0") | ||
cd $progdir | ||
HOME=$progdir | ||
HIGH_RES=1 ./SimpleTerminal | ||
# sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
progdir=$(dirname "$0") | ||
cd $progdir | ||
HOME=$progdir | ||
./SimpleTerminal | ||
# sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* See LICENSE file for copyright and license details. */ | ||
|
||
/* appearance */ | ||
#define USE_ANTIALIASING | ||
//static char font[] = "fonts/LiberationMono-Regular.ttf:fonts/LiberationMono-Bold.ttf"; | ||
//static char font[] = "fonts/inconsolata-dz.ttf:fonts/inconsolata-dz.ttf"; | ||
//static char font[] = "fonts/monaco.ttf:fonts/monaco.ttf"; | ||
//static char font[] = "fonts/TerminusTTF-4.46.0.ttf:fonts/TerminusTTF-4.46.0.ttf"; | ||
static char font[] = "fonts/FIXED_V0.TTF:fonts/FIXED_V0.TTF"; | ||
static int fontsize = 8; | ||
static int borderpx = 2; | ||
static int initial_width = 320; | ||
static int initial_height = 240; | ||
static char shell[] = "/bin/sh"; | ||
|
||
/* double-click timeout (in milliseconds) between clicks for selection */ | ||
static unsigned int doubleclicktimeout = 300; | ||
static unsigned int tripleclicktimeout = 600; | ||
|
||
/* TERM value */ | ||
static char termname[] = "xterm"; | ||
|
||
static unsigned int tabspaces = 4; | ||
#define WORD_BREAK " " | ||
|
||
/* Terminal colors (16 first used in escape sequence) */ | ||
SDL_Color colormap[] = { | ||
/* 8 normal colors */ | ||
{ 0, 0, 0, 0 },//black | ||
{ 128, 0, 0, 0 },//"red3", | ||
{ 0, 128, 0, 0 },//"green3", | ||
{ 128, 128, 0, 0 },//"yellow3", | ||
{ 0, 0, 128, 0 },//"blue2", | ||
{ 128, 0, 128, 0 },//"magenta3", | ||
{ 0, 128, 128, 0 },//"cyan3", | ||
{ 192, 192, 192, 0 },//"gray90", | ||
|
||
/* 8 bright colors */ | ||
{ 128, 128, 128, 0}, //"gray50", | ||
{ 255, 0, 0, 0 },//red | ||
{ 0, 255, 0, 0 },//green | ||
{ 255, 255, 0, 0 },//"yellow", | ||
{ 0, 0, 255, 0 },//"#0000ff", | ||
{ 255, 0, 255, 0 },//"magenta", | ||
{ 0, 255, 255, 0 },//"cyan", | ||
{ 255, 255, 255, 0 },//"white", | ||
|
||
[255] = { 0, 0, 0, 0 }, | ||
|
||
/* more colors can be added after 255 to use with DefaultXX */ | ||
{ 204, 204, 204, 0}, | ||
{ 51, 51, 51, 0}, | ||
}; | ||
|
||
/* | ||
* Default colors (colorname index) | ||
* foreground, background, cursor, unfocused cursor | ||
*/ | ||
static unsigned int defaultfg = 7; | ||
static unsigned int defaultbg = 0; | ||
static unsigned int defaultcs = 256; | ||
static unsigned int defaultucs = 257; | ||
|
||
/* | ||
* Special keys (change & recompile st.info accordingly) | ||
* Keep in mind that kpress() in st.c hardcodes some keys. | ||
* | ||
* Mask value: | ||
* * Use XK_ANY_MOD to match the key no matter modifiers state | ||
* * Use XK_NO_MOD to match the key alone (no modifiers) | ||
*/ | ||
|
||
/* key, mask, output */ | ||
static Key key[] = { | ||
{ SDLK_LEFT, KMOD_ALT, "\033[1;3D" }, | ||
{ SDLK_RIGHT, KMOD_ALT, "\033[1;3C" }, | ||
|
||
{ SDLK_BACKSPACE, 0, "\177" }, | ||
{ SDLK_INSERT, 0, "\033[2~" }, | ||
{ SDLK_DELETE, 0, "\033[3~" }, | ||
{ SDLK_HOME, 0, "\033[1~" }, | ||
{ SDLK_END, 0, "\033[4~" }, | ||
{ SDLK_PAGEUP, 0, "\033[5~" }, | ||
{ SDLK_PAGEDOWN, 0, "\033[6~" }, | ||
{ SDLK_F1, 0, "\033OP" }, | ||
{ SDLK_F2, 0, "\033OQ" }, | ||
{ SDLK_F3, 0, "\033OR" }, | ||
{ SDLK_F4, 0, "\033OS" }, | ||
{ SDLK_F5, 0, "\033[15~" }, | ||
{ SDLK_F6, 0, "\033[17~" }, | ||
{ SDLK_F7, 0, "\033[18~" }, | ||
{ SDLK_F8, 0, "\033[19~" }, | ||
{ SDLK_F9, 0, "\033[20~" }, | ||
{ SDLK_F10, 0, "\033[21~" }, | ||
{ SDLK_F11, 0, "\033[23~" }, | ||
{ SDLK_F12, 0, "\033[24~" }, | ||
}; | ||
|
||
/* Internal shortcuts. */ | ||
#define MODKEY KMOD_ALT | ||
|
||
static Shortcut shortcuts[] = { | ||
/* modifier key function argument */ | ||
{ MODKEY|KMOD_SHIFT, SDLK_PAGEUP, xzoom, {.i = +1} }, | ||
{ MODKEY|KMOD_SHIFT, SDLK_PAGEDOWN, xzoom, {.i = -1} }, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <SDL/SDL.h> | ||
#include "font.h" | ||
|
||
// font from https://github.com/nesbox/TIC-80 | ||
static const unsigned char embedded_font[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x00, 0x00, 0x78, 0xa0, 0x70, 0x28, 0xf0, 0x00, 0x00, 0x00, 0x88, 0x10, 0x20, 0x40, 0x88, 0x00, 0x00, 0x00, 0x40, 0xa0, 0x68, 0x90, 0x68, 0x00, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x40, 0x20, 0x20, 0x20, 0x40, 0x00, 0x00, 0x00, 0x20, 0xa8, 0x70, 0xa8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x70, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x70, 0xc8, 0xc8, 0xc8, 0x70, 0x00, 0x00, 0x00, 0x30, 0x70, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x18, 0x70, 0xc0, 0xf8, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x30, 0x98, 0x70, 0x00, 0x00, 0x00, 0x30, 0x70, 0xd0, 0xf8, 0x10, 0x00, 0x00, 0x00, 0xf8, 0xc0, 0xf0, 0x18, 0xf0, 0x00, 0x00, 0x00, 0x70, 0xc0, 0xf0, 0xc8, 0x70, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x30, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x70, 0xc8, 0x70, 0xc8, 0x70, 0x00, 0x00, 0x00, 0x70, 0xc8, 0x78, 0x08, 0x70, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x60, 0x20, 0x40, 0x00, 0x00, 0x10, 0x20, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x78, 0x18, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0xa8, 0xb8, 0x80, 0x70, 0x00, 0x00, 0x00, 0x70, 0xc8, 0xc8, 0xf8, 0xc8, 0x00, 0x00, 0x00, 0xf0, 0xc8, 0xf0, 0xc8, 0xf0, 0x00, 0x00, 0x00, 0x70, 0xc8, 0xc0, 0xc8, 0x70, 0x00, 0x00, 0x00, 0xf0, 0xc8, 0xc8, 0xc8, 0xf0, 0x00, 0x00, 0x00, 0xf8, 0xc0, 0xf0, 0xc0, 0xf8, 0x00, 0x00, 0x00, 0xf8, 0xc0, 0xf0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x78, 0xc0, 0xd8, 0xc8, 0x78, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0xf8, 0xc8, 0xc8, 0x00, 0x00, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00, 0x00, 0xc8, 0xd0, 0xe0, 0xd0, 0xc8, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xf8, 0x00, 0x00, 0x00, 0xd8, 0xf8, 0xf8, 0xa8, 0x88, 0x00, 0x00, 0x00, 0xc8, 0xe8, 0xf8, 0xd8, 0xc8, 0x00, 0x00, 0x00, 0x70, 0xc8, 0xc8, 0xc8, 0x70, 0x00, 0x00, 0x00, 0xf0, 0xc8, 0xc8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x70, 0xc8, 0xc8, 0xc8, 0x70, 0x08, 0x00, 0x00, 0xf0, 0xc8, 0xc8, 0xf0, 0xc8, 0x00, 0x00, 0x00, 0x78, 0xe0, 0x70, 0x38, 0xf0, 0x00, 0x00, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0xc8, 0xc8, 0x70, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0xc8, 0x70, 0x20, 0x00, 0x00, 0x00, 0x88, 0xa8, 0xf8, 0xf8, 0xd8, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0x70, 0xc8, 0xc8, 0x00, 0x00, 0x00, 0x68, 0x68, 0x78, 0x30, 0x30, 0x00, 0x00, 0x00, 0xf8, 0x30, 0x60, 0xc0, 0xf8, 0x00, 0x00, 0x00, 0x60, 0x40, 0x40, 0x40, 0x60, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x60, 0x20, 0x20, 0x20, 0x60, 0x00, 0x00, 0x00, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x98, 0x98, 0x78, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xc8, 0xc8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x78, 0xe0, 0xe0, 0x78, 0x00, 0x00, 0x00, 0x18, 0x78, 0x98, 0x98, 0x78, 0x00, 0x00, 0x00, 0x00, 0x70, 0xd8, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x38, 0x60, 0xf8, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x70, 0x98, 0xf8, 0x18, 0x70, 0x00, 0x00, 0xc0, 0xf0, 0xc8, 0xc8, 0xc8, 0x00, 0x00, 0x00, 0x30, 0x00, 0x70, 0x30, 0x78, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x18, 0x98, 0x70, 0x00, 0x00, 0xc0, 0xc8, 0xf0, 0xc8, 0xc8, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x38, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf8, 0xa8, 0xa8, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc8, 0xc8, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x70, 0xc8, 0xc8, 0x70, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc8, 0xc8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x78, 0x98, 0x98, 0x78, 0x18, 0x00, 0x00, 0x00, 0xf0, 0xc8, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x78, 0xe0, 0x38, 0xf0, 0x00, 0x00, 0x00, 0x60, 0xf8, 0x60, 0x60, 0x38, 0x00, 0x00, 0x00, 0x00, 0x98, 0x98, 0x98, 0x78, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0xd0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x88, 0xa8, 0xf8, 0xd8, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x70, 0x70, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x98, 0x98, 0x78, 0x18, 0x70, 0x00, 0x00, 0x00, 0xf8, 0x30, 0x60, 0xf8, 0x00, 0x00, 0x00, 0x30, 0x20, 0x60, 0x20, 0x30, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x60, 0x20, 0x30, 0x20, 0x60, 0x00, 0x00, 0x00, 0x00, 0x28, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
|
||
void draw_char(SDL_Surface* surface, unsigned char symbol, int x, int y, unsigned short color) { | ||
x += (8 - 1) * 1; | ||
int flip = 0; | ||
if(symbol > 127) { // flip symbols over 128 | ||
flip = 1; | ||
symbol -= 128; | ||
} | ||
const unsigned char* ptr = embedded_font + symbol * 8; | ||
|
||
for(int i = 0, ys = 0; i < 6; i++, ptr++, ys += 1) | ||
for(int col = 8 - 6, xs = x - col; col < 8; col++, xs -= 1) | ||
if((*ptr & 1 << col) && y + ys < surface->h && xs < surface->w ) | ||
((unsigned short*)surface->pixels)[(y + flip * 4 + (1 - 2 * flip) * ys) * (surface->pitch >> 1) + xs] = color; | ||
|
||
} | ||
|
||
void draw_string(SDL_Surface* surface, const char* text, int orig_x, int orig_y, unsigned short color) { | ||
int x = orig_x, y = orig_y; | ||
while(*text) { | ||
if(*text == '\n') { | ||
x = orig_x; | ||
y += 8; | ||
} else { | ||
draw_char(surface, *text, x, y, color); | ||
x += 6; | ||
} | ||
text++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef __FONT_H__ | ||
#define __FONT_H__ | ||
|
||
void draw_char(SDL_Surface* surface, unsigned char symbol, int x, int y, unsigned short color); | ||
void draw_string(SDL_Surface* surface, const char* text, int x, int y, unsigned short color); | ||
|
||
#endif |
Oops, something went wrong.