Mega Drive text reader
Moderator: Mask of Destiny
Mega Drive text reader
Hello!
I don't know if this was already done before (probably ), 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.
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
I don't know if this was already done before (probably ), 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.
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
-
- Very interested
- Posts: 745
- Joined: Sat Dec 15, 2007 7:49 am
- Location: Kazakhstan, Pavlodar
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).
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).
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
hehe, this is nice, really great work Brunni
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 145
- Joined: Sun Jan 28, 2007 2:01 am
- Location: DCEvolution.net
- Contact:
Re: Mega Drive text reader
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
viewtopic.php?t=442
-
- Very interested
- Posts: 256
- Joined: Tue Sep 11, 2007 9:10 pm