|
Post by scotthuggins on Mar 5, 2015 21:11:24 GMT -5
First off, thanks to everyone for their help so far. I have gone thru Christopher Salomon and Christopher Tumber's documentation. I have something I will share soon regarding my project.
Something I don't quite get is this: When it comes to the Vectrex coordinate system ( x - coordinate and y - coordinate), how are negative numbers fair in to all this? How does veccy know if y is > 0 or x > 0 or vice versa.
Example, if I want these coordinates to be stored and then call the below BIOS routine, how does the BIOS routine know what's negative vs. positive?
I am using this BIOS routine:
Moveto_ix_7F ($F30C) X-reg points to the (y,x) coordinate pair
What I am getting down to is this: if the X register points to both the Y,X coordinates, how do we know if y or x is positive or negative?
Is it a two's compliment thing?
Example code:
LDX #shipYX ; this is storing the y, x coordinate starting at $c930 JSR Moveto_ix_7F ; this a 'move to' bios routine at $F30C
Thanks for any responses!
|
|
|
Post by gauze on Mar 6, 2015 6:23:59 GMT -5
As far as I know all numbers in coords are treated as signed so yes 2's complimented numbers are used, you can tell if something is negative or not if the most significant bit is a '1', basically.
|
|
|
Post by mikiex on Mar 6, 2015 8:12:03 GMT -5
Gauze is correct, 2s compliment - its the fact that the bios routines are written with this in mind.
A byte could be thought of as 2s compliment or 1s compliment, it doesn't know what it is - its just a byte. Its the ASM instruction that if it is designed to will process the byte as if it is in 2s compliment format. That instruction will then output the result you expect in 2s compliment.
Does this make any sense, probably not - its hard to explain, but when you get it, you get it
|
|
|
Post by scotthuggins on Mar 6, 2015 8:20:47 GMT -5
gauze / mikiex-
Yea! That makes total sense. Got it. Thanks for the reply.
|
|
|
Post by christophertumber on Mar 6, 2015 9:40:40 GMT -5
I think a big part of the confusion is that from both a hardware perspective and a BIOS perspective there is no "coordinate system". There are vectors. You don't tell the Vectrex "draw a line from (x1,y1) to (x2,y2)" or even "draw a line to (x,y)" You tell the Vectrex "Draw a line in [direction] of [length]". Where direction are two 1 byte two's compliment values (X and Y) and length is defined by the Scale (which is really a timer). A negative value represents left or down depending on whether X or Y while positive values are up or right. You can certainly create your own routines to simulate a Cartesian plane, but that would be acting as "middleware" between you and what the hardware is actually doing. It seems like you're having trouble getting your head around "two's compliment". You don't really need to understand it. I suppose you can just take it on faith that it's a way to represent a value from -128 to 127 as a single byte. And it's extensible to a word (2 bytes) ie; in the D register - often used for "sub-pixel" movement. en.wikipedia.org/wiki/Two%27s_complement
|
|
|
Post by mikiex on Mar 7, 2015 11:16:06 GMT -5
I think you do need to understand it, maybe not right away - it certainly helped me when I started using 16bit values and fixed point as well. (That is if I really do understand it
|
|
|
Post by mountaingoat on Jul 12, 2015 15:25:19 GMT -5
I see this is somewhat old but an easy way to see if a number is negative (in 2s complement) is checking the highest bit. If it is 1, it is a negative number.
(So with this on 8 bits you have 0 to 127 in positive and -128 to -1 in negative.)
|
|
|
Post by garryg on Jul 19, 2015 14:37:49 GMT -5
The easiest way of all is to load the A and B registers with good old base-10 (decimal) numbers before calling a draw or move ROM routine, that way you can simply use minus sign (-) to indicate a negative value. It's the one place where decimal notation is easily the best... IMO
|
|
|
Post by mountaingoat on Aug 18, 2015 19:15:24 GMT -5
The easiest way of all is to load the A and B registers with good old base-10 (decimal) numbers before calling a draw or move ROM routine, that way you can simply use minus sign (-) to indicate a negative value. It's the one place where decimal notation is easily the best... IMO Naturally, if you are defining them as constants, just use decimal and the minus sign :-) I was talking about if you look at a byte in memory or register and want to figure out if it is negative or not in base 2.
|
|
|
Post by kokovec on Aug 24, 2015 10:07:16 GMT -5
|
|