Jump to content
IGNORED

The "Draw Circle" Library for IntyBASIC


DZ-Jay

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:
    title-screen.thumb.png.44b08b2804a124fd61dda4321cdcb18e.png

 

  • Test menu and parameter entry:
    test-menu.thumb.png.a98fce0a2b2e82b09602db74228a1b33.pngdata-entry.thumb.png.c27dfd8cfd64092680464b7b92b52940.png

 

  • "Card" and "Bloxel" circle tests:
    test-card.thumb.png.684f044dee987d06dfeb5f8e9a5a8663.pngtest-bloxel.thumb.png.57067625c2d09557e2769aa0b45da286.png

 

  • Visual effects menu:
    vfx-menu.thumb.png.240eff6967909349e65d394fc901a353.png

 

  • Visual effects "Color Bubbles" and "Ring Burst":
    vfx-1.thumb.png.744fe6e703616e60e8f66a8d540018c9.pngvfx-2.thumb.png.aeed40f5b1201b0bafe9cbfdb14f0706.png

 

  • Visual effect "Slide Show," slides illustrating mix of Color Stack, Colored Squares, GRAM and GROM pictures:
    vfx-6-bloxel.thumb.png.7e6d1b0a1e74f4dc632f8e5142569c67.pngvfx-6-colorstack.thumb.png.802ceb8bbf204354d50ace83d95cdfe7.png

 

 

 

 

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:

 

Spoiler
'' ======================================================================== ''
''  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.
    DrawStyle = GetDrawingStyle(DRAW_BLOCK_BLOXEL, DRAW_REGION_FULL, DRAW_SOURCE_FORMAT)
    DrawOpts  = DRAW_OPT_DOUBLE_FILL
    Do
        ' 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
        Next

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

    Return
End

 

 

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.  :)

 

       Enjoy!

 

      -dZ.

  • 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 :)

 

       -dZ.

  • 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.

test-bloxel.thumb.png.7a46c607e9914292f45ac5365575476c.png

 

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.  :)

 

     -dZ.

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.

Guest
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.

Loading...
  • Recently Browsing   0 members

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