10 ti$="000000": for i=1 to 90000: if i%>0 then print "ciao" 20 next 30 print ti$
I obtain 7:15, while the same program but with the variable "iz" instead of "i%", the time is 7:13. IMO the reason of the anomalies you discovered, is that math operations are managed by O.S. always as FP. The integers are converted into FP, then back into integer. In the above program there is no math operation (only comparison), while in RKSoft' one yes (i%=i%+1).
Re: BASIC Balloon Breaker My bad, it was a quick reaction, Csabo is absolutely right on most issues. However, it should be noted that although indeed "I1" vs. "I%" is a more fair comparison due to the parsing but as a real life example we should test against a single character variable since it is not possible using forced integers otherwise, so that is the overhead the whole thing comes with, i.e. it should be faster even with this overhead. Well it turns out it's not I just checked the C64 in VICE with separate 4 liners and I obtained this: 6169 (float) 6583 (int) Well, now I recall I used to have learned this trick on the TRS-80 (HT1080Z for the Hungarian folks) where it did speed things up a lot, but that's an entirely different implementation of Microsoft's BASIC.
Re: BASIC Balloon Breaker I pointed this out to Gaia in a PM, I didn't think it's worth cluttering the forum with it... But since you brought it up
First complaint: posting this huge screenshot is bad form, takes up too much space and can't be copy/pasted from.
Second: That's only half the reason (GOTO 60 is slower than GOTO 20 due to the number of lines before it), and you're still wrong. Your example suffers from a similar problem. As it is, the 2nd loop consistently takes about ~6180. However, if you run the two tests as two completely separate 3-line programs (as it should be), it consistently takes about ~6080. So you're unfairly adding about 100 to the speed. (I suspect it's because I% happens to be the 2nd variable that has been allocated, so it takes longer to find it, but don't quote me on that. My point still stands regardless of the cause.)
And finally, the other half of the problem is that the interpreter takes longer to parse the "I%" variable name than "I", since it's a whole byte longer. A more fair comparison would be "I1" vs. "I%", so both variable names are two characters/bytes.
The results are still the same in the end, the "%" variable is slower, but by less than both of your examples. Which is kinda weird, I also assumed that the integer variable would be faster, but not in this case.
Re: BASIC Balloon Breaker @Gaia var with % ist definitive slower than without the %. And your example is not exact because you use goto statement and the 2.part of your code needs more time for that goto . Here is my example:
Re: BASIC Balloon Breaker Yeah, thanks Gaia for the test, it was smarter then me, I tried to compare the final copy routine speed on screen by checking the drawing performance with my bare eyes. (hehe) Anyhow, your finding fits to my personal experience.
Maybe we should open a myth-buster topic? (next to this % issue is the DRAW routine behaviour in multicolor mode, but it could be more a bug then a myth)
There could be a part in programming section: how you can speed up your program? (the first thing comes into my mind, are the BASIC compilers, bigger but faster)
Re: BASIC Balloon Breaker I don't think that var% is faster than var.
I noticed that the IF...THEN statement is very slow in Commodore BASIC, that is why i'm using on()gosub statements. I tested different solutions for the computer AI the last 2 month and the current one is the fastest, strange. I don't know where i can optimize the code because i writing BASIC programms in Notepad++ and copy&paste to VICE. Okay, i know VICE can handle uppercase to CBM petscii but only the SHIFTed. Maybe, i can optimize the tilesets where are using uppercase instead of chr$.
And, i'm thinking about a different charset in hires like ZX Spectrum, also no multicolor. The sprites(!) looks nicier than in multicolor because they aren't so stretched. What do you think?
Re: BASIC Balloon Breaker Actually, you could be right... just tried this and the %-one was slower 10 TI$="000000" 20 I=I+1 30 IFI<10000THEN20 40 PRINTTI 50 TI$="000000" 60 J%=J%+1 70 IFJ%<10000THEN60 80 PRINTTI
Re: BASIC Balloon Breaker partially OT I recently tried this speed-up in a project, but still the FOR routine with % integers + POKEs into memory was slower, than the original DRAW routine. Strange... (so I was not really impressed by the speed of POKEs+PEEKs when combined with FOR)
Re: BASIC Balloon Breaker Really nice BASIC game, perhaps not an overstatement, that one of the nicest and fastest paced. The speed is impressive from a BASIC game but I think you could still optimize it a bit if you used forced integer arithmetic wherever possible, e.g. not using T = T + 50 but rather T%=T%+50. The BASIC interpreter can better optimize the execution this way (I seem to have some benchmarks in a magazine as well but I can't find it right now).
Re: BASIC Balloon Breaker Finally a first public beta for you. Please load the program with the parameters ,8,1 else it will be corrupt. I put a preloader, the charset and the BASIC program into one file. The start of the BASIC memory will be $2000.
Play with cursor keys and C= to jump. There is no titlescreen or an end, so after passing level 5 it will occurs an error. If someone can speed up the code please let me know. Currently, i working on a level editor for making tilebased levels.
There's no new features in this beta since the last video. But i speed up the code a little bit and changed some things in the charset (ex:arcade font).
Re: BASIC Balloon Breaker Looks, awesome already. The scrolling down of the levels look somehow very "assemblerish". However, I think the video has no hearable sfx. And again: Great achievement for it beeing purely basic. Nice work!
Re: BASIC Balloon Breaker So, the work on the game loop is final and i can show you a short preview of my hard work (the last 1 1/2 week). It has sfx at balloon breaking and bonus count after you success a room. Now, i will add the new rooms, a complete rework titlescreen and some bonus rooms.
Re: BASIC Balloon Breaker Cool, good first attempt The entire KB needs more work, I'm just not sure how to motivate people to do it.
My suggestions would be to break the individual topics into individual entries. For example, you've added stuff about simulating keystrokes, but this was already in the KB, covered in great detail and with examples: How To Simulate Keystrokes.
Also, check the forum for Defining a custom charset from BASIC. There's an old topic which has some very cool code. Yours doesn't copy the whole charset, only a quarter of it.
Re: BASIC Balloon Breaker You may add these POKEs to the Plus/4 Encyclopedia yourself. And the proper terminology is reverse not inverse. Even the keyboards have RVS ON/OFF as silk-screen printed labels.
Re: BASIC Balloon Breaker Mega thx, so i saved the following pokes into my TXT file (Tipps & Tricks for C264) ^^:
poke65287,peek(65287)and64or0:rem ...Auto-Invers on, Multicolor off, big border poke65287,peek(65287)and64or8:rem ...Auto-Invers on, Multicolor off, normal border poke65287,peek(65287)and64or16:rem ...Auto-Invers on, Multicolor on, big border poke65287,peek(65287)and64or24:rem ...Auto-Invers on, Multicolor on, normal border poke65287,peek(65287)and64or128:rem ...Auto-Invers off, Multicolor off, big border poke65287,peek(65287)and64or136:rem ...Auto-Invers off, Multicolor off, normal border poke65287,peek(65287)and64or144:rem ...Auto-Invers off, Multicolor on, big border poke65287,peek(65287)and64or152:rem ...Auto-Invers off, Multicolor on, normal border
And now, it works fine . Maybe, you can add these POKEs to Plus4World for other BASIC programmers?
Re: BASIC Balloon Breaker Sure. So, it's basically as I said above: the only bit you want to avoid changing is $40. This you can keep with the AND operator.
POKE 65287, PEEK(65287) AND 64 OR #
This is the single POKE you need. It will "save" the $40/64 bit, and let you OR any value. For multicolor ($10) + 256 chars ($80) + normal horizontal scroll value ($08), so that's $98, 152 in decimal.
Re: BASIC Balloon Breaker Ah, that's exactly what I said ($80 bit of $FF07 = 128/65287 in decimal). I just didn't understand you were asking how to do that in BASIC.
Aaaand... here we go again, this is my one big pet peeve Your POKEs actually make your game PAL only! $40 on that TED register is the PAL/NTSC bit. POKEing into that memory location and overwriting bit $40 is just wrong - do not do that under any circumstances please
"Standard value + 128"... Well, kinda, more like "current-value OR 128". Here's what do you want to from BASIC: POKE65287,PEEK(65287)OR128
Re: BASIC Balloon Breaker @Csabo I mean the use of all 256 chars in one screen, no auto invers, sorry for that misunderstanding.
It works now with the little help of Hexworxs@Forum64!
poke65287,0:rem ...Auto-Invers on, Multicolor off, big border poke65287,8:rem ...Auto-Invers on, Multicolor off, normal border poke65287,16:rem ...Auto-Invers on, Multicolor on, big border poke65287,24:rem ...Auto-Invers on, Multicolor on, normal border poke65287,128:rem ...Auto-Invers off, Multicolor off, big border poke65287,136:rem ...Auto-Invers off, Multicolor off, normal border poke65287,144:rem ...Auto-Invers off, Multicolor on, big border poke65287,152:rem ...Auto-Invers off, Multicolor on, normal border
Also, the standard value + 128! ^^ Simple, but effective.
Re: BASIC Balloon Breaker By default, you cannot do that. The $80 bit of $FF07 controls this: either you have characters 0-127 and then their inverted counterparts, or all 0-255 characters.
You probably don't need every single character inverted though, so you can probably just use the 256 character mode, and have the inverted characters drawn as they are.
(Or... you could use raster interrupts and such to get around this, but that's not possible from pure BASIC.)
Re: BASIC Balloon Breaker Beta testing will be nice. I released a first beta at 2016-08-21, see above. So, the game will be ready, yes. A release date, i don't know because i work very hard at the main loop to improve and to speed up. I know, i could not make an arcade game in BASIC with speed of machine code but i try to give my best to get the best result for a BASIC game.
I let you know when i work on the last routines. Then i know when i can release a rollup for beta testing.
Added: Btw, do anybody know how can i use a charset with 256 (0-255) per screen (also include the invers)?
Re: BASIC Balloon Breaker @Mad It is in BASIC and there isn't double buffering. For the double buffering effect, i set the new pos and then clear the old one.
Update 12.10.2016 - News about Balloon Breaker After some time, i continue my work on this game. So:
- charset reworked - no overlapping graphics! - added new tiles (floors and spikes) - see screenshot - the main game loop is only 13 rows! - i think it is fast for a BASIC game - added multiplicator for bonus - internal timer for time bonus - currently, the game is fit to 20 rooms! - all in one single file include title - except charset! - win and death animation
Re: BASIC Balloon Breaker Great! I don't know how it is in Basic but sound adds a lot to a game.. Btw, do you use double buffering for the grafix? I don't see any flickering... Nice work!
Re: BASIC Balloon Breaker @Ati Yes, but i think about compiling
@George thx i can put an insert coin so you must press 1 for 1 coin *joke
@rest thx for your comments. this motivate me
@topic So, i worked on BB these week and this is the result:
- our hero can jump, run, fall, collect balloons and killed by computer - how longer you press fire our hero jumps - changed the charset again to fix problems with my 16x16 tileset - i removed the 2UP mode - the first room/level is hardcoded to test the game (the levels will be load from disk as SEQ files)
I think about to merge the title code with the game code into one big BASIC program.
Added: So, here is the first beta of my game. Control the hero with Joystick in port 1!
Info: The programm quits when you collect all balloons or killed by the enemy!
Re: BASIC Balloon Breaker Finally, the title screen should be finish at this moment. A little menu will come if you press SPACE or fire to choose 1 or 2 player, controls (keyboard or joystick) and loading custom levels (later).
Now, i added some clouds in corner and 2 balloons. the balloons moves vertical and change their brightness. It runs fast for BASIC
@KiCHY done, it looks good and not too bright, it think
Re: BASIC Balloon Breaker Make the 5 hiscore entries darker. How does it look like if you do similar to: color1,4,0:print"HISCORE" color1,4,1:print"HISCORE" color1,4,2:print"HISCORE" color1,4,3:print"HISCORE" color1,4,4:print"HISCORE" ?
or, if 5th entry is too bright, you can stay at 4 hiscore entries only.
Re: BASIC Balloon Breaker You have a nice looking game there already RKSoft
I vote for the left title screen (blue background).
Would it be possible to add rising balloons on the title screen? Balloons would appear randomly at the bottom of the screen, rising up until they pop or disappear at the top of the screen.
Re: BASIC Balloon Breaker I agree with Kichy on the colors.
And btw... Are you really doing it with BASIC? Is C+4 Basic capable of these things? Wow. didn't know that. Good luck with finishing the game. It's looking kool already.
Re: BASIC Balloon Breaker @KiCHY I think i will compiled it with Austro or something. But, the 3. is an interesting point. First, i will make the game in BASIC and take a trip to compiler. ^^
@Litwr The game is in development, so i only own the sourcecode but the game isn't playable because its in alpha
update 2016-08-10: Now, the titlescreen is at a point that i can show you what i have done ^^
Which screen (diff. background color) is better, left or right?
Re: BASIC Balloon Breaker Are there source code available? I am ready to try it with a cross-compiler. It produces the very fast codes but its codes are big in size.
Re: BASIC Balloon Breaker Cool screenshots! I like the cute graphics
Converting to assembler: 1. Use a basic compiler the speed it up. Pro: easiest solution, compilation takes a short time only. Contra: hard to predict the final speed, needs a lot of trials to finalize. 2. Rewrite it in assembler. Pro: produces the fastest result. Con: takes the longest time. 3. Use our machine code routines with basic POKEs + SYS command. The sprite drawing, collision detection, etc. can become machine code and your basic code utilizes them.
1) Looks fantastic. You can count on me on the high-score list when it is finsished
2) did you try compilers? Some of them provides huge improvement in speed on BAISC programs. Austrospeed is definitely worth a try For Plus Comp I made the translation, but never tried out personally. I think (bsed on the documentation).,that Plus comp it better prepared to the special Plus/4 commands (GFX, Sounf), than Austrospeed.
Re: BASIC Balloon Breaker Maybe, anybody can convert it to assembler when the game is finish and/or can make music for? This would be great.
I think about a multiloader for loading levels and different charsets. What do you think? A single file game will have to limitation in levels.
@George A title screen, i will make it definitly but with another charset.
Update (translated with Google, so sorry for the translation): Preview # 3 and # 4 as a foretaste. The Preview # 4 already shows 2 different opponents, once a bird and 2 turtles. The bird will definitely come into play. Whether the turtles also come in or whether all are 2 types simultaneously, decides in the course of programming. Since the BASIC of Commodore is not the fastest, there are now 2 different ways:
only one type of enemy is the screen and the type changes depending on the level
all both are present, however, the opponents move then 3 times slower
Re: BASIC Balloon Breaker I agree with KiCHY, updates would be appreciated. BTW, as soon as I saw the pics (before reading your description), I immediately thought of "Bombjack"
BASIC Balloon Breaker I working on a new game called BASIC Balloon Breaker. It is a simple Bomb Jack clone that you must break all balloons on screen. An enemey will be following your char. The 2 screenshots shows the early preview of that game. If you want i can post news about that game here at this topic.