Skip to content

Godot text mode console compatible with ANSI colors, iCE colors, and 8x16px DOS font for rendering ANSI art in Godot using tilemaps!

Notifications You must be signed in to change notification settings

grymmjack/godot-console

Repository files navigation

GODOT-CONSOLE

Working CGA Godot Text Mode 16 color DOS console

Supports multiple screen modes:

More goodies

  • Greatly expanded the exported parameters
  • Added scale factor
  • Added support for ANSIFlags - see: https://www.acid.org/info/sauce/sauce.htm#ANSiFlags
  • Changing screen mode and scale in Editor updates in real time
  • Can now load ANSIs!
  • Supports iCE colors (16 background colors no blinking)
  • Supports blinking :)

TO DO

  • Cursors
  • Input
  • Baud Rate Emulation
  • Scrolling / Scrollback
  • PIPEPRINT! port from my QB64 library
  • Lightbar Menus :D
  • ANSI Music?
  • Legacy DOS Aspect Ratio / Square Aspect Ratio support (maybe!)
  • Possibly making this an @tool so it can load an ANSI into the editor in 2D mode GUI

Example ANSIs

image

Example output

image Web export version here (I will update this as needed)

9px width mode

image

8px width mode

image

8x8 font mode

image

Blinking examples

Regular old blinking godot-console-blinking-example Cat blinking :D godot-console-blinking-example-cat Supports blinking and non-blinking at the same time because tiles godot-blinking-and-non-blinking-at-once

The node tree is uncluttered: image

  • SCREEN = TextConsole node
  • BG = TileMapLayer named BG, which uses the solid color tile map
  • FG = TileMapLayer named FG, which uses the font tile map and alternative tiles for each color in the palette.

How to use

  1. Load main.tscn
  2. Adjust properties of the SCREEN node to suit in the property inspector
  3. In scripts/main.gd make sure it is TextScreen and extends AnsiParser that's it.

How the hell does this work?

The trick here is that there are 2 tilemap layers. A background one (BG) for background colors under the foreground one (FG).

  • Since CGA has 16 background colors we have 16 background tiles in the BG tilemap.
  • Since CGA has 16 foreground colors, we have 1 DOS Font 8x16 that has alternative tiles for every tile to match every color in the CGA palette. (Thanks to SelinaDev for the help and idea to use alternative tiles instead of duplicate tilemap atlasses!)

Then we just use set_cell and some little translation funcs to do stuff. This gets us a x, y grid just like SCREEN 0 in basic, etc. It's not REAL console mode, it's a graphical version. Godot doesn't have the ability to do CLI stuff AFAIK.

BASIC-like API (WIP)

  • echo = print
  • cecho = print in colors (specify fg/bg)
  • locate = locate :D
  • cls = cls
  • load_ansi_file(pathname) = load and display an ANSI file
  • etc.

See: scripts/text_console.gd for basics, consts, enums, etc.

Example use in scripts/main.gd:

extends TextConsole

func _ready() -> void:
	color(CGA.BRIGHT_WHITE, CGA.BLUE)
	cls()
	print_ruler()
	locate(10, 2)
	cecho("    Hello, World!    ", 14, 4)
	# will load ansi file from disk at current cursor position
	load_ansi_file("res://your_ansi.ans")

# print a little ruler
func print_ruler() -> void:
	for y in range(height):
		for x in range(width):
			if y == 0:
				if x % 10 == 0:
					locate(x, y)
					echo(str(x))
		locate(0, y)
		echo(str(y))

PLAN?

godot-console

Thanks again to Axel for the mentoring/peer reviews, Hueson for the idea to use TileMaps in general, and Selina for the guidance on best way to do it! ❤️

About

Godot text mode console compatible with ANSI colors, iCE colors, and 8x16px DOS font for rendering ANSI art in Godot using tilemaps!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published