Changed structure of svn repository

git-svn-id: svn://kolibrios.org@109 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron
2006-07-28 13:39:16 +00:00
parent 5aa9386dcc
commit 630234432f
673 changed files with 20707 additions and 28013 deletions
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm circle.asm circle
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm circle.asm circle
@pause
@@ -0,0 +1,167 @@
;
; SHAPED WINDOW - BASIC EXAMPLE
;
; Compile with FASM for Menuet
;
use32
org 0x0
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x1000 ; required amount of memory
dd 0x1000 ; esp
dd 0x00000000 ; reserved=no extended header
include 'lang.inc'
include 'macros.inc'
START: ; start of execution
call shape_window ; function for shaping
call draw_window ; at first, draw the window
still:
mov eax,10 ; wait here for event
int 0x40
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
jmp still
red: ; redraw
call draw_window
jmp still
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
jmp still
shape_window:
pusha
mov eax,50 ; give the shape reference area
mov ebx,0
mov ecx,shape_reference
int 0x40
mov eax,50 ; give the shape scale 32 x 32 -> 128 x 128
mov ebx,1 ; you dont have to give this, scale is 1:1 by default
mov ecx,2
int 0x40
popa
ret
shape_reference: ; 32 x 32 ( window_size_X + 1 ) * ( window_size_Y + 1 )
db 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
db 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0
db 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
db 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0
db 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0
db 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
db 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536 ; [x start] *65536 + [x size]
mov ecx,100*65536 ; [y start] *65536 + [y size]
mov bx,word [x_size]
mov cx,word [y_size]
mov edx,0x00cccc00 ; color of work area RRGGBB,8->color glide
mov esi,0x00cccc00 ; color of grab bar RRGGBB,8->color glide
mov edi,0x00cccc00 ; color of frames RRGGBB
int 0x40
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,78*65536+12 ; [x start] *65536 + [x size]
mov ecx,20*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x5599cc ; button color RRGGBB
int 0x40
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
; DATA AREA
x_size dd 127
y_size dd 127
I_END:
@@ -0,0 +1,266 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm example.asm example
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm example.asm example
@pause
@@ -0,0 +1,177 @@
;
; ਬ¥à ¯à®£à ¬¬ë ¤«ï MenuetOS
; ®§¢ã稢 ¥â ª®¤ ­ ¦ â®© ª« ¢¨è¨ ;)
;
; Š®¬¯¨«¨à®¢ âì FASM'®¬
;
; ‘¬. â ª¦¥:
; template.asm - ¯à¨¬¥à ¯à®á⥩襩 ¯à®£à ¬¬ë (­®¢ë©!)
; rb.asm - ª®­â¥ªáâ­®¥ ¬¥­î à ¡®ç¥£® á⮫ 
; example2.asm - ¯à¨¬¥à ¬¥­î ¨ ¤®¯®«­¨â¥«ì­ëå ®ª®­
; example3.asm - ¯à¨¬¥à ¬¥­î, ॠ«¨§®¢ ­­®£® ¯®-¤à㣮¬ã
;---------------------------------------------------------------------
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï
db 'MENUET01' ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
dd START ;  ¤à¥á ¯¥à¢®© ª®¬ ­¤ë
dd I_END ; à §¬¥à ¯à®£à ¬¬ë
dd 0x1000 ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
dd 0x1000 ;  ¤à¥á ¢¥à設ë áâíª 
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
dd 0x0 ; § à¥§¥à¢¨à®¢ ­®
include 'lang.inc'
include 'macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§­ì  áᥬ¡«¥à騪®¢!
;---------------------------------------------------------------------
;--- €—€‹Ž Žƒ€ŒŒ› ----------------------------------------------
;---------------------------------------------------------------------
START:
red: ; ¯¥à¥à¨á®¢ âì ®ª­®
call draw_window ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª­ 
;---------------------------------------------------------------------
;--- –ˆŠ‹ ŽŽ’Šˆ ‘Ž›’ˆ‰ ----------------------------------------
;---------------------------------------------------------------------
still:
mcall 10 ; äã­ªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ?
je red ; ¥á«¨ ¤  - ­  ¬¥âªã red
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ?
je key ; ¥á«¨ ¤  - ­  key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ?
je button ; ¥á«¨ ¤  - ­  button
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
;---------------------------------------------------------------------
key: ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
mcall 2 ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®«  (¢ ah)
mov [Music+1], ah ; § ¯¨á âì ª®¤ ᨬ¢®«  ª ª ª®¤ ­®âë
; äã­ªæ¨ï 55-55: á¨á⥬­ë© ¤¨­ ¬¨ª ("PlayNote")
; esi -  ¤à¥á ¬¥«®¤¨¨
; mov eax,55
; mov ebx,eax
; mov esi,Music
; int 0x40
; ¨«¨ ª®à®âª®:
mcall 55, eax, , , Music
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
;---------------------------------------------------------------------
button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
cmp ah, 1 ; ¥á«¨ … ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
jne still ; ¢¥à­ãâìáï
.exit:
mcall -1 ; ¨­ ç¥ ª®­¥æ ¯à®£à ¬¬ë
;---------------------------------------------------------------------
;--- Ž…„…‹…ˆ… ˆ Ž’ˆ‘ނЀ ŽŠ€ ----------------------------------
;---------------------------------------------------------------------
draw_window:
mcall 12, 1 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
; 1 - ­ ç¨­ ¥¬ à¨á®¢ âì
; ¤ «¥¥: á­ ç «  ¤«¨­­ë© ¢ à¨ ­â (§ ª®¬¬¥­â¨à®¢ ­­ë©)
; § â¥¬ ª®à®âª¨©  ­ «®£ á ¨á¯®«ì§®¢ ­¨¥¬ ¬ ªà®á®¢
; ‘އ„€ðŒ ŽŠŽ
; mov eax,0 ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à]
; mov ecx,200*65536+100 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,0x02aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
; mov esi,0x805080d0 ; 梥⠯®«®áë § £®«®¢ª  RRGGBB,8->color gl
; mov edi,0x005080d0 ; 梥â à ¬ª¨ RRGGBB
; int 0x40
mcall 0, <200,200>, <200,50>, 0x02AABBCC, 0x805080D0, 0x005080D0
; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ
; mov eax,4 ; äã­ªæ¨ï 4 : ­ ¯¨á âì ¢ ®ª­¥ ⥪áâ
; mov ebx,8*65536+8 ; [x] *65536 + [y]
; mov ecx,0x10ddeeff ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
; mov edx,header ;  ¤à¥á áâப¨
; mov esi,header.size ; ¨ ¥ñ ¤«¨­ 
; int 0x40
mcall 4, <8,8>, 0x10DDEEFF, header, header.size
; mov eax,4
; mov ebx,8 shl 16 + 30
; mov ecx,0
; mov edx,message
; mov esi,message.size
; int 0x40
mcall 4, <8, 30>, 0, message, message.size
; ŠŽŠ€ ‡€Š›’ˆŸ ŽŠ
; mov eax,8 ; äã­ªæ¨ï 8 : ®¯à¥¤¥«¨âì ¨ ­ à¨á®¢ âì ª­®¯ªã
; mov ebx,(200-19)*65536+12 ; [x áâ àâ] *65536 + [x à §¬¥à]
; mov ecx,5*65536+12 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,1 ; ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨ - 1
; mov esi,0x6688dd ; 梥⠪­®¯ª¨ RRGGBB
; int 0x40
mcall 8, <200-19, 12>, <5, 12>, 1, 0x6688DD
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
; 2, § ª®­ç¨«¨ à¨á®¢ âì
ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë
;---------------------------------------------------------------------
;--- „€›… Žƒ€ŒŒ› ----------------------------------------------
;---------------------------------------------------------------------
; ‚®â â ª ï ¢®â ª®à®âª ï "¬¥«®¤¨ï".
; ‚â®à®© ¡ ©â ¨§¬¥­ï¥âáï ­ ¦ â¨¥¬ ª« ¢¨èë
Music:
db 0x90, 0x30, 0
;---------------------------------------------------------------------
; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
; ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
lsz message,\
ru,' ¦¬¨â¥ «î¡ãî ª« ¢¨èã...',\
en,'Press any key...',\
fr,'Pressez une touche...'
lsz header,\
ru,'ˆŒ… Žƒ€ŒŒ›',\
en,'EXAMPLE APPLICATION',\
fr,"L'exemplaire programme"
;---------------------------------------------------------------------
I_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
@@ -0,0 +1,267 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm example2.asm example2
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm example2.asm example2
@pause
@@ -0,0 +1,597 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; DIALOGS1.INC ;
; ;
; COMPILE WITH FASM for MENUET ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menus dd 3 ; number of menus
m_x dd 0x5 ; x start
m_y dd 20 ; y start
m_xs dd 290 ; x size
m_ys dd 14 ; y size
g_stack dd 0xf000 ; thread stack - required
menu:; AB C D E F G
db '*D FILE +Save File +Load File +- +Quit '
db '*B EDIT +Copy +Paste '
db '*B HELP +Setup +About.. '
db '@' ; end mark
; A : Data type '*' -> New menu , '+' -> menu selection
; B : Number of selections in menu (A+)
; C : Menu header text
; D-G : Menu selection text
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; DATA BELOW IS FOR DIALOGS1.INC INTERNALS
menu_action dd '----'
window_on db 0
g_n dd -1
g_x dd 0x0
g_t dd 0x0
g_1 dd 0x0
g_l dd 0x0
closet db 0
table: times 1024 db 0
last_mouse dd 0x0
mo_x dd 0x0
mo_y dd 0x0
check_mouse:
pusha
cmp [window_on],1
je no_open
mov eax,37
mov ebx,2
int 0x40
cmp [window_on],0
jne openw2
cmp eax,0
je no_open
openw2:
waitformouse:
mov eax,23
mov ebx,2
int 0x40
cmp eax,0
jne no_open
mov eax,37
mov ebx,2
int 0x40
cmp eax,0
jne waitformouse
mov eax,37
mov ebx,1
int 0x40
mov esi,eax
shr eax,16
xor edx,edx
mov ebx,50
div ebx
mov edx,eax
cmp edx,[g_n]
je no_open
cmp edx,[menus]
jge no_open
mov eax,esi
and eax,0xffff
mov ebx,[m_y]
cmp eax,ebx
jbe no_open
add ebx,[m_ys]
cmp eax,ebx
jge no_open
cmp [window_on],0
je noww
mov [closet],1
mov ecx,100
waitm:
mov eax,5
mov ebx,1
int 0x40
dec ecx
jz no_open
cmp [window_on],0
jne waitm
noww:
mov eax,edx
jmp cll
no_open:
mov [last_mouse],esi
popa
ret
cll:
mov [window_on],2
mov [g_n],eax
mov [g_x],96
mov [g_t],0
mov [g_1],1
mov eax,9
mov ebx,table
mov ecx,-1
int 0x40
mov eax,[table+34]
mov [mo_x],eax
mov eax,[table+38]
mov [mo_y],eax
mov eax,51
mov ebx,1
mov ecx,alert_entry
mov edx,[g_stack]
int 0x40
mov [esp+28],dword 0 ; clear button entry
mov [menu_action],'MD '
check_gr:
popa
ret
draw_menu:
mov eax,9
mov ebx,table
mov ecx,-1
int 0x40
cmp [table+46],dword 30
jb drmr
mov eax,13 ; white background
mov ebx,[m_x]
shl ebx,16
add ebx,[m_xs]
inc ebx
mov ecx,[m_y]
shl ecx,16
add ecx,[m_ys]
mov edx,0xf0f8ff
int 0x40
mov eax,38 ; egde lines
mov ebx,[m_x]
shl ebx,16
add ebx,[m_x]
add ebx,[m_xs]
mov ecx,[m_y]
shl ecx,16
add ecx,[m_y]
mov edx,0x000000
int 0x40
mov eax,38
mov ecx,[m_y]
add ecx,[m_ys]
shl ecx,16
add ecx,[m_y]
add ecx,[m_ys]
int 0x40
mov esi,menu-1
mov edi,[m_x]
mov ebp,1
new_menu:
inc esi
cmp [esi],byte '*'
jne drmnl1
push esi
mov eax,4
mov ebx,edi
shl ebx,16
add ebx,[m_y]
add ebx,0x00050004
mov ecx,0x000000
mov edx,esi
add edx,3
mov esi,12
int 0x40 ; draw text
pop esi
add esi,2
add edi,50
inc ebp
drmnl1:
cmp [esi],byte '@'
jne new_menu
drmr:
ret
alert_box:
; eax : x size - min 200
; ebx : pointer to ASCIIZ - max 128 character text
; ecx : button 1 id ( OK or YES )
; edx : button 2 id or zero ( NO )
cmp [window_on],0
jne alert_box_return
mov [window_on],1
cmp eax,100
jg size_ok
mov eax,100
size_ok:
mov [g_x],eax
mov [g_t],ebx
mov [g_1],ecx
mov ecx,0
new_search:
cmp [ebx],byte 0
je found_len
inc ebx
inc ecx
cmp ecx,128
jbe new_search
found_len:
mov [g_l],ecx
mov eax,51
mov ebx,1
mov ecx,alert_entry
mov edx,[g_stack]
int 0x40
mov [menu_action],'MA '
alert_box_return:
ret
alert_entry:
call alert_draw_window
alert_still:
mov eax,23 ; wait here for event
mov ebx,1
int 0x40
cmp eax,1 ; redraw request ?
je alert_red
cmp eax,2 ; key in buffer ?
je alert_key
cmp eax,3 ; button in buffer ?
je alert_button
cmp [closet],0
jne ccc
mov eax,9
mov ebx,table
mov ecx,-1
int 0x40
cmp ax,[table+4]
je no_close
ccc:
mov [closet],0
mov [g_n],-1
mov [menu_action],'----'
mov [window_on],0
mov eax,-1
int 0x40
no_close:
jmp alert_still
alert_red: ; redraw
call alert_draw_window
jmp alert_still
alert_key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp alert_still
alert_button: ; button
mov eax,17 ; get id
int 0x40
shr eax,8
cmp eax,3
jg no_action1
dec eax
shl eax,2
mov eax,dword [eax+rtext]
mov [menu_action],eax
jmp action_done
no_action1:
sub eax,16
add eax,65
shl eax,8
mov ebx,[g_n]
add ebx,65
add eax,ebx
mov [menu_action],eax
action_done:
mov [closet],0
mov [g_n],-1
mov [window_on],0
mov eax,-1 ; close this program
int 0x40
rtext db 'NO YES OK '
jmp alert_still
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
alert_draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
cmp [window_on],2
jne no_win_type_2
mov edx,menu-1
mov ecx,[g_n]
add ecx,1
find_menu:
inc edx
cmp [edx],byte '*'
je menu_loop
jmp find_menu
menu_loop:
loop find_menu
movzx ebp,byte [edx+1]
sub ebp,64
push edx
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,[g_n]
imul ebx,50
add ebx,[mo_x]
add ebx,[m_x]
shl ebx,16
add ebx,[g_x]
mov ecx,[mo_y]
add ecx,[m_y]
add ecx,[m_ys]
shl ecx,16
mov edx,14
imul edx,ebp
add edx,7
add ecx,edx
mov edx,0x00ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x00ffffff ; color of grab bar RRGGBB,8->color gl
mov edi,0x000000cc ; color of frames RRGGBB
int 0x40
pop edx
mov ebx,5*65536+7 ; draw info text with function 4
mov ecx,0x10000000
mov esi,12
mov ebp,16
no_d_found:
inc edx
cmp [edx],byte '*'
je d_drawed
cmp [edx],byte '@'
je d_drawed
cmp [edx],byte '+'
jne no_d_found
inc edx
pusha ; draw button
mov eax,8
mov ecx,ebx
mov ebx,[g_x]
add ebx,0x0000fffe
shl ecx,16
add ecx,0xfffc0000+14
mov edx,0x40000000
add edx,ebp
mov esi,0
int 0x40
popa
mov eax,4 ; draw text
int 0x40
inc ebp
add ebx,14
jmp no_d_found
d_drawed:
no_win_type_2:
cmp [window_on],1
jne no_win_1
mov eax,14 ; to middle of screen
int 0x40
mov ecx,eax
and ecx,0xffff
shr ecx,1
shr eax,1
mov ebx,[g_x]
shr ebx,1
shl ebx,16
sub eax,ebx
mov ebx,eax
mov eax,0 ; function 0 : define and draw window
mov bx,word [g_x]
sub ecx,80
shl ecx,16
mov cx,110 ; [y start] *65536 + [y size]
mov edx,0x02ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x80d05050 ; color of grab bar RRGGBB,8->color gl
mov edi,0x00d05050 ; color of frames RRGGBB
int 0x40
mov eax,4 ; label
mov ebx,8*65536+8
mov ecx,0x10ddeeff
mov edx,alert_labelt1
mov esi,alert_label1len-alert_labelt1
int 0x40
mov eax,4
mov ebx,10*65536+43
mov ecx,0x10000000
mov edx,[g_t]
mov esi,[g_l]
int 0x40
cmp [g_1],1
jne gadgets_no_1
mov eax,8
mov ebx,[g_x]
sub ebx,100
shr ebx,1
shl ebx,16
add ebx,30*65536+40
mov ecx,75*65536+16
mov edx,3
mov esi,0x446688
int 0x40
mov eax,4
mov ebx,[g_x]
sub ebx,100
shr ebx,1
shl ebx,16
add ebx,31*65536+80
mov ecx,0x10ffffff
mov edx,alert_t2
mov esi,alert_t2len-alert_t2
int 0x40
gadgets_no_1:
cmp [g_1],2
jne gadgets_no_2
mov eax,8
mov ebx,[g_x]
sub ebx,100
shr ebx,1
shl ebx,16
add ebx,0*65536+40
mov ecx,75*65536+16
mov edx,1
mov esi,0x446688
int 0x40
mov eax,8
mov ebx,[g_x]
sub ebx,100
shr ebx,1
shl ebx,16
add ebx,57*65536+40
mov ecx,75*65536+16
mov edx,2
mov esi,0x446688
int 0x40
mov eax,4
mov ebx,[g_x]
sub ebx,100
shr ebx,1
shl ebx,16
add ebx,1*65536+80
mov ecx,0x10ffffff
mov edx,alert_t1
mov esi,alert_t1len-alert_t1
int 0x40
gadgets_no_2:
no_win_1:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
; DATA AREA
alert_t1:
db ' No Yes'
alert_t1len:
alert_t2:
db ' OK'
alert_t2len:
alert_labelt1:
db 'ALERT'
alert_label1len:
@@ -0,0 +1,201 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; MENU / DIALOG 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
dd 0x10000 ; memory for app
dd 0x10000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
include 'lang.inc'
include 'macros.inc'
include 'dialogs1.inc'
menu_history dd 0x0
START: ; start of execution
call draw_window_main
still: ; wait here for event
mov eax,23
mov ebx,2
int 0x40
cmp eax,1 ; process events
je red
cmp eax,2
je key
cmp eax,3
je button
call check_mouse ; DIALOG CHECK
mov eax,[menu_action]
cmp eax,[menu_history]
je nodisplay
mov [menu_history],eax
mov eax,13
mov ebx,220*65536+6*4
mov ecx,70*65536+8
mov edx,0xffffff
int 0x40
mov eax,4 ; show menu selections
mov ebx,220*65536+70
mov ecx,0x000000
mov edx,menu_action
mov esi,4
int 0x40
nodisplay:
cmp word [menu_action],word 'AD' ; user requests close
jne no_menu_close
mov eax,-1
int 0x40
no_menu_close:
jmp still
red: ; redraw
call draw_window_main
jmp still
key:
mov eax,2 ; key in buffer
int 0x40
jmp still
button: ; button in buffer
mov eax,17
int 0x40
cmp ah,1 ; close application
jne noclose
mov eax,-1
int 0x40
noclose:
cmp ah,2
jne no_alert_box ; ALERT BOX
mov eax,170 ; window width
mov ebx,alert_text ; asciiz string
mov ecx,1 ; OK button
call alert_box ; function call
jmp still
no_alert_box:
cmp ah,3
jne no_choose_box ; CHOOSE BOX
mov eax,220 ; window width
mov ebx,choose_text ; asciiz string
mov ecx,2 ; YES/NO buttons
call alert_box ; function call
jmp still
no_choose_box:
jmp still
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window_main:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
mov eax,0 ; open window
mov ebx,100*65536+300
mov ecx,100*65536+120
mov edx,0x02ffffff
mov esi,0x805080d0
mov edi,0x005080d0
int 0x40
call draw_menu ; DRAW MENU
mov eax,4 ; window label
mov ebx,8*65536+8
mov ecx,0x10ddeeff
mov edx,labelt
mov esi,labellen-labelt
int 0x40
mov eax,8 ; close button
mov ebx,(300-17)*65536+10
mov ecx,5*65536+10
mov edx,1
mov esi,0x4466bb
int 0x40
mov eax,8 ; button : OPEN ALERT BOX
mov ebx,25*65536+150
mov ecx,61*65536+14
mov edx,2
mov esi,0x4466aa
int 0x40
mov eax,8 ; button : OPEN CHOOSE BOX
mov ebx,25*65536+150
mov ecx,81*65536+14
mov edx,3
mov esi,0x4466aa
int 0x40
mov ebx,20*65536+55 ; draw info text with function 4
mov ecx,0xffffff
mov edx,text
mov esi,40
newline:
mov eax,4
int 0x40
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
int 0x40
ret
; DATA AREA
text:
db ' '
db ' OPEN ALERT BOX '
db ' '
db ' OPEN CHOOSE BOX '
db 'x <- END MARKER, DONT DELETE '
labelt:
db 'EXAMPLE APPLICATION'
labellen:
alert_text db ' File not found !',0
choose_text db ' Save file before exit ? ',0
I_END:
@@ -0,0 +1,267 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm example3.asm example3
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm example3.asm example3
@pause
@@ -0,0 +1,433 @@
;
; MENU 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
dd 0x1000 ; memory for app
dd 0x1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
include 'lang.inc'
include 'macros.inc'
START: ; start of execution
call draw_window ; draw window
call clear_data ; clear status bar
still:
mov eax,10 ; wait here for event
int 0x40 ; do it
cmp eax,1 ; redraw request ?
je red ; yes jump to it
cmp eax,2 ; key in buffer ?
je key ; yes jump to it
cmp eax,3 ; button in buffer ?
je button ; yes jump to it
jmp still ; start again
red: ; redraw
call draw_window ; redraw window
call clear_data ; clear status info
jmp still ; start again
key: ; key
mov eax,2 ; just read it and ignore
int 0x40 ; do it
jmp still ; start again
button: ; button
mov eax,17 ; get id
int 0x40 ; do it
cmp ah,1 ; is it the close button
jne noclose ; no then jump code
mov eax,-1 ; close this program
int 0x40 ; do it
noclose:
cmp ah,100 ; is it main menu
jb not_menu ; no then jump code
cmp ah,104 ; is it main menu
ja not_menu ; no then jump code
call draw_window ; redraw window
call clear_data ; clear status info
call draw_data ; update status info
call write_sub ; draw a sub menu
jmp still ; start again
not_menu:
cmp ah,110 ; is it a sub menu
jb not_sub ; no then jump code
cmp ah,145 ; is it a sub menu
ja not_sub ; no then jump code
call draw_window ; redraw window
call clear_data ; clear status info
mov [button_press],1 ; sub button pressed
call draw_data ; update status info
mov [button_press],0 ; clear pressed
jmp still ; start again
not_sub:
jmp still ; start again
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
push eax ; save register
mov eax,12 ; function 12: tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40 ; do it
mov eax,0 ; function 0: define and draw window
mov ebx,50*65536 ; [x start] *65536
add ebx,[x_size] ; add [x size]
mov ecx,50*65536 ; [y start] *65536
add ecx,[y_size] ; add [y size]
mov edx,0x80ffffff ; colour of work area RRGGBB
mov esi,0x806688dd ; grab bar colour. negative glide
int 0x40 ; do it
mov eax,4 ; function 4: write text to window
mov ebx,6*65536+7 ; [x start] *65536 + [y start]
mov ecx,0x00ffffff ; text colour
mov edx,window_text ; pointer to text beginning
mov esi,12 ; text length
int 0x40 ; do it
mov eax,8 ; function 8: define and draw button
mov ebx,(381-18)*65536+13 ; [x start] *65536 + [x size]
mov ecx,4*65536+13 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40 ; do it
mov eax,13 ; function 13: draw bar
mov ebx,1*65536 ; [x start] *65536
add ebx,[x_size] ; add [x size]
dec ebx ; x size - 1
mov ecx,[y_size] ; [y start] *65536
sub ecx,17 ; minus height
shl ecx,16 ; *65536
add ecx,17 ; add height
mov edx,0x006688dd ; bar colour
int 0x40 ; do it
mov eax,4 ; function 4 : write text to window
mov ebx,5*65536 ; [x start] *65536
add ebx,[y_size] ; add [y start]
sub ebx,12 ; move up
xor ecx,ecx ; text colour
mov edx,button_no ; pointer to text beginning
mov esi,14 ; text length
int 0x40 ; do it
add ebx,95*65536 ; move xy position
mov edx,menu_text ; pointer to text beginning
int 0x40 ; do it
call write_main ; draw menu
mov eax,12 ; function 12: tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40 ; do it
pop eax ; restore register
ret ; return
; ************* WRITE MAIN *************
write_main:
mov eax,13 ; function 13: draw bar
mov ebx,1*65536 ; [x start] *65536
add ebx,[x_size] ; +[x_size]
dec ebx ; x size - 1
mov ecx,21*65536+17 ; [y start] *65536 +[y size]
mov edx,[menu_colour] ; menu colour
int 0x40 ; do it
mov [main_pos],1 ; start position first button
xor edi,edi ; data offset = 0
next_main_item:
mov al,[MENU_DATA+edi] ; get byte at menu_data + offset
cmp al,'E' ; is it the END
je main_get_out ; yes then exit
cmp al,'0' ; is it a main menu item
jne not_main_menu ; no then jump code
main_menu:
mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1
cmp al,'0' ; is it a divider
je is_main_bar ; yes then jump code
mov eax,8 ; function 8: define button
mov ebx,[main_pos] ; [x start]
shl ebx,16 ; *65536
add bl,75 ; +[x size]
mov ecx,21*65536+16 ; [y start] *65536 +[y size]
xor edx,edx ; clear register
mov dl,[MENU_DATA+edi+2] ; get byte button id number
mov esi,[menu_colour] ; button colour
int 0x40 ; do it
mov eax,4 ; function 4: write text to window
add ebx,6*65536-49 ; move xy position
xor ecx,ecx ; text colour
mov edx,MENU_DATA+3 ; point at menu text
add edx,edi ; add our offset
mov esi,11 ; number of characters
int 0x40 ; do it
is_main_bar:
add [main_pos],76 ; update button position
not_main_menu:
add edi,14 ; update offset
jmp next_main_item ; do next menu item
main_get_out:
ret ; return
; *********** DRAW DATA ***********
draw_data:
push eax ; save register
mov ebx,0x00030000 ; display 3 decimal characters
xor ecx,ecx ; clear register
mov cl,ah ; swap data
mov eax,47 ; function 47: display number to window
mov edx,70*65536 ; [x start] *65536
add edx,[y_size] ; +[y start]
sub edx,12 ; move position
xor esi,esi ; text colour
int 0x40 ; do it
pop eax ; restore register
cmp [button_press],1 ; has a sub button been pressed
je draw_get_out ; then jump code
push eax ; save register
xor edx,edx ; clear register
shr ax,8 ; move button id into al
sub eax,100 ; subtract 100
mov dx,14 ; use record length as multiplier
mul dx ; multiply
mov edx,eax ; swap registers
add edx,MENU_DATA ; add offset
inc edx ; add 1
mov ebx,188*65536 ; [x start] *65536
add ebx,[y_size] ; +[y start]
sub ebx,12 ; move position
mov esi,1 ; 1 character
mov eax,4 ; function 4: write text to window
xor ecx,ecx ; text colour
int 0x40 ; do it
pop eax ; restore register
draw_get_out:
ret ; return
; **************** CLEAR DATA ******************
clear_data:
push eax ; save register
mov eax,13 ; function 13: draw bar
mov ebx,67*65536+23 ; [x start] *65536 +[x size]
mov ecx,[y_size] ; [y start]
sub ecx,15 ; move position
shl ecx,16 ; *65536
add ecx,13 ; [y size]
mov edx,0x00aaaaaa ; bar colour
int 0x40 ; do it
mov ebx,185*65536+11 ; move position
int 0x40 ; do it again
pop eax ; restore register
ret ; return
; ************* WRITE SUB *************
write_sub:
push eax ; save register
mov [but_pos],38 ; y start position offset
mov [sub_pos],1 ; x start position offset
xor edx,edx ; clear register
shr ax,8 ; move button id into al
sub eax,100 ; subtract 100
mov dx,76 ; menu width + 1
mul dx ; multiply
add [sub_pos],eax ; add menu position to offset
pop eax ; restore register
xor edx,edx ; clear register
shr ax,8 ; move button id into al
sub eax,100 ; subtract 100
mov dx,14 ; use record length as multiplier
mul dx ; multiply
add eax,MENU_DATA ; add offset
inc eax ; plus 1
mov al,[eax] ; get menu number byte
mov [menu_number],al ; save it
xor edi,edi ; clear offset
next_sub_item:
mov al,[MENU_DATA+edi] ; get byte at menu_data + offset
cmp al,'E' ; is it the END
je sub_get_out ; yes then exit
cmp al,[menu_number] ; is it sub menu item
jne not_sub_menu ; no then jump code
sub_menu:
mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1
cmp al,'0' ; is it a divider
jne is_sub_button ; no then jump code
mov eax,13 ; function 13: draw bar
mov edx,[menu_colour] ; bar colour
mov ebx,[sub_pos] ; [x start]
shl ebx,16 ; *65536
add ebx,76 ; [x size]
mov ecx,[but_pos] ; [y start]
shl ecx,16 ; *65536
add ecx,17 ; [y size]
int 0x40 ; do it
jmp is_sub_bar ; jump button code
is_sub_button:
mov eax,8 ; function 8: define and draw button
xor edx,edx ; clear register
mov dl,[MENU_DATA+edi+2] ; get byte button id number
mov ebx,[sub_pos] ; [x start]
shl ebx,16 ; *65536
add ebx,75 ; [x size]
mov ecx,[but_pos] ; [y start]
shl ecx,16 ; *65536
add ecx,16 ; [y size]
mov esi,[menu_colour] ; button colour
int 0x40 ; do it
mov ebx,[sub_pos] ; [x start]
shl ebx,16 ; *65536
add ebx,6*65536 ; move position
add ebx,[but_pos] ; [y start]
add bl,5 ; move position
xor ecx,ecx ; clear register
mov edx,MENU_DATA+3 ; point to button text
add edx,edi ; add offset
mov esi,11 ; number of characters
mov eax,4 ; function 4: write text to window
int 0x40 ; do it
is_sub_bar:
add [but_pos],17 ; move y position
not_sub_menu:
add edi,14 ; move offset
jmp next_sub_item ; do next button
sub_get_out:
ret ; return
; ***************** DATA AREA ******************
x_size: dd 381 ; window x size
y_size: dd 200 ; window y size
window_text db 'MENU EXAMPLE' ; grab bar text
button_no db 'BUTTON No: ' ; status bar text
menu_text db 'MENU SELECTED:' ; status bar text
button_press dd 0
menu_colour dd 0x00aaaaaa ; menu & button colour
menu_number db '0' ; menu selection
sub_pos dd 1 ; sub menu x position
but_pos dd 38 ; sub menu y position
main_pos dd 1 ; main menu x position
MENU_DATA: db '01' ; MAIN MENU = 0 - 1 = menu
db 100 ; button id
db 'FILE ' ; button text
db '02' ; MAIN MENU = 0 - 2 = menu
db 101 ; button id
db 'EDIT ' ; button text
db '04' ; MAIN MENU = 0 - 3 = menu
db 102 ; button id
db 'TEST ' ; button text
db '00' ; MAIN MENU = 0 - 0 = divider
db 103 ; SPACER ID
db ' ' ; SPACER TEXT padding
db '03' ; MAIN MENU = 0 - 4 = menu
db 104 ; button id
db 'HELP ' ; button text
db '11' ; menu level = 1 - 1 = button
db 110 ; button id
db 'LOAD ' ; button text
db '11' ; menu level = 1 - 1 = button
db 111 ; button id
db 'SAVE ' ; button text
db '10' ; menu level = 1 - 0 = divider
db 112 ; SPACER ID
db ' ' ; SPACER TEXT padding
db '11' ; menu level = 1 - 1 = button
db 113 ; button id
db 'QUIT ' ; button text
db '21' ; menu level = 2 - 1 = button
db 120 ; button id
db 'COPY ' ; button text
db '21' ; menu level = 2 - 1 = button
db 121 ; button id
db 'PASTE ' ; button text
db '31' ; menu level = 3 - 1 = button
db 130 ; button id
db 'SETUP ' ; button text
db '31' ; menu level = 3 - 1 = button
db 131 ; button id
db 'ABOUT.. ' ; button text
db '41' ; menu level = 3 - 1 = button
db 140 ; button id
db 'TEST 1 ' ; button text
db '41' ; menu level = 3 - 1 = button
db 141 ; button id
db 'TEST 2 ' ; button text
db '41' ; menu level = 3 - 1 = button
db 142 ; button id
db 'TEST 3 ' ; button text
db '41' ; menu level = 3 - 1 = button
db 143 ; button id
db 'TEST 4 ' ; button text
db '41' ; menu level = 3 - 1 = button
db 144 ; button id
db 'TEST 5 ' ; button text
db '41' ; menu level = 3 - 1 = button
db 145 ; button id
db 'TEST 6 ' ; button text
db 'END' ; IMPORTANT need an END
I_END:
@@ -0,0 +1,267 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm hello.asm hello
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm hello.asm hello
@pause
@@ -0,0 +1,221 @@
include "macros.inc"
initipc:
mov eax,9
mov ebx,prc
mov ecx,-1
int 0x40
mov ecx,eax
loop1:
push ecx
mov eax,9
mov ebx,prc
int 0x40
cmp word [prc+10],'CM'
jne no_cmd
cmp byte [prc+12],'D'
jne no_cmd
mov ebx,[prc+30]
mov dword [cmdpid],ebx
mov dword [cmdnumb],ecx
no_cmd:
pop ecx
loop loop1
cmp dword [cmdpid],0
jne no_exit
jmp exit
no_exit:
mov eax,60
mov ebx,2
mov ecx,dword [cmdpid]
mov edx,printf
mov esi,4
int 0x40
call initcmd
waitcmdinit:
mov eax,40
mov ebx,01000000b
int 0x40
mov eax,23
mov ebx,100
int 0x40
cmp eax,7
je cmd_ok
jmp exit
cmd_ok:
cmp byte [ipcb+16],'.'
jne exit
mov eax,18
mov ebx,3
mov ecx,dword [cmdnumb]
int 0x40
ret
pause1:
mov eax,5
mov ebx,1
int 0x40
ret
exit:
mov eax,-1
int 0x40
cls:
mov eax,60
mov ebx,2
mov ecx,dword [cmdpid]
mov edx,ipccls
mov esi,4
int 0x40
call pause1
ret
print:
mov ecx,84
loopprt:
mov edi,stripc
add edi,ecx
mov esi,fill_symbol
movsb
loop loopprt
cld
mov ecx,4
mov edi,stripc
mov esi,printf
rep movsb
cld
mov edx,79
sub edx,eax
mov ecx,79
sub ecx,edx
mov edi,stripc+4
mov esi,ebx
rep movsb
mov eax,60
mov ebx,2
mov ecx,dword [cmdpid]
mov edx,stripc
mov esi,84
int 0x40
call pause1
ret
eol:
mov eax,60
mov ebx,2
mov ecx,dword [cmdpid]
mov edx,ipceol
mov esi,4
int 0x40
call pause1
ret
initcmd:
mov eax,60
mov ebx,2
mov ecx,dword [cmdpid]
mov edx,ipckey
mov esi,4
int 0x40
mov eax,60
mov ebx,1
mov ecx,ipcb
mov edx,28
int 0x40
cld
mov ecx,28
mov edi,ipcb
mov esi,ipcc
rep movsb
ret
getkey:
call initcmd
waitagain:
mov eax,40
mov ebx,01000000b
int 0x40
mov eax,10
int 0x40
cmp eax,7
jne waitagain
mov edi,key
mov esi,ipcb+16
movsb
ret
endipc:
mov eax,60
mov ebx,2
mov ecx,dword [cmdpid]
mov edx,ipcend
mov esi,4
int 0x40
jmp exit
cmdpid dd 0
cmdnumb dd 0
printf db '~ppp'
ipceol db '~lll'
ipcend db '~eee'
ipccls db '~ccc'
ipckey db '~kkk'
key db 0
ipcb:
db 0
db 0,0,0
dd 8
times 20 db 0
ipcc:
db 0
db 0,0,0
dd 8
times 20 db 0
stripc: times 84 db 0
fill_symbol db 0
prc: times 52 db 0
@@ -0,0 +1,71 @@
; Hello, World! - Programm example for CMD shell
; Compile with FASM for Menuet
;
; You must run this program from CMD shell only
;
use32
org 0x0
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x100000
dd 0x7fff0
dd 0x0
dd 0x0
include "lang.inc"
include "cmdipc.inc" ; ®¤ª«îç¨âì ä ©« CMDIPC.INC
START:
call initipc ; ¨­¨æ¨ «¨§¨à®¢ âì ¤«ï à ¡®âë á CMD
mov eax,26 ; „«¨­  áâப¨
mov ebx,hello_text ; “ª § â¥«ì ­  áâபã
call print ; ‚뢥á⨠áâபã
again:
call getkey ; ަ¨¤ âì ­ ¦ â¨ï ª« ¢¨è¨ ¨ áç¨â âì ¥¥ ¢ key
cmp byte [key],'Y' ; ’ã⠯ணࠬ¬  ¯à®¢¥àï¥â, ­ ¦ â  «¨ ­ã¦­. ª« ¢¨è 
je goodday
cmp byte [key],'y'
je goodday
cmp byte [key],'N'
je goodmorning
cmp byte [key],'n'
je goodmorning
jmp again ; …᫨ ­ã¦­. ª« ¢¨è  ­¥ ­ ¦ â , â® áç¨â âì ª« ¢¨èã
; § ­®¢®
goodday: ; ‚뢥á⨠¯à¨¢¥âá⢨¥ Good Day, World!
call eol ; யãáâ¨âì áâபã
mov eax,16
mov ebx,text4
call print
call eol ; யãáâ¨âì áâபã
jmp endipc ; ‡ ¢¥àè¨âì ¯à®£à ¬¬ã
goodmorning: ; ‚뢥á⨠¯à¨¢¥âá⢨¥ Good Morning, World!
call eol
mov eax,20
mov ebx,text5
call print
call eol
jmp endipc ; ‡ ¢¥àé¨âì ¯à®£à ¬¬ã
hello_text db 'Is it after 12 noon? [Y\N]?'
text4 db 'Good day, World!'
text5 db 'Good morning, World!'
I_END:
@@ -0,0 +1,265 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm template.asm template
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm template.asm template
@pause
@@ -0,0 +1,266 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; language for programs
lang fix ru ; ru en fr ge fi
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,102 @@
; <--- description --->
; compiler: FASM 1.50
; name: Basic window example for MenuetOS
; version: 1.01
; last update: 25/08/2004
; written by: Ivan Poddubny
; e-mail: ivan-yar@bk.ru
; <--- include all MeOS stuff --->
include "lang.inc"
include "macros.inc"
; <--- start of MenuetOS application --->
MEOS_APP_START
; <--- start of code --->
CODE
call draw_window ; at first create and draw the window
wait_event: ; main cycle
mov eax, 10
int 0x40
cmp eax, 1 ; if event == 1
je redraw ; jump to redraw handler
cmp eax, 2 ; else if event == 2
je key ; jump to key handler
cmp eax, 3 ; else if event == 3
je button ; jump to button handler
jmp wait_event ; else return to the start of main cycle
redraw: ; redraw event handler
call draw_window
jmp wait_event
key: ; key event handler
mov eax, 2 ; get key code
int 0x40
jmp wait_event
button: ; button event handler
mov eax, 17 ; get button identifier
int 0x40
cmp ah, 1
jne wait_event ; return if button id != 1
or eax, -1 ; exit application
int 0x40
draw_window:
mov eax, 12 ; start drawing
mov ebx, 1
int 0x40
mov eax, 0 ; create and draw the window
mov ebx, 100*65536+300 ; (window_cx)*65536+(window_sx)
mov ecx, 100*65536+200 ; (window_cy)*65536+(window_sy)
mov edx, 0x03ffffff ; work area color & window type 3
; mov esi, 0 ; grab color (not used)
; mov edi, 0 ; frame color (not used)
int 0x40
mov eax, 4 ; window header
mov ebx, 8*65536+8 ; coordinates
mov ecx, 0x10ffffff ; color & font N1
mov edx, header ; address of text
mov esi, header.size ; length of text
int 0x40
mov eax, 12 ; finish drawing
mov ebx, 2
int 0x40
ret
; <--- initialised data --->
DATA
lsz header,\
ru, "˜ ¡«®­ ¯à®£à ¬¬ë",\
en, "Template program",\
fr, "La programme poncive"
; <--- uninitialised data --->
UDATA
MEOS_APP_END
; <--- end of MenuetOS application --->
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm thread.asm thread
@pause
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm thread.asm thread
@pause
@@ -0,0 +1,266 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; language for programs
lang fix ru ; ru en fr ge fi
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
@@ -0,0 +1,175 @@
;
; 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
dd 0x2000 ; memory for app
dd 0x1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
include 'lang.inc'
include 'macros.inc'
START: ; start of execution
call draw_window ; at first, draw the window
still:
mov eax,10 ; wait here for event
int 0x40
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
jmp still
red: ; redraw
call draw_window
jmp still
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program (thread)
int 0x40
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]
int 0x40
jmp still
no_thread:
jmp still
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
int 0x40
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
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
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x808899ff ; color of grab bar RRGGBB,8->color gl
mov edi,0x008899ff ; color of frames RRGGBB
int 0x40
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
mov eax,8 ; NEW THREAD BUTTON
mov ebx,25*65536+128
mov ecx,88*65536+20
mov edx,2
mov esi,0x90b0d0 ;0x5577cc
int 0x40
mov ebx,25*65536+35 ; draw info text with function 4
mov ecx,0x224466
mov edx,text
mov esi,40
newline:
mov eax,4
int 0x40
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
int 0x40
ret
; DATA AREA
if lang eq ru
text:
db '’€ Žƒ€ŒŒ€ ‘އ„€…’ Ž’ŽŠˆ, ‡€“‘Š€Ÿ '
db 'Ž„ˆ ˆ ’Ž’ †… ŠŽ„ ŒŽƒŽ €‡. €Œ “†Ž '
db '’Ž‹œŠŽ އ€Ž’ˆ’œ‘Ÿ Ž Ž’„…‹œŽŒ ‘’Š… '
db '„‹Ÿ Š€†„ŽƒŽ Ž’ŽŠ€. '
db '€ŒŸ’œ „‹Ÿ ‚‘…• Ž’ŽŠŽ‚ Ž™€Ÿ. '
db ' '
db ' ‘އ„€’œ Ž‚›‰ Ž’ŽŠ '
db 'x' ; <- END MARKER, DONT DELETE
labelt:
db 'ˆŒ… ˆ‘Ž‹œ‡Ž‚€ˆŸ 51®© ”“Š–ˆˆ'
labellen:
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
labelt:
db 'THREAD EXAMPLE'
labellen:
end if
I_END: