Map switching routines, M4.4, turbo/ignition/fuel. Basically, all these do is set the DPTR to the map address. The original MOV DPTR instruction before the map lookup call is replaced with a call to these switcher functions. The two most significant bits of the logging flagbyte are used to select maps 00 [00] = Nothing set, use stock map locations 40 [01] = Map set 1 80 [10] = Map set 2 C0 [11] = Map set 3 ------------------------------------------------------------------------------------------------------------ Map Switcher, Turbo Map, insert at 0x8640 then replace MOV DPTR with LCALL 8640 at B247 and B252 (-607) --or-- B1CD and B1D8 (-608) ; SAVE ACC TO STACK C0 E0 PUSH ACC ; Get Flagbyte, clear lower 6 bits 90 FD AE MOV DPTR, #0xFDAE ; Flagbyte E0 MOVX A, @DPTR ; Get byte to ACC 53 E0 C0 ANL A, 0xC0 ; Zero lower 6 bits of B -- 0x40 = Map 1 // 0x80 = Map 2 // 0xC0 = Map 3 ; 0x00: Stock Map B4 00 06 CJNE A, #0x00 +6 90 E4 54 MOV DPTR, #0xE454 ; default map address D0 E0 POP ACC ; restore ACC from stack 22 RET ; 0x40: Alt Map #1 B4 40 06 CJNE A, #0x40 +6 90 81 00 MOV DPTR, #0x8100 ; First alt map address D0 E0 POP ACC 22 RET ; 0x80: Alt Map #2 B4 80 06 CJNE A, #0x80 +6 90 82 00 MOV DPTR, #0x8200 ; Second alt map address D0 E0 POP ACC 22 RET ; 0xC0: Alt Map #3 B4 C0 06 CJNE A, #0xC0 +6 90 83 00 MOV DPTR, #0x8300 ; Third alt map address D0 E0 POP ACC 22 RET ; Failsafe - Shouldn't ever make it here, but in case, use stock map. 90 E4 54 MOV DPTR, #0xE454 ; default map address D0 E0 POP ACC 22 RET ------------------------------------------------------------------------------------------------------------ Map Switcher, Ignition Map, insert at 0x1E000 Then change the MOV DPTR at 1614C to LCALL E000. Same location in both 607 and 608 binaries. ; SAVE ACC TO STACK C0 E0 PUSH ACC ; Get Flagbyte, clear lower 6 bits 90 FD AE MOV DPTR, #0xFDAE ; Flagbyte E0 MOVX A, @DPTR ; Get byte to ACC 53 E0 C0 ANL A, 0xC0 ; Zero lower 6 bits of B -- 0x40 = Map 1 // 0x80 = Map 2 // 0xC0 = Map 3 ; 0x00: Stock Map B4 00 06 CJNE A, #0x00 +6 90 3C 37 MOV DPTR, #0x3C37 ; default map address D0 E0 POP ACC ; Restore ACC from stack 22 RET ; 0x40: Alt Map #1 B4 40 06 CJNE A, #0x40 +6 90 E1 00 MOV DPTR, #0xE100 ; First alt map address D0 E0 POP ACC 22 RET ; 0x80: Alt Map #2 B4 80 06 CJNE A, #0x80 +6 90 E2 00 MOV DPTR, #0xE200 ; Second alt map address D0 E0 POP ACC 22 RET ; 0xC0: Alt Map #3 B4 C0 06 CJNE A, #0xC0 +6 90 E3 00 MOV DPTR, #0xE300 ; Third alt map address D0 E0 POP ACC 22 RET ; Failsafe - Shouldn't ever make it here, but in case, use stock map. 90 3C 37 MOV DPTR, #0x3C37 ; default map address D0 E0 POP ACC 22 RET ------------------------------------------------------------------------------------------------------------ Map Switcher, Fuel Map, insert at 0x1E080 Then change the MOV DPTR at 164D0 to LCALL E080. Same location in both 607 and 608 binaries. ; SAVE ACC C0 E0 PUSH ACC ; Get Flagbyte, clear lower 6 bits 90 FD AE MOV DPTR, #0xFDAE ; Flagbyte E0 MOVX A, @DPTR ; Get byte to ACC 53 E0 C0 ANL A, 0xC0 ; Zero lower 6 bits of B -- 0x40 = Map 1 // 0x80 = Map 2 // 0xC0 = Map 3 ; 0x00: Stock Map B4 00 06 CJNE A, #0x00 +6 90 3D 47 MOV DPTR, #0x3D47 D0 E0 POP ACC 22 RET ; 0x40: Alt Map #1 B4 40 06 CJNE A, #0x40 +6 90 E4 00 MOV DPTR, #0xE400 D0 E0 POP ACC 22 RET ; 0x80: Alt Map #2 B4 80 06 CJNE A, #0x80 +6 90 E5 00 MOV DPTR, #0xE500 D0 E0 POP ACC 22 RET ; 0xC0: Alt Map #3 B4 C0 06 CJNE A, #0xC0 +6 90 E6 00 MOV DPTR, #0xE600 D0 E0 POP ACC 22 RET ; Failsafe - Shouldn't ever make it here, but in case, use stock map. 90 3D 47 MOV DPTR, #0x3D47 D0 E0 POP ACC 22 RET -------------------------------------------------------------------------------------- Map Switcher, Injector Constant For CODE_5225 ; Get Flagbyte, clear lower 6 bits 90 FD AE MOV DPTR, #0xFDAE ; Flagbyte E0 MOVX A, @DPTR ; Get byte to ACC 53 E0 C0 ANL A, 0xC0 ; Zero lower 6 bits of B -- 0x40 = Map 1 // 0x80 = Map 2 // 0xC0 = Map 3 ; 0x00: Stock Map B4 00 09 CJNE A, #0x00 +9 90 C9 23 MOV DPTR, #0xC923 ; Address of default injector constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 90 C9 21 MOV DPTR, #0xC921 ; Set DPTR where it was before we modified the function at CODE_5225 22 RET ; Return ; 0x40: Alt Map #1 B4 40 09 CJNE A, #0x40 +9 90 87 C1 MOV DPTR, #0x87C1 ; Address of Alt Map #1 Injector Constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 90 C9 21 MOV DPTR, #0xC921 ; Set DPTR where it was before we modified the function at CODE_5225 22 RET ; Return ; 0x80: Alt Map #2 B4 80 09 CJNE A, #0x80 +9 90 87 C2 MOV DPTR, #0x87C2 ; Address of Alt Map #2 Injector Constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 90 C9 21 MOV DPTR, #0xC921 ; Set DPTR where it was before we modified the function at CODE_5225 22 RET ; Return ; 0xC0: Alt Map #3 B4 C0 09 CJNE A, #0xC0 +9 90 87 C3 MOV DPTR, #0x87C3 ; Address of Alt Map #3 Injector Constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 90 C9 21 MOV DPTR, #0xC921 ; Set DPTR where it was before we modified the function at CODE_5225 22 RET ; Return ; Failsafe - Shouldn't ever make it here, but in case, use stock constant 90 C9 23 MOV DPTR, #0xC923 ; Address of default injector constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 90 C9 21 MOV DPTR, #0xC921 ; Set DPTR where it was before we modified the function at CODE_5225 22 RET -------------------------------------------------------------------------------------- Map Switcher, Injector Constant For CODE_5447 ; Get Flagbyte, clear lower 6 bits 90 FD AE MOV DPTR, #0xFDAE ; Flagbyte E0 MOVX A, @DPTR ; Get byte to ACC 53 E0 C0 ANL A, 0xC0 ; Zero lower 6 bits of B -- 0x40 = Map 1 // 0x80 = Map 2 // 0xC0 = Map 3 ; 0x00: Stock Map B4 00 06 CJNE A, #0x00 +6 90 C9 23 MOV DPTR, #0xC923 ; Address of default injector constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 22 RET ; Return ; 0x40: Alt Map #1 B4 40 06 CJNE A, #0x40 +6 90 87 C1 MOV DPTR, #0x87C1 ; Address of Alt Map #1 Injector Constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 22 RET ; Return ; 0x80: Alt Map #2 B4 80 06 CJNE A, #0x80 +6 90 87 C2 MOV DPTR, #0x87C2 ; Address of Alt Map #2 Injector Constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 22 RET ; Return ; 0xC0: Alt Map #3 B4 C0 06 CJNE A, #0xC0 +6 90 87 C3 MOV DPTR, #0x87C3 ; Address of Alt Map #3 Injector Constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 22 RET ; Return ; Failsafe - Shouldn't ever make it here, but in case, use stock constant 90 C9 23 MOV DPTR, #0xC923 ; Address of default injector constant E4 CLR A ; Clear A Register 93 MOV A, @A+DPTR ; Move injector constant to ACC 22 RET