smaller button routines.
This commit is contained in:
@@ -64,78 +64,130 @@ buttonDraw:
|
||||
lpm r9, Z+
|
||||
lpm r10, Z+ ; H
|
||||
lpm r11, Z+
|
||||
lpm r12, Z+ ; text
|
||||
lpm r13, Z+
|
||||
|
||||
; clear background
|
||||
push zl
|
||||
push zh
|
||||
rcall buttonClearBackground
|
||||
rcall buttonDrawText
|
||||
rcall buttonDrawBorder
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonClearBackground
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param r5:r4 X
|
||||
; @param r7:r6 Y
|
||||
; @param r9:r8 W
|
||||
; @param r11:r10 H
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @clobbers any, !Y, !Z
|
||||
|
||||
buttonClearBackground:
|
||||
tst r14
|
||||
brne buttonDraw_bgDown
|
||||
brne buttonClearBackground_bgDown
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_NORM)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_NORM)
|
||||
mov r3, r16
|
||||
rjmp buttonDraw_bgFill
|
||||
buttonDraw_bgDown:
|
||||
rjmp buttonClearBackground_bgFill
|
||||
buttonClearBackground_bgDown:
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r3, r16
|
||||
buttonDraw_bgFill:
|
||||
buttonClearBackground_bgFill:
|
||||
bigcall Display_FillRect
|
||||
pop zh
|
||||
pop zl
|
||||
|
||||
; draw border
|
||||
push zl
|
||||
push zh
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonDrawBorder
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param r5:r4 X
|
||||
; @param r7:r6 Y
|
||||
; @param r9:r8 W
|
||||
; @param r11:r10 H
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @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
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
ldi r16, 2
|
||||
clr r17
|
||||
add r4, r16 ; x+=2
|
||||
adc r5, r17
|
||||
add r6, r16 ; y+=2
|
||||
adc r7, r17
|
||||
|
||||
lpm r16, Z+ ; text
|
||||
lpm r17, Z+
|
||||
mov zl, r16
|
||||
mov zh, r17
|
||||
|
||||
; set text colors
|
||||
tst r14
|
||||
brne buttonDraw_textDown
|
||||
; 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 buttonDraw_textDraw
|
||||
buttonDraw_textDown:
|
||||
; 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
|
||||
buttonDraw_textDraw:
|
||||
bigcall Window_DrawColorTextFlash
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonDrawText
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param r5:r4 X
|
||||
; @param r7:r6 Y
|
||||
; @param r9:r8 W
|
||||
; @param r11:r10 H
|
||||
; @param r13:r12 Text in FLASH
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @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
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user