Space Invader - C vs Basic

Want to talks about games you like, would like to see developed on the Oric, it's here.
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Space Invader - C vs Basic

Post 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.
Attachments
INVADEC.tap
(15.84 KiB) Downloaded 295 times
INVADE.tap
(4.46 KiB) Downloaded 288 times
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Space Invader - C vs Basic

Post 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/
User avatar
ibisum
Wing Commander
Posts: 1643
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: Space Invader - C vs Basic

Post 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...
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: Space Invader - C vs Basic

Post 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
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
NekoNoNiaow
Flight Lieutenant
Posts: 272
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: Space Invader - C vs Basic

Post 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. ;)
Post Reply