Custom Terminal
-
So far the Terminal works. Using the functions:printf() //Print a string to the Terminal locate() //Set the Terminal's cursor X and Y positions color() //Change the text's color showCursor() //Show the cursor on the Terminal hideCursor() //Hide the cursor on the Terminal cls() //Clear the Terminal's screen
The pixel fonts are 4x4 so as you print a char to the screen Fuze loops about 4 times to display the char to the screen in pixels. So depending on the string's length that will be
str.length * 4
. So if you were to use thecls()
function each loop. That would be78 * 39 * 4 = 12,168
That's a lot of loops per cycle!! One can use this effectively by using a portion of the screen and displaying text within that area or by printing text (which may be in huge quantities) which do not need to be updated per cycle.Shared Code: T5473MND9K
-
Ho it's very cool for make fake MS-DOS thank you ! Do you can create a function scanf ?
-
He i can't download you project ! )':
(project not found) -
@EvanTropFun I think it's still pending. Will be live soon
-
Ok but well done anyway !
-
@EvanTropFun Thank you! Concerning your request for scanf(). That's a C function that allows you to input a string/number or float.
My Terminal mainly prints strings to the buffer while keeping track of the cursor and the color of the text. So implementing a scanf() function would need to be done within the said VM that implements this Terminal.
-
-
@LucasJG25, would it be Ok to borrow your font for my game?
I’ll give you credit, of course!
-
@vinicity Sure. Happy that it can be of use to the community!
-
Thanks!
I don’t quite grasp the code for setting the pixels in the screen array. Too many bit wise operations!How would I go about changing the code if I want an arbitrary colour for the text, and also a transparent background?
-
@vinicity So the color is managed by the
terminal.color
variable which uses the first 3 bits of the variable representing 7 colors in total. If you want more colors you'll need to represent fractions in binary which can be done with a few tricks. For getting the pixels to the screen it edits the current index of the screen array.
The font size is 4x4 so it uses 16 pixels which are a single bit per pixel. The terminal only uses 1 image to draw stuff to. So managing transparency in the code would mean adjusting theterminal.color
variable to take 4 bits instead of 3. So if you wanted black you'll need 1000 in the variable giving you 8. Though it would be much simpler to use the background color for transparency since using {0,0,0,0} would mean leaving behind traces of pixels on the screen from previous frames.As for changing the code. You'd want to focus on functions
putchar()
which sorts out the mapping of the font to the image including bitmasking theterminal.color
variable to the screen array to adjust the color. -
Thanks!
I’ll give it a shot! -
I think I rather butchered your code, but at least I got it working!
Thanks for the help!