I want to use a simple routine to calculate which memory address is used for a character to display on the screen at coordinates of X and Y..

Firstly, is there a rom routine for that? For example, getting 2 memory locations as input and calculating the adress by adding display memory top adress + Y*40 + X for text mode. Maybe PLOT or PRINT@ commands might use such rom routine.

If there's no preprogrammed rom routine, can you give me a simple code to do that? Adding 40*Y to a memory adress means looping Y times of 16 bits ADC adding command and this could be time consuming..

I have a game project in my mind using Basic and machine code together and trying to speed up some works with Machine code. So instead of saying : A=48040+X+Y*8 , I want to say : POKE 0,X:POKE 1,Y:CALL #1000 and get the calculated address from DEEK(2) for example. Then I will call another routine to display the characters on calculated address.

So would this code will speed up things ? Or should I keep up with basic as it might be useless?

My new code now tends to use 256 entries, with the last 56 ones pointing to an empty area with 40 unused bytes, that allows me to not even bother clipping: It will just draw garbage in some unimportant place

All calculations are done in ‘floating point’, In BASIC, numbers can be stored in either a floating-point variable (e.g., B) or an integer variable (e.g., C%). A variable such as B can contain any number up to an accuracy of nine digits, with a decimal point that ‘floats’ up and down the number. An integer variable can only contain a number between – 32768 and +32767, without a decimal point. Although in theory this would seem to be faster to process, the ROM can only manipulate numbers in floating-point form, so converts any integers that are used.

I'm not quoting the remainder of the chapter but everyone using Basic should read it. Microsoft guys were completely crazy to do this like that. I understand it was simpler for them to switch from Z80 to 6502 and to 6800 code but it's so slow !

Oh and X and Y are not integer variables. But anyway it's better to use them as the integer equivalents actually need conversion to floating point before any calculations.