Mega Drive text reader

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Post Reply
Brunni
Newbie
Posts: 9
Joined: Tue Dec 18, 2007 8:22 pm
Location: Switzerland

Mega Drive text reader

Post by Brunni » Tue Jun 30, 2009 8:18 pm

Hello!
I don't know if this was already done before (probably :P), but here is a small text reader that I did for the Mega Drive. The goal was to experiment software writes to the VDP with a simple app.

Image

It has smooth scrolling, and you can modify the text color and font using format codes.
There is a small "filesystem" which allows you to add your own files to the ROM image.
I'm curious to discuss about performance for this type of application. For now it's coded in C but I don't think I could earn much in assembly as the main (slow) drawing loop is already very clean.
Here is the download link (src + bin + sample): http://brunni.dev-fr.org/dl/smd/text-reader.7z

Huge
Very interested
Posts: 197
Joined: Sat Dec 13, 2008 11:50 pm

Post by Huge » Tue Jun 30, 2009 8:44 pm

Nice choice for fonts. I almost thought it was HTML before I read your post.

HardWareMan
Very interested
Posts: 745
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Post by HardWareMan » Wed Jul 01, 2009 3:53 am

TrueType font on Megadrive? You used graphic-based printing instead of tile-based (wich more simple and monospaced)? Awesome!

Brunni
Newbie
Posts: 9
Joined: Tue Dec 18, 2007 8:22 pm
Location: Switzerland

Post by Brunni » Wed Jul 01, 2009 10:09 am

Yep thank you ^^
It's a virtual bitmap (like used in 3D games) done by mapping every cell on the map to a unique tile in VRAM. Then when writing a letter I find the right tile to write to.
In fact here is more precisely how it works. The map (38x32) is defined like this:
0 32 64
1 33 65
2 34 66
3 35 67
..........
31 63 95
So for writing, if it's aligned (x mod 8 == 0) and the letter is long enough (at least 8 pixels) it's very easy: you can just write the letter 'h' times (where h is the letter height) because it's vertically contiguous. By using 32 bit arithmetic you can write 8 pixels at once, so work directly with whole lines in a given tile.
If the letter is not aligned you will need to first read what's there and OR it with the letter shifted right, and report the rest of the letter to the following tile. You can avoid rereading from the VRAM by using a buffer that you keep from letter to letter: when you know you are writing to the last tile of a letter (horizontally), you store a copy of what you write to the buffer.
From my calculation 32-bit arithmetic is a good tradeoff compared to the -a lot more- complicated 16-bit arithmetic that would be needed to achieve the same results.
Letters in ROM are thus stored as such: [line 0, pixels 0-7] [line 1, pixels 0-7] ... [line n, pixels 0-7], [line 0, pixels 8-15] , [line 1, pixels 8-15]...
For the color, every letter line, when fetched from ROM, is applied a 32-bit mask which can be for example 0x55555555 to make it use the color n° 5. You can give an effect to the letters like in the title screen by using masks like 0x12344321 (a horizontal gradient).

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Jul 02, 2009 4:07 pm

hehe, this is nice, really great work Brunni :D
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Fri Jul 03, 2009 10:07 pm

Nice VWF routine demo :)

Christuserloeser
Very interested
Posts: 145
Joined: Sun Jan 28, 2007 2:01 am
Location: DCEvolution.net
Contact:

Re: Mega Drive text reader

Post by Christuserloeser » Sat Jul 04, 2009 12:53 am

This is great! - How about implementing VGM playback into your text reader to allow us to listen to music while reading ?

viewtopic.php?t=442

:D
http://www.DCEvolution.net - Gigabytes of free Dreamcast software for you

Image

Brunni
Newbie
Posts: 9
Joined: Tue Dec 18, 2007 8:22 pm
Location: Switzerland

Post by Brunni » Sun Jul 05, 2009 7:02 pm

Thanks ^^ but what is a VWF routine? :oops:
Christuserloeser> No I'm not interested sorry ^^ althrough this project is impressive :D

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Sun Jul 05, 2009 7:07 pm

Variable-Width Font

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Mon Jul 06, 2009 3:41 am

Shiru wrote:Variable-Width Font
yup :) As opposed to a FWF (fixed width font) routine. Anyway, looks nice.

Post Reply