Skip to content

Commit

Permalink
New sleek default font 6x10
Browse files Browse the repository at this point in the history
... thanks dark_samus for the initial discovery and testing
  • Loading branch information
d0k3 committed Sep 6, 2016
1 parent 19724f4 commit 858342a
Show file tree
Hide file tree
Showing 8 changed files with 3,406 additions and 29 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export TARGET := EmuNAND9
BUILD := build
SOURCES := source source/fatfs source/abstraction
DATA := data
INCLUDES := source source/fatfs
INCLUDES := source source/font source/fatfs

#---------------------------------------------------------------------------------
# THEME: if set to anything, name of the themes file folder inside resources
Expand All @@ -45,6 +45,16 @@ ifneq ($(strip $(THEME)),)
CFLAGS += -DUSE_THEME=\"\/$(THEME)\"
endif

ifeq ($(FONT),ORIG)
CFLAGS += -DFONT_ORIGINAL
else ifeq ($(FONT),6X10)
CFLAGS += -DFONT_6X10
else ifeq ($(FONT),ACORN)
CFLAGS += -DFONT_ACORN
else
CFLAGS += -DFONT_6X10
endif

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions

ASFLAGS := -g $(ARCH) -DEXEC_$(EXEC_METHOD)
Expand Down
23 changes: 4 additions & 19 deletions source/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@
#include "fs.h"
#ifdef USE_THEME
#include "theme.h"
#else
#define STD_COLOR_BG COLOR_BLACK
#define STD_COLOR_FONT COLOR_WHITE

#define DBG_COLOR_BG COLOR_BLACK
#define DBG_COLOR_FONT COLOR_WHITE

#define DBG_START_Y 10
#define DBG_END_Y (SCREEN_HEIGHT - 10)
#define DBG_START_X 10
#define DBG_END_X (SCREEN_WIDTH_TOP - 10)
#define DBG_STEP_Y 10
#endif

#define DBG_N_CHARS_Y ((DBG_END_Y - DBG_START_Y) / DBG_STEP_Y)
#define DBG_N_CHARS_X (((DBG_END_X - DBG_START_X) / 8) + 1)

static char debugstr[DBG_N_CHARS_X * DBG_N_CHARS_Y] = { 0 };

void ClearScreen(u8* screen, int width, int color)
Expand All @@ -55,13 +40,13 @@ void ClearScreenFull(bool clear_top, bool clear_bottom)

void DrawCharacter(u8* screen, int character, int x, int y, int color, int bgcolor)
{
for (int yy = 0; yy < 8; yy++) {
for (int yy = 0; yy < FONT_HEIGHT; yy++) {
int xDisplacement = (x * BYTES_PER_PIXEL * SCREEN_HEIGHT);
int yDisplacement = ((SCREEN_HEIGHT - (y + yy) - 1) * BYTES_PER_PIXEL);
u8* screenPos = screen + xDisplacement + yDisplacement;

u8 charPos = font[character * 8 + yy];
for (int xx = 7; xx >= 0; xx--) {
u8 charPos = font[character * FONT_HEIGHT + yy];
for (int xx = 7; xx >= (8 - FONT_WIDTH); xx--) {
if ((charPos >> xx) & 1) {
*(screenPos + 0) = color >> 16; // B
*(screenPos + 1) = color >> 8; // G
Expand All @@ -79,7 +64,7 @@ void DrawCharacter(u8* screen, int character, int x, int y, int color, int bgcol
void DrawString(u8* screen, const char *str, int x, int y, int color, int bgcolor)
{
for (size_t i = 0; i < strlen(str); i++)
DrawCharacter(screen, str[i], x + i * 8, y, color, bgcolor);
DrawCharacter(screen, str[i], x + i * FONT_WIDTH, y, color, bgcolor);
}

void DrawStringF(int x, int y, bool use_top, const char *format, ...)
Expand Down
22 changes: 22 additions & 0 deletions source/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#define SCREEN_HEIGHT 240
#define SCREEN_WIDTH_TOP 400
#define SCREEN_WIDTH_BOT 320
#ifdef FONT_6X10 // special font width
#define FONT_WIDTH_EXT 6
#else
#define FONT_WIDTH_EXT 8
#endif

#define RGB(r,g,b) (r<<24|b<<16|g<<8|r)

Expand All @@ -22,6 +27,23 @@
#define COLOR_PURPLE RGB(0x66, 0x00, 0xFF)
#define COLOR_TRANSPARENT RGB(0xFF, 0x00, 0xEF) // otherwise known as 'super fuchsia'

#ifndef USE_THEME
#define STD_COLOR_BG COLOR_BLACK
#define STD_COLOR_FONT COLOR_WHITE

#define DBG_COLOR_BG COLOR_BLACK
#define DBG_COLOR_FONT COLOR_WHITE

#define DBG_START_Y 10
#define DBG_END_Y (SCREEN_HEIGHT - 10)
#define DBG_START_X 10
#define DBG_END_X (SCREEN_WIDTH_TOP - 10)
#define DBG_STEP_Y 10
#endif

#define DBG_N_CHARS_Y ((DBG_END_Y - DBG_START_Y) / DBG_STEP_Y)
#define DBG_N_CHARS_X (((DBG_END_X - DBG_START_X) / FONT_WIDTH) + 1)

#ifdef EXEC_GATEWAY
#define TOP_SCREEN0 (u8*)(*(u32*)((uint32_t)0x080FFFC0 + 4 * (*(u32*)0x080FFFD8 & 1)))
#define BOT_SCREEN0 (u8*)(*(u32*)((uint32_t)0x080FFFD0 + 4 * (*(u32*)0x080FFFDC & 1)))
Expand Down
14 changes: 14 additions & 0 deletions source/font/font.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//---------------------------------------------------------------------------------
#ifndef _font_h_
#define _font_h_
//---------------------------------------------------------------------------------
#if defined FONT_6X10
#include "font_6x10.h"
#elif defined FONT_ACORN
#include "font_acorn_8x8.h"
#else
#include "font_orig.h" // if nothing is selected
#endif
//---------------------------------------------------------------------------------
#endif //_font_h_
//---------------------------------------------------------------------------------
Loading

0 comments on commit 858342a

Please sign in to comment.