(http://www.playbasic.com)
Challenge #27 - Learn binary operations through Retro Computer Graphics
Those who grew up in the age of 8bit computers would no doubt remember the pain of writing video games on these systems. It wasn't just the speed, but it felt like the graphics hardware designers were conspiring against the programmer at times, intentionally making it difficult to do the most trivial of tasks. Like you'd think drawing a DOT would be easy right ? Unfortunately not, as many if those systems have scrambled video memory layouts and packed bit / planar displays. The upside of that, is it really made you learn about Binary operations and low level memory access. Which seems to be a thing of the past today in BASIC programming.
One common format seen in many retro computer systems for bitmap graphics are variations of planar. Generally in these formats 8 pixels on screen are represented within a single byte (plus generally a character map). Each bit in the byte is an individual pixel on screen. This can be pretty efficient in terms of memory usage, but it raises the complexity of drawing bitmap graphics. So to make this challenge somewhat easier the Retro Computer Environment library emulates a 2 colour planar graphics hardware.
The screen is 640*400 pixels, each pixel is a single BIT, so it's two possible colours. The screen memory is (640/8)*400 bytes. Each row is a (640/80) 80 bytes long. The manipulate the individual pixels you'll need to calculate the location of the byte that contains the pixel(s) then AND / OR / XOR the bits..
The attached template does all the work (and includes some example rendering functions DOT / BOX / CLS to get you started), but your challenge is try and implement either better ways of doing those functions as well of other primitive drawing functions.
Graphics Programming Challenges:
* Dot (Replace it)
* Box (Replace it)
* Add Font/Character Rendering
* Add Sprite rendering (clipping optional)
* Line (clipping optional)
* Circle (clipping optional)
* Polygon (clipping optional)
The challenge is not only to come up a with some rendering functions, but try and come up with the most optimal method you can. What you'll find, is that the more you look over your code you'll start to see alternative methods for solving each problem. I'll give you a hint, the most optimal solution tends not to be the first or second attempt, it's probably going to take you a 3 or 4 attempts to really get something up to speed..
So for those that on take such this challenge, you'll learn many fundamentals (dealing with Binary data / memory access & more importantly optimization) that will translate into your everyday BASIC programming skills. It's not an easiest challenge and it's not meant to be !
Good luck !
As always we'll award Extra Brownie points to the most creative submissions .
Downloads The Retro Computer Environment is attached to this post bellow. The whole idea here is you add your functions to the template to build your own mini graphics library. So when you post your solutions, you don't need to include the RCE library, just the code in your Main source file.
8Bit Games Here's a look a classic game ELITE written way back in the early 80's
BBC version shown Submission * Submissions can be written in any version of PlayBASIC (https://www.playbasic.com)
* Submission can only be accepted in
Source Code form only.
* No external media is permitted for this challenge.
*
Zip up your Submissions and please try to keep it smaller than
500K !
*
Authors automatically give consent for their submission(s) to distributed and used for promotional purposes via UnderwareDesign.com, PlayBasic.com code tank.
* Authors can submit as many times as they like.
* To make a submission, zip up your projects and either post it in this thread, or create your own thread in either the Source Codes or Show Case forums and post a link bellow.
Dead Line Anytime before the next ice age
Prizes * The best submissions will be periodically highlighted through the PlayBasic IDE news service / News Letters/ FaceBook (http://www.facebook.com/pages/PlayBasic/127905400584274), Twitter (http://www.twitter.com/PlayBasic) or the PlayBASIC youtube channel (http://www.youtube.com/playbasic).
Return to Challenge Index (https://www.underwaredesign.com/forums/index.php?topic=3225.0)