diff --git a/avr/modules/lcd2/gui2/base/object.asm b/avr/modules/lcd2/gui2/base/object.asm index bb8828a..ad7c304 100644 --- a/avr/modules/lcd2/gui2/base/object.asm +++ b/avr/modules/lcd2/gui2/base/object.asm @@ -1008,6 +1008,30 @@ objGetPredecessor_ret: +; --------------------------------------------------------------------------- +; @routine OBJ_CountDirectChildren @global +; +; @param Y address of object whose children are to be counted +; @return r16 number of direct children +; @clobbers r18, r19 + +OBJ_CountDirectChildren: + push yl + push yh + clr r16 + rcall OBJ_GetFirstChild +OBJ_CountDirectChildren_loop: + brcc OBJ_CountDirectChildren_done + inc r16 + mov yl, r18 + mov yh, r19 + rcall OBJ_GetNext + rjmp OBJ_CountDirectChildren_loop +OBJ_CountDirectChildren_done: + pop yh + pop yl + ret +; @end