Page 1 of 1

Space Invader - C vs Basic

Posted: Sat Oct 13, 2018 11:09 pm
by Badger
I decided to compare basic with c and what better way to do it than using the classic Space Invaders.

The basic program is from a listing in "Meteoric programming" and is playable if a little slow.

I then converted it using very dirty code, that could be tidied up somewhat given more time, but for this test I just wanted something that looked identical.

I added a welcome and a game over screen to the C version and decrementing delay for each successive wave of aliens, so they get faster with each destroyed wave.

I have attached the 2 TAP files for the basic and C versions.


There are bugs in both, and occaisionally the C version crashes.

If anyone wants the code (either basic or C) then just drop me a message and I'll get them to you. I cant attach them here it seems.

Have fun.

Re: Space Invader - C vs Basic

Posted: Sun Oct 14, 2018 8:30 am
by Dbug
If you want, I can give you access to the SVN repository and you could just put your game projects in a users/badger folder like other have done before:
http://miniserve.defence-force.org/svn/users/

Re: Space Invader - C vs Basic

Posted: Sun Oct 14, 2018 9:42 am
by ibisum
Cool stuff - interesting conversion. The difference in speed is pretty obvious - but what's going on with the sound in the C version? To me it feels like the C version gets interrupted by sound more severely than the BASIC version .. maybe its just a perception problem since the C version is noticeably faster ..

Anyway, great work - and yeah, would be nice to have projects like this in a repo, so you can get contributions. I've been following all the latest C-based projects with much interest .. and spent my day reading Oric machine code to try to work out how I can add cute things here and there...

Re: Space Invader - C vs Basic

Posted: Sun Oct 14, 2018 10:30 am
by Badger
Thanks Dbug.

These little projects are my method of testing and converting things betweem languages.

Most of the code is quick and dirty but is allowing me to figure out little routines that can be incorporated into a bigger project.

I will gladly share and it maybe interesting for people to see how I get from :-
PLOT 10,10,"A" in Basic
to
memset((char*)0xbbb2,65,1); in C
to
LDA #$41
STA $bbb2,A

Ibsum:-
I actually had to slow it down somewhat.

The sound issues are due to the fact that the alien missiles start too far down the screen and so the time between 2 missiles is a lot shorter.

48 and still learning :D

Re: Space Invader - C vs Basic

Posted: Thu Oct 25, 2018 5:05 am
by NekoNoNiaow
Great effort!

It is quite impressive how the C version is faster than the BASIC one, way too fast to be really playable though. ;)
This shows that there is a room for C based games on the Oric for sure.

Note that regarding the graphics, I tend to actually somewhat prefer the PET version of Space Invaders which embraces the text mode with the help of the PETSCI character set and does look really nice nevertheless:
Badger wrote: Sun Oct 14, 2018 10:30 am I will gladly share and it maybe interesting for people to see how I get from :-
PLOT 10,10,"A" in Basic
to
memset((char*)0xbbb2,65,1); in C
to
LDA #$41
STA $bbb2,A
This would definitely be useful for beginners indeed!

Note that you could also replace the memset with:

Code: Select all

*(char*)0xbbb2 = 65
;)
Badger wrote: Sun Oct 14, 2018 10:30 am48 and still learning :D
Never stop. ;)