New version of Space Invaders (was: BASIC Space Invaders)

User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

New version of Space Invaders (was: BASIC Space Invaders)

Post by tricky »

Latest version in https://www.stardot.org.uk/forums/viewt ... 70#p410170.

I saw somewhere around here that there was a programming competition for writing a BASIC game, so I thought I would start one ;)
Here is what I have so far, it takes a little while to load and there is nothing to play.
I just wondered how hard it would be as it is about 30 years since I wrote space invaders for the BBC!
Turns out it is much harder in BASIC than assembler with beebasm (for me anyway).
Feel free not to make suggestions if you think it would be unfair for the competition - I haven't read the rules yet!
Attachments
BASICInvaders.zip
(3.64 KiB) Downloaded 660 times
Last edited by tricky on Tue Dec 05, 2023 1:44 pm, edited 4 times in total.
User avatar
flaxcottage
Posts: 5718
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire
Contact:

Re: BASIC Space Invaders

Post by flaxcottage »

Nice - I like the font and characters, they are very clear. =D>

When moving the invaders though the whole row moves at once. Could a row be represented by a string? It could speed up refreshing the display and allow for toggling aliens.

Good luck with moving the bullets!
- John

Check out the Educational Software Archive at www.flaxcottage.com
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

I was modelling it on the original arcade game, where they move one at a time.
The font is just the normal beeb font, but anded with itself shifted left (*2).
I tried drawing the invaders as user-defined characters, but it was a bit slower.
Although you can't see it, it is checking for which aliens are left and only drawing them.
All the data statements in the first programme are for the graphics and barely fit with Dfs and mode 1, hence the two programmes.
Mode 1 may prove too much for a game written in BASIC that need to run at 50fps, but it's worth a try.
User avatar
PitfallJones
Posts: 455
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: BASIC Space Invaders

Post by PitfallJones »

Very Authentic looking!

Ok....

don't mess around ....

Just write it in Assembler!

It looks like it will be great!

PJ
User avatar
flaxcottage
Posts: 5718
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire
Contact:

Re: BASIC Space Invaders

Post by flaxcottage »

tricky wrote:I was modelling it on the original arcade game, where they move one at a time.
Ah then it will be more authentic. :D

The Acornsoft games I have move the whole row at a time and I'd never noticed.
- John

Check out the Educational Software Archive at www.flaxcottage.com
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

I only really noticed all that time ago, when I was looking at how the aliens speed up but the player doesn't. Answer, one alien moves two pixels horizontally and the player moves one every frame ; - simples ;)
sirbod
Posts: 1624
Joined: Mon Apr 09, 2012 9:44 am
Location: Essex
Contact:

Re: BASIC Space Invaders

Post by sirbod »

:twisted: I just opened this from the 32-bit Software forum (not realizing it was a link to a moved topic!) :twisted:

If it's BASIC, surely it will work under RISCOS? I was thwarted by the SSD file so couldn't try it #-o
User avatar
Arcadian
Site Admin
Posts: 4223
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: BASIC Space Invaders

Post by Arcadian »

PitfallJones wrote:Very Authentic looking!
^ This
PitfallJones wrote:don't mess around ....

Just write it in Assembler!

... ^ this
PitfallJones wrote:It looks like it will be great!
... and ^ this.

;)
Please subscribe to the ABug YouTube channel!
User avatar
PitfallJones
Posts: 455
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: BASIC Space Invaders

Post by PitfallJones »

Sorry my message came out a bit garbled
I meant the demo looks terrific - much closer to Real Space Invades than any previous BBC version.

But it runs very slow of course (being Basic) - so an Assembler version could be a really great version!

And if it's easier to write in Assembler why not? (Or do both)
Come to think about it - a lot of BBC games were hybrids - Missile Base comes to mind as one example - so why not slot in a Machine Code sprite drawer as an option.

PJ
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

sirbod, you could load the .ssd into beebem and then use the copy option to copy the basic to the windows (other OSs are available) clipboard and paste it on its merry way; next time I will include the source in the zip. It does use direct memory accesses though! PS I thought that I had posted it in the 8-bit section, but maybe not!
I've lost it again now, but someone did ask to allow some assembler, so I will add the drawing routine in asm (it only copies blocks of bytes anyway).
I was planning on using gotos, A%..Z% and a bit of memory, but thought I would try out these new fangled PROC and FN things - not sure about them, other than not needing line numbers they seem more trouble than they are worth (ducks for cover) :lol:
User avatar
FourthStone
Posts: 1527
Joined: Thu Nov 17, 2016 2:29 am
Location: Brisbane, Australia
Contact:

Re: BASIC Space Invaders

Post by FourthStone »

Nice work as usual Tricky :D Got any plans to add the bass sound effect?

Love that font especially, do you know of any similar routines to compress the Mode 2 font? I messed around with your invaders font code a little but it's obviously tuned for mode 1. If you have any ideas or links to an example that would be awesome :D

EDIT: Apologies, I found the slim font code defs for Deathmunks Ravenwood adventure, I think I'll use that :o
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: BASIC Space Invaders

Post by Lardo Boffin »

tricky wrote: I was planning on using gotos, A%..Z% and a bit of memory, but thought I would try out these new fangled PROC and FN things - not sure about them, other than not needing line numbers they seem more trouble than they are worth (ducks for cover) :lol:
Shots have been fired!

As I understand it PROCs are faster than GOTO. I'm sure I read somewhere (and doubtless someone will correct me) GOTO has to scan through each line of Basic to find the desired line number so GOTO 10000 from line 10 will be slower than GOTO 20 from line 10 because it has to find line 10000 (GOTO 10000 doesn't store the address of line 10000).
I believe the address of the PROC is stored directly in a much smaller lookup table and therefore is much faster to find in a large program.
Even if you use PROC heavily unless you have one PROC per line (which would be fairly pointless) there will be less searching to do.

Lardo
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
KarateEd
Posts: 6367
Joined: Fri Sep 20, 2013 10:15 pm
Location: Squamish, BC, Canada
Contact:

Re: BASIC Space Invaders

Post by KarateEd »

Not to mention that the program will be more structured when you go back in 2 years and decide to write it in Assembler....

Ed...... :-)
Ed...... :-)

3 working Beebs, 1 RetroClinic Master, 1 normal Master, 1 A3010, 1 Pi2 RISC OS, 2 broken Beeb Motherboards, 1 Omnibus A7000+ server, 1 A7000+ Desktop, 1 PET, 1 C64, 1 C128, 1 Amiga 500 and 1 Roamer.
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

Program has not got any more structured and if anything, the ASM has got less so ;)
Full source included this time with .ssd, just paste it in to beebem with a write enabled disc image, or just use the one provide :lol:
Only real changes are about 6 bugs fixed in the ASM so that the invaders march as they should (haven't checked exact locations).
I'm really bored of Space Invaders now :(
Attachments
BasicInvaders.zip
(8.3 KiB) Downloaded 219 times
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

Tonights installment, placeholder bombs ;)
Now it needs to be three programs to fit.
Attachments
BasicInvaders.zip
(9.52 KiB) Downloaded 226 times
User avatar
FourthStone
Posts: 1527
Joined: Thu Nov 17, 2016 2:29 am
Location: Brisbane, Australia
Contact:

Re: BASIC Space Invaders

Post by FourthStone »

Looking really good Tricky, love looking at your code I always learn something new so thanks for posting source :o
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

No time tonight, so just centred everything and added the bases.
The flickering in the top left is four bytes, each is the intersection of a bomb and something on screen.

EDIT: FourthStone, how to make code unreadable :lol:

EDIT: Missed the .zip, so also sneaked in a display of ships remaining and keyboard reading (displayed top left).
Attachments
BasicInvaders.zip
(11.69 KiB) Downloaded 211 times
User avatar
FourthStone
Posts: 1527
Joined: Thu Nov 17, 2016 2:29 am
Location: Brisbane, Australia
Contact:

Re: BASIC Space Invaders

Post by FourthStone »

Wow really coming together now :-)

The more you try to squeeze into a basic program the move abstract it becomes, at least your stuff looks neat, my code in ART is starting to look like spaghetti 8-[ time for a bit of refactoring.
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

I've pretty much given up on putting the actual game in to BASIC, even though it was one of the fastest BITD, it just doesn't compare to assembler.
?mem=?mem takes about 14 scan lines and a loop from 0 to 3 checking one location, with a chunky IF that is rarely taken is about half a screen!
Anyway, added a bit of colour and bomb collisions with the bases, destroying bits of them.
No gameplay yet and bombs are still placeholder, it feels a bit strange letting the OS do stuff for me and it hurts a bit that it takes longer to decode the instruction than execute it, but it is a marvel how compact it all is.
.ssd and source attached.
ImageImage
Attachments
gameplay.png
gameplay.png (843 Bytes) Viewed 12564 times
scoring.png
scoring.png (965 Bytes) Viewed 12564 times
BasicInvaders.zip
(11.16 KiB) Downloaded 235 times
User avatar
daveejhitchins
Posts: 7878
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: BASIC Space Invaders

Post by daveejhitchins »

tricky wrote:even though it was one of the fastest BITD
Have you considered 'packing' the BASIC? I've just tried it and it does run faster, however, it must screw-up the timing, or something, as the bombs don't drop :?

Dave H :D
Available: ARA II : ARA III-JR/PR : ABR : AP5 : AP6 : ABE : ATI : MGC : Plus 1 Support ROM : Plus 3 2nd DA : Prime's Plus 3 ROM/RAM : Pegasus 400 : Prime's MRB : ARCIN32 : Cross-32
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

Sounds interesting, but the bombs aren't effected by timing.

Edit: was it just invader that was packed, or the others too? If it stips unused variables, I can see it going wrong on the other two if it doesn't consider A℅..Z% being used from one programme the next.
User avatar
daveejhitchins
Posts: 7878
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: BASIC Space Invaders

Post by daveejhitchins »

tricky wrote:Sounds interesting, but the bombs aren't effected by timing.

Edit: was it just invader that was packed, or the others too? If it stips unused variables, I can see it going wrong on the other two if it doesn't consider A℅..Z% being used from one programme the next.
Ah! that would be it. I just 'packed' INVADER. But it was quicker :D

Dave H :D
Available: ARA II : ARA III-JR/PR : ABR : AP5 : AP6 : ABE : ATI : MGC : Plus 1 Support ROM : Plus 3 2nd DA : Prime's Plus 3 ROM/RAM : Pegasus 400 : Prime's MRB : ARCIN32 : Cross-32
avtovaz
Posts: 89
Joined: Wed Jan 18, 2017 5:09 pm
Contact:

Re: BASIC Space Invaders

Post by avtovaz »

a few people have said here about doing this in assembler, how hard is that actually? Ive always been told its not as easy as you think, and havnt really tried it.

I am thinking of my own game to make, ive got an idea but need to think mroe about how it will be on the screen etc...
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

Assembler does have its quirks and can be a pain.
It's like basic, but you only have goto, if goto, and ? to access memory. You can only do 8 bit integer maths and then only add, subtract, *2 and /2. To display stuff on screen, you have to copy it byte by byte!
So for most things, you have to write 10 times more code, but then it can run up to 20 times faster.
avtovaz
Posts: 89
Joined: Wed Jan 18, 2017 5:09 pm
Contact:

Re: BASIC Space Invaders

Post by avtovaz »

its one thing ive always wanted to learn so hopefully soon.


I cant get your game to my master atm, ive forgotten how to use the file program! But im really interested in it. thanks
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

I really don't recommend writing assembler inline in BASIC, although for writing a game in basic and then translating bits it works OK.
With something like RichTW's brilliant beebasm, you can still use things like FOR loops to make tables and generate code, but you also get scoping wi { and } like C etc; this make loops much cleaner as you can reuse names like .loop and .done. You also get better error checking and it can tokenize BAISC too as well as INCLUDE, making it easier to keep your code and files tidy. If that isn't enough, it will build .ssd files and has no limit on code size although it doesn't run on a beeb, but you can use your favourite (non-beeb) editor.
For machine code debugging, I find it easier to use an emulator, beebem for single stepping, b-em for command line and watch points and jsbeeb for some graphics; you could even use MAME, although you need to keep the CRTC is basic modes.
User avatar
sydney
Posts: 2925
Joined: Wed May 18, 2005 10:09 am
Location: Newcastle upon Tyne
Contact:

Re: BASIC Space Invaders

Post by sydney »

avtovaz wrote:a few people have said here about doing this in assembler, how hard is that actually? Ive always been told its not as easy as you think, and havnt really tried it.

I am thinking of my own game to make, ive got an idea but need to think mroe about how it will be on the screen etc...
Do you know any assembler? If not what then what other languages do you know?
avtovaz
Posts: 89
Joined: Wed Jan 18, 2017 5:09 pm
Contact:

Re: BASIC Space Invaders

Post by avtovaz »

syd, when i was younger i learnt some of bbc basic on my electron, and i can read code and work out what things do, but working up to do something good.



tricky, beebasm ive never heard of before! its all new to me! Ive only recently got back into this as i was given a master for doing some welding on a mini van LOL!


Ive got a lot to learn.
User avatar
sydney
Posts: 2925
Joined: Wed May 18, 2005 10:09 am
Location: Newcastle upon Tyne
Contact:

Re: BASIC Space Invaders

Post by sydney »

Have a look here for an easy introduction to 6502 assembly language:

https://skilldrick.github.io/easy6502/

It's not beeb centred but I found it quite useful.
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BASIC Space Invaders

Post by tricky »

Avtovaz, assembler can be quite slow going, to learn and to write.
Beebasm is an assembler built by RichTW for developing beeb games, it does everything in one go, no linking and no building disc image.
http://www.retrosoftware.co.uk/wiki/ind ... le=BeebAsm
Post Reply

Return to “trickysoft (new bbc micro games)”