1 Attachment(s)
understanding table lookups
finally getting back into hacking EE, im having a bit of trouble getting from A to B on this one table that i've always considered a top priority.
i'm trying to figure out how a table lookup is scaling MAP KPA against each column in a 5 column table (ex. is it 20,30,40,50,60kpa or what)
i have a table.
Code:
26F2 bt3_26f2_3dlkup_table_sizes:
26F2 db $00, $00, $05
26F5 bt75?_26f5_what_bpw_related_f(cooltmp,load):
26F5 db $45, $56, $5C, $62, $68, $45, $56, $5C, $62, $68
26FF db $45, $56, $5C, $62, $68, $45, $56, $5C, $62, $68
2709 db $40, $50, $56, $5B, $61, $2E, $39, $3E, $43, $48
2713 db $24, $2C, $31, $36, $3A, $1B, $21, $25, $2A, $2E
271D db $17, $1C, $21, $26, $2B, $13, $18, $1D, $22, $28
2727 db $0F, $13, $18, $1E, $23, $0A, $0C, $12, $18, $1E
2731 db $06, $08, $0A, $0C, $0E, $06, $08, $0A, $0C, $0E
273B db $06, $08, $0A, $0C, $0E
it's 5 columns of MAP by 15 rows of coolant temperature (picture attached).
Code:
659F B6 01 93 @243 ldaA l_0193_CoolTmp_fltrd_$f0_max_$e0
65A2 F6 01 6B ldaB l_016b_(ADMAP-26)*151*2/256
65A5 54 lsrB
65A6 54 lsrB
65A7 CE 26 F2 ldX #$26F2
and here's the lookup subroutine
Code:
;; lkup3d_sub: ; A row, B col, X tbl addr, A returned val
65AA A0 00 subA 0, X ; CALC ROW ARG OFFSET, (LIMITED TO 0)
65AC 24 01 bcc @244
65AE 4F clrA ; ... ELSE
65AF E0 01 @244 subB 1, X ; CALC COL ARG OFFSET, (LIMITED TO 0)
65B1 24 01 bcc @245
65B3 5F clrB ; ... ELSE
65B4 3C @245 pushX ; XFER TABLE ADDR TO Y REG
65B5 18 38 popY
65B7 36 pushA ; SAVE ROW ADDRESS
65B8 86 10 ldaA #$10 ; SPLIT COL ARG INTO TABLE OFFSET
65BA 3D mul ; & INTERP PORTION
65BB 37 pushB ; SAVE INTERP PORTION TO STACK
65BC 16 tAB
65BD 3A aBX
65BE 33 popB
65BF 32 popA ; GET ROW ARG
65C0 37 pushB
65C1 C6 10 ldaB #$10 ; SPLIT ROW ARG INTO R
65C3 3D mul ; TABLE NUMBER
65C4 37 pushB ; (MAX RESULT IS 255D)
65C5 18 E6 02 ldaB 2, Y
65C8 3D mul
65C9 3A aBX
65CA 3C pushX
65CB 18 E6 02 ldaB 2, Y
65CE 3A aBX
65CF 18 30 tSY
65D1 EC 03 ldD 3, X
65D3 10 sBA
65D4 18 E6 03 ldaB 3, Y
65D7 24 06 bcc @246
65D9 40 negA
65DA 3D mul
65DB A9 03 adcA 3, X
(ADMAP-26)*151*2/256 is calculated as:
Code:
5891 B6 01 2A ldaA l_012a_ADMAP
5894 80 1A subA #$1A ; ADMAP - 26
5896 24 01 bcc @18 ;br if ADMAP > 26
5898 4F clrA ; else min zero
5899 C6 97 @18 ldaB #$97
589B 3D mul ; (ADMAP-26)*151
589C 05 lslD ; * 2
589D 25 06 bcs @19
589F CB 80 addB #$80
58A1 89 00 adcA #$00 ; round up D to whole msb A ?
58A3 24 02 bcc @20
58A5 86 FF @19 ldaA #$FF
58A7 B7 01 6B @20 staA l_016b_(ADMAP-26)*151*2/256 ; (ADMAP-26)*151*2/256
i can make a very clear assumption on the table rows, being coolant temp against 15 rows, it's the same as every other vs coolant temp table in EE.
but this map thing is throwing me for a loop.
i know once i wrap my head around this more simple table, i'll start making some real sense of some other more mysterious tables.
any ideas?