Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;   DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT
3
;
4
;   See f63
5
;
6
;   Compile with FASM for Menuet
7
;
8
 
9
include 'lang.inc'
10
include 'macros.inc'
11
 
12
   use32
13
   org    0x0
14
   db     'MENUET01'              ; 8 byte id
15
   dd     0x01                    ; header version
16
   dd     START                   ; start of code
17
   dd     I_END                   ; size of image
18
   dd     0x2000                  ; memory for app (4 Kb)
19
   dd     0x2000                  ; esp
20
   dd     0x0 , 0x0               ; I_Param , I_Icon
21
 
22
MAXSTRINGS = 16
23
 
24
xpos  dd 0x0
25
ypos  dd 0
26
 
27
 
28
START:                          ; start of execution
29
 
30
     mov  ecx,1024
31
    flush:
32
     mov  eax,63
33
     mov  ebx,2
34
     int  0x40
35
     loop flush
36
 
37
     mov  ecx, 80*(MAXSTRINGS+1)
38
     xor  eax, eax
39
     mov  edi, text
40
     rep  stosb
41
 
42
     mov  [tmp],'x'
43
 
44
     mov  eax,14
45
     int  0x40
46
     and  eax,0xffff0000
47
     sub  eax,400 shl 16
48
     add  eax,400
49
     mov  [xstart],eax
50
 
51
     call draw_window
52
 
53
still:
54
 
55
    mov  eax,23                 ; wait here for event
56
    mov  ebx,1
57
    int  0x40
58
 
59
    cmp  eax,1                  ; redraw request ?
60
    je   red
61
    cmp  eax,2                  ; key in buffer ?
62
    je   key
63
    cmp  eax,3                  ; button in buffer ?
64
    je   button
65
 
66
    mov  eax,63
67
    mov  ebx,2
68
    int  0x40
69
 
70
    cmp  ebx,1
71
    jne  still
72
 
73
  new_data:
74
 
75
    cmp  al,13
76
    jne  no13
77
    mov  [xpos],0
78
    jmp  new_check
79
   no13:
80
    cmp  al,10
81
    jne  no10
82
    inc  [ypos]
83
    cmp  [ypos],MAXSTRINGS
84
    jbe  noypos
85
    mov  [ypos],MAXSTRINGS
86
    mov  esi,text+80
87
    mov  edi,text
88
    mov  ecx,80*(MAXSTRINGS)
89
    cld
90
    rep  movsb
91
 
92
    mov  esi,[ypos]
93
    imul esi,80
94
    add  esi,[xpos]
95
    add  esi,text
96
    mov  ecx,80
97
    xor  al,al
98
    rep  stosb
99
  noypos:
100
    jmp  new_check
101
  no10:
102
 
103
    mov  esi,[ypos]
104
    imul esi,80
105
    add  esi,[xpos]
106
    mov  [text+esi],al
107
    inc  [xpos]
108
    cmp  [xpos],80
109
    jb   xposok
110
    mov  [xpos],79
111
  xposok:
112
 
113
  new_check:
114
 
115
    mov  eax,63
116
    mov  ebx,2
117
    int  0x40
118
 
119
    cmp  ebx,1
120
    je   new_data
121
 
122
    call draw_window
123
 
124
    jmp  still
125
 
126
 
127
  red:                          ; redraw
128
    call draw_window
129
    jmp  still
130
 
131
  key:                          ; key
132
    mov  eax,2                  ; just read it and ignore
133
    int  0x40
134
    jmp  still
135
 
136
  button:                       ; button
137
    mov  eax,17                 ; get id
138
    int  0x40
139
 
140
    cmp  ah,1                   ; button id=1 ?
141
    jne  noclose
142
 
143
    mov  eax,-1                 ; close this program
144
    int  0x40
145
  noclose:
146
 
147
    jmp  still
148
 
149
 
150
 
151
 
152
;   *********************************************
153
;   *******  WINDOW DEFINITIONS AND DRAW ********
154
;   *********************************************
155
 
156
 
157
draw_window:
158
 
159
    mov  eax,48
160
    mov  ebx,3
161
    mov  ecx,sc
162
    mov  edx,sizeof.system_colors
163
    int  0x40
164
 
165
    mov  eax,12                    ; function 12:tell os about windowdraw
166
    mov  ebx,1                     ; 1, start of draw
167
    int  0x40
168
 
169
                                   ; DRAW WINDOW
170
    mov  eax,0                     ; function 0 : define and draw window
171
;   mov  ebx,50*65536+400          ; [x start] *65536 + [x size]
172
    mov  ebx,[xstart]
173
    mov  ecx,MAXSTRINGS*10+40      ; [y start] *65536 + [y size]
174
    mov  edx,[sc.work]             ; color of work area RRGGBB,8->color gl
175
    or   edx,0x03000000
176
    int  0x40
177
 
178
                                   ; WINDOW LABEL
179
    mov  eax,4                     ; function 4 : write text to window
180
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
181
    mov  ecx,[sc.grab_text]        ; color of text RRGGBB
182
    or   ecx,0x10000000
183
    mov  edx,header                ; pointer to text beginning
184
    mov  esi,header.len            ; text length
185
    int  0x40
186
 
187
    mov  ebx,15*65536+33           ; draw info text with function 4
188
    mov  ecx,[sc.work_text]
189
    mov  edx,text
190
    mov  esi,80
191
  newline:
192
    mov  eax,4
193
    int  0x40
194
    add  ebx,10
195
    add  edx,80
196
    cmp  [edx],byte 'x'
197
    jne  newline
198
 
199
    mov  eax,12                    ; function 12:tell os about windowdraw
200
    mov  ebx,2                     ; 2, end of draw
201
    int  0x40
202
 
203
    ret
204
 
205
 
206
; DATA AREA
207
 
208
if lang eq ru
209
   header:
210
        db   '   '
211
    .len = $ - header
212
else
213
   header:
214
        db   'GENERAL DEBUG & MESSAGE BOARD'
215
    .len = $ - header
216
end if
217
I_END:
218
     text rb 80*(MAXSTRINGS+1)
219
     tmp  db ?
220
     xstart dd ?
221
     sc   system_colors