Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;  COLORREF.ASM - COLOR REFERENCE
2
;
3
;  Compile with FASM for Menuet
4
;
5
 
6
use32
7
         org  0x0
8
 
9
         db  'MENUET01'            ; 8 byte id
10
         dd   0x01                 ; header version
11
         dd   start                ; start of code
12
         dd   finis                ; size of image
108 heavyiron 13
         dd   0x1000               ; memory for app
14
         dd   0x1000               ; esp
31 halyavin 15
         dd   0x0,0x0              ; I_Param , I_Icon
16
 
17
include 'lang.inc'
18
wide:    dd   0                    ; screen pixels width
19
mouse:   dd   0                    ; 1=right,2=left [mouse click]
20
 
21
 
22
start:
23
 
24
    mov  eax,14                    ; get screen size
25
    int  0x40
26
    shr  eax,16                    ; get width into AX
27
    inc  eax                       ; not 0 based
28
    mov  [wide],eax
29
 
30
    call draw_window
31
 
32
still:
33
    mov  eax,23                    ; wait for event w/timeout
34
    mov  ebx,5                     ; delay in hundredths
35
    int  0x40
36
 
37
    cmp  eax,1                     ; redraw request ?
38
    jne  s1
39
    jmp  red
40
s1: cmp  eax,2                     ; key in buffer ?
41
    jne  s2
42
    jmp  key
43
s2: cmp  eax,3                     ; button in buffer ?
44
    jne  s3
45
    jmp   button
46
s3: mov  eax,9                     ; process info function
47
    mov  ebx,stat_table            ; return data table
48
    mov  ecx,-1                    ; who am i
49
    int  0x40
50
    cmp  ax,[stat_table+4]         ; are we active?
51
    je   active                    ; yep
52
    jmp  still
53
 
54
  active:
55
    mov  eax,37                    ; mouse info function
56
    mov  ebx,2                     ; get buttons
57
    int  0x40
58
    cmp  eax,0                     ; mouse click?
59
    jne  click
60
    jmp  still
61
  click:
62
    mov  [mouse],eax               ; save mouse click
63
    mov  eax,37                    ; mouse info
64
    xor  ebx,ebx                   ; get screen pos for mouse
65
    int  0x40                      ; into EAX
66
    xor  ebx,ebx
67
    mov  bx,ax                     ; BX=y screen position
68
    shr  eax,16                    ; AX=x screen position
69
    xchg eax,ebx                   ; EAX=y, EBX=x
70
    dec  eax                       ; don't calc mouse scanline
71
    mov  ecx,[wide]                ; get pixels wide
72
    mul  ecx
73
    add  ebx,eax                   ; add x
74
    mov  eax,35                    ; get mouse pos pixel
75
    int  0x40                      ; EAX=mouse pixel color
76
    mov  ebx,eax                   ; EBX has color
77
    mov  esi,colors                ; color table
78
    mov  ecx,72                    ; total colors
79
    xor  edx,edx                   ; init a counter
80
  check:
81
    lodsd
82
    inc  edx                       ; update counter
83
    cmp  ebx,eax                   ; color match?
84
    je   _match                     ; yep
85
    loop check                     ; check all colors
86
    jmp still                      ; no match
87
  _match:
88
    cmp  [mouse],dword 1           ; right click?
89
    je   right                     ; yep
90
  left:
91
    cmp  [picks],edx               ; changed left color yet?
92
    jne  l1                        ; no, do it
93
    jmp  still
94
l1: mov  [picks],edx               ; update left pick color
95
    call clear                     ; erase old text
96
    call draw_picks                ; redraw colors and text
97
    jmp  still
98
  right:
99
    cmp  [picks+4],edx             ; changed right color yet?
100
    jne  r1                        ; no, do it
101
    jmp  still
102
r1: mov  [picks+4],edx             ; update right pick color
103
    call clear                     ; erase old text
104
    call draw_picks                ; redraw colors and text
105
    jmp  still
106
 
107
  red:                             ; redraw
108
    call draw_window
109
    jmp  still
110
 
111
  key:                             ; key
112
    mov  eax,2                     ; just read it and ignore
113
    int  0x40
114
    cmp  al,0                      ; key in buffer?
115
    je   k1                        ; yep
116
    jmp  still
117
k1: cmp  ah,'H'                    ; cap H ?
118
    je   k2                        ; yep
119
    cmp  ah,'h'                    ; locase h ?
120
    je   k2                        ; yep
121
    jmp  still
122
k2: call help                      ; show help screen
123
    jmp  still
124
 
125
  button:                          ; button
126
    mov  eax,17                    ; get id
127
    int  0x40
128
    cmp  ah,1                      ; button id=1 ?
129
    je   close
130
    jmp  still
131
 
132
  close:
133
    mov  eax,-1                    ; close this program
134
    int  0x40
135
 
136
 
137
;   *********************************************
138
;   *******  WINDOW DEFINITIONS AND DRAW ********
139
;   *********************************************
140
 
141
 
142
draw_window:
143
 
144
    mov  eax,12                    ; tell os about windowdraw
145
    mov  ebx,1                     ; 1, start of draw
146
    int  0x40
147
 
148
    mov  eax,0                     ; DRAW WINDOW
149
    mov  ebx,1*65536+200           ; [x start] *65536 + [x size]
150
    mov  ecx,200*65536+240         ; [y start] *65536 + [y size]
316 heavyiron 151
    mov  edx,0x13000000            ; work area color (type II)
152
    mov  edi,header                ; frame color
31 halyavin 153
    int  0x40
108 heavyiron 154
 
31 halyavin 155
    call palette                   ; display color palette
156
 
157
    mov  eax,12                    ; tell os about windowdraw
158
    mov  ebx,2                     ; 2, end of draw
159
    int  0x40
160
 
161
    ret
162
 
163
 
164
;   *********************************************
165
;   *******  COLOR PALETTE LAYOUT ROUTINES ******
166
;   *********************************************
167
 
168
 
169
palette:
170
    mov  ebx,15*65536+18           ; LAYOUT: start x and width
171
    mov  edx,32*65536+18           ; LAYOUT: start y and depth
172
    mov  ecx,8                     ; 8 rows
173
    mov  ebp,colors                ; color table
174
p1: push ecx
175
    mov  ecx,9                     ; 9 columns
176
p2: push ecx
177
    push edx
178
    mov  ecx,edx                   ; y coord
179
    mov  edx,[ebp]                 ; color
180
    mov  eax,13                    ; draw bar function
181
    int  0x40
182
    pop  edx
183
    pop  ecx
184
    add  ebx,19*65536              ; next column
185
    add  ebp,4                     ; next color
186
p3: loop p2
187
    pop  ecx
188
    mov  ebx,15*65536+18           ; restart x
189
    add  edx,19*65536              ; next row
190
    loop p1
191
    call draw_picks
192
 
193
    ret
194
 
195
draw_picks:
196
    mov  ebx,64*65536+24           ; draw x and width
197
    mov  ecx,188*65536+42          ; draw y and depth
198
    mov  edx,0xc0c0c0              ; color grey
199
    mov  eax,13                    ; draw bar function
200
    int  0x40
201
    mov  eax,[picks]               ; first picked color
202
    mov  esi,22*65536+196          ; print at x and y
203
    call do_hex                    ; print color number
204
    mov  eax,[picks+4]             ; second picked color
205
    mov  esi,22*65536+215          ; print at x and y
206
    call do_hex                    ; print color number
207
    mov  eax,[picks]               ; first picked color
208
    mov  ebx,67*65536+18           ; x and width
209
    mov  esi,191*65536+18          ; y and depth
210
    call do_color                  ; paint color 1 square
211
    mov  eax,[picks+4]             ; second picked color
212
    mov  ebx,67*65536+18           ; x and width
213
    mov  esi,209*65536+18          ; y and depth
214
    call do_color                  ; paint color 2 square
215
    mov  eax,[picks]               ; first picked color
216
    mov  ebx,96*65536+196          ; x and y
217
    call do_name                   ; print color's name
218
    mov  eax,[picks+4]             ; second picked color
219
    mov  ebx,96*65536+215          ; x and y
220
    call do_name                   ; print color's name
221
 
222
    ret
223
 
224
do_hex:
225
    dec  eax                       ; use 0 base
226
    mov  ecx,4                     ; dword length
227
    mul  ecx                       ; calc pointer
228
    mov  edi,colors                ; color table
229
    add  edi,eax                   ; add offset
230
    mov  ecx,[edi]                 ; save color 1
231
    mov  ebx,0x60100               ; print 6 hex digits
232
    mov  edx,esi                   ; copy color
233
    mov  esi,0xe1e1e1              ; use white
234
    mov  eax,47                    ; print number function
235
    int  0x40
236
 
237
    ret
238
 
239
do_color:
240
    dec  eax                       ; use 0 base
241
    mov  ecx,4                     ; dword length
242
    mul  ecx                       ; calc pointer
243
    mov  edi,colors                ; color table
244
    add  edi,eax                   ; add offset
245
    mov  edx,[edi]                 ; color
246
    mov  ecx,esi                   ; recover y an depth
247
    mov  eax,13                    ; draw bar function
248
    int  0x40
249
 
250
    ret
251
 
252
do_name:
253
    dec  eax                       ; use 0 base
254
    mov  ecx,15                    ; string length
255
    mul  ecx                       ; calc pointer
256
    mov  edx,names                 ; color table
257
    add  edx,eax                   ; add offset
258
    mov  ecx,0xe1e1e1              ; color
259
    mov  esi,15
260
    mov  eax,4                     ; print text function
261
    int  0x40
262
 
263
    ret
264
 
265
clear:
266
    mov  ebx,22*65536+36           ; x and width
267
    mov  ecx,196*65536+26          ; y and depth
268
    mov  edx,0x000000              ; color
269
    mov  eax,13                    ; draw bar funx
270
    int  0x40
271
    mov  ebx,96*65536+90           ; x and width
272
    mov  ecx,196*65536+26          ; y and depth
273
    mov  edx,0x000000              ; color
274
    mov  eax,13                    ; draw bar funx
275
    int  0x40
276
 
277
    ret
278
 
279
help:
280
    mov  ebx,4*65536+192           ; x and width
281
    mov  ecx,20*65536+216          ; y and depth
282
    mov  edx,0x465e8f              ; dark denim color
283
    mov  eax,13                    ; write text funx
284
    int  0x40
285
    mov  ebx,20*65536+40           ; starting x and y
286
    mov  edx,text                  ; start of text
287
    mov  esi,27                    ; width of text
288
    mov  ecx,14                    ; 14 text lines to do
289
    mov  eax,4                     ; write text funx
290
h1: push ecx
291
    sub  ebx,65537                 ; drop shadow x and y
292
    mov  ecx,0x000000              ; black shadow
293
    int  0x40
294
    add  ebx,65537                 ; original x and y
295
    mov  ecx,0xefefef              ; white text
296
    int  0x40
297
    add  edx,27                    ; next line of text
298
    add  bx,12                     ; next row
299
    pop  ecx
300
    loop h1
301
    mov  eax,10                    ; wait on event
302
    int  0x40
303
    cmp  eax,2                     ; got a key?
304
    jne  h2                        ; nope
305
    mov  eax,2                     ; yep, burn it
306
    int  0x40
307
h2: mov  ebx,4*65536+192           ; y and width
308
    mov  ecx,20*65536+216          ; x and depth
309
    mov  edx,0x00000               ; restore black bkg
310
    mov  eax,13                    ; draw bar funx
311
    int  0x40
312
    call palette                   ; redraw color palette
313
 
314
    ret
315
 
316
 
317
;   *********************************************
318
;   **********  DATA DEFINITIONS AREA ***********
319
;   *********************************************
320
 
316 heavyiron 321
header    db   'COLOR REFERENCE H>HELP',0
31 halyavin 322
 
323
picks:
324
    dd   31,2           ; selected top/bot colors
325
 
326
colors:
327
    dd   0xe0e0e0       ; white
328
    dd   0xe7e6a0       ; pale yellow
329
    dd   0xe7e05a       ; lemon yellow
330
    dd   0xe7c750       ; mustard
331
    dd   0xe7b850       ; cadium yellow
332
    dd   0xbfa461       ; yellow ocre
333
    dd   0xe0c090       ; cream
334
    dd   0xe0b27b       ; peach
335
    dd   0xe2986d       ; dark peach
336
    dd   0xebb2c0       ; pink
337
    dd   0xe0b0a0       ; flesh
338
    dd   0xc79790       ; artificial arm
339
    dd   0xb88688       ; deep blush
340
    dd   0xc4a077       ; washed khaki
341
    dd   0xb69269       ; khaki
342
    dd   0xa8845b       ; dark khaki
343
    dd   0xab937a       ; beige
344
    dd   0xa39370       ; poupon
345
    dd   0x988c00       ; camouflage
346
    dd   0x98a024       ; pale olive
347
    dd   0x838b00       ; olive
348
    dd   0x6d7600       ; dark olive
349
    dd   0x5b6200       ; black olive
350
    dd   0x94946a       ; washed army
351
    dd   0x74744a       ; army
352
    dd   0x66a696       ; pale teal
353
    dd   0x409b90       ; faded teal
354
    dd   0x008d8d       ; pastel teal
355
    dd   0x007c7c       ; teal
356
    dd   0x006464       ; dark teal
357
    dd   0x00b8ca       ; light turquoise
358
    dd   0x00a0b2       ; turquoise
359
    dd   0x00889a       ; dark turquoise
360
    dd   0x575f8c       ; medium cobalt
361
    dd   0x4e4e7c       ; cobalt
362
    dd   0x00459a       ; ultramarine
363
    dd   0x400088       ; navy blue
364
    dd   0x4e00e7       ; true blue
365
    dd   0x508cec       ; sky blue
366
    dd   0x6a73d0       ; mountain blue
367
    dd   0x677ab0       ; faded jeans
368
    dd   0x576fa0       ; denim
369
    dd   0xd048c8       ; fuschia
370
    dd   0xb800e7       ; lavendar
371
    dd   0xa800a8       ; light violet
372
    dd   0x780078       ; violet
373
    dd   0x520064       ; purple
374
    dd   0xb800b8       ; magenta
375
    dd   0xa4307a       ; rose
376
    dd   0x90207f       ; mauve
377
    dd   0xe76e83       ; salmon
378
    dd   0xea7a7d       ; pastel orange
379
    dd   0xe26830       ; orange
380
    dd   0xac5800       ; burnt sienna
381
    dd   0xcc0000       ; red orange
382
    dd   0xac0000       ; cadium red
383
    dd   0x880040       ; brick red
384
    dd   0x780000       ; rust
385
    dd   0x683020       ; terra cotta
386
    dd   0x7f4658       ; light maroon
387
    dd   0x702050       ; maroon
388
    dd   0x7a5b5f       ; umber blush
389
    dd   0x584838       ; burnt umber
390
    dd   0x8a5d1a       ; cigar brown
391
    dd   0x64504a       ; ice brown
392
    dd   0x564242       ; dark chocolate
393
    dd   0x00aa66       ; celery stalk
394
    dd   0x107a30       ; forest green
395
    dd   0x365800       ; hooker's green
396
    dd   0x8beb88       ; pastel lime
397
    dd   0x7bbb64       ; lime
398
    dd   0x4ba010       ; dark lime
399
 
400
names:
401
    db   'WHITE          '
402
    db   'PALE YELLOW    '
403
    db   'LEMON YELLOW   '
404
    db   'MUSTARD        '
405
    db   'CADIUM YELLOW  '
406
    db   'YELLOW OCRE    '
407
    db   'CREAM          '
408
    db   'PEACH          '
409
    db   'DARK PEACH     '
410
    db   'PINK           '
411
    db   'FLESH          '
412
    db   'ARTIFICIAL ARM '
413
    db   'DEEP BLUSH     '
414
    db   'WASHED KHAKI   '
415
    db   'KHAKI          '
416
    db   'DARK KHAKI     '
417
    db   'BEIGE          '
418
    db   'POUPON         '
419
    db   'CAMOUFLAGE     '
420
    db   'PALE OLIVE     '
421
    db   'OLIVE          '
422
    db   'DARK OLIVE     '
423
    db   'BLACK OLIVE    '
424
    db   'WASHED ARMY    '
425
    db   'ARMY           '
426
    db   'PALE TEAL      '
427
    db   'FADED TEAL     '
428
    db   'PASTEL TEAL    '
429
    db   'TEAL           '
430
    db   'DARK TEAL      '
431
    db   'LIGHT TURQUOISE'
432
    db   'TURQUOISE      '
433
    db   'DARK TURQUOISE '
434
    db   'MEDIUM COBALT  '
435
    db   'COBALT         '
436
    db   'ULTRAMARINE    '
437
    db   'NAVY BLUE      '
438
    db   'TRUE BLUE      '
439
    db   'SKY BLUE       '
440
    db   'MOUNTAIN BLUE  '
441
    db   'FADED JEANS    '
442
    db   'DENIM          '
443
    db   'FUSHIA         '
444
    db   'LAVENDAR       '
445
    db   'LIGHT VIOLET   '
446
    db   'VIOLET         '
447
    db   'PURPLE         '
448
    db   'MAGENTA        '
449
    db   'ROSE           '
450
    db   'MAUVE          '
451
    db   'SALMON         '
452
    db   'PASTEL ORANGE  '
453
    db   'ORANGE         '
454
    db   'BURNT SIENNA   '
455
    db   'RED ORANGE     '
456
    db   'CADIUM RED     '
457
    db   'BRICK RED      '
458
    db   'RUST           '
459
    db   'TERRA COTTA    '
460
    db   'LIGHT MAROON   '
461
    db   'MAROON         '
462
    db   'UMBER BLUSH    '
463
    db   'BURNT UMBER    '
464
    db   'CIGAR BROWN    '
465
    db   'ICE BROWN      '
466
    db   'DARK CHOCOLATE '
467
    db   'CELERY STALK   '
468
    db   'FOREST GREEN   '
469
    db   "HOOKER'S GREEN "
470
    db   'PASTEL LIME    '
471
    db   'LIME           '
472
    db   'DARK LIME      '
473
 
474
 
475
text:
476
    db   'TO SEE HOW COLORS COMPARE  '
477
    db   'TO ONE ANOTHER, LEFT CLICK '
478
    db   'THE FIRST COLOR AND RIGHT  '
479
    db   'CLICK THE SECOND. TO GET   '
480
    db   "A SENSE OF A COLOR'S TRUE  "
481
    db   'HUE, RIGHT AND LEFT CLICK  '
482
    db   'THE SAME COLOR TO SEE IT   '
483
    db   'ON THE NEUTRAL BACKGROUND. '
484
    db   'TO USE A LIGHTER OR DARKER '
485
    db   'VALUE OF A COLOR, ADD OR   '
486
    db   'SUBTRACT 0x10 OR 0x20 FROM '
487
    db   'EACH BYTE OF ITS HEX VALUE.'
488
    db   '                           '
489
    db   '       ANY KEY ...         '
490
 
491
stat_table:
492
 
493
 
494
finis: