|
Post by minsoft on Sept 5, 2020 8:57:20 GMT -5
Hi all,
I am new to vectrex programming, 6809 and assembler in general really. I am working on a game and am doing ok so far, but there are a few things I'm not sure how to do which seems like there may be a simple solution to.
I have some data at #enemy_pattern_0. I need to load in the data from that address+an offset (offset is in 'enemy_step'). I have achieved this with the following code:
STB enemy_step
LDX #enemy_pattern_0 step_loop: LDA ,X+ ... CMPB #0 BEQ enemy_save DECB JMP step_loop enemy_save: ...
This works - I end up with what I want in A, but is very inefficient as I'm looping through the no. of times in 'enemy_step' to get the offset I need by doing 'LDA ,X+'. I would rather not have a loop at all.
I thought I might be able to do this:
LDX enemy_step, #enemy_pattern
...but this doesn't work. I assume this is because a pointer cannot be used as the offset parameter.
First instinct was to use INCX / ADDX but of course they don't exist. I am not sure the best way to achieve what I'm trying to do. Any tips?
|
|
|
Post by kokovec on Sept 5, 2020 19:57:42 GMT -5
Maybe use something like this?
LDX #enemy_pattern_0 LDA enemy_step LDB A,X
|
|
|
Post by minsoft on Sept 7, 2020 3:54:11 GMT -5
Maybe use something like this? LDX #enemy_pattern_0 LDA enemy_step LDB A,X
It's that easy isn't it...not sure why I didn't do that. Thanks very much!
|
|