Hi all,
Here's some info re table lookups. I found five 3d table lookup routines.
ROM:000264AC
ROM:000264AC ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ ¦¦¦¦¦¦¦¦¦¦¦¦¦¦
ROM:000264AC
ROM:000264AC
ROM:000264AC Lookup_3Dsword_264AC: ; CODE XREF: ROM:00020260 p
ROM:000264AC ; ROM:000203B2 p ...
ROM:000264AC move.w d1,d3 ; Move Data from Source to Destination
ROM:000264AE lsr.w #8,d3 ; Logical Shift Right
ROM:000264B0 lsl.w #1,d2 ; Logical Shift Left
ROM:000264B2 mulu.w d2,d3 ; Unsigned Multiply
ROM:000264B4 adda.l d3,a0 ; Add Address
ROM:000264B6 move.w d0,d3 ; Move Data from Source to Destination
ROM:000264B8 tblsn.w (a0),d0 ; Table Lookup and Interpolation (Signed)
ROM:000264BC tblsn.w (a0,d2.w),d3 ; Table Lookup and Interpolation (Signed)
ROM:000264C2 tbls.l d0:d3,d1 ; Table Lookup and Interpolation (Signed)
ROM:000264C6 addi.l #$80,d1 ; 'Ç' ; Add Immediate
ROM:000264CC asr.l #8,d1 ; Arithmetic Shift Right
ROM:000264CE move.l d1,d0 ; Move Data from Source to Destination
ROM:000264D0 rts ; Return from Subroutine
ROM:000264D0 ; End of function Lookup_3Dsword_264AC
ROM:000264D0
Inputs:
A0 = Address of table
D0 = column variable
D1 = row variable
D2 = # columns per row
Outputs:
D0 & D1 both contain the lookup result
Temp registers:
D3 =
Analysing the routine:
D3 = D1
Shift right D3 8 places (divide by 256) (convert to integer row number)
Shift left D2 1 place (multiply by 2) convert from cols/row to bytes/row
Multiply Word Unsigned D2 and D3 result in D3
Add Long D3 to A0, result in A0 (this is the new lower row address)
D3 = D0 copy column variable to D3
D0 = Lookup Lower row: Lookup Signed Word Unrounded A0 as row and D0 as the column variable
D3 = Lookup Upper row: Lookup Signed Word Unrounded A0+D2 as row and D3 as the column variable
D1 = Interpolate with rounding between D0 and D3 for final answer
D1 = D1 + 128
Shift right D1 8 places (divide by 256) adjust to the resolution required
D0 = D1
Return Result in D0 and D1
Hopefully no mistakes above. There are word and byte, signed an unsigned equivalents of these. Also, some routines take D2 in bytes/row not cols/row. D0 and D1 need to be pre-scaled to be in range for the table size. In total i counted over 600 2d and 3d lookups in the code, thankfully not all are unique tables!!
I've found all sorts of other stuff but will post in another thread specific to this bin. The jump refernces take a while to get ya head around for sure - not quite there yet on the actual structure of the main routines but wont be long.