Optimizing the level generator, lines 120-140: Use bit 7 of RND instead of bit 0 to remove the need for multiplication, and use variables instead of literals: 120 e=128:d=32:fori=1024to1823:rnd:a=aande:a=a+d:pokei,a:next 130 140 => 53 jiffies, 2.4x faster than original Or use bits 15 and 7 of RND, variables instead of literals, and finally do GO6 (16-bit poke) to poke two pieces of 'doom' at once: 120 e=32896:d=8224:forz=1024to1823step2:rnd:a=aande:a=a+d:go6:next 130 140 => 29 jiffies, 4.4x faster :) Thanks for the coverage, Robin! These shows are always great fun to watch :)
@@luispieri640 sounds like a great side project for someone. Would you remap variables like ab and ac to a free single letter somehow? Thinking about it, you would have to assume some features were not used or this translation could become very difficult! Maybe a starting point would be a kind of lint where you detect if the source program was translatable in principle. Rewriting expressions feels like CS homework!
I remember back in the day using the BLITZ! compiler for basic programs which made a faster tokenized code. Of course it made it a little bigger due to the interpreter.
Oh - that's *cool* - I keep banging on about how amazing the BBC Basic is because it has a built-in inline assembler. Never even considered you could have a BASIC interpreter with another hi-performance basic interpreter built-in. Very, very cool idea.
Nice to see that BASIC, and it's concept, isn't dead. I thought from the name, that you had actually found something useful from the Haresoft company of back in the day. Glad I didn't miss out on it then.
I've been following an excellent 6502 tutorial on board-b's channel and it's given me some confidence to starting watching your wonderful channel again. I'm usually completely lost when I watch your videos but I have a morsel of confidence now so here I am again.
Nothing wrong with liking your own game. I think it's a testament to how fun it is that you do like it. Don't know how many times I would play Space Invaders back in the day and just spend a lot of time at the start just whittling away at those blocks near the bottom. Used to drive my brother crazy.. "Why are you doing that??!! Shoot the aliens!" Now I have a whole game dedicated to that!! Thanks.
So basically, it has the same limitations as one of those popular micro-compilers from back in the days but replaces the compilation with an interpreter. Interesting approach.
Really amazing project! It reignites my desire to tinker around in basic again. Thank you for the quick rundown of features and demos. Descending Doom seems like a really cool base to flesh out a wonderful addition to C64 shareware and a great example of Hare Basic's capabilities.
What a neat idea - the concept reminds me somewhat of "RISC" versus "CISC" - we now have a kind of "RISBAS", if you see what I mean. I especially like the way it "dovetails" with conventional C64 Basic. I'm definitely going to investigate ...
Hare Basic looks pretty interesting and definitely fast for basic. I was kind of hoping to see “10 Print” make an appearance. 😀 Your game prototype looks fun. I tend to like those “falling things create pressure” kind of games. At least up until they are way too fast to play.
Oh man, I was about to comment this but instead looked for the comment of someone else saying it: I wanted to see the "10 print" in this as well! I thought about how it would be a curious RND call with AAND1 again, it was going to be fun! But it was a very fun video as well anyway! Thanks Robin
I always thought that there were significant inefficiencies in the stock BASIC interpreter. This vindicates my opinion. Thank you for sharing this and thanks @AleksiEeben for making such an amazing interpreter.
I got chills on my spine for the metaphor of calendar years VS the bottom screen row memory locations, as those years match lifespan of interest in cbm64 by people I felt my very life as characters printed on that screen, as if what i did during those years could change the character on the screen of my life, as living in a cyberpunk movie, hence the chills
Reminds me of "back in the day" when I hacked up "quick print" routines from the original basic ML routines, though this is obviously a full-features product rather than hacking. Even that made a massive improvement (mostly as I had no error checking at all and different calls for integer and string). Yet another opportunity to be famous wasted (lol). Well done to Aleski and thankyou for sharing this with us. I'll have to check it out.
"Descending Doom"! That would be a fantastic title for a movie! Another great episode Robin! You have a fantastic way of making going through code line-by-line interesting. Your game in a way reminds me very much of the very popular "Astrosmash!" game for Intellivision in the 1980s! I must admit, Descending Doom looks like fun! The mark of a good game is that it is fun in spite of not having fancy graphics. There are too many junk games in this world with awesome graphics. Thanks Robin!
No white space is not a bad habit, it is efficient. Especially if you learned BASIC on something with around 4K of memory where every white space takes up precious space.
I remember the time making an accidental raster line in BASIC. It was just one line and pressing any key would make the line scroll. As soon as I saw the raster demo with bunch of lines I realized how fast this was.
Simons BASIC added what was really missing from V2.0: graphics, sound, sprite commands, next to disc handling. The first three made the C64 great (or even epic), but you could not touch it without register level programming in BASIC. Unfortunately even the later releases did not added these commands. You can download for C64 the V3.5 BASIC, just 3.5 KB extra, but makes the programming much more fun, with even structured programming commands.
After 30 years of using real text editors, it's almost impossible to remember pressing return on every line when copying lines in the C-64 screen editor :D
I see a cave crawler game. Maybe when the columns hit the floor they spread left or right. Or you have some limited vertical range and you can shoot a column off and it hits the ground and implodes and fades away or melts if they are ice columns with collectable gold nuggets (and dynamite sticks) embedded. You get the nuggets before being entombed in ice. If successful you move onto other caves with bats and monsters protecting nuggets.
There is a bug in the Balloons example (8 to 15 mins). It initializes C to 0 in line 10 then without using it sets it to 53286+A in line 40 as part of the setup loop. It then gopes on to use it from the unintended starting valuie.
I guess it's not retro enough (anymore)... Just kidding... Maybe it'll be here sooner or later. Not everyone is having REU to run Vision Basic on real HW (fact that could reduce audience, but also make people get REU and start with Vision Basic) But then, I assume most of us are just using VICE or other emulators and REU is suddenly not a problem. TSB, that's some nice piece of good entertainment. Yes, I would love to see both on this channel too. Robin is always having good ideas 💡 and I am sure he'll come up with something (again, sooner or later)... We, RetroPeople, are mostly used to waiting, just to bad life isn't eternal 😁
The best thing about TSB (Tuned Simons Basic) is that the developer is still working on it and making fixes and improvements. He is a very nice guy from Germany who likes to help and explain things.
23:50 it’s an LFSR, the feedback loops needs something to feed back. All zeros won’t XOR to something other than themself. Hence getting stuck. If you use the correct number and location of the TAPs (which commodore BASIC does) you can generally avoid the stuck in all 1s state. 33:35 that would make a good band name
Hare Basic RND is 16-bit "798" Xorshift (by George Marsaglia, John Metcalf, Veikko Sariola) from codebase64. The algo outputs numbers in the range $0001-$ffff, and stalls if the seed if set to $0000. Hare takes the number and EOR's it by $ffff to get numbers in the range $0000-$fffe, which is more handy: The programmer can then extract smaller ranges by doing an AND with a (power-of-two - 1), ie. 3, 7, 15, 31, 63, etc. (The point being in these smaller ranges we usually want to include 0.) Hare also checks if someone has accidentally (or on purpose) set the seed in memory to zero, and turns it to $0001. Takes a few extra cycles, but guarantees that the RND won't stall even if tampered with :) CBM BASIC random is very slow... What is in Hare I believe is sufficiently good, and speed is a plus! If non-deterministic randomness is needed, the output could be EOR'd with CIA timer low byte or user joystick inputs, or a dummy random number could be created every frame in the game loop, etc.
12:35 "R is the base register" but I don't see any use of it. Even more, I removed both occurrences of it (on Vice emulator) and the "Balloons" program seems to work just the same !
Looks like you're right; that must have been leftover code from when this example was being developed and I didn't notice it wasn't being used. Good catch!
Unusual and cool concept. I have regards for very simplified BASICs ( like subset of V2), exactly because it may run much faster (having , for example, static string handling and purely integer arithmetic). But even more important - it might be easier to create a very efficient compiler for such little BASIC! So, next very good step for this Hare project might be producing neat compiler, that gives small and even faster machine code! And so we can have everything, the best of all worlds! Why shouldn't we? :) One more thing I noticed - AMOS Basic for Amiga has some small and very fast internal BASIC interpreter called AMAL (animation language), executed from AMOS strings. Something like this existed in Oasis Lightning BASIC/Forth for C64, I think it was also called AMAL. This Hare thing reminds me on that concept, just using regular BASIC listing for the code.
The main things that need to be optimized in Commodore BASIC are to use addresses instead of or in addition to line numbers in GOTOs, etc.; to use addresses instead of names for variable references; to use tokenized binary representations of numbers instead of parsing them at runtime; and to have a special, optimized representation of binary numbers 0-65535 in the floating-point encoding, such as with exponent = $00. Use these integers directly for simple operations like reference and addition, and convert them to general floating point for non-trivial operations or integer overflows.
If you mean TheVIC20 "maxi" then I think rename the file to something like HareBasic_35k.d64 and it should work. Check the manual for TheC64 / TheVIC20 if that doesn't work.
Might I recommend a slight change to the fire button for your game - have it cancel the current shot as well. I noticed a bullet travelling all the way to the top of the screen on a clear column can take a bit. A cancel button would let you abort that shot and perhaps avoid imminent doom. Sorry if it already works like that - I couldn't tell :-)
I'm amazed it's that fast from an interpreter, I expected it to compile the code first. He should make a compiler too, although not sure if it could be that much faster. If only this was around back in the day.
Super interesting video to watch, as always. I would have loved if C=ommodore had optimized C128 basic a bit, with true fast integers variables and other possible small things
Yeah, they really focused on adding loads of features to C128 BASIC, but didn't seem to look at optimization at all. Except of course many of the new commands did speed things up by eliminating many POKEs in certain programs. But yes, true integers would have been great.
Wow! That's a bit of a coincidence! I started writing a simplified (only 16-bit integer maths and limited string handling) BASIC compiler on the BBC Micro, with a syntax intentionally compatible enough to allow code to be entered in the existing BASIC editor and run in its interpreter. It compiled to an intermediate code for a dedicated virtual machine designed "in parallel" with the language; for instance, FOR and NEXT had their own single opcodes in the VM. Long variable names were supported, too; as, once the symbol table has been built up, variable names only need to be searched for at compile time, as reading a variable's value gets translated to a fixed-location memory read based on wherever the variable actually is stored. The VM was basically stack-based, but with an optimisation to save a stack push and pull when a value was specified as a right-side operand. Each instruction could potentially exist in three addressing modes: Stack (ADD on its own adds the top two numbers on the stack and leaves the total on top of the stack), Immediate (USE #&0123 places &0123 on top of the stack) or Memory (SUB &0404 subtracts the contents of address &0404 from the number on top of the stack and leaves the difference where it was). USE #&0004 places &0004 on top of the stack, USE &0424 places the contents of address &0424 on top of the stack, GET takes an operand or the value on top of the stack and places the contents of that location on top of the stack, PUT takes a value as an immediate operand, memory address or from the stack; an address from the stack; and stores the value there. PAF does the same but the other way around, Address First, for situations where the operands naturally fall that way round. It needs some more instructions adding to the VM, and I need to do more work on the instruction parser, but I think I might pick it up again now there's obviously a bit of competition in town!
This programming style would have driven my computer science teacher MAD back in the 80s at school. He would call this "spaghetti code". We even weren't allowed to use Basic but had to use Turbo Pascal instead. It is still fun to watch but comes from a time when only ONE person in the world had to understand the code and - be honest - couldn't change a thing after a while because the code is simply unreadable. But a part of me still loves it.
9:50 so it's like turbobasic on Atari XL Where it's effectively a ram resident patch for the normal basic in ROM.... Replacing the inefficient stock basic routines and adding extra features
I really like them, yeah. They're a lot like CX40s but a bit more comfortable, have a longer cord (almost too long), and seem to be a bit better constructed. So yeah, I recommend them especially if the price is still reasonable like when I bought mine a few years ago.
@@8_Bit I agree, I bought mine after seeing Robin's a few years ago and it's served me well. They work on a bunch of systems which is great, just like the original Atari joysticks.
Not sure how it would slow things down, but with a little adjustment to the character set, you might design some mean looking little faces for the lowest or leading block of each column, and they look meaner as they get closer. Also instead of "Game Over" I would suggest "Thou Art Doomed" or something in keeping with the theme.
It would sure be nice to see a comparison of modern Commodore languages. Vision Basic is my current favorite. Yes, you need a VICE emulator or a REU to program with it, but it is blazing fast and can compile stand-alone programs that can run on a stock C64.
Don't hold your breath waiting. Robin is purposely staying away from Vision BASIC for some reason. Thankfully, there are other TH-camrs willing to cover it.
@@endwigast5212 I am just learning Vision Basic. I was able to create a fairly fast one line maze : 10 R=RND AND 1:ADD R=R+205:?CHR R; DO 10,920 Short and fast, although I am sure that Vision can go faster. I hope Robin will get around to covering it, he is a fantastic teacher and his explanation of how it works would be fantastic I am sure.
I didn't know about Solution 42 until yesterday when a commenter mentioned it, so I watched it and left a comment on that video. That coincidence alone amazed me! Is that enough to make the algorithm suggest that video as related??
Here’s an Idea for “Descending Doom” scoring: Have the game award more points for blocks that are destroyed in higher rows. I think this will incentivize players to take more risky actions and make it more challenging. ( of course I realize you don’t current keep score so you’d have to do that too… maybe eliminate the top row ) A subtle indication the row is about to drop much also be worth it to develop.
I'm looking at the random number benchmark sample and it doesn't seem entirely fair. Basic has to define the range 0-65534 and that is Hare's RND default code. If you specify a range like A=AAND255 then it's about three times slower. If you add a function like PRINTA; then it becomes only about twice as fast as BASIC.
That's a really compelling BASIC, and looks like it would be fun to create with. Maybe I'll take it for a spin and implement Conway's Game of Life, see how much faster it would be. I looked at the PDF and see that instead of arrays, you just peek/poke memory. The GO4/GO5 you showed makes me think that maybe smooth vertical scrolling would be possible?
Yes, I wonder if fast (max) 256 element arrays could be implemented in Hare Basic somehow, with it being up to the user to reserve the memory. And yes, I think smooth scrolling could be achieved with GO4/5, maybe not a rock solid 50 Hz (or especially) 60 Hz, but even with a frame stutter here or there it would be way better than CBM BASIC.
Of course a CNCD member creates a blazingly fast BASIC thing. Those demoscene people are usually pretty hardcore optimizers, whether it's code, graphics or music :)
Hey, Robin, you may have missed a good opportunity to make that "2023" video... _on time..._ but I'd still really love to see what you would do with that anyway! Late is still better than none in many cases, right? Please make that; I guarantee you that I'll watch it!
I'd love to play a game like that on Atari 2600. Maybe something based on Centipede. But with no centipedes. Just more and more mushrooms, descending upon you.
Some time ago I ran into "Vision Basic". This s a paid program, but you get a nice paper manual with it. It will need a REU (in future versions possibly also GEORAM would do). It works on VICE in case you don't have a real C64 with a REU. I wonder how your game would do with that? From my experience you can load a classic basic program - and like here you also need to take few adjustments [ "clr" the vars at start ]. Like here there are some math-quirks, like doing math as a 1$ calculator ==> 2+2*2 gives 8. What I love most is : You have quite extended command set and you can mix assembly code with Basic.
I actually bought Vision BASIC and used it a bit, but I really wasn't hugely into it. I started doing assembly programming on the C64 at the same time and that gives you so much more power and flexibility. I was really disappointed with some of the limitations in Vision BASIC, like no floating point numbers. A lot of the actual stuff I write for these computer is often engineering or science related and so no floating point is a deal-breaker. I did want to support him though, and I know he's about to release a v2.0 (not sure if existing owners will get an upgrade for free or discounted price?).
This game seems genuinely promising! What it needs is music. Since I've leraned that SID samples are usually block based rather than samples (courser building stones, but thematically re-usable), why not collaborate with this developer and provide music which gets gets progressively more ominous the further the wall of Doom descend on the player? Im not saying it's as easy as pitch shifting continuously, but maybe certain raster lines could provide trigger points to switching over to more sinister chord progressions? Just spitballing here.
This is a very interesting and novel concept: high level and mid level basic interpreters working together. I fear, however, that it will have less impact than it would have if it came some years ago. Nowadays it will undoubtedly be compared to languages such as XC=Basic (3.1 already) and Vision Basic, which are much more powerful AND compile to significantly faster stand alone code AND can easily integrate machine language routines.
I haven't. I did sort-of consider buying it when it was on sale a while ago but the high cost of shipping to Canada put me off again. I think I read a newer version is coming out in a while, maybe I'll look at it then. Hare Basic appealed to me because 1) it's written by someone I've respected for many years 2) it's free 3) it's light-weight 4) it's very effective 5) it was really easy to learn 6) it co-exists with CBM BASIC really nicely 7) it works on VIC-20 and C64 8) it has no extra requirements (beyond extra RAM on VIC-20 which I already have)
Bit of an offtopic comment I'm afraid but how on earth have you kept your C64 so clean and neat? Mine is all yellowed with age! It still functions though, as do both of my original ZX Spectrum computers I still have from when I was a kid in the 1980s. Wonderfully durable machines, despite their cheap production costs back then!
Besides cleaning it occasionally, I haven't done anything special with it. Might mostly be luck of the draw; the yellowing of the plastic apparently depends quite a bit on the mix of chemicals used and this 64 case must have been made on a day when they had the mix perfect.
Video idea: There is a way to upload code to the 1541 floppy and execute it, then get back the results to the C64. I dimly remember seeing that used to speed up calculating fractals. And i'm pretty sure a disk copy program used that so you can duplicate between two floppy drives while using the C64 for something else. Maybe you could go into details how that works?
It would be interesting to see where Hare Basic fits into Noel's Retro Lab's bench marking spreadsheet. Search for his video "Is this the FASTEST and CHEAPEST 8-Bit Computer Ever?" and see the link in the video description "BASIC benchmarck page". The simple basic code is in the "BASIC benchmark" tab. 10 FOR i=1 TO 10 20 s=0 30 FOR j=1 TO 1000 40 s=s+j 50 NEXT j 60 PRINT "."; 70 NEXT i 80 PRINT s CBM basic does it in 40 seconds. VIC20 in 37 seconds.
Very impressive work! "I think it's cool and that's all that matters" :) absolutely, your channel your rules but I have to say you're not the only one that thinks it's cool! So we're in the 16 bits of unused space... that explains a lot about the world today. I guess we only have until 2040 before we'll overwrite the sprite pointers and the universe will vanish? :D
I haven't tested it on my real SuperCPU but it works fine on the VICE SuperCPU emulator. Hare Basic just patches various BASIC/C64 vectors as far as I know, so it's compatible with SuperCPU and probably other well-behaved peripherals.
You should probably check E for an underflow condition in line 400. Yes, the game will most certainly have been lost before E wraps around, but you never know! 😉
I couldn't help but think the winning screen should have said "You Are Winner!" in reference to "Big Rigs: Over the Road Racing" Edit, it actually says "You're Winner!"
So the reason you put quotation marks around "repurposed" is that "go" really isn't a command in the 64; only in the 128 in 128 mode and the 65 in 65 mode? Or is there a different reason you used quotes; and if so, then what is that? And what would this be like if you ran it in 128 mode? Will you try to compile a video of odd experiments you can try with this? Like... try making a BASIC program that used all originally Commodore-compatible commands and tokens (so you won't get a syntax error, etc. when you try what I'm about to say next), and then run it on both Hare and pure Commodore (so run it again without loading Hare).
What a great concept. This could be used in university courses as a precursor tutorial to machine language. We used SPIM (MIPS simulation), why not use VICE with Hare BASIC then TMP in such subjects? Much more intuitive. You didn't credit yourself in the main game screen. And what's that imposter font at 45:15? ;) Great game concept too. A power-up element might be a fun addition.
Hah, I've been using that low-rent font occasionally in videos for a few months now, and I think you may be the first to comment on it :) Power-ups could be fun. Maybe a special block could occasionally show up on screen for a moment.
It's quite logical that a BASIC interpreter that uses only integers is faster than CBM BASIC V2, which uses floating-point arithmetic throughout. Similar to the speed of AppleSoft BASIC vs. Integer BASIC on the Apple II.
Optimizing the level generator, lines 120-140:
Use bit 7 of RND instead of bit 0 to remove the need for multiplication, and use variables instead of literals:
120 e=128:d=32:fori=1024to1823:rnd:a=aande:a=a+d:pokei,a:next
130
140
=> 53 jiffies, 2.4x faster than original
Or use bits 15 and 7 of RND, variables instead of literals, and finally do GO6 (16-bit poke) to poke two pieces of 'doom' at once:
120 e=32896:d=8224:forz=1024to1823step2:rnd:a=aande:a=a+d:go6:next
130
140
=> 29 jiffies, 4.4x faster :)
Thanks for the coverage, Robin! These shows are always great fun to watch :)
Nice optimizations! Thanks for Hare Basic, it's really fun.
Helluva great tool u've made. Mesmerizing such a thing is even possible.
@AleksiEeben amazing speed! A good txt converter to c64 that do not add spaces and let the c64 basic output compatible with Hare?
Aleksi: Any chance of doing a C-128 mode version of Hare BASIC? If any BASIC needs to be a "HARE" faster, it's the C-128 mode on a Commodore 128! ;)
@@luispieri640 sounds like a great side project for someone. Would you remap variables like ab and ac to a free single letter somehow? Thinking about it, you would have to assume some features were not used or this translation could become very difficult! Maybe a starting point would be a kind of lint where you detect if the source program was translatable in principle. Rewriting expressions feels like CS homework!
I love that Hare BASIC coexists so nicely with C64 basic, seems like it is almost being a library of sorts
You made a fully functioning game just to "test out Hare BASIC". Gotta admire that as well. Can't wait to try it out at the first opportunity I get.
I remember back in the day using the BLITZ! compiler for basic programs which made a faster tokenized code. Of course it made it a little bigger due to the interpreter.
Oh - that's *cool* - I keep banging on about how amazing the BBC Basic is because it has a built-in inline assembler. Never even considered you could have a BASIC interpreter with another hi-performance basic interpreter built-in. Very, very cool idea.
Nice to see that BASIC, and it's concept, isn't dead. I thought from the name, that you had actually found something useful from the Haresoft company of back in the day. Glad I didn't miss out on it then.
The documentation really captures the retro feel - it just needs to be photocopied a few times to really get that look heh.
I've been following an excellent 6502 tutorial on board-b's channel and it's given me some confidence to starting watching your wonderful channel again. I'm usually completely lost when I watch your videos but I have a morsel of confidence now so here I am again.
Nothing wrong with liking your own game. I think it's a testament to how fun it is that you do like it. Don't know how many times I would play Space Invaders back in the day and just spend a lot of time at the start just whittling away at those blocks near the bottom. Used to drive my brother crazy.. "Why are you doing that??!! Shoot the aliens!" Now I have a whole game dedicated to that!! Thanks.
So basically, it has the same limitations as one of those popular micro-compilers from back in the days but replaces the compilation with an interpreter. Interesting approach.
Really amazing project! It reignites my desire to tinker around in basic again. Thank you for the quick rundown of features and demos. Descending Doom seems like a really cool base to flesh out a wonderful addition to C64 shareware and a great example of Hare Basic's capabilities.
Whenever I see a new 8-Bit Show and Tell video appear it makes me feel happy!
What a neat idea - the concept reminds me somewhat of "RISC" versus "CISC" - we now have a kind of "RISBAS", if you see what I mean. I especially like the way it "dovetails" with conventional C64 Basic. I'm definitely going to investigate ...
"If you don't think it's fun, that's fine. Go do something else!"
And here I was believing the answer to life the universe and everything was 42.
42 isn't the answer to life the universe and everything.
It's the answer to the ULTIMATE QUESTION of life, the universe, and everything.
Amazing Video Robin! We want more Hare Basic games/tutorials!
Hare Basic looks pretty interesting and definitely fast for basic. I was kind of hoping to see “10 Print” make an appearance. 😀
Your game prototype looks fun. I tend to like those “falling things create pressure” kind of games. At least up until they are way too fast to play.
Same here 😊
Oh man, I was about to comment this but instead looked for the comment of someone else saying it: I wanted to see the "10 print" in this as well! I thought about how it would be a curious RND call with AAND1 again, it was going to be fun! But it was a very fun video as well anyway! Thanks Robin
It would have to be a few lines long right?
They fact that you can mix Hare Basic and regular basic is awesome. The no white space thing is much less so.
Every space wastes 1 byte plus interpretation time slowdown.
Totally get the ethos of no space - memory was ultra precious resource on the 8-bits
@@MyAmazingUsername The spaces could have been recreated by LIST.
Thank you, I’m creating a BASIC game and can use this. I really enjoy your videos.
I'd really like to see a Hare Basic version of Centipede. If no sprites were used, your game makes it seem easier than I would have thought.
Yes, I bet a fantastic version of Centipede could be made with this.
You can add a custom character set to make changing mushrooms as you shoot them
I always thought that there were significant inefficiencies in the stock BASIC interpreter. This vindicates my opinion. Thank you for sharing this and thanks @AleksiEeben for making such an amazing interpreter.
You should have called your game "DoomScrolling"
That's occupied already (for the PETSCII domain).… ;-)
This game was so fun, Robin! I almost beat it on my first try :) Wish we had this in Compute's Gazette back in the day!
I got chills on my spine for the metaphor of calendar years VS the bottom screen row memory locations, as those years match lifespan of interest in cbm64 by people
I felt my very life as characters printed on that screen, as if what i did during those years could change the character on the screen of my life, as living in a cyberpunk movie, hence the chills
Reminds me of "back in the day" when I hacked up "quick print" routines from the original basic ML routines, though this is obviously a full-features product rather than hacking. Even that made a massive improvement (mostly as I had no error checking at all and different calls for integer and string). Yet another opportunity to be famous wasted (lol). Well done to Aleski and thankyou for sharing this with us. I'll have to check it out.
"Descending Doom"! That would be a fantastic title for a movie! Another great episode Robin! You have a fantastic way of making going through code line-by-line interesting. Your game in a way reminds me very much of the very popular "Astrosmash!" game for Intellivision in the 1980s! I must admit, Descending Doom looks like fun! The mark of a good game is that it is fun in spite of not having fancy graphics. There are too many junk games in this world with awesome graphics. Thanks Robin!
No white space is not a bad habit, it is efficient. Especially if you learned BASIC on something with around 4K of memory where every white space takes up precious space.
I L I K E M Y S P A C E S : - D
"It's Tetris - but with a military touch" - The New York Times
I remember the time making an accidental raster line in BASIC. It was just one line and pressing any key would make the line scroll. As soon as I saw the raster demo with bunch of lines I realized how fast this was.
Wow a 60FPS clear screen! Will wonders never cease!
Wow! That is a very elegant approach to integrate a lightning speed basic within commodore basic. I wish it supported the PET/CBM!
It's like shooting down the spikes at the end of a Tempest level :)
This really is the next evolution of Commodore Basic. Just imagine if we'd had this back in the 80s? Much easier to use than Simon's Basic or LOGO.
Simons BASIC added what was really missing from V2.0: graphics, sound, sprite commands, next to disc handling. The first three made the C64 great (or even epic), but you could not touch it without register level programming in BASIC. Unfortunately even the later releases did not added these commands. You can download for C64 the V3.5 BASIC, just 3.5 KB extra, but makes the programming much more fun, with even structured programming commands.
Thanks for such a great video and a simple but fun game!!
21:40 I guess Line 77 should read "SCROLL UP (VIC 20)" ☺
I suspect you're right!
After 30 years of using real text editors, it's almost impossible to remember pressing return on every line when copying lines in the C-64 screen editor :D
I see a cave crawler game. Maybe when the columns hit the floor they spread left or right. Or you have some limited vertical range and you can shoot a column off and it hits the ground and implodes and fades away or melts if they are ice columns with collectable gold nuggets (and dynamite sticks) embedded. You get the nuggets before being entombed in ice. If successful you move onto other caves with bats and monsters protecting nuggets.
There is a bug in the Balloons example (8 to 15 mins). It initializes C to 0 in line 10 then without using it sets it to 53286+A in line 40 as part of the setup loop. It then gopes on to use it from the unintended starting valuie.
Very interesting! THANK YOU!
I think it'd be pretty cool if the descending lines were actually dripping slime, or something. :)
Great video. But I still miss a video about Simons Basic or the much improved TSB (Tuned Simons Basic). How can you ignore that?
Robin ignores a lot of stuff, such as Vision BASIC. Not sure why.
I guess it's not retro enough (anymore)...
Just kidding...
Maybe it'll be here sooner or later.
Not everyone is having REU to run Vision Basic on real HW (fact that could reduce audience, but also make people get REU and start with Vision Basic)
But then, I assume most of us are just using VICE or other emulators and REU is suddenly not a problem.
TSB, that's some nice piece of good entertainment.
Yes, I would love to see both on this channel too.
Robin is always having good ideas 💡 and I am sure he'll come up with something (again, sooner or later)...
We, RetroPeople, are mostly used to waiting, just to bad life isn't eternal 😁
The best thing about TSB (Tuned Simons Basic) is that the developer is still working on it and making fixes and improvements. He is a very nice guy from Germany who likes to help and explain things.
23:50 it’s an LFSR, the feedback loops needs something to feed back. All zeros won’t XOR to something other than themself. Hence getting stuck.
If you use the correct number and location of the TAPs (which commodore BASIC does) you can generally avoid the stuck in all 1s state.
33:35 that would make a good band name
Hare Basic RND is 16-bit "798" Xorshift (by George Marsaglia, John Metcalf, Veikko Sariola) from codebase64. The algo outputs numbers in the range $0001-$ffff, and stalls if the seed if set to $0000.
Hare takes the number and EOR's it by $ffff to get numbers in the range $0000-$fffe, which is more handy: The programmer can then extract smaller ranges by doing an AND with a (power-of-two - 1), ie. 3, 7, 15, 31, 63, etc. (The point being in these smaller ranges we usually want to include 0.)
Hare also checks if someone has accidentally (or on purpose) set the seed in memory to zero, and turns it to $0001. Takes a few extra cycles, but guarantees that the RND won't stall even if tampered with :)
CBM BASIC random is very slow... What is in Hare I believe is sufficiently good, and speed is a plus! If non-deterministic randomness is needed, the output could be EOR'd with CIA timer low byte or user joystick inputs, or a dummy random number could be created every frame in the game loop, etc.
I get it! The Tortoise and the Hare. Bunny Basic was obviously the first hop in that direction.
12:35 "R is the base register" but I don't see any use of it. Even more, I removed both occurrences of it (on Vice emulator) and the "Balloons" program seems to work just the same !
Looks like you're right; that must have been leftover code from when this example was being developed and I didn't notice it wasn't being used. Good catch!
It would be nice to see a Pac-man game written in this Basic.
33:05 - this is super cool!
Unusual and cool concept. I have regards for very simplified BASICs ( like subset of V2), exactly because it may run much faster (having , for example, static string handling and purely integer arithmetic). But even more important - it might be easier to create a very efficient compiler for such little BASIC! So, next very good step for this Hare project might be producing neat compiler, that gives small and even faster machine code! And so we can have everything, the best of all worlds! Why shouldn't we? :)
One more thing I noticed - AMOS Basic for Amiga has some small and very fast internal BASIC interpreter called AMAL (animation language), executed from AMOS strings. Something like this existed in Oasis Lightning BASIC/Forth for C64, I think it was also called AMAL. This Hare thing reminds me on that concept, just using regular BASIC listing for the code.
The main things that need to be optimized in Commodore BASIC are to use addresses instead of or in addition to line numbers in GOTOs, etc.; to use addresses instead of names for variable references; to use tokenized binary representations of numbers instead of parsing them at runtime; and to have a special, optimized representation of binary numbers 0-65535 in the floating-point encoding, such as with exponent = $00. Use these integers directly for simple operations like reference and addition, and convert them to general floating point for non-trivial operations or integer overflows.
Has anyone gotten this to work on the vic20 (VICE)? It seems to just lock up on the SYS40960.
You'll need to enable all RAM expansion on it, I think. The extra 3K and all four 8K banks for +35K RAM, 40K total.
If you mean TheVIC20 "maxi" then I think rename the file to something like HareBasic_35k.d64 and it should work. Check the manual for TheC64 / TheVIC20 if that doesn't work.
@@8_Bit Yes, thanks. 35K flag works. Put it in a cjm file,"X:vic,pal,fullheight,35k".
Very Nice!
Might I recommend a slight change to the fire button for your game - have it cancel the current shot as well. I noticed a bullet travelling all the way to the top of the screen on a clear column can take a bit. A cancel button would let you abort that shot and perhaps avoid imminent doom. Sorry if it already works like that - I couldn't tell :-)
I'd do power-ups like wizball style, giving you the features of the fire button like single-step, auto-fire and so on...
If only I had tools like this available when I was coding BASIC on my C64 back when I was a kid... :)
I'm amazed it's that fast from an interpreter, I expected it to compile the code first. He should make a compiler too, although not sure if it could be that much faster. If only this was around back in the day.
Your voice is healing
Super interesting video to watch, as always. I would have loved if C=ommodore had optimized C128 basic a bit, with true fast integers variables and other possible small things
Yeah, they really focused on adding loads of features to C128 BASIC, but didn't seem to look at optimization at all. Except of course many of the new commands did speed things up by eliminating many POKEs in certain programs. But yes, true integers would have been great.
Wow! That's a bit of a coincidence!
I started writing a simplified (only 16-bit integer maths and limited string handling) BASIC compiler on the BBC Micro, with a syntax intentionally compatible enough to allow code to be entered in the existing BASIC editor and run in its interpreter. It compiled to an intermediate code for a dedicated virtual machine designed "in parallel" with the language; for instance, FOR and NEXT had their own single opcodes in the VM. Long variable names were supported, too; as, once the symbol table has been built up, variable names only need to be searched for at compile time, as reading a variable's value gets translated to a fixed-location memory read based on wherever the variable actually is stored. The VM was basically stack-based, but with an optimisation to save a stack push and pull when a value was specified as a right-side operand. Each instruction could potentially exist in three addressing modes: Stack (ADD on its own adds the top two numbers on the stack and leaves the total on top of the stack), Immediate (USE #&0123 places &0123 on top of the stack) or Memory (SUB &0404 subtracts the contents of address &0404 from the number on top of the stack and leaves the difference where it was). USE #&0004 places &0004 on top of the stack, USE &0424 places the contents of address &0424 on top of the stack, GET takes an operand or the value on top of the stack and places the contents of that location on top of the stack, PUT takes a value as an immediate operand, memory address or from the stack; an address from the stack; and stores the value there. PAF does the same but the other way around, Address First, for situations where the operands naturally fall that way round.
It needs some more instructions adding to the VM, and I need to do more work on the instruction parser, but I think I might pick it up again now there's obviously a bit of competition in town!
Forth ? HP RPL ?
This programming style would have driven my computer science teacher MAD back in the 80s at school. He would call this "spaghetti code". We even weren't allowed to use Basic but had to use Turbo Pascal instead. It is still fun to watch but comes from a time when only ONE person in the world had to understand the code and - be honest - couldn't change a thing after a while because the code is simply unreadable. But a part of me still loves it.
Can you imagine releasing a programming language and same day someone makes a game for it
9:50 so it's like turbobasic on Atari XL
Where it's effectively a ram resident patch for the normal basic in ROM....
Replacing the inefficient stock basic routines and adding extra features
I was thinking about buying two of those Hyperkin Atari joysticks. Are they as good as the original CX40's? Cheers from Ottawa!
I really like them, yeah. They're a lot like CX40s but a bit more comfortable, have a longer cord (almost too long), and seem to be a bit better constructed. So yeah, I recommend them especially if the price is still reasonable like when I bought mine a few years ago.
@@8_Bit I agree, I bought mine after seeing Robin's a few years ago and it's served me well. They work on a bunch of systems which is great, just like the original Atari joysticks.
Not sure how it would slow things down, but with a little adjustment to the character set, you might design some mean looking little faces for the lowest or leading block of each column, and they look meaner as they get closer. Also instead of "Game Over" I would suggest "Thou Art Doomed" or something in keeping with the theme.
So if this is Hare Basic, does that mean the standard is Tortoise Basic?
The tortoise beat the hare, though.
It would sure be nice to see a comparison of modern Commodore languages. Vision Basic is my current favorite. Yes, you need a VICE emulator or a REU to program with it, but it is blazing fast and can compile stand-alone programs that can run on a stock C64.
Don't hold your breath waiting. Robin is purposely staying away from Vision BASIC for some reason. Thankfully, there are other TH-camrs willing to cover it.
@@endwigast5212 I am just learning Vision Basic. I was able to create a fairly fast one line maze :
10 R=RND AND 1:ADD R=R+205:?CHR R; DO 10,920
Short and fast, although I am sure that Vision can go faster. I hope Robin will get around to covering it, he is a fantastic teacher and his explanation of how it works would be fantastic I am sure.
Scary: The TH-cam algorithm suggested as the next video: "Solution 42" - a 4k C64 demo which mentions the 2023 screen address thing! 🙀
I didn't know about Solution 42 until yesterday when a commenter mentioned it, so I watched it and left a comment on that video. That coincidence alone amazed me! Is that enough to make the algorithm suggest that video as related??
Here’s an Idea for “Descending Doom” scoring: Have the game award more points for blocks that are destroyed in higher rows. I think this will incentivize players to take more risky actions and make it more challenging. ( of course I realize you don’t current keep score so you’d have to do that too… maybe eliminate the top row )
A subtle indication the row is about to drop much also be worth it to develop.
I'm looking at the random number benchmark sample and it doesn't seem entirely fair. Basic has to define the range 0-65534 and that is Hare's RND default code. If you specify a range like A=AAND255 then it's about three times slower. If you add a function like PRINTA; then it becomes only about twice as fast as BASIC.
True. Here's a coin toss benchmark, perhaps a bit more fair:
0 printchr$(147)"coin toss rnd benchmark"
1 ti$="000000":a=usr(3):h=ti
2 ti$="000000":gosub5:c=ti:goto100
3 n=0:fori=1to1000:rnd:a=aand1:ifa=1thenn+
4 next:print"hare got"n"tails":return
5 n=0:fori=1to1000:ifrnd(1)
Neat stuff for sure! It really does seem zippity fast,!
That's a really compelling BASIC, and looks like it would be fun to create with. Maybe I'll take it for a spin and implement Conway's Game of Life, see how much faster it would be. I looked at the PDF and see that instead of arrays, you just peek/poke memory. The GO4/GO5 you showed makes me think that maybe smooth vertical scrolling would be possible?
Yes, I wonder if fast (max) 256 element arrays could be implemented in Hare Basic somehow, with it being up to the user to reserve the memory. And yes, I think smooth scrolling could be achieved with GO4/5, maybe not a rock solid 50 Hz (or especially) 60 Hz, but even with a frame stutter here or there it would be way better than CBM BASIC.
I, too, almost got lost in the thought of living after video memory (of the c64)
Of course a CNCD member creates a blazingly fast BASIC thing. Those demoscene people are usually pretty hardcore optimizers, whether it's code, graphics or music :)
Hey, Robin, you may have missed a good opportunity to make that "2023" video... _on time..._ but I'd still really love to see what you would do with that anyway! Late is still better than none in many cases, right? Please make that; I guarantee you that I'll watch it!
To be honest, I would have been all over a game like this back in the day for my old TRS-80
I'd love to play a game like that on Atari 2600.
Maybe something based on Centipede. But with no centipedes. Just more and more mushrooms, descending upon you.
Some time ago I ran into "Vision Basic". This s a paid program, but you get a nice paper manual with it. It will need a REU (in future versions possibly also GEORAM would do). It works on VICE in case you don't have a real C64 with a REU.
I wonder how your game would do with that?
From my experience you can load a classic basic program - and like here you also need to take few adjustments [ "clr" the vars at start ]. Like here there are some math-quirks, like doing math as a 1$ calculator ==> 2+2*2 gives 8.
What I love most is : You have quite extended command set and you can mix assembly code with Basic.
I actually bought Vision BASIC and used it a bit, but I really wasn't hugely into it. I started doing assembly programming on the C64 at the same time and that gives you so much more power and flexibility. I was really disappointed with some of the limitations in Vision BASIC, like no floating point numbers. A lot of the actual stuff I write for these computer is often engineering or science related and so no floating point is a deal-breaker. I did want to support him though, and I know he's about to release a v2.0 (not sure if existing owners will get an upgrade for free or discounted price?).
1336 views. I just had to watch it immediately. 😁
This game seems genuinely promising! What it needs is music. Since I've leraned that SID samples are usually block based rather than samples (courser building stones, but thematically re-usable), why not collaborate with this developer and provide music which gets gets progressively more ominous the further the wall of Doom descend on the player? Im not saying it's as easy as pitch shifting continuously, but maybe certain raster lines could provide trigger points to switching over to more sinister chord progressions? Just spitballing here.
You could obviate the need for that string of "IFC=0THEN…"/"IFC=1THEN…" lines with judicious use of GOTOs
This is a very interesting and novel concept: high level and mid level basic interpreters working together. I fear, however, that it will have less impact than it would have if it came some years ago. Nowadays it will undoubtedly be compared to languages such as XC=Basic (3.1 already) and Vision Basic, which are much more powerful AND compile to significantly faster stand alone code AND can easily integrate machine language routines.
Your words are falling on deaf ears. Robin won't ever review Vision BASIC, probably because it costs money.
Hi Robin. Thanks for the video. Have you tried Vision Basic yet?
I haven't. I did sort-of consider buying it when it was on sale a while ago but the high cost of shipping to Canada put me off again. I think I read a newer version is coming out in a while, maybe I'll look at it then. Hare Basic appealed to me because 1) it's written by someone I've respected for many years 2) it's free 3) it's light-weight 4) it's very effective 5) it was really easy to learn 6) it co-exists with CBM BASIC really nicely 7) it works on VIC-20 and C64 8) it has no extra requirements (beyond extra RAM on VIC-20 which I already have)
@@8_Bit Great points. I decided to bite the bullet and yes the shipping to Australia was crazy. Once again thanks for the great video.
Bit of an offtopic comment I'm afraid but how on earth have you kept your C64 so clean and neat? Mine is all yellowed with age! It still functions though, as do both of my original ZX Spectrum computers I still have from when I was a kid in the 1980s. Wonderfully durable machines, despite their cheap production costs back then!
Besides cleaning it occasionally, I haven't done anything special with it. Might mostly be luck of the draw; the yellowing of the plastic apparently depends quite a bit on the mix of chemicals used and this 64 case must have been made on a day when they had the mix perfect.
Ah gotcha! Thanks for the info, and great video on Hare Basic too, very interesting
Video idea: There is a way to upload code to the 1541 floppy and execute it, then get back the results to the C64. I dimly remember seeing that used to speed up calculating fractals. And i'm pretty sure a disk copy program used that so you can duplicate between two floppy drives while using the C64 for something else.
Maybe you could go into details how that works?
It would be interesting to see where Hare Basic fits into Noel's Retro Lab's bench marking spreadsheet. Search for his video "Is this the FASTEST and CHEAPEST 8-Bit Computer Ever?" and see the link in the video description "BASIC benchmarck page". The simple basic code is in the "BASIC benchmark" tab.
10 FOR i=1 TO 10
20 s=0
30 FOR j=1 TO 1000
40 s=s+j
50 NEXT j
60 PRINT ".";
70 NEXT i
80 PRINT s
CBM basic does it in 40 seconds. VIC20 in 37 seconds.
Interesting!
Very impressive work!
"I think it's cool and that's all that matters" :) absolutely, your channel your rules but I have to say you're not the only one that thinks it's cool!
So we're in the 16 bits of unused space... that explains a lot about the world today. I guess we only have until 2040 before we'll overwrite the sprite pointers and the universe will vanish? :D
So I'm assuming this can't run on SuperCPU since this is a different kernel and SuperCPU has its own ?
I haven't tested it on my real SuperCPU but it works fine on the VICE SuperCPU emulator. Hare Basic just patches various BASIC/C64 vectors as far as I know, so it's compatible with SuperCPU and probably other well-behaved peripherals.
The graphics I imagine is oozing, dripping bacterial void.
You should probably check E for an underflow condition in line 400. Yes, the game will most certainly have been lost before E wraps around, but you never know! 😉
No labyrinth oneliner demo?
I couldn't help but think the winning screen should have said "You Are Winner!" in reference to "Big Rigs: Over the Road Racing"
Edit, it actually says "You're Winner!"
OK, what error message would we get in Hare if we try to assign a reserved variable, like zee, let's say?
Hello, is there any emulator in Windows or Linux for people that don't have the Commodore hardware?
Yes, look up VICE Emulator, it's very good.
0:47 reminds me more of Phoenix
So the reason you put quotation marks around "repurposed" is that "go" really isn't a command in the 64; only in the 128 in 128 mode and the 65 in 65 mode? Or is there a different reason you used quotes; and if so, then what is that? And what would this be like if you ran it in 128 mode? Will you try to compile a video of odd experiments you can try with this? Like... try making a BASIC program that used all originally Commodore-compatible commands and tokens (so you won't get a syntax error, etc. when you try what I'm about to say next), and then run it on both Hare and pure Commodore (so run it again without loading Hare).
I'd really like to see you do a video on Simons Basic.
Robin ignores a lot of stuff, such as Vision BASIC. So don't hold your breath waiting.
Sorry the website is in DK = Denmark. I suspect the guy is Danish :)
I would have thought Paddles would be a better controller for that sort of game. Just my $0.02
You should have the the button cause a bomb that blows up a radius around the ship.
What a great concept. This could be used in university courses as a precursor tutorial to machine language. We used SPIM (MIPS simulation), why not use VICE with Hare BASIC then TMP in such subjects? Much more intuitive.
You didn't credit yourself in the main game screen. And what's that imposter font at 45:15? ;)
Great game concept too. A power-up element might be a fun addition.
Hah, I've been using that low-rent font occasionally in videos for a few months now, and I think you may be the first to comment on it :)
Power-ups could be fun. Maybe a special block could occasionally show up on screen for a moment.
I can see the potential for lots of variation in this one.
i remember playing something similar to your game on a "brick game" which were popular in former eastern bloc countries.
It's quite logical that a BASIC interpreter that uses only integers is faster than CBM BASIC V2, which uses floating-point arithmetic throughout. Similar to the speed of AppleSoft BASIC vs. Integer BASIC on the Apple II.
Hey that multiply of b in your program must be slow - could just bit shift the 1 or 0 left.
What, no 10print comparison?