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 > Silly Basic question
2007-11-08 14:07
johncl

Registered: Aug 2007
Posts: 37
Silly Basic question

Something I have always wondered about the "good" old Basic was that for a lot of data you had to use the DATA keyword and type lots of numbers, which you then DIM'ed array variables and read them into. Essentially you stored the data twice! As if Basic wasnt sucking up enough memory as it is.

Why didnt they allow a simple way of accessing the DATA blocks like a pointer?

And for my silly question, are all DATA number values stored as 16 bit values or what format does it have? Is there a cool way of e.g. begin your Basic code with DATA statements with assembly data and then sys this to start it? Or do you always have to READ the DATA values and then POKE them to a certain memory location which you can then SYS call to?

The reason I ask this is that I am just tinkering with a silly game on a good old PET 2001 that is programmed in Basic, and I see that I need a fast screen memory copy which I want to program in assembly (but as normal lines of basic since I want this to single load off tape).
 
... 10 posts hidden. Click here to view all posts....
 
2007-11-08 22:49
iAN CooG

Registered: May 2002
Posts: 3197
Why bothering with data/read/poke at all when you can simply link basic and binaries and crunch the linked prg? All you have to remember is to set basic pointers to avoid data being overwritten by variables and temp strings.
    *=$0801 
startbasic 
    incprg mybasicprogram.prg 
endbasic
;init routine, jmp here in linker/cruncher
    lda #$80
    sta $d020
    sta $d021
    sta $0291
    jsr $e536
    lda #$14
    sta $d018
    lda #$ea 
    sta $0328

    ldx #(dataend-datatable-1)
st  lda datatable,x
    sta $2b,x
    dex
    bpl st

    jsr $A659
    jsr $A533
    jmp $A7AE

datatable 
    word startbasic
    word endbasic
    word endbasic
    word endbasic
    word endram
    word endram
    word endram
dataend

    *=$8000
endram = *-1
    incprg mydatas.prg
    incprg myroutines.prg

    *=$c000
    incprg otherstuff.prg

or simply use
EXOMIZER sfx basic,<start>,<end>,<high> mybasicprogram.prg etcetc -o final.prg
but you have to calc the addresses manually.
2007-11-09 23:30
chancer

Registered: Apr 2003
Posts: 347
Quote: Good idea! Let's improve it.
10 POKE648,192
20 ?"<code>";
30 ...
40 POKE648,4:SYS49152
Q: Are all screen codes achievable using PRINT?


Q: Are all screen codes achievable using PRINT?

I can't imagine why not, but maybe some would cause issues, like obvious things inverted heart (clear screen) or colour codes etc. then you could just use something like print chr$ etc, if it's outside the normal range of a-z etc. if there was problems, the would get over that.

A lot of coders did used to use REM statements to code, I've seen over the years in a few interviews, Steve Turner used to on the zx80/81.

maybe I'm talking rubbish, it's been a long time since I've done any form of c64 coding.




2007-11-23 19:40
MorGorr
Account closed

Registered: May 2002
Posts: 47

Concerning the characters available via Print: Yes, you cann PRINT all characters. The fun part is that you need the <rvs on> and <rvs off> codes to do that. Thus what you need is a rountine that converts your asm bytes to a printable string. Not too difficult, and avoids any strange effects when editing or listing your Basic program.

If your asm routine is needed elsewhere than the normal screen location, you can either change the screen pointers to print it somewehere else, or make the routine copy itself to the desired location.
2007-11-23 20:40
yago

Registered: May 2002
Posts: 333
The lazy ones can use Text Magic V2.2
Although done for designing screens, you can also convert any data to printable strings.
2007-11-24 15:59
MorGorr
Account closed

Registered: May 2002
Posts: 47

Or, look e.g. at my old game "The Session" and rip the routine from there. The level editor converts the screen into printable strings and saves them to disk in that format.
Previous - 1 | 2 - Next
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
Dr. Doom/RAD
Guests online: 71
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

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