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