Megazeux character set

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
Posts: 2128
Joined: Jun 21, 2005 19:04

Megazeux character set

Post by angros47 »

Does anyone remember the game MegaZeux?
Originally a DOS game, it was later ported on many platform, including web pages. Under DOS, it achieved its graphics using redefined fonts, as a primitive tile engine.
The redefined fonts were stored in files with .chr extensions.

I tried to load them with FreeBasic, here is the result:

Code: Select all

type Font
  w as long
  h as long
  d as any ptr
end type

  FB_FONT_8 = 0,
end enum

extern Fonts(2)  alias "__fb_font"  as Font

sub reverse(byref b as ubyte)
	b = (b and &HF0) shr 4 or (b and &H0F) shl 4
	b = (b and &HCC) shr 2 or (b and &H33) shl 2
	b = (b and &HAA) shr 1 or (b and &H55) shl 1
end sub

sub LoadChar (fontname as string)

	open fontname for binary access read as #1

	dim as long y
	dim row as ubyte ptr, b as ubyte

	for y = 1 to 8*256
		get #1,,b
		reverse b
	close #1
end sub

screenres 800,600
width 100, 42

LoadChar "Mario_1.chr"
for i as integer=0 to 255
	locate 1+2*(i\25),(i*3) mod 75
	Print chr(i)

The file "Mario_1.chr" comes from this game:
Post Reply