objasm Sprite Example
Andrew (8626) 3 posts |
I have recently started looking at learning some assembler and I have set myself the goal of ultimately writing a small game (something along the lines of Tetris hopefully). I am a Java developer by day so this is quite a challenge for me :-). I am currently experimenting with objasm and this is going quite well, however I do not know where to start regarding showing anything other than text on the screen. I wonder if anyone might be able to point me in the direction of some relevant code examples, perhaps some simple sprite handling if possible please. I am using RISC OS 5 under RPCEmu and this workflow is working quite well, however eventually it would be nice if I can get some stuff going on my A3010 or A5000 machines further own the road. Andrew |
Rick Murray (539) 13840 posts |
I’ll gloss over the obvious “Why?” regarding the use of assembler… ;) …and say that what you’re probably looking for is The calls are fairly straightforward and are documented in the StrongHelp “OS” guide, as well as here, the PRMs, etc. If you refer to sprites by name, then add 256 to the reason code to specify your own sprite area and using names. Or add 512 if your own area and using addresses. Otherwise, it’s a case of initialising the area, loading a sprite file into it, then banging them on to the screen in the appropriate places. This is all basically done by setting registers as necessary then calling the SpriteOp SWI. This might help: http://www.riscos.com/support/developers/agrm/index.htm There’s a potentially clearer example at the bottom of this page: https://heyrick.eu/blog/index.php?diary=20180811 |
David J. Ruck (33) 1635 posts |
If you are going to write in assembler, only do it for the most time critical sections, write the rest of the code in a high level language. Life really is too short to waste effort going down to machine level for stuff that doesn’t need it. |
Andrew (8626) 3 posts |
Thanks Rick, those pointers are very much appreciated. I was getting a bit lost looking at various tutorials and books. The barcode program is pretty interesting in itself. David, you raise a good point. I agree this isn’t very sensible. Perhaps I should look at doing a C version initially. I haven’t researched how easy it is to write C for RISC OS, however I have come across various discussions around compilers etc. |
Andrew McCarthy (3688) 605 posts |
Hello Andrew, and welcome. :) What you’re doing sounds fun! Keep going! Here’s a playlist- I put together a while ago, and recently updated. It pulls together several themes; a few videos have source code links. ;) Like yourself, hobbyists having a bit of fun. With your Java background, you may be interested in Guillaume’s in-development JVM- Tetris is one of the examples. You may find the Python games JVS ported from the Raspberry Pi book Code the Classics in the Store (PlingStore) helpful. |
Jay Davis (12058) 7 posts |
Since you’re using objasm on RISC OS 5, you might want to check out the RISC OS Programmer’s Reference Manuals (PRMs). They should have info on graphics programming for your platform. Look into the GraphicsV and OS_SpriteOp SWIs for sprite handling. |
Andrew (8626) 3 posts |
Thanks Andrew – the playlist is very helpful. Guillaum’s JVM implementation is very impressive! Jay – another good recommendation. I am lucky enough to be able to grab a dead-tree implementation of the PRMs (for RISC OS 3) – no excuses now! |