Software sprites?

Basic and Machine Language

Moderator: Moderators

User avatar
Vic 20 Nerd
Posts: 874
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Software sprites?

Postby beamrider » Wed Aug 09, 2017 10:10 am

No reason, you can't call it from 'c' or BASIC.

Would just need to import the data structures, sprite register locations and calls in the appropriate form. No-one has done this to my knowledge though.

I thought about using it to write an *enhanced version of 'blue-meanies' in 'c' as a example/bootstrap project, but never got around to it :(

* The enhancements I had in mind were:smooth movement, better graphics and not pausing when you fired the lasers.

User avatar
Vic 20 Nerd
Posts: 874
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Software sprites?

Postby beamrider » Sun Aug 13, 2017 3:30 am

I've created a C bridge or wrapper around the SSS by Robert Hurst. It can be downloaded from the following location: ... DRwVE9BUWM

The link is a .zip file that unpacks to a hello world project....


Everything is setup up to get you up and running quickly - it includes a copy of CC65 and VICSSS (but not VICE).

Inside the folder is a COMPILE.BAT that generates the above .PRG file. You will just need to change the path to the location of VICE on your machine
at the bottom of this file.


Code: Select all

"c:\MyViceFolder\xvic.exe" -moncommands %~dp0\obj\%TITLE%.sym  -memory 16k  bin\%TITLE%.prg

The guts of the program is in the file main.c and should be self explanatory with the //COMENTS and reading the included SSS pdf docs and a smattering of C knowledge.

Code: Select all

void main (void)
   BYTE bigDudeSprite = 0;
   BYTE idx = 0;

   // Set the screen colours
   textcolor (COLOR_RED);
   bordercolor (COLOR_BLUE);
   bgcolor (COLOR_BLACK);

   // Init Vic SSS

   // Start IRQ routine for optional frame rate lock   
   // Create the sprite
                        | SPRITEDEF_WIDTH_16
                        | SPRITEDEF_FLOATY_FLOAT
                        | SPRITEDEF_FLOATX_FLOAT
                        | SPRITEDEF_ENABLED);

   // Clear screen
   // Hello text..

   // Select sprite
   // Set sprite bitmap

   // LOOP forever..
      for (idx = 16; idx < 192; idx++)
         // Move sprite to x,y cords
         SSSMOVEXY(idx, idx);

A brief explanation some of the other files that are not documented in SSS:

data.s - you can put sprite data etc in here
RasterSync.s - [Assembler SSS] IRQ handler for flicker free sprites
vis-sss-bridge.s -C compatible assembly wrappers for SSS
vis-sss-bridge.h - C header file for SSS function definitions and SYMBOLS
vic20-16k.cfg - linker configuration file. Describes the memory layout and where to put each code file.

You may find an IDE type environment useful. I use Notepad ++ [with NppExec / Explorer plugins] so I can edit files and save/compile/run with a simple Ctrl+F6. You may wish to use Visual Studio code or similar...


You may find my Screen Designer will be useful for generating sprite data using the bitmap function...

There are plenty of tutorials for C on the web.

This zip file was developed under windows, but should be easy to change to other platforms. If anyone would like to produce and share a unix/mac variant that would be great...

Hoping this will encourage some people to progress from BASIC programming - those that don't want the tedium of writing assembly or writing a sprite library.

[I haven't tested all of the SSS API functions from C, but they should work. Let me know if you find a problem]

If there is enough interest I might extend this Hello World into a small game with some background music etc..

Any questions shout up..
Last edited by beamrider on Tue Aug 15, 2017 6:21 am, edited 1 time in total.

User avatar
Omega Star Commander
Posts: 1304
Joined: Thu Jan 31, 2008 2:12 pm
Location: Providence, RI
Occupation: Office of the CIO

Re: Software sprites?

Postby rhurst » Sun Aug 13, 2017 5:32 am

That's killer ... modern tools and APIs for VIC? Incredible.
Any technology distinguishable from magic is insufficiently advanced. See also magic.

User avatar
Vic 20 Afficionado
Posts: 332
Joined: Mon Jun 20, 2005 7:32 pm

Re: Software sprites?

Postby hawk » Tue Aug 15, 2017 5:14 am

This is great. Thanks. I'm looking forward to giving it a go. It might make it possible for me to continue a project a started ages ago but stalled on as I couldn't work out how to implement sprites that didn't tear and flicker.

User avatar
Herr VC
Posts: 3107
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Software sprites?

Postby Mike » Tue Aug 15, 2017 5:31 am

beamrider wrote:'c' [...] 'c' [...] 'c' [...] 'c'

Just curious: is there a specific reason you insist on this spelling of C (other than, possibly, that cc65 doesn't implement the full language)?

User avatar
Vic 20 Nerd
Posts: 874
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Software sprites?

Postby beamrider » Tue Aug 15, 2017 6:18 am

nope, you got me there.

I must have seen it written like that somewhere and it stuck.

Post corrected.

[Also noticed that there was a missing \0 after (SSS BY R.HURST) - must have worked by luck.]

Will update the download zip to match.

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest