Search found 196 matches

by Adam James
Sun Sep 13, 2020 12:55 am
Forum: 8-bit acorn software: classic games
Topic: Vindaloo - success at last!
Replies: 29
Views: 2246

Re: Vindaloo - success at last!

Hi Adam, I've been enoying reading through this thread this morning. If you're not completely satiated by your Vindaloo adventures and are looking for more perhaps you'd be interested in its forerunner, Bugeyes? The authors of both were Kevin Blake and Jason Sobell who used to go to the same comput...
by Adam James
Mon Jul 27, 2020 10:36 am
Forum: programming
Topic: Adding a delay to loop in BASIC
Replies: 15
Views: 1058

Re: Adding a delay to loop in BASIC

Thanks people. Since each machine runs at different speeds (and co-processors can make this even worse) maybe you should start your program with a simple counter loop and see how many times you loop Maybe something like T%=TIME+200:REPEAT:LET A=A+1:UNTIL TIME>T% Now you have some rough value. Maybe ...
by Adam James
Sun Jul 26, 2020 11:36 pm
Forum: programming
Topic: Adding a delay to loop in BASIC
Replies: 15
Views: 1058

Re: Adding a delay to loop in BASIC

Thanks people. I'm finding that the one-liner is as good as any in terms of simplicity and time taken. However... That will take different amounts of time on different machines, in different weather, during different phases of the moon, when a disk is still rotating, when a network packet flies past...
by Adam James
Fri Jul 24, 2020 8:53 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

On the general question of how to optimise your original code, something worth considering is changing... Gaaaaargh! I've just realised I've got in a pickle. I was running that test on BeebEm on my PC and it's the old version of the code, before I shifted the main loop to the start to speed up the ...
by Adam James
Fri Jul 24, 2020 8:42 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

replacing the AND s with IF s: To optimise it further ensure that the first condition you test is the one most likely to fail, so the rest of the line can be abandoned as soon as possible. Excellent! My timings from my test set-up (ratios is all that matters): Original: 1170 Goto: 1129 Two Gotos: 1...
by Adam James
Fri Jul 24, 2020 7:26 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

If speed was that important to me (which has been very rare) I would almost certainly have used something other than interpreted BASIC, as least for the time-critical parts of the program. I think that's changing the boundaries in order to fit a world-view. In the same way you told Lardo Boffin you...
by Adam James
Fri Jul 24, 2020 6:40 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

As has been noted, the use of GOTO (or an equivalent) is unavoidable in many programming languages, or even if it is avoidable it may have advantages which I haven't found to apply in BBC BASIC. I don't know if you missed my earlier question, but I'm wondering if the example I gave at the start is ...
by Adam James
Fri Jul 24, 2020 6:35 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

I'm stunned at just how many optimisations I've been able to perform on the main loop of this code. I suppose that says a lot about how poor it was in the first place :oops: . The latest optimisation was actually obvious, and more to do with poor thought in the first place. I was doing things like c...
by Adam James
Fri Jul 24, 2020 4:00 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

BigEd wrote:
Fri Jul 24, 2020 3:55 pm
I think it's best used sparingly: when it seems an advantage to use it, and knowing how it might have been avoided.
That's exactly where I am at currently, based on this recent experience, but am open to persuasion.
by Adam James
Fri Jul 24, 2020 3:53 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

I have yet to be persuaded, after nearly 40 years, that there is ever any good reason to use GOTO. Not even for the speed optimisation in this case? I'll go back to my original question: is it justified, or is there a better way? And add: even if it is justified and there is no better way, is it so...
by Adam James
Fri Jul 24, 2020 3:41 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

Exactly - this is a key point, GOTO in BBC BASIC is potentially very slow. Because it's deprecated (there are always alternatives, whatever some people may say) it's not optimised: it works by searching the program line-by-line, linearly, from the beginning every time. There are no shortcuts like c...
by Adam James
Fri Jul 24, 2020 2:49 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

I think it must be true that the larger your program is, the slower GOTO will be - so you had a better chance of a speedup because your program is small. (I don't know if GOTO targets are searched for from the present line or from the start of the program.) At the same time, try to keep the main sp...
by Adam James
Fri Jul 24, 2020 2:05 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

I think it must be true that the larger your program is, the slower GOTO will be - so you had a better chance of a speedup because your program is small. (I don't know if GOTO targets are searched for from the present line or from the start of the program.) I think removing the THEN might be a litt...
by Adam James
Fri Jul 24, 2020 1:54 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

Of course it is justified, it's a legal basic command :mrgreen: The IF statement in BBC (and also Atom) BASIC has the limitation that you cannot use a block of code just like other languages like C: if (condition) { .... block of statements } So if you want to optimize for speed then GOTO would be ...
by Adam James
Fri Jul 24, 2020 1:51 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

In BBC BASIC found on the 8 bit machines the use of GOTO is often mandatory and is frequently used to speed up processing. BASIC 2, for example, does not have multi-line IF ... THEN ... ELSE ..., WHILE ... ENDWHILE or CASE statements. To get round these 'deficiencies' one can use GOTO. That's good ...
by Adam James
Fri Jul 24, 2020 1:43 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Re: Is GOTO ever not evil?

I should add that I had earlier tried G%=U%>20, i.e. putting the result into another variable, and testing that variable instead in both of the IF statements. That was slower than the original.
by Adam James
Fri Jul 24, 2020 1:39 pm
Forum: programming
Topic: Is GOTO ever not evil?
Replies: 47
Views: 1872

Is GOTO ever not evil?

I've long suspected I might be the Antichrist, but last night came the strongest evidence yet. I'm learning BBC BASIC while writing a game, and yesterday was all about speed-optimising the main loop. Thanks in no small part to some great insight from others in another thread, I thought I'd reached t...
by Adam James
Fri Jul 24, 2020 12:40 pm
Forum: programming
Topic: Adding a delay to loop in BASIC
Replies: 15
Views: 1058

Re: Adding a delay to loop in BASIC

Double up the REPEAT statement to create two nested loops, and have the delay loop between two UNTIL statements: UNTIL D% followed by FORI%=0TOD%:NEXT:UNTIL 0 . That will have the inner loop execute exactly once as long as D% is bigger than 0; but once D% reaches zero, the inner loop will begin rep...
by Adam James
Thu Jul 23, 2020 10:13 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

So, instead of DIM X% (10) do DIM X% 10. Beebmaster beat me to it. I was going to suggest exactly that. I have been doing a test to see how much faster it is, which was to simply assign a value to variables in an array 1000 times. Compared to using a BASIC array, the saving with indirection operato...
by Adam James
Thu Jul 23, 2020 9:07 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

Instead of making an array with DIM, reserve some space instead. So, instead of DIM X% (10) do DIM X% 10. Then to refer to X%(1) or X%(10) you would use X%?1 or X%?10 to read the value, or X%(2)= becomes X%?2= etc. If any value of X% in the array is going to take up more than one byte, DIM more spa...
by Adam James
Thu Jul 23, 2020 8:45 pm
Forum: programming
Topic: Adding a delay to loop in BASIC
Replies: 15
Views: 1058

Re: Adding a delay to loop in BASIC

30 IF D%>0 THEN FOR I%=0 TO D%:NEXT It is a bit faster but I still begrudge it being there when D% is zero! This might be a tiny bit faster - and removed the spaces as that does help for speed... 30IFD%THENFORI%=0TOD%:NEXT Basically (no pun intended), I've removed the >0 check, so it's true if D% i...
by Adam James
Thu Jul 23, 2020 8:14 pm
Forum: programming
Topic: Adding a delay to loop in BASIC
Replies: 15
Views: 1058

Adding a delay to loop in BASIC

I want to have a game get gradually faster, so I tried something like: 10 D%=100 20 REPEAT 30 FOR I%=0 TO D%:NEXT (game logic) 90 UNTIL0 It works fine, however I'd really like it to be as fast as possible when D% gets down to zero, having just spent most of the morning optimising my main loop for sp...
by Adam James
Thu Jul 23, 2020 7:49 pm
Forum: 8-bit acorn software: classic games
Topic: Vindaloo - success at last!
Replies: 29
Views: 2246

Re: Vindaloo - success at last!

Decided it would be useful to display the level title when selecting with cursor keys, so added that :) Then thought it would be good if you didn't need to find somewhere to die before switching level, so D when paused will draw the (new) level Just spotted this now! More amazing stuff. Thank you:)...
by Adam James
Thu Jul 23, 2020 6:31 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

Some insight into the optimisations I tried, according to my notes. All numbers are percentage reductions in time taken for an average cycle of the main loop. I set it up to have 4 poles always in the same starting position, hitting the bottom 10 times. Changing a "*.1" to a "DIV8": 4% (thanks jms2!...
by Adam James
Thu Jul 23, 2020 5:57 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

I've spent hours trying to speed-optimise this and I've learned a lot! It's also been very worthwhile - it can now handle 4 poles faster than it could 3! And not by nasty stuff like making the poles jump greater gaps at each cycle - nothing has changed there. I think even 5 poles runs at a tolerable...
by Adam James
Thu Jul 23, 2020 12:15 am
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

I have just realised that my previous comment about the VDU23 statements wasn't right - its a semicolon that's missing, not a colon. Hopefully you understood what I was trying to say! So its VDU 23,1,0;0;0;0; I figured you meant semicolon yes, as I've noticed similar VDU statements when reading aro...
by Adam James
Wed Jul 22, 2020 11:04 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

What range of values do you need to DIV8 by? store all results and index by that value. It's knowing what index to use that I'm struggling to get my head around. For the Y axis lookups, it was straightforward: every cycle, the index increases by 1 (if braking) or 2. For the X axis lookups, given th...
by Adam James
Wed Jul 22, 2020 7:24 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

I note a distinct lack of Ewoks in this game. Your observation is verifiable:) I sense I may have caused some disappointment! And that I am missing something here... on top of the absent Ewoks. That's really good, it does feel like a game! The reason for your extra beep is that your two VDU23 state...
by Adam James
Wed Jul 22, 2020 5:10 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

I've just played this on the emulator, trying to get as far as I can, since I'm now on the PC. I like how it plays with 3 poles. I got a score of over 9700 and by that point the 'absorber' is extremely wide and I had to keep the brakes slammed on constantly and keep turning constantly in one directi...
by Adam James
Wed Jul 22, 2020 4:43 pm
Forum: programming
Topic: Drawing lines - BASIC vs machine code
Replies: 48
Views: 2616

Re: Drawing lines - BASIC vs machine code

Thanks for the continued investigation people! I'm shocked to declare this thing is possibly now an actual game. I just played it, trying to get the highest score I could, and it actually played well and felt worthwhile. I certainly feel I've achieved my original aim of writing a minimalist "3D" gam...

Go to advanced search