From 35a45e5cb2f3f0e4e81c30c318846409b63cf145 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 9 May 2026 01:58:38 +0200 Subject: [PATCH] gui: fixed some bugs. calling a dialog from another basically works now. --- avr/modules/lcd2/gui/base/object.asm | 71 +++++++++++++++++++++------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/avr/modules/lcd2/gui/base/object.asm b/avr/modules/lcd2/gui/base/object.asm index 32e43ca..0a08f01 100644 --- a/avr/modules/lcd2/gui/base/object.asm +++ b/avr/modules/lcd2/gui/base/object.asm @@ -388,6 +388,44 @@ OBJ_GetChildBySelector_ret: +; --------------------------------------------------------------------------- +; @routine OBJ_TreeDestroyMarked @global +; +; @param Y address of root object +; @clobbers any + +OBJ_TreeDestroyMarked: + ldd r16, Y+OBJECT_OFFS_FLAGS + sbrc r16, OBJECT_FLAGS_DESTROY_BIT + rjmp OBJ_TreeDestroyMarked_destroy + + rcall OBJ_GetFirstChild ; R19:R18=obj (none) + brcc OBJ_TreeDestroyMarked_ret +OBJ_TreeDestroyMarked_loop: + mov yl, r18 + mov yh, r19 + rcall OBJ_GetNext ; R19:R18=obj (none) + brcs OBJ_TreeDestroyMarked_handleChild + clr r18 + clr r19 +OBJ_TreeDestroyMarked_handleChild: + push r18 + push r19 + rcall OBJ_TreeDestroyMarked ; recursion + pop r19 + pop r18 + mov r16, r18 + or r16, r19 + breq OBJ_TreeDestroyMarked_ret + rjmp OBJ_TreeDestroyMarked_loop +OBJ_TreeDestroyMarked_destroy: + rcall OBJ_Free +OBJ_TreeDestroyMarked_ret: + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine OBJ_SkipObjects @global ; @@ -484,15 +522,11 @@ objAddObjXAsChildToY_setParent: ; @routine OBJ_Unlink @global ; ; @param Y object to unlink -; @clobbers r16, r17, r18, r19, r20, r21, X +; @clobbers r16, r17, r18, r19, r20, r21 OBJ_Unlink: - mov xl, yl - mov xh, yh - adiw xh:xl, OBJECT_OFFS_NEXT_LO ; r21:r20=next - ld r20, X+ - ld r21, X - sbiw xh:xl, (OBJECT_OFFS_NEXT_LO+1) + ldd r20, Y+OBJECT_OFFS_NEXT_LO ; r21:r20=next + ldd r21, Y+OBJECT_OFFS_NEXT_HI push yl push yh @@ -810,16 +844,17 @@ OBJ_TreeHandleSignalChildenFirst_loop: mov yl, r18 mov yh, r19 rcall OBJ_GetNext ; r19:r18=object (none) - ldi r20, 0 - sbci r20, 0 + brcs OBJ_TreeHandleSignalChildenFirst_handle + clr r18 + clr r19 +OBJ_TreeHandleSignalChildenFirst_handle: push r18 push r19 - push r20 rcall OBJ_TreeHandleSignalChildenFirst ; recursion! - pop r20 pop r19 pop r18 - tst r20 ; result of OBJ_GetNext (0=no next) + mov r20, r18 + or r20, r19 brne OBJ_TreeHandleSignalChildenFirst_loop OBJ_TreeHandleSignalChildenFirst_done: pop yh @@ -1020,16 +1055,18 @@ objGetHandlerFromSignalMap_done: ; @clobbers r16, r17, Y objGetPredecessor: - rcall OBJ_GetParent - brcc objGetPredecessor_ret - mov r16, yl + mov r16, yl ; R17:R16=object whose predecessor we look for mov r17, yh - rcall OBJ_GetFirstChild ; R19:R18=obj + rcall OBJ_GetParent ; R19:R18=obj (none) + brcc objGetPredecessor_ret + mov yl, r18 + mov yh, r19 + rcall OBJ_GetFirstChild ; R19:R18=obj (none) brcc objGetPredecessor_ret mov yl, r18 mov yh, r19 objGetPredecessor_loop: - rcall OBJ_GetNext + rcall OBJ_GetNext ; R19:R18=obj (none) brcc objGetPredecessor_ret cp r18, r16 brne objGetPredecessor_next