forked from KolibriOS/kolibrios
Addition to a previous revision.
git-svn-id: svn://kolibrios.org@3529 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
655ab2c435
commit
560ccdd0f3
@ -1,153 +1,172 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; <20>à®á⮩ ¯à¨¬¥à ¯à®£à ¬¬ë ¤«ï KolibriOS
|
||||||
; ;
|
; ®§¢ã稢 ¥â ª®¤ ¦ ⮩ ª« ¢¨è¨
|
||||||
; EXAMPLE APPLICATION ;
|
|
||||||
; ;
|
|
||||||
; Compile with FASM ;
|
|
||||||
; ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
; The header
|
|
||||||
|
|
||||||
use32 ; Tell compiler to use 32 bit instructions
|
|
||||||
|
|
||||||
org 0x0 ; the base address of code, always 0x0
|
|
||||||
|
|
||||||
db 'MENUET01'
|
|
||||||
dd 0x01
|
|
||||||
dd START
|
|
||||||
dd I_END
|
|
||||||
dd 0x100000
|
|
||||||
dd 0x7fff0
|
|
||||||
dd 0, 0
|
|
||||||
|
|
||||||
; The code area
|
|
||||||
|
|
||||||
include 'macros.inc'
|
|
||||||
|
|
||||||
START: ; start of execution
|
|
||||||
call draw_window ; draw the window
|
|
||||||
|
|
||||||
; After the window is drawn, it's practical to have the main loop.
|
|
||||||
; Events are distributed from here.
|
|
||||||
|
|
||||||
event_wait:
|
|
||||||
mov eax, 10 ; function 10 : wait until event
|
|
||||||
mcall ; event type is returned in eax
|
|
||||||
|
|
||||||
cmp eax, 1 ; Event redraw request ?
|
|
||||||
je red ; Expl.: there has been activity on screen and
|
|
||||||
; parts of the applications has to be redrawn.
|
|
||||||
|
|
||||||
cmp eax, 2 ; Event key in buffer ?
|
|
||||||
je key ; Expl.: User has pressed a key while the
|
|
||||||
; app is at the top of the window stack.
|
|
||||||
|
|
||||||
cmp eax, 3 ; Event button in buffer ?
|
|
||||||
je button ; Expl.: User has pressed one of the
|
|
||||||
; applications buttons.
|
|
||||||
|
|
||||||
jmp event_wait
|
|
||||||
|
|
||||||
; The next section reads the event and processes data.
|
|
||||||
|
|
||||||
red: ; Redraw event handler
|
|
||||||
call draw_window ; We call the window_draw function and
|
|
||||||
jmp event_wait ; jump back to event_wait
|
|
||||||
|
|
||||||
key: ; Keypress event handler
|
|
||||||
mov eax, 2 ; The key is returned in ah. The key must be
|
|
||||||
mcall ; read and cleared from the system queue.
|
|
||||||
jmp event_wait ; Just read the key, ignore it and jump to event_wait.
|
|
||||||
|
|
||||||
button: ; Buttonpress event handler
|
|
||||||
mov eax,17 ; The button number defined in window_draw
|
|
||||||
mcall ; is returned to ah.
|
|
||||||
|
|
||||||
cmp ah,1 ; button id=1 ?
|
|
||||||
jne noclose
|
|
||||||
mov eax,-1 ; Function -1 : close this program
|
|
||||||
mcall
|
|
||||||
|
|
||||||
noclose:
|
|
||||||
jmp event_wait ; This is for ignored events, useful at development
|
|
||||||
|
|
||||||
; *********************************************
|
|
||||||
; ****** WINDOW DEFINITIONS AND DRAW ********
|
|
||||||
; *********************************************
|
|
||||||
;
|
;
|
||||||
; The static window parts are drawn in this function. The window canvas can
|
; Š®¬¯¨«¨à®¢ âì FASM'®¬
|
||||||
; be accessed later from any parts of this code (thread) for displaying
|
; Œ®¦® ®âªàëâì example.asm ç¥à¥§ ¯à®£à ¬¬ã FASM (¥ñ ïà«ëª ¥áâì
|
||||||
; processes or recorded data, for example.
|
; à ¡®ç¥¬ á⮫¥)
|
||||||
|
; € ¬®¦® ¯à®áâ® ¦ âì F9 ¢ Tinypad'¥. ‹®£ ª®¬¯¨«ï樨
|
||||||
|
; ®â®¡à ¦ ¥âáï ¤®áª¥ ®â« ¤ª¨ (¯à®£à ¬¬ BOARD)
|
||||||
;
|
;
|
||||||
; The static parts *must* be placed within the fn 12 , ebx = 1 and ebx = 2.
|
; —â® ¢ ¦® § âì ¯à¨ ¯à®£à ¬¬¨à®¢ ¨¨ ¯®¤ Š®«¨¡à¨:
|
||||||
|
; <20>®¬¥à äãªæ¨¨ ¯®¬¥é ¥âáï ¢ ॣ¨áâà eax.
|
||||||
|
; ‚맮¢ á¨á⥬®© äãªæ¨¨ ®áãé¥á⢫ï¥âáï ª®¬ ¤®© "int 0x40".
|
||||||
|
; ‚ᥠॣ¨áâàë, ªà®¬¥  㪠§ ëå ¢ ¢®§¢à é ¥¬®¬ § 票¨,
|
||||||
|
; ¢ª«îç ï ॣ¨áâà ä« £®¢ eflags, á®åà ïîâáï.
|
||||||
|
;
|
||||||
|
; <20>ਬ¥à:
|
||||||
|
; mov eax, 1 ;”ãªæ¨ï 1 - ¯®áâ ¢¨âì â®çªã ¢ ®ª¥
|
||||||
|
; ;ᯨ᮪ á¨áäãªæ¨© á¬. ¢ DOCPACK - sysfuncr.txt
|
||||||
|
; mov ebx, 10 ; ª®®à¤¨ â x=10
|
||||||
|
; mov ecx, 20 ; ª®®à¤¨ â y=10
|
||||||
|
; mov edx, 0xFFFfff ;梥â â®çª¨
|
||||||
|
; int 0x40 ;¢ë§¢ âì äãªæ¨î
|
||||||
|
;
|
||||||
|
; ’®¦¥ á ¬®¥ á ¨á¯®«ì§®¢ ¨¥¬ ¬ ªà®á :
|
||||||
|
; mcall 1, 10, 20, 0xFFFfff
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
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' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§ì áᥬ¡«¥à騪®¢!
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
;--- <20>€—€‹Ž <20><>Žƒ<C5BD>€ŒŒ› ----------------------------------------------
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
START:
|
||||||
|
|
||||||
|
red: ; ¯¥à¥à¨á®¢ âì ®ª®
|
||||||
|
|
||||||
|
call draw_window ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
;--- –ˆŠ‹ Ž<><C5BD>€<EFBFBD>Ž’Šˆ ‘Ž<E28098>›’ˆ‰ ----------------------------------------
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
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 ; ¥á«¨ <20>… ¦ â ª®¯ª á ®¬¥à®¬ 1,
|
||||||
|
jne still ; ¢¥àãâìáï
|
||||||
|
|
||||||
|
.exit:
|
||||||
|
mcall -1 ; ¨ ç¥ ª®¥æ ¯à®£à ¬¬ë
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
;--- Ž<><C5BD>…„…‹…<E280B9>ˆ… ˆ Ž’<C5BD>ˆ‘Ž‚Š€ ŽŠ<C5BD>€ ----------------------------------
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
draw_window:
|
draw_window:
|
||||||
mov eax, 12 ; function 12: tell os about windowdraw
|
|
||||||
mov ebx, 1 ; 1, start of draw
|
mcall 12, 1 ; äãªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª
|
||||||
mcall
|
; 1 - ç¨ ¥¬ à¨á®¢ âì
|
||||||
|
|
||||||
mov eax, 0 ; function 0 : define and draw window
|
; ¤ «¥¥: á ç « ¤«¨ë© ¢ ਠâ (§ ª®¬¬¥â¨à®¢ ë©)
|
||||||
mov ebx, 100 * 65536 + 300 ; [x start] *65536 + [x size]
|
; § ⥬ ª®à®âª¨© «®£ á ¨á¯®«ì§®¢ ¨¥¬ ¬ ªà®á®¢
|
||||||
mov ecx, 100 * 65536 + 120 ; [y start] *65536 + [y size]
|
|
||||||
mov edx, 0x14ffffff ; color of work area RRGGBB
|
|
||||||
; 0x02000000 = window type 4 (fixed size, skinned window)
|
; ‘Ž‡„€ðŒ ŽŠ<C5BD>Ž
|
||||||
mov esi, 0x808899ff ; color of grab bar RRGGBB
|
; mov eax,0 ; äãªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª®
|
||||||
; 0x80000000 = color glide
|
; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à]
|
||||||
mov edi, title
|
; mov ecx,200*65536+50 ; [y áâ àâ] *65536 + [y à §¬¥à]
|
||||||
mcall
|
; mov edx,0x33aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
|
||||||
|
; mov edi,header ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ<C5BD>€
|
||||||
mov ebx, 25 * 65536 + 35 ; draw info text with function 4
|
; int 0x40
|
||||||
mov ecx, 0x224466
|
|
||||||
mov edx, text
|
mcall 0, <200,200>, <200,50>, 0x33AABBCC,,title
|
||||||
mov esi, 40
|
|
||||||
mov eax, 4
|
|
||||||
|
|
||||||
.newline: ; text from the DATA AREA
|
; mov eax,4
|
||||||
mcall
|
; mov ebx,3 shl 16 + 8
|
||||||
add ebx, 10
|
; mov ecx,0
|
||||||
add edx, 40
|
; mov edx,message
|
||||||
cmp byte[edx], 0
|
; mov esi,message.size
|
||||||
jne .newline
|
; int 0x40
|
||||||
|
|
||||||
mov eax, 12 ; function 12:tell os about windowdraw
|
mcall 4, <3, 8>, 0, message, message.size
|
||||||
mov ebx, 2 ; 2, end of draw
|
|
||||||
mcall
|
mcall 12, 2 ; äãªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª
|
||||||
|
; 2, § ª®ç¨«¨ à¨á®¢ âì
|
||||||
ret
|
|
||||||
|
ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë
|
||||||
; *********************************************
|
|
||||||
; ************* DATA AREA *****************
|
|
||||||
; *********************************************
|
;---------------------------------------------------------------------
|
||||||
;
|
;--- „€<E2809E><E282AC>›… <20><>Žƒ<C5BD>€ŒŒ› ----------------------------------------------
|
||||||
; Data can be freely mixed with code to any parts of the image.
|
;---------------------------------------------------------------------
|
||||||
; Only the header information is required at the beginning of the image.
|
|
||||||
|
; ‚®â â ª ï ¢®â ª®à®âª ï "¬¥«®¤¨ï".
|
||||||
text db "It look's like you have just compiled "
|
; ‚â®à®© ¡ ©â ¨§¬¥ï¥âáï ¦ ⨥¬ ª« ¢¨èë
|
||||||
db "your first program for KolibriOS. "
|
|
||||||
db " "
|
Music:
|
||||||
db "Congratulations! ", 0
|
db 0x90, 0x30, 0
|
||||||
|
|
||||||
title db "Example application", 0
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
I_END:
|
|
||||||
|
; ¨â¥àä¥©á ¯à®£à ¬¬ë ¬®£®ï§ëçë©
|
||||||
; The area after I_END is free for use as the application memory,
|
; ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
|
||||||
; just avoid the stack.
|
|
||||||
;
|
lsz message,\
|
||||||
; Application memory structure, according to the used header, 1 Mb.
|
ru,'<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...',\
|
||||||
;
|
en,'Press any key...',\
|
||||||
; 0x00000 - Start of compiled image
|
fr,'Pressez une touche...'
|
||||||
; I_END - End of compiled image
|
|
||||||
;
|
lsz title,\
|
||||||
; + Free for use in the application
|
ru,'<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ›',\
|
||||||
;
|
en,'EXAMPLE APPLICATION',\
|
||||||
; 0x7ff00 - Start of stack area
|
fr,"L'exemplaire programme"
|
||||||
; 0x7fff0 - End of stack area - defined in the header
|
|
||||||
;
|
;---------------------------------------------------------------------
|
||||||
; + Free for use in the application
|
|
||||||
;
|
I_END: ; ¬¥âª ª®æ ¯à®£à ¬¬ë
|
||||||
; 0xFFFFF - End of freely useable memory - defined in the header
|
|
||||||
;
|
|
||||||
; All of the the areas can be modified within the application with a
|
|
||||||
; direct reference.
|
|
||||||
; For example, mov [0x80000],byte 1 moves a byte above the stack area.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user