Subversion Repositories Kolibri OS

Rev

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

Rev 551 Rev 1446
Line 1... Line -...
1
;
-
 
2
;   Memory Blocks for Menuet v0.1
-
 
3
;   Crown Soft (c) crown_s@rambler.ru
-
 
4
;
-
 
5
;   Compile with FASM for Menuet
-
 
6
;
-
 
7
 
-
 
8
use32
1
use32
-
 
2
	db	'MENUET01'
-
 
3
	dd	1
-
 
4
	dd	start
-
 
5
	dd	i_end
-
 
6
	dd	mem
-
 
7
	dd	mem
-
 
8
	dd	0
-
 
9
	dd	0
-
 
10
 
-
 
11
; field size in items
-
 
12
FieldWidth = 10
-
 
13
FieldHeight = 6
-
 
14
 
-
 
15
; size of one picture in pixels
-
 
16
ImageWidth = 32
-
 
17
ImageHeight = 32
-
 
18
 
-
 
19
; size of one button in pixels
-
 
20
ButtonWidth = ImageWidth + 6
-
 
21
ButtonHeight = ImageHeight + 6
-
 
22
 
-
 
23
SpaceWidth = ButtonWidth + 4
-
 
24
SpaceHeight = ButtonHeight + 4
-
 
25
 
-
 
26
; size of window in pixels
-
 
27
WindowWidth = 434
-
 
28
WindowHeight = 291	; excluding skin height
-
 
29
 
-
 
30
if FieldWidth*FieldHeight mod 2
-
 
31
error field size must be an even number!
-
 
32
end if
-
 
33
 
-
 
34
draw_frame:
-
 
35
; in: ebx=[xstart]*65536+[xsize],ecx=[ystart]*65536+[ysize],edx=color
-
 
36
;	ystart is relative to SkinHeight
-
 
37
; out: nothing
-
 
38
; destroys: eax,ecx
-
 
39
	push	13
-
 
40
	pop	eax
-
 
41
	ror	ecx, 16
-
 
42
	add	ecx, [SkinHeight]
-
 
43
	push	ecx
-
 
44
	shl	ecx, 16
-
 
45
	inc	ecx
-
 
46
	int	0x40	; ebx=[xstart]*65536+[xsize], ecx=[ystart]*65536+1
-
 
47
	ror	ecx, 16
-
 
48
	add	cx, [esp+2]
-
 
49
	ror	ecx, 16
-
 
50
	int	0x40	; ebx=[xstart]*65536+[xsize], ecx=([ystart]+[ysize])*65536+1
-
 
51
	pop	ecx
-
 
52
	ror	ecx, 16
-
 
53
	push	ebx
-
 
54
	mov	bx, 1
-
 
55
	int	0x40	; ebx=[xstart]*65536+1, ecx=[ystart]*65536+[ysize]
-
 
56
	ror	ebx, 16
-
 
57
	add	bx, [esp]
-
 
58
	ror	ebx, 16
-
 
59
	inc	ecx
-
 
60
	int	0x40	; ebx=([xstart]+[xsize])*65536+1, ecx=[ystart]*65536+([ysize]+1)
-
 
61
	dec	ecx
-
 
62
	pop	ebx
-
 
63
	ret
-
 
64
 
-
 
65
draw_button:
-
 
66
; in: ebx=[xstart]*65536+[xsize],ecx=[ystart]*65536+[ysize],edx=button color,esi=id
-
 
67
;	ystart is relative to SkinHeight
-
 
68
; out: nothing
-
 
69
; destroys: eax
-
 
70
	push	edx
-
 
71
	mov	edx, 0x94AECE
-
 
72
	call	draw_frame
-
 
73
	mov	edx, 0xFFFFFF
-
 
74
	push	ebx
-
 
75
	add	ebx, 0xFFFF
-
 
76
	push	ecx
-
 
77
	add	ecx, 0x10000
-
 
78
	mov	cx, 1
-
 
79
	int	0x40	; ebx=([xstart]+1)*65536+([xsize]-1), ecx=([ystart]+1)*65536+1
-
 
80
	pop	ecx
-
 
81
	mov	edx, 0xC0C0C0
-
 
82
	dec	ebx
-
 
83
	push	ecx
-
 
84
	shr	ecx, 16
-
 
85
	add	ecx, [esp]
-
 
86
	dec	ecx
-
 
87
	shl	ecx, 16
-
 
88
	inc	ecx
-
 
89
	int	0x40	; ebx=([xstart]+1)*65536+([xsize]-2), ecx=([ystart]+[ysize]-1)*65536+1
-
 
90
	pop	ecx
-
 
91
	mov	edx, 0xFFFFFF
-
 
92
	push	ecx
-
 
93
	add	ecx, 0xFFFF
-
 
94
	push	ebx
-
 
95
	mov	bx, 1
-
 
96
	int	0x40	; ebx=([xstart]+1)*65536+1, ecx=([ystart]+1)*65536+([ysize]-1)
-
 
97
	pop	ebx
-
 
98
	push	ebx
-
 
99
	shr	ebx, 16
-
 
100
	add	ebx, [esp]
-
 
101
	shl	ebx, 16
-
 
102
	inc	ebx
-
 
103
	mov	edx, 0xC0C0C0
-
 
104
	add	ecx, 0xFFFF
-
 
105
	int	0x40	; ebx=([xstart]+[xsize]-1)*65536+1, ecx=([ystart]+2)*65536+([ysize]-2)
-
 
106
	pop	ebx
-
 
107
	pop	ecx
-
 
108
	pop	ebx
-
 
109
	pop	edx
-
 
110
	push	ebx ecx
-
 
111
	add	ebx, 20000h - 3
-
 
112
	add	ecx, 20000h - 3
-
 
113
	int	0x40
-
 
114
	pop	ecx ebx
-
 
115
	push	edx
-
 
116
	mov	edx, esi
-
 
117
	or	edx, 0x80000000
-
 
118
	mov	al, 8
-
 
119
	int	0x40
-
 
120
	mov	edx, esi
-
 
121
	or	edx, 0x40000000
-
 
122
	int	0x40
-
 
123
	pop	edx
-
 
124
	ret
-
 
125
 
-
 
126
;digits_ptr	dd	0
-
 
127
;digits_str	rb	11
-
 
128
 
-
 
129
;images:
-
 
130
;	file	'mblocks.raw'
-
 
131
images:
-
 
132
	file	'mblocksi.raw'
-
 
133
palette:
-
 
134
	file	'mblocksp.raw'
-
 
135
 
-
 
136
aNewGame_ru	db	'®¢ ï ¨£à (F2)',0
-
 
137
aCount_ru	db	' ‘ç¥â:',0
-
 
138
aRu		db	'RU',0
-
 
139
aNewGame_en	db	'New  game (F2)',0
-
 
140
aCount_en	db	'Count:',0
-
 
141
aEn		db	'EN',0
-
 
142
 
-
 
143
CurLanguage	db	0	; 0=russian, 1=english
-
 
144
 
-
 
145
field_status	rb	60	; status of field elements: 0=closed, 1=temporarily opened, 2=permanently opened
-
 
146
field_items	rb	60	; items in field
-
 
147
 
-
 
148
count		dd	0
-
 
149
 
-
 
150
start:
-
 
151
	push	26
-
 
152
	pop	eax
-
 
153
	push	5
-
 
154
	pop	ebx
-
 
155
	int	0x40
-
 
156
	cmp	eax, 4
-
 
157
	setnz	[CurLanguage]
-
 
158
	call	generate
-
 
159
; get skin height
-
 
160
	push	48
-
 
161
	pop	eax
-
 
162
	push	4
-
 
163
	pop	ebx
-
 
164
	int	0x40
-
 
165
	mov	[SkinHeight], eax
-
 
166
; no previous click
-
 
167
	mov	eax, 0xBAD
-
 
168
	mov	[FirstClick], eax
-
 
169
	mov	[SecondClick], eax
-
 
170
; draw window
-
 
171
redraw:
-
 
172
	call	draw_window
-
 
173
; events loop
-
 
174
evloop:
-
 
175
	push	10
-
 
176
	pop	eax
-
 
177
	int	0x40
-
 
178
	dec	eax
-
 
179
	jz	redraw
-
 
180
	dec	eax
-
 
181
	jz	key
-
 
182
	mov	al, 17
-
 
183
	int	0x40
-
 
184
	shr	eax, 8
-
 
185
;	cmp	eax, 6
-
 
186
;	jz	set_lang
-
 
187
	cmp	eax, 5
-
 
188
	jz	new_game
-
 
189
	cmp	eax, 1
-
 
190
	jnz	field_pressed
-
 
191
	push	-1
-
 
192
	pop	eax
-
 
193
	int	0x40
-
 
194
key:
-
 
195
	mov	al, 2
-
 
196
	int	0x40
-
 
197
	cmp	ah, '3'		; F2?
-
 
198
	jnz	evloop
-
 
199
new_game:
-
 
200
	mov	edi, field_status
-
 
201
	mov	ecx, FieldWidth*FieldHeight/2
-
 
202
	xor	eax, eax
-
 
203
	rep	stosd
-
 
204
	mov	[count], eax
-
 
205
	mov	eax, 0xBAD
-
 
206
	mov	[FirstClick], eax
-
 
207
	mov	[SecondClick], eax
-
 
208
	call	generate
-
 
209
	call	draw_field
-
 
210
@@:
-
 
211
	call	draw_aux
-
 
212
	jmp	evloop
-
 
213
;set_lang:
-
 
214
;	xor	[CurLanguage], 1
-
 
215
;	jmp	@b
-
 
216
field_pressed:
-
 
217
	sub	eax, 100
-
 
218
	cmp	[field_status+eax], 0
-
 
219
	jnz	cont
-
 
220
	mov	ebx, [FirstClick]
-
 
221
	mov	ecx, [SecondClick]
-
 
222
	cmp	ebx, 0xBAD
-
 
223
	jz	first_click
-
 
224
	cmp	ecx, 0xBAD
-
 
225
	jz	second_click
-
 
226
	mov	dl, [field_items+ecx]
-
 
227
	cmp	[field_items+ebx], dl
-
 
228
	jnz	dont_match
-
 
229
	mov	[field_status+ebx], 2
-
 
230
	mov	[field_status+ecx], 2
-
 
231
	jmp	@f
-
 
232
dont_match:
-
 
233
	mov	[field_status+ebx], 0
-
 
234
	mov	[field_status+ecx], 0
-
 
235
@@:
-
 
236
	push	eax ecx
-
 
237
	mov	eax, ebx
-
 
238
	call	draw_field_item
-
 
239
	pop	eax
-
 
240
	call	draw_field_item
-
 
241
	mov	[SecondClick], 0xBAD
-
 
242
	pop	eax
-
 
243
	mov	[FirstClick], eax
-
 
244
	jmp	@f
-
 
245
second_click:
-
 
246
	cmp	[FirstClick], eax
-
 
247
	jz	cont
-
 
248
	mov	[SecondClick], eax
-
 
249
@@:
-
 
250
	mov	[field_status+eax], 1
-
 
251
	call	draw_field_item
-
 
252
	inc	[count]
-
 
253
cont:
-
 
254
	call	draw_count
-
 
255
	jmp	evloop
-
 
256
first_click:
-
 
257
	mov	[FirstClick], eax
-
 
258
	jmp	@b
Line 9... Line -...
9
 
-
 
10
               org    0x0
-
 
11
 
-
 
12
               db     'MENUET01'              ; 8 byte id
-
 
13
               dd     0x01                    ; header version
-
 
14
               dd     START                   ; start of code
-
 
15
               dd     I_END                   ; size of image
-
 
16
               dd     0x4000                  ; memory for app
-
 
17
               dd     0x4000                  ; esp
-
 
18
               dd     0x0 , 0x0               ; I_Param , I_Icon
-
 
19
 
-
 
20
include '..\..\..\macros.inc'
-
 
21
 
-
 
22
title  db   'Memory Blocks for Menuet v0.1  Crown Soft (c)',0
-
 
23
 
-
 
24
 
-
 
25
START:                          ; start of execution
-
 
26
    call initpict
-
 
27
 
-
 
28
still:
-
 
29
    mov  eax,10                 ; wait here for event
-
 
30
    mcall
-
 
31
 
-
 
32
    cmp  eax,1                  ; redraw request ?
-
 
33
    je   red
-
 
34
    cmp  eax,2                  ; key in buffer ?
-
 
35
    je   key
-
 
36
    cmp  eax,3                  ; button in buffer ?
-
 
37
    je   button
-
 
38
jmp  still
-
 
39
 
-
 
40
  red:                          ; redraw
-
 
41
    call draw_window
-
 
42
  jmp  still
-
 
43
 
-
 
44
  key:                          ; key
-
 
45
    mov  eax,2                  ; just read it and ignore
-
 
46
    mcall
-
 
47
  jmp  still
-
 
48
 
-
 
49
  button:                       ; button
-
 
50
    mov  eax,17                 ; get id
-
 
51
    mcall
-
 
52
 
-
 
53
    cmp  ah,1                   ; button id=1 ?
-
 
54
    jz   close
-
 
55
 
-
 
56
    cmp  ah,100                 ; button id=100 ?
-
 
57
    jz   init
-
 
58
 
-
 
59
    movzx ebx,ah
-
 
60
 
-
 
61
    dec  bl
-
 
62
    dec  bl                     ; bl -number bitton
-
 
63
    mov  al,[bitstat+ebx*1]
-
 
64
    cmp  al,1                   ; is pictures on bitton?
-
 
65
    jz   still
-
 
66
 
-
 
67
    inc  [nkeydown]
-
 
68
 
-
 
69
    cmp  [firstbit],0xff
-
 
70
    jz   tofirst
-
 
71
 
-
 
72
    cmp  [secondbit],0xff
-
 
73
    jz   tosecond
-
 
74
 
-
 
75
 
-
 
76
    movzx  eax,[firstbit]
-
 
77
    mov  [bitstat+eax*1],0
-
 
78
 
-
 
79
    mov  al,[secondbit]
-
 
80
    mov  [bitstat+eax*1],0
-
 
81
 
-
 
82
    mov  [secondbit],0xff
-
 
83
 
-
 
84
 
-
 
85
  tofirst:
-
 
86
    mov  [firstbit],bl
-
 
87
    mov  [bitstat+ebx*1],1
-
 
88
    call draw_window
-
 
89
  jmp  still
-
 
90
 
-
 
91
  tosecond:
-
 
92
    mov  [secondbit],bl
-
 
93
    mov  [bitstat+ebx*1],1
-
 
94
 
-
 
95
    mov  al,[bitpict+ebx*1]
-
 
96
    mov  bl,[firstbit]          ; comply pictures on first bitton
-
 
97
    cmp  [bitpict+ebx*1],al     ;    with pictures on second
-
 
98
    jnz  tosm1
-
 
99
      mov [firstbit] ,0xff
-
 
100
      mov [secondbit],0xff
-
 
101
    tosm1:
-
 
102
 
-
 
103
    call draw_window
-
 
104
  jmp  still
-
 
105
 
-
 
106
  init:
-
 
107
    call initpict
-
 
108
  jmp still
-
 
109
 
-
 
110
  close:
-
 
111
    mov  eax,-1                 ; close program
-
 
112
    mcall
-
 
113
 
-
 
114
 
-
 
115
 
-
 
116
;======================================================================
-
 
117
;===============  WINDOW DEFINITIONS AND DRAW  ========================
-
 
118
;======================================================================
259