2006-01-03 10:43:31 +01:00
|
|
|
|
;
|
|
|
|
|
; THREAD EXAMPLE
|
|
|
|
|
;
|
|
|
|
|
; Compile with FASM for Menuet
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
use32
|
|
|
|
|
org 0x0
|
|
|
|
|
|
|
|
|
|
db 'MENUET01' ; 8 byte id
|
|
|
|
|
dd 0x01 ; header version
|
|
|
|
|
dd START ; start of code
|
|
|
|
|
dd I_END ; size of image
|
2007-05-10 15:48:35 +02:00
|
|
|
|
dd 0x2000 ; memory for app
|
|
|
|
|
dd 0x2000 ; esp
|
2006-01-03 10:43:31 +01:00
|
|
|
|
dd 0x0 , 0x0 ; I_Param , I_Icon
|
|
|
|
|
|
|
|
|
|
include 'lang.inc'
|
2007-05-10 15:48:35 +02:00
|
|
|
|
include '..\..\..\..\macros.inc'
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
START: ; start of execution
|
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
red: ; redraw
|
2006-01-03 10:43:31 +01:00
|
|
|
|
call draw_window ; at first, draw the window
|
|
|
|
|
|
|
|
|
|
still:
|
|
|
|
|
|
|
|
|
|
mov eax,10 ; wait here for event
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
dec eax ; redraw request ?
|
2006-01-03 10:43:31 +01:00
|
|
|
|
je red
|
2007-05-10 15:48:35 +02:00
|
|
|
|
dec eax ; key in buffer ?
|
|
|
|
|
jne button
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
key: ; key
|
|
|
|
|
mov eax,2 ; just read it and ignore
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
jmp still
|
|
|
|
|
|
|
|
|
|
button: ; button
|
|
|
|
|
mov eax,17 ; get id
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
cmp ah,1 ; button id=1 ?
|
|
|
|
|
jne noclose
|
2007-05-10 15:48:35 +02:00
|
|
|
|
or eax,-1 ; close this program (thread)
|
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
noclose:
|
|
|
|
|
|
|
|
|
|
cmp ah,2
|
|
|
|
|
jne no_thread
|
|
|
|
|
|
|
|
|
|
cmp [thread_stack],0x1f00
|
|
|
|
|
jge no_thread
|
|
|
|
|
|
|
|
|
|
add [thread_stack],0x100
|
|
|
|
|
mov eax,51
|
|
|
|
|
mov ebx,1
|
|
|
|
|
mov ecx,START
|
|
|
|
|
mov edx,[thread_stack]
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
jmp still
|
|
|
|
|
|
|
|
|
|
no_thread:
|
|
|
|
|
|
|
|
|
|
jmp still
|
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
thread_stack dd 0x1000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; *********************************************
|
|
|
|
|
; ******* WINDOW DEFINITIONS AND DRAW ********
|
|
|
|
|
; *********************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
draw_window:
|
|
|
|
|
|
|
|
|
|
mov eax,12 ; function 12:tell os about windowdraw
|
|
|
|
|
mov ebx,1 ; 1, start of draw
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
; DRAW WINDOW
|
2007-05-10 15:48:35 +02:00
|
|
|
|
xor eax,eax ; function 0 : define and draw window
|
2006-01-03 10:43:31 +01:00
|
|
|
|
mov ebx,10*65536+290 ; [x start] *65536 + [x size]
|
|
|
|
|
mov ecx,10*65536+130 ; [y start] *65536 + [y size]
|
|
|
|
|
mov esi,[thread_stack]
|
|
|
|
|
sub esi,0x1000
|
|
|
|
|
shr esi,4
|
|
|
|
|
shl esi,16
|
|
|
|
|
add ebx,esi
|
|
|
|
|
add ecx,esi
|
2007-06-22 22:24:06 +02:00
|
|
|
|
mov edx,0x34ffffff ; color of work area RRGGBB,8->color gl
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mov edi,title ; WINDOW LABEL
|
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
mov eax,8 ; NEW THREAD BUTTON
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mov ebx,20*65536+128
|
|
|
|
|
mov ecx,63*65536+20
|
2006-01-03 10:43:31 +01:00
|
|
|
|
mov edx,2
|
|
|
|
|
mov esi,0x90b0d0 ;0x5577cc
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mov eax,4
|
|
|
|
|
mov ebx,20*65536+10 ; draw info text with function 4
|
2006-01-03 10:43:31 +01:00
|
|
|
|
mov ecx,0x224466
|
|
|
|
|
mov edx,text
|
|
|
|
|
mov esi,40
|
|
|
|
|
newline:
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
add ebx,10
|
|
|
|
|
add edx,40
|
|
|
|
|
cmp [edx],byte 'x'
|
|
|
|
|
jne newline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mov eax,12 ; function 12:tell os about windowdraw
|
|
|
|
|
mov ebx,2 ; 2, end of draw
|
2007-05-10 15:48:35 +02:00
|
|
|
|
mcall
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; DATA AREA
|
|
|
|
|
|
|
|
|
|
if lang eq ru
|
|
|
|
|
text:
|
2007-05-10 15:48:35 +02:00
|
|
|
|
db '<27><><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC> ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><>⮪<EFBFBD>, <20><><EFBFBD><EFBFBD>᪠<EFBFBD> '
|
|
|
|
|
db '<27><><EFBFBD><EFBFBD> <20> <20><><EFBFBD> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ࠧ. <20><><EFBFBD> <20>㦭<EFBFBD> '
|
|
|
|
|
db '⮫쪮 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>⤥<EFBFBD>쭮<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
db '<27><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>⮪<EFBFBD>. '
|
|
|
|
|
db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>⮪<EFBFBD><E2AEAA> <20><><EFBFBD><EFBFBD><EFBFBD>. '
|
2006-01-03 10:43:31 +01:00
|
|
|
|
db ' '
|
|
|
|
|
db ' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
db 'x' ; <- END MARKER, DONT DELETE
|
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
title db '<27>ਬ<EFBFBD><E0A8AC> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD> <20><>⮪<EFBFBD><E2AEAA>',0
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
else
|
|
|
|
|
text:
|
|
|
|
|
db 'THIS EXAMPLE CREATES THREADS BY RUNNING '
|
|
|
|
|
db 'THE SAME CODE MULTIPLE TIMES. ALL WE '
|
|
|
|
|
db 'NEED IS A NEW STACK FOR EACH THREAD. '
|
|
|
|
|
db 'ALL THREADS SHARE THE SAME MEMORY. '
|
|
|
|
|
db ' '
|
|
|
|
|
db ' '
|
|
|
|
|
db ' CREATE NEW THREAD '
|
|
|
|
|
db 'x' ; <- END MARKER, DONT DELETE
|
|
|
|
|
|
2007-05-10 15:48:35 +02:00
|
|
|
|
title db 'THREAD EXAMPLE',0
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
end if
|
|
|
|
|
I_END:
|