Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:47 17 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Nostalgia?

Author Message
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 479
Posted: 04:07pm 24 Dec 2020
Copy link to clipboard 
Print this post

Does this remind anyone of something they've seen before?

Sprites.zip
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 479
Posted: 01:07pm 25 Dec 2020
Copy link to clipboard 
Print this post

In my little program I have the lines

10 SPRITE LOAD "BALLOON.SPR",1
15 SPRITE LOAD "BALLOON.SPR",42
20 SPRITE LOAD "GBALLOON.SPR",3


How does BASIC know to assign the sprites to buffers?

Is it in the order they're defined? If so, why does the second line have to be 42?
I know that picks out the sprite in the BALLOON file that starts on line 42 but why does the 3 in line 3 not start at line 3 and miss the top of the balloon?

The manual says it means "start_sprite_number" I'd think the number 2 would get the second sprite since the first line in the sprite file tells BASIC how many columns and rows each sprite is so BASIC should know the second sprite starts on line 42 (not counting the first line which is the sprite information)

So, in short, does anyone have another explanation of the SPRITE LOAD command? The advanced graphics manual doesn't go into any more detail than the User Manual, it just repeats the same explanation.

I have been an business applications programmer for my entire career so this is my first foray into graphics. Accounts Payable and Receivable don't have much need for graphics.
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 03:35pm 25 Dec 2020
Copy link to clipboard 
Print this post

First off, ditch line numbers - not needed at all in this version of basic.

Second, yeah I don't see any reason why it would need to be 42 - the sprite info line in the file tells it that the 2nd sprite is starting on line 42. Could it have just been a typo (fat fingered 42 instead of 2) ?

Wish I could help more but I never use this mechanism for sprites (I use PNG files and just load them in).
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 03:41pm 25 Dec 2020
Copy link to clipboard 
Print this post

Ok, couple other comments...

Line# 55 - that's how things worked to make a delay on the C64, but the better way to do it on the CMM2 is to use pause (for example pause 5)

You're also going to get some major smearing of the sprites the way you're doing them. They don't work the same way in CMM2 as they do in the C64 - on the 64 they were a special hardware construct that was overlaid on top of the screen but completely independent. On the CMM2 they are done in software and once you draw/show them they  are painted on the screen (to whichever page you're writing on, Page 0 being the display). If you don't clear the screen (or somehow redraw the background where the sprite was) then on the next iteration of your loop you'll be painting the sprite in the new position, but what was there from the previous loop iteration will still be there, so it'll look like the sprite is smearing its way across the screen instead of moving.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10590
Posted: 03:56pm 25 Dec 2020
Copy link to clipboard 
Print this post

You are misinterpreting the manual

  Quote  The first line of the file holds the parameters for the sprite (ie, the width, the number of sprites in the file, and the height in that order


So you only need to load balloon.spr once and the two sprites are there

1 REM UP UP AND AWAY!
5 MODE 3,12,RGB(blue)
10 SPRITE LOAD "BALLOON.SPR",1
20 SPRITE LOAD "GBALLOON.SPR",3
30 FOR X = 1 TO 190
40 SPRITE SHOW SAFE #3,X,100,1
45 SPRITE SHOW SAFE #2,X,190-X,1
50 SPRITE SHOW SAFE #1,X,X,1
55 for i=1 to 20000:next i
60 NEXT X
70 GOTO 30
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 479
Posted: 06:27pm 25 Dec 2020
Copy link to clipboard 
Print this post

  mkopack73 said  Ok, couple other comments...

Line# 55 - that's how things worked to make a delay on the C64, but the better way to do it on the CMM2 is to use pause (for example pause 5)

You're also going to get some major smearing of the sprites the way you're doing them. They don't work the same way in CMM2 as they do in the C64 - on the 64 they were a special hardware construct that was overlaid on top of the screen but completely independent. On the CMM2 they are done in software and once you draw/show them they  are painted on the screen (to whichever page you're writing on, Page 0 being the display). If you don't clear the screen (or somehow redraw the background where the sprite was) then on the next iteration of your loop you'll be painting the sprite in the new position, but what was there from the previous loop iteration will still be there, so it'll look like the sprite is smearing its way across the screen instead of moving.


Thanks for heads-up on PAUSE!  SHOW SAFE takes care of the background so there's no smearing.
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 479
Posted: 06:31pm 25 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  You are misinterpreting the manual

So you only need to load balloon.spr once and the two sprites are there



That clears up a lot of things. Thanks!
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 479
Posted: 06:38pm 25 Dec 2020
Copy link to clipboard 
Print this post

  mkopack73 said  First off, ditch line numbers - not needed at all in this version of basic.


Thanks for the reply! I've been programming almost exclusively in BASIC since 1965 and am too old to change so I won't be ditching line numbers anytime soon. Even though I don't use them in new programs I write (I don't use GOTO or GOSUB anymore), I still put them in programs. It's like a security blanket. They're still mandatory in the ANSI/ISO standard for Full BASIC, too.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10590
Posted: 06:41pm 25 Dec 2020
Copy link to clipboard 
Print this post

  Quote   If you don't clear the screen (or somehow redraw the background where the sprite was) then on the next iteration of your loop you'll be painting the sprite in the new position, but what was there from the previous loop iteration will still be there, so it'll look like the sprite is smearing its way across the screen instead of moving.


This is completely incorrect. When you use SPRITE SHOW if first replaces the background of where the sprite was previously drawn (except the first time), then it saves the background of where the sprite will be drawn and finally draws the sprite. This is all automatic and transparent to the program. This can cause some screen flashing artifacts so it is best done on a non-displayed page and then that page copied to page 0 during frame blanking.

Check the sprite demos in the welcome pack
Edited 2020-12-26 04:43 by matherp
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025