title: "AddressTable" description: TRSE built-in method (from IDE help)
AddressTable
Systems: X16,C64, MEGA65, PLUS4,C128, VIC20, PET, NES, OK64, ATARI2600, APPLEII, SNES, ORIC, BBCM, ACORN, ATARI800
Parameters: a,b,b
AddressTable( [address], [byte], [byte] );
- [address] - Memory address or integer array where to the address table was created
- [byte] - X Offset value
- [byte] - Y Offset value
Description
Looks up and address from an address table (see CreateAddressTable) using a Y Offset and adding an optional X Offset.
Useful for quickly referencing the screen or colour memory using X and Y positions.
Example
program MyProgram;
var
addr: array[25] of integer; // Screen addresses stored in this array
i: byte;
// C64 screen start address
@define scrn $0400
// PET screen start address
// @define scrn $8000
begin
DefineScreen(); // sets up the screenmemory pointer
ClearScreen(32, ^@scrn); // clear the screen memory
CreateAddressTable( #addr, @scrn, 40, 25); // create a table of screen addresses (starting at $0400)
// Loop through and print the 25 screen addresses (the memory address of the start of each row)
fori i := 0 to 24 do
begin
screenmemory := AddressTable( #addr, 0, i ); // get start of row i
printdecimal( #addr[i], 4 ); // print it (referencing the array directly)
end;
// plot 25 characters using AddressTable to find the X/Y locations on the screen
fori i := 0 to 24 do
begin
screenmemory := AddressTable( #addr, i+6, i); // find the screen address
screenmemory[0] := i; // plot the character at this screen address
end;
// Plot an ! character in the bottom / right corner of the screen
screenmemory := AddressTable( #addr, 39, 24);
screenmemory[0]:=33;
loop();
end.