|
Forum Index : Microcontroller and PC projects : Nostalgia?
| Author | Message | ||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 479 |
Does this remind anyone of something they've seen before? Sprites.zip |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 479 |
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 StatesPosts: 261 |
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 StatesPosts: 261 |
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 KingdomPosts: 10590 |
You are misinterpreting the manual 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 StatesPosts: 479 |
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 StatesPosts: 479 |
That clears up a lot of things. Thanks! |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 479 |
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 KingdomPosts: 10590 |
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 |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |