;
; File generated by cc65 v 2.15 - Git f7cdfbf
;
	.fopt		compiler,"cc65 v 2.15 - Git f7cdfbf"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	off
	.importzp	sp, sreg, regsave, regbank
	.importzp	tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
	.macpack	longbranch
	.import		_sprintf
	.export		_debug_keys
	.export		_debug_key_matrix
	.import		_keys_update
	.import		_keys_getc
	.import		_keys_get_code
	.import		_keys_get_modifiers
	.import		_keys_read_row
	.import		_lcd_putc
	.import		_lcd_puts
	.import		_lcd_goto
	.import		_led_set
	.importzp	_millis
	.export		_outbuf
	.export		_led
	.export		_next_blink_millis
	.export		_debug_blink

.segment	"DATA"

_led:
	.byte	$00
_next_blink_millis:
	.dword	$00000000

.segment	"RODATA"

L0011:
	.byte	$25,$30,$33,$64,$20,$25,$30,$32,$78,$20,$25,$63,$00

.segment	"BSS"

_outbuf:
	.res	41,$00

; ---------------------------------------------------------------
; void __near__ debug_keys (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_debug_keys: near

.segment	"CODE"

L000D:	jsr     _keys_update
	lda     #<(_outbuf)
	ldx     #>(_outbuf)
	jsr     pushax
	lda     #<(L0011)
	ldx     #>(L0011)
	jsr     pushax
	jsr     _keys_get_code
	jsr     pusha0
	jsr     _keys_get_modifiers
	jsr     pusha0
	jsr     _keys_getc
	jsr     pushax
	ldy     #$0A
	jsr     _sprintf
	lda     #$00
	jsr     pusha
	jsr     _lcd_goto
	lda     #<(_outbuf)
	ldx     #>(_outbuf)
	jsr     _lcd_puts
	jmp     L000D

.endproc

; ---------------------------------------------------------------
; void __near__ debug_key_matrix (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_debug_key_matrix: near

.segment	"CODE"

	jsr     decsp2
L0069:	lda     #$00
	ldy     #$01
L0068:	sta     (sp),y
	cmp     #$0E
	bcs     L0069
	ldx     #$00
	lda     (sp),y
	lsr     a
	lsr     a
	jsr     mulax10
	jsr     pusha
	ldy     #$02
	lda     (sp),y
	and     #$03
	jsr     _lcd_goto
	ldy     #$01
	lda     (sp),y
	jsr     _keys_read_row
	ldy     #$00
	sta     (sp),y
	and     #$80
	beq     L006A
	lda     #$31
	jmp     L006B
L006A:	lda     #$30
L006B:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$40
	beq     L006C
	lda     #$31
	jmp     L006D
L006C:	lda     #$30
L006D:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$20
	beq     L006E
	lda     #$31
	jmp     L006F
L006E:	lda     #$30
L006F:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$10
	beq     L0070
	lda     #$31
	jmp     L0071
L0070:	lda     #$30
L0071:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$08
	beq     L0072
	lda     #$31
	jmp     L0073
L0072:	lda     #$30
L0073:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$04
	beq     L0074
	lda     #$31
	jmp     L0075
L0074:	lda     #$30
L0075:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$02
	beq     L0076
	lda     #$31
	jmp     L0077
L0076:	lda     #$30
L0077:	jsr     _lcd_putc
	ldy     #$00
	lda     (sp),y
	and     #$01
	beq     L0078
	lda     #$31
	jmp     L0079
L0078:	lda     #$30
L0079:	jsr     _lcd_putc
	ldy     #$01
	clc
	tya
	adc     (sp),y
	jmp     L0068

.endproc

; ---------------------------------------------------------------
; void __near__ debug_blink (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_debug_blink: near

.segment	"CODE"

	lda     _millis+3
	sta     sreg+1
	lda     _millis+2
	sta     sreg
	ldx     _millis+1
	lda     _millis
	jsr     pusheax
	lda     _next_blink_millis+3
	sta     sreg+1
	lda     _next_blink_millis+2
	sta     sreg
	ldx     _next_blink_millis+1
	lda     _next_blink_millis
	jsr     tosugteax
	beq     L0060
	lda     _millis+3
	sta     sreg+1
	lda     _millis+2
	sta     sreg
	ldx     _millis+1
	lda     _millis
	jsr     pusheax
	ldx     #$01
	lda     #$00
	lda     #$F4
	jsr     tosadd0ax
	sta     _next_blink_millis
	stx     _next_blink_millis+1
	ldy     sreg
	sty     _next_blink_millis+2
	ldy     sreg+1
	sty     _next_blink_millis+3
	lda     _led
	jsr     _led_set
	lda     _led
	jsr     bnega
	sta     _led
L0060:	rts

.endproc

