RS Basic Sprite plotter example code

Discuss all aspects of programming here. From 8-bit through to modern architectures.
User avatar
sydney
Posts: 1968
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

RS Basic Sprite plotter example code

Postby sydney » Wed Jan 25, 2017 11:49 am

This example code is what I used in my beebout game and I'm going to adapt it a bit to use in my Combat game. I thought it was worth posting here as it's a good way for novice programmers to get started.
The code given at RS is in a format suitable for use with the Swift ide and P65 Ophis assembler which I never got on with and I use Beebasm and Notepad++ so I set about adjusting the code so that it assembles with beebasm.

I'm going to make some further adjustments so that it works with a 256 pixel (64 byte) wide screen, which should be quite easy, and I'll post that code here too.

Edit: added sprite256.zip which plots sprites on a 64 byte wide screen
Edit 2:This code is not written by me but by SteveO and was posted in the sample code section of RetroSoftware.
Attachments
sprite256.zip
(8.87 KiB) Downloaded 32 times
sprite.zip
(8.19 KiB) Downloaded 24 times

User avatar
FourthStone
Posts: 387
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: RS Basic Sprite plotter example code

Postby FourthStone » Tue Feb 07, 2017 9:29 pm

Thanks for posting this, really nice piece of code :D

I am absorbing as much sprite code as I can to build up to doing a project or two, noticing the 256 pixel screen really does simplify the code a lot so thinking that would be a good format to aim for.

User avatar
sydney
Posts: 1968
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: RS Basic Sprite plotter example code

Postby sydney » Tue Feb 07, 2017 9:54 pm

I've just reread my post and I've not made it clear that this code isn't mine, it's by SteveO and he posted it at Retrosoftware in the example code section. All I've done is adapt it for a 256 pixel wide screen. It's going to form the basis for my Combat project which I'll hopefully have time to work on tomorrow.

User avatar
FourthStone
Posts: 387
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: RS Basic Sprite plotter example code

Postby FourthStone » Wed Feb 15, 2017 11:10 pm

Hi,

I just had a question regarding the sprite data format, I'm trying to use my own sprites and they not plotting at all or produce a mess so I must be doing something wrong.

With the Sprite Graphic Structure, the comments say to use Width, Height, Data:

Code: Select all

;Sprite Graphic Structure
;
 
   ;offset       meaning
   ;00           width
   ;01           height
   ;02->to end   graphic data


So I've pasted in some mode 1 sprite data preceded by width (assume byte width) and height (assume pixel height) as follows:

Code: Select all

.GameSprites 
   ;INCBIN "DroidSprites.bin"
   
   equb 5,8,&11, &33, &CC, &88, &00, &11, &DD, &BB, &88, &00, &00, &57, &AE, &00, &00, &00, &FF, &FF, &00, &00, &11, &73, &EE, &88, &00, &22, &30, &CC, &44, &00, &DF, &00, &00, &BF, &00, &66, &00, &00, &66, &00


Strangely when I look at the DroidSprites.bin file the first two bytes are 24 and 0. Can you tell me if I am missing something about the width and height bits or the format of the sprite data? :?

Code: Select all

18 00 DA 00 9C 01 5E 02 20 03 E2 03 E4 04 E6 05 E8 06 EA 07 94 08 3E 09 06 20 00 00 00 00 00 15 15 15 15 01 03 03 03 03 03 03 03 03 02 00 00 00 00 00 00 00 00 01 01 01 00 00 00 14 14 14 3E 14 00 00 00 94 94 C0 03......

User avatar
FourthStone
Posts: 387
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: RS Basic Sprite plotter example code

Postby FourthStone » Thu Feb 16, 2017 1:27 am

Just a follow up to say I've worked it out, after finding the swift sprite format documentation and after a bit of head banging ](*,) the penny finally dropped after much scrutinizing of the data in DroidSprites.bin

So in case anyone was wondering, the excellent sprite plotter code above expects the sprite data to be in the following format:
SpritePlotterFromat.JPG

So depending on how many sprites are referenced this will determine the offset address for the first and subsequent sprites.

Apologies if this is made obvious somewhere else as I couldn't find it or was too thick to read it properly #-o


Return to “programming”

Who is online

Users browsing this forum: No registered users and 1 guest