From: falcovorbis <fal...@us...> - 2024-08-19 06:00:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c2d45545e439c0624865b792a23653bb3dfd956b (commit) via 76326ab61332ac7f7257447b88f4ff2bbcbaa712 (commit) from fff864a476bc3096afc0de1b515f1a4453a6caa5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c2d45545e439c0624865b792a23653bb3dfd956b Author: SiZiOUS <si...@gm...> Date: Mon Aug 19 06:59:56 2024 +0100 `utils`: adding `font2txf`, a tool to make TXF from TrueType/OpenType fonts (#704) * `utils`: adding `font2txf`, a tool to make TXF from TrueType/OpenType fonts. This tool is an updated version of the ttf2txf tool created by Chris Laurel for the Celestia project. TXF font format was created in 1997 by Mark J. Kilgard for the OpenGL Utility Toolkit (GLUT). TXF is supported using the `libdcplib` kos-port via the PLIB FNT component. * `utils`: don't build `font2txf` by default (at least for now) commit 76326ab61332ac7f7257447b88f4ff2bbcbaa712 Author: SiZiOUS <si...@gm...> Date: Mon Aug 19 06:25:26 2024 +0100 `LibADX`: adding an example for ADX playback (#715) This example was written by Josh 'PH3NOM' Pearson <ph3...@gm...> (@PH3NOM-PRO). ----------------------------------------------------------------------- Summary of changes: .../dreamcast/{2ndmix => sound/hello-adx}/Makefile | 12 +- examples/dreamcast/sound/hello-adx/libADXplay.c | 121 +++++++ examples/dreamcast/sound/hello-adx/readme.txt | 3 + .../dreamcast/sound/hello-adx/romdisk}/.keepme | 0 utils/font2txf/.gitignore | 40 +++ utils/font2txf/CHANGELOG.md | 35 ++ utils/font2txf/CREDITS | 6 + utils/{genromfs/COPYING => font2txf/LICENSE} | 64 +--- utils/{makeip => font2txf}/Makefile | 0 utils/font2txf/README.md | 169 ++++++++++ utils/font2txf/TODO.md | 10 + utils/font2txf/img/arial.png | Bin 0 -> 76428 bytes utils/font2txf/src/Makefile | 98 ++++++ utils/font2txf/src/Makefile.cfg | 46 +++ utils/font2txf/src/Makefile.hostdetect | 43 +++ utils/font2txf/src/charset.cpp | 32 ++ utils/font2txf/src/charset.h | 19 ++ utils/font2txf/src/global.cpp | 49 +++ utils/font2txf/src/global.h | 83 +++++ utils/font2txf/src/main.cpp | 360 +++++++++++++++++++++ utils/font2txf/src/preview.cpp | 186 +++++++++++ utils/font2txf/src/preview.h | 26 ++ utils/font2txf/src/txfbuild.cpp | 286 ++++++++++++++++ utils/font2txf/src/txfbuild.h | 27 ++ utils/font2txf/src/txfwrite.cpp | 148 +++++++++ utils/font2txf/src/txfwrite.h | 77 +++++ utils/font2txf/src/utils.cpp | 64 ++++ utils/font2txf/src/utils.h | 160 +++++++++ utils/gentexfont/readme.txt | 6 + 29 files changed, 2101 insertions(+), 69 deletions(-) copy examples/dreamcast/{2ndmix => sound/hello-adx}/Makefile (56%) create mode 100644 examples/dreamcast/sound/hello-adx/libADXplay.c create mode 100644 examples/dreamcast/sound/hello-adx/readme.txt copy {addons/lib => examples/dreamcast/sound/hello-adx/romdisk}/.keepme (100%) create mode 100644 utils/font2txf/.gitignore create mode 100644 utils/font2txf/CHANGELOG.md create mode 100644 utils/font2txf/CREDITS copy utils/{genromfs/COPYING => font2txf/LICENSE} (83%) copy utils/{makeip => font2txf}/Makefile (100%) create mode 100644 utils/font2txf/README.md create mode 100644 utils/font2txf/TODO.md create mode 100644 utils/font2txf/img/arial.png create mode 100644 utils/font2txf/src/Makefile create mode 100644 utils/font2txf/src/Makefile.cfg create mode 100644 utils/font2txf/src/Makefile.hostdetect create mode 100644 utils/font2txf/src/charset.cpp create mode 100644 utils/font2txf/src/charset.h create mode 100644 utils/font2txf/src/global.cpp create mode 100644 utils/font2txf/src/global.h create mode 100644 utils/font2txf/src/main.cpp create mode 100644 utils/font2txf/src/preview.cpp create mode 100644 utils/font2txf/src/preview.h create mode 100644 utils/font2txf/src/txfbuild.cpp create mode 100644 utils/font2txf/src/txfbuild.h create mode 100644 utils/font2txf/src/txfwrite.cpp create mode 100644 utils/font2txf/src/txfwrite.h create mode 100644 utils/font2txf/src/utils.cpp create mode 100644 utils/font2txf/src/utils.h diff --git a/examples/dreamcast/2ndmix/Makefile b/examples/dreamcast/sound/hello-adx/Makefile similarity index 56% copy from examples/dreamcast/2ndmix/Makefile copy to examples/dreamcast/sound/hello-adx/Makefile index 0e3b214d..218ef865 100644 --- a/examples/dreamcast/2ndmix/Makefile +++ b/examples/dreamcast/sound/hello-adx/Makefile @@ -1,11 +1,11 @@ -# KallistiOS ##version## # -# 2ndmix/Makefile -# Copyright (C)2003 Megan Potter +# LibADX Test +# Copyright (C) 2011-2013 Josh 'PH3NOM' Pearson <ph3...@gm...> +# Copyright (C) 2024 The KOS Team and contributors # -TARGET = 2ndmix.elf -OBJS = 2ndmix.o romdisk.o +TARGET = libADXplay.elf +OBJS = libADXplay.o romdisk.o KOS_ROMDISK_DIR = romdisk all: rm-elf $(TARGET) @@ -19,7 +19,7 @@ rm-elf: -rm -f $(TARGET) romdisk.* $(TARGET): $(OBJS) - kos-cc -o $(TARGET) $(OBJS) + kos-cc -o $(TARGET) $(OBJS) -lADX run: $(TARGET) $(KOS_LOADER) $(TARGET) diff --git a/examples/dreamcast/sound/hello-adx/libADXplay.c b/examples/dreamcast/sound/hello-adx/libADXplay.c new file mode 100644 index 00000000..8e220511 --- /dev/null +++ b/examples/dreamcast/sound/hello-adx/libADXplay.c @@ -0,0 +1,121 @@ +/* LibADX for KallistiOS ##version## + + libADXPlay.c + Simple "Hello World" style example of ADX playback. + + Copyright (C) 2012 Josh 'PH3NOM' Pearson <ph3...@gm...> + Copyright (C) 2024 The KOS Team and contributors +*/ + +#include <stdio.h> + +#include <kos/dbgio.h> + +#include <dc/maple.h> +#include <dc/maple/controller.h> +#include <dc/sound/stream.h> + +#include <kos/init.h> +#include <kos.h> + +#include <adx/adx.h> /* ADX Decoder Library */ +#include <adx/snddrv.h> /* Direct Access to Sound Driver */ + +#define CONT_RESUME 0x01 +#define CONT_PAUSE 0x02 +#define CONT_RESTART 0x03 +#define CONT_STOP 0x04 +#define CONT_VOLUP 0x05 +#define CONT_VOLDN 0x06 + +int check_cont() +{ + int ret=0; + maple_device_t *cont; + cont_state_t *state; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) + { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) + ret = 0; + if (state->buttons & CONT_START) + ret = CONT_STOP; + if (state->buttons & CONT_X) + ret = CONT_RESTART; + if (state->buttons & CONT_A) + ret = CONT_PAUSE; + if (state->buttons & CONT_B) + ret = CONT_RESUME; + if (state->buttons & CONT_DPAD_UP) + ret = CONT_VOLUP; + if (state->buttons & CONT_DPAD_DOWN) + ret = CONT_VOLDN; + } + return ret; +} + +int main() +{ + /* Print some text to the screen */ + int o = 20*640+20; + bfont_set_encoding(BFONT_CODE_ISO8859_1); + bfont_draw_str(vram_s+o,640,1,"LibADX (C) PH3NOM 2012"); o+=640*48; + printf("LibADX (C) PH3NOM 2012\n"); + + /* Start the ADX stream, with looping enabled */ + if( adx_dec( "/rd/test.adx", 1 ) < 1 ) + { + printf("Invalid ADX file\n"); + return 0; + } + + /* Wait for the stream to start */ + while( snddrv.drv_status == SNDDRV_STATUS_NULL ) + thd_pass(); + + bfont_draw_str(vram_s+o,640,1,"Press Start to stop, press X to restart"); + o+=640*48; + bfont_draw_str(vram_s+o,640,1,"Press A to pause, press B to resume"); + o+=640*48; + bfont_draw_str(vram_s+o,640,1,"Press UP or Down to increase/decrease volume"); + + /* Check for user input and eof */ + while( snddrv.drv_status != SNDDRV_STATUS_NULL ) { + int vol; + switch (check_cont()) { + case CONT_RESTART: + if(adx_restart()) + printf("ADX streaming restarted\n"); + break; + case CONT_STOP: + if(adx_stop()) + printf("ADX streaming stopped\n"); + break; + case CONT_PAUSE: + if(adx_pause()) + printf("ADX streaming paused\n"); + break; + case CONT_RESUME: + if(adx_resume()) + printf("ADX streaming resumed\n"); + break; + case CONT_VOLUP: + vol = snddrv_volume_up(); + printf("SNDDRV: Volume set to %i%s\n", ((vol*100)/255), "%"); + break; + case CONT_VOLDN: + vol = snddrv_volume_down(); + printf("SNDDRV: Volume set to %i%s\n", ((vol*100)/255), "%"); + break; + default: + break; + } + thd_sleep(50); + } /* when (snddrv.drv_status == SNDDRV_STATUS_NULL) the stream is finished*/ + + printf( "LibADX Example Finished\n"); + + return 0; +} diff --git a/examples/dreamcast/sound/hello-adx/readme.txt b/examples/dreamcast/sound/hello-adx/readme.txt new file mode 100644 index 00000000..e08dcc08 --- /dev/null +++ b/examples/dreamcast/sound/hello-adx/readme.txt @@ -0,0 +1,3 @@ +This example expects a file called "test.adx" to exist in the root of the +romdisk. Put a relatively small adx file with the correct filename in the +romdisk directory before compiling if you want the example to work. ;) diff --git a/addons/lib/.keepme b/examples/dreamcast/sound/hello-adx/romdisk/.keepme similarity index 100% copy from addons/lib/.keepme copy to examples/dreamcast/sound/hello-adx/romdisk/.keepme diff --git a/utils/font2txf/.gitignore b/utils/font2txf/.gitignore new file mode 100644 index 00000000..5bcd548d --- /dev/null +++ b/utils/font2txf/.gitignore @@ -0,0 +1,40 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Fonts +*.ttf +*.otf +*.txf + +# Other types +*.log diff --git a/utils/font2txf/CHANGELOG.md b/utils/font2txf/CHANGELOG.md new file mode 100644 index 00000000..1b2474ef --- /dev/null +++ b/utils/font2txf/CHANGELOG.md @@ -0,0 +1,35 @@ +# font2txf: Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.12.0] - 2024-08-xx + +### Added + +- Preview option (`-p`), used for displaying the generated TXF file at the + end of the process. This requires [Freeglut](https://freeglut.sourceforge.net/), + but it can be disabled if needed at compile time. +- Verbose option (`-v`), that display the original output from `ttf2txf`. + +### Changed + +- Complete redesign/refactoring of the whole code. Splitting code into many + small source files instead of a single `ttf2txf.cpp` file. +- Command-line options were updated a bit (exclusion between `-c` and `-f`, + `-q` is really quiet now, `-h` stands for help now but can be mapped to + height as originally if used with `-w`, etc.). +- Program is now licensed under the **GNU GPL 2 License** like the + [Celestia](https://celestiaproject.space/) project (previously this tool + wasn't clearly licensed). + +### Fixed + +- Some memory leaks while building the TXF font when an error occured. + +## [1.11.0] - 2001-10-20 + +### Added +- Initial release used for the [Celestia](https://celestiaproject.space/) project. diff --git a/utils/font2txf/CREDITS b/utils/font2txf/CREDITS new file mode 100644 index 00000000..9caa9721 --- /dev/null +++ b/utils/font2txf/CREDITS @@ -0,0 +1,6 @@ +font2txf: Credits + +- Mark J. Kilgard: Creator of the Texture Mapped Font (TXF) format. +- Chris Laurel and the Celestia project team: The initial authors of the original "ttf2txf" utility. + https://web.archive.org/web/20051104023112/http://www.shatters.net/~claurel/celestia/fonts/tt2txf/ +- Mickaël Cardoso (SiZiOUS): Complete refactoring of the project. diff --git a/utils/genromfs/COPYING b/utils/font2txf/LICENSE similarity index 83% copy from utils/genromfs/COPYING copy to utils/font2txf/LICENSE index dc63aaca..5ec43ee1 100644 --- a/utils/genromfs/COPYING +++ b/utils/font2txf/LICENSE @@ -1,9 +1,8 @@ - GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -277,64 +276,3 @@ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/utils/makeip/Makefile b/utils/font2txf/Makefile similarity index 100% copy from utils/makeip/Makefile copy to utils/font2txf/Makefile diff --git a/utils/font2txf/README.md b/utils/font2txf/README.md new file mode 100644 index 00000000..29ce2581 --- /dev/null +++ b/utils/font2txf/README.md @@ -0,0 +1,169 @@ +# font2txf + +**font2txf** is an utility used for generating texture mapped font files, +also known as the `TXF` format, from a **TrueType** (`TTF`) or **OpenType** +(`OTF`) font file. + +`TXF` is a texture font which can be used in the context of **GLUT** (OpenGL +Utility Toolkit), created by [Mark J. Kilgard](https://en.wikipedia.org/wiki/Mark_Kilgard). +For the **Sega Dreamcast**, the `TXF` format is supported using the `libdcplib` +KallistiOS Port, using the `PLIB FNT` component. An example of source code, +including sample `TXF` fonts, is available here: + + $KOS_BASE/examples/dreamcast/cpp/dcplib + +For generating `TXF` files, you can use the provided `gentexfont` (originally +written by Mark himself), `ttf2txf` (from the [Celestia](https://celestiaproject.space/) +project) or this `font2txf` utility. + +Below you'll find an example of a `TXF` generated font, from the `Arial` +TrueType font: + + + +## Building + +This program is a standard C program which may be compiled with **GNU Make**. +It requires `FreeType` installed. +[Learn more about FreeType here](http://freetype.org/). + +1. Edit the `Makefile.cfg` and check if everything is OK for you; +2. Enter `make` (`gmake` on BSD systems). + +If you want to enable the **Preview** feature (as displayed in this +`README` file), you will have to install `freeglut`. +[Learn more about freeglut here](https://freeglut.sourceforge.net/). + +Please note that you can indeed make a static binary by setting up +the `STANDALONE_BINARY` flag to `1`. This was created with Microsoft +Windows in mind, but could work on other OS as well. + +## Usage + +To use this tool, the usage is nearly identical as the original `ttf2txf` +utility. The minimal command-line is: + + ./font2txf <fontfile.ttf> + +This will convert `fontfile.ttf` to the corresponding `fontfile.txf`, +using the defaults, which are a `256x256` texture size, using a `20pt` font +size and the default charset, which is: + + (space)(A..Z)1234567890(a..z)?.;,!*:"/+-|'@#$%^&<>()[]{}_ + +Of course, `(space)` means a blank space character (` `) and `(A..Z)` means +every characters, from `A` to `Z` (same for `(a..z)`). + +Example of a more complete command-line: + + ./ttf2txf -o revenant.txf -s 22 -w 256 -h 256 -c "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_=+[]{}|;:,.<>~ ?/" revenant.ttf + +The `revenant.txf` file will be generated from the `revenant.ttf` font, +in a `256x256` texture, using the charset passed with the `-c` switch, +and using the `22pt` size. + +### Available Options + +Available options are (displayed with the `-h` switch): + + -w <width> Texture width (default: 256) + -e <height> Texture height (default: 256); also `-h` for compatibility + -c <string> Override charset to convert; read from command-line + Cannot be mixed with `-f` + -f <filename.txt> Override charset to convert; read from a text file + Cannot be mixed with `-c` + -g <gap> Space between glyphs (default: 1) + -s <size> Font point size (default: 20) + -o <filename.txf> Output file for textured font (default: <fontfile>.txf) + -q Quiet; except error messages, cannot be mixed with `-v` + -v Verbose; display more info, cannot be mixed with `-q` + -p Preview; display the txf output at the end of the process + -h Usage information (you're looking at it); if `-w` not set + +### Altering the generated texture + +The `-w` (width) and `-e` (height) options are used for altering the size of the +generated texture. For compatibility reasons, `-e` can be replaced by `-h`, if +used with `-w`. Indeed in the original `ttf2txf` tool, `-h` was mapped to texture +height, but now it means displaying help. ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |