how to (easy) acces larger arrays of bytes
Closed this issue · 3 comments
Is there a way to handle arrays larger then a byte lenght (more then 256 elements).
I have a screen designed with charpad 40x25 bytes (aka a full screen).
Now with assemby i can easily copy it to the screen memory but i struggle finding a way doing it with p65pas.
Take a look at the following example code:
unit Screen1;
interface
uses Commodore64;
var
screen1: []byte = [ $61,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,
$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,
$62,$62,$62,$62,$62,$62,$62,$61,$63,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$64,
$63,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$64,$63,$40,$40,$40,$40,$42,$43,$44,
$40,$40,$40,$4B,$4C,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$4B,
$4C,$40,$40,$40,$42,$43,$44,$40,$40,$40,$40,$40,$40,$40,$40,$64,
$63,$40,$40,$40,$40,$45,$46,$47,$40,$40,$40,$4D,$4E,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$4D,$4E,$40,$40,$40,$45,$46,$47,$40,
$40,$40,$40,$40,$40,$40,$40,$64,$63,$40,$40,$40,$40,$48,$49,$4A,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$48,$49,$4A,$40,$40,$40,$40,$40,$40,$40,$96,$64,
$63,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,
$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,
$66,$66,$67,$40,$40,$40,$65,$64,$63,$41,$41,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$40,$40,$40,$41,$64,
$63,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$64,$63,$40,$96,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$64,
$63,$66,$66,$66,$67,$40,$40,$40,$96,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$4B,
$4C,$40,$40,$40,$42,$43,$44,$64,$63,$41,$41,$41,$41,$40,$40,$65,
$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$66,$67,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$4D,$4E,$40,$40,$40,$45,$46,$47,$64,
$63,$40,$40,$40,$40,$40,$40,$41,$41,$41,$41,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$40,$40,$40,$40,$40,$40,$40,$40,$40,$96,$40,$40,
$40,$40,$40,$40,$48,$49,$4A,$64,$63,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$65,$66,$66,$66,$66,$67,$40,$40,$40,$40,$40,$65,$66,$66,$64,
$63,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$41,$41,$41,$41,$41,$41,$40,
$40,$40,$40,$40,$41,$41,$41,$64,$63,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$96,$40,$40,$96,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$64,
$63,$40,$40,$40,$40,$42,$43,$44,$40,$40,$40,$4B,$4C,$40,$40,$40,
$65,$66,$66,$66,$66,$67,$40,$4B,$4C,$40,$40,$40,$42,$43,$44,$40,
$40,$40,$40,$40,$40,$40,$40,$64,$63,$40,$40,$40,$40,$45,$46,$47,
$40,$40,$40,$4D,$4E,$40,$40,$40,$41,$41,$41,$41,$41,$41,$40,$4D,
$4E,$40,$40,$40,$45,$46,$47,$40,$40,$40,$40,$40,$40,$40,$40,$64,
$63,$40,$40,$40,$40,$48,$49,$4A,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$48,$49,$4A,$40,
$40,$40,$40,$40,$40,$40,$40,$64,$63,$66,$66,$66,$66,$66,$66,$66,
$66,$66,$66,$66,$67,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$65,$66,$66,$66,$66,$66,$66,$66,$67,$40,$40,$40,$64,
$63,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$41,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$40,$40,$40,$64,$63,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,
$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$64,
$61,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,
$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,
$62,$62,$62,$62,$62,$62,$62,$61,$20,$13,$03,$0F,$12,$05,$3A,$30,
$30,$30,$30,$30,$30,$20,$20,$0C,$09,$06,$05,$3A,$97,$98,$98,$98,
$98,$98,$98,$98,$98,$98,$98,$9B,$9B,$9B,$9C,$20,$24,$24,$24,$20,
$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$02,$15,$02,
$02,$0C,$05,$04,$20,$07,$08,$0F,$13,$14,$13,$20,$20,$20,$20,$20,
$20,$20,$20,$20,$20,$20,$20,$20 ];
screen1a: pointer absolute screen1;
screen1b: pointer absolute screen1;//+$100;
screen1c: pointer absolute screen1;//+$200;
screen1d: pointer absolute $B43;//screen1+$2E8; //hacked in real adres from compiled code
screen: [1000]byte absolute $0400;
procedure drawScreen1;
implementation
procedure drawScreen1;
begin
asm
LDX #$00
DRAWSCRN:
LDA screen1a,X ;Get data from screen data file SCREEN.BIN
STA $0400,X ;Put data into SCREEN RAM
LDA screen1b,X ;Fetch the next 256 bytes of data from binary
STA $0500,X ;Store the next 256 bytes to screen
LDA screen1c,X ;... and so on
STA $0600,X
LDA screen1d,X
STA $06E8,X
INX ;Increment accumulator until 256 bytes read
BNE DRAWSCRN ;
end
end;
end.
For the last block i tried hacking in the real adres from the currently compiled code. (as a proof i could get to the correct data within the array using pointers, it works but the code would not be maintainable).
It would be easier if i could use some simple math on the absolute adres. Say screen1b: pointer absolute screen1+$100;
As an alternative i could chop up the screen array into multiple arrays, but that woould be a hassle. Even more with multiple screen in the future.
There is another bug #18 reported the about not being able to offset labels within assembly. And indeed that does not work here either.
What other ways are there for handling larger arrays of bytes? Or will there be?
Or is there already a way in the curren 0.7.8 version that i have not thought of already?
Also tried a thing like myscreenpointer := @screen1[$0100]; but that does not work. Maybe with addr i could get the correct pointer adres and if myscreenpointer := pointer($adress); existed i could use that to assign a memory adres to a pointer runtime.
i think i may have found a 'workaround'/solution:
screen1a: pointer absolute screen1[$0000];
screen1b: pointer absolute screen1[$0100];
screen1c: pointer absolute screen1[$0200];
screen1d: pointer absolute screen1[$02E8];
seems to do the job :-)
and may be even nicer then doing screen1+$0100 since it is an array.
Hi. I'm creating the new version of the compiler with support for new features., and I really want to release it , but currently, I'm busy in other projects. This is an open source project and I only work in my free time.
No need to rush. It is the same for me and i just happened to have some extra spare time for once.
And screen1a: pointer absolute screen1[$0000]; does the job just fine for what i want.
So i close this one.