diff --git a/data/eng/File Managers/eolite b/data/eng/File Managers/eolite deleted file mode 100644 index db7b628d96..0000000000 Binary files a/data/eng/File Managers/eolite and /dev/null differ diff --git a/data/eng/Makefile b/data/eng/Makefile index e48382796f..e3c8c81ed7 100644 --- a/data/eng/Makefile +++ b/data/eng/Makefile @@ -190,6 +190,15 @@ COPY_FILES:=\ fonts/tscr.chr:FONTS/TSCR.CHR:$(PROGS)/demos/bgitest/trunk/FONTS/TSCR.CHR \ games/snake.ini:GAMES/SNAKE.INI:$(PROGS)/games/snake/trunk/snake.ini +# The list of all C-- programs with one main C-- file. +# Format of an item is exactly the same as in the previous list. +CMM_PROGRAMS:=\ + File|Managers/eolite:File|Managers/EOLITE:$(PROGS)/fs/Eolite/trunk/Eolite.c-- \ + games/clicks:GAMES/CLICKS:$(PROGS)/games/clicks/trunk/clicks.c-- \ +# end if list +# mine is not compilable +# games/mine:GAMES/MINE:$(PROGS)/games/mine/trunk/mine.c-- + # List of other files to be included in the image file. # Some of them are auto-built with special rules, some just exist before build. # Each item is of the form :. @@ -212,7 +221,6 @@ OTHER_FILES:=asciivju:ASCIIVJU autorun.dat:AUTORUN.DAT \ demos/use_mb:DEMOS/USE_MB demos/web:DEMOS/WEB \ drivers/atikms.dll:DRIVERS/ATIKMS.DLL \ File|Managers/buttons.bmp:File|Managers/BUTTONS.BMP \ - File|Managers/eolite:File|Managers/EOLITE \ File|Managers/eolite.ini:File|Managers/EOLITE.INI \ File|Managers/icons.bmp:File|Managers/ICONS.BMP \ File|Managers/icons.ini:File|Managers/ICONS.INI \ @@ -223,7 +231,7 @@ OTHER_FILES:=asciivju:ASCIIVJU autorun.dat:AUTORUN.DAT \ fonts/bold.chr:FONTS/BOLD.CHR fonts/char2.mt:FONTS/CHAR2.MT \ fonts/char.mt:FONTS/CHAR.MT \ games/bnc:GAMES/BNC \ - games/checkers:GAMES/CHECKERS games/clicks:GAMES/CLICKS \ + games/checkers:GAMES/CHECKERS \ games/FindNumbers:GAMES/FindNumbers games/gomoku:GAMES/GOMOKU \ games/klavisha:GAMES/KLAVISHA games/kosilka:GAMES/KOSILKA \ games/kosskin.gfx:GAMES/KOSSKIN.GFX games/kox:GAMES/KOX \ @@ -257,7 +265,7 @@ fsource=$(call respace,$(call sourcepart,$(f))) # Define targets for image file. # Join all the lists above. -targets_full:=$(COPY_FILES) $(FASM_PROGRAMS) $(NASM_PROGRAMS) $(OTHER_FILES) +targets_full:=$(COPY_FILES) $(FASM_PROGRAMS) $(NASM_PROGRAMS) $(OTHER_FILES) $(CMM_PROGRAMS) # For each item in the united list call fbinary. targets:=$(foreach f,$(targets_full),$(fbinary)) @@ -332,3 +340,119 @@ include Makefile.copy docpak: $(DOCDIR)SYSFUNCS.TXT $(wildcard $(DOCDIR)*) $(DOCDIR)SYSFUNCS.TXT: $(KERNEL)/docs/sysfuncs.txt cp $(KERNEL)/docs/sysfuncs.txt $(DOCDIR)SYSFUNCS.TXT + +# Similar for C--. +include Makefile.cmm + +# Sorry, even black magic seems to be insufficient for +# auto-handling all subtle effects. So we just define +# command lines for compiling and linking, and +# maintain the list of sources and objects by hand. +include Makefile.msvc + +# Rules for table +table: .obj.table/table.exe + $(msvc_final) +TABLE_OBJECTS:=.obj.table/calc.obj .obj.table/func.obj .obj.table/hello.obj \ + .obj.table/KosFile.obj .obj.table/kosSyst.obj .obj.table/math2.obj \ + .obj.table/mcsmemm.obj .obj.table/parser.obj +TABLE_H_FILES:=$(wildcard $(PROGS)/other/table/*.h) +.obj.table/table.exe: $(TABLE_OBJECTS) + $(msvc_link) +$(TABLE_OBJECTS): .obj.table/%.obj: $(PROGS)/other/table/%.cpp $(TABLE_H_FILES) Makefile.msvc | .obj.table + $(msvc_compile) +.obj.table: + mkdir -p .obj.table + +# Rules for graph +graph: .obj.graph/graph.exe + $(msvc_final) +GRAPH_CPP_OBJECTS:=.obj.graph/func.obj .obj.graph/hello.obj .obj.graph/kolibri.obj \ + .obj.graph/KosFile.obj .obj.graph/kosSyst.obj .obj.graph/math2.obj \ + .obj.graph/mcsmemm.obj .obj.graph/parser.obj +GRAPH_C_OBJECTS:=.obj.graph/string.obj +GRAPH_H_FILES:=$(wildcard $(PROGS)/other/graph/*.h) +GRAPH_FASM_OBJECTS:=.obj.graph/memcpy.obj .obj.graph/memset.obj +.obj.graph/graph.exe: $(GRAPH_CPP_OBJECTS) $(GRAPH_C_OBJECTS) $(GRAPH_FASM_OBJECTS) + $(msvc_link) +$(GRAPH_CPP_OBJECTS): .obj.graph/%.obj: $(PROGS)/other/graph/%.cpp $(GRAPH_H_FILES) Makefile.msvc | .obj.graph + $(msvc_compile) +$(GRAPH_C_OBJECTS): .obj.graph/%.obj: $(PROGS)/other/graph/%.c $(GRAPH_H_FILES) Makefile.msvc | .obj.graph + $(msvc_compile) +$(GRAPH_FASM_OBJECTS): .obj.graph/%.obj: $(PROGS)/other/graph/%.asm Makefile.msvc | .obj.graph + fasm $< $@ +.obj.graph: + mkdir -p .obj.graph + +# Rules for kosilka +games/kosilka: .obj.kosilka/kosilka.exe + $(msvc_final) +KOSILKA_OBJECTS:=.obj.kosilka/kosilka.obj .obj.kosilka/KosFile.obj .obj.kosilka/kosSyst.obj .obj.kosilka/mcsmemm.obj +KOSILKA_H_FILES:=$(PROGS)/games/kosilka/*.h +.obj.kosilka/kosilka.exe: $(KOSILKA_OBJECTS) + $(msvc_link) +$(KOSILKA_OBJECTS): .obj.kosilka/%.obj: $(PROGS)/games/kosilka/%.cpp $(KOSILKA_H_FILES) Makefile.msvc | .obj.kosilka + $(msvc_compile) +.obj.kosilka: + mkdir -p .obj.kosilka + +include Makefile.gcc + +# Rules for shell +shell: .obj.shell/start.o .obj.shell/shell.o .obj.shell/kolibri.o .obj.shell/stdlib.o .obj.shell/string.o \ + $(PROGS)/system/shell/kolibri.ld + $(call gcc_link,$(PROGS)/system/shell/kolibri.ld) +.obj.shell/shell.o: $(PROGS)/system/shell/shell.c \ + $(PROGS)/system/shell/all.h \ + $(PROGS)/system/shell/system/*.h \ + $(PROGS)/system/shell/cmd/*.c \ + $(PROGS)/system/shell/modules/*.c \ + $(PROGS)/system/shell/locale/rus/globals.h \ + Makefile.gcc | .obj.shell + $(gcc_compile) +.obj.shell/kolibri.o .obj.shell/stdlib.o .obj.shell/string.o: .obj.shell/%.o: \ + $(PROGS)/system/shell/system/%.c $(PROGS)/system/shell/system/*.h \ + Makefile.gcc | .obj.shell + $(gcc_compile) + win32-gcc -c -Os -o $@ $< +.obj.shell/start.o: $(PROGS)/system/shell/start.asm | .obj.shell + fasm $< $@ +.obj.shell: + mkdir -p .obj.shell + +# Rules for media/ac97snd +# Not compilable from svn sources, using preloaded binary + +# Rules for atikms.dll +# Use Makefile from $(REPOSITORY)/drivers/ddk and $(REPOSITORY)/drivers/video/drm/radeon +# However, dependencies must be duplicated - I don't know how to avoid this +# without need to rebuild kolibri.img at every iteration... +# Note that we are going to write in the directory shared +# between all Makefiles, so we need locked operations. +drivers/atikms.dll: $(REPOSITORY)/drivers/video/drm/radeon/atikms.dll drivers/.dir + kpack --nologo $< $@ +$(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: + flock $(REPOSITORY)/drivers/video/drm/radeon/.lock \ + $(MAKE) CC=win32-gcc AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/video/drm/radeon +$(REPOSITORY)/drivers/ddk/libddk.a: + flock $(REPOSITORY)/drivers/ddk/.lock \ + $(MAKE) CC=win32-gcc AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/ddk +# dependencies +$(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: \ + $(REPOSITORY)/drivers/video/drm/radeon/atikms.lds \ + $(REPOSITORY)/drivers/ddk/libddk.a \ + $(REPOSITORY)/drivers/video/drm/radeon/*.[Sch] \ + $(REPOSITORY)/drivers/video/drm/radeon/*.asm \ + $(REPOSITORY)/drivers/video/drm/radeon/Makefile \ + $(REPOSITORY)/drivers/video/drm/radeon/firmware/*.bin \ + $(REPOSITORY)/drivers/include/*.h \ + $(REPOSITORY)/drivers/include/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*/*.h +$(REPOSITORY)/drivers/ddk/libddk.a: \ + $(REPOSITORY)/drivers/ddk/Makefile \ + $(REPOSITORY)/drivers/ddk/*/* \ + $(REPOSITORY)/drivers/include/*.h \ + $(REPOSITORY)/drivers/include/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*/*.h diff --git a/data/eng/Makefile.cmm b/data/eng/Makefile.cmm new file mode 100644 index 0000000000..46a9a219cb --- /dev/null +++ b/data/eng/Makefile.cmm @@ -0,0 +1,15 @@ +# This is similar to Makefile.fasm, look there for comments. +# No dependency tracking, so force dependencies on all files +# in dir/* and dir/*/* +# Also, we cannot set output file name and need to guess +# whether c-- has created .com file or no-extension file. +define cmm_meta_rule +$(1): $(2) Makefile.cmm $$(call respace,$$(addsuffix .dir,$(3))) \ + $$(wildcard $$(dir $(2))*) $$(wildcard $$(dir $(2))*/*) + flock $$(dir $(2)).lock \ + win32-c-- /IP=Z:$$(dir $(2)) Z:$$< >&2 && \ + if [ -e $$(basename $$<) ]; then f=$$(basename $$<); else f=$$(basename $$<).com; fi && \ + kpack --nologo $$$$f "$$@" && rm $$$$f +endef + +$(foreach f,$(CMM_PROGRAMS),$(eval $(call cmm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) diff --git a/data/eng/Makefile.gcc b/data/eng/Makefile.gcc new file mode 100644 index 0000000000..14ae973a61 --- /dev/null +++ b/data/eng/Makefile.gcc @@ -0,0 +1,8 @@ +define gcc_compile + win32-gcc -c -Os -DAUTOBUILD -DLANG_ENG=1 -o $@ $< +endef +define gcc_link + win32-ld -nostdlib -T $(1) -o "$@" $^ + win32-objcopy "$@" -O binary + kpack --nologo "$@" +endef diff --git a/data/eng/Makefile.msvc b/data/eng/Makefile.msvc new file mode 100644 index 0000000000..0902ceed22 --- /dev/null +++ b/data/eng/Makefile.msvc @@ -0,0 +1,13 @@ +define msvc_compile +win32-cl /c /O2 /Os /Oy /GF /GS- /GR- /EHs-c- /fp:fast /GL /QIfist /Gr /DAUTOBUILD /Fo$@ Z:$< >&2 +endef +define msvc_link +win32-link /section:.bss,E /fixed:no /subsystem:native \ +/merge:.data=.text /merge:.rdata=.text /merge:.1seg=.text \ +/entry:crtStartUp /out:$@ /ltcg /nodefaultlib \ +$(addprefix Z:,$^) >&2 +endef +define msvc_final +EXENAME=$< fasm doexe2.asm "$@" +kpack --nologo "$@" +endef diff --git a/data/eng/drivers/atikms.dll b/data/eng/drivers/atikms.dll deleted file mode 100644 index f3dc7b8ccf..0000000000 Binary files a/data/eng/drivers/atikms.dll and /dev/null differ diff --git a/data/eng/games/clicks b/data/eng/games/clicks deleted file mode 100644 index d694ddf27c..0000000000 Binary files a/data/eng/games/clicks and /dev/null differ diff --git a/data/eng/games/kosilka b/data/eng/games/kosilka deleted file mode 100644 index dbb7caad2c..0000000000 Binary files a/data/eng/games/kosilka and /dev/null differ diff --git a/data/eng/graph b/data/eng/graph deleted file mode 100644 index 4c5f8b03bf..0000000000 Binary files a/data/eng/graph and /dev/null differ diff --git a/data/eng/shell b/data/eng/shell deleted file mode 100644 index f78fc63c9f..0000000000 Binary files a/data/eng/shell and /dev/null differ diff --git a/data/eng/table b/data/eng/table deleted file mode 100644 index 0d5d7172c2..0000000000 Binary files a/data/eng/table and /dev/null differ diff --git a/data/rus/File Managers/eolite b/data/rus/File Managers/eolite deleted file mode 100644 index db7b628d96..0000000000 Binary files a/data/rus/File Managers/eolite and /dev/null differ diff --git a/data/rus/Makefile b/data/rus/Makefile index 4e1cb8ce83..38ca69c077 100644 --- a/data/rus/Makefile +++ b/data/rus/Makefile @@ -190,6 +190,15 @@ COPY_FILES:=\ fonts/tscr.chr:FONTS/TSCR.CHR:$(PROGS)/demos/bgitest/trunk/FONTS/TSCR.CHR \ games/snake.ini:GAMES/SNAKE.INI:$(PROGS)/games/snake/trunk/snake.ini +# The list of all C-- programs with one main C-- file. +# Format of an item is exactly the same as in the previous list. +CMM_PROGRAMS:=\ + File|Managers/eolite:File|Managers/EOLITE:$(PROGS)/fs/Eolite/trunk/Eolite.c-- \ + games/clicks:GAMES/CLICKS:$(PROGS)/games/clicks/trunk/clicks.c-- \ +# end if list +# mine is not compilable +# games/mine:GAMES/MINE:$(PROGS)/games/mine/trunk/mine.c-- + # List of other files to be included in the image file. # Some of them are auto-built with special rules, some just exist before build. # Each item is of the form :. @@ -212,7 +221,6 @@ OTHER_FILES:=asciivju:ASCIIVJU autorun.dat:AUTORUN.DAT \ demos/use_mb:DEMOS/USE_MB demos/web:DEMOS/WEB \ drivers/atikms.dll:DRIVERS/ATIKMS.DLL \ File|Managers/buttons.bmp:File|Managers/BUTTONS.BMP \ - File|Managers/eolite:File|Managers/EOLITE \ File|Managers/eolite.ini:File|Managers/EOLITE.INI \ File|Managers/icons.bmp:File|Managers/ICONS.BMP \ File|Managers/icons.ini:File|Managers/ICONS.INI \ @@ -224,7 +232,7 @@ OTHER_FILES:=asciivju:ASCIIVJU autorun.dat:AUTORUN.DAT \ fonts/char.mt:FONTS/CHAR.MT \ games/appdata.dat:GAMES/APPDATA.DAT games/ataka:GAMES/ATAKA \ games/basekurs.kla:GAMES/BASEKURS.KLA games/bnc:GAMES/BNC \ - games/checkers:GAMES/CHECKERS games/clicks:GAMES/CLICKS \ + games/checkers:GAMES/CHECKERS \ games/FindNumbers:GAMES/FindNumbers games/gomoku:GAMES/GOMOKU \ games/klavisha:GAMES/KLAVISHA games/kosilka:GAMES/KOSILKA \ games/kosskin.gfx:GAMES/KOSSKIN.GFX games/kox:GAMES/KOX \ @@ -258,7 +266,7 @@ fsource=$(call respace,$(call sourcepart,$(f))) # Define targets for image file. # Join all the lists above. -targets_full:=$(COPY_FILES) $(FASM_PROGRAMS) $(NASM_PROGRAMS) $(OTHER_FILES) +targets_full:=$(COPY_FILES) $(FASM_PROGRAMS) $(NASM_PROGRAMS) $(OTHER_FILES) $(CMM_PROGRAMS) # For each item in the united list call fbinary. targets:=$(foreach f,$(targets_full),$(fbinary)) @@ -333,3 +341,118 @@ include Makefile.copy docpak: $(DOCDIR)SYSFUNCR.TXT $(wildcard $(DOCDIR)*) $(DOCDIR)SYSFUNCR.TXT: $(KERNEL)/docs/sysfuncr.txt cp $(KERNEL)/docs/sysfuncr.txt $(DOCDIR)SYSFUNCR.TXT + +# Similar for C--. +include Makefile.cmm + +# Sorry, even black magic seems to be insufficient for +# auto-handling all subtle effects. So we just define +# command lines for compiling and linking, and +# maintain the list of sources and objects by hand. +include Makefile.msvc + +# Rules for table +table: .obj.table/table.exe + $(msvc_final) +TABLE_OBJECTS:=.obj.table/calc.obj .obj.table/func.obj .obj.table/hello.obj \ + .obj.table/KosFile.obj .obj.table/kosSyst.obj .obj.table/math2.obj \ + .obj.table/mcsmemm.obj .obj.table/parser.obj +TABLE_H_FILES:=$(wildcard $(PROGS)/other/table/*.h) +.obj.table/table.exe: $(TABLE_OBJECTS) + $(msvc_link) +$(TABLE_OBJECTS): .obj.table/%.obj: $(PROGS)/other/table/%.cpp $(TABLE_H_FILES) Makefile.msvc | .obj.table + $(msvc_compile) +.obj.table: + mkdir -p .obj.table + +# Rules for graph +graph: .obj.graph/graph.exe + $(msvc_final) +GRAPH_CPP_OBJECTS:=.obj.graph/func.obj .obj.graph/hello.obj .obj.graph/kolibri.obj \ + .obj.graph/KosFile.obj .obj.graph/kosSyst.obj .obj.graph/math2.obj \ + .obj.graph/mcsmemm.obj .obj.graph/parser.obj +GRAPH_C_OBJECTS:=.obj.graph/string.obj +GRAPH_H_FILES:=$(wildcard $(PROGS)/other/graph/*.h) +GRAPH_FASM_OBJECTS:=.obj.graph/memcpy.obj .obj.graph/memset.obj +.obj.graph/graph.exe: $(GRAPH_CPP_OBJECTS) $(GRAPH_C_OBJECTS) $(GRAPH_FASM_OBJECTS) + $(msvc_link) +$(GRAPH_CPP_OBJECTS): .obj.graph/%.obj: $(PROGS)/other/graph/%.cpp $(GRAPH_H_FILES) Makefile.msvc | .obj.graph + $(msvc_compile) +$(GRAPH_C_OBJECTS): .obj.graph/%.obj: $(PROGS)/other/graph/%.c $(GRAPH_H_FILES) Makefile.msvc | .obj.graph + $(msvc_compile) +$(GRAPH_FASM_OBJECTS): .obj.graph/%.obj: $(PROGS)/other/graph/%.asm Makefile.msvc | .obj.graph + fasm $< $@ +.obj.graph: + mkdir -p .obj.graph + +# Rules for kosilka +games/kosilka: .obj.kosilka/kosilka.exe + $(msvc_final) +KOSILKA_OBJECTS:=.obj.kosilka/kosilka.obj .obj.kosilka/KosFile.obj .obj.kosilka/kosSyst.obj .obj.kosilka/mcsmemm.obj +KOSILKA_H_FILES:=$(PROGS)/games/kosilka/*.h +.obj.kosilka/kosilka.exe: $(KOSILKA_OBJECTS) + $(msvc_link) +$(KOSILKA_OBJECTS): .obj.kosilka/%.obj: $(PROGS)/games/kosilka/%.cpp $(KOSILKA_H_FILES) Makefile.msvc | .obj.kosilka + $(msvc_compile) +.obj.kosilka: + mkdir -p .obj.kosilka + +include Makefile.gcc + +# Rules for shell +shell: .obj.shell/start.o .obj.shell/shell.o .obj.shell/kolibri.o .obj.shell/stdlib.o .obj.shell/string.o \ + $(PROGS)/system/shell/kolibri.ld + $(call gcc_link,$(PROGS)/system/shell/kolibri.ld) +.obj.shell/shell.o: $(PROGS)/system/shell/shell.c \ + $(PROGS)/system/shell/all.h \ + $(PROGS)/system/shell/system/*.h \ + $(PROGS)/system/shell/cmd/*.c \ + $(PROGS)/system/shell/modules/*.c \ + $(PROGS)/system/shell/locale/rus/globals.h \ + Makefile.gcc | .obj.shell + $(gcc_compile) +.obj.shell/kolibri.o .obj.shell/stdlib.o .obj.shell/string.o: .obj.shell/%.o: \ + $(PROGS)/system/shell/system/%.c $(PROGS)/system/shell/system/*.h \ + Makefile.gcc | .obj.shell + $(gcc_compile) +.obj.shell/start.o: $(PROGS)/system/shell/start.asm | .obj.shell + fasm $< $@ +.obj.shell: + mkdir -p .obj.shell + +# Rules for media/ac97snd +# Not compilable from svn sources, using preloaded binary + +# Rules for atikms.dll +# Use Makefile from $(REPOSITORY)/drivers/ddk and $(REPOSITORY)/drivers/video/drm/radeon +# However, dependencies must be duplicated - I don't know how to avoid this +# without need to rebuild kolibri.img at every iteration... +# Note that we are going to write in the directory shared +# between all Makefiles, so we need locked operations. +drivers/atikms.dll: $(REPOSITORY)/drivers/video/drm/radeon/atikms.dll drivers/.dir + kpack --nologo $< $@ +$(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: + flock $(REPOSITORY)/drivers/video/drm/radeon/.lock \ + $(MAKE) CC=win32-gcc AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/video/drm/radeon +$(REPOSITORY)/drivers/ddk/libddk.a: + flock $(REPOSITORY)/drivers/ddk/.lock \ + $(MAKE) CC=win32-gcc AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/ddk +# dependencies +$(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: \ + $(REPOSITORY)/drivers/video/drm/radeon/atikms.lds \ + $(REPOSITORY)/drivers/ddk/libddk.a \ + $(REPOSITORY)/drivers/video/drm/radeon/*.[Sch] \ + $(REPOSITORY)/drivers/video/drm/radeon/*.asm \ + $(REPOSITORY)/drivers/video/drm/radeon/Makefile \ + $(REPOSITORY)/drivers/video/drm/radeon/firmware/*.bin \ + $(REPOSITORY)/drivers/include/*.h \ + $(REPOSITORY)/drivers/include/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*/*.h +$(REPOSITORY)/drivers/ddk/libddk.a: \ + $(REPOSITORY)/drivers/ddk/Makefile \ + $(REPOSITORY)/drivers/ddk/*/* \ + $(REPOSITORY)/drivers/include/*.h \ + $(REPOSITORY)/drivers/include/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*.h \ + $(REPOSITORY)/drivers/include/*/*/*/*.h diff --git a/data/rus/Makefile.cmm b/data/rus/Makefile.cmm new file mode 100644 index 0000000000..46a9a219cb --- /dev/null +++ b/data/rus/Makefile.cmm @@ -0,0 +1,15 @@ +# This is similar to Makefile.fasm, look there for comments. +# No dependency tracking, so force dependencies on all files +# in dir/* and dir/*/* +# Also, we cannot set output file name and need to guess +# whether c-- has created .com file or no-extension file. +define cmm_meta_rule +$(1): $(2) Makefile.cmm $$(call respace,$$(addsuffix .dir,$(3))) \ + $$(wildcard $$(dir $(2))*) $$(wildcard $$(dir $(2))*/*) + flock $$(dir $(2)).lock \ + win32-c-- /IP=Z:$$(dir $(2)) Z:$$< >&2 && \ + if [ -e $$(basename $$<) ]; then f=$$(basename $$<); else f=$$(basename $$<).com; fi && \ + kpack --nologo $$$$f "$$@" && rm $$$$f +endef + +$(foreach f,$(CMM_PROGRAMS),$(eval $(call cmm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) diff --git a/data/rus/Makefile.gcc b/data/rus/Makefile.gcc new file mode 100644 index 0000000000..aa8e9002c0 --- /dev/null +++ b/data/rus/Makefile.gcc @@ -0,0 +1,8 @@ +define gcc_compile + win32-gcc -c -Os -DAUTOBUILD -DLANG_RUS=1 -o $@ $< +endef +define gcc_link + win32-ld -nostdlib -T $(1) -o "$@" $^ + win32-objcopy "$@" -O binary + kpack --nologo "$@" +endef diff --git a/data/rus/Makefile.msvc b/data/rus/Makefile.msvc new file mode 100644 index 0000000000..0902ceed22 --- /dev/null +++ b/data/rus/Makefile.msvc @@ -0,0 +1,13 @@ +define msvc_compile +win32-cl /c /O2 /Os /Oy /GF /GS- /GR- /EHs-c- /fp:fast /GL /QIfist /Gr /DAUTOBUILD /Fo$@ Z:$< >&2 +endef +define msvc_link +win32-link /section:.bss,E /fixed:no /subsystem:native \ +/merge:.data=.text /merge:.rdata=.text /merge:.1seg=.text \ +/entry:crtStartUp /out:$@ /ltcg /nodefaultlib \ +$(addprefix Z:,$^) >&2 +endef +define msvc_final +EXENAME=$< fasm doexe2.asm "$@" +kpack --nologo "$@" +endef diff --git a/data/rus/drivers/atikms.dll b/data/rus/drivers/atikms.dll deleted file mode 100644 index f3dc7b8ccf..0000000000 Binary files a/data/rus/drivers/atikms.dll and /dev/null differ diff --git a/data/rus/games/clicks b/data/rus/games/clicks deleted file mode 100644 index 7d33e8a72c..0000000000 Binary files a/data/rus/games/clicks and /dev/null differ diff --git a/data/rus/games/kosilka b/data/rus/games/kosilka deleted file mode 100644 index 22e1e4f681..0000000000 Binary files a/data/rus/games/kosilka and /dev/null differ diff --git a/data/rus/graph b/data/rus/graph deleted file mode 100644 index 4c5f8b03bf..0000000000 Binary files a/data/rus/graph and /dev/null differ diff --git a/data/rus/shell b/data/rus/shell deleted file mode 100644 index f78fc63c9f..0000000000 Binary files a/data/rus/shell and /dev/null differ diff --git a/data/rus/table b/data/rus/table deleted file mode 100644 index 0d5d7172c2..0000000000 Binary files a/data/rus/table and /dev/null differ diff --git a/drivers/ddk/Makefile b/drivers/ddk/Makefile index 0ddec9dcf0..fcff015985 100644 --- a/drivers/ddk/Makefile +++ b/drivers/ddk/Makefile @@ -7,7 +7,7 @@ DRV_INCLUDES = $(DRV_TOPDIR)/include INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/linux -I$(DRV_INCLUDES)/linux/asm DEFINES = -DKOLIBRI -D__KERNEL__ -DCONFIG_X86_32 -CFLAGS = -c -O2 $(INCLUDES) $(DEFINES) -fomit-frame-pointer -fno-builtin-printf +CFLAGS = -c -Os $(INCLUDES) $(DEFINES) -march=i486 -fomit-frame-pointer -fno-builtin-printf NAME:= libddk diff --git a/drivers/video/drm/radeon/makefile b/drivers/video/drm/radeon/Makefile similarity index 87% rename from drivers/video/drm/radeon/makefile rename to drivers/video/drm/radeon/Makefile index 009f9d0e47..302586fa18 100644 --- a/drivers/video/drm/radeon/makefile +++ b/drivers/video/drm/radeon/Makefile @@ -1,6 +1,8 @@ CC = gcc +LD = ld +AS = as FASM = e:/fasm/fasm.exe DEFINES = -D__KERNEL__ -DCONFIG_X86_32 @@ -13,7 +15,7 @@ DRV_INCLUDES = $(DRV_TOPDIR)/include INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/drm \ -I$(DRV_INCLUDES)/linux -CFLAGS = -c -O2 $(INCLUDES) $(DEFINES) -march=i686 -fomit-frame-pointer -fno-builtin-printf +CFLAGS = -c -Os $(INCLUDES) $(DEFINES) -march=i486 -fomit-frame-pointer -fno-builtin-printf LIBPATH:= $(DRV_TOPDIR)/ddk @@ -135,15 +137,15 @@ NAME_OBJS = $(patsubst %.S, %.o, $(patsubst %.asm, %.o,\ all: $(NAME).dll -$(NAME).dll: $(NAME_OBJS) $(FW_BINS) $(SRC_DEP) $(HFILES) atikms.lds Makefile - ld -L$(LIBPATH) $(LDFLAGS) -T atikms.lds -o $@ $(NAME_OBJS) $(LIBS) +$(NAME).dll: $(NAME_OBJS) $(FW_BINS) $(SRC_DEP) $(HFILES) $(LIBPATH)/libcore.a $(LIBPATH)/libddk.a atikms.lds Makefile + $(LD) -L$(LIBPATH) $(LDFLAGS) -T atikms.lds -o $@ $(NAME_OBJS) $(LIBS) %.o : %.c $(HFILES) Makefile $(CC) $(CFLAGS) $(DEFINES) -o $@ $< %.o : %.S $(HFILES) Makefile - as -o $@ $< + $(AS) -o $@ $< fwblob.o: fwblob.asm $(FW_BINS) Makefile $(FASM) $< $@ diff --git a/drivers/video/drm/radeon/fwblob.asm b/drivers/video/drm/radeon/fwblob.asm index 325cab3560..f23213a8db 100644 --- a/drivers/video/drm/radeon/fwblob.asm +++ b/drivers/video/drm/radeon/fwblob.asm @@ -172,146 +172,146 @@ FIRMWARE_R700_RLC db 'radeon/R700_rlc.bin',0 align 16 R100CP_START: - file 'firmware/r100_cp.bin' + file 'firmware/R100_cp.bin' R100CP_END: align 16 R200CP_START: - file 'firmware/r200_cp.bin' + file 'firmware/R200_cp.bin' R200CP_END: align 16 R300CP_START: - file 'firmware/r300_cp.bin' + file 'firmware/R300_cp.bin' R300CP_END: align 16 R420CP_START: - file 'firmware/r420_cp.bin' + file 'firmware/R420_cp.bin' R420CP_END: align 16 R520CP_START: - file 'firmware/r520_cp.bin' + file 'firmware/R520_cp.bin' R520CP_END: align 16 RS600CP_START: - file 'firmware/rs600_cp.bin' + file 'firmware/RS600_cp.bin' RS600CP_END: align 16 RS690CP_START: - file 'firmware/rs690_cp.bin' + file 'firmware/RS690_cp.bin' RS690CP_END: align 16 RS780ME_START: - file 'firmware/rs780_me.bin' + file 'firmware/RS780_me.bin' RS780ME_END: align 16 RS780PFP_START: - file 'firmware/rs780_pfp.bin' + file 'firmware/RS780_pfp.bin' RS780PFP_END: align 16 R600ME_START: - file 'firmware/r600_me.bin' + file 'firmware/R600_me.bin' R600ME_END: align 16 RV610ME_START: - file 'firmware/rv610_me.bin' + file 'firmware/RV610_me.bin' RV610ME_END: align 16 RV620ME_START: - file 'firmware/rv620_me.bin' + file 'firmware/RV620_me.bin' RV620ME_END: align 16 RV630ME_START: - file 'firmware/rv630_me.bin' + file 'firmware/RV630_me.bin' RV630ME_END: align 16 RV635ME_START: - file 'firmware/rv635_me.bin' + file 'firmware/RV635_me.bin' RV635ME_END: align 16 RV670ME_START: - file 'firmware/rv670_me.bin' + file 'firmware/RV670_me.bin' RV670ME_END: align 16 RV710ME_START: - file 'firmware/rv710_me.bin' + file 'firmware/RV710_me.bin' RV710ME_END: align 16 RV730ME_START: - file 'firmware/rv730_me.bin' + file 'firmware/RV730_me.bin' RV730ME_END: align 16 RV770ME_START: - file 'firmware/rv770_me.bin' + file 'firmware/RV770_me.bin' RV770ME_END: align 16 RV610PFP_START: - file 'firmware/rv610_pfp.bin' + file 'firmware/RV610_pfp.bin' RV610PFP_END: align 16 RV620PFP_START: - file 'firmware/rv620_pfp.bin' + file 'firmware/RV620_pfp.bin' RV620PFP_END: align 16 RV630PFP_START: - file 'firmware/rv630_pfp.bin' + file 'firmware/RV630_pfp.bin' RV630PFP_END: align 16 RV635PFP_START: - file 'firmware/rv635_pfp.bin' + file 'firmware/RV635_pfp.bin' RV635PFP_END: align 16 RV670PFP_START: - file 'firmware/rv670_pfp.bin' + file 'firmware/RV670_pfp.bin' RV670PFP_END: align 16 RV710PFP_START: - file 'firmware/rv710_pfp.bin' + file 'firmware/RV710_pfp.bin' RV710PFP_END: align 16 RV730PFP_START: - file 'firmware/rv730_pfp.bin' + file 'firmware/RV730_pfp.bin' RV730PFP_END: align 16 RV770PFP_START: - file 'firmware/rv770_pfp.bin' + file 'firmware/RV770_pfp.bin' RV770PFP_END: align 16 R600RLC_START: - file 'firmware/r600_rlc.bin' + file 'firmware/R600_rlc.bin' R600RLC_END: align 16 R700RLC_START: - file 'firmware/r700_rlc.bin' + file 'firmware/R700_rlc.bin' R700RLC_END: diff --git a/programs/games/kosilka/kosSyst.h b/programs/games/kosilka/kosSyst.h index cd55f58ad5..4c8d212583 100644 --- a/programs/games/kosilka/kosSyst.h +++ b/programs/games/kosilka/kosSyst.h @@ -130,7 +130,7 @@ Dword rtlInterlockedExchange( Dword *target, Dword value ); // функция -1 завершения процесса void __declspec(noreturn) kos_ExitApp(); // функция 0 -void kos_DefineAndDrawWindow( +void __declspec(noinline) kos_DefineAndDrawWindow( Word x, Word y, Word sizeX, Word sizeY, Byte mainAreaType, Dword mainAreaColour, @@ -158,11 +158,11 @@ void kos_WriteTextToWindow_internal(Dword pos, Dword font, const char* textPtr, kos_WriteTextToWindow_internal(((x)<<16)|(y), ((fontType)<<24)|(textColour), textPtr, textLen) #endif // функция 7 нарисовать изображение -void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); +void __declspec(noinline) kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); // функция 8 определить кнопку void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); // функция 5 пауза, в сотых долях секунды -void __cdecl kos_Pause( Dword value ); +void __declspec(noinline) __cdecl kos_Pause( Dword value ); // функция 9 - информация о процессе Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF ); // функция 10 @@ -172,7 +172,7 @@ Dword kos_CheckForEvent(); // функция 12 void __cdecl kos_WindowRedrawStatus( Dword status ); // функция 13 нарисовать полосу -void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); +void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); // функция 17 bool kos_GetButtonID( Dword &buttonID ); // функция 23 @@ -189,7 +189,7 @@ void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY ); // функция 40 установить маску событий void kos_SetMaskForEvents( Dword mask ); // функция 47 вывести в окно приложения число -void kos_DisplayNumberToWindow( +void __declspec(noinline) kos_DisplayNumberToWindow( Dword value, Dword digitsNum, Word x, diff --git a/programs/other/graph/func.cpp b/programs/other/graph/func.cpp index 624813f6d3..e724818d5b 100644 --- a/programs/other/graph/func.cpp +++ b/programs/other/graph/func.cpp @@ -59,18 +59,18 @@ int atoi(const char* string) -double fabs(double x) +double __cdecl fabs(double x) { __asm fld x __asm fabs } #define M_PI 3.14159265358979323846 -double cos(double x) +double __cdecl cos(double x) { __asm fld x __asm fcos } -double sin(double x) +double __cdecl sin(double x) { __asm fld x __asm fsin @@ -242,12 +242,14 @@ void format( char *Str, int len, char* Format, ... ) Str[j] = 0; } +#ifndef AUTOBUILD void *memcpy(void *dst, const void *src, unsigned size) { while (size--) *((char*)dst+size) = *((char*)src+size); return dst; } +#endif int strcmp(const char *s1, const char *s2) { diff --git a/programs/other/graph/func.h b/programs/other/graph/func.h index cb84349000..3683c3f51e 100644 --- a/programs/other/graph/func.h +++ b/programs/other/graph/func.h @@ -31,9 +31,9 @@ void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword inver void DrawRegion(Dword x,Dword y,Dword width,Dword height,Dword color1); int atoi(const char* string); -double fabs(double x); -double cos(double x); -double sin(double x); +double __cdecl fabs(double x); +double __cdecl cos(double x); +double __cdecl sin(double x); int di(double x); double id(int x); diff --git a/programs/other/graph/hello.cpp b/programs/other/graph/hello.cpp index dc5a4fbf02..074762a449 100644 --- a/programs/other/graph/hello.cpp +++ b/programs/other/graph/hello.cpp @@ -55,7 +55,12 @@ char *HugeBuf = NULL; //char fuck[64] = "$this is a fucking marker$"; // параметры командной строки +#ifdef AUTOBUILD +extern char params[1024]; +char params[1024]; +#else char params[1024] = "_FIND_ME_"; +#endif /* diff --git a/programs/other/graph/kosSyst.cpp b/programs/other/graph/kosSyst.cpp index 00daf8512d..82ba5ea583 100644 --- a/programs/other/graph/kosSyst.cpp +++ b/programs/other/graph/kosSyst.cpp @@ -1,13 +1,44 @@ #include "kosSyst.h" +#include "func.h" #include #define atexitBufferSize 32 +// Autobuild uses FASM method for exe->kos, +// MENUET01 header should be present in EXE. +#ifdef AUTOBUILD +char kosExePath[1024]; +char exeStack[16384]; +extern char params[1024]; +// must be alphabetically first in the image +#pragma data_seg(".1seg") +extern "C" struct +{ + char header[8]; + int headerver; + void* entry; + void* i_end; + void* memsize; + void* stack; + void* params; + void* icon; +} header = { + {'M', 'E', 'N', 'U', 'E', 'T', '0', '1'}, + 1, + &crtStartUp, + 0, // filled by doexe2.asm + 0, // filled by doexe2.asm + exeStack + sizeof(exeStack), + params, + kosExePath +}; +#pragma data_seg() +#else +char *kosExePath = NULL; +#endif char pureCallMessage[] = "PURE function call!"; -char *kosExePath = NULL; - // void (__cdecl *atExitList[atexitBufferSize])(); int atExitFnNum = 0; @@ -64,13 +95,13 @@ Dword rtlRand( void ) return RandomSeed; } -#if _MSC_VER >= 1400 -// -void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ) +#ifdef AUTOBUILD +// Well, not really related to auto-build, but some compilation issue +void memcpy( void *dst, const void *src, size_t bytesCount ) { __asm{ mov edi, dst - mov eax, dst +// mov eax, dst mov esi, src mov ecx, bytesCount rep movsb @@ -90,6 +121,7 @@ void memset( Byte *dst, Byte filler, Dword count ) } #endif + // Dword rtlInterlockedExchange( Dword *target, Dword value ) { @@ -817,24 +849,30 @@ int __cdecl _purecall() #pragma data_seg(".CRT$XCA") #pragma data_seg(".CRT$XCZ") typedef void (__cdecl *_PVFV)(void); -__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; -__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; +//__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; +//__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; // #pragma comment(linker, "/merge:.CRT=.rdata") // void crtStartUp() { +#ifdef AUTOBUILD +// linker will try to remove unused variables; force header to be included + header.header; +#endif // вызываем инициализаторы по списку, NULL'ы игнорируем - for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) + /*for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) { // if ( *pbegin != NULL ) (**pbegin)(); - } + }*/ // инициализируем генератор случайных чисел rtlSrand( kos_GetSystemClock() ); +#ifndef AUTOBUILD // путь к файлу процесса kosExePath = *((char **)0x20); +#endif // вызов главной функции приложения kos_Main(); // выход diff --git a/programs/other/graph/kosSyst.h b/programs/other/graph/kosSyst.h index b8552de08e..9f60dba95a 100644 --- a/programs/other/graph/kosSyst.h +++ b/programs/other/graph/kosSyst.h @@ -32,10 +32,10 @@ typedef unsigned __int8 Byte; #define abs(a) (a<0?0-a:a) -extern "C" double acos(double x); -extern "C" double asin(double x); -extern "C" double floor(double x); -extern "C" double round(double x); +extern "C" double __cdecl acos(double x); +extern "C" double __cdecl asin(double x); +extern "C" double __cdecl floor(double x); +extern "C" double __cdecl round(double x); #pragma function(acos,asin) #if _MSC_VER > 1200 #pragma function(floor) @@ -101,8 +101,10 @@ union sProcessInfo } processInfo; }; +#ifndef AUTOBUILD // extern char *kosExePath; +#endif // void crtStartUp(); @@ -119,9 +121,12 @@ int __cdecl strlen( const char *line ); char * __cdecl strrchr( const char * string, int c ); #if _MSC_VER < 1400 -//extern "C" void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ); -//extern "C" void memset( Byte *dst, Byte filler, Dword count ); +extern "C" void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ); +extern "C" void memset( Byte *dst, Byte filler, Dword count ); //#pragma intrinsic(memcpy,memset) +#elif defined AUTOBUILD +void memcpy( void *dst, const void *src, size_t bytesCount ); +void memset( Byte *dst, Byte filler, Dword count ); #else void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ); void memset( Byte *dst, Byte filler, Dword count ); @@ -147,7 +152,7 @@ bool kos_GetKey( Byte &keyCode ); // функция 3 получить время Dword kos_GetSystemClock(); // функция 4 -void kos_WriteTextToWindow( +void __declspec(noinline) kos_WriteTextToWindow( Word x, Word y, Byte fontType, Dword textColour, @@ -157,7 +162,7 @@ void kos_WriteTextToWindow( // функция 7 нарисовать изображение void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); // функция 8 определить кнопку -void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); +void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); // функция 5 пауза, в сотых долях секунды void kos_Pause( Dword value ); // функция 9 - информация о процессе @@ -169,7 +174,7 @@ Dword kos_CheckForEvent(); // функция 12 void kos_WindowRedrawStatus( Dword status ); // функция 13 нарисовать полосу -void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); +void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); // функция 17 bool kos_GetButtonID( Dword &buttonID ); // функция 23 diff --git a/programs/other/graph/math2.cpp b/programs/other/graph/math2.cpp index 6b348ed777..f31a5b75a1 100644 --- a/programs/other/graph/math2.cpp +++ b/programs/other/graph/math2.cpp @@ -1,7 +1,7 @@ #include #include "kosSyst.h" extern "C" int _fltused = 0; -double acos(double x) +double __cdecl acos(double x) { __asm { fld qword ptr [esp+4] @@ -15,7 +15,7 @@ double acos(double x) fpatan } } -double asin(double x) +double __cdecl asin(double x) { __asm { fld qword ptr [esp+4] @@ -43,7 +43,7 @@ extern "C" double _ftol(double x) } } #endif -double ceil(double x) +double __cdecl ceil(double x) { __asm { fld qword ptr [esp+4] @@ -56,7 +56,7 @@ double ceil(double x) } } -double floor(double x) +double __cdecl floor(double x) { __asm { fld qword ptr [esp+4] @@ -69,7 +69,7 @@ double floor(double x) } } -double round(double x) +double __cdecl round(double x) { __asm { fld qword ptr [esp+4] diff --git a/programs/other/graph/parser.cpp b/programs/other/graph/parser.cpp index 9dc8206d94..bd28f613d9 100644 --- a/programs/other/graph/parser.cpp +++ b/programs/other/graph/parser.cpp @@ -18,17 +18,17 @@ #define ERR_BADVARIABLE -5 #define ERR_OVERFLOW -6 -double tg(double d) +double __cdecl tg(double d) { return sin(d) / cos(d); } -double ctg(double d) +double __cdecl ctg(double d) { return cos(d) / sin(d); } -double exp(double x) +double __cdecl exp(double x) { __asm { fld x @@ -49,7 +49,7 @@ double exp(double x) } -double log(double x) +double __cdecl log(double x) { //return 0.0; __asm { @@ -61,7 +61,7 @@ double log(double x) } } -double sqrt(double x) +double __cdecl sqrt(double x) { __asm { fld x @@ -69,7 +69,7 @@ double sqrt(double x) } } -double atan(double x) +double __cdecl atan(double x) { return 0.0; // в лом } @@ -81,7 +81,7 @@ double pow(double x, double y) // represents general mathematical function -typedef double(*matfunc)(double); +typedef double(__cdecl*matfunc)(double); // used to link function name to the function typedef struct diff --git a/programs/other/graph/string.c b/programs/other/graph/string.c index 9f9eac90a3..1e2d260aa0 100644 --- a/programs/other/graph/string.c +++ b/programs/other/graph/string.c @@ -1,6 +1,7 @@ #include "string.h" +#ifndef AUTOBUILD void* memset(void *mem, int c, unsigned size) { unsigned i; @@ -109,3 +110,4 @@ char* strchr(const char* string, int c) return (char*)0; } +#endif diff --git a/programs/other/graph/string.h b/programs/other/graph/string.h index 7cf010c54e..79936e841b 100644 --- a/programs/other/graph/string.h +++ b/programs/other/graph/string.h @@ -1,12 +1,14 @@ +#ifndef AUTOBUILD #define NULL ((void*)0) void* memset(void *mem, int c, unsigned size); void* memcpy(void *dst, const void *src, unsigned size); +int strlen(const char* string); +#endif void strcat(char strDest[], char strSource[]); int strcmp(const char* string1, const char* string2); //void strcpy(char strDest[], const char strSource[]); char* strncpy(char *strDest, const char *strSource, unsigned n); -int strlen(const char* string); char *strchr(const char* string, int c); diff --git a/programs/other/table/kosSyst.cpp b/programs/other/table/kosSyst.cpp index 4cd094921b..7469ddba96 100644 --- a/programs/other/table/kosSyst.cpp +++ b/programs/other/table/kosSyst.cpp @@ -4,11 +4,40 @@ #define atexitBufferSize 32 +// Autobuild uses FASM method for exe->kos, +// MENUET01 header should be present in EXE. +#ifdef AUTOBUILD +char kosExePath[1024]; +char exeStack[16384]; +// must be alphabetically first in the image +#pragma data_seg(".1seg") +extern "C" struct +{ + char header[8]; + int headerver; + void* entry; + void* i_end; + void* memsize; + void* stack; + void* params; + void* icon; +} header = { + {'M', 'E', 'N', 'U', 'E', 'T', '0', '1'}, + 1, + &crtStartUp, + 0, // filled by doexe2.asm + 0, // filled by doexe2.asm + exeStack + sizeof(exeStack), + NULL, + kosExePath +}; +#pragma data_seg() +#else +char *kosExePath = NULL; +#endif char pureCallMessage[] = "PURE function call!"; -char *kosExePath = NULL; - // void (__cdecl *atExitList[atexitBufferSize])(); int atExitFnNum = 0; @@ -65,12 +94,13 @@ Dword rtlRand( void ) return RandomSeed; } - -/*void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ) +#ifdef AUTOBUILD +// Well, not really related to auto-build, but some compilation issue +void memcpy( void *dst, const void *src, size_t bytesCount ) { __asm{ mov edi, dst - mov eax, dst +// mov eax, dst mov esi, src mov ecx, bytesCount rep movsb @@ -87,7 +117,8 @@ void memset( Byte *dst, Byte filler, Dword count ) mov ecx, count rep stosb } -}*/ +} +#endif // @@ -867,24 +898,32 @@ int __cdecl _purecall() #pragma data_seg(".CRT$XCA") #pragma data_seg(".CRT$XCZ") typedef void (__cdecl *_PVFV)(void); -__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; -__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; +//__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; +//__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; // +extern void ALMOST_HALF_init(); #pragma comment(linker, "/merge:.CRT=.rdata") // void crtStartUp() { +#ifdef AUTOBUILD +// linker will try to remove unused variables; force header to be included + header.header; +#endif // вызываем инициализаторы по списку, NULL'ы игнорируем - for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) + /*for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) { // if ( *pbegin != NULL ) (**pbegin)(); - } + }*/ + ALMOST_HALF_init(); // инициализируем генератор случайных чисел rtlSrand( kos_GetSystemClock() ); +#ifndef AUTOBUILD // путь к файлу процесса kosExePath = *((char **)0x20); +#endif // вызов главной функции приложения kos_Main(); // выход diff --git a/programs/other/table/kosSyst.h b/programs/other/table/kosSyst.h index c9ad210586..9f60dba95a 100644 --- a/programs/other/table/kosSyst.h +++ b/programs/other/table/kosSyst.h @@ -32,10 +32,10 @@ typedef unsigned __int8 Byte; #define abs(a) (a<0?0-a:a) -extern "C" double acos(double x); -extern "C" double asin(double x); -extern "C" double floor(double x); -extern "C" double round(double x); +extern "C" double __cdecl acos(double x); +extern "C" double __cdecl asin(double x); +extern "C" double __cdecl floor(double x); +extern "C" double __cdecl round(double x); #pragma function(acos,asin) #if _MSC_VER > 1200 #pragma function(floor) @@ -101,8 +101,10 @@ union sProcessInfo } processInfo; }; +#ifndef AUTOBUILD // extern char *kosExePath; +#endif // void crtStartUp(); @@ -122,6 +124,9 @@ char * __cdecl strrchr( const char * string, int c ); extern "C" void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ); extern "C" void memset( Byte *dst, Byte filler, Dword count ); //#pragma intrinsic(memcpy,memset) +#elif defined AUTOBUILD +void memcpy( void *dst, const void *src, size_t bytesCount ); +void memset( Byte *dst, Byte filler, Dword count ); #else void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ); void memset( Byte *dst, Byte filler, Dword count ); @@ -147,7 +152,7 @@ bool kos_GetKey( Byte &keyCode ); // функция 3 получить время Dword kos_GetSystemClock(); // функция 4 -void kos_WriteTextToWindow( +void __declspec(noinline) kos_WriteTextToWindow( Word x, Word y, Byte fontType, Dword textColour, @@ -157,7 +162,7 @@ void kos_WriteTextToWindow( // функция 7 нарисовать изображение void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); // функция 8 определить кнопку -void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); +void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); // функция 5 пауза, в сотых долях секунды void kos_Pause( Dword value ); // функция 9 - информация о процессе @@ -169,7 +174,7 @@ Dword kos_CheckForEvent(); // функция 12 void kos_WindowRedrawStatus( Dword status ); // функция 13 нарисовать полосу -void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); +void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); // функция 17 bool kos_GetButtonID( Dword &buttonID ); // функция 23 diff --git a/programs/other/table/math2.cpp b/programs/other/table/math2.cpp index 6b348ed777..f31a5b75a1 100644 --- a/programs/other/table/math2.cpp +++ b/programs/other/table/math2.cpp @@ -1,7 +1,7 @@ #include #include "kosSyst.h" extern "C" int _fltused = 0; -double acos(double x) +double __cdecl acos(double x) { __asm { fld qword ptr [esp+4] @@ -15,7 +15,7 @@ double acos(double x) fpatan } } -double asin(double x) +double __cdecl asin(double x) { __asm { fld qword ptr [esp+4] @@ -43,7 +43,7 @@ extern "C" double _ftol(double x) } } #endif -double ceil(double x) +double __cdecl ceil(double x) { __asm { fld qword ptr [esp+4] @@ -56,7 +56,7 @@ double ceil(double x) } } -double floor(double x) +double __cdecl floor(double x) { __asm { fld qword ptr [esp+4] @@ -69,7 +69,7 @@ double floor(double x) } } -double round(double x) +double __cdecl round(double x) { __asm { fld qword ptr [esp+4] diff --git a/programs/other/table/parser.cpp b/programs/other/table/parser.cpp index 4ea28ce854..2bb34e8307 100644 --- a/programs/other/table/parser.cpp +++ b/programs/other/table/parser.cpp @@ -260,7 +260,10 @@ double func_round(double val) __asm fild x } -const double ALMOST_HALF = 0.5 - epsilon; +//const double ALMOST_HALF = 0.5 - epsilon; +double ALMOST_HALF; +extern void ALMOST_HALF_init(void) +{ ALMOST_HALF = 0.5 - epsilon; } double func_floor(double val) { int x; diff --git a/programs/system/shell/all.h b/programs/system/shell/all.h index 9129942620..9a4690f60e 100644 --- a/programs/system/shell/all.h +++ b/programs/system/shell/all.h @@ -1,7 +1,10 @@ /// =========================================================== +#ifndef AUTOBUILD +// autobuild does not create lang.h, but defines LANG_{RUS,ENG} directly #include "lang.h" +#endif #include "system/boolean.h" #include "system/kolibri.h"