Re: A86: Using Table


[Prev][Next][Index][Thread]

Re: A86: Using Table




In a message dated 14/12/98 19:24:41 Pacific Standard Time, Bowser797@aol.com
writes:

<< I'm trying to adapt the usage of a table, as discussed recently in the
 Efficiency Problem thread, to my program.  It's eventually going to be
 generating a random (but weighted) number, and retriving the data
coresponding
 to that number in a table.  However, I guess I really don't understand the
 concept behind this, so what's wrong with this?  How should I use the table?
>>
I guess that since starting that thread, and having found new and interesting
ways to use tables in my program, I'll try and answer this. :)
 
> #include "ti86asm.inc"
> #include asm86.h
> 
> .org _asm_exec_ram
> 
> 	call _clrLCD
> 	ld a,2
Tables are most useful when you load them from a value, like ld a,($F600) but
for the sake of argument, you're looking for number three of the series here.
Yes, number three. The first value is zero.
>	ld hl, table
Save this for later.

> 	add a,a
> 	ld e,a
> 	ld d,0
Put the ld hl,table here, it's easier.
> 	add hl,de
> 	call $33
This is probably your problem. I had to look up the equate in Asm Studio's
help file, and it's worked:
_ldhlind	.equ $4010	;ROM Call
So change that line to call _ldhlind
> 	call _puts
> 
> table:
> 	.dw one
> 	.dw two
> 	.dw three
It's much easer to do Table: .dw one,two,three
> 
> one:
> 	"one",0
If you prefer this to one: "one",0 then go ahead. I personally find it easier
to see more if it's all on the same line. (Then again, my game has a TON of
text! :)

> 
> two:
> 	"two",0
> 
> three:
> 	"three",0
> .end >>


Mostly, I think that's right. Just call a _puts to put that on the screen, and
change the _ldhlind equate. That's probably your problem.