\* Subcell list. Routines to set up a list (sub-list) of subcells for each of the 16 bit slices. This is useful for diplay and i/o purposes. *\ variable sub-list : sl! (s val slice -- ) /l* sub-list @ + ! ; : sl@ (s slice -- val ) /l* sub-list @ + @ ; : sl-subcell (s n sublist -- ) sub-list ! 16 0 do dup i sl! loop drop ; 0 constant slf-subcell 0 constant slf-#bits : sl-fields (s cfa1 ... cfaN N sublist -- ) 0 swap sl-subcell dup 0= if drop exit then dup 0< abort" Use { }" dup >r reverse 0 r> 0 ?do over >field-mask @ count-ones is slf-#bits swap >field-subcell @ is slf-subcell dup slf-#bits bounds ?do i 16 >= abort" Too many fields." slf-subcell i sl! loop slf-#bits + loop ; \* Since all subcell information is saved before display and restored after the display, this selection is completely independent of the cell updating. "io-sub-list" is a similar array used for i/o operations. *\ create show-sub-list 16 /l* allot create io-sub-list 16 /l* allot : show-subcell (s n -- ) show-sub-list sl-subcell regen ; : show-fields (s cfa1 ... cfaN N -- ) show-sub-list sl-fields regen ; : io-subcell (s n -- ) io-sub-list sl-subcell ; : io-fields (s cfa1 ... cfaN N -- ) io-sub-list sl-fields ; : show>io show-sub-list io-sub-list 16 /l* cmove ; : io>show io-sub-list show-sub-list 16 /l* cmove ; : init-sub-list 0 show-subcell show>io ; variable showing-subcells? create show-sub-list 16 /l* allot : showsc showing-subcells? on ; : show-subcell (s n -- ) show-sub-list sl-subcell regen showsc ; : show-fields (s cfa1 ... cfaN N -- ) show-sub-list sl-fields regen showsc ; : show-active-fields showing-subcells? off regen ; : show>io show-sub-list io-sub-list 16 /l* cmove ; : io>show io-sub-list show-sub-list 16 /l* cmove ; : init-show-fields 0 show-subcell show-active-fields ;