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!
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.
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.
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.
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.
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 ...
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.
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 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.
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 :-)
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.
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
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.
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.
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.
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.
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.
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.
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.
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
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.
"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!
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.
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 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.
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.
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'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.
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
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.
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.
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 :)
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??
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?
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?).
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.
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.
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! 😉
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!
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.
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
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.
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!
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!
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!"
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.
This looks and feels something like "high-level assembly" to me. The ability to use both vanilla and Hare Basic in the same program is certainly a good idea. Hare Basic somewhat reminds me the old and forgotten G-Pascal, in the sense it doesn't support real variables (but otherwise G-Pascal makes way less compromises, and it's compiled). Just out of curiosity, I did a few tests and it seems G-Pascal is about two times faster than Hare Basic, which is a great score for Hare Basic, considering it is interpreted. If the program uses Go System Calls extensively Hare Basic is about ten times faster - but I don't think this is a fair comparison since using Go System Calls basically means you run ML code, plus you can't use Go System Calls to do anything you want.
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.
I'm surprised you didn't do RND, then do B=AAND128 rather than setting the 1 bit and multiplying by 128, which has to be a relatively slow routine compared to a simple AND. Assuming that all the bits in the RND are equally capable of being 1 or 0 of course, but they should be.
Most of the watchers and readers here already know this, just to grumble a bit: The 5-6-7 byte long floating point numbers C64 used for number storage and calculations killed the speed of C64 BASIC for most of the functions. Just check out the sprite movements, imagine C64 with factual integer position storage and calcuations with integers could do very similar speed. Compared to IEEE754 (used on PCs in C compilers) "C64 has 32 bits in the mantissa; IEEE 754 has 23.". Hopefully you see how much it was not necessary on C64. Extra 9 bits for mantissa, maybe they want to for to the Moon with C64? It ate the memory, it killed the CPU time As as there is no real integer calculation, everything is calculated back and front to float, made it pretty slow, and there is no way (except using a BASIC compiler) to have real (!) integer number arithmetics. And they did the same for Plus/4 too. Worst of all: there was no possibility to add an FPU into the C64 next to the CPU, like the Intel 8087 :-)
It makes me wonder if there is an equivalent for Color Basic. The CoCo seems to get left in the dust. I get that the C64 is just far superior to the CoCo, but it's what I grew up with. Specifically, the CoCo2. It wasn't even the CoCo3.
My friend Ken on the channel Canadian Retro Things is very knowledgeable about the CoCo, you might want to check with him to see if he knows of anything similar.
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)
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!
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.
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.
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.
The documentation really captures the retro feel - it just needs to be photocopied a few times to really get that look heh.
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.
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.
You should have called your game "DoomScrolling"
That's occupied already (for the PETSCII domain).… ;-)
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.
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.
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
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.
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 :-)
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
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.
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
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?
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.
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.
"It's Tetris - but with a military touch" - The New York Times
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.
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.
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.
Wow! That is a very elegant approach to integrate a lightning speed basic within commodore basic. I wish it supported the PET/CBM!
I think it'd be pretty cool if the descending lines were actually dripping slime, or something. :)
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.
Whenever I see a new 8-Bit Show and Tell video appear it makes me feel happy!
Thank you, I’m creating a BASIC game and can use this. I really enjoy your videos.
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.
Wow a 60FPS clear screen! Will wonders never cease!
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
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.
It would be nice to see a Pac-man game written in this Basic.
1336 views. I just had to watch it immediately. 😁
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.
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 get it! The Tortoise and the Hare. Bunny Basic was obviously the first hop in that direction.
If only I had tools like this available when I was coding BASIC on my C64 back when I was a kid... :)
I'd do power-ups like wizball style, giving you the features of the fire button like single-step, auto-fire and so on...
"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!
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.
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.
It's like shooting down the spikes at the end of a Tempest level :)
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.
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.
Amazing Video Robin! We want more Hare Basic games/tutorials!
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'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)
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
Very interesting! THANK YOU!
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, too, almost got lost in the thought of living after video memory (of the c64)
Thanks for such a great video and a simple but fun game!!
Sorry the website is in DK = Denmark. I suspect the guy is Danish :)
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.
To be honest, I would have been all over a game like this back in the day for my old TRS-80
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 :)
You could obviate the need for that string of "IFC=0THEN…"/"IFC=1THEN…" lines with judicious use of GOTOs
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??
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?
Can you imagine releasing a programming language and same day someone makes a game for 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?).
Very Nice!
I would have thought Paddles would be a better controller for that sort of game. Just my $0.02
33:05 - this is super cool!
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.
So if this is Hare Basic, does that mean the standard is Tortoise Basic?
The tortoise beat the hare, though.
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.
Neat stuff for sure! It really does seem zippity fast,!
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! 😉
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!
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.
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
Your voice is healing
i remember playing something similar to your game on a "brick game" which were popular in former eastern bloc countries.
The graphics I imagine is oozing, dripping bacterial void.
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".
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!
You should have the the button cause a bomb that blows up a radius around the ship.
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 ?
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!"
0:47 reminds me more of Phoenix
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.
This looks and feels something like "high-level assembly" to me. The ability to use both vanilla and Hare Basic in the same program is certainly a good idea.
Hare Basic somewhat reminds me the old and forgotten G-Pascal, in the sense it doesn't support real variables (but otherwise G-Pascal makes way less compromises, and it's compiled). Just out of curiosity, I did a few tests and it seems G-Pascal is about two times faster than Hare Basic, which is a great score for Hare Basic, considering it is interpreted. If the program uses Go System Calls extensively Hare Basic is about ten times faster - but I don't think this is a fair comparison since using Go System Calls basically means you run ML code, plus you can't use Go System Calls to do anything you want.
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
I'm surprised you didn't do RND, then do B=AAND128 rather than setting the 1 bit and multiplying by 128, which has to be a relatively slow routine compared to a simple AND. Assuming that all the bits in the RND are equally capable of being 1 or 0 of course, but they should be.
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.
Most of the watchers and readers here already know this, just to grumble a bit:
The 5-6-7 byte long floating point numbers C64 used for number storage and calculations killed the speed of C64 BASIC for most of the functions. Just check out the sprite movements, imagine C64 with factual integer position storage and calcuations with integers could do very similar speed.
Compared to IEEE754 (used on PCs in C compilers) "C64 has 32 bits in the mantissa; IEEE 754 has 23.".
Hopefully you see how much it was not necessary on C64. Extra 9 bits for mantissa, maybe they want to for to the Moon with C64? It ate the memory, it killed the CPU time
As as there is no real integer calculation, everything is calculated back and front to float, made it pretty slow, and there is no way (except using a BASIC compiler) to have real (!) integer number arithmetics. And they did the same for Plus/4 too.
Worst of all: there was no possibility to add an FPU into the C64 next to the CPU, like the Intel 8087 :-)
It makes me wonder if there is an equivalent for Color Basic. The CoCo seems to get left in the dust. I get that the C64 is just far superior to the CoCo, but it's what I grew up with. Specifically, the CoCo2. It wasn't even the CoCo3.
My friend Ken on the channel Canadian Retro Things is very knowledgeable about the CoCo, you might want to check with him to see if he knows of anything similar.
That might make a good VT100 game.
Interesting!
OK, what error message would we get in Hare if we try to assign a reserved variable, like zee, let's say?
No labyrinth oneliner demo?
Microsoft Basic, but there's a JIT compiler.
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.
Game is pretty much Tapper on steroids 😊
You should dig into the code a bit on this to tell everyone how it works