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

Todo sobre la creación, diseño y programación de nuevo software para
nuestro Spectrum

Moderador: Sir Cilve Sinclair

Responder
Avatar de Usuario
Hark0
Freddy Hardest
Mensajes: 545
Registrado: Mar Nov 13, 2012 12:42 pm
Ubicación: Cornella de Llobregat - Barcelona
Contactar:

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

Mensaje por Hark0 » Lun Ene 13, 2014 10:42 am

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.
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica

Avatar de Usuario
cheveron
Manic Miner
Mensajes: 280
Registrado: Lun Jun 28, 2010 6:14 pm
Ubicación: Londres
Contactar:

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

Mensaje por cheveron » Lun Ene 13, 2014 11:25 am

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.
«Dime con quién andas, y te diré quién eres» — Cervantes

Avatar de Usuario
Hark0
Freddy Hardest
Mensajes: 545
Registrado: Mar Nov 13, 2012 12:42 pm
Ubicación: Cornella de Llobregat - Barcelona
Contactar:

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

Mensaje por Hark0 » Lun Ene 13, 2014 11:45 am

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
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica

Avatar de Usuario
cheveron
Manic Miner
Mensajes: 280
Registrado: Lun Jun 28, 2010 6:14 pm
Ubicación: Londres
Contactar:

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

Mensaje por cheveron » Mié Ene 15, 2014 4:40 pm

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.
«Dime con quién andas, y te diré quién eres» — Cervantes

Avatar de Usuario
Hark0
Freddy Hardest
Mensajes: 545
Registrado: Mar Nov 13, 2012 12:42 pm
Ubicación: Cornella de Llobregat - Barcelona
Contactar:

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

Mensaje por Hark0 » Mié Ene 15, 2014 5:06 pm

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?
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica

Avatar de Usuario
cheveron
Manic Miner
Mensajes: 280
Registrado: Lun Jun 28, 2010 6:14 pm
Ubicación: Londres
Contactar:

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

Mensaje por cheveron » Mié Ene 15, 2014 11:02 pm

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.
«Dime con quién andas, y te diré quién eres» — Cervantes

Avatar de Usuario
Hark0
Freddy Hardest
Mensajes: 545
Registrado: Mar Nov 13, 2012 12:42 pm
Ubicación: Cornella de Llobregat - Barcelona
Contactar:

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

Mensaje por Hark0 » Jue Ene 16, 2014 9:46 am

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...

;)
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica

Responder

¿Quién está conectado?

Usuarios navegando por este Foro: Ahrefs [Bot] y 7 invitados