Here's a build that implements on-the-fly calculation of all Mode 7 matrix parameter tables using CPU multiplication registers during active display -- just to illustrate to you guys how awful that turns out.
From my notes:
Code: Select all
; This is the algorithm to do signed 8×16 bit multiplication using CPU multiplication registers:
; 1. do unsigned 8×8 bit multiplication for lower 8 bits of multiplicand, store 16-bit interim result in temp
; 2. do unsigned 8×8 bit multiplication for upper 8 bits of multiplicand, store 16-bit interim result in temp+3 (it's crucial that temp+2 remains $00)
; 3. combine interim results, keeping the upper 16 bits of the 24-bit result only (the lower 8 bits aren't needed by the Mode 7 matrix parameters)
;
; As CPU multiplication is unsigned, this is how the sign of the multiplier is accounted for:
; 1. if multiplier is positive, simply do the two 8×8 bit multiplications one by one, and do (temp+3)+(temp+1) for the end result
; 2. if multiplier is negative, make it positive first, then do the two 8×8 bit multiplications one by one, and do -(temp+3)-(temp+1) for the end result
;
; Proof of concept:
; Consider this multiplication:
; 17 * (-5) = -85
; Now make the multiplier positive, and store the two interim results:
; 7 * 5 = 35
; 10 * 5 = 50
; Now make the second result negative, and subtract the first one:
; (-50) - 35 = -85
As I suspected well before I actually decided to give it a try, 224 scanlines of active display still aren't enough to calculate all four tables (at least not without heavy slowdown), so I introduced a frame counter and split the calculations between odd and even frames, reducing performance from 60 fps to 30 fps.
Please be warned – doing turns on the Mode 7 map will very likely make you sea-sick.
Download:
http://manuloewe.de/snestuff/projects/f ... d_00222.7z
N.B. Please don't bother speculating again and again about how this or that game might have managed to implement Mode 7. Instead, feel free to impress me (if you can), and possibly contribute to this project, by
showing (

) us all your own working Mode 7 perspective implementation (BTW, have fun doing it).
Thanks!
Ramsis