avr: fixed button code.

This commit is contained in:
Martin Preuss
2025-11-18 19:14:40 +01:00
parent 059654b16f
commit b520ccb165
4 changed files with 183 additions and 140 deletions

View File

@@ -68,8 +68,8 @@ buttonDraw:
lpm r13, Z+
rcall buttonClearBackground
rcall buttonDrawText
rcall buttonDrawBorder
rcall buttonDrawText
ret
; @end
@@ -120,11 +120,11 @@ buttonClearBackground_bgFill:
; @clobbers any, !Y, !Z
buttonDrawBorder:
ldi r16, LOW(STYLE_BUTTON_COL_BORDER)
mov r2, r16
ldi r16, HIGH(STYLE_BUTTON_COL_BORDER)
mov r3, r16
bigcall Display_DrawRect
ldi r16, LOW(STYLE_BUTTON_COL_BORDER)
mov r2, r16
ldi r16, HIGH(STYLE_BUTTON_COL_BORDER)
mov r3, r16
bigcall Display_DrawRect
ret
; @end
@@ -143,51 +143,43 @@ buttonDrawBorder:
; @clobbers any, !Y, !Z
buttonDrawText:
push r4
push r5
push r6
push r7
ldi r16, 2
clr r17
add r4, r16 ; x+=2
adc r5, r17
add r6, r16 ; y+=2
adc r7, r17
; set text colors
tst r14
brne buttonDrawText_down
; set background color
ldi r16, LOW(STYLE_BUTTON_COL_BG_NORM)
mov r0, r16
ldi r16, HIGH(STYLE_BUTTON_COL_BG_NORM)
mov r1, r16
; set foreground color
ldi r16, LOW(STYLE_BUTTON_COL_FG_NORM)
mov r2, r16
ldi r16, HIGH(STYLE_BUTTON_COL_FG_NORM)
mov r3, r16
rjmp buttonDrawText_draw
buttonDrawText_down:
; set background color
ldi r16, LOW(STYLE_BUTTON_COL_BG_PRESSED)
mov r0, r16
ldi r16, HIGH(STYLE_BUTTON_COL_BG_PRESSED)
mov r1, r16
; set foreground color
ldi r16, LOW(STYLE_BUTTON_COL_FG_PRESSED)
mov r2, r16
ldi r16, HIGH(STYLE_BUTTON_COL_FG_PRESSED)
mov r3, r16
buttonDrawText_draw:
mov zl, r12
mov zh, r13
bigcall Window_DrawColorTextFlash
pop r7
pop r6
pop r5
pop r4
ldi r16, 2
clr r17
add r4, r16 ; x+=2
adc r5, r17
add r6, r16 ; y+=2
adc r7, r17
; set text colors
tst r14
brne buttonDrawText_down
; set background color
ldi r16, LOW(STYLE_BUTTON_COL_BG_NORM)
mov r0, r16
ldi r16, HIGH(STYLE_BUTTON_COL_BG_NORM)
mov r1, r16
; set foreground color
ldi r16, LOW(STYLE_BUTTON_COL_FG_NORM)
mov r2, r16
ldi r16, HIGH(STYLE_BUTTON_COL_FG_NORM)
mov r3, r16
rjmp buttonDrawText_draw
buttonDrawText_down:
; set background color
ldi r16, LOW(STYLE_BUTTON_COL_BG_PRESSED)
mov r0, r16
ldi r16, HIGH(STYLE_BUTTON_COL_BG_PRESSED)
mov r1, r16
; set foreground color
ldi r16, LOW(STYLE_BUTTON_COL_FG_PRESSED)
mov r2, r16
ldi r16, HIGH(STYLE_BUTTON_COL_FG_PRESSED)
mov r3, r16
buttonDrawText_draw:
mov zl, r12
mov zh, r13
bigcall Window_DrawColorTextFlash
ret
; @end