just a thread so i can get some help in trying to play with table lookups in $4d, or at least so you can all watch me fail miserably
first time trying to mess with table lookups, so chances of me doing the obvious and failing miserably are high.
my goal is, want both tables to be re-ranged from 20kpa to 100kpa. i do a LOT of decel and very light crusing, and spend a ton of time 20-40kpa, so i want more fine grained control in that range, and there is NO way to force an LO3 above 100kpa.
i'd like to increase VE resolution too, but maybe that's next, since there's very little free space to shove stuff around with only a 4k bin.
relavent code;
Code:;~~~~~~~~~~~~~~~~
;-Main %VE table
;~~~~~~~~~~~~~~~~
;
LD278 FCB 0 ;row offset
FCB 16 ;Col offset
FCB 8 ;# of cols
; RPM/1k .4 .8 1.2 1.6 2.0 2.4 2.8 3.2 ;kPa
;
FCB 50, 49, 54, 57, 60, 62, 63, 65 ; 30
FCB 51, 52, 55, 63, 69, 76, 86, 90 ; 40
FCB 53, 54, 61, 65, 79, 88, 99, 103 ; 50
FCB 55, 59, 75, 82, 86, 94, 101, 108 ; 60
FCB 65, 71, 88, 91, 93, 99, 110, 116 ; 70
FCB 95, 107, 112, 108, 103, 103, 111, 120 ; 80
FCB 98, 106, 121, 121, 119, 119, 122, 127 ; 90
FCB 99, 107, 121, 125, 124, 125, 125, 129 ;100
FCB 99, 106, 120, 127, 126, 124, 126, 130 ;110
;~~~~~~~~~~~~~~~~
;main %VE lookup
;~~~~~~~~~~~~~~~~
;
LD596 LDAB L001B ;RPM/25
BPL LD59C ;bra if <3200
;
LDAB #$0080 ;3200 rpm
;
LD59C LDX #LD278 ;%VE table
JSR LFB99 ;Do 3D lookup
ADDA L00AC ;add %VE in
BCC LD5A8 ;Bra if overflow
;
LDAA #$00FF ;clr overflow
;
LD5A8 STAA L00AC ;Store it, %VE
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;>
;>3D lookup routine
;>
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
LFB99 SUBA $0000,X ;Subtract row offset from A
BCC LFB9E ;Bra if > offset
;
CLRA ;Clr A
;
LFB9E SUBB $0001,X ;Subtract column offset from B
;
BCC LFBA3 ;Bra if > offset
;
CLRB ;Clr B
;
LFBA3 STAB L004B ;tmp storage
LDAB #$0010 ;
MUL ;Calc column offset
PSHB ;Push the leftovers to the stack
;
LDAB $0002,X ;Load in # of cols. into B
PSHB ;Push that to the stack too
MUL ;Offset in A x # cols.
ABX ;Add in offset to X
;
INX ;Addr +1
INX ; "
INX ; "
PSHX ;Addr of column ----> stack
LDAA L004B ;Load row offset into A
BSR LFB7B ;Go do 2D lookup
;
STAA L004A ;tmp storage
LDAA L004B ;load row offset into B
PULX ;Get column address off the stack
PULB ;Get # of columns from stack
ABX ;Add # of columns to X, go over one row
BSR LFB7B ;2D lookup, get value next to it
TAB ;Value ----> B
LDAA L004A ;Get that value back into A
BRA LFB83 ;Go interpolate it and return