log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Elsear brings super-fast Networking to Risc PC/A7000/A7000+ (News:)
- Latest hardware upgrade from RISCOSbits (News:)
- RISCOSbits releases a new laptop solution (News:4)
- Announcing the TIB 2024 Advent Calendar (News:2)
- RISC OS London Show Report 2024 (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- Rougol November 2024 meeting on monday (News:)
- Drag'n'Drop 14i1 edition reviewed (News:)
- WROCC November 2024 talk o...ay - Andrew Rawnsley (ROD) (News:2)
- October 2024 News Summary (News:3)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
Acorn Arcade forums: Programming: Animated sprites in BASIC
 
  Animated sprites in BASIC
  kick52 (08:05 26/6/2004)
  andrew (12:53 26/6/2004)
    ninj (18:30 29/6/2004)
      Phlamethrower (18:41 29/6/2004)
        kick52 (19:57 9/7/2004)
          ksattic (20:31 9/7/2004)
            andrew (12:33 10/7/2004)
              ksattic (19:36 11/7/2004)
                kick52 (18:04 13/7/2004)
                  ksattic (18:19 13/7/2004)
                    john (17:52 15/7/2004)
                      Phlamethrower (21:39 15/7/2004)
                        kick52 (18:45 18/7/2004)
                          martin (23:03 20/7/2004)
                            kick52 (15:58 22/7/2004)
                              Loris (16:05 22/7/2004)
                                kick52 (10:16 27/8/2004)
                                  monkeyson2 (10:28 27/8/2004)
                                    ksattic (18:56 7/9/2004)
                  ilcook (18:21 13/7/2004)
                    ksattic (19:05 13/7/2004)
                      kick52 (17:22 15/7/2004)
 
Tim Brook Message #56258, posted by kick52 at 08:05, 26/6/2004
Member
Posts: 87
Hi, again,
i bought a bbc BASIC book a while ago (expect progs) but it didnt say any thing about sprites.
is there any module or something like that so i can use sprites?
if i could i would port some of the games i have made for the cybiko (used a BASIC 2 C prog)

any info?


kick 52
  ^[ Log in to reply ]
 
Andrew Message #56265, posted by andrew at 12:53, 26/6/2004, in reply to message #56258
HandbagHandbag Boi
Posts: 3439
SYS "OS_SpriteOp"
In BASIC you have to initialise a sprite area, load in the sprites (both using SYS calls) after having found the size of the file and having created a DIMension the size of the spritefile+4.
Then you can use the calls to plot, invert, scale and so on.

[Edited by andrew at 13:56, 26/6/2004]
  ^[ Log in to reply ]
 
ninjah Message #56373, posted by ninj at 18:30, 29/6/2004, in reply to message #56265
Member
Posts: 288
Assuming you only have a BASIC book and not the PRMs, then StrongHelp along with a bunch of manuals will be invaluable. Start here. I'm not sure if OS_SpriteOp documentation is in the OS help file or the MiscSWIs help file, and I can't check just at the moment.
  ^[ Log in to reply ]
 
Jeffrey Lee Message #56375, posted by Phlamethrower at 18:41, 29/6/2004, in reply to message #56373
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
OS_SpriteOp should be in the OS help file.
  ^[ Log in to reply ]
 
Tim Brook Message #56823, posted by kick52 at 19:57, 9/7/2004, in reply to message #56375
Member
Posts: 87
I read the OS doc but i did not understand (I am a newbie to programing) it did not give me an example and i was baffled by the hex numbers and were you were meant to use them. Does any one have a clearer doc?
  ^[ Log in to reply ]
 
Simon Wilson Message #56825, posted by ksattic at 20:31, 9/7/2004, in reply to message #56823
ksattic
Finally, an avatar!

Posts: 1291
If I remember tonight, I'll post a quick message here about loading/using sprites in BASIC, including masked (transparent) sprites.
  ^[ Log in to reply ]
 
Andrew Message #56832, posted by andrew at 12:33, 10/7/2004, in reply to message #56825
HandbagHandbag Boi
Posts: 3439
DEF PROCloadsprites
REM Load standard sprites
sprite$="<awooba$Dir>.spritefile"
file%=OPENIN(sprite$)
size%=EXT#file%+4 :REM add 4 because file is sprite area
CLOSE#file% :REM without first word
DIM area% size%
area%!0=size%
area%!8=16
SYS "OS_SpriteOp",256+9,area%
SYS "OS_SpriteOp",256+10,area%,sprite$
ENDPROC

Try that :)
  ^[ Log in to reply ]
 
Simon Wilson Message #56863, posted by ksattic at 19:36, 11/7/2004, in reply to message #56832
ksattic
Finally, an avatar!

Posts: 1291
...and plot with:

SYS "OS_SpriteOp", 256+34, area%, "spritename", x%, y%, 8

The 8 means to plot with mask (transparent). Make sure your sprites are designed in a mode similar to the one you're plotting in (ie. square pixel, same colour depth, etc).
  ^[ Log in to reply ]
 
Tim Brook Message #56930, posted by kick52 at 18:04, 13/7/2004, in reply to message #56863
Member
Posts: 87
i will try that.

oh, by the way, could i kindly ask that no one to bid on the risc pc on ebay up for 15.00 with no bids? you see, i dont have much pocket money... (I am 11)
  ^[ Log in to reply ]
 
Simon Wilson Message #56932, posted by ksattic at 18:19, 13/7/2004, in reply to message #56930
ksattic
Finally, an avatar!

Posts: 1291
oh, by the way, could i kindly ask that no one to bid on the risc pc on ebay up for 15.00 with no bids? you see, i dont have much pocket money... (I am 11)
I can't see a RiscPC on eBay for 15.00. You shouldn't find it too difficult to get one for that price though. If you're lucky, you *may* find one with a StrongARM for around that price.
  ^[ Log in to reply ]
 
Ian Cook Message #56933, posted by ilcook at 18:21, 13/7/2004, in reply to message #56930
trainResident idiot
Posts: 1077
i will try that.
oh, by the way, could i kindly ask that no one to bid on the risc pc on ebay up for 15.00 with no bids? you see, i dont have much pocket money... (I am 11)


11 what? years or posts. :E
  ^[ Log in to reply ]
 
Simon Wilson Message #56934, posted by ksattic at 19:05, 13/7/2004, in reply to message #56933
ksattic
Finally, an avatar!

Posts: 1291
11 what? years or posts. :E
He'll reply to that on his next birthday.

Think about it. ;)
  ^[ Log in to reply ]
 
Tim Brook Message #57032, posted by kick52 at 17:22, 15/7/2004, in reply to message #56934
Member
Posts: 87
honestly, i am 11 years old.
  ^[ Log in to reply ]
 
John D Message #57033, posted by john at 17:52, 15/7/2004, in reply to message #56932
Member
Posts: 261
If you're lucky, you *may* find one with a StrongARM for around that price.
Not on ebay - just the SA alone I'm selling is up to 41ukp, and the RPC motherboard I sold went for 30ukp. Maybe visit all your local schools and smile sweetly at them? :)
  ^[ Log in to reply ]
 
Jeffrey Lee Message #57042, posted by Phlamethrower at 21:39, 15/7/2004, in reply to message #57033
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
If you're lucky, you *may* find one with a StrongARM for around that price.
Not on ebay - just the SA alone I'm selling is up to 41ukp, and the RPC motherboard I sold went for 30ukp. Maybe visit all your local schools and smile sweetly at them? :)
Or if they're 'upgrading' to PC's then follow the skip lorries to the dump and rescue a few Risc PC's ;)
  ^[ Log in to reply ]
 
Tim Brook Message #57105, posted by kick52 at 18:45, 18/7/2004, in reply to message #57042
Member
Posts: 87
nope, to late. the acorns went out a year ago. with gunk on the keyboard :(
and were replaced with the microsoft "computers" :cry:
  ^[ Log in to reply ]
 
martin hansen Message #57214, posted by martin at 23:03, 20/7/2004, in reply to message #57105
Member
Posts: 17
Get along to the start or the finish of one of the RISC OS shows - there is always a ton of charity stuff going for next to nothing at the start, and for nothing at the end. Certainly, A5000s now are a-plenty and the RiscPCs without strongARM will start appearing next.
  ^[ Log in to reply ]
 
Tim Brook Message #57298, posted by kick52 at 15:58, 22/7/2004, in reply to message #57214
Member
Posts: 87
sorry, but i forgot to tell you that i won that RiscPC 600 on ebay. And the sprites thing is working now. i just have to learn how you wipe the sprites off the screen.
  ^[ Log in to reply ]
 
Tony Haines Message #57300, posted by Loris at 16:05, 22/7/2004, in reply to message #57298
madbanHa ha, me mine, mwahahahaha
Posts: 1025
Well, you could draw something else over them if you want.

RiscOS sprites are not hardware sprites like you might be used to on other platforms. [1]

Basically drawing a sprite just plots it to screen memory. So you can't move it around, and what was underneath is lost.



[1] Well, there is one - the mouse pointer.
  ^[ Log in to reply ]
 
Tim Brook Message #57617, posted by kick52 at 10:16, 27/8/2004, in reply to message #57300
Member
Posts: 87
could i use CLS then put the sprite on again?
  ^[ Log in to reply ]
 
Phil Mellor Message #57621, posted by monkeyson2 at 10:28, 27/8/2004, in reply to message #57617
monkeyson2Please don't let them make me be a monkey butler

Posts: 12380
could i use CLS then put the sprite on again?
Absolutely. But it will be very flickery unless you use screen bank switching. You have two screen banks - one for displaying, the other for updating. When you've redrawn the screen you switch them over.

Typically I use

REM (set up sprite and screen mode here)
frame% = 1
x% = 0: y% = 0
REPEAT
SYS "OS_Byte", 112, frame% : REM screen bank to plot to
CLS
SYS "OS_SpriteOp",256+34,area%,"sprite",x%,y%,0
x% += 4
SYS "OS_Byte", 113, frame% : REM display the screen bank
frame% = 3 - frame% : REM swap bank numbers
WAIT : REM wait for vsync to avoid flicker
UNTIL x% > 1280


Unless you're using an Iyonix, make sure there's enough screen memory allocated in the task manager. (For two banks you need 2x the screen size).
  ^[ Log in to reply ]
 
Simon Wilson Message #57803, posted by ksattic at 18:56, 7/9/2004, in reply to message #57621
ksattic
Finally, an avatar!

Posts: 1291
Unless you're using an Iyonix, make sure there's enough screen memory allocated in the task manager. (For two banks you need 2x the screen size).
There's a simple trick to do this in programs. Say you want to allocate two banks for mode 13 (320x256x8bpp). Have the following at the start of your program:

MODE 15 : MODE 13

Mode 15 is a 640x256x8bpp mode, so it uses twice the memory as mode 13.

You can also use MODE 13 + 128. I think this is the preferred method.

Finally, you could also call SYS "OS_ChangeDynamicArea" to allocate 160KB for mode 13.
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Animated sprites in BASIC