Changed init part, added internal flags

git-svn-id: svn://kolibrios.org@5041 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
gtament 2014-08-18 12:16:26 +00:00
parent dfd9b3b599
commit bf60efb41b

View File

@ -43,12 +43,15 @@ ends
BUTTONXSIZE = 60 BUTTONXSIZE = 60
BUTTONYSIZE = 60 BUTTONYSIZE = 60
BUTTONXSTART= 20 BUTTONXSTART= 20
BUTTONYSTART= 50 BUTTONYSTART= 55
BUTTONXSPACE= 10 BUTTONXSPACE= 10
BUTTONCOUNT = 8 BUTTONCOUNT = 8
ONCOLOR = 0x0018c015 ONCOLOR = 0x0018c015
OFFCOLOR = 0x00db2521 OFFCOLOR = 0x00db2521
;Flags
PIN_CONF_FLAG = 0
INIT: INIT:
mov [btn_state], 0xFF mov [btn_state], 0xFF
mov [btn_io], 0xFF mov [btn_io], 0xFF
@ -71,9 +74,24 @@ INIT:
mov [IOCTLs+IOCTL.input], eax mov [IOCTLs+IOCTL.input], eax
call drivercomm.getlist call drivercomm.getlist
test eax, eax
jnz @f
mcall 4, 5 shl 16 + 25, 1 shl 31 + 0xFF shl 16, noftdi_msg
@@:
call drivercomm.getlock call drivercomm.getlock
call drivercomm.bitmode mov eax, [pid]
call drivercomm.baud cmp eax, [out_buf]
jz @f
mcall 4, 5 shl 16 + 25, 1 shl 31 + 0xFF shl 16, devlkd_msg
jmp event_wait
@@:
mcall 4, 5 shl 16 + 25, 1 shl 31, welcio_msg
mov [flags], 1 shl PIN_CONF_FLAG
call draw_window.no_redraw
jmp event_wait
.init_cont:
call draw_window
mcall 4, 5 shl 16 + 25, 1 shl 31 + ONCOLOR, devrdy_msg
event_wait: event_wait:
mov eax, 10 mov eax, 10
@ -108,7 +126,7 @@ button:
mcall mcall
cmp ah, 1 cmp ah, 1
jle .noclose jg .noclose
call drivercomm.unlock call drivercomm.unlock
mov eax, -1 mov eax, -1
mcall mcall
@ -116,23 +134,29 @@ button:
.noclose: .noclose:
cmp ah, 10 cmp ah, 10
jge .toggleb jge .toggleb
mov ebx, [flags]
and ebx, 1 shl PIN_CONF_FLAG
jnz event_wait
movzx edx, ah movzx edx, ah
dec ah dec ah
dec ah dec ah
mov cl, ah mov cl, ah
mov ah ,1 mov ah ,1
shl ah, cl shl ah, cl
mov al, [btn_io]
and al, ah
jz .input
xor byte[btn_state], ah xor byte[btn_state], ah
push edx .input:
call draw_window.oloop_entry
call drivercomm.write call drivercomm.write
call drivercomm.read call drivercomm.read
pop edx ;call drivercomm.pins
call redraw_obutton
jmp event_wait jmp event_wait
.toggleb: .toggleb:
cmp ah, 18 cmp ah, 19
jg event_wait jg .pinconf
movzx edx, ah movzx edx, ah
mov cl, ah mov cl, ah
sub cl, 10 sub cl, 10
@ -142,6 +166,17 @@ button:
call draw_tbutton call draw_tbutton
jmp event_wait jmp event_wait
.pinconf:
cmp ah, 20
mov eax, [flags]
and eax, 1 shl PIN_CONF_FLAG
jz .no_conf
call drivercomm.bitmode
call drivercomm.baud
.no_conf:
xor [flags], 1 shl PIN_CONF_FLAG
jmp INIT.init_cont
drivercomm: ;Driver communication procs drivercomm: ;Driver communication procs
.baud: .baud:
mov [IOCTLs+IOCTL.io_code], 10 mov [IOCTLs+IOCTL.io_code], 10
@ -163,7 +198,9 @@ drivercomm: ;Driver communication procs
mov [edi+4], eax mov [edi+4], eax
mov [edi+8], dword 1 mov [edi+8], dword 1
mov al, [btn_state] mov al, [btn_state]
mov byte[edi+12], al mov ecx, 4
add edi, 12
rep stosb
mcall 68, 17, IOCTLs mcall 68, 17, IOCTLs
ret ret
@ -174,11 +211,15 @@ drivercomm: ;Driver communication procs
mov [edi], eax mov [edi], eax
mov eax, [dev] mov eax, [dev]
mov [edi+4], eax mov [edi+4], eax
mov [edi+8], dword 1 mov [edi+8], dword 3
mcall 68, 17, IOCTLs mcall 68, 17, IOCTLs
mov al, byte[out_buf] test eax, eax
mov [btn_state], al jz .read_ok
debug_print 'Error'
newline newline
.read_ok:
mov al, byte[out_buf+2]
mov [btn_state], al
ret ret
.getlock: .getlock:
@ -203,6 +244,7 @@ drivercomm: ;Driver communication procs
mov edi, out_buf mov edi, out_buf
mov eax, [edi+12] mov eax, [edi+12]
mov [dev], eax mov [dev], eax
mov eax, [edi]
ret ret
.bitmode: .bitmode:
@ -213,12 +255,24 @@ drivercomm: ;Driver communication procs
mov eax, [dev] mov eax, [dev]
mov [edi+4], eax mov [edi+4], eax
xor eax, eax xor eax, eax
mov al, [btn_io] mov ah, [btn_io]
mov ah, 0x04 mov al, 0x01
mov [edi+8], eax mov [edi+8], eax
mcall 68, 17, IOCTLs mcall 68, 17, IOCTLs
ret ret
.pins:
mov [IOCTLs+IOCTL.io_code], 22
mov edi, in_buf
mov eax, [pid]
mov [edi], eax
mov eax, [dev]
mov [edi+4], eax
mcall 68, 17, IOCTLs
mov al, byte[out_buf]
mov [btn_state], al
ret
.unlock: .unlock:
mov eax, [pid] mov eax, [pid]
mov edi, in_buf mov edi, in_buf
@ -249,15 +303,12 @@ draw_window:
mov edi, title mov edi, title
mcall mcall
mov edx, BUTTONCOUNT+1 .no_redraw:
.oloop: mcall 8, ((BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT-30) shl 16 + 60, 25 shl 16 + 12, 20, 0x00E1E1E1
push edx mov eax, [flags]
call draw_obutton and eax, 1 shl PIN_CONF_FLAG
pop edx jz .no_toggles
dec edx mcall 4, ((BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT-27) shl 16 + 28, 1 shl 31, fnsh_btn
cmp edx, 1
jnz .oloop
mov edx, BUTTONCOUNT+9 mov edx, BUTTONCOUNT+9
.tloop: .tloop:
push edx push edx
@ -266,6 +317,19 @@ draw_window:
dec edx dec edx
cmp edx, 9 cmp edx, 9
jnz .tloop jnz .tloop
jmp @f
.no_toggles:
mcall 4, ((BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT-27) shl 16 + 28, 1 shl 31, conf_btn
@@:
.oloop_entry:
mov edx, BUTTONCOUNT+1
.oloop:
push edx
call draw_obutton
pop edx
dec edx
cmp edx, 1
jnz .oloop
mov eax, 12 mov eax, 12
mov ebx, 2 mov ebx, 2
@ -371,8 +435,14 @@ btn_state db ?
btn_io db ? btn_io db ?
dev dd ? dev dd ?
pid dd ? pid dd ?
counter dd ? flags dd ?
drv_name db 'usbother', 0 drv_name db 'usbother', 0
noftdi_msg db 'No FTDI connected', 0
devrdy_msg db 'First FTDI is ready', 0
devlkd_msg db 'First FTDI is locked', 0
welcio_msg db 'Please, choose pin state', 0
conf_btn db 'Configure', 0
fnsh_btn db 'Finish', 0
off_text db 'OFF', 0 off_text db 'OFF', 0
on_text db 'ON', 0 on_text db 'ON', 0
i_text db 'I', 0 i_text db 'I', 0