forked from KolibriOS/kolibrios
outdated/clip: Post-SVN tidy
- Move source code from `trunk` into root directory. - Update build files and ASM include paths. - Note: Line endings standardised from `CRLF` > `LF`, so best to view diffs with whitespace changes hidden.
This commit is contained in:
@@ -1,413 +1,419 @@
|
|||||||
; <--- description --->
|
; SPDX-License-Identifier: NOASSERTION
|
||||||
; compiler: FASM
|
;
|
||||||
; name: Clipboard server/daemon
|
|
||||||
; version: 0.2
|
; Text encoded with Code Page 866 - Cyrillic
|
||||||
; author: barsuk
|
|
||||||
|
|
||||||
; <--- include all MeOS stuff --->
|
; <--- description --->
|
||||||
include "lang.inc"
|
; compiler: FASM
|
||||||
include "..\..\..\..\macros.inc"
|
; name: Clipboard server/daemon
|
||||||
|
; version: 0.2
|
||||||
; <--- start of MenuetOS application --->
|
; author: barsuk
|
||||||
MEOS_APP_START
|
|
||||||
|
; <--- include all MeOS stuff --->
|
||||||
;define DEBUG TRUE
|
include "lang.inc"
|
||||||
define DEBUG FALSE
|
include "..\..\..\macros.inc"
|
||||||
include "bdebug.inc"
|
|
||||||
|
; <--- start of MenuetOS application --->
|
||||||
DEFAULT_SIZE = 0x10010 ; 64K + size of headers
|
MEOS_APP_START
|
||||||
MAX_SIZE = 0x01000000 ; 16 M
|
|
||||||
MAX_FORMAT = 16
|
;define DEBUG TRUE
|
||||||
DELAY = 10 ; 1/10 sec between sending attempts
|
define DEBUG FALSE
|
||||||
ATTEMPT = 5 ; number of sending attempts
|
include "bdebug.inc"
|
||||||
|
|
||||||
|
DEFAULT_SIZE = 0x10010 ; 64K + size of headers
|
||||||
; <--- start of code --->
|
MAX_SIZE = 0x01000000 ; 16 M
|
||||||
CODE
|
MAX_FORMAT = 16
|
||||||
|
DELAY = 10 ; 1/10 sec between sending attempts
|
||||||
; ¢®-¯¥à¢ëå, ¤® 㡨âì ¢á¥ @clip, ª ª¨¥ ©¤ãâáï:
|
ATTEMPT = 5 ; number of sending attempts
|
||||||
; ¤¥¬® ¡ãä¥à ®¡¬¥ ¤®«¦¥ ¡ëâì ⮫쪮 ®¤¨!
|
|
||||||
; ¨ ¨¬ ®ª ¦¥âáï á ¬ë© ¬®«®¤®© ¨§ ¤¥¬®®¢...
|
|
||||||
|
; <--- start of code --->
|
||||||
mov ecx, 2 ; ¯¥à¢ë© ®¬¥à ᫮⠤«ï ¯à®¢¥àª¨
|
CODE
|
||||||
mov ebp, info
|
|
||||||
mov ebx, ebp
|
; ¢®-¯¥à¢ëå, ¤® 㡨âì ¢á¥ @clip, ª ª¨¥ ©¤ãâáï:
|
||||||
mov edx, 18
|
; ¤¥¬® ¡ãä¥à ®¡¬¥ ¤®«¦¥ ¡ëâì ⮫쪮 ®¤¨!
|
||||||
.next_process:
|
; ¨ ¨¬ ®ª ¦¥âáï á ¬ë© ¬®«®¤®© ¨§ ¤¥¬®®¢...
|
||||||
mov eax, 9
|
|
||||||
int 0x40
|
mov ecx, 2 ; ¯¥à¢ë© ®¬¥à ᫮⠤«ï ¯à®¢¥àª¨
|
||||||
cmp dword [ebx + 10], '@CLI'
|
mov ebp, info
|
||||||
jnz .differ
|
mov ebx, ebp
|
||||||
cmp byte [ebx + 14], 'P'
|
mov edx, 18
|
||||||
jnz .differ
|
.next_process:
|
||||||
.similar:
|
mov eax, 9
|
||||||
xchg eax, edx
|
int 0x40
|
||||||
mov ebx, 2
|
cmp dword [ebx + 10], '@CLI'
|
||||||
int 0x40
|
jnz .differ
|
||||||
mov ebx, ebp
|
cmp byte [ebx + 14], 'P'
|
||||||
xchg eax, edx
|
jnz .differ
|
||||||
.differ:
|
.similar:
|
||||||
inc ecx
|
xchg eax, edx
|
||||||
cmp ecx, eax
|
mov ebx, 2
|
||||||
jae .done ; process not found
|
int 0x40
|
||||||
jmp .next_process
|
mov ebx, ebp
|
||||||
|
xchg eax, edx
|
||||||
.done:
|
.differ:
|
||||||
mov eax, 68 ; init heap
|
inc ecx
|
||||||
mov ebx, 11
|
cmp ecx, eax
|
||||||
int 0x40
|
jae .done ; process not found
|
||||||
|
jmp .next_process
|
||||||
mov eax, 66 ; set hotkey: Ctrl-Alt-V
|
|
||||||
mov ebx, 4
|
.done:
|
||||||
mov ecx, 47
|
mov eax, 68 ; init heap
|
||||||
mov edx, 0x110 ; 0x110
|
mov ebx, 11
|
||||||
int 0x40
|
int 0x40
|
||||||
print "set hot key (1 bad)"
|
|
||||||
pregs
|
mov eax, 66 ; set hotkey: Ctrl-Alt-V
|
||||||
|
mov ebx, 4
|
||||||
mov ebp, DEFAULT_SIZE
|
mov ecx, 47
|
||||||
|
mov edx, 0x110 ; 0x110
|
||||||
mov eax, 68 ; get memory for buffer
|
int 0x40
|
||||||
mov ebx, 12
|
print "set hot key (1 bad)"
|
||||||
mov ecx, ebp
|
pregs
|
||||||
int 0x40
|
|
||||||
mov esi, IPC_buffer
|
mov ebp, DEFAULT_SIZE
|
||||||
mov [esi], eax
|
|
||||||
|
mov eax, 68 ; get memory for buffer
|
||||||
mov eax, 60 ; define buffer for IPC
|
mov ebx, 12
|
||||||
mov ebx, 1
|
mov ecx, ebp
|
||||||
mov ecx, [esi]
|
int 0x40
|
||||||
mov edx, ebp
|
mov esi, IPC_buffer
|
||||||
int 0x40
|
mov [esi], eax
|
||||||
|
|
||||||
mov eax, 40
|
mov eax, 60 ; define buffer for IPC
|
||||||
mov ebx, 01000010b ;
|
mov ebx, 1
|
||||||
int 0x40
|
mov ecx, [esi]
|
||||||
|
mov edx, ebp
|
||||||
wait_event: ; main cycle
|
int 0x40
|
||||||
mov eax, [IPC_buffer]
|
|
||||||
mov dword [eax], 0 ; unlock buffer
|
mov eax, 40
|
||||||
mov dword [eax + 4], 8
|
mov ebx, 01000010b ;
|
||||||
|
int 0x40
|
||||||
mov eax, 10 ; wait
|
|
||||||
int 0x40
|
wait_event: ; main cycle
|
||||||
print "event"
|
mov eax, [IPC_buffer]
|
||||||
pregs
|
mov dword [eax], 0 ; unlock buffer
|
||||||
|
mov dword [eax + 4], 8
|
||||||
;dec eax
|
|
||||||
;dec eax
|
mov eax, 10 ; wait
|
||||||
cmp eax, 2
|
int 0x40
|
||||||
jnz ipc_event
|
print "event"
|
||||||
|
pregs
|
||||||
print "hotkey"
|
|
||||||
|
;dec eax
|
||||||
mov eax, 2
|
;dec eax
|
||||||
int 0x40
|
cmp eax, 2
|
||||||
pregs
|
jnz ipc_event
|
||||||
cmp ah, 47 ; "v" up
|
|
||||||
jnz wait_event
|
print "hotkey"
|
||||||
|
|
||||||
print "hotkey v up"
|
mov eax, 2
|
||||||
; it is hotkey
|
int 0x40
|
||||||
mov eax, 1
|
pregs
|
||||||
mov ebx, eax
|
cmp ah, 47 ; "v" up
|
||||||
call find_format
|
jnz wait_event
|
||||||
pregs
|
|
||||||
cmp eax, -1
|
print "hotkey v up"
|
||||||
jz wait_event
|
; it is hotkey
|
||||||
mov esi, [data_buffer + eax * 4]
|
mov eax, 1
|
||||||
mov edi, [data_size + eax * 4]
|
mov ebx, eax
|
||||||
mov ecx, 2
|
call find_format
|
||||||
print "ping"
|
pregs
|
||||||
.next:
|
cmp eax, -1
|
||||||
mov eax, 72
|
jz wait_event
|
||||||
movzx edx, byte [esi]
|
mov esi, [data_buffer + eax * 4]
|
||||||
int 0x40 ; here we should pause if eax = 1
|
mov edi, [data_size + eax * 4]
|
||||||
pregs
|
mov ecx, 2
|
||||||
|
print "ping"
|
||||||
inc esi
|
.next:
|
||||||
dec edi
|
mov eax, 72
|
||||||
jnz .next
|
movzx edx, byte [esi]
|
||||||
jmp wait_event
|
int 0x40 ; here we should pause if eax = 1
|
||||||
|
pregs
|
||||||
ipc_event:
|
|
||||||
|
inc esi
|
||||||
; we get an IPC message
|
dec edi
|
||||||
|
jnz .next
|
||||||
print "recv. "
|
jmp wait_event
|
||||||
|
|
||||||
mov eax, [IPC_buffer]
|
ipc_event:
|
||||||
mov dword [eax], 1 ; lock buffer
|
|
||||||
mov dword [eax + 4], 8
|
; we get an IPC message
|
||||||
|
|
||||||
dph1 dword [eax] ; lock
|
print "recv. "
|
||||||
dph1 dword [eax + 4] ; current used size
|
|
||||||
dph1 dword [eax + 8] ; pid
|
mov eax, [IPC_buffer]
|
||||||
dph1 dword [eax + 12] ; len
|
mov dword [eax], 1 ; lock buffer
|
||||||
print ""
|
mov dword [eax + 4], 8
|
||||||
dph1 dword [eax + 16] ; cmd << 16 | fmt
|
|
||||||
dph1 dword [eax + 20]
|
dph1 dword [eax] ; lock
|
||||||
dph1 dword [eax + 24]
|
dph1 dword [eax + 4] ; current used size
|
||||||
|
dph1 dword [eax + 8] ; pid
|
||||||
mov ebx, [eax + 8 + 4]
|
dph1 dword [eax + 12] ; len
|
||||||
cmp ebx, 8
|
print ""
|
||||||
jb wait_event ; all my messages have 8-byte header
|
dph1 dword [eax + 16] ; cmd << 16 | fmt
|
||||||
; so ignore this one
|
dph1 dword [eax + 20]
|
||||||
|
dph1 dword [eax + 24]
|
||||||
movzx ecx, word [eax + 8 + 8] ; command
|
|
||||||
cmp ecx, 1
|
mov ebx, [eax + 8 + 4]
|
||||||
jz command_setsize
|
cmp ebx, 8
|
||||||
cmp ecx, 2
|
jb wait_event ; all my messages have 8-byte header
|
||||||
jz command_set
|
; so ignore this one
|
||||||
cmp ecx, 3
|
|
||||||
jz command_getsize
|
movzx ecx, word [eax + 8 + 8] ; command
|
||||||
cmp ecx, 4
|
cmp ecx, 1
|
||||||
jz command_get
|
jz command_setsize
|
||||||
cmp ecx, 5
|
cmp ecx, 2
|
||||||
jz command_delete
|
jz command_set
|
||||||
jmp wait_event ; unrecognised command
|
cmp ecx, 3
|
||||||
|
jz command_getsize
|
||||||
command_setsize:
|
cmp ecx, 4
|
||||||
|
jz command_get
|
||||||
; the only thing we really need to do here is to grow IPC buffer
|
cmp ecx, 5
|
||||||
; no changes are done to real buffer of chosen format
|
jz command_delete
|
||||||
|
jmp wait_event ; unrecognised command
|
||||||
; the bad thing is that IPC buffer grows and never becomes less.
|
|
||||||
; i want to fix this in the next version.
|
command_setsize:
|
||||||
|
|
||||||
print "set size"
|
; the only thing we really need to do here is to grow IPC buffer
|
||||||
|
; no changes are done to real buffer of chosen format
|
||||||
mov esi, [IPC_buffer_size]
|
|
||||||
mov ecx, [eax + 24] ; size
|
; the bad thing is that IPC buffer grows and never becomes less.
|
||||||
add ecx, 0x18 ; for headers
|
; i want to fix this in the next version.
|
||||||
;pregs
|
|
||||||
cmp esi, ecx
|
print "set size"
|
||||||
jae wait_event
|
|
||||||
print "ipc buffer resize from esi to ecx"
|
mov esi, [IPC_buffer_size]
|
||||||
pregs
|
mov ecx, [eax + 24] ; size
|
||||||
|
add ecx, 0x18 ; for headers
|
||||||
mov ebp, MAX_SIZE ; sort of protection. forbid transfer of more
|
;pregs
|
||||||
cmp ecx, ebp ; than 16,7 Mb of data through buffer
|
cmp esi, ecx
|
||||||
jbe not_much
|
jae wait_event
|
||||||
mov ecx, ebp
|
print "ipc buffer resize from esi to ecx"
|
||||||
|
pregs
|
||||||
not_much:
|
|
||||||
xchg eax, edi ; edx := [IPC_buffer]
|
mov ebp, MAX_SIZE ; sort of protection. forbid transfer of more
|
||||||
add ecx, 0x18 ; for headers
|
cmp ecx, ebp ; than 16,7 Mb of data through buffer
|
||||||
|
jbe not_much
|
||||||
mov [IPC_buffer_size], ecx
|
mov ecx, ebp
|
||||||
mov eax, 68
|
|
||||||
mov ebx, 12
|
not_much:
|
||||||
int 0x40 ; get memory
|
xchg eax, edi ; edx := [IPC_buffer]
|
||||||
print "get mem for new buf, eax"
|
add ecx, 0x18 ; for headers
|
||||||
pregs
|
|
||||||
mov [IPC_buffer], eax
|
mov [IPC_buffer_size], ecx
|
||||||
|
mov eax, 68
|
||||||
mov dword [eax + 4], 8
|
mov ebx, 12
|
||||||
mov edx, ecx
|
int 0x40 ; get memory
|
||||||
mov ecx, eax
|
print "get mem for new buf, eax"
|
||||||
mov eax, 60
|
pregs
|
||||||
mov ebx, 1
|
mov [IPC_buffer], eax
|
||||||
int 0x40 ; make it IPC buffer
|
|
||||||
|
mov dword [eax + 4], 8
|
||||||
mov ecx, edi
|
mov edx, ecx
|
||||||
mov eax, 68
|
mov ecx, eax
|
||||||
mov ebx, 13
|
mov eax, 60
|
||||||
int 0x40 ; free old IPC buffer
|
mov ebx, 1
|
||||||
|
int 0x40 ; make it IPC buffer
|
||||||
jmp wait_event
|
|
||||||
|
mov ecx, edi
|
||||||
command_set:
|
mov eax, 68
|
||||||
print "set"
|
mov ebx, 13
|
||||||
|
int 0x40 ; free old IPC buffer
|
||||||
; here we put the data transfered to us to one of internal buffers
|
|
||||||
|
jmp wait_event
|
||||||
;;;outs eax + 0x18
|
|
||||||
|
command_set:
|
||||||
movzx eax, word [eax + 18] ; format id
|
print "set"
|
||||||
call find_format
|
|
||||||
cmp eax, -1
|
; here we put the data transfered to us to one of internal buffers
|
||||||
jz new_format
|
|
||||||
mov edx, eax
|
;;;outs eax + 0x18
|
||||||
|
|
||||||
; free old buffer of this format
|
movzx eax, word [eax + 18] ; format id
|
||||||
|
call find_format
|
||||||
mov ecx, [data_buffer + edx * 4]
|
cmp eax, -1
|
||||||
mov eax, 68
|
jz new_format
|
||||||
mov ebx, 13
|
mov edx, eax
|
||||||
int 0x40
|
|
||||||
jmp set_buffer
|
; free old buffer of this format
|
||||||
|
|
||||||
new_format:
|
mov ecx, [data_buffer + edx * 4]
|
||||||
mov eax, data_count ; allocate a buffer
|
mov eax, 68
|
||||||
mov edx, [eax]
|
mov ebx, 13
|
||||||
inc dword [eax] ; no protection, no checks. very bad :(
|
int 0x40
|
||||||
set_buffer:
|
jmp set_buffer
|
||||||
mov eax, [IPC_buffer]
|
|
||||||
mov ecx, dword [eax + 12]
|
new_format:
|
||||||
sub ecx, 8 ; get length of data itself
|
mov eax, data_count ; allocate a buffer
|
||||||
; subtract size of my headers
|
mov edx, [eax]
|
||||||
;pregs
|
inc dword [eax] ; no protection, no checks. very bad :(
|
||||||
mov [data_size + edx * 4], ecx ; save length of data
|
set_buffer:
|
||||||
|
mov eax, [IPC_buffer]
|
||||||
mov eax, 68
|
mov ecx, dword [eax + 12]
|
||||||
mov ebx, 12
|
sub ecx, 8 ; get length of data itself
|
||||||
int 0x40
|
; subtract size of my headers
|
||||||
mov [data_buffer + edx * 4], eax
|
;pregs
|
||||||
|
mov [data_size + edx * 4], ecx ; save length of data
|
||||||
; copy data from IPC to new buffer
|
|
||||||
mov esi, [IPC_buffer]
|
mov eax, 68
|
||||||
mov ebp, esi
|
mov ebx, 12
|
||||||
add esi, 24 ; start of data
|
int 0x40
|
||||||
mov edi, eax
|
mov [data_buffer + edx * 4], eax
|
||||||
rep movsb ; oh, me knows that it's bad
|
|
||||||
|
; copy data from IPC to new buffer
|
||||||
mov eax, ebp
|
mov esi, [IPC_buffer]
|
||||||
movzx ecx, word [eax + 18] ; format id
|
mov ebp, esi
|
||||||
mov [data_format + edx * 4], ecx
|
add esi, 24 ; start of data
|
||||||
|
mov edi, eax
|
||||||
; debug
|
rep movsb ; oh, me knows that it's bad
|
||||||
; print "set debug"
|
|
||||||
; mov eax, [data_buffer + edx * 4]
|
mov eax, ebp
|
||||||
; mov ebx, [data_size + edx * 4]
|
movzx ecx, word [eax + 18] ; format id
|
||||||
; mov ecx, [data_format + edx * 4]
|
mov [data_format + edx * 4], ecx
|
||||||
; pregs
|
|
||||||
|
; debug
|
||||||
jmp wait_event
|
; print "set debug"
|
||||||
|
; mov eax, [data_buffer + edx * 4]
|
||||||
command_delete:
|
; mov ebx, [data_size + edx * 4]
|
||||||
movzx eax, word [eax + 18] ; format id
|
; mov ecx, [data_format + edx * 4]
|
||||||
cmp eax, -1
|
; pregs
|
||||||
jz command_clear
|
|
||||||
call find_format
|
jmp wait_event
|
||||||
cmp eax, -1
|
|
||||||
jz wait_event
|
command_delete:
|
||||||
mov ecx, [data_buffer + eax * 4]
|
movzx eax, word [eax + 18] ; format id
|
||||||
mov [data_format + eax * 4], 0
|
cmp eax, -1
|
||||||
mov eax, 68
|
jz command_clear
|
||||||
mov ebx, 13
|
call find_format
|
||||||
int 0x40
|
cmp eax, -1
|
||||||
jmp wait_event
|
jz wait_event
|
||||||
|
mov ecx, [data_buffer + eax * 4]
|
||||||
command_clear:
|
mov [data_format + eax * 4], 0
|
||||||
mov eax, 68
|
mov eax, 68
|
||||||
mov ebx, 13
|
mov ebx, 13
|
||||||
mov edx, data_buffer
|
int 0x40
|
||||||
.next:
|
jmp wait_event
|
||||||
mov ecx, [edx]
|
|
||||||
jecxz .nofree
|
command_clear:
|
||||||
int 0x40
|
mov eax, 68
|
||||||
.nofree:
|
mov ebx, 13
|
||||||
mov [edx + data_size - data_buffer], 0
|
mov edx, data_buffer
|
||||||
add edx, 4
|
.next:
|
||||||
cmp edx, data_format
|
mov ecx, [edx]
|
||||||
jnae .next
|
jecxz .nofree
|
||||||
jmp wait_event
|
int 0x40
|
||||||
|
.nofree:
|
||||||
command_getsize:
|
mov [edx + data_size - data_buffer], 0
|
||||||
|
add edx, 4
|
||||||
print "get size"
|
cmp edx, data_format
|
||||||
|
jnae .next
|
||||||
; we should send reply, containing size of data with chosen format id
|
jmp wait_event
|
||||||
movzx eax, word [eax + 18] ; format id
|
|
||||||
mov esi, 4
|
command_getsize:
|
||||||
call find_format
|
|
||||||
;pregs
|
print "get size"
|
||||||
cmp eax, -1
|
|
||||||
jz zero_size
|
; we should send reply, containing size of data with chosen format id
|
||||||
|
movzx eax, word [eax + 18] ; format id
|
||||||
lea edx, [data_size + eax * 4]
|
mov esi, 4
|
||||||
mov eax, [edx]
|
call find_format
|
||||||
jmp send_getsize
|
;pregs
|
||||||
zero_size:
|
cmp eax, -1
|
||||||
mov edx, dw_zero ; send 0 to indicate that the buffer is empty
|
jz zero_size
|
||||||
send_getsize:
|
|
||||||
jmp send_msg
|
lea edx, [data_size + eax * 4]
|
||||||
|
mov eax, [edx]
|
||||||
command_get:
|
jmp send_getsize
|
||||||
print "get"
|
zero_size:
|
||||||
|
mov edx, dw_zero ; send 0 to indicate that the buffer is empty
|
||||||
; we need to send the data
|
send_getsize:
|
||||||
|
jmp send_msg
|
||||||
; [:||||:]
|
|
||||||
|
command_get:
|
||||||
movzx eax, word [eax + 18] ; format id
|
print "get"
|
||||||
call find_format
|
|
||||||
cmp eax, -1
|
; we need to send the data
|
||||||
jz wait_event
|
|
||||||
mov edi, eax ; ¥ä¨£
|
; [:||||:]
|
||||||
|
|
||||||
mov edx, [data_buffer + edi * 4]
|
movzx eax, word [eax + 18] ; format id
|
||||||
mov esi, [data_size + edi * 4]
|
call find_format
|
||||||
;jmp send_msg
|
cmp eax, -1
|
||||||
|
jz wait_event
|
||||||
send_msg:
|
mov edi, eax ; ¥ä¨£
|
||||||
|
|
||||||
; for debugging
|
mov edx, [data_buffer + edi * 4]
|
||||||
; mov eax, 5
|
mov esi, [data_size + edi * 4]
|
||||||
; mov ebx, DELAY*5
|
;jmp send_msg
|
||||||
; int 0x40
|
|
||||||
|
send_msg:
|
||||||
mov ebp, ATTEMPT ; number of attempts to send
|
|
||||||
mov eax, [IPC_buffer]
|
; for debugging
|
||||||
mov ecx, [eax + 8] ; sender PID
|
; mov eax, 5
|
||||||
mov eax, 60
|
; mov ebx, DELAY*5
|
||||||
mov ebx, 2
|
; int 0x40
|
||||||
int 0x40
|
|
||||||
print "send data result eax"
|
mov ebp, ATTEMPT ; number of attempts to send
|
||||||
pregs
|
mov eax, [IPC_buffer]
|
||||||
cmp eax, 2
|
mov ecx, [eax + 8] ; sender PID
|
||||||
jz .wait
|
mov eax, 60
|
||||||
cmp eax, 3 ; it is strange..
|
mov ebx, 2
|
||||||
jz .wait ; maybe he needs time to resize his buf
|
int 0x40
|
||||||
jmp wait_event
|
print "send data result eax"
|
||||||
.wait:
|
pregs
|
||||||
dec ebp
|
cmp eax, 2
|
||||||
jz wait_event
|
jz .wait
|
||||||
mov eax, 5 ; sleep a bit
|
cmp eax, 3 ; it is strange..
|
||||||
mov ebx, DELAY
|
jz .wait ; maybe he needs time to resize his buf
|
||||||
int 0x40
|
jmp wait_event
|
||||||
jmp send_msg
|
.wait:
|
||||||
|
dec ebp
|
||||||
|
jz wait_event
|
||||||
find_format: ; small function returning number of format
|
mov eax, 5 ; sleep a bit
|
||||||
|
mov ebx, DELAY
|
||||||
;print "find format"
|
int 0x40
|
||||||
push ebx
|
jmp send_msg
|
||||||
mov ebx, eax ; format id
|
|
||||||
and ebx, 0xffff ; it is word
|
|
||||||
xor eax, eax
|
find_format: ; small function returning number of format
|
||||||
next:
|
|
||||||
cmp [data_format + eax * 4], ebx
|
;print "find format"
|
||||||
jz found
|
push ebx
|
||||||
inc eax
|
mov ebx, eax ; format id
|
||||||
cmp eax, MAX_FORMAT
|
and ebx, 0xffff ; it is word
|
||||||
jb next
|
xor eax, eax
|
||||||
not_found:
|
next:
|
||||||
or eax, -1
|
cmp [data_format + eax * 4], ebx
|
||||||
found:
|
jz found
|
||||||
;pregs
|
inc eax
|
||||||
pop ebx
|
cmp eax, MAX_FORMAT
|
||||||
ret
|
jb next
|
||||||
|
not_found:
|
||||||
; <--- initialised data --->
|
or eax, -1
|
||||||
DATA
|
found:
|
||||||
IPC_buffer dd 0
|
;pregs
|
||||||
IPC_buffer_size dd DEFAULT_SIZE ; initially 64K
|
pop ebx
|
||||||
|
ret
|
||||||
info db 1024 dup(0) ; for process info
|
|
||||||
|
; <--- initialised data --->
|
||||||
data_buffer dd MAX_FORMAT dup(0) ; buffer for some format
|
DATA
|
||||||
; (256 formats max)
|
IPC_buffer dd 0
|
||||||
data_format dd MAX_FORMAT dup(0) ; format id
|
IPC_buffer_size dd DEFAULT_SIZE ; initially 64K
|
||||||
data_size dd MAX_FORMAT dup(0) ; size of buffer
|
|
||||||
data_count dd 0 ; number of formats used
|
info db 1024 dup(0) ; for process info
|
||||||
dw_zero dd 0 ; used to tell that
|
|
||||||
; we don't have a format
|
data_buffer dd MAX_FORMAT dup(0) ; buffer for some format
|
||||||
|
; (256 formats max)
|
||||||
; <--- uninitialised data --->
|
data_format dd MAX_FORMAT dup(0) ; format id
|
||||||
UDATA
|
data_size dd MAX_FORMAT dup(0) ; size of buffer
|
||||||
|
data_count dd 0 ; number of formats used
|
||||||
|
dw_zero dd 0 ; used to tell that
|
||||||
MEOS_APP_END
|
; we don't have a format
|
||||||
; <--- end of MenuetOS application --->
|
|
||||||
|
; <--- uninitialised data --->
|
||||||
|
UDATA
|
||||||
|
|
||||||
|
|
||||||
|
MEOS_APP_END
|
||||||
|
; <--- end of MenuetOS application --->
|
@@ -1,5 +1,5 @@
|
|||||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
|
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||||
add_include(tup.getvariantdir())
|
add_include(tup.getvariantdir())
|
||||||
|
|
@@ -1,47 +1,50 @@
|
|||||||
; debugging include file by barsuk
|
; SPDX-License-Identifier: NOASSERTION
|
||||||
; if DEBUG=TRUE, adds debug.inc
|
;
|
||||||
; if DEBUG=FALSE, adds stubs for several macros from debug.inc
|
|
||||||
|
; debugging include file by barsuk
|
||||||
match =TRUE, DEBUG
|
; if DEBUG=TRUE, adds debug.inc
|
||||||
{
|
; if DEBUG=FALSE, adds stubs for several macros from debug.inc
|
||||||
|
|
||||||
include '..\..\..\..\debug.inc'
|
match =TRUE, DEBUG
|
||||||
|
{
|
||||||
macro dph1 str
|
|
||||||
\{
|
include '..\..\..\debug.inc'
|
||||||
debug_print_hex str
|
|
||||||
push eax
|
macro dph1 str
|
||||||
mov al, ' '
|
\{
|
||||||
call debug_outchar
|
debug_print_hex str
|
||||||
pop eax
|
push eax
|
||||||
\}
|
mov al, ' '
|
||||||
|
call debug_outchar
|
||||||
macro outs str
|
pop eax
|
||||||
\{
|
\}
|
||||||
pushad
|
|
||||||
lea edx, [str]
|
macro outs str
|
||||||
call debug_outstr
|
\{
|
||||||
popad
|
pushad
|
||||||
\}
|
lea edx, [str]
|
||||||
}
|
call debug_outstr
|
||||||
|
popad
|
||||||
match =FALSE, DEBUG
|
\}
|
||||||
{
|
}
|
||||||
|
|
||||||
macro print message
|
match =FALSE, DEBUG
|
||||||
\{
|
{
|
||||||
\}
|
|
||||||
|
macro print message
|
||||||
macro pregs
|
\{
|
||||||
\{
|
\}
|
||||||
\}
|
|
||||||
|
macro pregs
|
||||||
macro dph1 str
|
\{
|
||||||
\{
|
\}
|
||||||
\}
|
|
||||||
|
macro dph1 str
|
||||||
macro outs str
|
\{
|
||||||
\{
|
\}
|
||||||
\}
|
|
||||||
|
macro outs str
|
||||||
}
|
\{
|
||||||
|
\}
|
||||||
|
|
||||||
|
}
|
@@ -1,240 +1,246 @@
|
|||||||
; <--- description --->
|
; SPDX-License-Identifier: NOASSERTION
|
||||||
; compiler: FASM
|
;
|
||||||
; name: Clipboard Client Demo
|
|
||||||
; version: 0.1
|
; Text encoded with Code Page 866 - Cyrillic
|
||||||
; author: barsuk
|
|
||||||
|
|
||||||
|
; <--- description --->
|
||||||
; <--- include all MeOS stuff --->
|
; compiler: FASM
|
||||||
include "lang.inc"
|
; name: Clipboard Client Demo
|
||||||
include "..\..\..\..\macros.inc"
|
; version: 0.1
|
||||||
|
; author: barsuk
|
||||||
TEST_SIZE = 100000 ; ¤®«¦® ¤¥«¨âìáï 4
|
|
||||||
|
|
||||||
IPC_buffer_size = TEST_SIZE + 0x10
|
; <--- include all MeOS stuff --->
|
||||||
MAX_BUFFER = TEST_SIZE + 0x10
|
include "lang.inc"
|
||||||
|
include "..\..\..\macros.inc"
|
||||||
SEND_DELAY = 10
|
|
||||||
RECV_DELAY = 100
|
TEST_SIZE = 100000 ; ¤®«¦® ¤¥«¨âìáï 4
|
||||||
|
|
||||||
ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥¨¥ ¤¥¬®ã, ¥á«¨
|
IPC_buffer_size = TEST_SIZE + 0x10
|
||||||
; ® § ïâ
|
MAX_BUFFER = TEST_SIZE + 0x10
|
||||||
|
|
||||||
; <--- start of MenuetOS application --->
|
SEND_DELAY = 10
|
||||||
MEOS_APP_START
|
RECV_DELAY = 100
|
||||||
|
|
||||||
define DEBUG TRUE
|
ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥¨¥ ¤¥¬®ã, ¥á«¨
|
||||||
include "bdebug.inc"
|
; ® § ïâ
|
||||||
|
|
||||||
include "clip.inc"
|
; <--- start of MenuetOS application --->
|
||||||
|
MEOS_APP_START
|
||||||
; <--- start of code --->
|
|
||||||
CODE
|
define DEBUG TRUE
|
||||||
|
include "bdebug.inc"
|
||||||
|
|
||||||
;;; This is the entry point of the program
|
include "clip.inc"
|
||||||
|
|
||||||
begin:
|
; <--- start of code --->
|
||||||
|
CODE
|
||||||
print "clipboard testing module loaded"
|
|
||||||
|
|
||||||
mov eax, 5
|
;;; This is the entry point of the program
|
||||||
mov ebx, 100 ; 5 sec
|
|
||||||
int 0x40
|
begin:
|
||||||
|
|
||||||
call clipboard_init
|
print "clipboard testing module loaded"
|
||||||
or eax, eax
|
|
||||||
jz .err
|
mov eax, 5
|
||||||
|
mov ebx, 100 ; 5 sec
|
||||||
; put the data into clip_buffer
|
int 0x40
|
||||||
|
|
||||||
mov esi, test_line
|
call clipboard_init
|
||||||
mov edi, cb.data
|
or eax, eax
|
||||||
mov ecx, cb.size
|
jz .err
|
||||||
rep movsb
|
|
||||||
|
; put the data into clip_buffer
|
||||||
print "init ok. @clip found."
|
|
||||||
|
mov esi, test_line
|
||||||
mov esi, cb
|
mov edi, cb.data
|
||||||
mov eax, 2
|
mov ecx, cb.size
|
||||||
call clipboard_write
|
rep movsb
|
||||||
or eax, eax
|
|
||||||
jz .err
|
print "init ok. @clip found."
|
||||||
|
|
||||||
print "write test ok."
|
mov esi, cb
|
||||||
|
mov eax, 2
|
||||||
; á«¥£ª ®ç¨á⨬ ¡ãä¥à, ¤«ï ¤¥¦®á⨠¯à®¢¥àª¨
|
call clipboard_write
|
||||||
|
or eax, eax
|
||||||
mov dword [cb.data], 0
|
jz .err
|
||||||
|
|
||||||
;jmp .exit
|
print "write test ok."
|
||||||
mov eax, 3 ; try to read bad data
|
|
||||||
mov esi, cb
|
; á«¥£ª ®ç¨á⨬ ¡ãä¥à, ¤«ï ¤¥¦®á⨠¯à®¢¥àª¨
|
||||||
mov edx, 7
|
|
||||||
call clipboard_read
|
mov dword [cb.data], 0
|
||||||
or eax, eax
|
|
||||||
jz .bad2
|
;jmp .exit
|
||||||
cmp eax, -1
|
mov eax, 3 ; try to read bad data
|
||||||
jz .err
|
mov esi, cb
|
||||||
|
mov edx, 7
|
||||||
.bad2:
|
call clipboard_read
|
||||||
print "unset data read ok 1."
|
or eax, eax
|
||||||
mov eax, 88 ; -"-
|
jz .bad2
|
||||||
mov esi, cb
|
cmp eax, -1
|
||||||
mov edx, 7
|
jz .err
|
||||||
call clipboard_read
|
|
||||||
or eax, eax
|
.bad2:
|
||||||
jz .bad3
|
print "unset data read ok 1."
|
||||||
cmp eax, -1
|
mov eax, 88 ; -"-
|
||||||
jz .err
|
mov esi, cb
|
||||||
|
mov edx, 7
|
||||||
.bad3:
|
call clipboard_read
|
||||||
print "unset data read ok 2."
|
or eax, eax
|
||||||
|
jz .bad3
|
||||||
.read:
|
cmp eax, -1
|
||||||
mov eax, 2
|
jz .err
|
||||||
mov esi, cb
|
|
||||||
mov edx, 7
|
.bad3:
|
||||||
call clipboard_read ; read the string we've written
|
print "unset data read ok 2."
|
||||||
or eax, eax
|
|
||||||
jz .err
|
.read:
|
||||||
cmp eax, -1
|
mov eax, 2
|
||||||
jz .err
|
mov esi, cb
|
||||||
|
mov edx, 7
|
||||||
print "read ok o_O, data:"
|
call clipboard_read ; read the string we've written
|
||||||
outs cb.data
|
or eax, eax
|
||||||
print ""
|
jz .err
|
||||||
|
cmp eax, -1
|
||||||
mov eax, 5
|
jz .err
|
||||||
mov ebx, 200
|
|
||||||
int 0x40
|
print "read ok o_O, data:"
|
||||||
|
outs cb.data
|
||||||
|
print ""
|
||||||
; ¯®á«¥¤ïï ¯à®¢¥àª - à¥á ©§ ¡ãä¥à . ¨¬¥®, ¢®§ì¬¥¬ ¬®£® ¤ ëå
|
|
||||||
; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à
|
mov eax, 5
|
||||||
|
mov ebx, 200
|
||||||
mov eax, 68
|
int 0x40
|
||||||
mov ebx, 11
|
|
||||||
int 0x40
|
|
||||||
|
; ¯®á«¥¤ïï ¯à®¢¥àª - à¥á ©§ ¡ãä¥à . ¨¬¥®, ¢®§ì¬¥¬ ¬®£® ¤ ëå
|
||||||
mov eax, 68
|
; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à
|
||||||
mov ebx, 12
|
|
||||||
mov ecx, TEST_SIZE + 12
|
mov eax, 68
|
||||||
int 0x40
|
mov ebx, 11
|
||||||
mov [mega_buf], eax
|
int 0x40
|
||||||
|
|
||||||
mov dword [eax], TEST_SIZE
|
mov eax, 68
|
||||||
|
mov ebx, 12
|
||||||
lea edx, [eax + 12]
|
mov ecx, TEST_SIZE + 12
|
||||||
mov eax, 12131415
|
int 0x40
|
||||||
shr ecx, 2
|
mov [mega_buf], eax
|
||||||
.loop:
|
|
||||||
mov [edx], eax
|
mov dword [eax], TEST_SIZE
|
||||||
add edx, 4
|
|
||||||
dec ecx
|
lea edx, [eax + 12]
|
||||||
jnz .loop
|
mov eax, 12131415
|
||||||
|
shr ecx, 2
|
||||||
print "mega buffer allocated and filled"
|
.loop:
|
||||||
|
mov [edx], eax
|
||||||
; now write it
|
add edx, 4
|
||||||
|
dec ecx
|
||||||
mov esi, [mega_buf]
|
jnz .loop
|
||||||
mov eax, 69
|
|
||||||
call clipboard_write
|
print "mega buffer allocated and filled"
|
||||||
or eax, eax
|
|
||||||
jz .err
|
; now write it
|
||||||
|
|
||||||
print "mega buffer written"
|
mov esi, [mega_buf]
|
||||||
mov eax, 5
|
mov eax, 69
|
||||||
mov ebx, 100
|
call clipboard_write
|
||||||
int 0x40
|
or eax, eax
|
||||||
|
jz .err
|
||||||
; clear it.
|
|
||||||
|
print "mega buffer written"
|
||||||
mov edx, [mega_buf]
|
mov eax, 5
|
||||||
add edx, 12
|
mov ebx, 100
|
||||||
xor eax, eax
|
int 0x40
|
||||||
mov ecx, TEST_SIZE/4
|
|
||||||
.loopc:
|
; clear it.
|
||||||
mov [edx], eax
|
|
||||||
add edx, 4
|
mov edx, [mega_buf]
|
||||||
dec ecx
|
add edx, 12
|
||||||
jnz .loopc
|
xor eax, eax
|
||||||
|
mov ecx, TEST_SIZE/4
|
||||||
; now read
|
.loopc:
|
||||||
|
mov [edx], eax
|
||||||
mov eax, 69
|
add edx, 4
|
||||||
mov esi, [mega_buf]
|
dec ecx
|
||||||
mov edx, 7
|
jnz .loopc
|
||||||
call clipboard_read ; read the string we've written
|
|
||||||
or eax, eax
|
; now read
|
||||||
jz .err
|
|
||||||
cmp eax, -1
|
mov eax, 69
|
||||||
jz .err
|
mov esi, [mega_buf]
|
||||||
|
mov edx, 7
|
||||||
print "mega buf read"
|
call clipboard_read ; read the string we've written
|
||||||
|
or eax, eax
|
||||||
; now compare
|
jz .err
|
||||||
|
cmp eax, -1
|
||||||
mov edx, [mega_buf]
|
jz .err
|
||||||
add edx, 12
|
|
||||||
mov eax, 12131415
|
print "mega buf read"
|
||||||
mov ecx, TEST_SIZE/4
|
|
||||||
.loopm:
|
; now compare
|
||||||
cmp eax, [edx]
|
|
||||||
jnz .err
|
mov edx, [mega_buf]
|
||||||
add edx, 4
|
add edx, 12
|
||||||
dec ecx
|
mov eax, 12131415
|
||||||
jnz .loopm
|
mov ecx, TEST_SIZE/4
|
||||||
|
.loopm:
|
||||||
print "deleting mega buf"
|
cmp eax, [edx]
|
||||||
|
jnz .err
|
||||||
mov eax, 69
|
add edx, 4
|
||||||
call clipboard_delete
|
dec ecx
|
||||||
or eax, eax
|
jnz .loopm
|
||||||
jz .err
|
|
||||||
|
print "deleting mega buf"
|
||||||
mov eax, 5
|
|
||||||
mov ebx, 100
|
mov eax, 69
|
||||||
int 0x40
|
call clipboard_delete
|
||||||
|
or eax, eax
|
||||||
print "if read error then all is ok"
|
jz .err
|
||||||
|
|
||||||
mov eax, 69
|
mov eax, 5
|
||||||
mov esi, [mega_buf]
|
mov ebx, 100
|
||||||
mov edx, 7
|
int 0x40
|
||||||
call clipboard_read ; read the string we've written
|
|
||||||
or eax, eax
|
print "if read error then all is ok"
|
||||||
jz .reading
|
|
||||||
jmp .err
|
mov eax, 69
|
||||||
|
mov esi, [mega_buf]
|
||||||
.reading:
|
mov edx, 7
|
||||||
|
call clipboard_read ; read the string we've written
|
||||||
print "test complete!"
|
or eax, eax
|
||||||
|
jz .reading
|
||||||
.exit:
|
jmp .err
|
||||||
or eax, -1
|
|
||||||
int 0x40
|
.reading:
|
||||||
|
|
||||||
.err:
|
print "test complete!"
|
||||||
print "error!"
|
|
||||||
jmp .exit
|
.exit:
|
||||||
|
or eax, -1
|
||||||
|
int 0x40
|
||||||
; <--- initialised data --->
|
|
||||||
DATA
|
.err:
|
||||||
|
print "error!"
|
||||||
CLIP_BUFFER cb, 256
|
jmp .exit
|
||||||
|
|
||||||
; in_buf db 256 dup(0)
|
|
||||||
; out_buf db 'Cthulhu Fhtagn',0
|
; <--- initialised data --->
|
||||||
|
DATA
|
||||||
test_line db 'Cthulhu Fhtagn',0
|
|
||||||
mega_buf dd 0
|
CLIP_BUFFER cb, 256
|
||||||
|
|
||||||
; <--- uninitialised data --->
|
; in_buf db 256 dup(0)
|
||||||
UDATA
|
; out_buf db 'Cthulhu Fhtagn',0
|
||||||
|
|
||||||
|
test_line db 'Cthulhu Fhtagn',0
|
||||||
MEOS_APP_END
|
mega_buf dd 0
|
||||||
; <--- end of MenuetOS application --->
|
|
||||||
|
; <--- uninitialised data --->
|
||||||
|
UDATA
|
||||||
|
|
||||||
|
|
||||||
|
MEOS_APP_END
|
||||||
|
; <--- end of MenuetOS application --->
|
@@ -1,272 +1,278 @@
|
|||||||
; <--- description --->
|
; SPDX-License-Identifier: NOASSERTION
|
||||||
; compiler: FASM
|
;
|
||||||
; name: Clipboard test with GUI.
|
|
||||||
; version: 0.1
|
; Text encoded with Code Page 866 - Cyrillic
|
||||||
; author: barsuk
|
|
||||||
; comments: uses edit_box by Maxxxx32,<Lrz> (old static version)
|
|
||||||
|
; <--- description --->
|
||||||
|
; compiler: FASM
|
||||||
; <--- include all MeOS stuff --->
|
; name: Clipboard test with GUI.
|
||||||
include "lang.inc"
|
; version: 0.1
|
||||||
include "..\..\..\..\macros.inc"
|
; author: barsuk
|
||||||
|
; comments: uses edit_box by Maxxxx32,<Lrz> (old static version)
|
||||||
; <--- start of MenuetOS application --->
|
|
||||||
MEOS_APP_START
|
|
||||||
|
; <--- include all MeOS stuff --->
|
||||||
SEND_DELAY = 10
|
include "lang.inc"
|
||||||
RECV_DELAY = 100
|
include "..\..\..\macros.inc"
|
||||||
ATTEMPT = 5
|
|
||||||
|
; <--- start of MenuetOS application --->
|
||||||
|
MEOS_APP_START
|
||||||
define DEBUG TRUE
|
|
||||||
include "bdebug.inc"
|
SEND_DELAY = 10
|
||||||
|
RECV_DELAY = 100
|
||||||
include "editbox.inc"
|
ATTEMPT = 5
|
||||||
|
|
||||||
include "clip.inc"
|
|
||||||
|
define DEBUG TRUE
|
||||||
use_edit_box
|
include "bdebug.inc"
|
||||||
|
|
||||||
; <--- start of code --->
|
include "editbox.inc"
|
||||||
CODE
|
|
||||||
|
include "clip.inc"
|
||||||
call clipboard_init
|
|
||||||
|
use_edit_box
|
||||||
call draw_window ; at first create and draw the window
|
|
||||||
|
; <--- start of code --->
|
||||||
wait_event: ; main cycle
|
CODE
|
||||||
|
|
||||||
mov edi, input_box
|
call clipboard_init
|
||||||
call edit_box.mouse
|
|
||||||
|
call draw_window ; at first create and draw the window
|
||||||
mov eax, 10
|
|
||||||
int 0x40
|
wait_event: ; main cycle
|
||||||
|
|
||||||
cmp eax, 1 ; if event == 1
|
mov edi, input_box
|
||||||
je redraw ; jump to redraw handler
|
call edit_box.mouse
|
||||||
cmp eax, 2 ; else if event == 2
|
|
||||||
je key ; jump to key handler
|
mov eax, 10
|
||||||
cmp eax, 3 ; else if event == 3
|
int 0x40
|
||||||
je button ; jump to button handler
|
|
||||||
|
cmp eax, 1 ; if event == 1
|
||||||
jmp wait_event ; else return to the start of main cycle
|
je redraw ; jump to redraw handler
|
||||||
|
cmp eax, 2 ; else if event == 2
|
||||||
|
je key ; jump to key handler
|
||||||
redraw: ; redraw event handler
|
cmp eax, 3 ; else if event == 3
|
||||||
call draw_window
|
je button ; jump to button handler
|
||||||
jmp wait_event
|
|
||||||
|
jmp wait_event ; else return to the start of main cycle
|
||||||
|
|
||||||
key: ; key event handler
|
|
||||||
mov eax, 2 ; get key code
|
redraw: ; redraw event handler
|
||||||
int 0x40
|
call draw_window
|
||||||
|
jmp wait_event
|
||||||
cmp ah, '0'
|
|
||||||
jb no_digit
|
|
||||||
cmp ah, '9'
|
key: ; key event handler
|
||||||
ja no_digit
|
mov eax, 2 ; get key code
|
||||||
sub ah, '0'
|
int 0x40
|
||||||
mov byte [format_id], ah
|
|
||||||
call draw_window
|
cmp ah, '0'
|
||||||
jmp wait_event
|
jb no_digit
|
||||||
no_digit:
|
cmp ah, '9'
|
||||||
|
ja no_digit
|
||||||
mov edi, input_box
|
sub ah, '0'
|
||||||
call edit_box.key
|
mov byte [format_id], ah
|
||||||
|
call draw_window
|
||||||
jmp wait_event
|
jmp wait_event
|
||||||
|
no_digit:
|
||||||
|
|
||||||
button: ; button event handler
|
mov edi, input_box
|
||||||
mov eax, 17 ; get button identifier
|
call edit_box.key
|
||||||
int 0x40
|
|
||||||
|
jmp wait_event
|
||||||
cmp ah, 1
|
|
||||||
jz exit
|
|
||||||
|
button: ; button event handler
|
||||||
cmp ah, 5
|
mov eax, 17 ; get button identifier
|
||||||
jz copy
|
int 0x40
|
||||||
cmp ah, 6
|
|
||||||
jz paste
|
cmp ah, 1
|
||||||
jmp wait_event
|
jz exit
|
||||||
copy:
|
|
||||||
mov esi, input_text
|
cmp ah, 5
|
||||||
mov edi, buffer.data
|
jz copy
|
||||||
mov ecx, [buffer.size]
|
cmp ah, 6
|
||||||
rep movsb ; copy text to buffer
|
jz paste
|
||||||
|
jmp wait_event
|
||||||
mov edi, input_box
|
copy:
|
||||||
mov edx, [edi + 38] ; ed_size
|
mov esi, input_text
|
||||||
xchg edx, [buffer.size]
|
mov edi, buffer.data
|
||||||
movzx eax, byte [format_id]
|
mov ecx, [buffer.size]
|
||||||
mov esi, buffer
|
rep movsb ; copy text to buffer
|
||||||
call clipboard_write
|
|
||||||
xchg edx, [buffer.size]
|
mov edi, input_box
|
||||||
jmp wait_event
|
mov edx, [edi + 38] ; ed_size
|
||||||
|
xchg edx, [buffer.size]
|
||||||
paste:
|
movzx eax, byte [format_id]
|
||||||
mov esi, buffer
|
mov esi, buffer
|
||||||
movzx eax, byte [format_id]
|
call clipboard_write
|
||||||
mov edx, 7
|
xchg edx, [buffer.size]
|
||||||
call clipboard_read
|
jmp wait_event
|
||||||
|
|
||||||
or eax, eax
|
paste:
|
||||||
jz wait_event
|
mov esi, buffer
|
||||||
|
movzx eax, byte [format_id]
|
||||||
cmp eax, -1
|
mov edx, 7
|
||||||
jz wait_event
|
call clipboard_read
|
||||||
|
|
||||||
or edx, edx
|
or eax, eax
|
||||||
jz wait_event ; íâ® ¢á¥ ®è¨¡ª¨
|
jz wait_event
|
||||||
|
|
||||||
mov eax, input_box
|
cmp eax, -1
|
||||||
;print "input box"
|
jz wait_event
|
||||||
;dph1 [eax]
|
|
||||||
;dph1 [eax+4]
|
or edx, edx
|
||||||
;dph1 [eax+8]
|
jz wait_event ; íâ® ¢á¥ ®è¨¡ª¨
|
||||||
;dph1 [eax+12]
|
|
||||||
;dph1 [eax+16]
|
mov eax, input_box
|
||||||
;dph1 [eax+20]
|
;print "input box"
|
||||||
;dph1 [eax+24]
|
;dph1 [eax]
|
||||||
|
;dph1 [eax+4]
|
||||||
;;;;jmp wait_event
|
;dph1 [eax+8]
|
||||||
|
;dph1 [eax+12]
|
||||||
mov word [input_box + 36], ed_focus ; flags
|
;dph1 [eax+16]
|
||||||
|
;dph1 [eax+20]
|
||||||
mov ecx, [input_box + 38] ; size
|
;dph1 [eax+24]
|
||||||
print "paste read ecx=size"
|
|
||||||
jecxz .noloop
|
;;;;jmp wait_event
|
||||||
mov edi, input_box
|
|
||||||
mov ah, 8 ; backspace
|
mov word [input_box + 36], ed_focus ; flags
|
||||||
.loop:
|
|
||||||
call edit_box.key
|
mov ecx, [input_box + 38] ; size
|
||||||
dec ecx
|
print "paste read ecx=size"
|
||||||
jnz .loop
|
jecxz .noloop
|
||||||
.noloop:
|
mov edi, input_box
|
||||||
mov esi, buffer.data
|
mov ah, 8 ; backspace
|
||||||
mov ecx, edx
|
.loop:
|
||||||
pregs
|
call edit_box.key
|
||||||
.loop2:
|
dec ecx
|
||||||
mov ah, [esi]
|
jnz .loop
|
||||||
cmp ah, 0
|
.noloop:
|
||||||
jz .done
|
mov esi, buffer.data
|
||||||
call edit_box.key ; ï ¡ë ᥡ¥ à㪨 ®â१ « § â ª®¥
|
mov ecx, edx
|
||||||
; ® çâ® ¤¥« âì, ¥á«¨ ¨ ç¥ ¥ ¯®«ãç ¥âáï?
|
pregs
|
||||||
inc esi
|
.loop2:
|
||||||
dec ecx
|
mov ah, [esi]
|
||||||
jnz .loop2
|
cmp ah, 0
|
||||||
|
jz .done
|
||||||
.done:
|
call edit_box.key ; ï ¡ë ᥡ¥ à㪨 ®â१ « § â ª®¥
|
||||||
print "rest of data ecx"
|
; ® çâ® ¤¥« âì, ¥á«¨ ¨ ç¥ ¥ ¯®«ãç ¥âáï?
|
||||||
pregs
|
inc esi
|
||||||
call draw_window
|
dec ecx
|
||||||
jmp wait_event
|
jnz .loop2
|
||||||
|
|
||||||
exit:
|
.done:
|
||||||
or eax, -1 ; exit application
|
print "rest of data ecx"
|
||||||
int 0x40
|
pregs
|
||||||
|
call draw_window
|
||||||
|
jmp wait_event
|
||||||
draw_window:
|
|
||||||
mov eax, 12 ; start drawing
|
exit:
|
||||||
mov ebx, 1
|
or eax, -1 ; exit application
|
||||||
int 0x40
|
int 0x40
|
||||||
|
|
||||||
mov eax, 0 ; create and draw the window
|
|
||||||
mov ebx, 100*65536+400 ; (window_cx)*65536+(window_sx)
|
draw_window:
|
||||||
mov ecx, 100*65536+250 ; (window_cy)*65536+(window_sy)
|
mov eax, 12 ; start drawing
|
||||||
mov edx, 0x33ffffff ; work area color & window type 3
|
mov ebx, 1
|
||||||
mov edi, head
|
int 0x40
|
||||||
int 0x40
|
|
||||||
|
mov eax, 0 ; create and draw the window
|
||||||
mov eax, 4
|
mov ebx, 100*65536+400 ; (window_cx)*65536+(window_sx)
|
||||||
mov ebx, 10 shl 16 + 10
|
mov ecx, 100*65536+250 ; (window_cy)*65536+(window_sy)
|
||||||
mov ecx, 0x80000000
|
mov edx, 0x33ffffff ; work area color & window type 3
|
||||||
mov edx, text1
|
mov edi, head
|
||||||
int 0x40
|
int 0x40
|
||||||
mov eax, 4
|
|
||||||
mov ebx, 10 shl 16 + 20
|
mov eax, 4
|
||||||
mov edx, text2
|
mov ebx, 10 shl 16 + 10
|
||||||
int 0x40
|
mov ecx, 0x80000000
|
||||||
mov eax, 47
|
mov edx, text1
|
||||||
mov ebx, 0x00020000
|
int 0x40
|
||||||
movzx ecx, byte [format_id]
|
mov eax, 4
|
||||||
mov edx, 200 shl 16 + 20
|
mov ebx, 10 shl 16 + 20
|
||||||
mov esi, 0
|
mov edx, text2
|
||||||
int 0x40
|
int 0x40
|
||||||
|
mov eax, 47
|
||||||
mov eax, 8
|
mov ebx, 0x00020000
|
||||||
mov ebx, 10 shl 16 + 60
|
movzx ecx, byte [format_id]
|
||||||
mov ecx, 40 shl 16 + 15
|
mov edx, 200 shl 16 + 20
|
||||||
mov edx, 5
|
mov esi, 0
|
||||||
mov esi, 0xd72189
|
int 0x40
|
||||||
int 0x40
|
|
||||||
mov eax, 4
|
mov eax, 8
|
||||||
mov ebx, 12 shl 16 + 42
|
mov ebx, 10 shl 16 + 60
|
||||||
mov ecx, 0x80000000
|
mov ecx, 40 shl 16 + 15
|
||||||
mov edx, button1
|
mov edx, 5
|
||||||
int 0x40
|
mov esi, 0xd72189
|
||||||
|
int 0x40
|
||||||
mov eax, 8
|
mov eax, 4
|
||||||
mov ebx, 80 shl 16 + 60
|
mov ebx, 12 shl 16 + 42
|
||||||
mov ecx, 40 shl 16 + 15
|
mov ecx, 0x80000000
|
||||||
mov edx, 6
|
mov edx, button1
|
||||||
mov esi, 0xd72189
|
int 0x40
|
||||||
int 0x40
|
|
||||||
mov eax, 4
|
mov eax, 8
|
||||||
mov ebx, 82 shl 16 + 42
|
mov ebx, 80 shl 16 + 60
|
||||||
mov ecx, 0x80000000
|
mov ecx, 40 shl 16 + 15
|
||||||
mov edx, button2
|
mov edx, 6
|
||||||
int 0x40
|
mov esi, 0xd72189
|
||||||
|
int 0x40
|
||||||
mov edi, input_box
|
mov eax, 4
|
||||||
call edit_box.draw
|
mov ebx, 82 shl 16 + 42
|
||||||
|
mov ecx, 0x80000000
|
||||||
; mov eax, 4
|
mov edx, button2
|
||||||
; mov ebx, 10 shl 16 + 90
|
int 0x40
|
||||||
; mov ecx, 0
|
|
||||||
; mov edx, input_text
|
mov edi, input_box
|
||||||
; mov esi, [input_box + 38]
|
call edit_box.draw
|
||||||
; int 0x40
|
|
||||||
; mov eax, esi
|
; mov eax, 4
|
||||||
;print "eax = edit etxt len"
|
; mov ebx, 10 shl 16 + 90
|
||||||
;pregs
|
; mov ecx, 0
|
||||||
|
; mov edx, input_text
|
||||||
|
; mov esi, [input_box + 38]
|
||||||
|
; int 0x40
|
||||||
mov eax, 12 ; finish drawing
|
; mov eax, esi
|
||||||
mov ebx, 2
|
;print "eax = edit etxt len"
|
||||||
int 0x40
|
;pregs
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
mov eax, 12 ; finish drawing
|
||||||
|
mov ebx, 2
|
||||||
; <--- initialised data --->
|
int 0x40
|
||||||
DATA
|
|
||||||
|
ret
|
||||||
format_id db 1
|
|
||||||
|
|
||||||
; buffer db 256 dup(0)
|
|
||||||
|
; <--- initialised data --->
|
||||||
CLIP_BUFFER buffer, 256
|
DATA
|
||||||
|
|
||||||
input_text db 256 dup(0)
|
format_id db 1
|
||||||
input_box edit_box 100,10,70,0xffffff,0,0x00aaaaaa,0,255,input_text
|
|
||||||
|
; buffer db 256 dup(0)
|
||||||
; input_box edit_box 100,10,70,0xffffff,0,0xaaaaaa,0,\
|
|
||||||
; 0xaaaaaa,0,255,input_text,ed_always_focus
|
CLIP_BUFFER buffer, 256
|
||||||
|
|
||||||
head db "<22>ਬ¥à à ¡®âë á ¡ãä¥à®¬ ®¡¬¥ ",0
|
input_text db 256 dup(0)
|
||||||
text1 db "<22> ¦¨¬ ©â¥ æ¨äàë 0-9 ¤«ï ᬥë id ä®à¬ â ¤ ëå",0
|
input_box edit_box 100,10,70,0xffffff,0,0x00aaaaaa,0,255,input_text
|
||||||
text2 db "‘¥©ç á ¢ë¡à id ä®à¬ â ¤ ëå: ",0
|
|
||||||
|
; input_box edit_box 100,10,70,0xffffff,0,0xaaaaaa,0,\
|
||||||
button1 db "Š®¯¨à®¢ âì",0
|
; 0xaaaaaa,0,255,input_text,ed_always_focus
|
||||||
button2 db "‚áâ ¢¨âì",0
|
|
||||||
|
head db "<22>ਬ¥à à ¡®âë á ¡ãä¥à®¬ ®¡¬¥ ",0
|
||||||
; <--- uninitialised data --->
|
text1 db "<22> ¦¨¬ ©â¥ æ¨äàë 0-9 ¤«ï ᬥë id ä®à¬ â ¤ ëå",0
|
||||||
UDATA
|
text2 db "‘¥©ç á ¢ë¡à id ä®à¬ â ¤ ëå: ",0
|
||||||
|
|
||||||
|
button1 db "Š®¯¨à®¢ âì",0
|
||||||
MEOS_APP_END
|
button2 db "‚áâ ¢¨âì",0
|
||||||
; <--- end of MenuetOS application --->
|
|
||||||
|
; <--- uninitialised data --->
|
||||||
|
UDATA
|
||||||
|
|
||||||
|
|
||||||
|
MEOS_APP_END
|
||||||
|
; <--- end of MenuetOS application --->
|
Reference in New Issue
Block a user