Login
Back to forumReply to this topicGo to last reply

Posted By

George
on 2020-12-22
12:39:52
 Optimize assembly function-call from BASIC

Hi all,

The BASIC-Funktion draw1,x1,y1 to x2,y2 is quite fast.

I tried another way to call an assembly linedrawing-function from BASIC and found out, thats slower. I suppose it has do with the calling it from BASIC. Is there any way to make this BASIC-Code faster?

10 GRAPHIC 1,1
20 if a=0 then a=1: load"p4line",8,1:
22 for i=0 to 199
25 x1=10:y1=i:x2=50:y2=i: gosub 100
30 SYS 20486 : Rem Linedrawing function.
40 next
50 end
100 poke 20481,x1:poke 20482,y1:poke 20484,x2:poke 20485,y2:return : REM Setting x1,y1,x2,y2

Posted By

Csabo
on 2020-12-22
14:14:21
 Re: Optimize assembly function-call from BASIC

The GOSUB/RETURN slows down the code a lot and it's unnecessary. The more numbers there are in the POKEs, the slower the execution. You'd be best off using 4 zeropage variables that BASIC doesn't mind, e.g. $58-$5B (but don't quote me on those exact addresses). Your code then becomes POKE88,x1:POKE89,y1... etc.

But probably the best solution is to have the ML code load the values of those variables straight from where they are in the memory. Change x1 to something like "A%", so that the values will be stored as 16 bit numbers, and this way there would be no need for POKEs at all.

Posted By

George
on 2020-12-22
17:10:26
 Re: Optimize assembly function-call from BASIC

i understand.

I would go over the pointer where the BASIC Variables area starts ($2D,$2E) and read the specific 2 bytes of the variable (SVS-MAP helped!)



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024