diff --git a/data/Tupfile.lua b/data/Tupfile.lua index cdd797f18..eec36bbd6 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -407,6 +407,7 @@ tup.append_table(img_files, { {"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"}, {"@VOLUME", VAR_PROGS .. "/media/volume/volume"}, {"HACONFIG", VAR_PROGS .. "/other/ha/HACONFIG"}, + {"ACLOCK", VAR_PROGS .. "/demos/aclock/trunk/aclock"}, {"APM", VAR_PROGS .. "/system/apm/apm"}, {"CALC", VAR_PROGS .. "/other/calc/trunk/calc"}, {"CALENDAR", VAR_PROGS .. "/system/calendar/trunk/calendar"}, @@ -646,15 +647,6 @@ if build_type == "ru_RU" then tup.append_table(extra_files, { end -- tup.getconfig('NO_FASM') ~= 'full' --- Programs that require NASM to compile. -if tup.getconfig('NO_NASM') ~= 'full' then -tup.append_table(img_files, { - {"ACLOCK", VAR_PROGS .. "/demos/aclock/trunk/aclock"}, -}) -tup.append_table(extra_files, { -}) -end -- tup.getconfig('NO_NASM') ~= 'full' - -- Programs that require JWASM to compile. if tup.getconfig('NO_JWASM') ~= 'full' then tup.append_table(img_files, { diff --git a/programs/demos/aclock/trunk/Readme.txt b/programs/demos/aclock/Readme.txt similarity index 100% rename from programs/demos/aclock/trunk/Readme.txt rename to programs/demos/aclock/Readme.txt diff --git a/programs/demos/aclock/Tupfile.lua b/programs/demos/aclock/Tupfile.lua new file mode 100644 index 000000000..08c171685 --- /dev/null +++ b/programs/demos/aclock/Tupfile.lua @@ -0,0 +1,2 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +tup.rule("aclock.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "aclock") diff --git a/programs/demos/aclock/trunk/aclock.asm b/programs/demos/aclock/aclock.asm similarity index 72% rename from programs/demos/aclock/trunk/aclock.asm rename to programs/demos/aclock/aclock.asm index 298d48089..1627bb5df 100644 --- a/programs/demos/aclock/trunk/aclock.asm +++ b/programs/demos/aclock/aclock.asm @@ -16,44 +16,42 @@ ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - bits 32 - %include 'mos.inc' - section .text +use32 + org 0 + db 'MENUET01' + dd 1,main,image_end,memory_end,stacktop,cmdLine,0 + +include '../../macros.inc' +include '../../proc32.inc' +include '../../KOSfuncs.inc' ;******************************************************************** ; configuration stuff ;******************************************************************** - - %define APPNAME "Clock" - %define STACKSIZE 1024 + ; skinned window borders +MOS_WND_SKIN_BORDER_LEFT = 5 +MOS_WND_SKIN_BORDER_RIGHT = 5 +MOS_WND_SKIN_BORDER_BOTTOM = 5 ; default window position/dimensions (work area) - %define DEFAULT_XPOS -20 - %define DEFAULT_YPOS 20 - %define DEFAULT_WIDTH 110 - %define DEFAULT_HEIGHT 110 + DEFAULT_XPOS =-20 + DEFAULT_YPOS =20 + DEFAULT_WIDTH =110 + DEFAULT_HEIGHT =110 ; minimal size (horizontal and vertical) of work area - %define MIN_WIDTH 100 - %define MIN_HEIGHT 100 + MIN_WIDTH =100 + MIN_HEIGHT =100 -;******************************************************************** -; header -;******************************************************************** - - MOS_HEADER01 main,image_end,memory_end,stacktop-4,cmdLine,0 - ; these includes introduce code and thus mustn't stand ; before the menuet header =) - %include 'dbgboard.inc' - %include 'strlen.inc' - %include 'str2dwrd.inc' - %include 'strtok.inc' - %include 'cmdline.inc' - %include 'adjstwnd.inc' - %include 'draw.inc' + include 'dbgboard.inc' + include 'strfunct.inc' + include 'cmdline.inc' + include 'adjstwnd.inc' + include 'draw.inc' ;******************************************************************** ; main program @@ -89,20 +87,18 @@ main: ; call drawClock ; wait up to a second for next event - mov eax,MOS_SC_WAITEVENTTIMEOUT - mov ebx,100 - int 0x40 + mcall SF_WAIT_EVENT_TIMEOUT,100 test eax,eax jne .event_occured call drawClock .event_occured: - cmp eax,MOS_EVT_REDRAW + cmp eax,EVM_REDRAW je .redraw - cmp eax,MOS_EVT_KEY + cmp eax,EVM_KEY je .key - cmp eax,MOS_EVT_BUTTON + cmp eax,EVM_BUTTON je .button jmp .msgpump @@ -110,12 +106,10 @@ main: call drawWindow jmp .msgpump .key: - mov eax,MOS_SC_GETKEY - int 0x40 + mcall SF_GET_KEY jmp .msgpump .button: - mov eax,MOS_SC_EXIT - int 0x40 + mcall SF_TERMINATE_PROCESS jmp .msgpump @@ -128,11 +122,7 @@ main: getDefaultWindowColors: pushad pushfd - mov eax,MOS_SC_WINDOWPROPERTIES - mov ebx,3 - mov ecx,wndColors - mov edx,MOS_WNDCOLORS_size - int 0x40 + mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,wndColors,sizeof.system_colors popfd popad ret @@ -149,29 +139,24 @@ drawWindow: pusha ; start window redraw - mov eax,MOS_SC_REDRAWSTATUS - mov ebx,1 - int 0x40 + mcall SF_REDRAW,SSF_BEGIN_DRAW ; create window - mov eax,MOS_SC_DEFINEWINDOW mov ebx,[wndXPos] shl ebx,16 or ebx,[wndWidth] mov ecx,[wndYPos] shl ecx,16 or ecx,[wndHeight] - mov edx,[wndColors+MOS_WNDCOLORS.work] + mov edx,[wndColors.work] or edx,0x53000000 - mov edi,label - int 0x40 + mov edi,w_label + mcall SF_CREATE_WINDOW call drawClock ; end window redraw - mov eax,MOS_SC_REDRAWSTATUS - mov ebx,2 - int 0x40 + mcall SF_REDRAW,SSF_END_DRAW popa ret @@ -188,32 +173,29 @@ wndWidth dd DEFAULT_WIDTH wndHeight dd DEFAULT_HEIGHT ; window label -label db APPNAME,0 -LABEL_LEN equ ($-label-1) +w_label: db "Clock",0 +.end: +LABEL_LEN equ (w_label.end-w_label-1) ; token delimiter list for command line delimiters db 9,10,11,12,13,32,0 - ; don't insert anything after this label image_end: ;******************************************************************** ; uninitialized data ;******************************************************************** - section .bss align=4 - -wndColors resb MOS_WNDCOLORS_size -procInfo resb MOS_PROCESSINFO_size +align 4 +wndColors system_colors +procInfo process_information ; space for command line. at the end we have an additional ; byte for a terminating zero, just to be sure... -cmdLine resb 257 +cmdLine rb 257 - alignb 4 -stack resb STACKSIZE +align 4 + rb 1024 stacktop: - - ; don't insert anything after this label memory_end: diff --git a/programs/demos/aclock/trunk/aclock.bmp b/programs/demos/aclock/aclock.bmp similarity index 100% rename from programs/demos/aclock/trunk/aclock.bmp rename to programs/demos/aclock/aclock.bmp diff --git a/programs/demos/aclock/aclock.kex b/programs/demos/aclock/aclock.kex new file mode 100644 index 000000000..b6361d0ec Binary files /dev/null and b/programs/demos/aclock/aclock.kex differ diff --git a/programs/demos/aclock/trunk/adjstwnd.inc b/programs/demos/aclock/adjstwnd.inc similarity index 95% rename from programs/demos/aclock/trunk/adjstwnd.inc rename to programs/demos/aclock/adjstwnd.inc index 83313e117..7a233089f 100644 --- a/programs/demos/aclock/trunk/adjstwnd.inc +++ b/programs/demos/aclock/adjstwnd.inc @@ -20,8 +20,6 @@ ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; -%ifndef _ADJSTWND_INC -%define _ADJSTWND_INC ;window types @@ -72,8 +70,7 @@ adjustWindowDimensions: ; clamp window dimensions .clamp: - mov eax,MOS_SC_GETSCREENMAX ; get screen dimensions - int 0x40 + mcall SF_GET_SCREEN_SIZE ; get screen dimensions mov edi,eax ; edi = screen width shr edi,16 mov ebp,eax ; ebp = screen height @@ -136,12 +133,10 @@ adjustWindowDimensions: add edx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT ; adjust height (esi). we need the skin height to do this. push ebx - mov eax,MOS_SC_WINDOWPROPERTIES - mov ebx,4 - int 0x40 + mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT lea esi,[esi+eax+MOS_WND_SKIN_BORDER_BOTTOM] pop ebx jmp .clamp -%endif + diff --git a/programs/demos/aclock/build.bat b/programs/demos/aclock/build.bat new file mode 100644 index 000000000..fa69a2772 --- /dev/null +++ b/programs/demos/aclock/build.bat @@ -0,0 +1,3 @@ +@fasm.exe -m 16384 aclock.asm aclock.kex +@kpack aclock.kex +pause diff --git a/programs/demos/aclock/trunk/cmdline.inc b/programs/demos/aclock/cmdline.inc similarity index 97% rename from programs/demos/aclock/trunk/cmdline.inc rename to programs/demos/aclock/cmdline.inc index 3c704d04e..e146c951e 100644 --- a/programs/demos/aclock/trunk/cmdline.inc +++ b/programs/demos/aclock/cmdline.inc @@ -17,8 +17,6 @@ ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; -%ifndef _CMDLINE_INC -%define _CMDLINE_INC ;******************************************************************** @@ -105,8 +103,7 @@ parseCommandLine: ; output : eax contains position ; destroys : nothing parsePositionParam: - push ebx - push esi + push ebx esi pushfd ; is the second char of the parameter a '-' ? @@ -129,8 +126,7 @@ parsePositionParam: .rotationshyperboloid: popfd - pop esi - pop ebx + pop esi ebx ret ; parse dimension parameter @@ -147,5 +143,4 @@ parseSizeParam: ret -%endif diff --git a/programs/demos/aclock/trunk/dbgboard.inc b/programs/demos/aclock/dbgboard.inc similarity index 79% rename from programs/demos/aclock/trunk/dbgboard.inc rename to programs/demos/aclock/dbgboard.inc index 74940814b..b878bf0e0 100644 --- a/programs/demos/aclock/trunk/dbgboard.inc +++ b/programs/demos/aclock/dbgboard.inc @@ -19,20 +19,34 @@ ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; -%ifndef _DBGBOARD_INC -%define _DBGBOARD_INC -%ifdef DEBUG +if DEBUG eq +macro DBG_BOARD_PRINTNEWLINE { +} + +macro DBG_BOARD_PRINTCHAR c1 { +} + +macro DBG_BOARD_PRINTDWORD w1 { +} + +macro DBG_BOARD_PRINTSTRINGLITERAL p1 { +} + +macro DBG_BOARD_PRINTSTRING s1 { +} + +else ;******************************************************************** ; print newline ; no input ;******************************************************************** -%macro DBG_BOARD_PRINTNEWLINE 0 +macro DBG_BOARD_PRINTNEWLINE { call dbg_board_printnewline -%endm +} ;******************************************************************** @@ -44,12 +58,12 @@ ; DBG_BOARD_PRINTCHAR [esi] ; DBG_BOARD_PRINTCHAR [somevariable] ;******************************************************************** -%macro DBG_BOARD_PRINTCHAR 1 +macro DBG_BOARD_PRINTCHAR c1 { push ecx - mov cl,byte %1 + mov cl,byte c1 call dbg_board_printchar pop ecx -%endm +} @@ -60,10 +74,10 @@ ; DBG_BOARD_PRINTDWORD 0xdeadbeef ; DBG_BOARD_PRINTDWORD [somevariable] ;******************************************************************** -%macro DBG_BOARD_PRINTDWORD 1 - push dword %1 +macro DBG_BOARD_PRINTDWORD w1 { + push dword w1 call dbg_board_printdword -%endm +} ;******************************************************************** @@ -73,13 +87,14 @@ ; examples DBG_BOARD_PRINTSTRINGLITERAL "foo",0 ; DBG_BOARD_PRINTSTRINGLITERAL "bar",10,13,0 ;******************************************************************** -%macro DBG_BOARD_PRINTSTRINGLITERAL 1+ - jmp %%bar -%%foo db %1, 0 ; terminate string, just to be sure -%%bar: - push dword %%foo +macro DBG_BOARD_PRINTSTRINGLITERAL p1 { + local .foo + jmp @f +.foo db p1, 0 ; terminate string, just to be sure +@@: + push dword .foo call dbg_board_printstring -%endm +} ;******************************************************************** @@ -89,22 +104,18 @@ ; DBG_BOARD_PRINTSTRING esi ; DBG_BOARD_PRINTSTRING [ebx] ;******************************************************************** -%macro DBG_BOARD_PRINTSTRING 1 - push dword %1 +macro DBG_BOARD_PRINTSTRING s1 { + push dword s1 call dbg_board_printstring -%endm +} ; no input dbg_board_printnewline: pushad pushfd - mov eax,MOS_SC_DEBUGBOARD - mov ebx,1 - mov ecx,10 - int 0x40 - mov ecx,13 - int 0x40 + mcall SF_BOARD,SSF_DEBUG_WRITE,10 + mcall ,,13 popfd popad ret @@ -114,10 +125,8 @@ dbg_board_printnewline: dbg_board_printchar: pushad pushfd - mov eax,MOS_SC_DEBUGBOARD - mov ebx,1 and ecx,0xff - int 0x40 + mcall SF_BOARD,SSF_DEBUG_WRITE popfd popad ret @@ -127,20 +136,17 @@ dbg_board_printchar: dbg_board_printdword: enter 0,0 pushad - pushfd - mov eax,MOS_SC_DEBUGBOARD - mov ebx,1 - mov ecx,'0' ; print 0x prefix - int 0x40 - mov ecx,'x' - int 0x40 + pushfd + ; print 0x prefix + mcall SF_BOARD,SSF_DEBUG_WRITE,'0' + mcall ,,'x' mov edx,[ebp + 8] ; get dword to print mov esi,8 ; iterate through all nibbles .loop: mov ecx,edx ; display hex digit shr ecx,28 movzx ecx,byte [dbg_board_printdword_digits + ecx] - int 0x40 + mcall shl edx,4 ; next nibble dec esi jnz .loop @@ -166,35 +172,13 @@ dbg_board_printstring: or al,al ; zero ? je .done ; yeah -> get outta here movzx ecx,al ; nope -> display character - mov eax,MOS_SC_DEBUGBOARD - int 0x40 + mcall SF_BOARD jmp .loop .done: popfd popad leave ret 4 - -%else - -%macro DBG_BOARD_PRINTNEWLINE 0 -%endm - -%macro DBG_BOARD_PRINTCHAR 1 -%endm - -%macro DBG_BOARD_PRINTDWORD 1 -%endm - -%macro DBG_BOARD_PRINTSTRINGLITERAL 1+ -%endm - -%macro DBG_BOARD_PRINTSTRING 1 -%endm - -%endif - - -%endif +end if diff --git a/programs/demos/aclock/trunk/draw.inc b/programs/demos/aclock/draw.inc similarity index 69% rename from programs/demos/aclock/trunk/draw.inc rename to programs/demos/aclock/draw.inc index fefd32f02..ae0f2d590 100644 --- a/programs/demos/aclock/trunk/draw.inc +++ b/programs/demos/aclock/draw.inc @@ -17,8 +17,6 @@ ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; -%ifndef _DRAW_INC -%define _DRAW_INC TMR1_FACTOR dd 0.45 @@ -50,45 +48,36 @@ monthNames: ; output : nothing ; destroys : nothing ;******************************************************************** -drawClock: - %push drawClock_context - %stacksize flat - %assign %$localsize 0 - - %local i:dword, \ - TMR1X:dword, \ - TMR1Y:dword, \ - TMR2X:dword, \ - TMR2Y:dword, \ - SECRX:dword, \ - SECRY:dword, \ - MINRX:dword, \ - MINRY:dword, \ - HOURRX:dword, \ - HOURRY:dword, \ - workwidth:dword, \ - workheight:dword, \ - foo:dword - - enter %$localsize,0 +proc drawClock + locals + i dd ? + TMR1X dd ? + TMR1Y dd ? + TMR2X dd ? + TMR2Y dd ? + SECRX dd ? + SECRY dd ? + MINRX dd ? + MINRY dd ? + HOURRX dd ? + HOURRY dd ? + workwidth dd ? + workheight dd ? + foo dd ? + endl pushad pushfd ; get window dimensions - mov eax,MOS_SC_GETPROCESSINFO - mov ebx,procInfo - mov ecx,-1 - int 0x40 + mcall SF_THREAD_INFO,procInfo,-1 ; calculate work area size (width/height = ecx/edx) ; if the work area is too small (maybe the window is shaded) ; we don't draw anything. - mov eax,MOS_SC_WINDOWPROPERTIES - mov ebx,4 ; get skin height (eax) - int 0x40 - mov ecx,[procInfo + MOS_PROCESSINFO.wndWidth] + mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT ; get skin height (eax) + mov ecx,[procInfo.box.width] sub ecx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT - mov edx,[procInfo + MOS_PROCESSINFO.wndHeight] + mov edx,[procInfo.box.height] sub edx,eax sub edx,MOS_WND_SKIN_BORDER_BOTTOM cmp ecx,0 ; width too small ? @@ -102,9 +91,9 @@ drawClock: mov [workheight],edx ; calculate center of clock (x/y = esi/edi) - mov esi,[procInfo + MOS_PROCESSINFO.wndWidth] + mov esi,[procInfo.box.width] shr esi,1 - mov edi,[procInfo + MOS_PROCESSINFO.wndHeight] + mov edi,[procInfo.box.height] sub edi,MOS_WND_SKIN_BORDER_BOTTOM sub edi,eax shr edi,1 @@ -119,9 +108,8 @@ drawClock: shl ecx,16 ; (=skin height) or ecx,edx ; height inc ecx - mov edx,[wndColors + MOS_WNDCOLORS.work] - mov eax,MOS_SC_DRAWBAR - int 0x40 + mov edx,[wndColors.work] + mcall SF_DRAW_RECT popad ; calculate second hand radii @@ -163,8 +151,7 @@ drawClock: fstp dword [TMR2Y] ; get system clock (edx) - mov eax,MOS_SC_GETSYSCLOCK - int 0x40 + mcall SF_GET_SYS_TIME mov edx,eax ; draw second hand @@ -173,21 +160,14 @@ drawClock: shr eax,16 call bcdbin mov ecx,eax ; save seconds for later - push ecx - push eax - fpush32 0.104719755 ; 2*pi/60 - push dword [SECRX] - push dword [SECRY] - push esi - push edi - call getHandCoords - mov eax,MOS_SC_DRAWLINE + ; 2*pi/60 + stdcall getHandCoords,edi,esi,[SECRY],[SECRX],0.104719755,eax,ecx shl ebx,16 or ebx,esi shl ecx,16 or ecx,edi - mov edx,[wndColors + MOS_WNDCOLORS.workText] - int 0x40 + mov edx,[wndColors.work_text] + mcall SF_DRAW_LINE pop ecx pop edx @@ -200,21 +180,14 @@ drawClock: mul edx add eax,ecx mov ecx,eax ; save for later - push ecx - push eax - fpush32 0.001745329 ; 2*pi/60/60 - push dword [MINRX] - push dword [MINRY] - push esi - push edi - call getHandCoords - mov eax,MOS_SC_DRAWLINE + ; 2*pi/60/60 + stdcall getHandCoords,edi,esi,[MINRY],[MINRX],0.001745329,eax,ecx shl ebx,16 or ebx,esi shl ecx,16 or ecx,edi - mov edx,[wndColors + MOS_WNDCOLORS.workText] - int 0x40 + mov edx,[wndColors.work_text] + mcall SF_DRAW_LINE pop ecx pop edx @@ -229,55 +202,39 @@ drawClock: mov edx,60*60 mul edx add eax,ecx - push eax - fpush32 0.000145444 ; 2*pi/60/60/12 - push dword [HOURRX] - push dword [HOURRY] - push esi - push edi - call getHandCoords - mov eax,MOS_SC_DRAWLINE + ; 2*pi/60/60/12 + stdcall getHandCoords,edi,esi,[HOURRY],[HOURRX],0.000145444,eax shl ebx,16 or ebx,esi shl ecx,16 or ecx,edi - mov edx,[wndColors + MOS_WNDCOLORS.workText] - int 0x40 + mov edx,[wndColors.work_text] + mcall SF_DRAW_LINE pop edx ; draw tick marks mov dword [i],11 ; draw 12 marks .drawtickmarks: - push dword [i] ; calculate start point - fpush32 0.523598776 ; 2*pi/12 - push dword [TMR1X] - push dword [TMR1Y] - push esi - push edi - call getHandCoords + ; calculate start point + ; 2*pi/12 + stdcall getHandCoords,edi,esi,[TMR1Y],[TMR1X],0.523598776,[i] mov eax,ebx ; save in eax and edx mov edx,ecx - push dword [i] - fpush32 0.523598776 ; 2*pi/12 - push dword [TMR2X] - push dword [TMR2Y] - push esi - push edi - call getHandCoords + ; 2*pi/12 + stdcall getHandCoords,edi,esi,[TMR2Y],[TMR2X],0.523598776,[i] shl eax,16 shl edx,16 or ebx,eax ; ebx = x start and end or ecx,edx ; ecx = y start and end - mov edx,[wndColors + MOS_WNDCOLORS.workText] - mov eax,MOS_SC_DRAWLINE - int 0x40 + mov edx,[wndColors.work_text] + mcall SF_DRAW_LINE dec dword [i] jns .drawtickmarks - %define DATE_WIDTH 48 + DATE_WIDTH =48 ; calculate text start position - mov eax,[procInfo+MOS_PROCESSINFO.wndWidth] + mov eax,[procInfo.box.width] sub eax,DATE_WIDTH ; x = (wndwidth-textwidth)/2 shr eax,1 ; eax = x fild dword [workheight] ; y = DATE_FACTOR*workheight... @@ -292,7 +249,7 @@ drawClock: jb .goodbye mov ecx,ebx ; text too high ? add ecx,10-1 - mov edx,[procInfo+MOS_PROCESSINFO.wndHeight] + mov edx,[procInfo.box.height] sub edx,MOS_WND_SKIN_BORDER_BOTTOM cmp ecx,edx jnae .yousuck @@ -306,8 +263,7 @@ drawClock: or ebx,eax ; get date (edi) - mov eax,MOS_SC_GETDATE - int 0x40 + mcall SF_GET_SYS_DATE mov edi,eax ; display month @@ -315,44 +271,41 @@ drawClock: shr eax,8 call bcdbin ; ebx contains already position - mov ecx,[wndColors+MOS_WNDCOLORS.workText] + mov ecx,[wndColors.work_text] lea edx,[monthNames-3+eax*2+eax]; -3 because eax = 1..12 =] mov esi,3 ; text length - mov eax,MOS_SC_WRITETEXT - int 0x40 + mcall SF_DRAW_TEXT ; display date - add ebx,MOS_DWORD(3*6+3,0) + add ebx,(3*6+3) shl 16 mov eax,edi ; get date shr eax,16 call bcdbin mov edx,ebx ; position must be in edx mov ebx,0x00020000 ; number, display two digits mov ecx,eax ; number to display - mov esi,[wndColors+MOS_WNDCOLORS.workText] - mov eax,MOS_SC_WRITENUMBER - int 0x40 + mov esi,[wndColors.work_text] + mcall SF_DRAW_NUMBER ; display year. the way we avoid the y2k bug is even ; simpler, yet much better than in the last version: ; now we simply display the last two digits and let the ; user decide wether it's the year 1903 or 2003 =] - add edx,MOS_DWORD(2*6+3,0) + add edx,(2*6+3) shl 16 mov eax,edi ; get year call bcdbin mov ebx,0x00020000 ; number, display two digits mov ecx,eax ; number to display ; edx contains already position - mov esi,[wndColors+MOS_WNDCOLORS.workText] - mov eax,MOS_SC_WRITENUMBER - int 0x40 + mov esi,[wndColors.work_text] + mcall SF_DRAW_NUMBER .byebye: popfd popad - leave + ;leave ret - %pop +endp ;********************************************************** @@ -397,36 +350,26 @@ bcdbin: ; destroys: ; nothing ;******************************************************************** -getHandCoords: - -ANGLE equ 28 -DEG2RAD equ 24 -RADIUSX equ 20 -RADIUSY equ 16 -CENTERX equ 12 -CENTERY equ 8 - - enter 0,0 +proc getHandCoords CENTERY:dword, CENTERX:dword, RADIUSY:dword, RADIUSX:dword, DEG2RAD:dword, ANGLE:dword pushfd - fild dword [ebp+ANGLE] ; get angle - fmul dword [ebp+DEG2RAD] ; convert to radians + fild dword [ANGLE] ; get angle + fmul dword [DEG2RAD] ; convert to radians fsincos - fmul dword [ebp+RADIUSY] ; -y * radius + clockcy + fmul dword [RADIUSY] ; -y * radius + clockcy fchs - fiadd dword [ebp+CENTERY] - fistp dword [ebp+CENTERY] - fmul dword [ebp+RADIUSX] ; x * radius + clockcx - fiadd dword [ebp+CENTERX] - fistp dword [ebp+CENTERX] + fiadd dword [CENTERY] + fistp dword [CENTERY] + fmul dword [RADIUSX] ; x * radius + clockcx + fiadd dword [CENTERX] + fistp dword [CENTERX] - mov ebx,[ebp+CENTERX] - mov ecx,[ebp+CENTERY] + mov ebx,[CENTERX] + mov ecx,[CENTERY] popfd - leave - ret 4*6 + ;leave + ret +endp -%endif - diff --git a/programs/demos/aclock/trunk/strtok.inc b/programs/demos/aclock/strfunct.inc similarity index 63% rename from programs/demos/aclock/trunk/strtok.inc rename to programs/demos/aclock/strfunct.inc index 5c8db3dad..bbc68bb73 100644 --- a/programs/demos/aclock/trunk/strtok.inc +++ b/programs/demos/aclock/strfunct.inc @@ -1,5 +1,3 @@ -; some strtok-like function -; ; Copyright (c) 2003 Thomas Mathys ; killer@vantage.ch ; @@ -17,8 +15,94 @@ ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; -%ifndef _STRTOK_INC -%define _STRTOK_INC + + +;******************************************************************** +; returns the length of an asciiz string +; input : esi = pointer to string +; output : eax = string length +; destroys : nothing +;******************************************************************** +strlen: + push ecx edi + pushfd + cld ; ! + mov ecx,-1 + mov edi,esi ; find terminating zero + xor al,al + repne scasb + mov eax,edi ; calculate string length + sub eax,esi + dec eax + popfd + pop edi ecx + ret + + +;******************************************************************** +; converts an asciiz string into an unsigned doubleword. +; (base 10 is assumed) +; +; - first, leading whitespaces are skipped +; - then the function converts the string, until it +; finds the terminating zero, another character it +; cannot convert or the number becomes too large. +; +; input : esi = pointer to string +; output : eax = unsigned doubleword +; the function tries to convert as +; many digits as possible, before it +; stops. if the value of the dword +; becomes too large, 0xffffffff is +; returned. +; destroys : nothing +;******************************************************************** +string2dword: + push ebx ecx edx esi + pushfd + + xor ebx,ebx ; ebx : dword + + ; skip leading whitespaces +.skipspaces: + lodsb + cmp al,32 ; space + je .skipspaces + cmp al,12 ; ff + je .skipspaces + cmp al,10 ; lf + je .skipspaces + cmp al,13 ; cr + je .skipspaces + cmp al,9 ; ht + je .skipspaces + cmp al,11 ; vt + je .skipspaces + + ; convert string + dec esi ; esi -> 1st non-whitespace +.convert: + xor eax,eax ; get character + lodsb + sub al,'0' ; convert to digit + cmp al,9 ; is digit in range [0,9] ? + ja .done ; nope -> stop conversion + mov ecx,eax ; save new digit + mov eax,10 ; dword = dword * 10 + mul ebx + jc .overflow + add eax,ecx ; + new digit + jc .overflow + mov ebx,eax + jmp .convert + +.overflow: + mov ebx,0xffffffff +.done: + mov eax,ebx + popfd + pop esi edx ecx ebx + ret ;******************************************************************** @@ -121,5 +205,3 @@ strtok: ret .adx dd 0 -%endif - diff --git a/programs/demos/aclock/trunk/Tupfile.lua b/programs/demos/aclock/trunk/Tupfile.lua deleted file mode 100644 index a5f3786eb..000000000 --- a/programs/demos/aclock/trunk/Tupfile.lua +++ /dev/null @@ -1,2 +0,0 @@ -if tup.getconfig("NO_NASM") ~= "" then return end -tup.rule("aclock.asm", "nasm -f bin -o %o %f " .. tup.getconfig("KPACK_CMD"), "aclock") diff --git a/programs/demos/aclock/trunk/make.bat b/programs/demos/aclock/trunk/make.bat deleted file mode 100644 index e770ff785..000000000 --- a/programs/demos/aclock/trunk/make.bat +++ /dev/null @@ -1,3 +0,0 @@ -@rem nasm -t -f bin -o aclock -l aclock.lst aclock.asm -DDEBUG -nasmw -t -f bin -o aclock aclock.asm -@pause diff --git a/programs/demos/aclock/trunk/mos.inc b/programs/demos/aclock/trunk/mos.inc deleted file mode 100644 index 20274343c..000000000 --- a/programs/demos/aclock/trunk/mos.inc +++ /dev/null @@ -1,334 +0,0 @@ -; mos.inc 0.03 -; Copyright (c) 2002 Thomas Mathys -; killer@vantage.ch -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; either version 2 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; -%ifndef _MOS_INC -%define _MOS_INC - - -;********************************************************** -; generates a menuetos 01 header -; takes 6 parameters: -; -; MOS_HEADER01 start, end, appmem, esp, i_param, i_icon -;********************************************************** - -%macro MOS_HEADER01 6 - org 0x0 - db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd %1 ; start of code - dd %2 ; image size - dd %3 ; application memory - dd %4 ; esp - dd %5 ; i_param - dd %6 ; i_icon -%endmacro - - -;********************************************************** -; MOS_DWORD -; packs 2 words into a double word -;********************************************************** - -%define MOS_DWORD(hi,lo) ((((hi) & 0xffff) << 16) + ((lo) & 0xffff)) - - -;********************************************************** -; MOS_RGB -; creates a menuet os compatible color (0x00RRGGBB) -;********************************************************** - -%define MOS_RGB(r,g,b) ((((r) & 255) << 16) + (((g) & 255) << 8) + ((b) & 255)) - - -;********************************************************** -; window stuff -;********************************************************** - - ; default window colors -struc MOS_WNDCOLORS - .frame: resd 1 - .grab: resd 1 - .grabButton: resd 1 - .grabButtonText: resd 1 - .grabText: resd 1 - .work: resd 1 - .workButton: resd 1 - .workButtonText: resd 1 - .workText: resd 1 - .workGraphics: resd 1 -endstruc - - ; skinned window borders -MOS_WND_SKIN_BORDER_LEFT equ 5 -MOS_WND_SKIN_BORDER_RIGHT equ 5 -MOS_WND_SKIN_BORDER_BOTTOM equ 5 - - -;********************************************************** -; process info structure -;********************************************************** - -struc MOS_PROCESSINFO - .CPUUsage: resd 1 - .windowStackPos: resw 1 - .windowStackVal: resw 1 - .reserved1: resw 1 - .processName: resb 12 - .memStart: resd 1 - .memUsed: resd 1 - .pid: resd 1 - .wndXPos resd 1 - .wndYPos resd 1 - .wndWidth resd 1 - .wndHeight resd 1 - .reserved2: resb (1024 - 50) -endstruc - - - -;********************************************************** -; system call numbers -;********************************************************** - -MOS_SC_EXIT equ -1 -MOS_SC_DEFINEWINDOW equ 0 -MOS_SC_PUTPIXEL equ 1 -MOS_SC_GETKEY equ 2 -MOS_SC_GETSYSCLOCK equ 3 -MOS_SC_WRITETEXT equ 4 -MOS_SC_DELAY equ 5 -MOS_SC_OPENFILEFLOPPY equ 6 ; obsolete -MOS_SC_PUTIMAGE equ 7 -MOS_SC_DEFINEBUTTON equ 8 -MOS_SC_GETPROCESSINFO equ 9 -MOS_SC_WAITEVENT equ 10 -MOS_SC_CHECKEVENT equ 11 -MOS_SC_REDRAWSTATUS equ 12 -MOS_SC_DRAWBAR equ 13 -MOS_SC_GETSCREENMAX equ 14 -MOS_SC_SETBACKGROUND equ 15 -MOS_SC_GETPRESSEDBUTTON equ 17 -MOS_SC_SYSTEMSERVICE equ 18 -MOS_SC_STARTPROGRAM equ 19 ; obsolete -MOS_SC_MIDIINTERFACE equ 20 -MOS_SC_DEVICESETUP equ 21 -MOS_SC_WAITEVENTTIMEOUT equ 23 -MOS_SC_CDAUDIO equ 24 -MOS_SC_SB16MIXER1 equ 25 -MOS_SC_GETDEVICESETUP equ 26 -MOS_SC_WSS equ 27 -MOS_SC_SB16MIXER2 equ 28 -MOS_SC_GETDATE equ 29 -MOS_SC_READHD equ 30 ; obsolete -MOS_SC_STARTPROGRAMHD equ 31 ; obsolete -MOS_SC_DELETEFILEFLOPPY equ 32 -MOS_SC_SAVEFILERAMDISK equ 33 ; obsolete -MOS_SC_READDIRRAMDISK equ 34 ; obsolete -MOS_SC_GETSCREENPIXEL equ 35 -MOS_SC_GETMOUSEPOSITION equ 37 -MOS_SC_DRAWLINE equ 38 -MOS_SC_GETBACKGROUND equ 39 -MOS_SC_SETEVENTMASK equ 40 -MOS_SC_GETIRQOWNER equ 41 -MOS_SC_GETDATAREADBYIRQ equ 42 -MOS_SC_SENDDATATODEVICE equ 43 -MOS_SC_PROGRAMIRQS equ 44 -MOS_SC_RESERVEFREEIRQ equ 45 -MOS_SC_RESERVEFREEPORTS equ 46 -MOS_SC_WRITENUMBER equ 47 -MOS_SC_WINDOWPROPERTIES equ 48 -MOS_SC_SHAPEDWINDOWS equ 50 -MOS_SC_CREATETHREAD equ 51 -MOS_SC_STACKDRIVERSTATE equ 52 -MOS_SC_SOCKETINTERFACE equ 53 -MOS_SC_SOUNDINTERFACE equ 55 -MOS_SC_WRITEFILEHD equ 56 ; obsolete -MOS_SC_DELETEFILEHD equ 57 -MOS_SC_SYSTREEACCESS equ 58 -MOS_SC_SYSCALLTRACE equ 59 -MOS_SC_IPC equ 60 -MOS_SC_DIRECTGRAPHICS equ 61 -MOS_SC_PCI equ 62 -MOS_SC_DEBUGBOARD equ 63 - - -;********************************************************** -; event numbers -;********************************************************** - -MOS_EVT_NONE equ 0 -MOS_EVT_REDRAW equ 1 -MOS_EVT_KEY equ 2 -MOS_EVT_BUTTON equ 3 - - -;********************************************************** -; event bits -;********************************************************** - -MOS_EVTBIT_REDRAW equ (1 << 0) -MOS_EVTBIT_KEY equ (1 << 1) -MOS_EVTBIT_BUTTON equ (1 << 2) -MOS_EVTBIT_ENDREQUEST equ (1 << 3) -MOS_EVTBIT_BGDRAW equ (1 << 4) -MOS_EVTBIT_MOUSECHANGE equ (1 << 5) -MOS_EVTBIT_IPCEVENT equ (1 << 6) -MOS_EVTBIT_IRQ0 equ (1 << 16) -MOS_EVTBIT_IRQ1 equ (1 << 17) -MOS_EVTBIT_IRQ2 equ (1 << 18) -MOS_EVTBIT_IRQ3 equ (1 << 19) -MOS_EVTBIT_IRQ4 equ (1 << 20) -MOS_EVTBIT_IRQ5 equ (1 << 21) -MOS_EVTBIT_IRQ6 equ (1 << 22) -MOS_EVTBIT_IRQ7 equ (1 << 23) -MOS_EVTBIT_IRQ8 equ (1 << 24) -MOS_EVTBIT_IRQ9 equ (1 << 25) -MOS_EVTBIT_IRQ10 equ (1 << 26) -MOS_EVTBIT_IRQ11 equ (1 << 27) -MOS_EVTBIT_IRQ12 equ (1 << 28) -MOS_EVTBIT_IRQ13 equ (1 << 29) -MOS_EVTBIT_IRQ14 equ (1 << 30) -MOS_EVTBIT_IRQ15 equ (1 << 31) - - -;********************************************************** -; exit application (syscall -1) -;********************************************************** - -; exit application -%macro MOS_EXIT 0 - mov eax,MOS_SC_EXIT - int 0x40 -%endmacro - -; exit application, smaller version -%macro MOS_EXIT_S 0 - xor eax,eax - dec eax - int 0x40 -%endmacro - - -;********************************************************** -; wait event stuff -; (MOS_SC_WAITEVENT, syscall 10) -;********************************************************** - -; wait for event -; destroys : nothing -; returns : eax = event type -%macro MOS_WAITEVENT 0 - mov eax,MOS_SC_WAITEVENT - int 0x40 -%endmacro - -; wait for event, smaller version -; destroys : flags -; returns : eax = event type -%macro MOS_WAITEVENT_S 0 - xor eax,eax - mov al,MOS_SC_WAITEVENT - int 0x40 -%endmacro - - -;********************************************************** -; window redraw status stuff -; (MOS_SC_REDRAWSTATUS, syscall 12) -;********************************************************** - -MOS_RS_STARTREDRAW equ 1 -MOS_RS_ENDREDRAW equ 2 - -; start window redraw -; destroys: eax,ebx -%macro MOS_STARTREDRAW 0 - mov ebx,MOS_RS_STARTREDRAW - mov eax,MOS_SC_REDRAWSTATUS - int 0x40 -%endmacro - -; start window redraw, smaller version -; destroys: eax,ebx,flags -%macro MOS_STARTREDRAW_S 0 - xor ebx,ebx - inc ebx - xor eax,eax - mov al,MOS_SC_REDRAWSTATUS - int 0x40 -%endmacro - -; end window redraw -; destroys: eax,ebx -%macro MOS_ENDREDRAW 0 - mov ebx,MOS_RS_ENDREDRAW - mov eax,MOS_SC_REDRAWSTATUS - int 0x40 -%endmacro - -; end window redraw, smaller version -; destroys: eax,ebx,flags -%macro MOS_ENDREDRAW_S 0 - xor ebx,ebx - mov bl,MOS_RS_ENDREDRAW - xor eax,eax - mov al,MOS_SC_REDRAWSTATUS - int 0x40 -%endmacro - - -;********************************************************** -; get screen max stuff (syscall 14) -;********************************************************** - -; get screen dimensions in eax -; destroys: nothing -%macro MOS_GETSCREENMAX 0 - mov eax,MOS_SC_GETSCREENMAX - int 0x40 -%endmacro - -; get screen dimensions in eax, smaller version -; destroys: flags -%macro MOS_GETSCREENMAX_S 0 - xor eax,eax - mov al,MOS_SC_GETSCREENMAX - int 0x40 -%endmacro - - -;******************************************************************** -; opcode hacks -;******************************************************************** - -; nasm refuses to assemble stuff like -; push dword 4.44 -; with the following macro this becomes possible: -; fpush32 9.81 -; don't forget to use a decimal point. things like -; fpush32 1 -; will probably not do what you expect. instead, write: -; fpush32 1.0 -%macro fpush32 1 - db 0x68 ; push imm32 - dd %1 -%endm - -%endif - diff --git a/programs/demos/aclock/trunk/str2dwrd.inc b/programs/demos/aclock/trunk/str2dwrd.inc deleted file mode 100644 index d2f1cbfea..000000000 --- a/programs/demos/aclock/trunk/str2dwrd.inc +++ /dev/null @@ -1,92 +0,0 @@ -; string2dword - a useless string to double word conversion routine -; -; Copyright (c) 2003 Thomas Mathys -; killer@vantage.ch -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; either version 2 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - -;******************************************************************** -; converts an asciiz string into an unsigned doubleword. -; (base 10 is assumed) -; -; - first, leading whitespaces are skipped -; - then the function converts the string, until it -; finds the terminating zero, another character it -; cannot convert or the number becomes too large. -; -; input : esi = pointer to string -; output : eax = unsigned doubleword -; the function tries to convert as -; many digits as possible, before it -; stops. if the value of the dword -; becomes too large, 0xffffffff is -; returned. -; destroys : nothing -;******************************************************************** -string2dword: - push ebx - push ecx - push edx - push esi - pushfd - - xor ebx,ebx ; ebx : dword - - ; skip leading whitespaces -.skipspaces: - lodsb - cmp al,32 ; space - je .skipspaces - cmp al,12 ; ff - je .skipspaces - cmp al,10 ; lf - je .skipspaces - cmp al,13 ; cr - je .skipspaces - cmp al,9 ; ht - je .skipspaces - cmp al,11 ; vt - je .skipspaces - - ; convert string - dec esi ; esi -> 1st non-whitespace -.convert: - xor eax,eax ; get character - lodsb - sub al,'0' ; convert to digit - cmp al,9 ; is digit in range [0,9] ? - ja .done ; nope -> stop conversion - mov ecx,eax ; save new digit - mov eax,10 ; dword = dword * 10 - mul ebx - jc .overflow - add eax,ecx ; + new digit - jc .overflow - mov ebx,eax - jmp .convert - -.overflow: - mov ebx,0xffffffff -.done: - mov eax,ebx - popfd - pop esi - pop edx - pop ecx - pop ebx - ret - diff --git a/programs/demos/aclock/trunk/strlen.inc b/programs/demos/aclock/trunk/strlen.inc deleted file mode 100644 index d4ece71a7..000000000 --- a/programs/demos/aclock/trunk/strlen.inc +++ /dev/null @@ -1,49 +0,0 @@ -; strlen function -; -; Copyright (c) 2003 Thomas Mathys -; killer@vantage.ch -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; either version 2 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; -%ifndef _STRLEN_INC -%define _STRLEN_INC - - -;******************************************************************** -; returns the length of an asciiz string -; input : esi = pointer to string -; output : eax = string length -; destroys : nothing -;******************************************************************** -strlen: - push ecx - push edi - pushfd - cld ; ! - mov ecx,-1 - mov edi,esi ; find terminating zero - xor al,al - repne scasb - mov eax,edi ; calculate string length - sub eax,esi - dec eax - popfd - pop edi - pop ecx - ret - - -%endif -