Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Change DATA pointer READ in Basic
2019-12-01 23:42
Rudi
Account closed

Registered: May 2010
Posts: 125
Change DATA pointer READ in Basic

I want a value that I can skip by four or one (when x*4), so I can skip data lines.

Example
1000 DATA 1,2,3,4,5,6,...
1001 DATA ....
1002 ....
1004 DATA 6,5,4,3,2,1,...
...
1006 ....
...
1008 ....

(I have data lines in 3 by 3, but I separate them by line of fours, such that the beginning of each section is an even number).

So when I do a READ Q, I want to have changed the data-pointer to either 1000, 1004, 1008 or 1012, etc..
But the only way I found out to jump between these datas are by POKE 65,x and POKE 66,y, before READ Q. But those are not lines, those are addresses, and the addresses change alot because I have 27 values on each line (81 values in total for each section). POKING into 63 and 64 doesn't work here, it seems its read only and writing to these zp address does not work. Is there any way to bypass this or is there a formula to convert line number to read pointer address? Or is there another method to do this?

2019-12-02 00:07
TheRyk

Registered: Mar 2009
Posts: 2035
the idea seems quite painful
Might be $0F flag interferes. Adresses are definetely not ROM. Maybe $3f and $40 need to be manipulated too?
Did you try if Y=5:RESTORE:FORX=1TOY*4:READZ:NEXT:READA sets A to the desired value? Also not sure if I understood the structure of your DATA ^^ slightly confused by these 3s and 4s

otherwise just check out BASIC and KERNAL ROM listings, but I don't believe that you find any register for "line no. of currently read DATA"
2019-12-02 00:33
Rudi
Account closed

Registered: May 2010
Posts: 125
Thank for the reply TheRyk. The structure of my data is shown on screenshot: I have 3 lines of DATA, and each line consist of 27 values separated by commas.

In my program I want to only read 81 values from data-lines in total. But during the program I would like to read arbitrary data (not all the data, but different sections). I use the term sections for different data here. for example: instead of reading the first section: i.e. line 1000 to 1002 I would like to read 1004 to 1007 instead.

I tried using "Pointer to next DATA item for READ" ($41 and $42) but found it to be a pain, yes. Maybe I can figure a way around it by reading the first line and storing the pointer then do 16-bit arithmetic to change the pointer. Ill try that next.
2019-12-02 00:55
Rudi
Account closed

Registered: May 2010
Posts: 125
this seemed to work:
I can multiply 180 with section-number;


i will go for this method and see with time if it fails or not. (it may corrupt if peek(65)<2), but so far so good.
2019-12-02 08:32
Krill

Registered: Apr 2002
Posts: 2804
I sense an XY problem.

With the little means given by BASIC V2, what about reading all data into arrays first (so you have a random-access representation of it), then performing whatever number crunching you want on those arrays instead of the initial data lines?
2019-12-02 08:52
Oswald

Registered: Apr 2002
Posts: 5007
why not just stuff those numbers into memory and then peek(whatever)
2019-12-02 08:57
Oswald

Registered: Apr 2002
Posts: 5007
... or store the info as data strings, one string per line, then use mid$ and val to extract the numbers you need, skipping lines should be trivial in that case.
2019-12-02 10:16
Rudi
Account closed

Registered: May 2010
Posts: 125
Thanks. Might try that if this fails.
2019-12-02 13:49
Krill

Registered: Apr 2002
Posts: 2804
Yeah. Really, DATA lines are intended to be one-time sequentially imported into whatever variable types you deem sensible.

If you need delimiters, run lengths or other meta-data, you can encode them into your data values. And multi-dimensional arrays for storage exist, too. I wouldn't go for direct memory access via PEEK and POKE, though.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
JackAsser/Booze Design
hedning/G★P
algorithm
Mason/Unicess
katon/Lepsi De
Impetigo/Crescent
MCM/ONSLAUGHT
E$G/hOKUtO fOrcE
Guests online: 334
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.158 sec.