Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 132
Line 1... Line 1...
1
;
1
;
2
;    LIFE.ASM
2
;    LIFE.ASM
3
;
3
;
4
;    This program displays Conways game of life
4
;    This program displays Conways game of life
5
;
5
;
6
;    Compile with FASM v1.49 for DOS;
6
;    Compile with FASM for Menuet;
7
;
7
;
8
;    Version 0.1a   20th May   2004
-
 
9
;                   Ivan Poddubny
-
 
10
;
8
;
11
;    Version 0.1    30th March 2004
9
;    Version 0.1    30th March 2004
12
;                   Mike Hibbett
10
;                   Mike Hibbett
13
;
11
;
-
 
12
;    Version 0.2    23th May 2004
-
 
13
;                   Random generation dots with start
-
 
14
;
-
 
15
;    Convert to ASCL Libary by Pavlushin Evgeni
-
 
16
;
14
;    This is an experiment to see how small a usefull application can get
17
;    This is an experiment to see how small a usefull application can get
15
 
18
;
16
include "lang.inc"
-
 
17
include "macros.inc"
-
 
Line 18... Line 19...
18
 
19
 
19
  use32
20
use32
Line 20... Line 21...
20
  org     0x0
21
               org     0x0
21
 
22
 
22
  db     'MENUET01'              ; 8 byte id
23
               db     'MENUET01'              ; 8 byte id
23
  dd     0x01                    ; header version
24
               dd     0x01                    ; header version
24
  dd     START                   ; start of code
25
               dd     START                   ; start of code
25
  dd     I_END                   ; size of image
26
               dd     I_END                   ; size of image
26
  dd     0xc1000                  ; memory for app
27
               dd     0x100000                 ; memory for app
-
 
28
               dd     0x100000                ; esp
Line 27... Line -...
27
  dd     0xc1000                  ; esp
-
 
28
  dd     0x0 , 0x0               ; I_Param , I_Icon
29
               dd     0x0 , 0x0               ; I_Param , I_Icon
Line 29... Line 30...
29
 
30
include 'ascl.inc'
Line 30... Line 31...
30
;include "DEBUG.INC"
31
 
Line 40... Line 41...
40
    ; Life needs a seed pattern, which is 'hardcode' at compile time
41
    ; Life needs a seed pattern, which is 'hardcode' at compile time
41
    ; The grid is 512 wide (x direction) by 512 deep (y direction)
42
    ; The grid is 512 wide (x direction) by 512 deep (y direction)
42
    ; setcell take the arguments setcell x,y
43
    ; setcell take the arguments setcell x,y
43
    ; 0,0 is the top left corner.
44
    ; 0,0 is the top left corner.
Line 44... Line 45...
44
 
45
 
45
;    setcell 200,120
46
    setcell 200,120
46
;    setcell 201,120
47
    setcell 201,120
47
;    setcell 200,121
48
    setcell 200,121
48
;    setcell 199,121
49
    setcell 199,121
49
;    setcell 200,122
50
    setcell 200,122
50
 
51
 
51
;    setcell 70,120
52
    setcell 70,120
52
;    setcell 71,120
53
    setcell 71,120
53
;    setcell 70,121
54
    setcell 70,121
54
;    setcell 69,121
55
    setcell 69,121
55
;    setcell 70,122
-
 
56
 
-
 
57
    mov     eax, 40
-
 
58
    mov     ebx, 100101b
-
 
Line 59... Line 56...
59
    int     0x40
56
    setcell 70,122
Line 60... Line 57...
60
 
57
 
Line -... Line 58...
-
 
58
    call    draw_window
-
 
59
 
-
 
60
    ;Random generation dots
-
 
61
 
-
 
62
    mov ecx,20000
-
 
63
xxx:
-
 
64
    push ecx
61
    call    draw_window
65
    random 30000,edi     ;up pice of screen
62
 
66
    mov al,0xff
63
still:
67
    shl edi,3
-
 
68
;    mov [I_END+edi],al
-
 
69
;    random 50000,edi     ;down pice of screen
64
 
70
;    mov al,0xff
-
 
71
;    shl edi,3
65
;    mov  eax, 23                 ; wait here for event
72
    add edi,512*460 ;760
Line 66... Line -...
66
;    mov  ebx, 5
-
 
67
;    int  0x40
-
 
68
    mov  eax, 11
-
 
69
    int  0x40
73
    mov [I_END+edi],al
70
 
-
 
71
    test eax, eax
-
 
72
    je   nokey
-
 
73
    cmp  eax,1                  ; redraw request ?
-
 
Line -... Line 74...
-
 
74
    pop ecx
74
    je   red
75
    dec ecx
Line 75... Line -...
75
    cmp  eax,3                  ; button in buffer ?
-
 
76
    je   button
-
 
77
    cmp  eax,6
-
 
78
    je   mouse
-
 
79
 
-
 
80
    jmp  still
-
 
81
 
-
 
82
 
-
 
83
  mouse:
-
 
84
    mov  eax, 37
-
 
85
    mov  ebx, 2
-
 
86
    int  0x40
-
 
87
    test eax, eax
-
 
88
    jz   still
-
 
89
 
-
 
90
    mov  eax, 37
-
 
91
    mov  ebx, 1
-
 
92
    int  0x40
-
 
93
    sub  eax, 5*65536+20
-
 
94
    mov  ebx, eax
-
 
95
    shr  eax, 16
-
 
96
    and  ebx, 0xffff
-
 
97
 
-
 
98
; WRITE COORDINATES
-
 
99
;   dpd  eax
-
 
100
;   dps  "  "
-
 
101
;   dpd  ebx
-
 
102
;   dps  <10,13>
-
 
103
 
-
 
104
    cmp  ax, 0
-
 
105
    js   still
-
 
106
    cmp  bx, 0
-
 
107
    js   still
-
 
108
 
-
 
109
    shl  ebx, 9
76
    jnz xxx
110
    add  ebx, eax
77
 
111
    imul ebx, 3
78
still:
Line -... Line 79...
-
 
79
 
-
 
80
    timeevent 5,nokey,red,key,button    ;Wait EVENT with 5 fps
-
 
81
    jmp still
Line 112... Line 82...
112
    add  ebx, I_END
82
 
113
    mov  [ebx], dword 0xFFFFFFFF
-
 
Line 114... Line -...
114
    jmp  draw
-
 
115
 
83
red:                          ; REDRAW WINDOW
116
  red:                          ; REDRAW WINDOW
-
 
Line 117... Line 84...
117
    call draw_window
84
    call draw_window
Line 118... Line 85...
118
    jmp  still
85
    jmp  still
Line 185... Line 152...
185
    cmp     esi, I_END + 512*512*3
152
    cmp     esi, I_END + 512*512*3
186
    jne     lifeloop
153
    jne     lifeloop
Line 187... Line 154...
187
 
154
 
Line 188... Line -...
188
    ; copy new generation across
-
 
189
 
155
    ; copy new generation across
190
 
156
 
191
    mov     ecx, 512*512*3
157
    mov     ecx, 512*512*3
192
    mov     esi, I_END+1
158
    mov     esi, I_END+1
Line 197... Line 163...
197
    mov     esi, I_END
163
    mov     esi, I_END
198
nc1:
164
nc1:
199
    mov     [esi+2], byte 0
165
    mov     [esi+2], byte 0
200
    add     esi, 3
166
    add     esi, 3
201
    loop    nc1
167
    loop    nc1
202
draw:
168
 
203
    mov     ebx, I_END
169
    mov     ebx, I_END
204
    mov     ecx, 512*65536+512
170
    mov     ecx, 512*65536+512
205
    mov     edx, 5*65536+22
171
    mov     edx, 5*65536+20
206
    mov     eax,7
172
    mov     eax,7
207
    int     0x40
173
    int     0x40
Line 208... Line 174...
208
 
174
 
Line 209... Line 175...
209
    jmp  still
175
    jmp  still
210
 
-
 
211
button:                       ; BUTTON - only close supported
176
 
212
    or   eax,-1
-
 
213
    int  0x40
-
 
214
 
-
 
Line 215... Line 177...
215
 
177
button:                       ; BUTTON - only close supported
216
 
178
    close
217
 
179
 
218
;   *********************************************
-
 
219
;   *******  WINDOW DEFINITIONS AND DRAW ********
-
 
220
;   *********************************************
180
;   *********************************************
221
 
-
 
222
 
-
 
223
draw_window:
181
;   *******  WINDOW DEFINITIONS AND DRAW ********
224
    mov  eax,12
-
 
225
    mov  ebx,1
-
 
226
    int  0x40
-
 
227
 
182
;   *********************************************
228
    mov  eax,0                     ; open window
-
 
229
    mov  ebx,50*65536+512+9
-
 
230
    mov  ecx,50*65536+512+22+4
-
 
231
    mov  edx,0x03000000
183
draw_window:
232
    int  0x40
-
 
233
 
-
 
234
    mov  eax,4                     ; WINDOW LABEL
-
 
235
    mov  ebx,8*65536+8
-
 
236
    mov  ecx,0x10ffffff
184
    startwd
237
    mov  edx,header
-
 
238
    mov  esi,header.size
-
 
239
    int  0x40
-
 
240
 
-
 
241
    mov     eax,12                    ; function 12:tell os about windowdraw
-
 
242
    mov     ebx,2                     ; 2, end of draw
185
    window 50,50,512+9,512+23,window_Skinned
Line 243... Line -...
243
    int     0x40
-
 
244
 
-
 
245
    ret
-
 
246
 
-
 
247
 
-
 
248
 
-
 
249
; DATA AREA
-
 
250
 
186
    label  8,8,'Life Screen',cl_White+font_Big