having an issue here with a usercmd macro overwriting an array boundary and I'm at a loss to understand what I'm doing wrong ,
attached is a safer version of the touch screen addin.
problem is , lets say I have defined number_of_buttons con 9
vars are defined by button_Taddr VAR byte[number_of_buttons*3]
by my count that's 27 bytes
I usercmd a button the nineth button
MAKEBUTTON 34,216,8,40
in the macro k=Button*3 which should be 24
so
movlw 0
movwf _button_Taddr +k
movwf _button_Taddr +k+1
movwf _button_Taddr +k+2
should place 0 into button_Taddr[24-26]
but something else gets clobbered instead , buttons 0-7 seem ok but I might be wrong
Code:
MAKEBUTTON?CCCC macro X0in ,Y0in ,Button ,Szin ;sqr button no text
k=Button*3 ;
j=Button*2 ;1 WORD PER BUTTON
i=Button*6 ;3 WORDS PER BUTTON
if Button <8
bcf _button_action ,Button
bcf _button_rpt ,Button
bcf _button_set ,Button
else
bcf _button_action+1 ,Button-8
bcf _button_rpt+1 ,Button-8
bcf _button_set+1 ,Button-8
endif
MOVE?CW Szin ,_button_xsize+ j
MOVE?CW Szin ,_button_ysize+ j
MOVE?CB 0 , _BUTTON_STATE + Button
; movlw 0
; movwf _button_Taddr +k
; movwf _button_Taddr +k+1
; movwf _button_Taddr +k+2
MOVE?CW 0 ,button_count +i
MOVE?CW X0in ,button_X +i
MOVE?CW Y0in ,button_Y +i
MOVE?CW 0, _button_Tsize + j
endm