Post by scotthuggins on Dec 19, 2015 21:09:11 GMT -5
I say a small issue, but it's actually a complete pain in the arse! LOL.
In my case depending on how far away an enemy is from my player ship, the BIOS routine: Rise_Run_Angle
returns #14, but the documentation (http://playvectrex.com/designit/chrissalo/rise_run_angle.htm) says in order to convert to Vectrex angle, you must subtract #$10 (90 degrees) in order to use it to in your programs. When I do that it becomes -2 for the angle.
When I then turn around and compute the rise and run values (how much to add to the enemy's X coordinate and how much to add to the enemy's Y coordinate) using Rise_Run_Y ($F601) in bios the numbers seem backwards. Like, instead of +2 for the value to add to Y for enemy, it brings back -2.
This only happens when the player ship is a long ways from the enemy (as far as y,x coordinates are concerned).
Pretty easy to duplicate. Here's the code to gather the angle of the enemy that I point him to in order to chase the player ship. I think it's something with this code. I have tried for several hours to no avail. Any ideas, as always, is much much appreciated.
Code:
; **** THIS SECTION COMPUTES THE ANGLE ALIEN SHIP NEEDS TO EMBARK ON IN ORDER TO CATCH PLAYER SHIP
jsr dptoc8
lda ShipYX ; y,x coordinate of player ship (each are stored in consecutive bytes, y followed by x)
suba enemyy ; subtract the enemy's Y coordinate value from the player's Y coordinate
ldb $c931 ; x coordinate of player ship
subb enemyx ; subtract the enemy's X value from player's x value
jsr $f593 ; get angle where player ship is at
subb #$10 ; subtract 16 from the angle - this converts to a vectrex angle
stb ThaAngle ; store the angle to be used in next lines of code
; NOW THAT WE HAVE "ThaAngle", LETS GET RISE / RUN TO GET THE ENEMY SHIP MOVING
; move enemy #1 towards player ship
lda #$02 ; a-reg = the scalar velocity value
ldb ThaAngle ; b-reg = angle
jsr $f601 ; calc rise/run <-- this bios function is returning 255 in A reg when player and enemy are far apart from each other or -1 when used as a signed integer
adda enemyy ;a-reg = the rise value - add this to enemy's y position
sta enemyy
addb enemyx ;b-reg = the run value - add this to enemy's x position
stb enemyx
In my case depending on how far away an enemy is from my player ship, the BIOS routine: Rise_Run_Angle
returns #14, but the documentation (http://playvectrex.com/designit/chrissalo/rise_run_angle.htm) says in order to convert to Vectrex angle, you must subtract #$10 (90 degrees) in order to use it to in your programs. When I do that it becomes -2 for the angle.
When I then turn around and compute the rise and run values (how much to add to the enemy's X coordinate and how much to add to the enemy's Y coordinate) using Rise_Run_Y ($F601) in bios the numbers seem backwards. Like, instead of +2 for the value to add to Y for enemy, it brings back -2.
This only happens when the player ship is a long ways from the enemy (as far as y,x coordinates are concerned).
Pretty easy to duplicate. Here's the code to gather the angle of the enemy that I point him to in order to chase the player ship. I think it's something with this code. I have tried for several hours to no avail. Any ideas, as always, is much much appreciated.
Code:
; **** THIS SECTION COMPUTES THE ANGLE ALIEN SHIP NEEDS TO EMBARK ON IN ORDER TO CATCH PLAYER SHIP
jsr dptoc8
lda ShipYX ; y,x coordinate of player ship (each are stored in consecutive bytes, y followed by x)
suba enemyy ; subtract the enemy's Y coordinate value from the player's Y coordinate
ldb $c931 ; x coordinate of player ship
subb enemyx ; subtract the enemy's X value from player's x value
jsr $f593 ; get angle where player ship is at
subb #$10 ; subtract 16 from the angle - this converts to a vectrex angle
stb ThaAngle ; store the angle to be used in next lines of code
; NOW THAT WE HAVE "ThaAngle", LETS GET RISE / RUN TO GET THE ENEMY SHIP MOVING
; move enemy #1 towards player ship
lda #$02 ; a-reg = the scalar velocity value
ldb ThaAngle ; b-reg = angle
jsr $f601 ; calc rise/run <-- this bios function is returning 255 in A reg when player and enemy are far apart from each other or -1 when used as a signed integer
adda enemyy ;a-reg = the rise value - add this to enemy's y position
sta enemyy
addb enemyx ;b-reg = the run value - add this to enemy's x position
stb enemyx