Jump to content

The "Draw Circle" Library for IntyBASIC


Recommended Posts

Over 10 years ago, I posted an Assembly Language code module for drawing circles.  I used it in Christmas Carol for screen transitions and other effects.  I believe it also made its way to some of @catsfolly's games, where he extended the routine to use Colored Squares mode.

Fast forward to the present day, and I found myself in need of something similar for one of my projects.  Because I was trying to develop my new project entirely in IntyBASIC (as a personal challenge and to force myself to learn the language), I decided to port it.


However, rather than just port it from Assembly to IntyBASIC, I decided to go back to the original C source I found on the Internet and re-implement it from scratch.  The result is the "Draw Circle" library, a software library for IntyBASIC programs for drawing circles.


I added a bunch of new features and options to make it not only easy to use, but more versatile.  Among these are:

  • Support for all Intellivision color modes.
  • Supports a number of input parameters that control the drawing behaviour.
  • It can draw with using either a regular background card (from GRAM or GROM) or Colored Squares.
  • It can also draw using data from a screen buffer (in an array variable or ROM data).
  • Automatically clips when drawing outside screen boundaries.
  • Supports limiting the boundaries to a smaller screen region (with automatic clipping).


And as if all that wasn't enough, I wrote a user's manual that describes in excrutiating detail what it is, how to use it, and how it works -- and even a demo program that not only allows you to test the drawing routine, but showcases its utility and versatility with some fancy visual effects!


I thought the whole circle drawing project was so cool that I decided to share it with everyone.


At this point you may be asking yourself, why would I want to draw a circle?  Well, just take a look at the videos below for some examples made entirely with the "Draw Circle" library.  I intend to use variations of these effects in my own programs, for scene transitions, etc.  I invite you all to use the library in your own programs.  I can't wait to see what cool stuff you come up with!


Here are some screenshots:

  • Title screen:


  • Test menu and parameter entry:


  • "Card" and "Bloxel" circle tests:


  • Visual effects menu:


  • Visual effects "Color Bubbles" and "Ring Burst":


  • Visual effect "Slide Show," slides illustrating mix of Color Stack, Colored Squares, GRAM and GROM pictures:





Visual Effect #1: Color Bubbles

Fills the screen with colorful bubbles that grow to random sizes.




Visual Effect #2: Ring Burst

Fills the screen with colorful rings that grow to random sizes and consume each other.





Visual Effect #3: Sonar Pulse

Simulates a sonar or radar pulse that appears to "ping" on top of the menu screen.





Visual Effect #4: Color Transition

Simulates a "closing circle" color transition that covers a scene completely.





Visual Effect #5: Scene Reveal

Simulates an "opening circle" transition that reveals one scene on top of another.





Visual Effect #6: Slide Show

By far the most complex of all effects, it simulates a slide show that cycles through various scenes taken from classic games, using a variety of circle transition effects and techniques.





The above videos were recorded from the emulator.  They seem to have dropped some frames, but I can assure you that the demos looks a lot better in person. :)


The full source code for the effects is included with the demo program.  Everything is meticulously (some would say, obsessively) commented and should be easy to follow.


The vast majority of the complexity is encapsulated by the "DrawCircle" procedure, so making the effects is just a matter of plugging in some parameters in the input variables, and calling the procedure in a loop.  Below is the code for the "Color Bubbles" effect, just to show how simple it all is, encapsulated in the "DoVfxColorBubbles" procedure:


'' ======================================================================== ''
''  DoVfxColorBubbles                                                       ''
''      Runs the "Color Bubbles" visual effect using Colored Squares mode.  ''
''      The effect will cycle continuously until the user presses any key   ''
''      on the keypad.                                                      ''
''                                                                          ''
''      Effect Description:                                                 ''
''          On each iteration, the routine will randomly choose a position  ''
''          on the screen, a maximum circle radius, and a drawing color.    ''
''                                                                          ''
''          Using the chosen random parameters, the routine will then draw  ''
''          increasingly larger concentric circles at the chosen location,  ''
''          starting from a radius of zero, until the maximum is reached.   ''
''                                                                          ''
''          The end result gives the effect of an expanding color bubble.   ''
''                                                                          ''
''      Input:                                                              ''
''          None.                                                           ''
''                                                                          ''
''      Output:                                                             ''
''          None.                                                           ''
''                                                                          ''
''      Temp:                                                               ''
''          TempMax                                                         ''
''          InputAny                                                        ''
'' ======================================================================== ''
DoVfxColorBubbles: Procedure
    Wait : Cls

    ' Configure the drawing style.
        ' Initialize a new circle.
        OrigX   = Random(CSQ_BLOXEL_MAX_X + 1)
        OrigY   = Random(CSQ_BLOXEL_MAX_Y + 1)
        TempMax = (Random(8) + 2)

        ' Choose a colour, but not the background!
        #PlotFormat = Random(CS_PIX0_BACKGROUND)

        For Radius = 0 To TempMax
            ' Draw a circle ...
            Gosub DrawCircle

            ' Check if the user wants to exit ...
            Gosub GetNewInput
            If (InputAny <> INPUT_NONE) Then
                Exit For
            End If

        ' Pause before drawing the next bubble ...
        If (InputAny = INPUT_NONE) Then
        End If
    Loop Until (InputAny <> INPUT_NONE)




All code is similarly commented -- even the support routines and functions.  If you find any of it useful, by all means, use it in your own programs.


I have prepared two distribution packages:  one for the IntyBASIC SDK, and the other for just the compiler and assembler.


Download the Draw Circle Library:


For those using the IntyBASIC SDK, just drop the "circle" folder contained in the package above, into the "Projects" folder of your SDK installation, then use "intybuild" and "intyrun" to build and run.


Many thanks to Alois Zingl, who wrote the algorithm (a variant of Bresenham's Line Algorithm applied to circles) and original C implementation from which my code is made; and who so graciously gave me permission to share it and re-distribute it.  You can find information about Herr Zingl's circle drawing algorithm on his web site:


If you have any questions, comments, or suggestions, just let me know.  Also, if you encounter any problems or bugs, you can post them below.  :)





  • Like 6
  • Thanks 2
Link to comment
Share on other sites

1 hour ago, nanochess said:

Wow! Pretty amazing.


Kudos for your hard work 😀👍🏻


Thank you!  I will be honest with you, I'm kind of liking IntyBASIC.  I sometimes get frustrated with some things, and I'm just too old and set in my ways with Assembly, but it's great to put things together quickly, and it has enough power to do really cool stuff, and some serious work.


Still, my favorite part of IntyBASIC is all the cool games that have come out because of it.  So thanks to you too for making IntyBASIC :)



  • Like 1
  • Thanks 1
Link to comment
Share on other sites

I added some screenshots and the ROM file to the first post.


I love how the "bloxel" circle test looks -- it is chunky, but does not look bad at all.



I have this idea of drawing circles like that, using Colored Squares, on top of a regular Color Stack screen, sort of like the "Sonar Pulse" VFX example above, but using Colored Squares.  I think it can be used to simulate something like a blast shockwave from an explosion, passing through the screen.  I wanted to implement something like that, but had some trouble with the performance.  (Drawing circles repeatedly with Colored Squares gets a bit heavy on the CPU.)


At some point, I will re-implement the entire library in Assembly Language for Raw! Ultimate! Powah! and try it out again.  Of course, it would be integrated with IntyBASIC.


In the meantime, the VFX examples in the demo program should give some idea about what is possible and practical.  It is not perfect, and it could be optimized for speed, but it seems to work in general.  :)



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...