Jump to content

Photo

Really simple development question


3 replies to this topic

#1 ToyguyVT OFFLINE  

ToyguyVT

    Space Invader

  • 15 posts
  • Location:Vermont USA

Posted Thu Jan 19, 2017 11:49 PM

I'm just starting to play around with this new Vectrex and was fiddling around with VIDE and one of the programming tutorials.  It has you just draw a simple line, which worked fine.  The suggestion was to play around with that and try different things so I attempted to draw two lines :-)  

 

This was the first try (leaving out the equates and initialization block, etc:

draw_line:
        jsr   waitrecal                 ;Reset the CRT
        lda   #00                       ;Get y
        ldb   #00                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #$7f                      ;Get the Intensity
        jsr   intensity_to_A            ;Set intensity
        lda   #00                       ;Get y
        ldb   #127                      ;Get x
        jsr   draw_to_d                 ;draw a line to (x,y)
        lda   #00                       ;Get y
        ldb   #00                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #30                       ;Get y
        ldb   #00                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #30                       ;Get y
        ldb   #127                      ;Get x
        jsr   draw_to_d                 ;draw a line to (x,y)
        bra   draw_line

This results in this:

 

Try1.png

 

So OK, I guess drawing inherently resets 0 to the previous endpoint.  So I try this next:

draw_line:
        jsr   waitrecal                 ;Reset the CRT
        lda   #00                       ;Get y
        ldb   #00                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #$7f                      ;Get the Intensity
        jsr   intensity_to_A            ;Set intensity
        lda   #00                       ;Get y
        ldb   #127                      ;Get x
        jsr   draw_to_d                 ;draw a line to (x,y)
        jsr   waitrecal
        lda   #30                       ;Get y
        ldb   #00                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #30                       ;Get y
        ldb   #127                      ;Get x
        jsr   draw_to_d                 ;draw a line to (x,y)
        bra   draw_line

I've inserted another cal to waitrecal before doing the second line.  I now get this:

 

Try2.png

 

OK, that has the starting point reset but why the heck is that line diagonal?  I'm stumped...

 

Thanks in advance!

 



#2 Mayhem OFFLINE  

Mayhem

    River Patroller

  • 4,925 posts
  • Commodore Chaos Knight
  • Location:London, England

Posted Fri Jan 20, 2017 3:29 AM

I must admit, I've played lots of Vectrex games, but I've never programmed one! Could it be that x and y are offsets when drawing? So for the second draw command, what happens if you set y to 0 for it after the move?



#3 Malban OFFLINE  

Malban

    Combat Commando

  • 7 posts

Posted Fri Jan 20, 2017 9:27 AM

Hi,

some short notes:

a) You should do the WaitRecal only once (at the beginning usually) in your update round, since it waits till the rest of your 30000 cycles have passed and than goes on.

b) to reset the beam position (other than WaitRecal) you can use a different BIOS Function "Reset0Ref"

c) untill you know better, after such a Reset you should do a move (what you already do - good!)

d) all positioning is done from the last "location" the vector beam resides this is called relative positioning.

e) within that relative positioning you do NOT tell the routines which coordinates you want to go to but rather tell in which direction (and distance) the next "point" (or endpoint of a line) lies

f) so, going from 0,0: 30 "pixel" up and 127 "pixel" right draws a "diagonal" from point 0,0 to 30,127 (but still notice, this is relative movement - it just looks absolut since you started off at 0,0)
   if you do exactly the same move "30,127" directly after the first, you will have the "same" diagonal again, which in effect doubles the line and from the view of point 0,0 is a "60, 254" line

 

Malban



#4 ToyguyVT OFFLINE  

ToyguyVT

    Space Invader

  • Topic Starter
  • 15 posts
  • Location:Vermont USA

Posted Fri Jan 20, 2017 1:26 PM

Thanks gentlemen!  Knowing that everything is relative now makes sense.  I was able to get the effect I wanted with this:

draw_line:
        jsr   waitrecal                 ;Reset the CRT
        lda   #00                       ;Get y
        ldb   #00                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #$7f                      ;Get the Intensity
        jsr   intensity_to_A            ;Set intensity
        lda   #00                       ;Get y
        ldb   #127                      ;Get x
        jsr   draw_to_d                 ;draw a line to (x,y)
        lda   #30                       ;Get y
        ldb   #-127                       ;Get x
        jsr   move_pen7f_to_d           ;go to (x,y)
        lda   #0                       ;Get y
        ldb   #127                      ;Get x
        jsr   draw_to_d                 ;draw a line to (x,y)
        bra   draw_lin

I dropped the extra call to waitrecal and moved the X location back 127 units.  Maybe not the most efficient thing, but the end result works :-)






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users