; ***************************************************************************
; copyright   : (C) 2026 by Martin Preuss
; email       : martin@libchipcard.de
;
; ***************************************************************************
; * This file is part of the project "AqHome".                              *
; * Please see toplevel file COPYING of that project for license details.   *
; ***************************************************************************

#ifndef AQH_AVR_GUI2_ROOTWIDGET_ASM
#define AQH_AVR_GUI2_ROOTWIDGET_ASM


; ***************************************************************************
; defines

; RootWidget in flash
.equ ROOTWIDGET_OFFS_BEGIN      =  WIDGET_SIZE
.equ ROOTWIDGET_OFFS_APP_LO     =  ROOTWIDGET_OFFS_BEGIN+0
.equ ROOTWIDGET_OFFS_APP_HI     =  ROOTWIDGET_OFFS_BEGIN+1
.equ ROOTWIDGET_SIZE            =  ROOTWIDGET_OFFS_BEGIN+2



; ***************************************************************************
; code

.cseg



; ---------------------------------------------------------------------------
; @routine RootWidget_GetApp @global
;
; @param  Z       byte address of object (for LPM!)
; @return R19:R18 byte address pointer to GuiApp
; @clobbers none

RootWidget_GetApp:
  bigcall OBJ_IsObject              ; (none)
  brcc RootWidget_GetApp_ret
  adiw zh:zl, ROOTWIDGET_OFFS_APP_LO
  lpm r18, Z+
  lpm r19, Z
  sbiw zh:zl, ROOTWIDGET_OFFS_APP_LO+1
  sec
RootWidget_GetApp_ret:
  ret
; @end



#endif



