Space Invader - C vs Basic

Want to talks about games you like, would like to see developed on the Oric, it's here.
Post Reply
User avatar
Badger
2nd Star Corporal
Posts: 20
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Space Invader - C vs Basic

Post by Badger » Sat Oct 13, 2018 11:09 pm

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.
Attachments
INVADEC.tap
(15.84 KiB) Downloaded 21 times
INVADE.tap
(4.46 KiB) Downloaded 20 times
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Dbug
Site Admin
Posts: 2744
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Space Invader - C vs Basic

Post by Dbug » Sun Oct 14, 2018 8:30 am

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/

User avatar
ibisum
Wing Commander
Posts: 1031
Joined: Fri Apr 03, 2009 8:56 am

Re: Space Invader - C vs Basic

Post by ibisum » Sun Oct 14, 2018 9:42 am

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

User avatar
Badger
2nd Star Corporal
Posts: 20
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: Space Invader - C vs Basic

Post by Badger » Sun Oct 14, 2018 10:30 am

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
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
NekoNoNiaow
Flying Officer
Posts: 149
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: Space Invader - C vs Basic

Post by NekoNoNiaow » Thu Oct 25, 2018 5:05 am

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 am
48 and still learning :D
Never stop. ;)

Post Reply