Megazeux character set

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

Megazeux character set

Post by angros47 »

Does anyone remember the game MegaZeux? https://www.digitalmzx.com/
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

enum
  FB_FONT_8 = 0,
  FB_FONT_14
  FB_FONT_16
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

	row=Fonts(FB_FONT_14).d
	for y = 1 to 8*256
		get #1,,b
		reverse b
		*row=b
		row+=1
	next
	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)
next

sleep
The file "Mario_1.chr" comes from this game: https://www.digitalmzx.com/show.php?id=1400
Post Reply