Feb 18, 2009
Textmode experiments using Alchemy and C++
Recently, I’ve been playing a lot with Alchemy, an Adobe Labs project that allows developers to compile C/C++ code for use in AVM2. Brandon Hall does a great job of explaining exactly how Alchemy works, so I won’t bother.
I’ve been thinking about writing an bitmap to ASCII converter ever since I started obsessing over textmode a few months back. Luckily I was sidetracked with AS3ANSI and Flashterm long enough for Alchemy to mature a bit. Of course, ASCII converters have been done in Flash before. The one that immediately comes to mind is Asciify by Pierluigi Pesenti. While these converters actually worked, I was never satisfied with the character results or the speed.
By far, the best bitmap to ASCII libraries exist in C/C++, most notable being AA-lib. That’s where I started. After successfully installing and testing Alchemy, I began the work of modifying AA-lib. Those early experiments didn’t go well. AA-lib is well structured, but I found it difficult to control. It didn’t help that I was trying to relearn C (which I haven’t touched since school) at the same time.
That’s when I stumbled upon TextFX, a textmode graphics library for Windows written by demoscene coder Jari Komppa. Check his award winning demo that was built off the library. TextFX was exactly what I needed. It is powerful, lightweight, and easy to modify. Hell, does anything bad ever come from the demoscene? Jari built an award winning demo out of the library.
It took some work to marshal the bytearray’s properly, especially since I needed to worry about memory allocation and interpreting the Windows console screen buffer, but the end result was exactly what I wanted. The actual calls to C++ were lightning fast, processing 64k bitmapdata bytearray’s in ~5-10ms. I was already aware of the slow down with AS to C++ communication, so I kept my calls to a minimum (one per frame). The only real bottle occurred with Actionscript drawing the result (the reason fps is around 20).
So far I’m impressed with Alchemy. With careful control I can see it being a valuable addition to projects that require heavy number crunching.





This is very cool!!! Nice idea!
Awesome. When’s ASCII star wars coming out on blue ray? Haha.
i want an clear explanation about c++ in text mode &process