A86: Re: Loading data from a "variable" address. . .


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

A86: Re: Loading data from a "variable" address. . .




>I've been following this list for two or three weeks now, and found it to
>extremely helpful (well. . . most of the time =)  Anyways, I'm working on
an
>RPG similar to the original Legend of Zelda for the old NES (not quite an
>"RPG", but close enough).

Awesome! I love Zelda

>  The problem I'm having is the way the data is
>stored. Since the map is split into many sections (one at a time), I have
>all the data stored for them in Sections labeled Screen1, Screen2, etc. . .
>So every time you move right a screem, the number is increased by one, left
>decreases one, and up or down decreases or increases by the number of
>screens in a row.
>
>For example:
>
>Screen01    Screen02    Screen03    Screen04    Screen05
>Screen06    Screen07    Screen08    Screen09    Screen10
>Screen11    Screen12    Screen13    Screen14    Screen15
>. . . etc., etc. . .
>
>What I want to do is have the "a" register pointing to the data.  Assuming
>you start in Screen01 and move down a screen, you'll be at Screen06. What I
>want to do is set "b" to be equal to 6 (or, if possible, use OP1 to store
>the string "Screen06"), and do something like "ld a, [the label in b/OP1]".
>I've been trying to find a way to do this, and I think it may involve
>_ABS_DEST_ADDR (is that absolute destination address?) and
>_SET_ABS_DEST_ADDR -- but I have no clue how to use them. . .
>
>I could also use "cp b,1 / jp z,SetAToScreen01 / cp b,2 / jp
>z,SetAtoScreen02" etc. (and have those labels do just what they say), but
>that's at least 2 or 3 times the memory, and not flexible enough (if I use
>other labels -- like Dungeon01, or Cave02) -- so i anyone could help me,
I'd
>appreciate it. . .


If you use a lot of memory that span multiple pages I believe you will need
to use absolute addresses. I honestly dont know, I am still learning

>And, does anyone have any clue how the Zelda enemy AI works? I was watching
>the game; half of what the guys did was completely random (Firing in the
>opposite direction from me, moving straight random amounts of time before
>turning), and half was actually moving TOWARDS me and aiming AT me (not an
>easy feat -- I've got a few ideas as to how I'll program them, but They may
>be pretty dumb =) I got the Gameboy Zelda ROM image and decompiled it, but
>It's impossible to find ANYTHING in 120K of decompiled Z80 source code --
>and it's only legal to have these things 24 hours without owning the actual
>game. . .


About the AI. You could have preprogrammed movements, ie.

.db 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4

Where 1 would be move down, 2 move right, 3 move up, 4 move left

in this case the guy would move in a circle. Another byte could be a flag
setup for
each eneny.

db %11001000

bit 7 tells what color (dark or light)
bits 0-3 may tell how much health the guy has, just an idea

just some ideas.

>I've also got a few other ASM questions:
>1) When do I need to use "ret", and when don't I??? I've seen source code
>for some programs that jump, do a routine, and go back but don't use
>"ret" -- When does it know to return?


when you use call it will push the current instruction address (PC) onto the
stack.
When you use ret it retrieves it from the stack.

That explains why you must push as much as pop in any routine

>2) I've seen cases where "call" was used exactly like "jp" -- and NOT for
>ROM calls?!? Am I allowed to use it for anything else???

go ahead. It can be used to call any routines, whether inside your asm
program or outside, as long as it is in the current 16k page. Page $D is
default and when you call something on Page $D, it will change ram pages for
you and call the real routine

If you are using it as a function then use call, but if you are using it as
a "goto" then use jr (if less then 128 bytes away) or JP (takes longer, but
jump anywhere in 16-bit memory)

>3) While I'm at it, is a TI-89 list going to open soon?


When the TI-89 comes outs, after this summer I think

>4) Since the 89 will use a Motorola 68000 like the TI-92, the assembly will
>be like Fargo, not the 82, 83, 85, 86, or any of the others that use a 6MHz
>Z80, right? If so, does anyone here know of a good Fargo reference source?
>(again, it's the wrong list, but I'm not on the TI-92 list and this is more
>convenient).


It will be like FARGO, but I think the screen dimensions are different. The
key layout is
also probably different..

>Anyways, that's enough for one E-Mail -- I'd appreciate any help I can get.
>Thanks!


Later,

Matt
http://www.dogtech.com/cybop/ti86/