	cpu LMM
	.module pad.c
	.area text(rom, con, rel)
	.dbfile ./pad.c
	.dbfunc e pad_waitForAck _pad_waitForAck fV
;      starttime -> X+0
_pad_waitForAck::
	.dbline -1
	push X
	mov X,SP
	add SP,4
	.dbline 16
; #include "pad.h"
; #include "main.h"
; #include "ed_host_int.h"
; #include "ed_slave_int.h"
; #include "ed_pad_int.h"
; #include <string.h>
; #include "util.h"
; 
; void pad_waitForAck(void);
; 
; extern unsigned char pad_ack_flag;
; 
; #define PADTIMEOUT 100L
; 
; void pad_waitForAck()
; {
	.dbline 17
; 	long starttime=sleepcounter;
	mov REG[0xd0],>_sleepcounter
	mov A,[_sleepcounter+1]
	mov [X+3],A
	mov A,[_sleepcounter]
	mov [X+2],A
	mov [X+1],0
	mov [X+0],0
	.dbline 19
; 	
; 	pad_ack_flag=0;
	mov REG[0xd0],>_pad_ack_flag
	mov [_pad_ack_flag],0
	xjmp L3
L2:
	.dbline 22
; 	
; 	while (!pad_ack_flag)
; 	{
	.dbline 23
; 		if ((sleepcounter-starttime)>PADTIMEOUT)
	mov REG[0xd0],>_sleepcounter
	mov A,[_sleepcounter+1]
	mov REG[0xd0],>__r0
	mov [__r3],A
	mov REG[0xd0],>_sleepcounter
	mov A,[_sleepcounter]
	mov REG[0xd0],>__r0
	mov [__r2],A
	mov [__r1],0
	mov [__r0],0
	mov A,[X+3]
	sub [__r3],A
	mov A,[X+2]
	sbb [__r2],A
	mov A,[X+1]
	sbb [__r1],A
	mov A,[X+0]
	sbb [__r0],A
	mov A,100
	sub A,[__r3]
	mov A,0
	sbb A,[__r2]
	mov A,0
	sbb A,[__r1]
	mov A,[__r0]
	xor A,-128
	mov [__rX],A
	mov A,(0 ^ 0x80)
	sbb A,[__rX]
	jnc L5
X0:
	.dbline 24
; 		{
	.dbline 25
; 			commerror(4);
	mov A,4
	push A
	xcall _commerror
	add SP,-1
	.dbline 26
; 			break;
	xjmp L4
L5:
	.dbline 28
	xcall _idle
	.dbline 29
L3:
	.dbline 21
	mov REG[0xd0],>_pad_ack_flag
	cmp [_pad_ack_flag],0
	jz L2
L4:
	.dbline 31
; 		}
; 		idle();
; 	}
; 	
; 	pad_ack_flag=0;
	mov REG[0xd0],>_pad_ack_flag
	mov [_pad_ack_flag],0
	.dbline -2
	.dbline 32
; }
L1:
	add SP,-4
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l starttime 0 L
	.dbend
	.dbfunc e pad_LcdPrintC _pad_LcdPrintC fV
;            len -> X+1
;            chk -> X+0
;           cstr -> X-8
;           font -> X-6
;              y -> X-5
;              x -> X-4
_pad_LcdPrintC::
	.dbline -1
	push X
	mov X,SP
	add SP,2
	.dbline 35
; 
; void pad_LcdPrintC(unsigned char x, unsigned char y, unsigned char font, const char *cstr)
; {
	.dbline 36
; 	unsigned char chk=0;
	mov [X+0],0
	.dbline 37
; 	unsigned char len=cstrlen(cstr);
	mov A,[X-8]
	push A
	mov A,[X-7]
	push A
	xcall _cstrlenLMM
	mov REG[0xd0],>__r0
	mov A,[__r1]
	mov [X+1],A
	.dbline 39
; 	
; 	pad_ack_flag=0;
	mov REG[0xd0],>_pad_ack_flag
	mov [_pad_ack_flag],0
	.dbline 41
; 	
; 	chk = pad_chksend(chk, 237);
	mov A,-19
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 42
; 	chk = pad_chksend(chk, len+8);
	mov A,[X+1]
	add A,8
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 43
; 	chk = pad_chksend(chk, 0xc0);
	mov A,-64
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 44
; 	chk = pad_chksend(chk, 'T');
	mov A,84
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 45
; 	chk = pad_chksend(chk, x);
	mov A,[X-4]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 46
; 	chk = pad_chksend(chk, y);
	mov A,[X-5]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 47
; 	chk = pad_chksend(chk, font);
	mov A,[X-6]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 48
; 	chk = pad_chksend_cstring(chk, cstr);
	mov A,[X-8]
	push A
	mov A,[X-7]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend_cstring
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 49
; 	chk = pad_chksend(chk, chk);
	mov A,[X+0]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-5
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 51
; 
; 	pad_waitForAck();
	xcall _pad_waitForAck
	.dbline -2
	.dbline 52
; }
L7:
	add SP,-2
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l len 1 c
	.dbsym l chk 0 c
	.dbsym l cstr -8 pc
	.dbsym l font -6 c
	.dbsym l y -5 c
	.dbsym l x -4 c
	.dbend
	.dbfunc e pad_LcdPrint _pad_LcdPrint fV
;            len -> X+1
;            chk -> X+0
;            str -> X-8
;           font -> X-6
;              y -> X-5
;              x -> X-4
_pad_LcdPrint::
	.dbline -1
	push X
	mov X,SP
	add SP,2
	.dbline 55
; 
; void pad_LcdPrint(unsigned char x, unsigned char y, unsigned char font,  char *str)
; {
	.dbline 56
; 	unsigned char chk=0;
	mov [X+0],0
	.dbline 57
; 	unsigned char len=strlen(str);
	mov A,[X-8]
	push A
	mov A,[X-7]
	push A
	xcall _strlenLMM
	mov REG[0xd0],>__r0
	mov A,[__r1]
	mov [X+1],A
	.dbline 59
; 	
; 	pad_ack_flag=0;
	mov REG[0xd0],>_pad_ack_flag
	mov [_pad_ack_flag],0
	.dbline 61
; 	
; 	chk = pad_chksend(chk, 237);
	mov A,-19
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 62
; 	chk = pad_chksend(chk, len+8);
	mov A,[X+1]
	add A,8
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 63
; 	chk = pad_chksend(chk, 0xc0);
	mov A,-64
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 64
; 	chk = pad_chksend(chk, 'T');
	mov A,84
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 65
; 	chk = pad_chksend(chk, x);
	mov A,[X-4]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 66
; 	chk = pad_chksend(chk, y);
	mov A,[X-5]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 67
; 	chk = pad_chksend(chk, font);
	mov A,[X-6]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 68
; 	chk = pad_chksend_string(chk, str);
	mov A,[X-8]
	push A
	mov A,[X-7]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend_string
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 69
; 	chk = pad_chksend(chk, chk);
	mov A,[X+0]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-5
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 71
; 
; 	pad_waitForAck();
	xcall _pad_waitForAck
	.dbline -2
	.dbline 72
; }
L8:
	add SP,-2
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l len 1 c
	.dbsym l chk 0 c
	.dbsym l str -8 pc
	.dbsym l font -6 c
	.dbsym l y -5 c
	.dbsym l x -4 c
	.dbend
	.dbfunc e pad_LcdClear _pad_LcdClear fV
;            chk -> X+0
_pad_LcdClear::
	.dbline -1
	push X
	mov X,SP
	add SP,1
	.dbline 76
; 
; 
; void pad_LcdClear()
; {
	.dbline 77
; 	unsigned char chk=0;
	mov [X+0],0
	.dbline 79
; 
; 	pad_ack_flag=0;
	mov REG[0xd0],>_pad_ack_flag
	mov [_pad_ack_flag],0
	.dbline 81
; 		
; 	chk = pad_chksend(chk, 237);
	mov A,-19
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-2
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 82
; 	chk = pad_chksend(chk, 5);
	mov A,5
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 83
; 	chk = pad_chksend(chk, 0xc0);
	mov A,-64
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 84
; 	chk = pad_chksend(chk, 'C');
	mov A,67
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 85
; 	chk = pad_chksend(chk, chk);
	mov A,[X+0]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 87
; 
; 	pad_waitForAck();
	xcall _pad_waitForAck
	.dbline -2
	.dbline 88
; }
L9:
	add SP,-1
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l chk 0 c
	.dbend
	.dbfunc e pad_ConsoleWriteC _pad_ConsoleWriteC fV
;            len -> X+1
;            chk -> X+0
;           cstr -> X-5
_pad_ConsoleWriteC::
	.dbline -1
	push X
	mov X,SP
	add SP,2
	.dbline 92
; 
; 
; void pad_ConsoleWriteC(const char *cstr)
; {
	.dbline 93
; 	unsigned char chk=0;
	mov [X+0],0
	.dbline 94
; 	unsigned char len=cstrlen(cstr);
	mov A,[X-5]
	push A
	mov A,[X-4]
	push A
	xcall _cstrlenLMM
	add SP,-2
	mov REG[0xd0],>__r0
	mov A,[__r1]
	mov [X+1],A
	.dbline 96
; 	
; 	chk = pad_chksend(chk, 237);
	mov A,-19
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 97
; 	chk = pad_chksend(chk, len+5);
	mov A,[X+1]
	add A,5
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 98
; 	chk = pad_chksend(chk, 0xc0);
	mov A,-64
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 99
; 	chk = pad_chksend(chk, 'W');
	mov A,87
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 100
; 	chk = pad_chksend_cstring(chk, cstr);
	mov A,[X-5]
	push A
	mov A,[X-4]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend_cstring
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 101
; 	pad_chksend(chk, chk);
	mov A,[X+0]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-5
	mov REG[0xd0],>__r0
	.dbline -2
	.dbline 102
; }
L10:
	add SP,-2
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l len 1 c
	.dbsym l chk 0 c
	.dbsym l cstr -5 pc
	.dbend
	.dbfunc e pad_ConsoleWrite _pad_ConsoleWrite fV
;            len -> X+1
;            chk -> X+0
;            str -> X-5
_pad_ConsoleWrite::
	.dbline -1
	push X
	mov X,SP
	add SP,2
	.dbline 105
; 
; void pad_ConsoleWrite(char *str)
; {
	.dbline 106
; 	unsigned char chk=0;
	mov [X+0],0
	.dbline 107
; 	unsigned char len=strlen(str);
	mov A,[X-5]
	push A
	mov A,[X-4]
	push A
	xcall _strlenLMM
	add SP,-2
	mov REG[0xd0],>__r0
	mov A,[__r1]
	mov [X+1],A
	.dbline 109
; 	
; 	chk = pad_chksend(chk, 237);
	mov A,-19
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 110
; 	chk = pad_chksend(chk, len+5);
	mov A,[X+1]
	add A,5
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 111
; 	chk = pad_chksend(chk, 0xc0);
	mov A,-64
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 112
; 	chk = pad_chksend(chk, 'W');
	mov A,87
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 113
; 	chk = pad_chksend_string(chk, str);
	mov A,[X-5]
	push A
	mov A,[X-4]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend_string
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 114
; 	pad_chksend(chk, chk);
	mov A,[X+0]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-5
	mov REG[0xd0],>__r0
	.dbline -2
	.dbline 115
; }
L11:
	add SP,-2
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l len 1 c
	.dbsym l chk 0 c
	.dbsym l str -5 pc
	.dbend
	.dbfunc e pad_ConsoleWriteInt _pad_ConsoleWriteInt fV
;            buf -> X+1
;            chk -> X+0
;            len -> X-6
;              v -> X-5
_pad_ConsoleWriteInt::
	.dbline -1
	push X
	mov X,SP
	add SP,6
	.dbline 118
; 
; void pad_ConsoleWriteInt(int v, unsigned char len)
; {
	.dbline 120
; 	unsigned char buf[5];
; 	unsigned char chk=0;
	mov [X+0],0
	.dbline 122
; 	
; 	formatInt(v, buf, len);
	mov A,[X-6]
	push A
	mov REG[0xd0],>__r0
	mov [__r1],X
	add [__r1],1
	mov A,7
	push A
	mov A,[__r1]
	push A
	mov A,[X-5]
	push A
	mov A,[X-4]
	push A
	xcall _formatInt
	add SP,-5
	.dbline 124
; 
; 	chk = pad_chksend(chk, 237);
	mov A,-19
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 125
; 	chk = pad_chksend(chk, len+5);
	mov A,[X-6]
	add A,5
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 126
; 	chk = pad_chksend(chk, 0xc0);
	mov A,-64
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 127
; 	chk = pad_chksend(chk, 'W');
	mov A,87
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-4
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 128
; 	chk = pad_chksend_string(chk, buf);
	mov [__r1],X
	add [__r1],1
	mov A,7
	push A
	mov A,[__r1]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend_string
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 129
; 	pad_chksend(chk, chk);
	mov A,[X+0]
	push A
	mov A,[X+0]
	push A
	xcall _pad_chksend
	add SP,-5
	mov REG[0xd0],>__r0
	.dbline -2
	.dbline 130
; }
L12:
	add SP,-6
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l buf 1 A[5:5]c
	.dbsym l chk 0 c
	.dbsym l len -6 c
	.dbsym l v -5 I
	.dbend
	.dbfunc e pad_chksend _pad_chksend fc
;              c -> X-5
;            chk -> X-4
_pad_chksend::
	.dbline -1
	push X
	mov X,SP
	add SP,2
	.dbline 133
; 
; unsigned char pad_chksend(unsigned char chk, unsigned char c)
; {
	.dbline 134
; 	ED_PAD_putData(c);
	push X
	mov A,[X-5]
	xcall _ED_PAD_putData
	pop X
	.dbline 135
; 	return (chk<<1)+c+(chk&0x80 ? 1: 0);
	tst [X-4],-128
	jz L15
	mov [X+1],1
	mov [X+0],0
	xjmp L16
L15:
	mov [X+1],0
	mov [X+0],0
L16:
	mov REG[0xd0],>__r0
	mov A,[X-4]
	mov [__r1],A
	asl [__r1]
	mov A,[X-5]
	add [__r1],A
	mov A,[X+1]
	add [__r1],A
	mov A,[__r1]
	.dbline -2
L13:
	add SP,-2
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l c -5 c
	.dbsym l chk -4 c
	.dbend
	.dbfunc e pad_chksend_cstring _pad_chksend_cstring fc
;              i -> X+0
;              s -> X-6
;            chk -> X-4
_pad_chksend_cstring::
	.dbline -1
	push X
	mov X,SP
	add SP,1
	.dbline 139
; }
; 
; unsigned char pad_chksend_cstring(unsigned char chk, const char *s)
; {
	.dbline 140
; 	unsigned char i=0;
	mov [X+0],0
	xjmp L19
L18:
	.dbline 143
	.dbline 144
	mov REG[0xd0],>__r0
	mov A,[X+0]
	mov [__r1],A
	mov [__r0],0
	mov A,[X-5]
	add [__r1],A
	mov A,[X-6]
	adc [__r0],A
	mov A,[__r0]
	push X
	mov X,[__r1]
	romx
	pop X
	push A
	mov A,[X-4]
	push A
	xcall _pad_chksend
	add SP,-2
	mov REG[0xd0],>__r0
	mov [X-4],A
	.dbline 145
	inc [X+0]
	.dbline 146
L19:
	.dbline 142
; 	
; 	while (s[i]!=0)
	mov REG[0xd0],>__r0
	mov A,[X+0]
	mov [__r1],A
	mov [__r0],0
	mov A,[X-5]
	add [__r1],A
	mov A,[X-6]
	adc [__r0],A
	mov A,[__r0]
	push X
	mov X,[__r1]
	romx
	pop X
	cmp A,0
	jnz L18
	.dbline 148
; 	{
; 		chk = pad_chksend(chk, s[i]);
; 		i++;
; 	}
; 	
; 	return chk;
	mov A,[X-4]
	.dbline -2
L17:
	add SP,-1
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l i 0 c
	.dbsym l s -6 pc
	.dbsym l chk -4 c
	.dbend
	.dbfunc e pad_chksend_string _pad_chksend_string fc
;              i -> X+0
;              s -> X-6
;            chk -> X-4
_pad_chksend_string::
	.dbline -1
	push X
	mov X,SP
	add SP,1
	.dbline 152
; }
; 
; unsigned char pad_chksend_string(unsigned char chk, char *s)
; {
	.dbline 153
; 	unsigned char i=0;
	mov [X+0],0
	xjmp L23
L22:
	.dbline 156
	.dbline 157
	mov REG[0xd0],>__r0
	mov A,[X+0]
	mov [__r1],A
	mov [__r0],0
	mov A,[X-5]
	add [__r1],A
	mov A,[X-6]
	adc [__r0],A
	mov A,[__r0]
	mov REG[0xd4],A
	mvi A,[__r1]
	push A
	mov A,[X-4]
	push A
	xcall _pad_chksend
	add SP,-2
	mov REG[0xd0],>__r0
	mov [X-4],A
	.dbline 158
	inc [X+0]
	.dbline 159
L23:
	.dbline 155
; 	
; 	while (s[i]!=0)
	mov REG[0xd0],>__r0
	mov A,[X+0]
	mov [__r1],A
	mov [__r0],0
	mov A,[X-5]
	add [__r1],A
	mov A,[X-6]
	adc [__r0],A
	mov A,[__r0]
	mov REG[0xd4],A
	mvi A,[__r1]
	cmp A,0
	jnz L22
	.dbline 161
; 	{
; 		chk = pad_chksend(chk, s[i]);
; 		i++;
; 	}
; 	
; 	return chk;
	mov A,[X-4]
	.dbline -2
L21:
	add SP,-1
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l i 0 c
	.dbsym l s -6 pc
	.dbsym l chk -4 c
	.dbend
	.dbfunc e pad_waitButtonRelease _pad_waitButtonRelease fV
_pad_waitButtonRelease::
	.dbline -1
	.dbline 165
; }
; 
; void pad_waitButtonRelease()
; {
	xjmp L27
L26:
	.dbline 167
	xcall _idle
L27:
	.dbline 166
; 	while (pad_buttons!=0)
	mov REG[0xd0],>_pad_buttons
	cmp [_pad_buttons],0
	jnz L26
	.dbline -2
	.dbline 168
; 		idle();
; }
L25:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e pad_gets _pad_gets fc
;       old_left -> X+4
;      old_right -> X+3
;       old_down -> X+2
;         old_up -> X+1
;              b -> X+0
_pad_gets::
	.dbline -1
	push X
	mov X,SP
	add SP,5
	.dbline 171
; 
; unsigned char pad_gets()
; {
	.dbline 175
; 	unsigned char old_up, old_down, old_right, old_left;
; 	unsigned char b;
; 	
; 	pad_waitButtonRelease();
	xcall _pad_waitButtonRelease
	.dbline 177
; 	
; 	old_up=pad_move_up;
	mov REG[0xd0],>_pad_move_up
	mov A,[_pad_move_up]
	mov [X+1],A
	.dbline 178
; 	old_down=pad_move_down;
	mov REG[0xd0],>_pad_move_down
	mov A,[_pad_move_down]
	mov [X+2],A
	.dbline 179
; 	old_left=pad_move_left;
	mov REG[0xd0],>_pad_move_left
	mov A,[_pad_move_left]
	mov [X+4],A
	.dbline 180
; 	old_right=pad_move_right;
	mov REG[0xd0],>_pad_move_right
	mov A,[_pad_move_right]
	mov [X+3],A
	xjmp L31
L30:
	.dbline 183
; 	
; 	while (1)
; 	{
	.dbline 184
; 		idle();
	xcall _idle
	.dbline 186
; 		
; 		if (pad_move_up!=old_up)
	mov REG[0xd0],>_pad_move_up
	mov A,[_pad_move_up]
	cmp A,[X+1]
	jz L33
	.dbline 187
; 			return PAD_UP | (pad_buttons<<4);
	mov REG[0xd0],>_pad_buttons
	mov A,[_pad_buttons]
	mov REG[0xd0],>__r0
	asl A
	asl A
	asl A
	asl A
	mov [__r0],A
	or [__r0],1
	mov A,[__r0]
	xjmp L29
L33:
	.dbline 188
; 		if (pad_move_down!=old_down)
	mov REG[0xd0],>_pad_move_down
	mov A,[_pad_move_down]
	cmp A,[X+2]
	jz L35
	.dbline 189
; 			return PAD_DOWN | (pad_buttons<<4);
	mov REG[0xd0],>_pad_buttons
	mov A,[_pad_buttons]
	mov REG[0xd0],>__r0
	asl A
	asl A
	asl A
	asl A
	mov [__r0],A
	or [__r0],2
	mov A,[__r0]
	xjmp L29
L35:
	.dbline 190
; 		if (pad_move_left!=old_left)
	mov REG[0xd0],>_pad_move_left
	mov A,[_pad_move_left]
	cmp A,[X+4]
	jz L37
	.dbline 191
; 			return PAD_LEFT | (pad_buttons<<4);
	mov REG[0xd0],>_pad_buttons
	mov A,[_pad_buttons]
	mov REG[0xd0],>__r0
	asl A
	asl A
	asl A
	asl A
	mov [__r0],A
	or [__r0],4
	mov A,[__r0]
	xjmp L29
L37:
	.dbline 192
; 		if (pad_move_right!=old_right)
	mov REG[0xd0],>_pad_move_right
	mov A,[_pad_move_right]
	cmp A,[X+3]
	jz L39
	.dbline 193
; 			return PAD_RIGHT | (pad_buttons<<4);
	mov REG[0xd0],>_pad_buttons
	mov A,[_pad_buttons]
	mov REG[0xd0],>__r0
	asl A
	asl A
	asl A
	asl A
	mov [__r0],A
	or [__r0],3
	mov A,[__r0]
	xjmp L29
L39:
	.dbline 195
; 		
; 		b=pad_pollButtons();
	xcall _pad_pollButtons
	mov REG[0xd0],>__r0
	mov [X+0],A
	.dbline 196
; 		if (b)
	cmp [X+0],0
	jz L41
	.dbline 197
; 			return b;
	mov A,[X+0]
	xjmp L29
L41:
	.dbline 198
L31:
	.dbline 182
	xjmp L30
X1:
	.dbline 200
; 	}
; 	
; 	return 0;
	mov REG[0xd0],>__r0
	mov A,0
	.dbline -2
L29:
	add SP,-5
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l old_left 4 c
	.dbsym l old_right 3 c
	.dbsym l old_down 2 c
	.dbsym l old_up 1 c
	.dbsym l b 0 c
	.dbend
	.dbfunc e pad_currentButtons _pad_currentButtons fc
_pad_currentButtons::
	.dbline -1
	.dbline 205
; }
; 
; // This doesn't call idle, so you must do so somewhere
; unsigned char pad_currentButtons()
; {
	.dbline 206
; 	return pad_buttons<<4;
	mov REG[0xd0],>_pad_buttons
	mov A,[_pad_buttons]
	mov REG[0xd0],>__r0
	asl A
	asl A
	asl A
	asl A
	.dbline -2
L43:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e pad_pollButtons _pad_pollButtons fc
_pad_pollButtons::
	.dbline -1
	.dbline 210
; }
; 
; unsigned char pad_pollButtons()
; {
	.dbline 211
; 	idle();
	xcall _idle
	.dbline 212
; 	return pad_buttons<<4;
	mov REG[0xd0],>_pad_buttons
	mov A,[_pad_buttons]
	mov REG[0xd0],>__r0
	asl A
	asl A
	asl A
	asl A
	.dbline -2
L44:
	.dbline 0 ; func end
	ret
	.dbend
