Trying to understand the VERA FX Polygon Tutorial
Posted: Wed May 29, 2024 12:56 am
The 15-bit signed fixed point number is not explained very well. Is it signed using 2's complement?
The example gives magic numbers of -110 for the left slope and 380 for the right slope without any explanation of where the numbers came from. The concept of filling a triangle is well known -it needs to explain more on how to set it up.
I'm struggling to translate what those values equate to for the actual slope values, so that I can input my own numbers.
Plugging -110 (1111111110010010) into the registers gets you:
What is (-110) and (380)? If I read it right, -110 should equate to
110010010 = 402
111111 = -1?
402 / 512 (9 bits) = 0.75815625
so is the result -1.758? - it only gets more complicated when it's actually half-pixels we're talking about apparently, so the slope is -3.516? What if it's 4-bit?
Am I on the right track?
How the hell am I supposed to calculate this on the fly? is there a simple formula? I tried looking at the hardware tests for examples, but they are even more complicated. I'm sure the person who coded it understood their own code.
The example gives magic numbers of -110 for the left slope and 380 for the right slope without any explanation of where the numbers came from. The concept of filling a triangle is well known -it needs to explain more on how to set it up.
I'm struggling to translate what those values equate to for the actual slope values, so that I can input my own numbers.
Plugging -110 (1111111110010010) into the registers gets you:
Code: Select all
lda #%10010010 ; X Increment (-2:-9) (signed)
sta $9f29
lda #%11111111 ; X Incr. 32x X Increment (5:0) (signed) X Incr. (-1)
and #%01111111 ; why do this if we're using magic numbers? why not just use $7F92 ?
sta $9f2a
What is (-110) and (380)? If I read it right, -110 should equate to
110010010 = 402
111111 = -1?
402 / 512 (9 bits) = 0.75815625
so is the result -1.758? - it only gets more complicated when it's actually half-pixels we're talking about apparently, so the slope is -3.516? What if it's 4-bit?
Am I on the right track?
How the hell am I supposed to calculate this on the fly? is there a simple formula? I tried looking at the hardware tests for examples, but they are even more complicated. I'm sure the person who coded it understood their own code.