This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 29 Nov 2003 04:14:50 pm    Post subject:

If you have degrees instead of slope, you could do deltaY=cos theta, deltaX=sin theta=1-deltaY^2. This will probably be slow, but it will be accurate.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 29 Nov 2003 06:14:52 pm    Post subject:

That would be very slow. Plus its to much, all I need is a simplified rise and run. Nothing more really.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 29 Nov 2003 06:24:28 pm    Post subject:

You could probably use something linear that will estimate the sine/cosine of theta.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 30 Nov 2003 09:44:36 pm    Post subject:

ok, I tried to write a slope routine that would give me what I wanted but it still doesn't work right. The puck starts flying across the screen in random places. Heres the code I wrote


Code:
;------------------------slope---------------------
;inputs b(final  x cor)
;inputs c(initial x cor)
;inputs d(final y cor)
;inputs e(initial x cor)
;outputs (d,e) Slope
slope:
  ld a,0
  ld (x_neg),a
  ld (y_neg),a    ;these are just to see if the value is going to be changed back to a negative at the end
  ld a,b
  sub c
  ld b,a
  cp 0
  call m,end_neg1    ;if this is negatiove it sets the x_neg to 1
  ld a,d
  sub e
  ld c,a
  cp 0
  call m,end_neg2    ;if this is negative it sets the y_neg to 1
  ld a,b
  ld (x_slope),a    ;temporaily saves run here
  ld a,c
  ld (y_slope),a    ;temporarilt saves rise here
  ld hl,(x_slope)    ;loads the run into op2 the op2 to op1
  bcall(_setxxxxop2)
  bcall(_op2toop1)
  ld hl,(y_slope)    ;loads the rise into op2
  bcall(_setxxxxop2)
  bcall(_abso1o2cp)    ;gives the absolute value of both op1 & op2
  bcall(_FPDiv)    ;divides op1 by op2 leaving the answer in op1
  bcall(_ToFrac)    ;takes op1 and tries to convert it into a fraction.  op1 = num op2 = den
  bcall(_intgr)    ;converts op1 to and integer
  ld hl,op1
  ld (x_slope),hl    ;sets run=op1
  bcall(_op2toop1)    ;sets op2 to op1 now that op1 has been saved
  bcall(_intgr)    ;converts it to and integer
  ld hl,op1
  ld (y_slope),hl    ;sets rise=op1
  call signchange    ;if the number was negative before the absolute value was taken, it will be negative again
  ret
signchange:
  ld a,(x_neg)
  cp 1
  call z,make_xneg
  ld a,(y_neg)
  cp 1
  call z,make_yneg
  ret
make_xneg:
  ld a,(x_slope)
  ld h,a
  ld l,-1
  ld (x_slope),hl
  ret
make_yneg:
  ld a,(y_slope)
  ld h,a
  ld l,-1
  ld (y_slope),hl
  ret
end_neg1:
  ld a,1
  ld (x_neg),a
  ret
end_neg2:
  ld a,1
  ld (y_neg),a
  ret


Last edited by Guest on 30 Nov 2003 09:47:10 pm; edited 1 time in total
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 06 Dec 2003 01:10:52 pm    Post subject:

Can anyone help me with this?
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 06 Dec 2003 08:42:39 pm    Post subject:

I have been thinking and it turns out that it can be pretty complicated. My suggestion is that you find a pixel perfect line drawing routine and try and mod it.
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 08 Dec 2003 12:54:45 pm    Post subject:

Why not use vectors? Use LUTs for the sine and cosines and some fixed-point math and you're sailing.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 08 Dec 2003 02:34:26 pm    Post subject:

Yeah, I think I'm gonna do that anyways bc trying to find the slope is really hard the way I want it. Plus I want to just completely re-write the code to make it smaller and more effictient. So wish me luck and thankyou for the tutorial thing.
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 09 Dec 2003 03:04:39 pm    Post subject:

Yes that is a good idea. Instead of making the puck from one positon to another position, you can give it a velocity and a direction. This will make it look more 'realistic' and make bouncing off walls etc easier.
Back to top
sic


Advanced Newbie


Joined: 28 Jul 2003
Posts: 62

Posted: 09 Dec 2003 07:17:48 pm    Post subject:

MaxVT103 wrote:
Yeah, I think I'm gonna do that anyways bc trying to find the slope is really hard the way I want it.

....plus it's rather hard to find the slope of a perfectly vertical line Laughing you'd have to special case that.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 16 Dec 2003 01:27:45 pm    Post subject:

Yeah, but now that I'm trying it a new way, calculating its being a dic and I don't know how to display it properly. The tutorials you guys gave me were in C, their good but it doesn't help me to much with making a z80 version
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page Previous  1, 2
» View previous topic :: View next topic  
Page 2 of 2 » All times are UTC - 5 Hours

 

Advertisement