Skip to content

Commit

Permalink
cleanup gdextensions; add tools and update .gitignore with binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ppiecuch committed Sep 25, 2024
1 parent 49c4657 commit 6938dc8
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,11 @@ $RECYCLE.BIN/
*.msm
*.msp
*.lnk

##################################
### Modules tools and binaries ###
##################################

modules/gdextensions/submodules/benchmark/tools/read_dat
modules/gdextensions/_tools/conv_rgb_to_8
modules/gdextensions/_tools/dos_font_data*
57 changes: 57 additions & 0 deletions modules/gdextensions/_tools/conv_rgb_to_8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#define GL_RGB 3

typedef struct {
const char *label;
const char *image;
const unsigned char *pixels;
int char_w, char_h, size, width, height, channels;
} EmbedImageItem;

extern const unsigned char font_8x16[], font_8x12[], font_8x8[], font_7x9[], font_4x6[];
const EmbedImageItem embed_debug_font[] = {
{ "font_8x16", "dos-8x16.bmp", font_8x16, 8, 16, 196608, 128, 512, GL_RGB },
{ "font_8x12", "dos-8x12.bmp", font_8x12, 8, 12, 147456, 128, 384, GL_RGB },
{ "font_8x8", "dos-8x8.bmp", font_8x8, 8, 8, 98304, 128, 256, GL_RGB },
{ "font_7x9", "dos-7x9.bmp", font_7x9, 7, 9, 96768, 112, 288, GL_RGB },
{ "font_4x6", "dos-4x6.bmp", font_4x6, 4, 6, 36864, 64, 192, GL_RGB },
{ NULL, NULL, 0, 0, 0, 0, 0, 0 }
};

#include "dos_font_data_rgb.h"

int main() {
FILE *out = fopen("dos_font_data_8.h", "w");
if (out == 0) {
printf("Cannot open dos_font_data_8.h!\n");
exit(1);
}
EmbedImageItem *el = (EmbedImageItem *)&embed_debug_font[0];
int index = 1;
while (el->image) {
printf("Converting %s ..\n", el->image);
fprintf(out,
"/* %s contains file \"%s\". */\n"
"const unsigned char %s[] =\n"
"{",
el->label, el->image, el->label);

assert(el->size % 3 == 0);

for (int b = 0; b < el->size; b += 3) {
if (b % 10 == 0)
fprintf(out, "\n\t");
fprintf(out, "0x%02x", el->pixels[b]);
if (b + 3 != el->size)
fprintf(out, ",");
}

fprintf(out, "\n};\n\n");
el++;
index++;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added modules/gdextensions/_tools/fonts/dos-4x6.bmp
Binary file not shown.
Binary file added modules/gdextensions/_tools/fonts/dos-7x9.bmp
Binary file not shown.
Binary file added modules/gdextensions/_tools/fonts/dos-8x12.bmp
Binary file not shown.
Binary file added modules/gdextensions/_tools/fonts/dos-8x16.bmp
Binary file not shown.
Binary file added modules/gdextensions/_tools/fonts/dos-8x8.bmp
Binary file not shown.
19 changes: 19 additions & 0 deletions modules/gdextensions/_tools/make_figfonts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

ROOT=~/Private/Workspace/embedFiglet
CONV=$ROOT/scripts/FigletFontConvert.rb

ruby $CONV $ROOT/res/figfonts/Calvin\ S.flf > figlet_font_calvins.cpp
ruby $CONV $ROOT/res/figfonts/maxiwi.flf > figlet_font_maxiwi.cpp
ruby $CONV $ROOT/res/figfonts/maxii.flf > figlet_font_maxii.cpp
ruby $CONV $ROOT/res/figfonts/DOS\ Rebel.flf > figlet_font_dosrebel.cpp
ruby $CONV $ROOT/res/figfonts/ANSI\ Regular.flf > figlet_font_ansiregular.cpp

sed -i '' \
-e 's/Calvin S/calvins/g' \
-e 's/DOS Rebel/dosrebel/g' \
-e 's/ANSI Regular/ansiregular/g' \
-e 's/Figlet.hh/figlet_font.h/g' \
figlet_font_*.cpp
23 changes: 23 additions & 0 deletions modules/gdextensions/_tools/make_fonts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Convert to 1-bit bmp:
# ---------------------
# > convert fonts.altered/dos-8x8@24.bmp -monochrome -depth 1 fonts.altered/dos-8x8@1.bmp

set -e

DEVTOOLS="~/Private/Projekty/0.shared/common-dev-tools"

$DEVTOOLS/res_tools/c-embed/c-embed \
dos_font_data \
fonts.altered/*.bmp

sed -i '' -e 's/embed_1/font_4x6/g' dos_font_data.*
sed -i '' -e 's/embed_2/font_7x9/g' dos_font_data.*
sed -i '' -e 's/embed_3/font_8x12/g' dos_font_data.*
sed -i '' -e 's/embed_4/font_8x16/g' dos_font_data.*
sed -i '' -e 's/embed_5/font_8x8/g' dos_font_data.*

mv -v dos_font_data.c dos_font_data_rgb.h
gcc -o conv_rgb_to_8 conv_rgb_to_8.cpp
./conv_rgb_to_8

0 comments on commit 6938dc8

Please sign in to comment.