Jump to content
Yoruk

Vectrex screen coordinates system

Recommended Posts

Hello there,

 

I was studying the incredible Vectrex, and to understand more how it works I started to code a small sample. Well for now it's just a moving "sprite", but maybe in the future it may become a small game. 🙂

 

I'm almost unfamiliar with assembly language (my small skills are only on the 6502) so I used the CMOC compiler to compile a source written in C. For now everything is fine. I found some samples, and with them I was able to start.

 

But now I have issues with the coordinates system. I understand that (0,0) is the screen center.

 

My sprite position, when I move it to (0,0) is perfectly aligned with the screen center :

 

image.thumb.png.d4d58b70f8ee0354c1c303b047823db9.png

 

My x/y variables are defined with uint8_t values.

 

When I move slightly to the left (x = x-1), as my x value can't be <0 it becomes like 250, and it works fine. (Looping between 0...255, normal).

 

So now I want to add a missile. When pushing a button a second "sprite" is added, moving on the +x axis, starting at the actual player position. The idea is to "cut" the missile once it is away from the screen.

 

So in my code I have something like this :

 

Quote

if ( ShootInProgress==1 &&  missileX >= 254 )                    
        ShootInProgress=0;

 

if ( ShootInProgress==1)

     drawMissile();

 

to "reset" the missile once it goes away from the screen. BUT 254 doesn't works as a limit, as x=254 means the middle of the screen.  The good "edge" value should be 128 is the missile is fired on the right part of the screen, 255 if left.

 

So I'm not sure how to deal with that. I can of course use an other variable or programming trick to solve this problem, but maybe it's not the good way to work.

 

Is there a good way to deal with coordinates ? Like using a signed variable ??? (something from -128 to +128) ???

 

Thanks for your feedback...

 

 

 

 

Share this post


Link to post
Share on other sites

Yes, life will be much simpler if you use signed chars for X and Y coordinates!

Share this post


Link to post
Share on other sites

I tried to use int8_t variables to store my positions. Seems to work fine now !!

 

image.thumb.png.6dd4ea054d7caf22600b7bdf24bbbaf6.png

 

Now I can go deeper....

Thanks ! 😃

 

 

Share this post


Link to post
Share on other sites

Ok my knowledge on this is slowly increasing, but there is still some weird things that I need to understand, like the set_scale function that could be used to size objects.

 

It looks like that a scale value of 128 leave the object untouched, 64 divide the size by two, and so one.

 

But I don't see how to deal with multiples values, like putting two set_scales instructions together. It seems that everything is relative !

 

I didn't manage to find a programming manual or similar stuff on this (only for assembly...).

 

Is there resources for the Vectrex for C programming ?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...