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: 115
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: 645
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: 115
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: 115
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: 1310
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: 4489
why not just stuff those numbers into memory and then peek(whatever)
2019-12-02 08:57
Oswald

Registered: Apr 2002
Posts: 4489
... 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: 115
Thanks. Might try that if this fails.
2019-12-02 13:49
Krill

Registered: Apr 2002
Posts: 1310
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
Romppainen/ΤRIΛD
nucleus
Broti/DT/KRN
Joe/Wrath/EXON
Krill/Plush
Flotsam
sailor/Triad
Lubber/Padua
Ladyneutrone
r242
JEZ
icon/The Silents, Sp..
Jason Page
ZeSmasher/F4CG
TheEnemy/Excess/THD
E$G/HoKuTo FOrCE
visionvortex
Guests online: 42
Top Demos
1 Uncensored  (9.7)
2 Unboxed  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.7)
5 Comaland 100%  (9.6)
6 Lunatico  (9.6)
7 The Shores of Reflec..  (9.5)
8 Rivalry  (9.5)
9 C=Bit 18  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Instinct  (9.6)
2 Crystal Gazer  (9.6)
3 Dawnfall V1.1  (9.5)
4 Smile to the Sky  (9.5)
5 The Tuneful Eight [u..  (9.5)
6 Field Sort  (9.5)
7 Space Demo  (9.5)
8 The Tuneful Eight (U..  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Innervasion  (9.5)
Top Groups
1 Performers  (9.6)
2 Oxyron  (9.4)
3 PriorArt  (9.4)
4 Fossil  (9.4)
5 Booze Design  (9.4)
Top Organizers
1 cTrix  (10)
2 Retroluzzer  (10)
3 Burglar  (9.9)
4 Sixx  (9.9)
5 Taper  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2019
Page generated in: 0.043 sec.