Since I had no reply...
I have been trying to get back into z80, with more sucess than previous tries. I have been messing around with some game ideas and this one reuires (tilemapping) using Arrays. I know how to access the arrays once they are there, but how do I store them to memory?

Code:

array_base .EQU AppBackUpSreen

This is the base memory but how do I store my whole Array into the calculators memory? (Starting at AppBackUpScreen and continuing). This is not a jump table or vector table. Since my values (right now) are not changing should I use a vector table?
Thanks for any help. (Code examples please?)
Edit: (new post so people will read/answer this)
I meant to say Lookup tables instead of vector tables. Would a lookup table be good to store my map data?
In my code I used this:

Code:

;Map is map data
Ld      A,Map+(Row*16-16+Col)

But it won't let me compile, it throws an error. What is wrong?
I'm able to compile this line of code witthout any errors. Could you please post your error messages?
Are Map, Row and Col defined as Label or as "Define"?
My code:

Code:
.nolist
#include "ti83plus.inc"
#define    ProgStart    $9D95
#define Map 0
#define Row 1
#define Col 6
.list
.org    ProgStart - 2 ;-2 wegen den beiden tokens
.db    t2ByteTok, tAsmCmp   
(...)
Ld  A,Map+(Row*16-16+Col)
Map is a label in a sense. It is where my map data is.

Code:

Col    .Equ    AppBackUpScreen
Row   .Equ    Col+2

So Row, Col are variables not set dimensions.
It would be easiert to help you if you post your code...

Quote:
Map is a label in a sense. It is where my map data is.

I assume that you are trying to load a 16-bit value in an 8-bit register. Thats not really a good Idea. If you want to load the value of the element of the array you have to write this expression in brackets.

Code:
Ld  A,Map+(Row*16-16+Col)


It's also not possible to load a vaue directly from the ram. If you want to use row and col you must load them manually.
I wrote this code. I did not test it and i'm a newbie, but maybe it helps you understanding what i mean:




Code:
   ld h, 0
   ld a, (Row) ;i assume that col and row is an 8-bit value
   ld l, a
   add hl,hl ;*2
   add hl,hl ;*4
   add hl,hl ;*8
   add hl,hl ;*16
   ld de, $0010
   sbc hl, de ;-16
_Label1:
   ld a, (Col)
   ld d, 0
   ld e, a
   sbc hl, de
   
   ;add the map-address
   ld de, map
   add hl, de
   ;Load the VALUE (Not the address) of the element
   ld a, (hl)
The way you want to store an array depends on the way you want to use it afterwards. From your question
Quote:
Since my values are not changing

I assume that the data in the array will never change during the execution of your program.
When also assuming the data inside the array is irregular (every other number is random relative to the previous/next), the best thing you can do is to just add it to your program, like so:

Code:
.nolist
#include    "ti83plus.inc"
#define    ProgStart    $9D95
.list
.org    ProgStart - 2
    .db t2ByteTok, tAsmCmp

;If we have the column in B and the row in C:
    LD HL, MapData
    LD A, C
;The row times 8, because there are 8 columns in a row.
    SLA A ;Ax2->A
    SLA A ;Ax2->A
    SLA A ;Ax2->A
    ADD A, B
    LD E, A
    LD D, 0
    ADD HL, DE
    LD A, (HL)
;And there is the data in A.

MapData: ;This is your array base.
;We want a map with size 8x8
;This means we need 64 entries to store it.
    .db 0
    .db 0
    (...) x64
    .db 0
.end
.end

It is also possible to change the data inside such an array.
There is a downside to this way of using it though. Your program will be 64 bytes larger than otherwize, but when using tilemapping, I don't think there is a way around that.
Edit: Needless to say this code will not work the way it is right now, you will need to store some data in B and C manually and of course you will have to exit the program using RET.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement