Omnimaga

Calculator Community => TI Calculators => General Calculator Help => Topic started by: Happybobjr on December 25, 2010, 06:01:23 pm

Title: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 06:01:23 pm
ok, so i read wikipedia's thoughts about mode 7 and i am even more confused.

can someone explain this please?

mostly about the matrices.

"Planar texture maps using Mode 7 graphics are generated by transforming screen coordinates to background coordinates using a 2D affine transformation,


umm??? VVV
    \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} a & b & x_0 \\ c & d & x_0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x - x_0 \\ y - y_0 \\ 1 \end{bmatrix}

where a, b, c, and d are the transformation coefficients; x and y are the screen offset; x_0 and y_0 are the origin offset; and x' and y' are the transformed coordinates. All arithmetic is carried out on 16-bit signed fixed point numbers, while all offsets are limited to 13 bits. The radix point is between bits 7 and 8.

Affine transformations only allow for displacement, scaling, and shearing effects. Many games create additional effects through creative manipulation of the transformation matrix parameters on a scanline by scanline basis. In this way pseudo-perspective, curved surface, and distortion effects can be achieved"
Title: Re: [Help please] Mode 7.
Post by: calc84maniac on December 25, 2010, 06:12:23 pm
Here's a nice post about it by JimE on Revsoft: http://www.revsoft.org/phpBB3/viewtopic.php?p=14409#p14409

If you don't understand it, I'll be happy to explain more.
Title: Re: [Help please] Mode 7.
Post by: yunhua98 on December 25, 2010, 06:20:30 pm
Please elaborate, I may have an idea...
But I can't really understand it yet.  ;)
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 06:22:01 pm
Is that what you used on your (http://i88.photobucket.com/albums/k168/calc84maniac/spinsmall.gif)


sorry, but that doesn't have enough info.
How would i make it?
Title: Re: [Help please] Mode 7.
Post by: calc84maniac on December 25, 2010, 06:26:00 pm
I worked out all the math on paper (it involved lots of similar triangles :D)

The thing to remember is that to figure out what each pixel is, you have to cast a ray through each screen pixel (as if there was a floating screen in the virtual space). This is how raytracing works, but this has much simpler math because you're only intersecting with a flat plane.
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 06:28:25 pm
can you give me a small code example of a small mode 7 screen or something?
Title: Re: [Help please] Mode 7.
Post by: yunhua98 on December 25, 2010, 06:28:44 pm
so in for a car on a straight road, how would you figure out how the road shows up on a screen?

me too!  ;)
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 06:44:57 pm
can we see the program you used for (http://i88.photobucket.com/albums/k168/calc84maniac/spinsmall.gif)
Title: Re: [Help please] Mode 7.
Post by: yunhua98 on December 25, 2010, 06:46:36 pm
I beleive the program is in F-Zero subforum, however, its in ASM
Title: Re: [Help please] Mode 7.
Post by: jnesselr on December 25, 2010, 06:48:50 pm
so in for a car on a straight road, how would you figure out how the road shows up on a screen?

me too!  ;)
You would essentially pick a point on the road away from you, and draw a line from your "eye" through the screen to where the point on the road is.  The distance between your eye and the screen (d1), and the distance between your eye and the point on the road (technically the point above the road that is directly in line with the first line (the one that makes d1) is what you would use instead of the point itself) This is d2.  You would then compare the height from the point on the ground to the point in the air that is eye-level.  This is r2.  So d1/d2=r1/r2.  Since r1 is what we need to find, (r2 * d1)/d2 = r1.  That is the point on the screen.
Title: Re: [Help please] Mode 7.
Post by: Quigibo on December 25, 2010, 06:57:54 pm
If you want to see the Axe version I made a while back, you can download the source code here (http://ourl.ca/4050/119339) but it doesn't have rotation.  One confusing optimization that programs like these use though is to remove the multiplication in the main loop and replace it with an addition.
Title: Re: [Help please] Mode 7.
Post by: calc84maniac on December 25, 2010, 06:58:56 pm
I made an image here for you. Lines of the same color are similar, meaning the ratio is the same within each of the pairs of lines of the same color.
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 06:59:20 pm
ok, could i edit the code to have rotation?
If you want to see the Axe version I made a while back, you can download the source code here (http://ourl.ca/4050/119339) but it doesn't have rotation.  One confusing optimization that programs like these use though is to remove the multiplication in the main loop and replace it with an addition.
Title: Re: [Help please] Mode 7.
Post by: calc84maniac on December 25, 2010, 07:03:28 pm
Oh, and the method you actually use for getting the points is by going out to the end of the bright green line, and then the points are evenly spaced along the blue line.
Title: Re: [Help please] Mode 7.
Post by: jnesselr on December 25, 2010, 07:08:24 pm
One confusing optimization that programs like these use though is to remove the multiplication in the main loop and replace it with an addition.
How exactly would you do that with addition?
Title: Re: [Help please] Mode 7.
Post by: Quigibo on December 25, 2010, 07:54:51 pm
Code: [Select]
:For(A,0,20)
:A*B->C
:End

Can be changed to:
Code: [Select]
:-B->A
:For(D,0,20)
:A+B->A->C
:End

And now you've removed a multiplication.  If you add rotation, you have to do 2 additions: one for the Y spacing and one for the X spacing.
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 08:06:00 pm
thanks i'll look into that.
Title: Re: [Help please] Mode 7.
Post by: jnesselr on December 25, 2010, 08:08:41 pm
@Quigibo: I don't fully understand the concept behind what you are doing. Can you explain it?
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 25, 2010, 08:10:00 pm
Code: [Select]
:For(A,0,20)
:A*B->C
:End

Can be changed to:
Code: [Select]
:-B->A
:For(D,0,20)
:A+B->A->C
:End

And now you've removed a multiplication.  If you add rotation, you have to do 2 additions: one for the Y spacing and one for the X spacing.

that isn't in the code you linked to.
Title: Re: [Help please] Mode 7.
Post by: yunhua98 on December 27, 2010, 11:42:49 pm
thanks, but to make sure I'm understanding correctly, could someone make a pic like calc84maniac's and label the d1, d2, r1, and r2?
I'm still a bit confused...  I just can't picture things in 3D.  :P
Title: Re: [Help please] Mode 7.
Post by: Happybobjr on December 28, 2010, 09:16:20 am
do what i did.
Take quigibo's mode 7 code.
in your program only draw to L3.
put in quigibo's code right where you would normally have display gragh.
note: change all Y's in quigibo's code to (20-y). (maybe 30-y  i can't remember and don't have my calc near me.)

Then you can fiddle around with his code to understand it.