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


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

Registered: May 2010
Posts: 124
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: 785
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

Registered: May 2010
Posts: 124
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

Registered: May 2010
Posts: 124
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: 1632
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: 4628
why not just stuff those numbers into memory and then peek(whatever)
2019-12-02 08:57
Oswald

Registered: Apr 2002
Posts: 4628
... 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

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

Registered: Apr 2002
Posts: 1632
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
Linus/MSL^OXY^Fossil
K-reator/CMS
Britelite/Dekadence
Jammer/TooMany
Acidchild/Padua
Krill/Plush
kbs/Pht/Lxt
Shogoon/Elysium/MSL
psych858o/MSL/Elysiu..
rikib80
Manex/Anubis
ZeHa
Guests online: 96
Top Demos
1 Coma Light 13  (9.6)
2 Uncensored  (9.6)
3 Memento Mori  (9.6)
4 Edge of Disgrace  (9.6)
5 Unboxed  (9.6)
6 Comaland 100%  (9.6)
7 Lunatico  (9.6)
8 The Shores of Reflec..  (9.5)
9 Rivalry  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Copper Booze  (9.9)
2 Quadrants  (9.6)
3 Elite Code Mechanics  (9.6)
4 Square Booze  (9.6)
5 Dawnfall V1.1  (9.5)
6 Smile to the Sky  (9.5)
7 Daah, Those Acid Pil..  (9.5)
8 Hedge of Disgrace - ..  (9.4)
9 Crystal Gazer  (9.4)
10 Instinct  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 Oxyron  (9.3)
4 PriorArt  (9.3)
5 Triad  (9.3)
Top Hardware-Gurus
1 Jope  (10)
2 Soci  (9.9)
3 Grue  (9.8)
4 Zer0-X  (9.8)
5 Lemming  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.041 sec.