From 40267e753ce301e662ddaf0100ca7e966bf57160 Mon Sep 17 00:00:00 2001 From: pavelyakov Date: Thu, 7 May 2020 08:16:59 +0000 Subject: [PATCH] Upd: function indexArray, add: new example git-svn-id: svn://kolibrios.org@7881 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/examples/array2.c | 46 ++++++++++++++++++++++++++++++++++ programs/cmm/lib/array.h | 10 ++++---- 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100755 programs/cmm/examples/array2.c diff --git a/programs/cmm/examples/array2.c b/programs/cmm/examples/array2.c new file mode 100755 index 0000000000..549b310ad9 --- /dev/null +++ b/programs/cmm/examples/array2.c @@ -0,0 +1,46 @@ +#define MEMSIZE 4096*400 + +#include "../lib/window.h" +#include "../lib/array.h" + +window win1=0; +void main() +{ + win1.background = 0xFFFFFF; + win1.left = 200; + win1.top = 200; + win1.caption = "Stress test"; + win1.ondraw = #draw_window; + win1.create(); +} + + +void draw_window() +{ + dword init = 0; + dword count = 0; + dword position = 0; + dword y = 15; + init = malloc(0x1000); + count = 200000; + while (count) + { + position = indexArray(init, count); + DSDWORD[position] = count*2; + count--; + } + position = indexArray(init, 123);DSDWORD[position] = 0; + position = indexArray(init, 777);DSDWORD[position] = 0; + count = 200000; + while (count) + { + position = indexArray(init, count); + if (DSDWORD[position] != count*2) + { + WriteText(15, y, 0x81, 0xFF0000, itoa(count)); + y += 25; + } + count--; + } + +} diff --git a/programs/cmm/lib/array.h b/programs/cmm/lib/array.h index 84ca05b6e0..72a6b0710a 100644 --- a/programs/cmm/lib/array.h +++ b/programs/cmm/lib/array.h @@ -173,13 +173,13 @@ RETURN array.init(size); } -dword indexArray(dword address, key) +:dword indexArray(dword address, key) { - dword offset = key&11b; + dword offset = key&0x1FF; dword offsetAddress = offset*4+address; - IF (key==offset) RETURN 4*4+offsetAddress; - IF (!DSDWORD[offsetAddress]) DSDWORD[offsetAddress] = malloc(4*4*2); - RETURN indexArray(DSDWORD[offsetAddress], key>>2); + IF (key==offset) RETURN 4*0x200+offsetAddress; + IF (!DSDWORD[offsetAddress]) DSDWORD[offsetAddress] = malloc(0x1000); + RETURN indexArray(DSDWORD[offsetAddress], key>>9); } #endif