UCT
UCI
UCP
-URM
# Messages for i2clib, S*
SM i2clib+panic:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state
# R - Reversers (polarity)
RS FSR0L ; POLARITY message too short
RL FSR0L ; POLARITY message too long
+RF ; master board has no reversers
+RG ; too many reversers boards
# P - Points
PB points:pointmsg ; Firing point when already busy
res maxpics+1
; Each byte is:
; 11RRRRRR reverse command for slave, waiting to write
- ; 00000001 this is not a reversers pic
+ ; 00000001 this is not a reversers board
; 00000000 we have written any relevant command
; 01000000 sentinel
;----------------------------------------------------------------------
polarity_master_init
- panic morse_URM
- ; need to set up polarity_cmds
+
+ load_tblptr picno2revmasks
+ mov_lfsr polarity_cmds - 1, 0
+ mov_lw maxpics
+ mov_wf t
+ mov_lw 0x01 ; meaning `not a reversers board'
+polarity_master_init_boardloop
+ mov_wf PREINC0
+ rcall polarity_master_init_board_mask_check
+ rcall polarity_master_init_board_mask_check
+ dec_f_ifnz t
+ bra polarity_master_init_boardloop
+
+ tst_f_ifnz polarity_cmds
+ bra polarity_bad_masternotused
+
+ ; OK, but now we have to work our way back and place
+ ; the sentinel
+ mov_lw 0x40 ; meaning `sentinel'
+ tst_f_ifnz INDF0
+ bra polarity_bad_lastpicused
+polarity_master_init_truncateloop
+ mov_wf POSTDEC0 ; overwrite with sentinel
+ tst_f_ifnz INDF0 ; previous one is also `not reversers board' ?
+ bra polarity_master_init_truncateloop ; yes
+ ; no. hah, we have truncated it.
+
+ return
+
+polarity_master_init_board_mask_check
+ tblrd_postinc_fixup
+ tst_f_ifnz TABLAT
+ clr_f INDF0 ; meaning `reversers board but no command to send'
+ return
+
+polarity_bad_masternotused panic morse_RF
+polarity_bad_lastpicused panic morse_RG
;----------------------------------------------------------------------
polarity_needwrite