Software sprites?

Basic and Machine Language

Moderator: Moderators

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

Post by Mike »

rhurst wrote:I recall some C128 sprite-oriented commands, but please list a syntax you feel would be worthwhile.
I am currently overviewing the SSS API, but indeed the SPR* commands of BASIC 7.0 inspired me, too.
this address $EDE4 (NTSC=$05, PAL=$0C) [...], but it falls within the BASIC ROM space
It's the beginning of the table that initialises the VIC registers. I use this table within MINIGRAFIK, adding/subtracting offsets, to make the screen positioning independent of PAL/NTSC.
so is that a fixed VIC 20 value that can be used instead of user intervention?
It's canon. :)
create "fixed" JMP vector(s) into the API to allow its "kernal" to be loaded anywhere?
Yes.

Referring to the API: Each call should cite register usage, and pre-conditions necessary for the routine to work. At the moment this information is already present, but somehow hidden within flow text. Don't be afraid to use a whole page per API call. You should also give some small examples embedding the JSR instruction.

I once designed a Thread API for the ARM processor. Here is the documentation of this API (raw text only). The documentation (PRM's) of Acorn RISC OS was written in a similar style throughout 4 volumes spanning over 3000 pages, accompanied by chapters conveying the "philosophy" behind the OS API.
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

I updated the VIC-SSS.zip archive to include a "primer", so it is a much larger download than before (>600K). This primer is described in the updated PDF, but it essentially is a subfolder with templates and a brief SAMPLE for making binaries to:

- load from BASIC using 3K only memory expansion;
- load from BASIC with at least 8k memory expansion; or
- autoboot from game cartridge slot in either 4K or 8K ROM sizes.

The included DEMO has been slightly modified to use those same templates, although it cannot link for +3K (17-byte overflow, heh, so it might be worth seeing what a map error looks like).
Don't be afraid to use ...
Er, thanks... I think. I "get" best practices, but since I don't entirely follow-through, I don't preach it either. :P
And I certainly don't follow the old programming adage, either:
If it was complicated to write, then it must be complicated to understand.
:lol:
Anyways, I hope this incremental improvement is helpful. Enjoy!!
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
User avatar
Mike
Herr VC
Posts: 4831
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PM sent
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

No worries... I think I am just getting (old and) cranky -- and I think it's because I want to be spending more time writing Omega Fury than anything else! :P

Mike, love the feedback and the motivation -- keep it coming. because I have been conquered by the Thargoids, so my hull plating got thicker. :lol:
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
Gary_Leeds
Vic 20 Amateur
Posts: 54
Joined: Wed Feb 18, 2009 5:21 am

Post by Gary_Leeds »

I must admit the demo looks impressive and I cant help think this will make it so much easier for novices like myself to write new games or ports to the Vic especially as its using CC65 so can be included in with any code someone else has written. Cant help thinking with your mention of Mr Do earlier that it should be agame thats attempted as there is no version I know of for the Vic
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

the demo looks impressive
Thanks, although it was a result of using it to test the API to begin with. Its coding is very unclean, but serviceable.

Speaking of unclean, I updated the VIC-SSS zip archive once again, cleaning up the following fluff:

- moved demo parts to a demo subfolder with its own README.TXT.

- cleaned up demo.s so it will compile using +3K memory config.

- re-organized VIC-SSS.h and VIC-SSS.s to place commonly-used entry points listed first, and with minor comment cleanups throughout for the daring.

- minor update to the documentation (PDF)

- fixed SSSINIT to respect passed Accumulator value for SSSCLEAR, instead of a hard-wired $A0 (a reverse SPACE).

No changes made to the API itself, so a game like Quikman 8K is not affected. :o
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Just a heads-up notice on some new happenings in this space:

The second implementation of VIC-SSS in a game, Omega Fury, has revealed to me a few more needed enhancements to this API. I have coded and now need to debug and test implement it in its demo and Quikman first, before moving on to the more heavy-duty game(s). Here's what I found so far:

1) Optimize dirty-bit cleaning with a second 24-byte array holding maximum column values -- with just 5 active sprites on the screen, I can save an average 100 iterations per video flip in its cleaning loop.

2) Add SSSCELL call as a sub-function to SSSWRITE, but use the last dirty bit as a STATIC cell. Essentially, I want to have a top-level layer of characters that cannot be touched by sprites, much like PLAYFIELD, but sprites render under these characters so marked. More importantly, you can have a different character / color per frame buffer generating interesting effects at zero cost to the flip operation.

3) Implement another sprite mask, SSSSKIP. This mask tells the sprite rendering & display routine called from SSSFLIP to simply skip the rendering portion, essentially keeping the last rendered image and re0displaying that character matrix on the PENDING video buffer. This will save quite a few cycles (if programmed properly) for static and slow-moving sprites.

That last point will be extremely interesting to me to see how it affects performance of Omega Fury with up to 16 "active" sprites. Many of those do not need rendering per SSSFLIP operation, so this SKIP flag should help reduce needless re-work, yet still allow for a quality display without flicker, or resorting to moving sprites multiple pixels to keep the "frame rate" up.

I'll post the new results as it becomes available.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

rhurst wrote:1) Optimize dirty-bit cleaning with a second 24-byte array holding maximum column values -- with just 5 active sprites on the screen, I can save an average 100 iterations per video flip in its cleaning loop.
Completed. This reduces just a tiny amount of overhead, but it was still worth fitting in.
rhurst wrote:2) Add SSSCELL call as a sub-function to SSSWRITE, but use the last dirty bit as a STATIC cell. Essentially, I want to have a top-level layer of characters that cannot be touched by sprites, much like PLAYFIELD, but sprites render under these characters so marked. More importantly, you can have a different character / color per frame buffer generating interesting effects at zero cost to the flip operation.
Completed. IMHO, this was a very important feature to add. The Thargoid mines are maintained better on the playfield as static objects.
rhurst wrote:3) Implement another sprite mask, SSSSKIP. This mask tells the sprite rendering & display routine called from SSSFLIP to simply skip the rendering portion, essentially keeping the last rendered image and re0displaying that character matrix on the PENDING video buffer. This will save quite a few cycles (if programmed properly) for static and slow-moving sprites.
Completed. I am thrilled/relieved to say this may have probably saved Omega Fury from an early death. It was a difficult process to integrate in the sprite's SSSUPDATE, but the early results tell me it was worth it. While it is an advanced feature to add to a game, the API simplifies most of it by merely flipping the same masking bit in SSSSKIP to "freeze" the sprite rendered image. 8)

P.S., I will post a V1.1 release after I fix the documentation, demo, etc. :)
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
User avatar
amramsey
Vic 20 Hobbyist
Posts: 117
Joined: Sat Apr 14, 2007 9:38 pm

Post by amramsey »

This is pretty fantastic stuff. I appreciate you taking the time to really document this stuff too... it makes it much easier to get started with.
User avatar
ral-clan
plays wooden flutes
Posts: 3702
Joined: Thu Jan 26, 2006 2:01 pm
Location: Canada

Post by ral-clan »

Note being a deep programmer, I have to admit I only vaguely understand what you are talking about half the time with this project. But, it seems like a pretty important project and the results (the Omega Fury demo) look great (such smooth movement). I really hope that your software sprite engine catches on and is used by many VIC programmers!
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Ok, a 4th re-write of the API is in progress . . . :o

After some clever dancing with the last revisions to make Omega Fury animations work better, I have decided those enhancements have lost sight of one of its primary objectives: it is suppose to be a programmer-friendly API. Manipulating bits throughout your game to make for optimizations is not my idea of programmer-friendly.

Implementations always shine a good light on how things should work. So, back to the drawing board I go! Actually, it is not all that bad. I already have a good draft in place. I have quite a bit coding to do before resuming its implementation in Omega Fury (and possibly re-integrating into Quikman as a differential to see how it stacks up against the original).

Here's my thoughts on what needs to be addressed:

1) No custom flip routine should be required for >8 active sprites. Thus, I got rid of the 8-bit on/off register, and made it into a SPRITE list instead, allowing for 1-16 active sprites.

2) SSSFLIP should have prior knowledge of whether an active sprite requires rendering and copy/merging into its character matrix. The game program should not have to manipulate for that to occur, or not to occur, such that each sprite's copy/merge process might be skipped if nothing new has happened to it.

3) Adding, removing, or changing a sprite on-the-fly should incur zero "glitches" as a result. While the original VIC-SSS does maintain image integrity, my recent enhancements introduced some complexity that made for some brief, but visible, graphical errors.

4) Maintain a sprite image buffer between frames to help avoid longer renders. Maintain image and buffer pointers per sprite to avoid unnecessary re-calculations.

5) The SSSFLIP routine should have the following modes:

Like before:

0 = immediate
1 = wait for next vertical sync to occur
>1 pace for that many vertical syncs (keeps frame rate steady)

But also, if >X vertical syncs occur, allow for a skip in the next frame flip to occur. This worked out pretty well for me in the later Omega Fury levels whereas the frame-skip allowed fast movement with four enemy ships (including the large carrier) -- most objects don't even lose their single-pixel movements, because they are moving at half-speed or less anyways. The player's ship can be seen moving double-pixels when flying at higher speeds, but it makes for a better playing experience if the action doesn't crawl.

I am also considering allowing for a mode that decides to split sprite rendering over two frames instead of all in one... alternating between even/odd frame updates.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

For those interested, I re-vamped a new version of VIC-SSS (the "original" is still available) into what is called the "4th edition". It has gone through some heavy re-work, so I am not declaring it READY, but it looks to be very promising for implementation in Omega Fury. Documentation has been moderately updated as well.

Feature highlights include up to 16 active sprites, smarter rendering, automatic frame drops when playing speed is required.

Download the latest zip archive, feedback is welcome.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

A lot of debugging with some internal re-arrangements to sprite registers. It has been integrated with the latest alpha release of Omega Fury, so I believe it to be in a usable state now.

Download this latest zip archive, which includes playable vic20 and vic20pal.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
Bacon
for breakfast
Posts: 578
Joined: Mon Apr 19, 2004 8:07 am

Post by Bacon »

Great job you're doing! I just hope I'll soon find some time to do a little VIC 20 programming.
Bacon
-------------------------------------------------------
Das rubbernecken Sichtseeren keepen das cotton-pickenen Hands in die Pockets muss; relaxen und watschen die Blinkenlichten.
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

I am declaring VIC Software Sprite Stack 4th edition released. I added one last simple function, SSSREFRESH, and successfully integrated it with Quilkman (source and binary included with the other simple demos) as a proof-of-concept that it works in a full arcade-style game -- it went in with very little trouble.

I feel this edition offers a very good balance between programmer-friendliness and performance. I know I could make Quikman run even faster with some alteration to the game loop and using SSSFFLIP -- but it runs fine as-is and it took very time to drop it in as a replacement. Omega Fury uses many more sprites, and even though it is not done yet, its performance is quite acceptable considering the amount of varying animation that is going on.

Download it from the usual link -- enjoy! :D

If you have any problems using it, please feel free to PM me.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
Post Reply