rewrite aClock from nasm to fasm

This commit is contained in:
2025-03-06 21:45:20 +02:00
parent f155308c19
commit 002e1677ee
17 changed files with 261 additions and 763 deletions

View File

@@ -407,6 +407,7 @@ tup.append_table(img_files, {
{"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"}, {"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"},
{"@VOLUME", VAR_PROGS .. "/media/volume/volume"}, {"@VOLUME", VAR_PROGS .. "/media/volume/volume"},
{"HACONFIG", VAR_PROGS .. "/other/ha/HACONFIG"}, {"HACONFIG", VAR_PROGS .. "/other/ha/HACONFIG"},
{"ACLOCK", VAR_PROGS .. "/demos/aclock/trunk/aclock"},
{"APM", VAR_PROGS .. "/system/apm/apm"}, {"APM", VAR_PROGS .. "/system/apm/apm"},
{"CALC", VAR_PROGS .. "/other/calc/trunk/calc"}, {"CALC", VAR_PROGS .. "/other/calc/trunk/calc"},
{"CALENDAR", VAR_PROGS .. "/system/calendar/trunk/calendar"}, {"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' 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. -- Programs that require JWASM to compile.
if tup.getconfig('NO_JWASM') ~= 'full' then if tup.getconfig('NO_JWASM') ~= 'full' then
tup.append_table(img_files, { tup.append_table(img_files, {

View File

@@ -0,0 +1,2 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("aclock.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "aclock")

View File

@@ -16,44 +16,42 @@
; along with this program; if not, write to the Free Software ; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bits 32 use32
%include 'mos.inc' org 0
section .text db 'MENUET01'
dd 1,main,image_end,memory_end,stacktop,cmdLine,0
include '../../macros.inc'
include '../../proc32.inc'
include '../../KOSfuncs.inc'
;******************************************************************** ;********************************************************************
; configuration stuff ; configuration stuff
;******************************************************************** ;********************************************************************
; skinned window borders
%define APPNAME "Clock" MOS_WND_SKIN_BORDER_LEFT = 5
%define STACKSIZE 1024 MOS_WND_SKIN_BORDER_RIGHT = 5
MOS_WND_SKIN_BORDER_BOTTOM = 5
; default window position/dimensions (work area) ; default window position/dimensions (work area)
%define DEFAULT_XPOS -20 DEFAULT_XPOS =-20
%define DEFAULT_YPOS 20 DEFAULT_YPOS =20
%define DEFAULT_WIDTH 110 DEFAULT_WIDTH =110
%define DEFAULT_HEIGHT 110 DEFAULT_HEIGHT =110
; minimal size (horizontal and vertical) of work area ; minimal size (horizontal and vertical) of work area
%define MIN_WIDTH 100 MIN_WIDTH =100
%define MIN_HEIGHT 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 ; these includes introduce code and thus mustn't stand
; before the menuet header =) ; before the menuet header =)
%include 'dbgboard.inc' include 'dbgboard.inc'
%include 'strlen.inc' include 'strfunct.inc'
%include 'str2dwrd.inc' include 'cmdline.inc'
%include 'strtok.inc' include 'adjstwnd.inc'
%include 'cmdline.inc' include 'draw.inc'
%include 'adjstwnd.inc'
%include 'draw.inc'
;******************************************************************** ;********************************************************************
; main program ; main program
@@ -89,20 +87,18 @@ main:
; call drawClock ; call drawClock
; wait up to a second for next event ; wait up to a second for next event
mov eax,MOS_SC_WAITEVENTTIMEOUT mcall SF_WAIT_EVENT_TIMEOUT,100
mov ebx,100
int 0x40
test eax,eax test eax,eax
jne .event_occured jne .event_occured
call drawClock call drawClock
.event_occured: .event_occured:
cmp eax,MOS_EVT_REDRAW cmp eax,EVM_REDRAW
je .redraw je .redraw
cmp eax,MOS_EVT_KEY cmp eax,EVM_KEY
je .key je .key
cmp eax,MOS_EVT_BUTTON cmp eax,EVM_BUTTON
je .button je .button
jmp .msgpump jmp .msgpump
@@ -110,12 +106,10 @@ main:
call drawWindow call drawWindow
jmp .msgpump jmp .msgpump
.key: .key:
mov eax,MOS_SC_GETKEY mcall SF_GET_KEY
int 0x40
jmp .msgpump jmp .msgpump
.button: .button:
mov eax,MOS_SC_EXIT mcall SF_TERMINATE_PROCESS
int 0x40
jmp .msgpump jmp .msgpump
@@ -128,11 +122,7 @@ main:
getDefaultWindowColors: getDefaultWindowColors:
pushad pushad
pushfd pushfd
mov eax,MOS_SC_WINDOWPROPERTIES mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,wndColors,sizeof.system_colors
mov ebx,3
mov ecx,wndColors
mov edx,MOS_WNDCOLORS_size
int 0x40
popfd popfd
popad popad
ret ret
@@ -149,29 +139,24 @@ drawWindow:
pusha pusha
; start window redraw ; start window redraw
mov eax,MOS_SC_REDRAWSTATUS mcall SF_REDRAW,SSF_BEGIN_DRAW
mov ebx,1
int 0x40
; create window ; create window
mov eax,MOS_SC_DEFINEWINDOW
mov ebx,[wndXPos] mov ebx,[wndXPos]
shl ebx,16 shl ebx,16
or ebx,[wndWidth] or ebx,[wndWidth]
mov ecx,[wndYPos] mov ecx,[wndYPos]
shl ecx,16 shl ecx,16
or ecx,[wndHeight] or ecx,[wndHeight]
mov edx,[wndColors+MOS_WNDCOLORS.work] mov edx,[wndColors.work]
or edx,0x53000000 or edx,0x53000000
mov edi,label mov edi,w_label
int 0x40 mcall SF_CREATE_WINDOW
call drawClock call drawClock
; end window redraw ; end window redraw
mov eax,MOS_SC_REDRAWSTATUS mcall SF_REDRAW,SSF_END_DRAW
mov ebx,2
int 0x40
popa popa
ret ret
@@ -188,32 +173,29 @@ wndWidth dd DEFAULT_WIDTH
wndHeight dd DEFAULT_HEIGHT wndHeight dd DEFAULT_HEIGHT
; window label ; window label
label db APPNAME,0 w_label: db "Clock",0
LABEL_LEN equ ($-label-1) .end:
LABEL_LEN equ (w_label.end-w_label-1)
; token delimiter list for command line ; token delimiter list for command line
delimiters db 9,10,11,12,13,32,0 delimiters db 9,10,11,12,13,32,0
; don't insert anything after this label
image_end: image_end:
;******************************************************************** ;********************************************************************
; uninitialized data ; uninitialized data
;******************************************************************** ;********************************************************************
section .bss align=4 align 4
wndColors system_colors
wndColors resb MOS_WNDCOLORS_size procInfo process_information
procInfo resb MOS_PROCESSINFO_size
; space for command line. at the end we have an additional ; space for command line. at the end we have an additional
; byte for a terminating zero, just to be sure... ; byte for a terminating zero, just to be sure...
cmdLine resb 257 cmdLine rb 257
alignb 4 align 4
stack resb STACKSIZE rb 1024
stacktop: stacktop:
; don't insert anything after this label
memory_end: memory_end:

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

View File

@@ -20,8 +20,6 @@
; along with this program; if not, write to the Free Software ; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
; ;
%ifndef _ADJSTWND_INC
%define _ADJSTWND_INC
;window types ;window types
@@ -72,8 +70,7 @@ adjustWindowDimensions:
; clamp window dimensions ; clamp window dimensions
.clamp: .clamp:
mov eax,MOS_SC_GETSCREENMAX ; get screen dimensions mcall SF_GET_SCREEN_SIZE ; get screen dimensions
int 0x40
mov edi,eax ; edi = screen width mov edi,eax ; edi = screen width
shr edi,16 shr edi,16
mov ebp,eax ; ebp = screen height mov ebp,eax ; ebp = screen height
@@ -136,12 +133,10 @@ adjustWindowDimensions:
add edx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT add edx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT
; adjust height (esi). we need the skin height to do this. ; adjust height (esi). we need the skin height to do this.
push ebx push ebx
mov eax,MOS_SC_WINDOWPROPERTIES mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
mov ebx,4
int 0x40
lea esi,[esi+eax+MOS_WND_SKIN_BORDER_BOTTOM] lea esi,[esi+eax+MOS_WND_SKIN_BORDER_BOTTOM]
pop ebx pop ebx
jmp .clamp jmp .clamp
%endif

View File

@@ -0,0 +1,3 @@
@fasm.exe -m 16384 aclock.asm aclock.kex
@kpack aclock.kex
pause

View File

@@ -17,8 +17,6 @@
; along with this program; if not, write to the Free Software ; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; 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 ; output : eax contains position
; destroys : nothing ; destroys : nothing
parsePositionParam: parsePositionParam:
push ebx push ebx esi
push esi
pushfd pushfd
; is the second char of the parameter a '-' ? ; is the second char of the parameter a '-' ?
@@ -129,8 +126,7 @@ parsePositionParam:
.rotationshyperboloid: .rotationshyperboloid:
popfd popfd
pop esi pop esi ebx
pop ebx
ret ret
; parse dimension parameter ; parse dimension parameter
@@ -147,5 +143,4 @@ parseSizeParam:
ret ret
%endif

View File

@@ -19,20 +19,34 @@
; along with this program; if not, write to the Free Software ; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; 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 ; print newline
; no input ; no input
;******************************************************************** ;********************************************************************
%macro DBG_BOARD_PRINTNEWLINE 0 macro DBG_BOARD_PRINTNEWLINE {
call dbg_board_printnewline call dbg_board_printnewline
%endm }
;******************************************************************** ;********************************************************************
@@ -44,12 +58,12 @@
; DBG_BOARD_PRINTCHAR [esi] ; DBG_BOARD_PRINTCHAR [esi]
; DBG_BOARD_PRINTCHAR [somevariable] ; DBG_BOARD_PRINTCHAR [somevariable]
;******************************************************************** ;********************************************************************
%macro DBG_BOARD_PRINTCHAR 1 macro DBG_BOARD_PRINTCHAR c1 {
push ecx push ecx
mov cl,byte %1 mov cl,byte c1
call dbg_board_printchar call dbg_board_printchar
pop ecx pop ecx
%endm }
@@ -60,10 +74,10 @@
; DBG_BOARD_PRINTDWORD 0xdeadbeef ; DBG_BOARD_PRINTDWORD 0xdeadbeef
; DBG_BOARD_PRINTDWORD [somevariable] ; DBG_BOARD_PRINTDWORD [somevariable]
;******************************************************************** ;********************************************************************
%macro DBG_BOARD_PRINTDWORD 1 macro DBG_BOARD_PRINTDWORD w1 {
push dword %1 push dword w1
call dbg_board_printdword call dbg_board_printdword
%endm }
;******************************************************************** ;********************************************************************
@@ -73,13 +87,14 @@
; examples DBG_BOARD_PRINTSTRINGLITERAL "foo",0 ; examples DBG_BOARD_PRINTSTRINGLITERAL "foo",0
; DBG_BOARD_PRINTSTRINGLITERAL "bar",10,13,0 ; DBG_BOARD_PRINTSTRINGLITERAL "bar",10,13,0
;******************************************************************** ;********************************************************************
%macro DBG_BOARD_PRINTSTRINGLITERAL 1+ macro DBG_BOARD_PRINTSTRINGLITERAL p1 {
jmp %%bar local .foo
%%foo db %1, 0 ; terminate string, just to be sure jmp @f
%%bar: .foo db p1, 0 ; terminate string, just to be sure
push dword %%foo @@:
push dword .foo
call dbg_board_printstring call dbg_board_printstring
%endm }
;******************************************************************** ;********************************************************************
@@ -89,22 +104,18 @@
; DBG_BOARD_PRINTSTRING esi ; DBG_BOARD_PRINTSTRING esi
; DBG_BOARD_PRINTSTRING [ebx] ; DBG_BOARD_PRINTSTRING [ebx]
;******************************************************************** ;********************************************************************
%macro DBG_BOARD_PRINTSTRING 1 macro DBG_BOARD_PRINTSTRING s1 {
push dword %1 push dword s1
call dbg_board_printstring call dbg_board_printstring
%endm }
; no input ; no input
dbg_board_printnewline: dbg_board_printnewline:
pushad pushad
pushfd pushfd
mov eax,MOS_SC_DEBUGBOARD mcall SF_BOARD,SSF_DEBUG_WRITE,10
mov ebx,1 mcall ,,13
mov ecx,10
int 0x40
mov ecx,13
int 0x40
popfd popfd
popad popad
ret ret
@@ -114,10 +125,8 @@ dbg_board_printnewline:
dbg_board_printchar: dbg_board_printchar:
pushad pushad
pushfd pushfd
mov eax,MOS_SC_DEBUGBOARD
mov ebx,1
and ecx,0xff and ecx,0xff
int 0x40 mcall SF_BOARD,SSF_DEBUG_WRITE
popfd popfd
popad popad
ret ret
@@ -127,20 +136,17 @@ dbg_board_printchar:
dbg_board_printdword: dbg_board_printdword:
enter 0,0 enter 0,0
pushad pushad
pushfd pushfd
mov eax,MOS_SC_DEBUGBOARD ; print 0x prefix
mov ebx,1 mcall SF_BOARD,SSF_DEBUG_WRITE,'0'
mov ecx,'0' ; print 0x prefix mcall ,,'x'
int 0x40
mov ecx,'x'
int 0x40
mov edx,[ebp + 8] ; get dword to print mov edx,[ebp + 8] ; get dword to print
mov esi,8 ; iterate through all nibbles mov esi,8 ; iterate through all nibbles
.loop: .loop:
mov ecx,edx ; display hex digit mov ecx,edx ; display hex digit
shr ecx,28 shr ecx,28
movzx ecx,byte [dbg_board_printdword_digits + ecx] movzx ecx,byte [dbg_board_printdword_digits + ecx]
int 0x40 mcall
shl edx,4 ; next nibble shl edx,4 ; next nibble
dec esi dec esi
jnz .loop jnz .loop
@@ -166,35 +172,13 @@ dbg_board_printstring:
or al,al ; zero ? or al,al ; zero ?
je .done ; yeah -> get outta here je .done ; yeah -> get outta here
movzx ecx,al ; nope -> display character movzx ecx,al ; nope -> display character
mov eax,MOS_SC_DEBUGBOARD mcall SF_BOARD
int 0x40
jmp .loop jmp .loop
.done: .done:
popfd popfd
popad popad
leave leave
ret 4 ret 4
%else
end if
%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

View File

@@ -17,8 +17,6 @@
; along with this program; if not, write to the Free Software ; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
; ;
%ifndef _DRAW_INC
%define _DRAW_INC
TMR1_FACTOR dd 0.45 TMR1_FACTOR dd 0.45
@@ -50,45 +48,36 @@ monthNames:
; output : nothing ; output : nothing
; destroys : nothing ; destroys : nothing
;******************************************************************** ;********************************************************************
drawClock: proc drawClock
%push drawClock_context locals
%stacksize flat i dd ?
%assign %$localsize 0 TMR1X dd ?
TMR1Y dd ?
%local i:dword, \ TMR2X dd ?
TMR1X:dword, \ TMR2Y dd ?
TMR1Y:dword, \ SECRX dd ?
TMR2X:dword, \ SECRY dd ?
TMR2Y:dword, \ MINRX dd ?
SECRX:dword, \ MINRY dd ?
SECRY:dword, \ HOURRX dd ?
MINRX:dword, \ HOURRY dd ?
MINRY:dword, \ workwidth dd ?
HOURRX:dword, \ workheight dd ?
HOURRY:dword, \ foo dd ?
workwidth:dword, \ endl
workheight:dword, \
foo:dword
enter %$localsize,0
pushad pushad
pushfd pushfd
; get window dimensions ; get window dimensions
mov eax,MOS_SC_GETPROCESSINFO mcall SF_THREAD_INFO,procInfo,-1
mov ebx,procInfo
mov ecx,-1
int 0x40
; calculate work area size (width/height = ecx/edx) ; calculate work area size (width/height = ecx/edx)
; if the work area is too small (maybe the window is shaded) ; if the work area is too small (maybe the window is shaded)
; we don't draw anything. ; we don't draw anything.
mov eax,MOS_SC_WINDOWPROPERTIES mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT ; get skin height (eax)
mov ebx,4 ; get skin height (eax) mov ecx,[procInfo.box.width]
int 0x40
mov ecx,[procInfo + MOS_PROCESSINFO.wndWidth]
sub ecx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT 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,eax
sub edx,MOS_WND_SKIN_BORDER_BOTTOM sub edx,MOS_WND_SKIN_BORDER_BOTTOM
cmp ecx,0 ; width too small ? cmp ecx,0 ; width too small ?
@@ -102,9 +91,9 @@ drawClock:
mov [workheight],edx mov [workheight],edx
; calculate center of clock (x/y = esi/edi) ; calculate center of clock (x/y = esi/edi)
mov esi,[procInfo + MOS_PROCESSINFO.wndWidth] mov esi,[procInfo.box.width]
shr esi,1 shr esi,1
mov edi,[procInfo + MOS_PROCESSINFO.wndHeight] mov edi,[procInfo.box.height]
sub edi,MOS_WND_SKIN_BORDER_BOTTOM sub edi,MOS_WND_SKIN_BORDER_BOTTOM
sub edi,eax sub edi,eax
shr edi,1 shr edi,1
@@ -119,9 +108,8 @@ drawClock:
shl ecx,16 ; (=skin height) shl ecx,16 ; (=skin height)
or ecx,edx ; height or ecx,edx ; height
inc ecx inc ecx
mov edx,[wndColors + MOS_WNDCOLORS.work] mov edx,[wndColors.work]
mov eax,MOS_SC_DRAWBAR mcall SF_DRAW_RECT
int 0x40
popad popad
; calculate second hand radii ; calculate second hand radii
@@ -163,8 +151,7 @@ drawClock:
fstp dword [TMR2Y] fstp dword [TMR2Y]
; get system clock (edx) ; get system clock (edx)
mov eax,MOS_SC_GETSYSCLOCK mcall SF_GET_SYS_TIME
int 0x40
mov edx,eax mov edx,eax
; draw second hand ; draw second hand
@@ -173,21 +160,14 @@ drawClock:
shr eax,16 shr eax,16
call bcdbin call bcdbin
mov ecx,eax ; save seconds for later mov ecx,eax ; save seconds for later
push ecx ; 2*pi/60
push eax stdcall getHandCoords,edi,esi,[SECRY],[SECRX],0.104719755,eax,ecx
fpush32 0.104719755 ; 2*pi/60
push dword [SECRX]
push dword [SECRY]
push esi
push edi
call getHandCoords
mov eax,MOS_SC_DRAWLINE
shl ebx,16 shl ebx,16
or ebx,esi or ebx,esi
shl ecx,16 shl ecx,16
or ecx,edi or ecx,edi
mov edx,[wndColors + MOS_WNDCOLORS.workText] mov edx,[wndColors.work_text]
int 0x40 mcall SF_DRAW_LINE
pop ecx pop ecx
pop edx pop edx
@@ -200,21 +180,14 @@ drawClock:
mul edx mul edx
add eax,ecx add eax,ecx
mov ecx,eax ; save for later mov ecx,eax ; save for later
push ecx ; 2*pi/60/60
push eax stdcall getHandCoords,edi,esi,[MINRY],[MINRX],0.001745329,eax,ecx
fpush32 0.001745329 ; 2*pi/60/60
push dword [MINRX]
push dword [MINRY]
push esi
push edi
call getHandCoords
mov eax,MOS_SC_DRAWLINE
shl ebx,16 shl ebx,16
or ebx,esi or ebx,esi
shl ecx,16 shl ecx,16
or ecx,edi or ecx,edi
mov edx,[wndColors + MOS_WNDCOLORS.workText] mov edx,[wndColors.work_text]
int 0x40 mcall SF_DRAW_LINE
pop ecx pop ecx
pop edx pop edx
@@ -229,55 +202,39 @@ drawClock:
mov edx,60*60 mov edx,60*60
mul edx mul edx
add eax,ecx add eax,ecx
push eax ; 2*pi/60/60/12
fpush32 0.000145444 ; 2*pi/60/60/12 stdcall getHandCoords,edi,esi,[HOURRY],[HOURRX],0.000145444,eax
push dword [HOURRX]
push dword [HOURRY]
push esi
push edi
call getHandCoords
mov eax,MOS_SC_DRAWLINE
shl ebx,16 shl ebx,16
or ebx,esi or ebx,esi
shl ecx,16 shl ecx,16
or ecx,edi or ecx,edi
mov edx,[wndColors + MOS_WNDCOLORS.workText] mov edx,[wndColors.work_text]
int 0x40 mcall SF_DRAW_LINE
pop edx pop edx
; draw tick marks ; draw tick marks
mov dword [i],11 ; draw 12 marks mov dword [i],11 ; draw 12 marks
.drawtickmarks: .drawtickmarks:
push dword [i] ; calculate start point ; calculate start point
fpush32 0.523598776 ; 2*pi/12 ; 2*pi/12
push dword [TMR1X] stdcall getHandCoords,edi,esi,[TMR1Y],[TMR1X],0.523598776,[i]
push dword [TMR1Y]
push esi
push edi
call getHandCoords
mov eax,ebx ; save in eax and edx mov eax,ebx ; save in eax and edx
mov edx,ecx mov edx,ecx
push dword [i] ; 2*pi/12
fpush32 0.523598776 ; 2*pi/12 stdcall getHandCoords,edi,esi,[TMR2Y],[TMR2X],0.523598776,[i]
push dword [TMR2X]
push dword [TMR2Y]
push esi
push edi
call getHandCoords
shl eax,16 shl eax,16
shl edx,16 shl edx,16
or ebx,eax ; ebx = x start and end or ebx,eax ; ebx = x start and end
or ecx,edx ; ecx = y start and end or ecx,edx ; ecx = y start and end
mov edx,[wndColors + MOS_WNDCOLORS.workText] mov edx,[wndColors.work_text]
mov eax,MOS_SC_DRAWLINE mcall SF_DRAW_LINE
int 0x40
dec dword [i] dec dword [i]
jns .drawtickmarks jns .drawtickmarks
%define DATE_WIDTH 48 DATE_WIDTH =48
; calculate text start position ; calculate text start position
mov eax,[procInfo+MOS_PROCESSINFO.wndWidth] mov eax,[procInfo.box.width]
sub eax,DATE_WIDTH ; x = (wndwidth-textwidth)/2 sub eax,DATE_WIDTH ; x = (wndwidth-textwidth)/2
shr eax,1 ; eax = x shr eax,1 ; eax = x
fild dword [workheight] ; y = DATE_FACTOR*workheight... fild dword [workheight] ; y = DATE_FACTOR*workheight...
@@ -292,7 +249,7 @@ drawClock:
jb .goodbye jb .goodbye
mov ecx,ebx ; text too high ? mov ecx,ebx ; text too high ?
add ecx,10-1 add ecx,10-1
mov edx,[procInfo+MOS_PROCESSINFO.wndHeight] mov edx,[procInfo.box.height]
sub edx,MOS_WND_SKIN_BORDER_BOTTOM sub edx,MOS_WND_SKIN_BORDER_BOTTOM
cmp ecx,edx cmp ecx,edx
jnae .yousuck jnae .yousuck
@@ -306,8 +263,7 @@ drawClock:
or ebx,eax or ebx,eax
; get date (edi) ; get date (edi)
mov eax,MOS_SC_GETDATE mcall SF_GET_SYS_DATE
int 0x40
mov edi,eax mov edi,eax
; display month ; display month
@@ -315,44 +271,41 @@ drawClock:
shr eax,8 shr eax,8
call bcdbin call bcdbin
; ebx contains already position ; 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 =] lea edx,[monthNames-3+eax*2+eax]; -3 because eax = 1..12 =]
mov esi,3 ; text length mov esi,3 ; text length
mov eax,MOS_SC_WRITETEXT mcall SF_DRAW_TEXT
int 0x40
; display date ; display date
add ebx,MOS_DWORD(3*6+3,0) add ebx,(3*6+3) shl 16
mov eax,edi ; get date mov eax,edi ; get date
shr eax,16 shr eax,16
call bcdbin call bcdbin
mov edx,ebx ; position must be in edx mov edx,ebx ; position must be in edx
mov ebx,0x00020000 ; number, display two digits mov ebx,0x00020000 ; number, display two digits
mov ecx,eax ; number to display mov ecx,eax ; number to display
mov esi,[wndColors+MOS_WNDCOLORS.workText] mov esi,[wndColors.work_text]
mov eax,MOS_SC_WRITENUMBER mcall SF_DRAW_NUMBER
int 0x40
; display year. the way we avoid the y2k bug is even ; display year. the way we avoid the y2k bug is even
; simpler, yet much better than in the last version: ; simpler, yet much better than in the last version:
; now we simply display the last two digits and let the ; now we simply display the last two digits and let the
; user decide wether it's the year 1903 or 2003 =] ; 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 mov eax,edi ; get year
call bcdbin call bcdbin
mov ebx,0x00020000 ; number, display two digits mov ebx,0x00020000 ; number, display two digits
mov ecx,eax ; number to display mov ecx,eax ; number to display
; edx contains already position ; edx contains already position
mov esi,[wndColors+MOS_WNDCOLORS.workText] mov esi,[wndColors.work_text]
mov eax,MOS_SC_WRITENUMBER mcall SF_DRAW_NUMBER
int 0x40
.byebye: .byebye:
popfd popfd
popad popad
leave ;leave
ret ret
%pop endp
;********************************************************** ;**********************************************************
@@ -397,36 +350,26 @@ bcdbin:
; destroys: ; destroys:
; nothing ; nothing
;******************************************************************** ;********************************************************************
getHandCoords: proc getHandCoords CENTERY:dword, CENTERX:dword, RADIUSY:dword, RADIUSX:dword, DEG2RAD:dword, ANGLE:dword
ANGLE equ 28
DEG2RAD equ 24
RADIUSX equ 20
RADIUSY equ 16
CENTERX equ 12
CENTERY equ 8
enter 0,0
pushfd pushfd
fild dword [ebp+ANGLE] ; get angle fild dword [ANGLE] ; get angle
fmul dword [ebp+DEG2RAD] ; convert to radians fmul dword [DEG2RAD] ; convert to radians
fsincos fsincos
fmul dword [ebp+RADIUSY] ; -y * radius + clockcy fmul dword [RADIUSY] ; -y * radius + clockcy
fchs fchs
fiadd dword [ebp+CENTERY] fiadd dword [CENTERY]
fistp dword [ebp+CENTERY] fistp dword [CENTERY]
fmul dword [ebp+RADIUSX] ; x * radius + clockcx fmul dword [RADIUSX] ; x * radius + clockcx
fiadd dword [ebp+CENTERX] fiadd dword [CENTERX]
fistp dword [ebp+CENTERX] fistp dword [CENTERX]
mov ebx,[ebp+CENTERX] mov ebx,[CENTERX]
mov ecx,[ebp+CENTERY] mov ecx,[CENTERY]
popfd popfd
leave ;leave
ret 4*6 ret
endp
%endif

View File

@@ -1,5 +1,3 @@
; some strtok-like function
;
; Copyright (c) 2003 Thomas Mathys ; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch ; killer@vantage.ch
; ;
@@ -17,8 +15,94 @@
; along with this program; if not, write to the Free Software ; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; 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 ret
.adx dd 0 .adx dd 0
%endif

View File

@@ -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")

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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