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

new games to be launched and discussed here
User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

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

Postby tricky » Tue Jan 24, 2017 9:14 pm

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 91 times
Last edited by tricky on Tue Apr 25, 2017 5:04 pm, edited 2 times in total.

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

Re: BASIC Space Invaders

Postby flaxcottage » Tue Jan 24, 2017 10:45 pm

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

Currently running Level 4 Econet with BBC B, BBC B+ 128K, Master 128K, 4Mb A3000, 4Mb A3020, 4Mb A4000, 4Mb A5000 dual FDD; UK101; HP41CX setup; Psion 3a, 3mx and 5mx; Z88; TI-58c, TI-59 and printer, HP-16C programmer's calculator

User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Tue Jan 24, 2017 11:29 pm

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: 431
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: BASIC Space Invaders

Postby PitfallJones » Wed Jan 25, 2017 2:51 am

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: 2797
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire

Re: BASIC Space Invaders

Postby flaxcottage » Wed Jan 25, 2017 10:52 am

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

Currently running Level 4 Econet with BBC B, BBC B+ 128K, Master 128K, 4Mb A3000, 4Mb A3020, 4Mb A4000, 4Mb A5000 dual FDD; UK101; HP41CX setup; Psion 3a, 3mx and 5mx; Z88; TI-58c, TI-59 and printer, HP-16C programmer's calculator

User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Wed Jan 25, 2017 11:24 am

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: 736
Joined: Mon Apr 09, 2012 8:44 am
Location: Essex
Contact:

Re: BASIC Space Invaders

Postby sirbod » Wed Jan 25, 2017 12:56 pm

: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
Posts: 2798
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: BASIC Space Invaders

Postby Arcadian » Wed Jan 25, 2017 1:26 pm

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.

;)
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk

Image
ABug NORTH (Manchester) (19-21 January 2018)
ABug SOUTH (Hampshire) (1-3 June 2018)

User avatar
PitfallJones
Posts: 431
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: BASIC Space Invaders

Postby PitfallJones » Wed Jan 25, 2017 2:13 pm

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: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Wed Jan 25, 2017 6:37 pm

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: 400
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: BASIC Space Invaders

Postby FourthStone » Fri Jan 27, 2017 4:21 am

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: 670
Joined: Thu Aug 06, 2015 6:47 am

Re: BASIC Space Invaders

Postby Lardo Boffin » Fri Jan 27, 2017 6:48 am

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
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, matchbox co-proc, Viglen twin 40/80 5.25" discs, acorn cassette
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc, Acorn 6502 coproc

User avatar
KarateEd
Posts: 3050
Joined: Fri Sep 20, 2013 9:15 pm
Location: Squamish, BC, Canada

Re: BASIC Space Invaders

Postby KarateEd » Sun Jan 29, 2017 4:51 am

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...... :-)

User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Tue Jan 31, 2017 9:35 pm

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 35 times

User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Wed Feb 01, 2017 9:00 pm

Tonights installment, placeholder bombs ;)
Now it needs to be three programs to fit.
Attachments
BasicInvaders.zip
(9.52 KiB) Downloaded 39 times

User avatar
FourthStone
Posts: 400
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: BASIC Space Invaders

Postby FourthStone » Thu Feb 02, 2017 12:16 am

Looking really good Tricky, love looking at your code I always learn something new so thanks for posting source :o

User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Thu Feb 02, 2017 8:27 pm

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 37 times

User avatar
FourthStone
Posts: 400
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: BASIC Space Invaders

Postby FourthStone » Fri Feb 03, 2017 5:14 am

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: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Sun Feb 05, 2017 3:59 pm

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
(843 Bytes) Not downloaded yet
scoring.png
(965 Bytes) Not downloaded yet
BasicInvaders.zip
(11.16 KiB) Downloaded 42 times

User avatar
daveejhitchins
Posts: 3691
Joined: Wed Jun 13, 2012 5:23 pm
Location: Newton Aycliffe, County Durham

Re: BASIC Space Invaders

Postby daveejhitchins » Sun Feb 05, 2017 6:51 pm

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
Parts: UM6502CE, GAL22V10D, GAL16V8D, AS6C62256A, TC514400AZ, WD1772, R6522, TMS27C512, AT28C256
Products: ARA II, ABR, ATI, AP6, MGC, AP5 . . .
For a price list, contact me at: Retro Hardware AT dave ej hitchins DOT plus DOT com

User avatar
tricky
Posts: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Sun Feb 05, 2017 7:29 pm

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: 3691
Joined: Wed Jun 13, 2012 5:23 pm
Location: Newton Aycliffe, County Durham

Re: BASIC Space Invaders

Postby daveejhitchins » Sun Feb 05, 2017 9:02 pm

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
Parts: UM6502CE, GAL22V10D, GAL16V8D, AS6C62256A, TC514400AZ, WD1772, R6522, TMS27C512, AT28C256
Products: ARA II, ABR, ATI, AP6, MGC, AP5 . . .
For a price list, contact me at: Retro Hardware AT dave ej hitchins DOT plus DOT com

avtovaz
Posts: 34
Joined: Wed Jan 18, 2017 5:09 pm

Re: BASIC Space Invaders

Postby avtovaz » Mon Feb 06, 2017 6:21 pm

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: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Mon Feb 06, 2017 6:43 pm

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: 34
Joined: Wed Jan 18, 2017 5:09 pm

Re: BASIC Space Invaders

Postby avtovaz » Mon Feb 06, 2017 8:18 pm

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: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Mon Feb 06, 2017 9:00 pm

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: 1986
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: BASIC Space Invaders

Postby sydney » Mon Feb 06, 2017 9:11 pm

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: 34
Joined: Wed Jan 18, 2017 5:09 pm

Re: BASIC Space Invaders

Postby avtovaz » Tue Feb 07, 2017 7:34 pm

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: 1986
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: BASIC Space Invaders

Postby sydney » Tue Feb 07, 2017 7:44 pm

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: 1916
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BASIC Space Invaders

Postby tricky » Tue Feb 07, 2017 7:58 pm

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/index.php?title=BeebAsm


Return to “software: new games”

Who is online

Users browsing this forum: No registered users and 1 guest