Página 1 de 1

BASIC: Localizar variable en RAM (pero YA,... rápido rápido)

NotaPublicado: Lun Ene 13, 2014 11:42 am
por Hark0
Buenas!

Quiero localizar una variable en la memoria para luego POKEARLA en tiempo real...

Usando las variables del sistema, podemos encontrar el inicio del bloque en VARS... pero claro, se va "meneando" a medida que el listado cambia y las variables se añaden/quitan...

¿Hay alguna forma rápida de encontrar la ubicación EXACTA de una variable sin tener que recurrir a leer byte a byte hasta encontrar la variable de turno (que es como lo hago ahora)?

Gracias anticipadas.

Re: BASIC: Localizar variable en RAM (pero YA,... rápido ráp

NotaPublicado: Lun Ene 13, 2014 12:25 pm
por cheveron
No. That's why it's important to have the DEF FNs at the beginning of a program. Because BASIC itself reads through the lot itself. If you are using fixed length variables then you could use an array, at which point you should be able to quickly calculate the address of any value in the array.

Re: BASIC: Localizar variable en RAM (pero YA,... rápido ráp

NotaPublicado: Lun Ene 13, 2014 12:45 pm
por Hark0
cheveron escribió:No. That's why it's important to have the DEF FNs at the beginning of a program. Because BASIC itself reads through the lot itself. If you are using fixed length variables then you could use an array, at which point you should be able to quickly calculate the address of any value in the array.


Well, Im thinking in two options:

1- Declare a DIM array variable like a$(32*16) for "Screen Buffer"... and poke him...

2- Load directly at XXXX Adress of ram the bytes for "Screen Buffer"... and poke him...

hmmm Which is faster?

1- LET a$(ypos*32+ypos)="X"

2- POKE XXXXX,X

Re: BASIC: Localizar variable en RAM (pero YA,... rápido ráp

NotaPublicado: Mie Ene 15, 2014 5:40 pm
por cheveron
Hark0 escribió:
cheveron escribió:No. That's why it's important to have the DEF FNs at the beginning of a program. Because BASIC itself reads through the lot itself. If you are using fixed length variables then you could use an array, at which point you should be able to quickly calculate the address of any value in the array.


Well, Im thinking in two options:

1- Declare a DIM array variable like a$(32*16) for "Screen Buffer"... and poke him...

2- Load directly at XXXX Adress of ram the bytes for "Screen Buffer"... and poke him...

hmmm Which is faster?

1- LET a$(ypos*32+ypos)="X"

2- POKE XXXXX,X


It sounds like you're storing the screen as a string. If that's the case then the quickest way to update it is with:

LET a$((ypos*32+ypos) TO (ypos*32+ypos)+length-1)="some string"

Certainly, printing the whole screen with PRINT AT 0,0;A$ is surprisingly fast.

Re: BASIC: Localizar variable en RAM (pero YA,... rápido ráp

NotaPublicado: Mie Ene 15, 2014 6:06 pm
por Hark0
Ops! a mistake on second use of ypor... I think.... :P

LET a$((ypos*32+xpos) TO (ypos*32+xpos)+length-1)="some string"

Its more fast than poke at VAR address directly?

Re: BASIC: Localizar variable en RAM (pero YA,... rápido ráp

NotaPublicado: Jue Ene 16, 2014 12:02 am
por cheveron
Hark0 escribió:Ops! a mistake on second use of ypor... I think.... :P

LET a$((ypos*32+xpos) TO (ypos*32+xpos)+length-1)="some string"

Its more fast than poke at VAR address directly?


For a single value POKE will be quicker, but if there are two or more consecutive bytes to change then updating the string may be quicker.

Re: BASIC: Localizar variable en RAM (pero YA,... rápido ráp

NotaPublicado: Jue Ene 16, 2014 10:46 am
por Hark0
Well, first I'm use this code to find var data pos:

LET dirvar=(PEEK 23627+256*PEEK 23628)+6

The var of "double buffer" declared with DIM are the first var declared... just I add +6 for store in dirvar the correct position of RAM.

And... I try two methods for "fill" data to variable (One char):

a) Using poke...
b) Using LET a$(y*32+x)="x"

It's take about 8.5 secs in boths methods for fill a var with 32*18 of size...


Now Im are testing another routine for fill using 2 chars for upper 32x32 sprites and 2 chars for lower...

;)