Hi mister_e,
good idea:

What i have done is using th original code from Robert Soubie posted on his website.
I made some more remarks and checked all gaainst the MCHIP AppNote AN734, i hope i made no mistake.

1. I initialize the i2c:

'Initialize I2C slave mode
SCLDIR = 1 ' SCL must be made an input before enabling interrupts
SDADIR = 1 ' SDA must be made an input before enabling interrupts
SSPCON = $36 ' configure for i2c 7Bit
gosub read_12c_address ' get address from B0 - B3
SSPSTAT = 0 ' setting some regs...
SSPIE = 1
SSPIF = 0
' PIE1 = 1 ' ?????????
PEIE = 1
GIE = 1
RxBufferIndex = 0
TxBufferIndex = 0

2. In the main program i include the int-handler:

On Interrupt goto int_hand
.... main program parts ....

'***************** INTERRUPT HANDLER ************
Disable
int_hand:
include "i2c_slave_int2.inc"
'INTCON.1 = 0
Resume
Enable
'*********************************************

3. The "i2c_slave_int.inc" you can see here (derived from Robert Soubie)

'*********************************************
'* Name : i2c_slave_int.inc *
'* Author : Ralf Mayr *
'* : Derived from Robert Soubie *
'* Notes : Original Code by Robert Soubie *
'*********************************************


goto i2c_interrupt_handler

'*********************************************
'write TXBuffer to I2C
'*********************************************
write_i2c:

while STAT_BF = 1
i = 0
wend ' loop while buffer is full
wcol = 0 ' clear collision flag
SSPBUF = TxBuffer(TxBufferIndex)
while wcol = 1
wcol = 0
SSPBUF = TxBuffer(TxBufferIndex)
wend
CKP = 1 ' release clock, allowing read by master
TxBufferIndex = TxBufferIndex + 1 ' increment index
if TxBufferIndex = 2 then ' all bytes have been transmitted
TxBufferIndex = 0
int_ready = 1 ' so reset index
endif
goto i2c_interrupt_handler_exit

'***********************************************
'Interrupt handling starts here
'***********************************************
i2c_interrupt_handler:

'mask Status Register first
i2c_Save_Status = SSPSTAT & i2c_slave_mask

'***********************************************
' Write operation, last byte was an address, buffer is full
' BF = 1
' UA = NA
' RW = 0 (we get data)
' S = 1 (Start bit was set)
' P = NA
' DA = 0 (last byte was address)
'***********************************************
State_1:
if i2c_Save_Status <> %00001001 then State_2
i2cTempVAr = SSPBUF ' empty buffer
if sspov then ' overflow occured?
sspov = 0
i2cTempVAr = SSPBUF ' empty buffer
endif
for RxBufferIndex = 0 to 2 ' empty receive buffer
RxBuffer(RxbufferIndex) = 0
next RxBufferIndex
RxBufferIndex = 0 ' reset buffer index
goto i2c_interrupt_handler_exit

'***********************************************
' Write operation, last byte was data, buffer is full
' BF = 1
' UA = NA
' RW = 0 (we get data)
' S = 1 (Start bit was set)
' P = NA
' DA = 1 (last byte was data)
'***********************************************
State_2:
if i2c_Save_Status <> %00101001 then State_3
RxBuffer(RxBufferIndex) = SSPBUF ' read received byte and empty buffer
if sspov then ' overflow occured?
sspov = 0
i2cTempVAr = SSPBUF ' empty buffer
endif
RxBufferIndex = RxBufferIndex + 1 ' point at next empty slot in buffer
goto i2c_interrupt_handler_exit

'***********************************************
' Read operation, last byte was an address, buffer is empty
' BF = unknown ?
' UA = NA
' RW = 1 (we send data)
' S = 1
' P = NA
' DA = 0 (last byte was address)
'***********************************************
State_3:
if i2c_Save_Status <> %00001100 then State_4
goto write_i2c ' write next byte

'***********************************************
' Read operation, last byte was data, buffer is empty
' BF = 0
' UA = NA
' RW = 1 (we send data)
' S = 1 (Start bit was set)
' P = NA
' DA = 1 (last byte send was data)
'***********************************************
State_4:
if i2c_Save_Status <> %00101100 then State_5
goto write_i2c ' write next byte

'***********************************************
' Unknown operation
' BF = 0
' UA = NA
' RW = 0
' S = 1 (Start bit was set)
' P = NA
' DA = 1 (last byte send was data)
'***********************************************
State_5:
if i2c_Save_Status <> %00101000 then State_i2CErr
CKP = 1
goto i2c_interrupt_handler_exit


'***********************************************
' We should never get here... BUT WE GET HERE *g*
'***********************************************
State_i2cErr:
i2c_error = 1

'***********************************************
' Did we receive one command byte and two parameter bytes?
' if so, RxBufferIndex equals 3
'***********************************************
i2c_interrupt_handler_exit:

if rxbufferindex = 3 then
CKP = 0 ' Disable clock
include "Proc_i2c.inc"
rxBufferIndex = 0 ' Reset Rx Buffer index for next time we get a command
TxBufferindex = 0 ' Reset Tx Buffer index for sending two result bytes
int_ready = 1
CKP = 1 ' Enable clock
endif

if sspov then ' overflow occured?
i2cTempVAr = SSPBUF ' empty buffer
sspov = 0
endif

SSPIF = 0 ' reset interrupt flag that took us here

4. The include file "Proc_I2C.inc resolves the vars and their values:

i2c_OutL = RxBuffer(0)
i2c_OutH = $ff
if RxBuffer(0) = "M" then
i2c_OutL = var1
i2c_OutH = "M"
else
if RxBuffer(0) = "I" then
i2c_OutL = var2
i2c_OutH = "I"
else
if RxBuffer(0) = "G" then
i2c_OutL = var3
i2c_OutH = "G"
else
i2c_OutH = $FF 'error unknown command
endif
endif
endif

TxBuffer(0) = i2c_outh
TxBuffer(1) = i2c_outL

5. The masster accesses the slave with I2CWrite and I2CRead, but sometimes the master gets errors and also the slave sets the i2c_eror bit (a variable from me in State_i2cErr).
- The master always sends three bytes (the "id" and the two databytes).
- The master always reads two bytes (two values form the "id "in the write operation before)
Writing to the slave seems to work fine, but reading from the slave results in errors and sometimes senseless values on the master side.