├── blkdev
├── cdrom.inc
├── fdc.inc
├── flp_drv.inc
├── rd.inc
└── rdsave.inc
├── boot
├── bootcode.inc
├── booteng.inc
├── bootru.inc
├── preboot.inc
├── rdload.inc
├── ru.inc
└── shutdown.inc
├── build_en.bat
├── build_ru.bat
├── bus
└── pci
│ ├── pci16.inc
│ └── pci32.inc
├── core
├── fpu.inc
├── mem.inc
├── memmanag.inc
├── newproce.inc
├── physmem.inc
├── sched.inc
├── sync.inc
├── sys32.inc
└── syscall.inc
├── detect
├── commouse.inc
├── dev_fd.inc
├── dev_hdcd.inc
├── disks.inc
└── sear_par.inc
├── fs
├── fat12.inc
├── fat32.inc
├── fs.inc
└── fs_phys.inc
├── gui
├── button.inc
├── event.inc
├── font.inc
├── mouse.inc
├── skincode.inc
├── skindata.inc
└── window.inc
├── hid
├── keyboard.inc
└── set_dtc.inc
├── kernel.asm
├── kernel16.inc
├── kernel32.inc
├── kglobals.inc
├── memmap.inc
├── network
├── eth_drv
│ ├── 3c59x.inc
│ ├── ethernet.inc
│ ├── i8255x.inc
│ ├── pcnet32.inc
│ ├── rtl8029.inc
│ ├── rtl8139.inc
│ └── sis900.inc
├── ip.inc
├── queue.inc
├── stack.inc
├── tcp.inc
└── udp.inc
├── sound
├── playnote.inc
└── sb16.inc
├── video
├── vesa12.inc
├── vesa20.inc
└── vga.inc
├── vmodeint.inc
└── vmodeld.inc
/blkdev/cdrom.inc:
--------------------------------------------------------------------------------
1 | sys_cd_audio:
2 |
3 | cmp word [cdbase],word 0
4 | jnz @f
5 | mov eax,1
6 | ret
7 | @@:
8 |
9 | ; eax=1 cdplay at ebx 0x00FFSSMM
10 | ; eax=2 get tracklist size of ecx to [ebx]
11 | ; eax=3 stop/pause playing
12 |
13 | cmp eax,1
14 | jnz nocdp
15 | call sys_cdplay
16 | ret
17 | nocdp:
18 |
19 | cmp eax,2
20 | jnz nocdtl
21 | mov edi,[0x3010]
22 | add edi,0x10
23 | add ebx,[edi]
24 | call sys_cdtracklist
25 | ret
26 | nocdtl:
27 |
28 | cmp eax,3
29 | jnz nocdpause
30 | call sys_cdpause
31 | ret
32 | nocdpause:
33 |
34 | mov eax,0xffffff01
35 | ret
36 |
37 |
38 |
39 | sys_cd_atapi_command:
40 |
41 | pushad
42 |
43 | mov dx,word [cdbase]
44 | add dx,6
45 | mov ax,word [cdid]
46 | out dx,al
47 | mov esi,10
48 | call delay_ms
49 | mov dx,word [cdbase]
50 | add dx,7
51 | in al,dx
52 | and al,0x80
53 | cmp al,0
54 | jnz res
55 | jmp cdl6
56 | res:
57 | mov dx,word [cdbase]
58 | add dx,7
59 | mov al,0x8
60 | out dx,al
61 | mov dx,word [cdbase]
62 | add dx,0x206
63 | mov al,0xe
64 | out dx,al
65 | mov esi,1
66 | call delay_ms
67 | mov dx,word [cdbase]
68 | add dx,0x206
69 | mov al,0x8
70 | out dx,al
71 | mov esi,30
72 | call delay_ms
73 | xor cx,cx
74 | cdl5:
75 | inc cx
76 | cmp cx,10
77 | jz cdl6
78 | mov dx,word [cdbase]
79 | add dx,7
80 | in al,dx
81 | and al,0x88
82 | cmp al,0x00
83 | jz cdl5
84 | mov esi,100
85 | call delay_ms
86 | jmp cdl5
87 | cdl6:
88 | mov dx,word [cdbase]
89 | add dx,4
90 | mov al,0
91 | out dx,al
92 | mov dx,word [cdbase]
93 | add dx,5
94 | mov al,0
95 | out dx,al
96 | mov dx,word [cdbase]
97 | add dx,7
98 | mov al,0xec
99 | out dx,al
100 | mov esi,5
101 | call delay_ms
102 | mov dx,word [cdbase]
103 | add dx,1
104 | mov al,0
105 | out dx,al
106 | add dx,1
107 | mov al,0
108 | out dx,al
109 | add dx,1
110 | mov al,0
111 | out dx,al
112 | add dx,1
113 | mov al,0
114 | out dx,al
115 | add dx,1
116 | mov al,128
117 | out dx,al
118 | add dx,2
119 | mov al,0xa0
120 | out dx,al
121 | xor cx,cx
122 | mov dx,word [cdbase]
123 | add dx,7
124 | cdl1:
125 | inc cx
126 | cmp cx,100
127 | jz cdl2
128 | in al,dx
129 | and ax,0x88
130 | cmp al,0x8
131 | jz cdl2
132 | mov esi,2
133 | call delay_ms
134 | jmp cdl1
135 | cdl2:
136 |
137 | popad
138 | ret
139 |
140 |
141 | sys_cdplay:
142 |
143 | mov ax,5
144 | push ax
145 | push ebx
146 | cdplay:
147 | call sys_cd_atapi_command
148 | cli
149 | mov dx,word [cdbase]
150 | mov ax,0x0047
151 | out dx,ax
152 | mov al,1
153 | mov ah,[esp+0] ; min xx
154 | out dx,ax
155 | mov ax,[esp+1] ; fr sec
156 | out dx,ax
157 | mov ax,256+99
158 | out dx,ax
159 | mov ax,0x0001
160 | out dx,ax
161 | mov ax,0x0000
162 | out dx,ax
163 | mov esi,10
164 | call delay_ms
165 | sti
166 | add dx,7
167 | in al,dx
168 | test al,1
169 | jz cdplayok
170 | mov ax,[esp+4]
171 | dec ax
172 | mov [esp+4],ax
173 | cmp ax,0
174 | jz cdplayfail
175 | jmp cdplay
176 | cdplayfail:
177 | cdplayok:
178 | pop ebx
179 | pop ax
180 | xor eax, eax
181 | ret
182 |
183 |
184 | sys_cdtracklist:
185 |
186 | push ebx
187 | tcdplay:
188 | call sys_cd_atapi_command
189 | mov dx,word [cdbase]
190 | mov ax,0x43+2*256
191 | out dx,ax
192 | mov ax,0x0
193 | out dx,ax
194 | mov ax,0x0
195 | out dx,ax
196 | mov ax,0x0
197 | out dx,ax
198 | mov ax,200
199 | out dx,ax
200 | mov ax,0x0
201 | out dx,ax
202 | in al,dx
203 | mov cx,1000
204 | mov dx,word [cdbase]
205 | add dx,7
206 | cld
207 | cdtrnwewait:
208 | mov esi,10
209 | call delay_ms
210 | in al,dx
211 | and al,128
212 | cmp al,0
213 | jz cdtrl1
214 | loop cdtrnwewait
215 | cdtrl1:
216 | ; read the result
217 | mov ecx,[esp+0]
218 | mov dx,word [cdbase]
219 | cdtrread:
220 | add dx,7
221 | in al,dx
222 | and al,8
223 | cmp al,8
224 | jnz cdtrdone
225 | sub dx,7
226 | in ax,dx
227 | mov [ecx],ax
228 | add ecx,2
229 | jmp cdtrread
230 | cdtrdone:
231 | pop ecx
232 | xor eax, eax
233 | ret
234 |
235 |
236 | sys_cdpause:
237 |
238 | call sys_cd_atapi_command
239 |
240 | mov dx,word [cdbase]
241 | mov ax,0x004B
242 | out dx,ax
243 | mov ax,0
244 | out dx,ax
245 | mov ax,0
246 | out dx,ax
247 | mov ax,0
248 | out dx,ax
249 | mov ax,0
250 | out dx,ax
251 | mov ax,0
252 | out dx,ax
253 |
254 | mov esi,10
255 | call delay_ms
256 | add dx,7
257 | in al,dx
258 |
259 | xor eax, eax
260 | ret
261 |
262 |
--------------------------------------------------------------------------------
/blkdev/fdc.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/blkdev/fdc.inc
--------------------------------------------------------------------------------
/blkdev/flp_drv.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/blkdev/flp_drv.inc
--------------------------------------------------------------------------------
/blkdev/rd.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; RAMDISK functions ;;
4 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;;
5 | ;; Addings by M.Lisovin ;;
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 |
8 |
9 | ramdisk_free_space:
10 | ;---------------------------------------------
11 | ;
12 | ; returns free space in edi
13 | ; rewr.by Mihasik
14 | ;---------------------------------------------
15 |
16 | push eax ebx ecx
17 |
18 | mov edi,0x280000 ;start of FAT
19 | xor ax,ax ;Free cluster=0x0000 in FAT
20 | xor ebx,ebx ;counter
21 | mov ecx,2847 ;2849 ;2849 clusters
22 | cld
23 | rdfs1:
24 | repne scasw
25 | jnz rdfs2 ;if last cluster not 0
26 | inc ebx
27 | jcxz rdfs2 ;if last cluster=0
28 | jmp rdfs1 ;if not last
29 | rdfs2:
30 | shl ebx,9 ;free clusters*512
31 | mov edi,ebx
32 |
33 | pop ecx ebx eax
34 | ret
35 |
36 |
37 | expand_filename:
38 | ;---------------------------------------------
39 | ;
40 | ; exapand filename with '.' to 11 character
41 | ; eax - pointer to filename
42 | ;---------------------------------------------
43 |
44 | push esi edi ebx
45 |
46 | mov edi,esp ; check for '.' in the name
47 | add edi,12+8
48 |
49 | mov esi,eax
50 |
51 | mov eax,edi
52 | mov [eax+0],dword ' '
53 | mov [eax+4],dword ' '
54 | mov [eax+8],dword ' '
55 |
56 | flr1:
57 |
58 | cmp [esi],byte '.'
59 | jne flr2
60 | mov edi,eax
61 | add edi,7
62 | jmp flr3
63 |
64 | flr2:
65 |
66 | mov bl,[esi]
67 | mov [edi],bl
68 |
69 | flr3:
70 |
71 | inc esi
72 | inc edi
73 |
74 | mov ebx,eax
75 | add ebx,11
76 |
77 | cmp edi,ebx
78 | jbe flr1
79 |
80 | pop ebx edi esi
81 | ret
82 |
83 | fileread:
84 | ;----------------------------------------------------------------
85 | ;
86 | ; fileread - sys floppy
87 | ;
88 | ; eax points to filename 11 chars
89 | ; ebx first wanted block ; 1+ ; if 0 then set to 1
90 | ; ecx number of blocks to read ; 1+ ; if 0 then set to 1
91 | ; edx mem location to return data
92 | ; esi length of filename 12*X 0=root
93 | ;
94 | ; ret ebx = size or 0xffffffff file not found
95 | ; eax = 0 ok read or other = errormsg
96 | ;
97 | ;--------------------------------------------------------------
98 | test ebx,ebx ;if ebx=0 - set to 1
99 | jnz frfl5
100 | inc ebx
101 | frfl5:
102 | test ecx,ecx ;if ecx=0 - set to 1
103 | jnz frfl6
104 | inc ecx
105 | frfl6:
106 | test esi,esi ; return ramdisk root
107 | jnz fr_noroot ;if not root
108 | cmp ebx,14 ;14 clusters=root dir
109 | ja oorr
110 | cmp ecx,14
111 | ja oorr
112 | jmp fr_do
113 | oorr:
114 | mov eax,5 ;out of root range (fnf)
115 | xor ebx,ebx
116 | dec ebx ;0xffffffff
117 | ret
118 |
119 | fr_do: ;reading rootdir
120 | mov edi,edx
121 | dec ebx
122 | push edx
123 | mov edx,ecx
124 | add edx,ebx
125 | cmp edx,14 ;ebx+ecx=14
126 | pushf
127 | jbe fr_do1
128 | sub edx,14
129 | sub ecx,edx
130 | fr_do1:
131 | shl ebx,9
132 | mov esi,0x100000+512*19
133 | add esi,ebx
134 | shl ecx,7
135 | cld
136 | rep movsd
137 | popf
138 | pop edx
139 | ; jae fr_do2
140 | xor eax,eax ; ok read
141 | xor ebx,ebx
142 | ret
143 | fr_do2: ;if last cluster
144 | mov eax,6 ;end of file
145 | xor ebx,ebx
146 | ret
147 |
148 | fr_noroot:
149 |
150 | sub esp,32
151 | call expand_filename
152 |
153 | dec ebx
154 |
155 | push eax
156 |
157 | push eax ebx ecx edx esi edi
158 | call rd_findfile
159 | je fifound
160 | add esp,32+28 ;if file not found
161 | ret
162 |
163 | fifound:
164 |
165 | mov ebx,[edi-11+28] ;file size
166 | mov [esp+20],ebx
167 | mov [esp+24],ebx
168 | add edi,0xf
169 | movzx eax,word [edi]
170 | mov edi,eax ;edi=cluster
171 |
172 | frnew:
173 |
174 | add eax,31 ;bootsector+2*fat+filenames
175 | shl eax,9 ;*512
176 | add eax,0x100000 ;image base
177 | mov ebx,[esp+8]
178 | mov ecx,512 ;[esp+4]
179 |
180 | cmp [esp+16],dword 0 ; wanted cluster ?
181 | jne frfl7
182 | call memmove
183 | add [esp+8],dword 512
184 | dec dword [esp+12] ; last wanted cluster ?
185 | cmp [esp+12],dword 0
186 | je frnoread
187 | jmp frfl8
188 | frfl7:
189 | dec dword [esp+16]
190 | frfl8:
191 | shl edi,1 ;find next cluster from FAT
192 | add edi,0x280000
193 | movzx eax,word [edi]
194 | mov edi,eax
195 | cmp edi,4095 ;eof - cluster
196 | jz frnoread2
197 |
198 | cmp [esp+24],dword 512 ;eof - size
199 | jb frnoread
200 | sub [esp+24],dword 512
201 |
202 | jmp frnew
203 |
204 | frnoread2:
205 |
206 | cmp [esp+16],dword 0 ; eof without read ?
207 | je frnoread
208 |
209 | pop edi esi edx ecx
210 | add esp,4
211 | pop ebx ; ebx <- eax : size of file
212 | add esp,36
213 | mov eax,6 ; end of file
214 | ret
215 |
216 | frnoread:
217 |
218 | pop edi esi edx ecx
219 | add esp,4
220 | pop ebx ; ebx <- eax : size of file
221 | add esp,36
222 | xor eax,eax ;read ok
223 | ret
224 |
225 | filedelete:
226 | ;--------------------------------------------
227 | ;
228 | ; filedelete - sys floppy
229 | ; in:
230 | ; eax - pointer to filename 11 chars
231 | ;
232 | ; out:
233 | ; eax - 0 = successful, 5 = file not found
234 | ;
235 | ;--------------------------------------------
236 |
237 | sub esp,32
238 | call expand_filename
239 |
240 | push eax ebx ecx edx esi edi
241 |
242 | call rd_findfile
243 | je fifoundd
244 | pop edi esi edx ecx ebx eax ;file not found
245 | add esp,32
246 | mov eax,5
247 | ret
248 |
249 | fifoundd:
250 |
251 | mov [edi-11],byte 0xE5 ;mark filename deleted
252 | add edi,0xf
253 | movzx eax,word [edi]
254 | mov edi,eax ;edi = cluster
255 |
256 | frnewd:
257 |
258 | shl edi,1 ;find next cluster from FAT
259 | add edi,0x280000
260 | movzx eax,word [edi]
261 | mov [edi],word 0x0 ;clear fat chain cluster
262 | mov edi,eax
263 | cmp edi,dword 0xff8 ;last cluster ?
264 | jb frnewd
265 |
266 | pop edi esi edx ecx ebx eax
267 | add esp,32
268 | xor eax,eax ; file found
269 | ret
270 |
271 |
272 |
273 | filesave:
274 | ;----------------------------------------------------------
275 | ;
276 | ; filesave - sys floppy
277 | ;
278 | ; eax points to filename 11 chars
279 | ;
280 | ; eax ; pointer to file name
281 | ; ebx ; buffer
282 | ; ecx ; count to write in bytes
283 | ; edx ; 0 create new , 1 append
284 | ;
285 | ;-----------------------------------------------------------
286 |
287 | sub esp,32
288 | call expand_filename
289 | test edx,edx
290 | jnz fsdel
291 | pusha
292 | call filedelete
293 | popa
294 |
295 | fsdel:
296 |
297 | call ramdisk_free_space
298 | cmp ecx,edi
299 | jbe rd_do_save
300 | add esp,32
301 | mov eax,8 ;disk full
302 | ret
303 |
304 | rd_do_save:
305 |
306 | push eax ebx ecx edx esi edi
307 |
308 | mov edi,0x100000+512*18+512 ;Point at directory
309 | mov edx,224 +1
310 | ; find an empty spot for filename in the root dir
311 | l20ds:
312 | dec edx
313 | test edx,edx
314 | jz frnoreadds
315 | l21ds:
316 | cmp [edi],byte 0xE5
317 | jz fifoundds
318 | cmp [edi],byte 0x0
319 | jz fifoundds
320 | add edi,32 ; Advance to next entry
321 | jmp l20ds
322 | fifoundds:
323 |
324 | push edi ; move the filename to root dir
325 | mov esi,[esp+4+20]
326 | mov ecx,11
327 | cld
328 | rep movsb
329 | pop edi
330 | mov edx,edi
331 | add edx,11+0xf ; edx <- cluster save position
332 | mov ebx,[esp+12] ; save file size
333 | mov [edi+28],ebx
334 | mov [edi+11],byte 0x20 ; attribute
335 | ; Ivan Poddubny 11/12/2003:
336 | call get_date_for_file ; from FAT32.INC
337 | mov [edi+24],ax ; date
338 | call get_time_for_file ; from FAT32.INC
339 | mov [edi+22],ax ; time
340 | ; End
341 | mov edi,0x280000 ;pointer to first cluster
342 | mov ecx,2849
343 | cld
344 | frnewds:
345 | xor ax,ax
346 | repne scasw
347 | mov ebx,2848
348 | sub ebx,ecx
349 | mov [edx],bx ; save next cluster pos. to prev cl.
350 | mov edx,edi ; next save pos abs mem add
351 | dec edx
352 | dec edx
353 | call fdc_filesave
354 | pusha ; move save to floppy cluster
355 | add ebx,31
356 | shl ebx,9
357 | add ebx,0x100000
358 | mov eax,[esp+32+16]
359 | mov ecx,512
360 | call memmove
361 | popa
362 |
363 | mov eax,[esp+12]
364 | cmp eax,512
365 | jb flnsa
366 | sub eax,512
367 | mov [esp+12],eax
368 | mov eax,[esp+16]
369 | add eax,512
370 | mov [esp+16],eax
371 | jmp frnewds
372 |
373 | flnsa:
374 | dec edi
375 | dec edi
376 | mov [edi],word 4095 ; mark end of file - last cluster
377 |
378 | frnoreadds:
379 |
380 | pop edi esi edx ecx ebx eax
381 | add esp,32
382 |
383 | pusha
384 | cli
385 | call fdc_commitfile
386 | sti
387 | popa
388 |
389 | xor eax,eax ;ok write
390 | ret
391 |
392 | rd_findfile:
393 | ;by Mihasik
394 | ;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx
395 |
396 | mov edi,0x100000+512*18+512 ;Point at directory
397 | cld
398 | rd_newsearch:
399 | mov esi,eax
400 | mov ecx,11
401 | rep cmpsb
402 | je rd_ff
403 | add cl,21
404 | add edi,ecx
405 | cmp edi,0x100000+512*33
406 | jb rd_newsearch
407 | mov eax,5 ;if file not found - eax=5
408 | xor ebx,ebx
409 | dec ebx ;ebx=0xffffffff and zf=0
410 | rd_ff:
411 | ret
412 |
413 | rd_getfileinfo:
414 | ;get date, time, size or attributes of file
415 | ;IN: eax - pointer to file, ebx - type of function: 12-get filesize, 13-get fileattr, 14-get filedate
416 | ;ecx - filelengh 0=root
417 | ;OUT: eax=0 - Ok or 5 - file not found ebx - date/time, size or attributes
418 | test ecx,ecx
419 | jnz no_getfinfo_root
420 | mov eax,5 ;if root - fnf
421 | xor ebx,ebx
422 | dec ebx
423 | ret
424 | no_getfinfo_root: ;if not root
425 | sub esp,32
426 | call expand_filename
427 | call rd_findfile
428 | je fifoundi
429 | add esp,32 ;if file not found
430 | ret
431 | fifoundi:
432 | cmp ebx,13
433 | jne no_rd_attr
434 | movzx ebx,byte [edi] ;get attributes
435 | jmp rd_getfileinfo_end
436 | no_rd_attr:
437 | cmp ebx,14
438 | jne no_rd_date
439 | mov ebx,dword [edi+11] ;get date/time
440 | jmp rd_getfileinfo_end
441 | no_rd_date:
442 | mov ebx,dword [edi+17] ;get size
443 | rd_getfileinfo_end:
444 | xor eax,eax
445 | add esp,32
446 | ret
447 |
--------------------------------------------------------------------------------
/blkdev/rdsave.inc:
--------------------------------------------------------------------------------
1 | cmp eax,6 ; SAVE FLOPPY IMAGE (HD version only)
2 | jnz nosaveimage
3 | cmp ebx,1
4 | jnz img_save_hd_1
5 | mov edx,bootpath ; path = '/KOLIBRI '
6 | jmp img_save_hd_3
7 | img_save_hd_1:
8 | cmp ebx,2
9 | jnz img_save_hd_2
10 | mov edx,bootpath2 ; path = 0 (root dir)
11 | jmp img_save_hd_3
12 | img_save_hd_2:
13 | cmp ebx,3
14 | jnz exit_for_anyone
15 | mov edx,[3010h]
16 | mov edx,[edx+10h]
17 | add edx,ecx
18 | img_save_hd_3:
19 | call restorefatchain ; restore FAT !!!
20 | mov eax,image_save
21 | mov ebx,1440*1024 ; size 1440 Kb
22 | mov ecx,0x100000 ; address of image
23 | call file_write
24 | ret
25 |
26 | nosaveimage:
27 |
--------------------------------------------------------------------------------
/boot/bootcode.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/boot/bootcode.inc
--------------------------------------------------------------------------------
/boot/booteng.inc:
--------------------------------------------------------------------------------
1 | ;======================================================================
2 | ;
3 | ; BOOT DATA
4 | ;
5 | ;======================================================================
6 |
7 | macro line_full_top {
8 | db 201
9 | times 78 db 205
10 | db 187
11 | }
12 | macro line_full_bottom {
13 | db 200
14 | times 78 db 205
15 | db 188
16 | }
17 | macro line_half {
18 | db 186,' '
19 | times 76 db 0xc4
20 | db ' ',186
21 | }
22 | macro line_space {
23 | db 186
24 | times 78 db 32
25 | db 186
26 | }
27 | d80x25: line_full_top
28 | line_space
29 | line_space
30 | line_half
31 | line_space
32 | line_space
33 | line_space
34 | line_space
35 | line_space
36 | line_space
37 | line_space
38 | line_space
39 | line_space
40 | line_space
41 | line_space
42 | line_space
43 | line_space
44 | line_space
45 | line_space
46 | line_space
47 | line_space
48 | line_space
49 | line_space
50 | db 186,' Kolibri OS comes with ABSOLUTELY NO WARR'
51 | db 'ANTY; See file COPYING for details ',186
52 | line_full_bottom
53 |
54 | novesa db "Display: EGA/CGA",13,10,0
55 | vervesa db "Version of Vesa: Vesa x.x ",13,10,0
56 | vervesa_off=22
57 | gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
58 | db "[3] 1024x768, [4] 1280x1024",13,10
59 | db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
60 | db "[7] 1024x768, [8] 1280x1024",13,10
61 | db 186," EGA/CGA 256 Colors: [9] 320x200, "
62 | db "VGA 16 Colors: [0] 640x480",13,10
63 | db 186," Select mode: ",0
64 | bt24 db 13,10,186," Bits Per Pixel: 24",13,10,0
65 | bt32 db 13,10,186," Bits Per Pixel: 32",13,10,0
66 | vrrmprint db 13,10,186," Apply VRR? (picture frequency greater than 60Hz"
67 | db " only for transfers:",13,10
68 | db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0
69 | askmouse db " Mouse at:"
70 | db " [1] PS/2 (USB), [2] Com1, [3] Com2."
71 | db " Select port [1-3]: ",0
72 | no_com1 db 13,10,186, " No COM1 mouse",0
73 | no_com2 db 13,10,186, " No COM2 mouse",0
74 | gr_acc db 13,10,186," Vesa 2.0+ : MTRR graphics acceleration "
75 | db "[1-yes/2-no] ? ",0
76 | gr_direct db 186," Use direct LFB writing? "
77 | db "[1-yes/2-no] ? ",0
78 | ;mem_model db 13,10,186," Motherboard memory [1-16 Mb / 2-32 Mb / "
79 | ; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0
80 | bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0
81 | bdev db 13,10,186
82 | db " Load ramdisk from [1-floppy; 2-C:\menuet.img (FAT32);"
83 | db 13,10,186," "
84 | db "3-use preloaded ram-image from kernel restart]: ",0
85 | probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, "
86 | db "2-probe bios (Vesa 3.0)]: ",0
87 | ;memokz256 db 13,10,186," RAM 256 Mb",0
88 | ;memokz128 db 13,10,186," RAM 128 Mb",0
89 | ;memokz64 db 13,10,186," RAM 64 Mb",0
90 | ;memokz32 db 13,10,186," RAM 32 Mb",0
91 | ;memokz16 db 13,10,186," RAM 16 Mb",0
92 | prid db " pr.",0
93 | prnotfnd db " pr. - not found.",0
94 | modena db "Fatal - VBE 0x112+ required.",0
95 | not386 db "Fatal - CPU 386+ required.",0
96 | btns db 13,10,186,"Fatal - Can't determine color depth.",0
97 | fatalsel db 13,10,"Fatal - Graphics mode not supported by hardware.",0
98 | badsect db 13,10,186," Fatal - Bad sector. Replace floppy. ",0
99 | memmovefailed db "Fatal - Int 0x15 move failed.",0
100 | linef2 db 13,10
101 | linef db 13,10,0
102 | okt db " ... OK",0
103 | keyin db "x",0
104 | keyinbs db "x",8,0
105 | diskload db 13,10,186," Loading diskette: 00 %",8,8,8,8,0
106 | backspace db 8,0
107 | pros db "00",8,8,0
108 | leftpr db 186," ",0
109 | boot_dev db 0 ; 0=floppy, 1=hd
110 |
--------------------------------------------------------------------------------
/boot/bootru.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/boot/bootru.inc
--------------------------------------------------------------------------------
/boot/preboot.inc:
--------------------------------------------------------------------------------
1 | display_modechg db 0 ; display mode change for text, yes/no (0 or 2)
2 | ;
3 | ; !! Important note !!
4 | ;
5 | ; Must be set to 2, to avoid two screenmode
6 | ; changes within a very short period of time.
7 |
8 | display_atboot db 0 ; show boot screen messages ( 2-no )
9 |
10 | preboot_graph db 0 ; graph mode
11 | preboot_gprobe db 0 ; probe vesa3 videomodes (1-no, 2-yes)
12 | preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no)
13 | ;;preboot_mouse db 0 ; mouse port (1-PS2, 2-COM1, 3-COM2)
14 | preboot_mtrr db 0 ; mtrr acceleration (1-yes, 2-no)
15 | preboot_device db 0 ; boot device
16 | ; (1-floppy 2-harddisk 3-kernel restart)
17 | ;;preboot_memory db 0 ; amount of memory
18 | ; (1-16Mb;2-32Mb;3-64Mb;4-128Mb;5-256Mb)
19 | ; !!!! 0 - autodetect !!!!
20 | preboot_blogesc db 0 ; start immediately after bootlog
21 |
22 | hdsysimage db 'MENUET IMG' ; load from
23 | image_save db 'MENUET IMG' ; save to
24 |
--------------------------------------------------------------------------------
/boot/rdload.inc:
--------------------------------------------------------------------------------
1 | ; READ RAMDISK IMAGE FROM HD
2 |
3 | cmp [boot_dev],1
4 | jne no_sys_on_hd
5 |
6 | test [0x40001],byte 0x40
7 | jz position_2
8 | mov [hdbase],0x1f0
9 | mov [hdid],0x0
10 | mov [hdpos],1
11 | mov [fat32part],0
12 | position_1_1:
13 | inc [fat32part]
14 | call search_and_read_image
15 | cmp [image_retrieved],1
16 | je yes_sys_on_hd
17 | movzx eax,byte [0x40002]
18 | cmp [fat32part],eax
19 | jle position_1_1
20 | position_2:
21 | test [0x40001],byte 0x10
22 | jz position_3
23 | mov [hdbase],0x1f0
24 | mov [hdid],0x10
25 | mov [hdpos],2
26 | mov [fat32part],0
27 | position_2_1:
28 | inc [fat32part]
29 | call search_and_read_image
30 | cmp [image_retrieved],1
31 | je yes_sys_on_hd
32 | movzx eax,byte [0x40003]
33 | cmp eax,[fat32part]
34 | jle position_2_1
35 | position_3:
36 | test [0x40001],byte 0x4
37 | jz position_4
38 | mov [hdbase],0x170
39 | mov [hdid],0x0
40 | mov [hdpos],3
41 | mov [fat32part],0
42 | position_3_1:
43 | inc [fat32part]
44 | call search_and_read_image
45 | cmp [image_retrieved],1
46 | je yes_sys_on_hd
47 | movzx eax,byte [0x40004]
48 | cmp eax,[fat32part]
49 | jle position_3_1
50 | position_4:
51 | test [0x40001],byte 0x1
52 | jz no_sys_on_hd
53 | mov [hdbase],0x170
54 | mov [hdid],0x10
55 | mov [hdpos],4
56 | mov [fat32part],0
57 | position_4_1:
58 | inc [fat32part]
59 | call search_and_read_image
60 | cmp [image_retrieved],1
61 | je yes_sys_on_hd
62 | movzx eax,byte [0x40005]
63 | cmp eax,[fat32part]
64 | jle position_4_1
65 | jmp yes_sys_on_hd
66 |
67 | search_and_read_image:
68 | ; mov [0xfe10],dword 0 ; entries in hd cache
69 | call set_FAT32_variables
70 | mov edx, bootpath
71 | call read_image
72 | test eax, eax
73 | jz image_present
74 | mov edx, bootpath2
75 | call read_image
76 | test eax, eax
77 | jz image_present
78 | ret
79 | image_present:
80 | mov [image_retrieved],1
81 | ret
82 |
83 | read_image:
84 | mov eax, hdsysimage
85 | mov ebx, 1474560/512
86 | mov ecx, 0x100000
87 | mov esi, 0
88 | mov edi, 12
89 | call file_read
90 | ret
91 |
92 | image_retrieved db 0
93 | counter_of_partitions db 0
94 | no_sys_on_hd:
95 | yes_sys_on_hd:
96 |
--------------------------------------------------------------------------------
/boot/ru.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/boot/ru.inc
--------------------------------------------------------------------------------
/boot/shutdown.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/boot/shutdown.inc
--------------------------------------------------------------------------------
/build_en.bat:
--------------------------------------------------------------------------------
1 | @if not exist lang.inc (
2 | @echo lang fix en >lang.inc
3 | )
4 | @fasm kernel.asm kernel.mnt
--------------------------------------------------------------------------------
/build_ru.bat:
--------------------------------------------------------------------------------
1 | @if not exist lang.inc (
2 | @echo lang fix ru >lang.inc
3 | )
4 | @fasm kernel.asm kernel.mnt
--------------------------------------------------------------------------------
/bus/pci/pci16.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; PCI16.INC ;;
4 | ;; ;;
5 | ;; 16 bit PCI driver code ;;
6 | ;; ;;
7 | ;; Version 0.2 December 21st, 2002 ;;
8 | ;; ;;
9 | ;; Author: Victor Prodan, victorprodan@yahoo.com ;;
10 | ;; ;;
11 | ;; See file COPYING for details ;;
12 | ;; ;;
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 |
15 |
16 | init_pci_16:
17 |
18 | pushad
19 |
20 | xor ax,ax
21 | mov es,ax
22 | mov byte [es:0x9020],1 ;default mechanism:1
23 | mov ax,0xb101
24 | int 0x1a
25 | or ah,ah
26 | jnz pci16skip
27 |
28 | mov [es:0x9021],cl ;last PCI bus in system
29 | mov [es:0x9022],bx
30 | mov [es:0x9024],edi
31 |
32 | ; we have a PCI BIOS, so check which configuration mechanism(s)
33 | ; it supports
34 | ; AL = PCI hardware characteristics (bit0 => mechanism1, bit1 => mechanism2)
35 | test al,1
36 | jnz pci16skip
37 | test al,2
38 | jz pci16skip
39 | mov byte [es:0x9020],2 ; if (al&3)==2 => mechanism 2
40 |
41 | pci16skip:
42 |
43 | mov ax,0x1000
44 | mov es,ax
45 |
46 | popad
--------------------------------------------------------------------------------
/bus/pci/pci32.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; PCI32.INC ;;
4 | ;; ;;
5 | ;; 32 bit PCI driver code ;;
6 | ;; ;;
7 | ;; Version 0.2 December 21st, 2002 ;;
8 | ;; ;;
9 | ;; Author: Victor Prodan, victorprodan@yahoo.com ;;
10 | ;; Credits: ;;
11 | ;; Ralf Brown ;;
12 | ;; Mike Hibbett, mikeh@oceanfree.net ;;
13 | ;; ;;
14 | ;; See file COPYING for details ;;
15 | ;; ;;
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17 |
18 |
19 | ;***************************************************************************
20 | ; Function
21 | ; pci_api:
22 | ;
23 | ; Description
24 | ; entry point for system PCI calls
25 | ;***************************************************************************
26 |
27 | align 4
28 |
29 | pci_api:
30 |
31 | cmp [pci_access_enabled],1
32 | jne no_pci_access_for_applications
33 |
34 | or al,al
35 | jnz pci_fn_1
36 | ; PCI function 0: get pci version (AH.AL)
37 | movzx eax,word [0x2F0000+0x9022]
38 | ret
39 |
40 | pci_fn_1:
41 | cmp al,1
42 | jnz pci_fn_2
43 |
44 | ; PCI function 1: get last bus in AL
45 | mov al,[0x2F0000+0x9021]
46 | ret
47 |
48 | pci_fn_2:
49 | cmp al,2
50 | jne pci_fn_3
51 | ; PCI function 2: get pci access mechanism
52 | mov al,[0x2F0000+0x9020]
53 | ret
54 | pci_fn_3:
55 |
56 | cmp al,4
57 | jz pci_read_reg ;byte
58 | cmp al,5
59 | jz pci_read_reg ;word
60 | cmp al,6
61 | jz pci_read_reg ;dword
62 |
63 | cmp al,8
64 | jz pci_write_reg ;byte
65 | cmp al,9
66 | jz pci_write_reg ;word
67 | cmp al,10
68 | jz pci_write_reg ;dword
69 |
70 | no_pci_access_for_applications:
71 |
72 | mov eax,-1
73 |
74 | ret
75 |
76 | ;***************************************************************************
77 | ; Function
78 | ; pci_make_config_cmd
79 | ;
80 | ; Description
81 | ; creates a command dword for use with the PCI bus
82 | ; bus # in ah
83 | ; device+func in bh (dddddfff)
84 | ; register in bl
85 | ;
86 | ; command dword returned in eax ( 10000000 bbbbbbbb dddddfff rrrrrr00 )
87 | ;***************************************************************************
88 |
89 | align 4
90 |
91 | pci_make_config_cmd:
92 | shl eax,8 ; move bus to bits 16-23
93 | mov ax,bx ; combine all
94 | and eax,0xffffff
95 | or eax,0x80000000
96 | ret
97 |
98 | ;***************************************************************************
99 | ; Function
100 | ; pci_read_reg:
101 | ;
102 | ; Description
103 | ; read a register from the PCI config space into EAX/AX/AL
104 | ; IN: ah=bus,device+func=bh,register address=bl
105 | ; number of bytes to read (1,2,4) coded into AL, bits 0-1
106 | ;***************************************************************************
107 |
108 | align 4
109 |
110 | pci_read_reg:
111 | cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use?
112 | je pci_read_reg_2
113 |
114 | ; mechanism 1
115 | push esi ; save register size into ESI
116 | mov esi,eax
117 | and esi,3
118 |
119 | call pci_make_config_cmd
120 | mov ebx,eax
121 | ; get current state
122 | mov dx,0xcf8
123 | in eax, dx
124 | push eax
125 | ; set up addressing to config data
126 | mov eax,ebx
127 | and al,0xfc ; make address dword-aligned
128 | out dx,eax
129 | ; get requested DWORD of config data
130 | mov dl,0xfc
131 | and bl,3
132 | or dl,bl ; add to port address first 2 bits of register address
133 |
134 | or esi,esi
135 | jz pci_read_byte1
136 | cmp esi,1
137 | jz pci_read_word1
138 | cmp esi,2
139 | jz pci_read_dword1
140 | jmp pci_fin_read1
141 |
142 | pci_read_byte1:
143 | in al,dx
144 | jmp pci_fin_read1
145 | pci_read_word1:
146 | in ax,dx
147 | jmp pci_fin_read1
148 | pci_read_dword1:
149 | in eax,dx
150 | jmp pci_fin_read1
151 | pci_fin_read1:
152 | ; restore configuration control
153 | xchg eax,[esp]
154 | mov dx,0xcf8
155 | out dx,eax
156 |
157 | pop eax
158 | pop esi
159 | ret
160 | pci_read_reg_2:
161 |
162 | test bh,128 ;mech#2 only supports 16 devices per bus
163 | jnz pci_read_reg_err
164 |
165 | push esi ; save register size into ESI
166 | mov esi,eax
167 | and esi,3
168 |
169 | push eax
170 | ;store current state of config space
171 | mov dx,0xcf8
172 | in al,dx
173 | mov ah,al
174 | mov dl,0xfa
175 | in al,dx
176 |
177 | xchg eax,[esp]
178 | ; out 0xcfa,bus
179 | mov al,ah
180 | out dx,al
181 | ; out 0xcf8,0x80
182 | mov dl,0xf8
183 | mov al,0x80
184 | out dx,al
185 | ; compute addr
186 | shr bh,3 ; func is ignored in mechanism 2
187 | or bh,0xc0
188 | mov dx,bx
189 |
190 | or esi,esi
191 | jz pci_read_byte2
192 | cmp esi,1
193 | jz pci_read_word2
194 | cmp esi,2
195 | jz pci_read_dword2
196 | jmp pci_fin_read2
197 |
198 | pci_read_byte2:
199 | in al,dx
200 | jmp pci_fin_read2
201 | pci_read_word2:
202 | in ax,dx
203 | jmp pci_fin_read2
204 | pci_read_dword2:
205 | in eax,dx
206 | ; jmp pci_fin_read2
207 | pci_fin_read2:
208 |
209 | ; restore configuration space
210 | xchg eax,[esp]
211 | mov dx,0xcfa
212 | out dx,al
213 | mov dl,0xf8
214 | mov al,ah
215 | out dx,al
216 |
217 | pop eax
218 | pop esi
219 | ret
220 |
221 | pci_read_reg_err:
222 | xor eax,eax
223 | dec eax
224 | ret
225 |
226 |
227 | ;***************************************************************************
228 | ; Function
229 | ; pci_write_reg:
230 | ;
231 | ; Description
232 | ; write a register from ECX/CX/CL into the PCI config space
233 | ; IN: ah=bus,device+func=bh,register address (dword aligned)=bl,
234 | ; value to write in ecx
235 | ; number of bytes to write (1,2,4) coded into AL, bits 0-1
236 | ;***************************************************************************
237 |
238 | align 4
239 |
240 | pci_write_reg:
241 | cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use?
242 | je pci_write_reg_2
243 |
244 | ; mechanism 1
245 | push esi ; save register size into ESI
246 | mov esi,eax
247 | and esi,3
248 |
249 | call pci_make_config_cmd
250 | mov ebx,eax
251 | ; get current state into ecx
252 | mov dx,0xcf8
253 | in eax, dx
254 | push eax
255 | ; set up addressing to config data
256 | mov eax,ebx
257 | and al,0xfc ; make address dword-aligned
258 | out dx,eax
259 | ; write DWORD of config data
260 | mov dl,0xfc
261 | and bl,3
262 | or dl,bl
263 | mov eax,ecx
264 |
265 | or esi,esi
266 | jz pci_write_byte1
267 | cmp esi,1
268 | jz pci_write_word1
269 | cmp esi,2
270 | jz pci_write_dword1
271 | jmp pci_fin_write1
272 |
273 | pci_write_byte1:
274 | out dx,al
275 | jmp pci_fin_write1
276 | pci_write_word1:
277 | out dx,ax
278 | jmp pci_fin_write1
279 | pci_write_dword1:
280 | out dx,eax
281 | jmp pci_fin_write1
282 | pci_fin_write1:
283 |
284 | ; restore configuration control
285 | pop eax
286 | mov dl,0xf8
287 | out dx,eax
288 |
289 | xor eax,eax
290 | pop esi
291 |
292 | ret
293 | pci_write_reg_2:
294 |
295 | test bh,128 ;mech#2 only supports 16 devices per bus
296 | jnz pci_write_reg_err
297 |
298 |
299 | push esi ; save register size into ESI
300 | mov esi,eax
301 | and esi,3
302 |
303 | push eax
304 | ;store current state of config space
305 | mov dx,0xcf8
306 | in al,dx
307 | mov ah,al
308 | mov dl,0xfa
309 | in al,dx
310 | xchg eax,[esp]
311 | ; out 0xcfa,bus
312 | mov al,ah
313 | out dx,al
314 | ; out 0xcf8,0x80
315 | mov dl,0xf8
316 | mov al,0x80
317 | out dx,al
318 | ; compute addr
319 | shr bh,3 ; func is ignored in mechanism 2
320 | or bh,0xc0
321 | mov dx,bx
322 | ; write register
323 | mov eax,ecx
324 |
325 | or esi,esi
326 | jz pci_write_byte2
327 | cmp esi,1
328 | jz pci_write_word2
329 | cmp esi,2
330 | jz pci_write_dword2
331 | jmp pci_fin_write2
332 |
333 | pci_write_byte2:
334 | out dx,al
335 | jmp pci_fin_write2
336 | pci_write_word2:
337 | out dx,ax
338 | jmp pci_fin_write2
339 | pci_write_dword2:
340 | out dx,eax
341 | jmp pci_fin_write2
342 | pci_fin_write2:
343 | ; restore configuration space
344 | pop eax
345 | mov dx,0xcfa
346 | out dx,al
347 | mov dl,0xf8
348 | mov al,ah
349 | out dx,al
350 |
351 | xor eax,eax
352 | pop esi
353 | ret
354 |
355 | pci_write_reg_err:
356 | xor eax,eax
357 | dec eax
358 | ret
359 |
--------------------------------------------------------------------------------
/core/fpu.inc:
--------------------------------------------------------------------------------
1 | iglobal
2 | prev_user_of_fpu dd 0x1 ; set to OS
3 | endg
4 |
5 | label fpu_tss at 0xB080
6 | label fpu_stack dword at 0xB060
7 |
8 |
9 | align 4
10 | fpu_handler:
11 |
12 | ; clear TS flag in CR0 -> for task switching
13 | clts
14 |
15 | ; save FPU context of the previous task
16 | mov eax,[prev_user_of_fpu]
17 | shl eax,8
18 | add eax,0x80000+0x10
19 | fsave [eax]
20 |
21 | ; next task switch save our FPU context
22 | ; now restore context of current task (if exists)
23 | mov eax,[0x3000]
24 | mov [prev_user_of_fpu],eax
25 | shl eax,8
26 | add eax,0x80000
27 | cmp [eax+0x7f],byte 0
28 | je bs7_first_fpu
29 | frstor [eax+0x10]
30 | bs7_first_fpu:
31 | mov [eax+0x7f],byte 1
32 |
33 | ; prepare structure in stack for proper IRET
34 | movzx eax,word [fpu_tss+l.ss-tss_sceleton] ; push ss
35 | push eax
36 | mov eax,[fpu_tss+l.esp-tss_sceleton] ; push esp
37 | push eax
38 | mov eax,[fpu_tss+l.eflags-tss_sceleton] ; push eflags
39 | push eax
40 |
41 | movzx eax,word [fpu_tss+l.cs-tss_sceleton] ; push cs
42 | push eax
43 | mov eax,[fpu_tss+l.eip-tss_sceleton] ; push eip
44 | push eax
45 |
46 | ; save eax
47 | push dword [fpu_tss+l.eax-tss_sceleton]
48 |
49 | ; restore all segment registers
50 | mov ax,[fpu_tss+l.es-tss_sceleton]
51 | mov es,ax
52 | mov ax,[fpu_tss+l.fs-tss_sceleton]
53 | mov fs,ax
54 | mov ax,[fpu_tss+l.gs-tss_sceleton]
55 | mov gs,ax
56 | mov ax,[fpu_tss+l.ds-tss_sceleton]
57 | mov ds,ax
58 |
59 | ; restore eax
60 | pop eax
61 |
62 | iret
63 |
--------------------------------------------------------------------------------
/core/mem.inc:
--------------------------------------------------------------------------------
1 | if ~defined mem_inc
2 | mem_inc_fix:
3 | mem_inc fix mem_inc_fix
4 | ;include "memmanag.inc"
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 | ;;High-level memory management in MenuetOS.
7 | ;;It uses memory manager in memmanager.inc
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 | second_base_address=0xC0000000
10 | std_application_base_address=0x10000000
11 | general_page_table_ dd 0
12 | general_page_table=general_page_table_+second_base_address
13 | ;-----------------------------------------------------------------------------
14 | create_general_page_table:
15 | ;input
16 | ; none
17 | ;output
18 | ; none
19 | ;Procedure create general page directory and write
20 | ;it address to [general_page_table].
21 | pushad
22 | mov eax,1 ;alloc 1 page
23 | mov ebx,general_page_table ;write address to [general_page_table]
24 | call MEM_Alloc_Pages ;allocate page directory
25 | mov eax,[general_page_table]
26 | call MEM_Get_Linear_Address ;eax - linear address of page directory
27 | mov edi,eax
28 | mov ebx,eax
29 | xor eax,eax
30 | mov ecx,4096/4
31 | cld
32 | rep stosd ;clear page directory
33 |
34 | mov eax,4
35 | mov edx,eax
36 | call MEM_Alloc_Pages ;alloc page tables for 0x0-0x1000000 region
37 | cmp eax,edx
38 | jnz $ ;hang if not enough memory
39 |
40 | ;fill page tables
41 | xor esi,esi
42 | mov ebp,7
43 |
44 | .loop:
45 | ;esi - number of page in page directory
46 | ;ebp - current page address
47 | ;ebx - linear address of page directory
48 | mov eax,[ebx+4*esi]
49 | add dword [ebx+4*esi],7 ;add flags to address of page table
50 | call MEM_Get_Linear_Address
51 | ;eax - linear address of page table
52 | mov ecx,4096/4
53 | ;ecx (counter) - number of pages in page table
54 | ;current address=4Mb*esi
55 | cmp esi,2
56 | jz .start_lfb_map ;lfb map begin at 0x800000
57 | cmp esi,3
58 | jz .end_lfb_map ;lfb map end at 0xC00000
59 | jmp .loop1
60 | .start_lfb_map:
61 | ;current address=lfb address
62 | mov ebp,[0x2f0000+0x9018]
63 | add ebp,7 ;add flags
64 | jmp .loop1
65 | .end_lfb_map:
66 | ;current address=linear address
67 | mov ebp,12*0x100000+7
68 |
69 | .loop1:
70 | mov [eax],ebp ;write page address (with flags) in page table
71 | add eax,4
72 | add ebp,4096 ;size of page=4096 bytes
73 | loop .loop1
74 |
75 | inc esi ;next page directory entry
76 | cmp esi,edx
77 | jnz .loop
78 |
79 | ;map region 0x80000000-0x803fffff to 0x800000-0xcfffff
80 | mov eax,1 ;size of the region is 4Mb so only 1 page table needed
81 | mov edx,ebx ;ebx still contains linear address of the page directory
82 | add ebx,0x800
83 | call MEM_Alloc_Pages ;alloc page table for the region
84 | mov eax,[ebx]
85 | add dword [ebx],7 ;add flags
86 | call MEM_Get_Linear_Address ;get linear address of the page table
87 | mov ebx,eax
88 | mov ecx,4096/4 ;number of pages in page table
89 | mov eax,8*0x100000+7
90 | .loop3:
91 | ;ebx - linear address of page table
92 | ;eax - current linear address with flags
93 | mov [ebx],eax
94 | add ebx,4
95 | add eax,4096
96 | loop .loop3
97 |
98 | ;map region 0xC0000000-* to 0x0-*
99 | mov esi,edx ;esi=linear address of the page directory
100 | lea edi,[esi+(second_base_address shr 20)];add offset of entry (0xC00)
101 | mov ecx,4
102 | rep movsd ;first 16Mb of the region mapped as 0x0-0x1000000 block
103 | mov eax,[0xfe8c] ;eax=memory size
104 | add eax,0x3fffff
105 | shr eax,22
106 | mov esi,eax ;calculate number of entries in page directory
107 | sub esi,4 ;subtract entries for first 16Mb.
108 | mov ebp,0x1000000+7 ;start physical address with flags
109 |
110 | ;mapping memory higher than 16Mb
111 | .loop4:
112 | ;esi (counter) - number of entries in page directory
113 | ;edi - address of entry
114 | test esi,esi
115 | jle .loop4end
116 | call MEM_Alloc_Page ;alloc page table for entry in page directory
117 | mov [edi],eax
118 | add dword [edi],7 ;write physical address of page table in page directory
119 | add edi,4 ;move entry pointer
120 | call MEM_Get_Linear_Address
121 | mov ecx,eax
122 | xor edx,edx
123 |
124 | .loop5:
125 | ;ecx - linear address of page table
126 | ;edx - index of page in page table
127 | ;ebp - current mapped physical address with flags
128 | mov [ecx+4*edx],ebp ;write address of page in page table
129 | add ebp,0x1000 ;move to next page
130 | inc edx
131 | cmp edx,4096/4
132 | jl .loop5
133 |
134 | dec esi
135 | jmp .loop4
136 | .loop4end:
137 |
138 | .set_cr3:
139 | ;set value of cr3 register to the address of page directory
140 | mov eax,[general_page_table]
141 | add eax,8+16 ;add flags
142 | mov cr3,eax ;now we have full access paging
143 |
144 | popad
145 | ret
146 | ;-----------------------------------------------------------------------------
147 | simple_clone_cr3_table:
148 | ;Parameters:
149 | ; eax - physical address of cr3 table (page directory)
150 | ;result:
151 | ; eax - physical address of clone of cr3 table.
152 | ;Function copy only page directory.
153 | push ecx
154 | push edx
155 | push esi
156 | push edi
157 | call MEM_Get_Linear_Address
158 | ;eax - linear address of cr3 table
159 | mov esi,eax
160 | call MEM_Alloc_Page
161 | test eax,eax
162 | jz .failed
163 | ;eax - physical address of new page diretory
164 | mov edx,eax
165 | call MEM_Get_Linear_Address
166 | mov edi,eax
167 | mov ecx,4096/4
168 | cld
169 | ;esi - address of old page directory
170 | ;edi - address of new page directory
171 | rep movsd ;copy page directory
172 | mov eax,edx
173 | .failed:
174 | pop edi
175 | pop esi
176 | pop edx
177 | pop ecx
178 | ret
179 |
180 | ;-----------------------------------------------------------------------------
181 | create_app_cr3_table:
182 | ;Parameters:
183 | ; eax - slot of process (index in 0x3000 table)
184 | ;result:
185 | ; eax - physical address of table.
186 | ;This function create page directory for new process and
187 | ;write it physical address to offset 0xB8 of extended
188 | ;process information.
189 | push ebx
190 |
191 | mov ebx,eax
192 | mov eax,[general_page_table]
193 | call simple_clone_cr3_table ;clone general page table
194 | shl ebx,8
195 | mov [second_base_address+0x80000+ebx+0xB8],eax ;save address of page directory
196 |
197 | pop ebx
198 | ret
199 | ;-----------------------------------------------------------------------------
200 | get_cr3_table:
201 | ;Input:
202 | ; eax - slot of process
203 | ;result:
204 | ; eax - physical address of page directory
205 | shl eax,8 ;size of process extended information=256 bytes
206 | mov eax,[second_base_address+0x80000+eax+0xB8]
207 | ret
208 | ;-----------------------------------------------------------------------------
209 | dispose_app_cr3_table:
210 | ;Input:
211 | ; eax - slot of process
212 | ;result:
213 | ; none
214 | ;This procedure frees page directory,
215 | ;page tables and all memory of process.
216 | pushad
217 | mov ebp,eax
218 | ;ebp = process slot in the procedure.
219 | shl eax,8
220 | mov eax,[second_base_address+0x80000+eax+0xB8]
221 | mov ebx,eax
222 | ;ebx = physical address of page directory
223 | call MEM_Get_Linear_Address
224 | mov edi,eax
225 | ;edi = linear address of page directory
226 | mov eax,[edi+(std_application_base_address shr 20)]
227 | and eax,not (4096-1)
228 | call MEM_Get_Linear_Address
229 | mov esi,eax
230 | ;esi = linear address of first page table
231 |
232 | ;search threads
233 | ; mov ecx,0x200
234 | xor edx,edx
235 | mov eax,0x2
236 |
237 | .loop:
238 | ;eax = current slot of process
239 | mov ecx,eax
240 | shl ecx,5
241 | cmp byte [second_base_address+0x3000+ecx+0xa],0 ;if process running?
242 | jnz .next ;slot empty or process is terminating - go to next slot
243 | shl ecx,3
244 | cmp [second_base_address+0x80000+ecx+0xB8],ebx ;compare page directory addresses
245 | jnz .next
246 | inc edx ;thread found
247 | .next:
248 | inc eax
249 | cmp eax,[0x3004] ;exit loop if we look through all processes
250 | jle .loop
251 |
252 | ;edx = number of threads
253 | ;our process is zombi so it isn't counted
254 | test edx,edx
255 | jnz .threadsexists
256 | ;if there isn't threads then clear memory.
257 | add edi,std_application_base_address shr 20
258 |
259 | .loop1:
260 | ;edi = linear address of current directory entry
261 | ;esi = linear address of current page table
262 | test esi,esi
263 | jz .loop1end
264 | xor ecx,ecx
265 |
266 | .loop2:
267 | ;ecx = index of page
268 | mov eax,[esi+4*ecx]
269 | test eax,eax
270 | jz .loopend ;skip empty entries
271 | and eax,not (4096-1) ;clear flags
272 | push ecx
273 | call MEM_Free_Page ;free page
274 | pop ecx
275 | .loopend:
276 | inc ecx
277 | cmp ecx,1024 ;there are 1024 pages in page table
278 | jl .loop2
279 |
280 | mov eax,esi
281 | call MEM_Free_Page_Linear ;free page table
282 | .loop1end:
283 | add edi,4 ;move to next directory entry
284 | mov eax,[edi]
285 | and eax,not (4096-1)
286 | call MEM_Get_Linear_Address
287 | mov esi,eax ;calculate linear address of new page table
288 | test edi,0x800
289 | jz .loop1 ;test if we at 0x80000000 address?
290 |
291 | and edi,not (4096-1) ;clear offset of page directory entry
292 | mov eax,edi
293 | call MEM_Free_Page_Linear ;free page directory
294 | popad
295 | ret
296 |
297 | .threadsexists: ;do nothing
298 | popad ;last thread will free memory
299 | ret
300 | ;-----------------------------------------------------------------------------
301 | mem_alloc_specified_region:
302 | ;eax - linear directory address
303 | ;ebx - start address (aligned to 4096 bytes)
304 | ;ecx - size in pages
305 | ;result:
306 | ; eax=1 - ok
307 | ; eax=0 - failed
308 | ;Try to alloc and map ecx pages to [ebx;ebx+4096*ecx) interval.
309 | pushad
310 | mov ebp,ebx ;save start address for recoil
311 | mov esi,eax
312 | .gen_loop:
313 | ;esi = linear directory address
314 | ;ebx = current address
315 | ;ecx = remaining size in pages
316 | mov edx,ebx
317 | shr edx,22
318 | mov edi,[esi+4*edx] ;find directory entry for current address
319 | test edi,edi
320 | jnz .table_exists ;check if page table allocated
321 | call MEM_Alloc_Page ;alloc page table
322 | test eax,eax
323 | jz .failed
324 | mov [esi+4*edx],eax
325 | add dword [esi+4*edx],7 ;write it address with flags
326 | call MEM_Get_Linear_Address
327 | call mem_fill_page ;clear page table
328 | jmp .table_linear
329 | .table_exists:
330 | ;calculate linear address of page table
331 | mov eax,edi
332 | and eax,not (4096-1) ;clear flags
333 | call MEM_Get_Linear_Address
334 | .table_linear:
335 | ;eax = linear address of page table
336 | mov edx,ebx
337 | shr edx,12
338 | and edx,(1024-1) ;calculate index in page table
339 | mov edi,eax
340 |
341 | .loop:
342 | ;edi = linear address of page table
343 | ;edx = current page table index
344 | ;ecx = remaining size in pages
345 | ;ebx = current address
346 | test ecx,ecx
347 | jle .endloop1 ;all requested pages allocated
348 |
349 | call MEM_Alloc_Page ;alloc new page
350 | test eax,eax
351 | jz .failed
352 | mov [edi+4*edx],eax
353 | add dword [edi+4*edx],7 ;write it address with flags
354 | call MEM_Get_Linear_Address
355 | call mem_fill_page ;clear new page
356 | ;go to next page table entry
357 | dec ecx
358 | add ebx,4096
359 | inc edx
360 | test edx,(1024-1)
361 | jnz .loop
362 |
363 | jmp .gen_loop
364 |
365 | .endloop1:
366 | popad
367 | mov eax,1 ;ok
368 | ret
369 |
370 | .failed:
371 | ;calculate data for recoil
372 | sub ebx,ebp
373 | shr ebx,12
374 | mov ecx,ebx ;calculate number of allocated pages
375 | mov eax,esi ;restore linear address of page directory
376 | mov ebx,ebp ;restore initial address
377 | call mem_free_specified_region ;free all allocated pages
378 | popad
379 | xor eax,eax ;fail
380 | ret
381 | ;-----------------------------------------------------------------------------
382 | mem_fill_page:
383 | ;Input:
384 | ; eax - address
385 | ;result:
386 | ; none
387 | ;set to zero 4096 bytes at eax address.
388 | push ecx
389 | push edi
390 | mov edi,eax
391 | mov ecx,4096/4
392 | xor eax,eax
393 | rep stosd
394 | lea eax,[edi-4096]
395 | pop edi
396 | pop ecx
397 | ret
398 | ;-----------------------------------------------------------------------------
399 | mem_free_specified_region:
400 | ;eax - linear page directory address
401 | ;ebx - start address (aligned to 4096 bytes)
402 | ;ecx - size in pages
403 | ;result - none
404 | ;Free pages in [ebx;ebx+4096*ecx) region.
405 | pushad
406 | mov esi,eax
407 | xor ebp,ebp
408 |
409 | .gen_loop:
410 | ;esi = linear page directory address
411 | ;ebx = current address
412 | ;ecx = remaining pages
413 | ;ebp = 0 for first page table
414 | ; 1 otherwise
415 | mov edx,ebx
416 | shr edx,22
417 | mov eax,[esi+4*edx] ;find directory entry for current address
418 | and eax,not (4096-1)
419 | test eax,eax
420 | jnz .table_exists
421 | ;skip absent page tables
422 | mov edx,ebx
423 | shr edx,12
424 | and edx,(1024-1) ;edx - index of current page
425 | add ebx,1 shl 22
426 | add ecx,edx
427 | and ebx,not ((1 shl 22)-1)
428 | mov ebp,1 ;set flag
429 | sub ecx,1024 ;ecx=ecx-(1024-edx)
430 | jg .gen_loop
431 | popad
432 | ret
433 | .table_exists:
434 | call MEM_Get_Linear_Address
435 | ;eax - linear address of table
436 | mov edx,ebx
437 | shr edx,12
438 | and edx,(1024-1) ;edx - index of current page
439 | mov edi,eax
440 |
441 | .loop:
442 | ;edi = linear address of page table entry
443 | ;edx = index of page table entry
444 | ;ecx = remaining pages
445 | test ecx,ecx
446 | jle .endloop1
447 |
448 | mov eax,[edi+4*edx]
449 | and eax,not (4096-1)
450 | call MEM_Free_Page ;free page
451 | mov dword [edi+4*edx],0 ;and clear page table entry
452 | dec ecx
453 | inc edx
454 | cmp edx,1024
455 | jl .loop
456 |
457 | test ebp,ebp
458 | jz .first_page
459 | mov eax,edi
460 | call MEM_Free_Page_Linear ;free page table
461 | mov edx,ebx
462 | shr edx,22
463 | mov dword [esi+4*edx],0 ;and clear page directory entry
464 | .first_page:
465 | add ebx,1 shl 22
466 | and ebx,not ((1 shl 22)-1) ;calculate new current address
467 | mov ebp,1 ;set flag
468 | jmp .gen_loop
469 |
470 | .endloop1:
471 | popad
472 | ret
473 | end if
474 |
--------------------------------------------------------------------------------
/core/physmem.inc:
--------------------------------------------------------------------------------
1 | virtual at 0
2 | physical_mem_block:
3 | .start rd 1
4 | .size rd 1
5 | .flags rd 1 ;0-free, pid-used.
6 | .sizeof:
7 | end virtual
8 | max_physical_mem_blocks = 24
9 | uglobal
10 | num_physical_mem_blocks rd 1
11 | physical_mem_blocks rd 3*max_physical_mem_blocks
12 | endg
13 | Init_Physical_Memory_Manager:
14 | pushad
15 | mov edi,physical_mem_blocks
16 | mov ecx,3*max_physical_mem_blocks
17 | xor eax,eax
18 | cld
19 | rep stosd
20 | mov dword [num_physical_mem_blocks],2
21 | mov [physical_mem_blocks+physical_mem_block.start],0x60000
22 | mov [physical_mem_blocks+physical_mem_block.size],0x20000 ;128Kb
23 | mov [physical_mem_blocks+physical_mem_block.sizeof+physical_mem_block.start],0x780000
24 | mov [physical_mem_blocks+physical_mem_block.sizeof+physical_mem_block.size],0x80000 ;512Kb
25 | popad
26 | ret
27 | Insert_Block:
28 | ;input:
29 | ; eax - handle
30 | ;output:
31 | ; none
32 | push eax ecx esi edi
33 | sub eax,[num_physical_mem_blocks]
34 | neg eax
35 | mov edi,physical_mem_block.sizeof
36 | imul eax,edi
37 | shr eax,2
38 | mov ecx,eax
39 | mov esi,[num_physical_mem_blocks]
40 | imul esi,edi
41 | add esi,physical_mem_blocks
42 | lea edi,[esi+physical_mem_block.sizeof]
43 | std
44 | rep movsd
45 | pop edi esi ecx eax
46 | ret
47 | Delete_Block:
48 | ;input:
49 | ; eax - handle
50 | ;output:
51 | ; none
52 | pushad
53 | mov edi,eax
54 | sub eax,[num_physical_mem_blocks]
55 | neg eax
56 | dec eax
57 | mov esi,physical_mem_block.sizeof
58 | imul eax,esi
59 | imul edi,esi
60 | add edi,physical_mem_blocks
61 | lea esi,[edi+physical_mem_block.sizeof]
62 | mov ecx,eax
63 | shr ecx,2
64 | cld
65 | rep movsd
66 | popad
67 | ret
68 | Allocate_Physical_Block:
69 | ;input:
70 | ; eax - size
71 | ;output:
72 | ; eax - address or 0 if not enough memory.
73 | pushad
74 | cmp [num_physical_mem_blocks],max_physical_mem_blocks
75 | jge .error
76 | mov ebx,eax
77 | xor eax,eax
78 | mov esi,physical_mem_blocks
79 | .loop:
80 | cmp dword [esi+physical_mem_block.flags],0
81 | jnz .next
82 | cmp [esi+physical_mem_block.size],ebx
83 | jg .addblock
84 | jz .noaddblock
85 | .next:
86 | inc eax
87 | add esi,physical_mem_block.sizeof
88 | cmp eax,[num_physical_mem_blocks]
89 | jl .loop
90 | .error:
91 | popad
92 | xor eax,eax
93 | ret
94 | .noaddblock:
95 | mov eax,[esi+physical_mem_block.start]
96 | mov [esp+28],eax
97 | mov eax,[0x3010]
98 | mov eax,[eax+0x4]
99 | mov [esi+physical_mem_block.flags],eax
100 | popad
101 | ret
102 | .addblock:
103 | call Insert_Block
104 | inc dword [num_physical_mem_blocks]
105 | mov eax,[esi+physical_mem_block.start]
106 | mov [esp+28],eax
107 | mov ecx,[0x3010]
108 | mov ecx,[ecx+0x4]
109 | mov [esi+physical_mem_block.flags],ecx
110 | mov ecx,[esi+physical_mem_block.size]
111 | mov [esi+physical_mem_block.size],ebx
112 | sub ecx,ebx
113 | mov [esi+physical_mem_block.sizeof+physical_mem_block.size],ecx
114 | add ebx,[esi+physical_mem_block.start]
115 | mov [esi+physical_mem_block.sizeof+physical_mem_block.start],ebx
116 | mov dword [esi+physical_mem_block.sizeof+physical_mem_block.flags],0
117 | popad
118 | ret
119 | Free_Physical_Block:
120 | ;input:
121 | ; eax - address
122 | ;output:
123 | ; none
124 | pushad
125 | test eax,eax
126 | jz .ret
127 | mov ebx,eax
128 | xor eax,eax
129 | mov esi,physical_mem_blocks
130 | .loop:
131 | cmp ebx,[esi+physical_mem_block.start]
132 | jz .endloop
133 | inc eax
134 | add esi,physical_mem_block.sizeof
135 | cmp eax,[num_physical_mem_blocks]
136 | jl .loop
137 | jmp .ret
138 | .endloop:
139 | mov dword [esi+physical_mem_block.flags],0
140 | test eax,eax
141 | jz .no_union_previous
142 | cmp dword [esi-physical_mem_block.sizeof+physical_mem_block.flags],0
143 | jnz .no_union_previous
144 | mov ebx,[esi-physical_mem_block.sizeof+physical_mem_block.start]
145 | add ebx,[esi-physical_mem_block.sizeof+physical_mem_block.size]
146 | cmp ebx,[esi+physical_mem_block.start]
147 | jnz .no_union_previous
148 | mov ebx,[esi+physical_mem_block.size]
149 | add [esi-physical_mem_block.sizeof+physical_mem_block.size],ebx
150 | call Delete_Block
151 | dec eax
152 | dec [num_physical_mem_blocks]
153 | .no_union_previous:
154 | inc eax
155 | cmp eax,[num_physical_mem_blocks]
156 | jge .no_union_next
157 | cmp dword [esi+physical_mem_block.sizeof+physical_mem_block.flags],0
158 | jnz .no_union_next
159 | mov ebx,[esi+physical_mem_block.start]
160 | add ebx,[esi+physical_mem_block.size]
161 | cmp ebx,[esi+physical_mem_block.sizeof+physical_mem_block.start]
162 | jnz .no_union_next
163 | mov ebx,[esi+physical_mem_block.sizeof+physical_mem_block.size]
164 | add [esi+physical_mem_block.size],ebx
165 | call Delete_Block
166 | dec [num_physical_mem_blocks]
167 | .no_union_next:
168 | .ret:
169 | popad
170 | ret
171 |
172 | sys_allocate_physical_block:
173 | ;eax - subfunction number
174 | mov eax,ebx
175 | call Allocate_Physical_Block
176 | mov [esp+36],eax
177 | ret
178 | sys_free_physical_block:
179 | ;eax - subfunction number
180 | mov eax,ebx
181 | call Free_Physical_Block
182 | ret
183 | sys_set_buffer:
184 | add ecx,std_application_base_address
185 | isys_set_buffer: ;for using in kernel
186 | ;eax - subfunction number
187 | ;ebx - physical address
188 | ;ecx - buffer start
189 | ;edx - buffer size
190 | lea edi,[ebx+second_base_address]
191 | mov esi,ecx
192 | mov ecx,edx
193 | rep movsb
194 | ret
195 | sys_get_buffer:
196 | add ecx,std_application_base_address
197 | isys_get_buffer: ;for using in kernel
198 | ;eax - subfunction number
199 | ;ebx - physical address
200 | ;ecx - buffer start
201 | ;edx - buffer size
202 | mov edi,ecx
203 | lea esi,[ebx+second_base_address]
204 | mov ecx,edx
205 | rep movsb
206 | ret
207 | sys_internal_services:
208 | cmp eax,4
209 | jle sys_sheduler
210 | cmp eax,5
211 | jz sys_allocate_physical_block
212 | cmp eax,6
213 | jz sys_free_physical_block
214 | cmp eax,7
215 | jz sys_set_buffer
216 | cmp eax,8
217 | jz sys_get_buffer
218 | ret
--------------------------------------------------------------------------------
/core/sched.inc:
--------------------------------------------------------------------------------
1 | label next_usage_update dword at 0xB008
2 | label timer_ticks dword at 0xFDF0
3 |
4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 | ;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 |
8 | align 32
9 | irq0:
10 |
11 | cmp [error_interrupt],-1
12 | je no_error_in_previous_process
13 |
14 | mov edi,[error_interrupt]
15 | shl edi, 3
16 | mov [edi+tss0i_l +5], word 01010000b *256 +11101001b
17 |
18 | mov edi,[error_interrupt]
19 | shl edi,7
20 | add edi,0x290000
21 | mov esi,[error_interrupt_entry]
22 | mov [edi+l.eip-tss_sceleton],esi
23 | mov [edi+l.eflags-tss_sceleton],dword 0x11002
24 |
25 | mov [0xffff],byte 0
26 |
27 | mov [error_interrupt],-1
28 |
29 | no_error_in_previous_process:
30 |
31 | mov edi,[0x3000]
32 | shl edi, 3
33 | ; fields of TSS descriptor:
34 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
35 |
36 | inc dword [timer_ticks]
37 |
38 | mov eax, [timer_ticks]
39 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40 | call playNote ; <<<--- INSERT THIS LINE !!!!!!!!!!
41 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 |
43 | cmp eax,[next_usage_update]
44 | jb .nocounter
45 | add eax,100
46 | mov [next_usage_update],eax
47 | call updatecputimes
48 | .nocounter:
49 |
50 | mov edi, [0x3010]
51 |
52 | mov ebx, [edi+0x18] ; time stamp counter add
53 | call _rdtsc
54 | sub eax, ebx
55 | add eax, [edi+0x14] ; counter sum
56 | mov [edi+0x14], eax
57 |
58 | mov ebx,[0x3000]
59 |
60 | cmp [0xffff], byte 1 ;1
61 | je do_not_change_task ;je
62 |
63 | .waiting_for_termination:
64 | .waiting_for_reuse:
65 | .waiting_on_queue:
66 | add edi,0x20
67 | inc ebx
68 |
69 | mov al, byte [edi+0xA]
70 | cmp al, 3
71 | je .waiting_for_termination
72 | cmp al, 4
73 | je .waiting_for_termination
74 | cmp al, 9
75 | je .waiting_for_reuse
76 | cmp al, 16
77 | je .waiting_on_queue
78 | cmp al, 17
79 | je .waiting_on_queue
80 |
81 | cmp ebx,[0x3004]
82 | jbe nsched0
83 | mov ebx,1
84 | mov edi,0x3020
85 |
86 | nsched0:
87 |
88 | mov [0x3000],ebx
89 | mov [0x3010],edi
90 |
91 | do_not_change_task:
92 |
93 | mov edx,[0x3000]
94 | lea edx,[tss0sys+8*edx]
95 | ;mov [8*0x40+idts+8+0], word 0
96 | mov [8*0x40+idts+8+2],dx
97 | ;mov [8*0x40+idts+8+4],word 11100101b*256
98 | ;mov [8*0x40+idts+8+6], word 0
99 |
100 | call _rdtsc
101 | mov [edi+0x18],eax
102 |
103 | cmp [0xffff],byte 0
104 | je nodecffff
105 | dec byte [0xffff]
106 | nodecffff:
107 |
108 |
109 | shl ebx, 3
110 | xor eax, eax
111 | add ebx, tss0
112 | mov word [0xB004], bx ; selector ;mov [tss_s],bx
113 | mov dword [0xB000], eax ; offset
114 |
115 | mov al,0x20 ; send End Of Interrupt signal
116 | mov dx,0x20
117 | out dx,al
118 | .switch:
119 | jmp pword [0xB000]
120 | inc [context_counter] ;noname & halyavin
121 | jmp irq0
122 |
123 | iglobal
124 | context_counter dd 0 ;noname & halyavin
125 | endg
126 |
127 |
128 | align 4
129 | change_task:
130 |
131 | mov [0xffff],byte 2
132 |
133 | dec dword [timer_ticks] ; because irq0 will increase it
134 |
135 | int 0x20 ; irq0 handler
136 |
137 | ret
138 |
139 |
140 |
141 | align 4
142 | updatecputimes:
143 |
144 | mov eax,[idleuse]
145 | mov [idleusesec],eax
146 | mov [idleuse],dword 0
147 | mov ecx, [0x3004]
148 | mov edi, 0x3020
149 | .newupdate:
150 | mov ebx,[edi+0x14]
151 | mov [edi+0x1c],ebx
152 | mov [edi+0x14],dword 0
153 | add edi,0x20
154 | dec ecx
155 | jnz .newupdate
156 |
157 | ret
158 |
159 |
160 |
161 | ;
162 | ; Wait queue is 16 bytes
163 | ; dd return code +12
164 | ; dd pointer to process +8
165 | ; dd prev +4
166 | ; dd next +0
167 | ;
168 | ; eax - pointer to pointer to the wait queue
169 | ; return:
170 | ; ecx - return code
171 | sleep_on_queue:
172 | sub esp,16 ; reserve space for wait node
173 | mov ecx,esp ; ecx=this_node, [eax]=queue
174 |
175 | pusha
176 |
177 | mov ebx,[0x3010] ; get pointer to the current process
178 | mov [ecx+8],ebx
179 |
180 | pushf
181 | cli ; adding element to the wait queue must be atomic
182 |
183 | mov edi,[eax] ; edi=queue
184 | and edi,edi ; check if queue is empty
185 | jz .is_empty
186 |
187 | ; add element at the end of wait queue
188 |
189 | mov edx,[edi+4] ; get pointer to prev edx=queue->prev
190 | mov [ecx+4],edx ; this_node->prev=queue->prev
191 | mov [ecx+0],edi ; this_node->next=queue
192 | mov [edx+0],ecx ; this_node->prev->next=this_node
193 | mov [edi+4],ecx ; queue->prev=this_node
194 | jmp .added_ok
195 | .is_empty:
196 | ; set this element as first in the queue
197 | mov [ecx+0],ecx ; this_node->next=this_node
198 | mov [ecx+4],ecx ; this_node->prev=this_node
199 | mov [eax],ecx ; [queue]=this_node
200 | .added_ok:
201 |
202 | popf ; we can safely restore interrupts
203 |
204 | mov [ebx+0xa],byte 17 ; set current task state as sleeping
205 | call change_task ; schedule new thread
206 |
207 | ; someone has called wake_up_queue
208 |
209 | pushf ; disable interrupts
210 | cli
211 |
212 | mov edx,[ecx+0] ; edx=this_node->next
213 | mov esi,[ecx+4] ; esi=this_node->prev
214 |
215 | ; check if we need to remove this node from head
216 | cmp [eax],ecx
217 | jne .no_head
218 |
219 | cmp [ecx+0],ecx ; check if queue is empty
220 | jne .not_empty
221 |
222 | mov [eax],dword 0
223 | jmp .no_head
224 |
225 | .not_empty:
226 | mov [eax],edx
227 |
228 | ; remove our node from the queue (this must be atomic)
229 | .no_head:
230 | mov [edx+4],esi ; this_node->next->prev=this_node->prev
231 | mov [esi+0],edx ; this_node->prev->next=this_node->next
232 |
233 | popf
234 | popa
235 | add esp,12
236 | pop ecx
237 | ret
238 |
239 | ; eax - pointer to the wait queue
240 | ; ebx - wake up all (1=yes, 0=no)
241 | ; ecx - return code
242 | ; return:
243 | ; ebx - number of processes woken
244 | wake_up_queue:
245 | and eax,eax
246 | jnz .nz
247 | ret
248 | .nz:
249 | push eax
250 | push ebx
251 | push ecx
252 | push edx
253 | push esi
254 |
255 | pushf
256 | cli
257 |
258 | xor ebx,ebx
259 | mov edx,eax
260 | .wake_loop:
261 |
262 | mov [edx+12],ecx
263 | mov esi,[edx+8]
264 | mov byte [esi+0xa],0
265 | inc ebx
266 |
267 | mov edx,[edx+0]
268 | cmp edx,eax
269 | jne .wake_loop
270 |
271 | and ebx,ebx
272 | jz .wake_up_1
273 |
274 | .return_it:
275 | popf
276 | pop esi
277 | pop edx
278 | pop ecx
279 | add esp,4
280 | pop eax
281 | ret
282 | .wake_up_1:
283 | mov [eax+12],ecx
284 | mov ecx,[eax+8]
285 | mov byte [ecx+0xa],0
286 | jmp .return_it
287 |
--------------------------------------------------------------------------------
/core/sync.inc:
--------------------------------------------------------------------------------
1 | if ~defined sync_inc
2 | sync_inc_fix:
3 | sync_inc fix sync_inc_fix
4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 | ;;Synhronization for MenuetOS. ;;
6 | ;;Author: Halyavin Andrey, halyavin@land.ru ;;
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 |
9 | ;simplest mutex.
10 | macro SimpleMutex name
11 | {
12 | ; iglobal
13 | name dd 0
14 | name#.type = 1
15 | ; endg
16 | }
17 | macro WaitSimpleMutex name
18 | {
19 | local start_wait,ok
20 | start_wait=$
21 | cli
22 | cmp [name],dword 0
23 | jz ok
24 | sti
25 | call change_task
26 | jmp start_wait
27 | ok=$
28 | push eax
29 | mov eax,dword [0x3010+second_base_address]
30 | mov eax,[eax+0x4]
31 | mov [name],eax
32 | pop eax
33 | sti
34 | }
35 | macro ReleaseSimpleMutex name
36 | {
37 | mov [name],dword 0
38 | }
39 | macro TryWaitSimpleMutex name ;result in eax and in flags
40 | {
41 | local ok,try_end
42 | cmp [name],dword 0
43 | jz ok
44 | xor eax,eax
45 | jmp try_end
46 | ok=$
47 | xor eax,eax
48 | inc eax
49 | try_end=$
50 | }
51 | macro SimpleCriticalSection name
52 | {
53 | ; iglobal
54 | name dd 0
55 | dd 0
56 | name#.type=2
57 | ; endg
58 | }
59 | macro WaitSimpleCriticalSection name
60 | {
61 | local start_wait,first_wait,inc_counter,end_wait
62 | push eax
63 | mov eax,[0x3010+second_base_address]
64 | mov eax,[eax+0x4]
65 | start_wait=$
66 | cli
67 | cmp [name],dword 0
68 | jz first_wait
69 | cmp [name],eax
70 | jz inc_counter
71 | sti
72 | call change_task
73 | jmp start_wait
74 | first_wait=$
75 | mov [name],eax
76 | mov [name+4],dword 1
77 | jmp end_wait
78 | inc_counter=$
79 | inc dword [name+4]
80 | end_wait=$
81 | sti
82 | pop eax
83 | }
84 | macro ReleaseSimpleCriticalSection name
85 | {
86 | local release_end
87 | dec dword [name+4]
88 | jnz release_end
89 | mov [name],dword 0
90 | release_end=$
91 | }
92 | macro TryWaitSimpleCriticalSection name ;result in eax and in flags
93 | {
94 | local ok,try_end
95 | mov eax,[0x3000+second_base_address]
96 | mov eax,[eax+0x4]
97 | cmp [name],eax
98 | jz ok
99 | cmp [name],0
100 | jz ok
101 | xor eax,eax
102 | jmp try_end
103 | ok=$
104 | xor eax,eax
105 | inc eax
106 | try_end=$
107 | }
108 | _cli equ call MEM_HeapLock
109 | _sti equ call MEM_HeapUnLock
110 | end if
111 |
112 |
--------------------------------------------------------------------------------
/core/syscall.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; SYSTEM CALL ENTRY ;;
4 | ;; ;;
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 |
7 | align 32
8 | i40:
9 | cli
10 |
11 | mov edi,[0x3000]
12 | mov eax,edi
13 | shl edi, 3
14 | ;clear busy flag in application's TSS
15 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
16 |
17 | ;save GDT TSS entry
18 | mov edx,[edi+tss0_l]
19 | mov [reg1+eax*4],edx
20 | mov edx,[edi+tss0_l+4]
21 | mov [reg2+eax*4],edx
22 | ;and then write there i40's descriptor
23 | mov edx,[tss0sys_l+edi]
24 | mov [edi+tss0_l],edx
25 | mov edx,[tss0sys_l+edi+4]
26 | mov [edi+tss0_l+4],edx
27 |
28 |
29 | shl edi,5
30 | mov [edi+0x80000+0xB0],eax ; used i40 handler
31 |
32 | ; for syscall trace function
33 | call save_registers
34 |
35 | mov esi, [0x3000]
36 | imul esi, tss_step
37 | add esi, tss_data
38 | ; esi holds address of TSS of interupted program
39 | ; load first 3 registers
40 | mov eax,[esi+l.eax-tss_sceleton]
41 | mov ebx,[esi+l.ebx-tss_sceleton]
42 | mov ecx,[esi+l.ecx-tss_sceleton]
43 |
44 | ; save current registers
45 | ; stack may be modified by a system function to return some value to caller!
46 | pushad
47 |
48 | ; load all registers from TSS of the application, in crossed order (why?)
49 | mov edi,[esi+l.eax-tss_sceleton]
50 | mov eax,[esi+l.ebx-tss_sceleton]
51 | mov ebx,[esi+l.ecx-tss_sceleton]
52 | mov ecx,[esi+l.edx-tss_sceleton]
53 | mov edx,[esi+l.esi-tss_sceleton]
54 | mov esi,[esi+l.edi-tss_sceleton]
55 |
56 | ; enable interupts - a task switch or an IRQ _CAN_ interrupt i40 handler
57 | sti
58 | ; eax doesn't need to be saved, but...
59 | push eax
60 | and edi,0xff
61 | call dword [servetable+edi*4]
62 | pop eax
63 | cli
64 |
65 | ; return saved and probably even changed regs
66 | popad
67 |
68 | ; esi already loaded - look above "pusha"
69 | ;mov esi,[0x3000]
70 | ;imul esi,tss_step
71 | ;add esi,tss_data
72 | ;
73 |
74 | ; modify 3 program's registers (in its TSS)
75 | mov [esi+l.eax-tss_sceleton], eax
76 | mov [esi+l.ebx-tss_sceleton], ebx
77 | mov [esi+l.ecx-tss_sceleton], ecx
78 |
79 | ; calculate app's TSS address
80 | mov ebx, [0x3000]
81 | shl ebx, 3
82 | add ebx, tss0_l
83 |
84 | mov ecx, [0x3000]
85 |
86 | ; restore saved TSS descriptor
87 | mov eax, [reg1+ecx*4]
88 | mov [ebx], eax
89 | mov eax, [reg2+ecx*4]
90 | mov [ebx+4], eax
91 |
92 | xor eax, eax
93 | mov edi, [0x3000] ; no syscall interrupt in use anymore
94 | shl edi, 8
95 | mov [edi+0x80000+0xB0],eax
96 |
97 | ; clear busy flag in TSS of this handler
98 | mov edi, [0x3000]
99 | shl edi, 3
100 | mov [edi+tss0sys_l +5], word 01010000b *256 +11101001b
101 |
102 | add edi,tss0
103 | mov [0xB004], di
104 |
105 | jmp pword [0xB000]
106 |
107 | jmp i40
108 |
109 | label reg1 dword at 0x6000
110 | label reg2 dword at 0x6400
111 | label usedi40 byte at 0x6800
112 |
113 | uglobal
114 | schd dd 0x0
115 | endg
116 |
117 | align 4
118 | save_registers:
119 |
120 | mov esi,[0x3000]
121 | imul esi,tss_step
122 | add esi,tss_data
123 |
124 | mov eax,[esi+l.eax-tss_sceleton]
125 | mov ebx,[esi+l.ebx-tss_sceleton]
126 | mov ecx,[esi+l.ecx-tss_sceleton]
127 | mov edx,[esi+l.edx-tss_sceleton]
128 | mov edi,[esi+l.edi-tss_sceleton]
129 | mov ebp,[esi+l.ebp-tss_sceleton]
130 |
131 | mov esi,[esi+l.esi-tss_sceleton]
132 |
133 | push eax ecx esi edi
134 | mov esi,[0x3010]
135 | mov eax,[esi+0x4]
136 | mov esi,esp
137 | inc [save_syscall_count]
138 | mov edi,[save_syscall_count]
139 | and edi,0xF
140 | shl edi,6
141 | add edi,save_syscall_data+32
142 | mov [edi-32],eax
143 | mov ecx,32 / 4
144 | cld
145 | rep movsd
146 | pop edi esi ecx eax
147 | ret
148 |
149 | uglobal
150 | save_syscall_count dd 0x0
151 | endg
152 |
153 | label save_syscall_data dword at 0x5000
154 |
155 |
156 | iglobal
157 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
158 | ;; SYSTEM FUNCTIONS TABLE ;;
159 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
160 |
161 | align 4
162 | servetable:
163 |
164 | dd sys_drawwindow ; 0-DrawWindow
165 | dd syscall_setpixel ; 1-SetPixel
166 | dd sys_getkey ; 2-GetKey
167 | dd sys_clock ; 3-GetTime
168 | dd syscall_writetext ; 4-WriteText
169 | dd delay_hs ; 5-DelayHs
170 | dd syscall_openramdiskfile ; 6-OpenRamdiskFile
171 | dd syscall_putimage ; 7-PutImage
172 | dd sys_button ; 8-DefineButton
173 | dd sys_cpuusage ; 9-GetProcessInfo
174 | dd sys_waitforevent ; 10-WaitForEvent
175 | dd sys_getevent ; 11-CheckForEvent
176 | dd sys_redrawstat ; 12-BeginDraw and EndDraw
177 | dd syscall_drawrect ; 13-DrawRect
178 | dd syscall_getscreensize ; 14-GetScreenSize
179 | dd sys_background ; 15-bgr
180 | dd sys_cachetodiskette ; 16-FlushFloppyCache
181 | dd sys_getbutton ; 17-GetButton
182 | dd syscall_system ; 18-Shutdown,KillApp,WindowActivate
183 | dd syscall_startapp ; 19-StartApp
184 | dd sys_midi ; 20-ResetMidi and OutputMidi
185 | dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
186 | dd sys_settime ; 22-setting date,time,clock and alarm-clock
187 | dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
188 | dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist
189 | dd sys_sb16 ; 25-SetSb16
190 | dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
191 | dd sys_wss ; 27-SetWssMainVol and SetWssCdVol
192 | dd sys_sb16II ; 28-SetSb16
193 | dd sys_date ; 29-GetDate
194 | dd syscall_readhd ; 30-ReadHd
195 | dd syscall_starthdapp ; 31-StartHdApp
196 | dd syscall_delramdiskfile ; 32-DelRamdiskFile
197 | dd syscall_writeramdiskfile; 33-WriteRamdiskFile
198 | dd read_floppy_file ; 34-ReadFloppyDrive
199 | dd syscall_getpixel ; 35-GetPixel
200 | dd syscall_readstring ; 36-ReadString (not yet ready)
201 | dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
202 | dd syscall_drawline ; 38-DrawLine
203 | dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
204 | dd set_app_param ; 40-WantEvents
205 | dd syscall_getirqowner ; 41-GetIrqOwner
206 | dd get_irq_data ; 42-ReadIrqData
207 | dd sys_outport ; 43-SendDeviceData
208 | dd sys_programirq ; 44-ProgramIrqs
209 | dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
210 | dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
211 | dd display_number ; 47-WriteNum
212 | dd display_settings ; 48-SetRedrawType and SetButtonType
213 | dd syscall_appints ; 49-AppInts
214 | dd random_shaped_window ; 50-Window shape & scale
215 | dd syscall_threads ; 51-Threads
216 | dd stack_driver_stat ; 52-Stack driver status
217 | dd socket ; 53-Socket interface
218 | dd user_events ; 54-User events
219 | dd sound_interface ; 55-Sound interface
220 | dd write_to_hd ; 56-Write a file to hd
221 | dd delete_from_hd ; 57-Delete a file from hd
222 | dd file_system ; 58-Common file system interface
223 | dd sys_trace ; 59-System call trace
224 | dd new_sys_ipc ; 60-Inter Process Communication
225 | dd sys_gs ; 61-Direct graphics access
226 | dd sys_pci ; 62-PCI functions
227 | dd sys_msg_board ; 63-System message board
228 | dd sys_resize_app_memory ; 64-Resize application memory usage
229 | dd undefined_syscall ; 65-UTF
230 | dd sys_process_def ; 66-Process definitions - keyboard
231 | dd sys_window_move ; 67-Window move or resize
232 | dd sys_internal_services ; 68-Some internal services
233 |
234 | times 255 - ( ($-servetable) /4 ) dd undefined_syscall
235 |
236 | dd sys_end ; -1-end application
237 | endg
238 |
239 |
--------------------------------------------------------------------------------
/detect/commouse.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/detect/commouse.inc
--------------------------------------------------------------------------------
/detect/dev_fd.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/detect/dev_fd.inc
--------------------------------------------------------------------------------
/detect/dev_hdcd.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/detect/dev_hdcd.inc
--------------------------------------------------------------------------------
/detect/disks.inc:
--------------------------------------------------------------------------------
1 | include 'dev_fd.inc'
2 | include 'dev_hdcd.inc'
3 | include 'sear_par.inc'
4 |
5 |
--------------------------------------------------------------------------------
/detect/sear_par.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/detect/sear_par.inc
--------------------------------------------------------------------------------
/fs/fat12.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/fs/fat12.inc
--------------------------------------------------------------------------------
/fs/fat32.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/fs/fat32.inc
--------------------------------------------------------------------------------
/fs/fs.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/fs/fs.inc
--------------------------------------------------------------------------------
/fs/fs_phys.inc:
--------------------------------------------------------------------------------
1 | hd_phys_read:
2 | ;eax - sector number
3 | ;ebx - destination
4 | pushad
5 | call wait_for_hd_idle
6 | popad
7 | push edx
8 | push eax
9 | cli
10 | xor eax,eax
11 | mov edx,[hdbase]
12 | inc edx
13 | out dx,al
14 | inc edx
15 | inc eax
16 | out dx,al
17 | inc edx
18 | ;write sector number.
19 | mov eax,[esp]
20 | out dx,al
21 | shr eax,8
22 | inc edx
23 | out dx,al
24 | shr eax,8
25 | inc edx
26 | out dx,al
27 | shr eax,8
28 | inc edx
29 | and al,1+2+4+8
30 | add al,byte [hdid] ;+0 or +16
31 | or al,32+64+128
32 | out dx,al
33 | inc edx
34 | mov al,0x20
35 | out dx,al
36 | sti
37 |
38 | call wait_for_sector_buffer
39 | cmp [hd_error],0
40 | jnz hd_read_error
41 | cli
42 | push edi
43 | mov edi,ebx
44 | mov ecx,256
45 | mov edx,[hdbase]
46 | cld
47 | rep insw
48 | pop edi
49 | sti
50 | pop edx
51 | pop eax
52 | ret
53 |
54 | hd_phys_write:
55 | ;eax - sector number
56 | ;ebx - destination
57 | cmp eax,[partition_start]
58 | jb .ret
59 | cmp eax,[partition_end]
60 | ja .ret
61 | pushad
62 | call wait_for_hd_idle
63 | popad
64 | push edx
65 | push eax
66 | cli
67 | xor eax,eax
68 | mov edx,[hdbase]
69 | inc edx
70 | out dx,al
71 | inc edx
72 | inc eax
73 | out dx,al
74 | ;write sector number
75 | inc edx
76 | mov eax,[esp]
77 | out dx,al
78 | shr eax,8
79 | inc edx
80 | out dx,al
81 | shr eax,8
82 | inc edx
83 | out dx,al
84 | shr eax,8
85 | inc edx
86 | and al,1+2+4+8
87 | add al,byte [hdid] ;+0 or +16
88 | or al,32+64+128
89 | out dx,al
90 |
91 | inc edx
92 | mov al,0x30
93 | out dx,al
94 | sti
95 |
96 | call wait_for_sector_buffer
97 | cmp [hd_error],0
98 | jnz hd_write_error
99 | cli
100 | push esi
101 | mov esi,ebx
102 | mov ecx,256
103 | mov edx,[hdbase]
104 | cld
105 | rep outsw
106 | pop esi
107 | sti
108 | pop edx
109 | pop eax
110 | .ret:
111 | ret
--------------------------------------------------------------------------------
/gui/button.inc:
--------------------------------------------------------------------------------
1 | max_buttons=4095
2 | dececx:
3 |
4 | push eax
5 | push edx
6 | push ecx
7 |
8 | mov edx,1
9 | dececl:
10 |
11 | movzx eax,byte [esp+edx]
12 | cmp eax,0x20
13 | jge @f
14 | mov [esp+edx],byte 0x20
15 | @@:
16 | sub [esp+edx],byte 0x20
17 |
18 | add edx,1
19 | cmp edx,4
20 | jbe dececl
21 |
22 | pop ecx
23 | pop edx
24 | pop eax
25 | ret
26 |
27 |
28 | drawbuttonframes:
29 |
30 | push esi
31 | push edi
32 | push eax
33 | push ebx
34 | push ecx
35 | push edx
36 |
37 | shr eax,16
38 | shr ebx,16
39 | mov edx,[0x3010]
40 |
41 | add eax,[edx-twdw]
42 | add ebx,[edx-twdw+4]
43 | mov cx,ax
44 | mov dx,bx
45 | shl eax,16
46 | shl ebx,16
47 | mov ax,cx
48 | mov bx,dx
49 | add ax,word [esp+12]
50 | mov esi,ebx
51 | mov edi,0
52 | mov ecx,[esp+0]
53 | add ecx,0x202020
54 | call [draw_line]
55 |
56 | movzx edx,word [esp+8]
57 | add ebx,edx
58 | shl edx,16
59 | add ebx,edx
60 | mov ecx,[esp+0]
61 | call dececx
62 | call [draw_line]
63 |
64 | mov ebx,esi
65 | push edx
66 | mov edx,eax
67 | shr edx,16
68 | mov ax,dx
69 | mov edx,ebx
70 | shr edx,16
71 | mov bx,dx
72 | mov dx,[esp+8+4]
73 | add bx,dx
74 | pop edx
75 | mov edi,0
76 | mov ecx,[esp+0]
77 | add ecx,0x202020
78 | call [draw_line]
79 |
80 | mov esi,edx
81 | mov dx,[esp+12]
82 | add ax,dx
83 | shl edx,16
84 | add eax,edx
85 | add ebx,1*65536
86 | mov edx,esi
87 | mov ecx,[esp+0]
88 | call dececx
89 | call [draw_line]
90 |
91 | pop edx
92 | pop ecx
93 | pop ebx
94 | pop eax
95 | pop edi
96 | pop esi
97 |
98 | ret
99 |
100 | button_dececx:
101 |
102 | cmp [buttontype],dword 1
103 | jne .finish
104 | ; je bdece
105 | ; ret
106 | ; bdece:
107 | push eax
108 | mov eax,0x01
109 | cmp edi,20
110 | jg @f
111 | mov eax,0x02
112 | @@:
113 | test ecx,0xff
114 | jz @f
115 | sub ecx,eax
116 | @@:
117 | shl eax,8
118 | test ecx,0xff00
119 | jz @f
120 | sub ecx,eax
121 | @@:
122 | shl eax,8
123 | test ecx,0xff0000
124 | jz @f
125 | sub ecx,eax
126 | @@:
127 | pop eax
128 | .finish:
129 | ret
130 |
131 |
132 | sys_button:
133 |
134 | test ecx,0x80000000
135 | jnz remove_button
136 |
137 | push esi
138 | push edi
139 | push eax
140 | push ebx
141 | push ecx
142 | push edx
143 |
144 | test ecx,0x40000000
145 | jnz button_no_draw
146 |
147 | pushad ; button body
148 | push ebx
149 | shr eax,16
150 | shr ebx,16
151 | mov edx,[0x3010]
152 | mov esi,[edx-twdw]
153 | mov edi,[edx-twdw+4]
154 | add eax,esi
155 | add ebx,edi
156 | mov cx,ax
157 | mov dx,bx
158 | shl eax,16
159 | shl ebx,16
160 | mov ax,cx
161 | mov bx,dx
162 | movzx ecx,word [4+32+esp+12]
163 | add eax,ecx
164 | mov ecx,[4+32+esp+0]
165 | cmp [buttontype],dword 0
166 | je @f
167 | add ecx,0x141414
168 | @@:
169 | movzx edi,word [esp]
170 |
171 | ;
172 | pop edx
173 | and edx, 0xFFFF
174 | ;;cli
175 | .newline:
176 | call button_dececx
177 | push edi
178 | xor edi, edi
179 | call [draw_line]
180 | pop edi
181 | add ebx,1*65536+1 ; [ y start | y end ]
182 | dec edx
183 | jnz .newline
184 | ;;sti
185 | ;; pop ebx
186 | ;
187 | popad
188 |
189 | call drawbuttonframes
190 |
191 | button_no_draw:
192 |
193 | and ecx,0xffff
194 |
195 | mov edi,[0x3010]
196 | sub edi,twdw
197 |
198 | mov edi,[0xfe88]
199 | movzx eax,word [edi]
200 | cmp eax,max_buttons
201 | jge noaddbutt
202 | inc eax
203 | mov [edi],ax
204 |
205 | shl eax,4
206 | add eax,edi
207 |
208 | mov bx,[0x3000]
209 | mov [eax],bx
210 |
211 | add eax,2 ; save button id number
212 | mov ebx,[esp+4]
213 | mov [eax],bx ; bits 0-15
214 | shr ebx,16
215 | mov [eax-2+0xc],bx; bits 16-31
216 | add eax,2 ; x start
217 | mov bx,[esp+12+2]
218 | mov [eax],bx
219 | add eax,2 ; x size
220 | mov bx,[esp+12+0]
221 | mov [eax],bx
222 | add eax,2 ; y start
223 | mov bx,[esp+8+2]
224 | mov [eax],bx
225 | add eax,2 ; y size
226 | mov bx,[esp+8+0]
227 | mov [eax],bx
228 |
229 | noaddbutt:
230 |
231 | pop edx
232 | pop ecx
233 | pop ebx
234 | pop eax
235 | pop edi
236 | pop esi
237 |
238 | ret
239 |
240 |
241 | remove_button:
242 |
243 | and ecx,0x7fffffff
244 |
245 | rnewba2:
246 |
247 | mov edi,[0xfe88]
248 | mov eax,edi
249 | movzx ebx,word [edi]
250 | inc bx
251 |
252 | rnewba:
253 |
254 | dec bx
255 | jz rnmba
256 |
257 | add eax,0x10
258 |
259 | mov dx,[0x3000]
260 | cmp dx,[eax]
261 | jnz rnewba
262 |
263 | cmp cx,[eax+2]
264 | jnz rnewba
265 |
266 | pushad
267 | mov ecx,ebx
268 | inc ecx
269 | shl ecx,4
270 | mov ebx,eax
271 | add eax,0x10
272 | call memmove
273 | dec dword [edi]
274 | popad
275 |
276 | jmp rnewba2
277 |
278 | rnmba:
279 |
280 | ret
281 |
282 | find_pressed_button_frames:
283 |
284 | pushad
285 |
286 | movzx ebx,word [eax+0]
287 | shl ebx,5
288 | add ebx,window_data
289 | movzx ecx,word [ebx+0] ; window x start
290 | movzx edx,word [eax+4] ; button x start
291 | add ecx,edx
292 | push ecx
293 |
294 | mov dx,[eax+6] ; button x size
295 | add cx,dx
296 | mov esi,ecx
297 | inc esi
298 | mov cx,[ebx+4] ; window y start
299 | mov dx,[eax+8] ; button y start
300 | add ecx,edx
301 | mov ebx,ecx
302 | mov dx,[eax+10] ; button y size
303 | add dx,cx
304 | inc dx
305 |
306 | pop eax
307 |
308 | ; eax x beginning
309 | ; ebx y beginning
310 | ; esi x end
311 | ; edx y end
312 | ; ecx color
313 |
314 | mov [pressed_button_eax],eax
315 | mov [pressed_button_ebx],ebx
316 | mov [pressed_button_ecx],ecx
317 | mov [pressed_button_edx],edx
318 | mov [pressed_button_esi],esi
319 |
320 | popad
321 | ret
322 |
323 | uglobal
324 | pressed_button_eax dd 0
325 | pressed_button_ebx dd 0
326 | pressed_button_ecx dd 0
327 | pressed_button_edx dd 0
328 | pressed_button_esi dd 0
329 | endg
330 |
331 | ; negative button image
332 |
333 | negativebutton:
334 | ; If requested, do not display button
335 | ; boarder on press.
336 | test ebx,0x20000000
337 | jz draw_negative_button
338 | ret
339 | draw_negative_button:
340 |
341 | pushad
342 |
343 | mov eax,[pressed_button_eax]
344 | mov ebx,[pressed_button_ebx]
345 | mov ecx,[pressed_button_ecx]
346 | mov edx,[pressed_button_edx]
347 | mov esi,[pressed_button_esi]
348 | mov ecx,0x01000000
349 |
350 | dec edx
351 | push edx
352 | inc edx
353 | dec esi
354 | push esi
355 | inc esi
356 |
357 | push eax
358 | push ebx
359 | push ecx
360 | push edx
361 | push edi
362 |
363 | call [disable_mouse]
364 |
365 | bdbnewline:
366 | mov edi,1 ; force
367 | cmp eax,[esp+16]
368 | jz bneg
369 | cmp eax,[esp+20]
370 | jz bneg
371 | cmp ebx,[esp+12]
372 | jz bneg
373 | cmp ebx,[esp+24]
374 | jnz nbneg
375 | ; jz bneg
376 | ; jmp nbneg
377 |
378 | bneg:
379 |
380 | ;;;call [disable_mouse]
381 | call [putpixel]
382 |
383 | nbneg:
384 |
385 | inc eax
386 | cmp eax,esi
387 | jnz bdbnewline
388 | mov eax,[esp+16]
389 | inc ebx
390 | cmp ebx,edx
391 | jnz bdbnewline
392 |
393 | add esp,28
394 |
395 | popad
396 |
397 | ret
398 |
399 | ; check buttons
400 |
401 |
402 | ; 0000 word process number
403 | ; 0002 word button id number : bits 0-15
404 | ; 0004 word x start
405 | ; 0006 word x size
406 | ; 0008 word y start
407 | ; 000A word y size
408 | ; 000C word button id number : bits 16-31
409 | ;
410 | ; button table in 0x10 increments
411 | ;
412 | ; first at 0x10
413 |
414 |
415 | checkbuttons:
416 |
417 | cmp [0xfb40],byte 0 ; mouse buttons pressed
418 | jnz @f
419 | ret
420 | @@:
421 |
422 | pushad
423 |
424 | xor esi, esi
425 | mov edi, [0xfe88]
426 | movzx edx, word [edi]
427 | test edx, edx
428 | jne @f
429 | popad
430 | ret
431 |
432 | @@:
433 |
434 | push esi
435 | inc edx
436 | push edx
437 |
438 | buttonnewcheck:
439 |
440 | pop edx
441 | pop esi
442 | inc esi
443 | cmp edx,esi
444 | jge bch
445 |
446 | popad ; no button pressed
447 | ret
448 |
449 | bch:
450 |
451 | push esi
452 | push edx
453 | mov eax,esi
454 | shl eax,4
455 | add eax,edi
456 |
457 | ; check that button is at top of windowing stack
458 |
459 | movzx ebx,word [eax]
460 | movzx ecx,word [0xC000 + ebx * 2]
461 | cmp ecx,[0x3004]
462 | jne buttonnewcheck
463 |
464 | ; check that button start is inside window x/y end
465 |
466 | movzx ebx,word [eax+0]
467 | shl ebx,5
468 | ; add ebx,window_data
469 | ; mov ecx,[window_data+ebx+8] ; window end X
470 | movzx edx,word [eax+4] ; button start X
471 | cmp edx, [window_data+ebx+8] ;ecx
472 | jge buttonnewcheck
473 |
474 | ; mov ecx,[window_data+ebx+12] ; window end Y
475 | movzx edx, word [eax+8] ; button start Y
476 | cmp edx, [window_data+ebx+12] ;ecx
477 | jge buttonnewcheck
478 |
479 | ; check coordinates
480 | ; mouse x >= button x ?
481 | movzx ebx,word [eax+0]
482 | shl ebx,5
483 | add ebx,window_data
484 | movzx ecx,word [ebx+0] ; window x start
485 | movzx edx,word [eax+4] ; button x start
486 | add edx,ecx
487 | mov cx,[0xfb0a]
488 | cmp edx,ecx
489 | jg buttonnewcheck
490 |
491 | movzx ebx,word [eax+6] ; button x size
492 | add edx,ebx
493 | cmp ecx,edx
494 | jg buttonnewcheck
495 |
496 | ; mouse y >= button y ?
497 | movzx ebx,word [eax+0]
498 | shl ebx,5
499 | add ebx,window_data
500 | movzx ecx,word [ebx+4] ; window y start
501 | movzx edx,word [eax+8] ; button y start
502 | add edx,ecx
503 | mov cx,[0xfb0c]
504 | cmp edx,ecx
505 | jg buttonnewcheck
506 |
507 | movzx ebx,word [eax+10] ; button y size
508 | add edx,ebx
509 | cmp ecx,edx
510 | jg buttonnewcheck
511 |
512 | ; mouse on button
513 |
514 | pop edx
515 | pop esi
516 |
517 | mov bx,[eax+0xc] ; button id : bits 16-31
518 | shl ebx,16
519 | mov bx,[eax+2] ; button id : bits 00-16
520 | push ebx
521 |
522 | mov [0xfb44],byte 1 ; no mouse down checks
523 | call find_pressed_button_frames
524 | call negativebutton
525 |
526 | pushad
527 | cbwaitmouseup:
528 |
529 | call checkidle
530 |
531 | call check_mouse_data
532 | call [draw_pointer]
533 |
534 | pushad
535 | call stack_handler
536 | popad
537 |
538 | cmp [0xfb40],byte 0 ; mouse buttons pressed ?
539 | jnz cbwaitmouseup
540 | popad
541 |
542 | call negativebutton
543 | mov [0xfff4],byte 0 ; no mouse background
544 | mov [0xfff5],byte 0 ; draw mouse
545 | mov [0xf500],byte 1
546 | pop ebx
547 | mov [0xf501],ebx
548 | mov [0xfb44],byte 0 ; mouse down checks
549 | popad
550 | ret
551 |
552 |
--------------------------------------------------------------------------------
/gui/event.inc:
--------------------------------------------------------------------------------
1 | sys_getevent:
2 |
3 | call get_event_for_app
4 | mov [esp+36],eax
5 | ret
6 |
7 |
8 | align 4
9 |
10 | sys_wait_event_timeout:
11 |
12 | mov ebx,[timer_ticks];[0xfdf0]
13 | add ebx,eax
14 | cmp ebx,[timer_ticks];[0xfdf0]
15 | jna .swfet2
16 | .swfet1:
17 | call get_event_for_app
18 | test eax,eax
19 | jne .eventoccur_time
20 | call change_task
21 | cmp ebx,[timer_ticks];[0xfdf0]
22 | jg .swfet1
23 | .swfet2:
24 | xor eax,eax
25 | .eventoccur_time:
26 | mov [esp+36],eax
27 | ret
28 |
29 |
30 | align 4
31 |
32 | sys_waitforevent:
33 |
34 | call get_event_for_app
35 | test eax,eax
36 | jne eventoccur
37 | newwait:
38 |
39 | call change_task
40 | call get_event_for_app
41 | test eax,eax
42 | je newwait
43 |
44 | eventoccur:
45 | mov [esp+36],eax
46 | ret
47 |
48 |
49 | get_event_for_app:
50 |
51 | pushad
52 |
53 | mov edi,[0x3010] ; WINDOW REDRAW
54 | test [edi],dword 1
55 | jz no_eventoccur1
56 | mov edi,[0x3010]
57 | cmp [edi-twdw+31],byte 0
58 | je no_eventoccur1
59 | popad
60 | mov eax,1
61 | ret
62 | no_eventoccur1:
63 |
64 | mov edi,[0x3010] ; KEY IN BUFFER
65 | test [edi],dword 2
66 | jz no_eventoccur2
67 | mov ecx, [0x3000]
68 | movzx edx,word [0xC000+ecx*2]
69 | mov eax, [0x3004]
70 | cmp eax,edx
71 | jne no_eventoccur2
72 | cmp [0xf400],byte 0
73 | je no_eventoccur2
74 | popad
75 | mov eax,2
76 | ret
77 | no_eventoccur2:
78 |
79 | mov edi,[0x3010] ; BUTTON IN BUFFER
80 | test [edi],dword 4
81 | jz no_eventoccur3
82 | mov ecx, [0x3000]
83 | movzx edx, word [0xC000+ecx*2]
84 | mov eax, [0x3004]
85 | cmp eax,edx
86 | jnz no_eventoccur3
87 | cmp [0xf500],byte 0
88 | je no_eventoccur3
89 | popad
90 | mov eax,[0xf501]
91 | cmp eax,65535
92 | je no_event_1
93 | mov eax,3
94 | ret
95 |
96 | no_event_1:
97 | mov [window_minimize],1
98 | mov [0xf500],byte 0
99 | xor eax, eax
100 | ret
101 |
102 | no_eventoccur3:
103 |
104 | mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW
105 | test [edi],dword 16
106 | jz no_eventoccur5
107 | cmp [0xfff0],byte 2
108 | jnz no_eventoccur5
109 | popad
110 | mov eax,5
111 | ret
112 | no_eventoccur5:
113 |
114 | mov edi,[0x3010] ; mouse event
115 | test [edi],dword 00100000b
116 | jz no_mouse_event
117 | mov edi,[0x3000]
118 | shl edi,8
119 | test [edi+0x80000+0xA8],dword 00100000b
120 | jz no_mouse_event
121 | and [edi+0x80000+0xA8],dword 0xffffffff-00100000b
122 | popad
123 | mov eax,6
124 | ret
125 | no_mouse_event:
126 |
127 | mov edi,[0x3010] ; IPC
128 | test [edi],dword 01000000b
129 | jz no_ipc
130 | mov edi,[0x3000]
131 | shl edi,8
132 | test [edi+0x80000+0xA8],dword 01000000b
133 | jz no_ipc
134 | and [edi+0x80000+0xA8],dword 0xffffffff-01000000b
135 | popad
136 | mov eax,7
137 | ret
138 | no_ipc:
139 |
140 |
141 | mov edi,[0x3010] ; STACK
142 | test [edi],dword 10000000b
143 | jz no_stack_event
144 | mov edi,[0x3000]
145 | shl edi,8
146 | test [edi+0x80000+0xA8],dword 10000000b
147 | jz no_stack_event
148 | and [edi+0x80000+0xA8],dword 0xffffffff-10000000b
149 | popad
150 | mov eax,7
151 | ret
152 | no_stack_event:
153 |
154 |
155 | mov esi,0x2e0000 ; IRQ'S AND DATA
156 | mov ebx,0x00010000
157 | xor ecx, ecx
158 | irq_event_test:
159 | mov edi,[0x3010]
160 | test [edi],ebx
161 | jz no_irq_event
162 | mov edi,ecx
163 | shl edi,2
164 | add edi,irq_owner
165 | mov edx,[edi]
166 | mov eax,[0x3010]
167 | mov eax,[eax+0x4]
168 | cmp edx,eax
169 | jne no_irq_event
170 | cmp [esi],dword 0
171 | jz no_irq_event
172 | mov eax,ecx
173 | add eax,16
174 | mov [esp+28],eax
175 | popad
176 | ret
177 | no_irq_event:
178 | add esi,0x1000
179 | shl ebx,1
180 | inc ecx
181 | cmp ecx,16
182 | jb irq_event_test
183 |
184 | popad
185 | xor eax, eax
186 | ret
187 |
188 |
189 |
--------------------------------------------------------------------------------
/gui/font.inc:
--------------------------------------------------------------------------------
1 | align 4
2 | dtext:
3 | ; eax x & y
4 | ; ebx font ( 0xX0000000 ) & color ( 0x00RRGGBB )
5 | ; ecx start of text
6 | ; edx length
7 | ; edi 1 force
8 |
9 | test ebx,0x10000000
10 | jnz dtext2
11 |
12 | pushad
13 |
14 | mov esi, edx
15 | and esi, 0xff
16 | test esi, esi ; zero length ?
17 | jnz @f
18 | popad
19 | ret
20 | @@:
21 | align 4
22 | .letnew:
23 |
24 | push eax ecx edx
25 | movzx ebx,ax
26 | shr eax,16
27 | movzx edx,byte [ecx]
28 | mov ecx,[esp+3*4+32-16]
29 | call drawletter
30 | pop edx ecx eax
31 |
32 | add eax,6*65536
33 |
34 | inc ecx
35 | dec edx
36 | jnz .letnew
37 |
38 | popad
39 | ret
40 |
41 | align 4
42 | drawletter:
43 |
44 | ; eax x
45 | ; ebx y
46 | ; ecx color
47 | ; edx letter
48 | ; esi shl size
49 | ; edi force
50 |
51 | pushad
52 | call [disable_mouse]
53 | xor eax, eax
54 | xor ebx, ebx ; 0x37000+eax+ebx*8
55 | inc esi
56 | align 4
57 | chc:
58 |
59 | push eax
60 | push ebx
61 |
62 | mov edx,ebx
63 | shl edx,3
64 | add edx,eax
65 | add edx,0x37000+8
66 | mov ecx,[esp+32-12+8]
67 | imul ecx,8*10
68 | add edx,ecx
69 | cmp [edx],byte 'o'
70 | jnz .nopix
71 | mov eax,[esp+4]
72 | mov ebx,[esp+0]
73 | add eax,[esp+32+2*4-4]
74 | add ebx,[esp+32+2*4-16]
75 | mov ecx,[esp+32+2*4-8]
76 | ;;;call [disable_mouse]
77 | call [putpixel]
78 | .nopix:
79 | pop ebx
80 | pop eax
81 |
82 | inc eax
83 | cmp eax,5 ; ebp
84 | jne chc
85 |
86 | xor eax, eax
87 |
88 | inc ebx
89 | cmp ebx,9 ; ebp
90 | jne chc
91 |
92 | popad
93 | ret
94 |
95 |
96 | dtext2:
97 |
98 | ; eax x & y
99 | ; ebx color
100 | ; ecx start of text
101 | ; edx length
102 | ; edi 1 force
103 |
104 | pushad
105 |
106 | mov esi,edx
107 | and esi,0xff
108 | test esi,esi ; zero length ?
109 | jnz @f
110 | popad
111 | ret
112 | @@:
113 |
114 | align 4
115 | letnew2:
116 |
117 | push eax
118 | push ecx
119 | push edx
120 | movzx ebx,ax
121 | shr eax,16
122 | movzx edx,byte [ecx]
123 | mov ecx,[esp+3*4+32-16]
124 | call drawletter2
125 | pop edx
126 | pop ecx
127 | pop eax
128 |
129 | push edx
130 | movzx edx,byte [ecx]
131 | imul edx,10*10
132 | add edx,0x30000
133 | cmp [edx+6],byte ' '
134 | jne nocharadd8
135 | add eax,8*65536
136 | jmp charaddok
137 | nocharadd8:
138 | movzx edx,byte [edx+6]
139 | sub edx,47
140 | shl edx,16
141 | add eax,edx
142 | charaddok:
143 | pop edx
144 |
145 | inc ecx
146 | dec edx
147 | jnz letnew2
148 |
149 | popad
150 | ret
151 |
152 | align 4
153 | drawletter2:
154 |
155 | ; eax x
156 | ; ebx y
157 | ; ecx color
158 | ; edx letter
159 | ; esi shl size
160 | ; edi force
161 |
162 | pushad
163 | call [disable_mouse]
164 | xor eax, eax
165 | xor ebx, ebx ; +eax+ebx*8
166 | inc esi
167 |
168 | align 4
169 | chc2:
170 |
171 | push eax
172 | push ebx
173 |
174 | ; cmp esi,1
175 | ; je noldiv
176 | ; xor edx,edx
177 | ; div esi
178 | ; push eax
179 | ; xor edx,edx
180 | ; mov eax,ebx
181 | ; div esi
182 | ; mov ebx,eax
183 | ; pop eax
184 | ; noldiv:
185 |
186 | mov edx,ebx
187 | ;shl edx,3
188 | imul edx,10
189 | add edx,eax
190 | add edx,0x30000+8+2
191 | mov ecx,[esp+32-12+8]
192 | ;shl ecx,6
193 | imul ecx,10*10
194 | add edx,ecx
195 | cmp [edx],byte 'o'
196 | jnz nopix2
197 | mov eax,[esp+4]
198 | mov ebx,[esp+0]
199 | add eax,[esp+32+2*4-4]
200 | add ebx,[esp+32+2*4-16]
201 | mov ecx,[esp+32+2*4-8]
202 | ;;;call [disable_mouse]
203 | call [putpixel]
204 | nopix2:
205 | pop ebx
206 | pop eax
207 |
208 | ;mov ebp,7
209 | ;imul ebp,esi
210 |
211 | inc eax
212 | cmp eax,7 ;ebp
213 | jnz chc2
214 |
215 | xor eax, eax
216 |
217 | ;mov ebp,9
218 | ;imul ebp,esi
219 |
220 | inc ebx
221 | cmp ebx,9 ; ebp
222 | jnz chc2
223 |
224 | popad
225 | ret
226 |
--------------------------------------------------------------------------------
/gui/mouse.inc:
--------------------------------------------------------------------------------
1 | ;mouseunder:
2 | ; times 16*24 dd 0
3 | label mouseunder dword at 0x6900
4 |
5 | iglobal
6 |
7 | mousepointer:
8 | db 0x00,0x00,0x00,0x74,0x74,0x74,0x6e,0x6e,0x6e,0x6f
9 | db 0x6f,0x6f,0x71,0x71,0x71,0x75,0x75,0x75,0x79,0x79
10 | db 0x79,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80,0x80
11 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
12 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
13 | db 0x80,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63
14 | db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
15 | db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
16 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
17 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0
18 | db 0xc0,0xc0,0x00,0x00,0x00,0x54,0x54,0x54,0x57,0x57
19 | db 0x57,0x5f,0x5f,0x5f,0x68,0x68,0x68,0x71,0x71,0x71
20 | db 0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80
21 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
22 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xc0,0xc0
23 | db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x47,0x47,0x47,0x50
24 | db 0x50,0x50,0x5b,0x5b,0x5b,0x67,0x67,0x67,0x70,0x70
25 | db 0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e
26 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
27 | db 0x80,0x80,0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0
28 | db 0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3f,0x3f,0x3f
29 | db 0x4b,0x4b,0x4b,0x59,0x59,0x59,0x66,0x66,0x66,0x70
30 | db 0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e
31 | db 0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
32 | db 0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
33 | db 0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3a,0x3a
34 | db 0x3a,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66,0x66
35 | db 0x70,0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e
36 | db 0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
37 | db 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0
38 | db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x39
39 | db 0x39,0x39,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66
40 | db 0x66,0x71,0x71,0x71,0x78,0x78,0x78,0x7c,0x7c,0x7c
41 | db 0x7e,0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0xff
42 | db 0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0
43 | db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00
44 | db 0x39,0x39,0x39,0x4a,0x4a,0x4a,0x5a,0x5a,0x5a,0x68
45 | db 0x68,0x68,0x72,0x72,0x72,0x79,0x79,0x79,0x7d,0x7d
46 | db 0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0xff,0xff,0xff
47 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
48 | db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00
49 | db 0x00,0x3c,0x3c,0x3c,0x4e,0x4e,0x4e,0x5e,0x5e,0x5e
50 | db 0x6b,0x6b,0x6b,0x75,0x75,0x75,0x7a,0x7a,0x7a,0x7e
51 | db 0x7e,0x7e,0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff
52 | db 0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0
53 | db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00
54 | db 0x00,0x00,0x43,0x43,0x43,0x55,0x55,0x55,0x64,0x64
55 | db 0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d
56 | db 0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
57 | db 0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
58 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
59 | db 0x00,0x00,0x00,0x4e,0x4e,0x4e,0x5f,0x5f,0x5f,0x6d
60 | db 0x6d,0x6d,0x76,0x76,0x76,0x7c,0x7c,0x7c,0x80,0x80
61 | db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
62 | db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x14
63 | db 0x14,0x14,0x1b,0x1b,0x1b,0x29,0x29,0x29,0x3a,0x3a
64 | db 0x3a,0x4c,0x4c,0x4c,0x5d,0x5d,0x5d,0x6c,0x6c,0x6c
65 | db 0x75,0x75,0x75,0x7b,0x7b,0x7b,0x80,0x80,0x80,0xc0
66 | db 0xc0,0xc0,0x00,0x00,0x00,0x2f,0x2f,0x2f,0x80,0x80
67 | db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
68 | db 0x21,0x21,0x21,0x2e,0x2e,0x2e,0x40,0x40,0x40,0x52
69 | db 0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f,0x77,0x77
70 | db 0x77,0x7c,0x7c,0x7c,0x80,0x80,0x80,0x00,0x00,0x00
71 | db 0x47,0x47,0x47,0x3b,0x3b,0x3b,0x80,0x80,0x80,0xff
72 | db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x25,0x25
73 | db 0x25,0x30,0x30,0x30,0x42,0x42,0x42,0x54,0x54,0x54
74 | db 0x64,0x64,0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
75 | db 0x7d,0x7d,0x00,0x00,0x00,0x62,0x62,0x62,0x52,0x52
76 | db 0x52,0x4a,0x4a,0x4a,0x43,0x43,0x43,0x80,0x80,0x80
77 | db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x33
78 | db 0x33,0x33,0x42,0x42,0x42,0x54,0x54,0x54,0x64,0x64
79 | db 0x64,0x71,0x71,0x71,0x79,0x79,0x79,0x7d,0x7d,0x7d
80 | db 0x72,0x72,0x72,0x6b,0x6b,0x6b,0x5f,0x5f,0x5f,0x5a
81 | db 0x5a,0x5a,0x54,0x54,0x54,0x80,0x80,0x80,0xff,0xff
82 | db 0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x35,0x35,0x35
83 | db 0x41,0x41,0x41,0x53,0x53,0x53,0x63,0x63,0x63,0x70
84 | db 0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d,0x77,0x77
85 | db 0x77,0x73,0x73,0x73,0x6c,0x6c,0x6c,0x68,0x68,0x68
86 | db 0x62,0x62,0x62,0x5a,0x5a,0x5a,0x80,0x80,0x80,0xff
87 | db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x41,0x41
88 | db 0x41,0x52,0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f
89 | db 0x78,0x78,0x78,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x79
90 | db 0x79,0x79,0x74,0x74,0x74,0x72,0x72,0x72,0x6e,0x6e
91 | db 0x6e,0x66,0x66,0x66,0x80,0x80,0x80,0xc0,0xc0,0xc0
92 | db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x44,0x44,0x44,0x52
93 | db 0x52,0x52,0x62,0x62,0x62,0x6e,0x6e,0x6e,0x77,0x77
94 | db 0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7c,0x7c,0x7c
95 | db 0x7a,0x7a,0x7a,0x79,0x79,0x79,0x75,0x75,0x75,0x6f
96 | db 0x6f,0x6f,0x65,0x65,0x65,0x00,0x00,0x00,0x00,0x00
97 | db 0x00,0x48,0x48,0x48,0x4b,0x4b,0x4b,0x56,0x56,0x56
98 | db 0x65,0x65,0x65,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
99 | db 0x7d,0x7d,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e
100 | db 0x7e,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76,0x76
101 | db 0x6f,0x6f,0x6f,0x65,0x65,0x65,0x5c,0x5c,0x5c,0x56
102 | db 0x56,0x56,0x58,0x58,0x58,0x60,0x60,0x60,0x6b,0x6b
103 | db 0x6b,0x73,0x73,0x73,0x7a,0x7a,0x7a,0x7d,0x7d,0x7d
104 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f
105 | db 0x7f,0x7f,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76
106 | db 0x76,0x70,0x70,0x70,0x6a,0x6a,0x6a,0x66,0x66,0x66
107 | db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
108 | db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
109 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
110 | db 0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x77
111 | db 0x77,0x77,0x73,0x73,0x73,0x71,0x71,0x71,0x71,0x71
112 | db 0x71,0x74,0x74,0x74,0x78,0x78,0x78,0x7b,0x7b,0x7b
113 | db 0x7d,0x7d,0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
114 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
115 | db 0x80,0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7c,0x7c,0x7c
116 | db 0x7a,0x7a,0x7a,0x78,0x78,0x78,0x78,0x78,0x78,0x7a
117 | db 0x7a,0x7a,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7f,0x7f
118 | db 0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
119 | db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
120 | db 0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e,0x7e,0x7e,0x7e
121 | db 0x7e,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e
122 | db 0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
123 | db 0x80,0x80
124 |
125 | mousepointer1:
126 | db 0xff,0xff,0xff,0x06,0x06,0x06,0x0a,0x0a
127 | db 0x0a,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00
128 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
129 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
130 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
131 | db 0xff,0xff,0xff,0xff,0xff,0xff,0x19,0x19,0x19,0x16
132 | db 0x16,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
133 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
134 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
135 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
136 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2e,0x2e,0x2e
137 | db 0x23,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00
138 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
139 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
140 | db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
141 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f
142 | db 0x3f,0x29,0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00
143 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
144 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
145 | db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
146 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x47
147 | db 0x47,0x47,0x2c,0x2c,0x2c,0x00,0x00,0x00,0x00,0x00
148 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
149 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
150 | db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
151 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
152 | db 0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16,0x00
153 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
154 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
155 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
156 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
157 | db 0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16
158 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
159 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
160 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
161 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
162 | db 0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00,0x00
163 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
164 | db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
165 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
166 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
167 | db 0xff,0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00
168 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
169 | db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
170 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
171 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
172 | db 0xff,0xff,0xff,0xff,0x47,0x47,0x47,0x29,0x29,0x29
173 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
174 | db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
175 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
176 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
177 | db 0xff,0xff,0xff,0xff,0xff,0x40,0x40,0x40,0x23,0x23
178 | db 0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
179 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
180 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
181 | db 0xff,0xaa,0xaa,0xaa,0x9f,0x9f,0x9f,0x8c,0x8c,0x8c
182 | db 0x70,0x70,0x70,0x4f,0x4f,0x4f,0x30,0x30,0x30,0x00
183 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
184 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x8f,0x8f,0x8f
185 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
186 | db 0xff,0xff,0x9c,0x9c,0x9c,0x87,0x87,0x87,0x6c,0x6c
187 | db 0x6c,0x4f,0x4f,0x4f,0x32,0x32,0x32,0x19,0x19,0x19
188 | db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
189 | db 0xff,0xff,0x69,0x69,0x69,0x84,0x84,0x84,0xff,0xff
190 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
191 | db 0x92,0x92,0x92,0x79,0x79,0x79,0x59,0x59,0x59,0x3c
192 | db 0x3c,0x3c,0x24,0x24,0x24,0x11,0x11,0x11,0x00,0x00
193 | db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x37,0x37,0x37
194 | db 0x5d,0x5d,0x5d,0x70,0x70,0x70,0x76,0x76,0x76,0xff
195 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
196 | db 0xff,0x75,0x75,0x75,0x51,0x51,0x51,0x31,0x31,0x31
197 | db 0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00
198 | db 0x00,0x00,0x16,0x16,0x16,0x2d,0x2d,0x2d,0x49,0x49
199 | db 0x49,0x53,0x53,0x53,0x54,0x54,0x54,0xff,0xff,0xff
200 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x78
201 | db 0x78,0x78,0x54,0x54,0x54,0x30,0x30,0x30,0x16,0x16
202 | db 0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
203 | db 0x0f,0x0f,0x0f,0x1f,0x1f,0x1f,0x30,0x30,0x30,0x33
204 | db 0x33,0x33,0x33,0x33,0x33,0x3b,0x3b,0x3b,0xff,0xff
205 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
206 | db 0x62,0x62,0x62,0x3b,0x3b,0x3b,0x1c,0x1c,0x1c,0x00
207 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08
208 | db 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
209 | db 0x00,0x00,0x00,0x24,0x24,0x24,0xff,0xff,0xff,0xff
210 | db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6e,0x6e
211 | db 0x6e,0x48,0x48,0x48,0x25,0x25,0x25,0x0e,0x0e,0x0e
212 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00
213 | db 0x00,0x00,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x00,0x00
214 | db 0x00,0x00,0x00,0x00,0x29,0x29,0x29,0xff,0xff,0xff
215 | db 0xff,0xff,0xff,0x7c,0x7c,0x7c,0x71,0x71,0x71,0x50
216 | db 0x50,0x50,0x2b,0x2b,0x2b,0x00,0x00,0x00,0x00,0x00
217 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
218 | db 0x00,0x00,0x00,0x02,0x02,0x02,0x04,0x04,0x04,0x00
219 | db 0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x56,0x56
220 | db 0x56,0x69,0x69,0x69,0x64,0x64,0x64,0x4a,0x4a,0x4a
221 | db 0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00
222 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
223 | db 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x05,0x05,0x05
224 | db 0x00,0x00,0x00,0x21,0x21,0x21,0x39,0x39,0x39,0x49
225 | db 0x49,0x49,0x48,0x48,0x48,0x35,0x35,0x35,0x1d,0x1d
226 | db 0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
227 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
228 | db 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00
229 | db 0x00,0x00,0x00,0x00,0x1d,0x1d,0x1d,0x27,0x27,0x27
230 | db 0x27,0x27,0x27,0x1d,0x1d,0x1d,0x0f,0x0f,0x0f,0x06
231 | db 0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
232 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
233 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
234 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
235 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
236 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
237 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
238 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
239 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
240 | db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
241 | db 0x00,0x00,0x00,0x00
242 |
243 | endg
--------------------------------------------------------------------------------
/gui/skincode.inc:
--------------------------------------------------------------------------------
1 |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 | ;; ;;
4 | ;; WINDOW SKIN for MenuetOS ;;
5 | ;; ;;
6 | ;; entryway@bkg.lt ;;
7 | ;; ;;
8 | ;; Bugfixes & upgrades by ;;
9 | ;; Samuel Rodriguez Perez ;;
10 | ;; Xeoda@ciberirmandade.org ;;
11 | ;; ;;
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 |
14 |
15 |
16 | include "SKINDATA.INC"
17 |
18 | virtual at 0
19 | bmp_header:
20 | .type rw 1 ; "BM" signature
21 | .filesize rd 1 ; size of the file
22 | .reserved rd 1 ; zero
23 | .offbits rd 1 ; pointer to image data
24 | ;----------------
25 | .headsize rd 1 ; usually 40 bytes for image header
26 | .width rd 1
27 | .height rd 1
28 | .planes rw 1 ; usually 1
29 | .bitcount rw 1 ; currently 24 bits/pixel (0x18)
30 | .compress rd 1 ; zero
31 | .sizeimage rd 1 ; x*y*(bitcount/8)
32 | .unused rd 4 ; these bits aren't used by MeOS
33 | bmp_data:
34 | end virtual
35 |
36 | virtual at 0x778000
37 | _bmp_bpl dd ? ; bytes per line
38 | _bmp_dpl dd ? ; dwords per line
39 | _bmp_zb dd ? ; bytes filled by zeroes at the end of a scanline
40 | align 32
41 | raw_data:
42 | end virtual
43 |
44 | bmp2raw:
45 | ; esi = to bmp data (source)
46 | ; edi = to raw data (destination)
47 | cmp [esi+bmp_header.type],'BM' ; check if bmp file is really loaded
48 | jne .finish
49 | mov edx,esi
50 |
51 | mov eax,[edx+bmp_header.width]
52 | imul eax,3
53 | push eax
54 | test eax,11b
55 | jz @f
56 | add eax,4
57 | @@:
58 | shr eax,2
59 | mov [_bmp_dpl],eax
60 | shl eax,2
61 | mov [_bmp_bpl],eax
62 | pop ebx
63 | sub eax,ebx
64 | mov [_bmp_zb],eax
65 |
66 | add esi,bmp_data
67 | mov eax,[_bmp_bpl]
68 | imul eax,[edx+bmp_header.height]
69 | add esi,eax
70 | mov ebx,[edx+bmp_header.height] ; ebx = y
71 | cld
72 | .y_begin:
73 | sub esi,[_bmp_bpl]
74 | push esi
75 | mov ecx,[_bmp_dpl]
76 | rep movsd
77 | pop esi
78 | sub edi,[_bmp_zb]
79 | dec ebx
80 | jne .y_begin
81 |
82 | .finish:
83 | ret
84 |
85 |
86 | ; BMP support by Ivan Poddubny
87 | ; 1) load LEFT.BMP
88 | ; a) _skinleftw = bmp_width
89 | ; b) _skinleft = 0
90 | ; c) _refleft = 0x778000
91 | ; d) convert
92 | ; 2) load BASE.BMP
93 | ; a) _skinbasew = bmp_width
94 | ; b) _skinbase = _skinleftw
95 | ; c) _refbase = _refleft+sizeof(left_raw_converted)
96 | ; d) convert
97 | ; 3) load OPER.BMP
98 | ; a) _skinoper = minus width from bmp file
99 | ; b) _skinoperw = width from bmp file
100 | ; c) _refoper = _refbase+sizeof(oper_raw_converted)
101 | ; d) convert
102 | ; 4) set height
103 |
104 | load_bmp_file:
105 | ; eax = pointer to filename
106 | mov ebx, 1
107 | or ecx, -1
108 | mov edx, 0x90000
109 | mov esi, 12
110 | call fileread
111 | ret
112 |
113 |
114 | load_default_skin:
115 | pushad
116 | mov eax, _fileleft
117 | call load_bmp_file
118 | mov eax, [0x90000+bmp_header.width]
119 | mov [_skinleftw], eax
120 | mov [_skinleft], 0
121 | mov edi, raw_data
122 | mov [_refleft], edi
123 | mov esi, 0x90000
124 | call bmp2raw
125 | mov eax, [_bmp_bpl]
126 | imul eax, [0x90000+bmp_header.height]
127 | push eax
128 |
129 | mov eax, _filebase
130 | call load_bmp_file
131 | mov eax, [0x90000+bmp_header.width]
132 | mov [_skinbasew], eax
133 | mov eax, [_skinleftw]
134 | mov [_skinbase], eax
135 | pop eax
136 | add eax, [_refleft]
137 | ; align to 32-byte boundary
138 | test eax, 11111b
139 | jz @f
140 | shr eax, 5
141 | inc eax
142 | shl eax, 5
143 | @@:
144 | ; save base address
145 | mov [_refbase], eax
146 | ; convert
147 | mov edi, eax
148 | mov esi, 0x90000
149 | call bmp2raw
150 | mov eax, [_bmp_bpl]
151 | imul eax, [0x90000+bmp_header.height]
152 | push eax
153 |
154 | mov eax, _fileoper
155 | call load_bmp_file
156 | mov eax, [0x90000+bmp_header.width]
157 | mov [_skinoperw], eax
158 | neg eax
159 | mov [_skinoper], eax
160 | pop eax
161 | add eax, [_refbase]
162 | ; align to 32-byte boundary
163 | test eax, 11111b
164 | jz @f
165 | shr eax, 5
166 | inc eax
167 | shl eax, 5
168 | @@:
169 | mov [_refoper], eax
170 | mov edi, eax
171 | mov esi, 0x90000
172 | call bmp2raw
173 |
174 |
175 | ; mov eax, [0x90000+bmp_header.height]
176 | ; imul eax, [0x90000+bmp_header.width]
177 | ; imul eax, 3
178 | ; add eax, raw_data ; now eax points to the last line of image
179 |
180 | ; mov ecx, [eax]
181 | ; mov [_coloroutborder], ecx
182 | ; mov [_colorborder], ecx
183 | ; sub eax, 2*3
184 | ; mov ecx, [eax]
185 | ; mov [_colorframe], ecx
186 |
187 |
188 | mov eax, [0x90000+bmp_header.height]
189 | mov [_skinh], eax
190 | popad
191 | ret
192 |
193 |
194 |
195 | drawwindow_IV:
196 |
197 | pusha
198 |
199 | push edx
200 |
201 | mov edi,[esp] ; RECTANGLE
202 |
203 | mov eax,[edi+0]
204 | shl eax,16
205 | mov ax,[edi+0]
206 | add ax,[edi+8]
207 | mov ebx,[edi+4]
208 | shl ebx,16
209 | mov bx,[edi+4]
210 | add bx,[edi+12]
211 | ; mov esi,[edi+24]
212 | ; shr esi,1
213 | ; and esi,0x007f7f7f
214 | mov esi,[_coloroutborder]
215 | call draw_rectangle
216 | mov ecx,3
217 | _dw3l:
218 | add eax,1*65536-1
219 | add ebx,1*65536-1
220 | test ax,ax
221 | js no_skin_add_button
222 | test bx,bx
223 | js no_skin_add_button
224 | mov esi,[_colorframe] ;[edi+24]
225 | call draw_rectangle
226 | dec ecx
227 | jnz _dw3l
228 | mov esi,[_colorborder]
229 | add eax,1*65536-1
230 | add ebx,1*65536-1
231 | test ax,ax
232 | js no_skin_add_button
233 | test bx,bx
234 | js no_skin_add_button
235 | call draw_rectangle
236 |
237 | mov esi,[esp]
238 | mov eax,[esi+8] ; window width
239 | mov edx,[_skinleft]
240 | shl edx,16
241 | mov ecx,[_skinleftw]
242 | shl ecx,16
243 | add ecx,[_skinh]
244 | mov ebx,[_refleft]
245 | call sys_putimage
246 |
247 | mov esi,[esp]
248 | mov eax,[esi+8]
249 | sub eax,[_skinleftw]
250 | sub eax,[_skinoperw]
251 | cmp eax,[_skinbase]
252 | jng non_base
253 | xor edx,edx
254 | mov ebx,[_skinbasew]
255 | div ebx
256 |
257 | inc eax
258 |
259 | mov ebx,[_refbase]
260 | mov ecx,[_skinbasew]
261 | shl ecx,16
262 | add ecx,[_skinh]
263 | mov edx,[_skinbase]
264 | sub edx,[_skinbasew]
265 | shl edx,16
266 | baseskinloop:
267 | shr edx,16
268 | add edx,[_skinbasew]
269 | shl edx,16
270 |
271 | push eax ebx ecx edx
272 | call sys_putimage
273 | pop edx ecx ebx eax
274 |
275 | dec eax
276 | jnz baseskinloop
277 | non_base:
278 |
279 | mov esi,[esp]
280 | mov edx,[esi+8]
281 | sub edx,[_skinoperw]
282 | inc edx
283 | shl edx,16
284 | mov ebx,[_refoper]
285 | mov ecx,[_skinoperw]
286 | shl ecx,16
287 | add ecx,[_skinh]
288 | call sys_putimage
289 |
290 | mov esi,[esp]
291 |
292 | mov edx,[esi+04] ; WORK AREA
293 | add edx,21+5
294 | mov ebx,[esi+04]
295 | add ebx,[esi+12]
296 | cmp edx,ebx
297 | jg _noinside2
298 | mov eax,5
299 | mov ebx,[_skinh]
300 | mov ecx,[esi+8]
301 | mov edx,[esi+12]
302 | sub ecx,4
303 | sub edx,4
304 | mov edi,[esi+16]
305 | call [drawbar]
306 | _noinside2:
307 |
308 | mov edi,[0xfe88]
309 | movzx eax,word [edi]
310 | cmp eax,1000
311 | jge no_skin_add_button
312 | inc eax
313 | mov [edi],ax
314 |
315 | shl eax,4
316 | add eax,edi
317 |
318 | mov bx,[0x3000]
319 | mov [eax],bx
320 |
321 | add eax,2 ; save button id number
322 | mov bx,1
323 | mov [eax],bx
324 | add eax,2 ; x start
325 | mov ebx,[esp]
326 | mov ebx,[ebx+8]
327 | cmp [_buttonCx],0
328 | jg _bCx_at_right
329 | mov ebx,[_buttonCw] ; ebx will be 0 in next instruction
330 | _bCx_at_right:
331 | sub ebx,[_buttonCw]
332 | sub ebx,[_buttonCx]
333 | mov [eax],bx
334 | add eax,2 ; x size
335 | mov ebx,[_buttonCw]
336 | mov [eax],bx
337 | add eax,2 ; y start
338 | mov ebx,[_buttonCy]
339 | mov [eax],bx
340 | add eax,2 ; y size
341 | mov ebx,[_buttonCh]
342 | mov [eax],bx
343 |
344 | ;* minimize button
345 | mov edi,[0xfe88]
346 | movzx eax,word [edi]
347 | cmp eax,1000
348 | jge no_skin_add_button
349 | inc eax
350 | mov [edi],ax
351 |
352 | shl eax,4
353 | add eax,edi
354 |
355 | mov bx,[0x3000]
356 | mov [eax],bx
357 |
358 | add eax,2 ; save button id number
359 | mov bx,65535 ;999
360 | mov [eax],bx
361 | add eax,2 ; x start
362 | mov ebx,[esp]
363 | mov ebx,[ebx+8]
364 | cmp [_buttonMx],0
365 | jg _bMx_at_right
366 | mov ebx,[_buttonMw] ; ebx will be 0 in next instruction
367 | _bMx_at_right:
368 | sub ebx,[_buttonMw]
369 | sub ebx,[_buttonMx]
370 | mov [eax],bx
371 | add eax,2 ; x size
372 | mov ebx,[_buttonMw]
373 | mov [eax],bx
374 | add eax,2 ; y start
375 | mov ebx,[_buttonMy]
376 | mov [eax],bx
377 | add eax,2 ; y size
378 | mov ebx,[_buttonMh]
379 | mov [eax],bx
380 | ;* minimize button
381 |
382 | no_skin_add_button:
383 |
384 | add esp,4
385 | popa
386 | ret
387 |
388 |
389 |
--------------------------------------------------------------------------------
/gui/skindata.inc:
--------------------------------------------------------------------------------
1 | ;
2 | ; WINDOW SKIN for MenuetOS
3 | ; ivan-yar@bk.ru
4 | ;
5 |
6 | iglobal
7 | _skinh dd 22
8 |
9 | _skinleftw dd 10
10 |
11 | _skinbase dd 10
12 | _skinbasew dd 8
13 |
14 | _skinoper dd -39 ;-21
15 | _skinoperw dd 39 ;21
16 |
17 | _buttonCx dd 5 ; close
18 | _buttonCy dd 2
19 | _buttonCw dd 15
20 | _buttonCh dd 17
21 |
22 | _buttonMx dd 23 ; minimize
23 | _buttonMy dd 2
24 | _buttonMw dd 15
25 | _buttonMh dd 17
26 |
27 |
28 | _colorframe dd 0x3a6cb6 ;0x586E93
29 | _colorborder dd 0x00081D
30 | _coloroutborder dd 0x00081D
31 |
32 | _fileleft db 'LEFT.BMP '
33 | _filebase db 'BASE.BMP '
34 | _fileoper db 'OPER.BMP '
35 | endg
36 |
37 | uglobal
38 | _refoper dd 0
39 | _refbase dd 0
40 | _refleft dd 0
41 | _skinleft dd 0
42 | _skinwinw dd 0
43 | endg
44 |
45 |
--------------------------------------------------------------------------------
/gui/window.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/gui/window.inc
--------------------------------------------------------------------------------
/hid/keyboard.inc:
--------------------------------------------------------------------------------
1 | ;// mike.dld [
2 |
3 | VKEY_LSHIFT = 0000000000000001b
4 | VKEY_RSHIFT = 0000000000000010b
5 | VKEY_LCONTROL = 0000000000000100b
6 | VKEY_RCONTROL = 0000000000001000b
7 | VKEY_LALT = 0000000000010000b
8 | VKEY_RALT = 0000000000100000b
9 | VKEY_CAPSLOCK = 0000000001000000b
10 | VKEY_NUMLOCK = 0000000010000000b
11 | VKEY_SCRLOCK = 0000000100000000b
12 |
13 | VKEY_SHIFT = 0000000000000011b
14 | VKEY_CONTROL = 0000000000001100b
15 | VKEY_ALT = 0000000000110000b
16 |
17 | uglobal
18 | align 4
19 | kb_state dd 0
20 | ext_code db 0
21 |
22 | keyboard_mode db 0
23 | keyboard_data db 0
24 |
25 | altmouseb db 0
26 | ctrl_alt_del db 0
27 |
28 | kb_lights db 0
29 | endg
30 |
31 | align 4
32 | irq1:
33 |
34 | call restore_caller
35 |
36 | movzx eax,word[0x3004] ; top window process
37 | movzx eax,word[0xC400+eax*2]
38 | shl eax,8
39 | mov al,[0x800B4+eax]
40 | mov [keyboard_mode],al
41 |
42 | in al,0x60
43 | mov [keyboard_data],al
44 |
45 | mov ch,al
46 | cmp al,0xE0
47 | je @f
48 | cmp al,0xE1
49 | jne .normal_code
50 | @@: mov [ext_code],al
51 | jmp .no_key.end
52 | .normal_code:
53 | mov cl,[ext_code]
54 | mov [ext_code],0
55 | and al,0x7F
56 | @@: cmp al,0x2A
57 | jne @f
58 | cmp cl,0xE0
59 | je .no_key.end
60 | mov eax,VKEY_LSHIFT
61 | jmp .no_key
62 | @@: cmp al,0x36
63 | jne @f
64 | cmp cl,0xE0
65 | je .no_key.end
66 | mov eax,VKEY_RSHIFT
67 | jmp .no_key
68 | @@: cmp al,0x38
69 | jne @f
70 | cmp cl,0xE0
71 | je .alt.r
72 | mov eax,VKEY_LALT
73 | jmp .no_key
74 | .alt.r:
75 | mov eax,VKEY_RALT
76 | jmp .no_key
77 | @@: cmp al,0x1D
78 | jne @f
79 | cmp cl,0
80 | jne .ctrl.r
81 | mov eax,VKEY_LCONTROL
82 | jmp .no_key
83 | .ctrl.r:
84 | cmp cl,0xE1
85 | jne .ctrl.r.2
86 | mov [ext_code],cl
87 | jmp .no_key.end
88 | .ctrl.r.2:
89 | mov eax,VKEY_RCONTROL
90 | jmp .no_key
91 | @@: cmp al,0x3A
92 | jne @f
93 | mov bl,4
94 | mov eax,VKEY_CAPSLOCK
95 | jmp .no_key.xor
96 | @@: cmp al,0x45
97 | jne @f
98 | cmp cl,0
99 | jne .no_key.end
100 | mov bl,2
101 | mov eax,VKEY_NUMLOCK
102 | jmp .no_key.xor
103 | @@: cmp al,0x46
104 | jne @f
105 | mov bl,1
106 | mov eax,VKEY_SCRLOCK
107 | jmp .no_key.xor
108 | @@:
109 | test ch,0x80
110 | jnz .no_key.end
111 | movzx eax,ch ; plain key
112 | mov bl,[keymap+eax]
113 | mov edx,[kb_state]
114 | test dl,VKEY_CONTROL ; ctrl alt del
115 | jz .noctrlaltdel
116 | test dl,VKEY_ALT
117 | jz .noctrlaltdel
118 | cmp bl,134+48
119 | jne .noctrlaltdel
120 | mov [ctrl_alt_del],1
121 | jmp .no_key.end
122 | .noctrlaltdel:
123 | test dl,VKEY_CONTROL ; ctrl on ?
124 | jz @f
125 | sub bl,0x60
126 | @@: test dl,VKEY_SHIFT ; shift on ?
127 | jz @f
128 | mov bl,[keymap_shift+eax]
129 | @@: test dl,VKEY_ALT ; alt on ?
130 | jz @f
131 | mov bl,[keymap_alt+eax]
132 | ; alt mouse ?
133 | xor edx,edx
134 | cmp bl,178
135 | jnz .no_alt.up
136 | mov edx,5*65536
137 | jmp .mouse.change
138 | .no_alt.up:
139 | cmp bl,177
140 | jnz .no_alt.down
141 | mov edx,251*65536
142 | jmp .mouse.change
143 | .no_alt.down:
144 | cmp bl,176
145 | jnz .no_alt.left
146 | mov edx,251*256
147 | jmp .mouse.change
148 | .no_alt.left:
149 | cmp bl,179
150 | jnz .no_alt.right
151 | mov edx,5*256
152 | jmp .mouse.change
153 | .no_alt.right:
154 | cmp bl,' '
155 | jne @f
156 | xor [altmouseb],1
157 | .mouse.change:
158 | mov byte[0xF604],1; ps2 data
159 | mov byte[0xFB00],0; ps2 chunk count
160 | mov word[0x2E0000+4096*12],3; mouse data count
161 | mov dl,[altmouseb]
162 | mov [0x2E0000+4096*12+0x10],edx
163 | mov bl,0
164 | @@:
165 | cmp [keyboard_mode],0 ; return from keymap
166 | jne .no_key.end
167 | mov [keyboard_mode_sys],0
168 | cmp bl,0
169 | je .no_key.end
170 | movzx eax,byte[0xF400]
171 | cmp al,120
172 | jae .no_key.end
173 | inc al
174 | mov [0xF400],al
175 | mov [0xF400+eax],bl
176 |
177 | jmp .no_key.end
178 |
179 | .no_key:
180 | test ch,0x80
181 | jz .no_key.down
182 | not eax
183 | and [kb_state],eax
184 | jmp .no_key.end
185 | .no_key.xor:
186 | test ch,0x80
187 | jnz .no_key.end
188 | xor [kb_state],eax
189 | xor [kb_lights],bl
190 | call set_lights
191 | jmp .no_key.end
192 | .no_key.down:
193 | or [kb_state],eax
194 | .no_key.end:
195 | cmp [keyboard_mode],1 ; return scancode
196 | jne .no_scancode
197 | mov [keyboard_mode_sys],1
198 | movzx eax,byte[0xF400]
199 | cmp al,120
200 | jae .no_scancode
201 | inc al
202 | mov [0xF400],al
203 | mov [0xF400+eax],ch
204 | .no_scancode:
205 |
206 | .exit.irq1:
207 | mov [check_idle_semaphore],5
208 |
209 | mov al,0x20 ; ready for next irq
210 | out 0x20,al
211 |
212 | call return_to_caller
213 |
214 | jmp irq1
215 |
216 | set_lights:
217 | mov al,0xED
218 | call kb_write
219 | mov al,[kb_lights]
220 | call kb_write
221 | ret
222 |
223 | ;// mike.dld ]
224 |
--------------------------------------------------------------------------------
/hid/set_dtc.inc:
--------------------------------------------------------------------------------
1 | ;setting date,time,clock and alarm-clock
2 | ;add sys_settime at servetable as for ex. 22 fcn:
3 | ; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK
4 | ; ebx =0 - set time ecx - 00SSMMHH
5 | ; ebx =1 - set date ecx=00DDMMYY
6 | ; ebx =2 - set day of week ecx- 1-7
7 | ; ebx =3 - set alarm-clock ecx - 00SSMMHH
8 | ; out: 0 -Ok 1 -wrong format 2 -battery low
9 | sys_settime:
10 | mov ecx,eax
11 | cli
12 | mov al,0x0d
13 | out 0x70,al
14 | in al,0x71
15 | bt ax,7
16 | jnc bat_low
17 | cmp ecx,2 ;day of week
18 | jne nosetweek
19 | test ebx,ebx ;test day of week
20 | je wrongtime
21 | cmp ebx,7
22 | ja wrongtime
23 | mov dx,0x70
24 | call startstopclk
25 | dec edx
26 | mov al,6
27 | out dx,al
28 | inc edx
29 | mov al,bl
30 | out dx,al
31 | jmp endsettime
32 | nosetweek: ;set date
33 | cmp ecx,1
34 | jne nosetdate
35 | cmp bl,0x99 ;test year
36 | ja wrongtime
37 | shl ebx,4
38 | cmp bl,0x90
39 | ja wrongtime
40 | cmp bh,0x99 ;test month
41 | ja wrongtime
42 | shr ebx,4
43 | test bh,bh
44 | je wrongtime
45 | cmp bh,0x12
46 | ja wrongtime
47 | shl ebx,8
48 | bswap ebx ;ebx=00YYMMDD
49 | test bl,bl ;test day
50 | je wrongtime
51 | shl ebx,4
52 | cmp bl,0x90
53 | ja wrongtime
54 | shr ebx,4
55 | cmp bh,2 ;February
56 | jne testday
57 | cmp bl,0x29
58 | ja wrongtime
59 | jmp setdate
60 | testday:
61 | cmp bh,8
62 | jb testday1 ;Aug-Dec
63 | bt bx,8
64 | jnc days31
65 | jmp days30
66 | testday1:
67 | bt bx,8 ;Jan-Jul ex.Feb
68 | jnc days30
69 | days31:
70 | cmp bl,0x31
71 | ja wrongtime
72 | jmp setdate
73 | days30:
74 | cmp bl,0x30
75 | ja wrongtime
76 | setdate:
77 | mov dx,0x70
78 | call startstopclk
79 | dec edx
80 | mov al,7 ;set days
81 | out dx,al
82 | inc edx
83 | mov al,bl
84 | out dx,al
85 | dec edx
86 | mov al,8 ;set months
87 | out dx,al
88 | inc edx
89 | mov al,bh
90 | out dx,al
91 | dec edx
92 | mov al,9 ;set years
93 | out dx,al
94 | inc edx
95 | shr ebx,8
96 | mov al,bh
97 | out dx,al
98 | jmp endsettime
99 | nosetdate: ;set time or alarm-clock
100 | cmp ecx,3
101 | ja wrongtime
102 | cmp bl,0x23
103 | ja wrongtime
104 | cmp bh,0x59
105 | ja wrongtime
106 | shl ebx,4
107 | cmp bl,0x90
108 | ja wrongtime
109 | cmp bh,0x92
110 | ja wrongtime
111 | shl ebx,4
112 | bswap ebx ;00HHMMSS
113 | cmp bl,0x59
114 | ja wrongtime
115 | shl ebx,4
116 | cmp bl,0x90
117 | ja wrongtime
118 | shr ebx,4
119 | mov dx,0x70
120 | call startstopclk
121 | dec edx
122 | cmp ecx,3
123 | je setalarm
124 | xor eax,eax ;al=0-set seconds
125 | out dx,al
126 | inc edx
127 | mov al,bl
128 | out dx,al
129 | dec edx
130 | mov al,2 ;set minutes
131 | out dx,al
132 | inc edx
133 | mov al,bh
134 | out dx,al
135 | dec edx
136 | mov al,4 ;set hours
137 | out dx,al
138 | inc edx
139 | shr ebx,8
140 | mov al,bh
141 | out dx,al
142 | jmp endsettime
143 | setalarm:
144 | mov al,1 ;set seconds for al.
145 | out dx,al
146 | inc edx
147 | mov al,bl
148 | out dx,al
149 | dec edx
150 | mov al,3 ;set minutes for al.
151 | out dx,al
152 | inc edx
153 | mov al,bh
154 | out dx,al
155 | dec edx
156 | mov al,5 ;set hours for al.
157 | out dx,al
158 | inc edx
159 | shr ebx,8
160 | mov al,bh
161 | out dx,al
162 | dec edx
163 | mov al,0x0b ;enable irq's
164 | out dx,al
165 | inc dx
166 | in al,dx
167 | bts ax,5 ;set bit 5
168 | out dx,al
169 | endsettime:
170 | dec edx
171 | call startstopclk
172 | sti
173 | mov [esp+36],dword 0
174 | ret
175 | bat_low:
176 | sti
177 | mov [esp+36],dword 2
178 | ret
179 | wrongtime:
180 | sti
181 | mov [esp+36],dword 1
182 | ret
183 |
184 | startstopclk:
185 | mov al,0x0b
186 | out dx,al
187 | inc dx
188 | in al,dx
189 | btc ax,7
190 | out dx,al
191 | ret
192 |
--------------------------------------------------------------------------------
/kernel.asm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luki122/kolibrios/a50f6e4d6acbe974f31dda408756f0b0bf789c88/kernel.asm
--------------------------------------------------------------------------------
/kernel16.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; KERNEL16.INC ;;
4 | ;; ;;
5 | ;; Included 16 bit kernel files for MenuetOS ;;
6 | ;; ;;
7 | ;; This file is kept separate as it will be easier to ;;
8 | ;; maintain and compile with an automated SETUP program ;;
9 | ;; in the future. ;;
10 | ;; ;;
11 | ;; Copyright Ville Turjanmaa, see file COPYING for details. ;;
12 | ;; ;;
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 |
15 |
16 | ;% +include
17 |
18 | ;!!!
19 | if lang eq en
20 | include "boot/booteng.inc" ; english system boot messages
21 | else
22 | include "boot/bootru.inc" ; russian system boot messages
23 | ;!!!
24 | end if
25 | include "boot/ru.inc" ; Russian font
26 |
27 | include "boot/bootcode.inc" ; 16 bit system boot code
28 |
29 | include "bus/pci/pci16.inc"
30 |
31 | ;% -include
--------------------------------------------------------------------------------
/kernel32.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; KERNEL32.INC ;;
4 | ;; ;;
5 | ;; Included 32 bit kernel files for MenuetOS ;;
6 | ;; ;;
7 | ;; This file is kept separate as it will be easier to ;;
8 | ;; maintain and compile with an automated SETUP program ;;
9 | ;; in the future. ;;
10 | ;; ;;
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12 |
13 | ; structure definition helper
14 | macro struct name, [arg]
15 | {
16 | common
17 | name@struct fix name
18 | struc name arg {
19 | }
20 |
21 | macro struct_helper name
22 | {
23 | virtual at 0
24 | name name
25 | sizeof.#name = $ - name
26 | name equ sizeof.#name
27 | end virtual
28 | }
29 |
30 | ends fix } struct_helper name@struct
31 |
32 |
33 | ; Core functions
34 | include "core/sync.inc"
35 | include "core/sys32.inc" ; process management
36 | include "core/sched.inc" ; process scheduling
37 | include "core/fpu.inc" ; FPU handler
38 | include "core/syscall.inc" ; system call
39 | include "core/mem.inc" ; high-level memory management
40 | include "core/newproce.inc" ;new process management
41 | include "core/physmem.inc" ; access to physical memory for applications
42 | include "core/sync.inc" ; macros for synhronization objects
43 |
44 | ; GUI stuff
45 | include "gui/window.inc"
46 | include "gui/event.inc"
47 | include "gui/font.inc"
48 | include "gui/button.inc"
49 |
50 | ; shutdown
51 |
52 | include "boot/shutdown.inc" ; shutdown or restart
53 |
54 | ; file system
55 |
56 | include "fs/fs.inc" ; syscall
57 | include "fs/fat32.inc" ; read / write for fat32 filesystem
58 | include "fs/fat12.inc" ; read / write for fat12 filesystem
59 | include "blkdev/rd.inc" ; ramdisk read /write
60 |
61 | ; sound
62 |
63 | include "sound/sb16.inc" ; playback for Sound Blaster 16
64 | include "sound/playnote.inc" ; player Note for Speaker PC
65 |
66 | ; display
67 |
68 | include "video/vesa12.inc" ; Vesa 1.2 functions
69 | include "video/vesa20.inc" ; Vesa 2.0 functions
70 | include "video/vga.inc" ; VGA 16 color functions
71 |
72 | ; Network Interface & TCPIP Stack
73 |
74 | include "network/stack.inc"
75 |
76 | ; Mouse pointer
77 |
78 | include "gui/mouse.inc"
79 |
80 | ; Window skinning
81 |
82 | include "gui/skincode.inc"
83 |
84 | ; Pci functions
85 |
86 | include "bus/pci/pci32.inc"
87 |
88 | ; Floppy drive controller
89 |
90 | include "blkdev/fdc.inc"
91 | include "blkdev/flp_drv.inc"
92 |
93 | ; CD drive controller
94 |
95 | include "blkdev/cdrom.inc"
96 |
97 | ; Character devices
98 |
99 | include "hid/keyboard.inc"
100 |
101 | ; setting date,time,clock and alarm-clock
102 |
103 | include "hid/set_dtc.inc"
104 |
105 | ;% -include
106 |
--------------------------------------------------------------------------------
/kglobals.inc:
--------------------------------------------------------------------------------
1 | ;------------------------------------------------------------------
2 | ; use "iglobal" for inserting initialized global data definitions.
3 | ;------------------------------------------------------------------
4 | macro iglobal {
5 | IGlobals equ IGlobals,
6 | macro __IGlobalBlock { }
7 |
8 | ;-------------------------------------------------------------
9 | ; use 'uglobal' for inserting uninitialized global definitions.
10 | ; even when you define some data values, these variables
11 | ; will be stored as uninitialized data.
12 | ;-------------------------------------------------------------
13 | macro uglobal {
14 | UGlobals equ UGlobals,
15 | macro __UGlobalBlock { }
16 |
17 | endg fix } ; Use endg for ending iglobal and uglobal blocks.
18 |
19 | macro IncludeIGlobals{
20 | macro IGlobals dummy,[n] \{ __IGlobalBlock
21 | purge __IGlobalBlock \}
22 | match I, IGlobals \{ I \} }
23 |
24 |
25 | macro IncludeUGlobals{
26 | macro UGlobals dummy,[n] \{
27 | \common
28 | \local begin, size
29 | begin = $
30 | virtual at $
31 | \forward
32 | __UGlobalBlock
33 | purge __UGlobalBlock
34 | \common
35 | size = $ - begin
36 | end virtual
37 | rb size
38 | \}
39 | match U, UGlobals \{ U \} }
40 |
41 | macro IncludeAllGlobals {
42 | IncludeIGlobals
43 | IncludeUGlobals
44 | }
45 |
46 | iglobal
47 | endg
48 |
49 | uglobal
50 | endg
51 |
--------------------------------------------------------------------------------
/memmap.inc:
--------------------------------------------------------------------------------
1 | ;
2 | ; MEMORY MAP
3 | ;
4 | ; Boot:
5 | ;
6 | ; 0:9000 byte bits per pixel
7 | ; 0:9001 word scanline length
8 | ; 0:9008 word vesa video mode
9 | ; 0:900A word X res
10 | ; 0:900C word Y res
11 | ; 0:9010 byte mouse port - not used
12 | ; 0:9014 dword Vesa 1.2 pm bank switch
13 | ; 0:9018 dword Vesa 2.0 LFB address
14 | ; 0:901C byte 0 or 1 : enable MTRR graphics acceleration
15 | ; 0:901D byte not used anymore (0 or 1 : enable system log display)
16 | ; 0:901E byte 0 or 1 : enable direct lfb write, paging disabled
17 | ; 0:9020 8bytes pci data
18 | ; 0:9030 byte VRR start enabled 1, 2-no
19 | ; 0:9031 word IDEContrRegsBaseAddr
20 | ;
21 | ;
22 | ; Runtime:
23 | ;
24 | ; 0000 -> 2FFF window_data - 256 entries
25 | ;
26 | ; 0000 dword x start
27 | ; 0004 dword y start
28 | ; 0008 dword x size
29 | ; 000C dword y size
30 | ; 0010 dword color of work area
31 | ; 0014 dword color of grab bar
32 | ; 0018 dword color of frames
33 | ; 001C dword window flags, +30 = window drawn, +31 redraw flag
34 | ;
35 | ; 3000 -> 4FFF task list - 256 entries
36 | ;
37 | ; 00 dword process count
38 | ; 04 dword no of processes
39 | ; 10 dword base of running process at 0x3000+
40 | ;
41 | ; 20 dword application event mask
42 | ; 24 dword PID - process identification number
43 | ; 2a word 0, state 3=zombie, 4=terminate
44 | ; 2e byte window number on screen
45 | ; 30 dword exact position in memory
46 | ; 34 dword counter sum
47 | ; 38 dword time stamp counter add
48 | ; 3c dword cpu usage in cpu timer tics
49 | ;
50 | ; -> delete -> 5000 -> AFFF free
51 | ;
52 | ;!!!
53 | ; 5000 -> 5FFF save_syscall_data - syscall trace
54 | ; 6000 -> 63FF reg1 array - for i40 (first parts of saved TSS descriptor)
55 | ; 6400 -> 67FF reg2 array - same thing, second part
56 | ; 6800 -> 68FF used i40 (1 if used, 0 if free), first element not used
57 | ; 6900 -> 6EFF saved picture under mouse pointer
58 | ;
59 | ; 6F00 -> 7FFF i38 stack (4,25Kb)
60 | ;
61 | ; 8000 -> A3FF used FLOPPY driver
62 | ;
63 | ; A400 -> AFFF free
64 | ;
65 | ; B000 -> B005 jump address for irq0 (task switch)
66 | ; B008 -> B00B count of ticks remaining to updating CPU usage info
67 | ;
68 | ; B060 -> B07F fpu error handler's stack
69 | ; B080 -> B0FF fpu_tss -> temporary TSS for FPU context switching
70 | ; B100 -> B2FF IDT
71 | ; B300 -> BAFF tasknum array - for i40 handler
72 | ; BB00 -> BEFF free
73 | ;!!!
74 |
75 | ; BF00 -> BFFF bytes, 1 if process running/memory in use
76 | ; C000 -> C3FF window stack C000 no of windows - all in words
77 | ; C402 -> C7FF window position in stack
78 | ; D000 -> D1FF FDC controller
79 | ; D200 -> D3FF FDC controller for Fat12
80 | ; D400 -> DFFF free
81 | ; E000 byte multitasking started
82 | ; E004 dword save for boot mem 0x24
83 | ; E010 dword pm bank switch address
84 | ; E014 dword window multiplier
85 | ; E020 dword putpixel address
86 | ; E024 dword getpixel address
87 | ; E030 dword Vesa 1.2 pm bank switch address
88 | ; F000 dword hd partition 1 start
89 | ; F004 dword root start at partition 1
90 | ; F008 dword root start at hd
91 | ; F100 byte 1=only os draw on screen
92 | ; F200 dword mousepicture -pointer
93 | ; F204 dword mouse appearance counter
94 | ; F300 dword x & y temp for windowmove
95 | ; F400 byte no of keys in buffer
96 | ; F401 byte 'buffer'
97 | ; F402 -> F4FF reserved for keys
98 | ; F500 byte no of buttons in buffer
99 | ; F501 dword 'buffer'
100 | ; F502 -> F5FF reserved for buttons
101 | ; F600 dword tsc / second
102 | ; F604 byte mouse port: 1 ps2, 2 com1, 3 com2
103 | ; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y
104 | ; FB10 -> FB17 mouse color mem
105 | ; FB21 x move
106 | ; FB22 y move
107 | ; FB28 high bits temp
108 | ; FB30 color temp
109 | ; FB40 byte buttons down
110 | ; FB44 byte 0 mouse down -> do not draw
111 | ; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under
112 | ; FBF0 byte multiplied window
113 | ; FBF1 byte bits per pixel
114 | ; FC00 -> FCFE com1/ps2 buffer
115 | ; FCFF com1/ps2 buffer count starting from FC00
116 | ; FDF0 -> FDF3 timer tick inc every 1/100 sec 4 bytes
117 | ; FE00 dword screen x size
118 | ; FE04 dword screen y size
119 | ; FE08 dword screen y multiplier
120 | ; FE0C dword screen mode
121 | ; FE10 dword entries in hd cache
122 | ; FE80 dword address of LFB in physical
123 | ; FE84 dword address of applications memory start in physical
124 | ; FE88 dword address of button list
125 | ; FE8C dword memory to use
126 | ; FF00 byte 1 = system shutdown request
127 | ; FF01 dword if >1 then activate process
128 | ; FFF0 byte 1 = redraw background request from app
129 | ; FFF1 byte 1 = diskette int occur
130 | ; FFF2 write and read bank in screen
131 | ; FFF4 byte 0 if first mouse draw & do not return picture under
132 | ; FFF5 byte 1 do not draw pointer
133 | ; FFFF byte do not change task for 1/100 sec.
134 | ;
135 | ; 10000 -> 1FFFF 32 bit os
136 | ; 20000 -> 2FFFF 32 bit stack
137 | ; 30000 -> 36FFF basic text font II
138 | ; 37000 -> 3BFFF basic text font I
139 | ; 40000 -> 4FFFF data of retrieved disks and partitions (Mario79)
140 | ; 50000 -> 500FF TSS of scheduler
141 | ; 51000 -> 54000 esp0,esp1,esp2
142 | ; 5F000 -> 5FFFF schedulers stack
143 | ; 60000 -> 7FFFF paging tables
144 | ; 80000 -> 8FFFF additional app info, in 256 byte steps - 256 entries
145 | ;
146 | ; 00 11db name of app running
147 | ; 10 108db floating point unit save area
148 | ; 7f byte 0= no fpu saved , 1= fpu saved to 0x10 -> restore
149 | ; 80 dword address of random shaped window area
150 | ; 84 byte shape area scale
151 | ; 88 dword used GDT of TSS
152 | ; 8C dword application memory size
153 | ; 90 dword window X position save
154 | ; 94 dword window Y position save
155 | ; 98 dword window X size save
156 | ; 9C dword window Y size save
157 | ; A0 dword IPC memory start
158 | ; A4 dword IPC memory size
159 | ; A8 dword event bits: mouse, stack,..
160 | ;
161 | ; B0 dword int40 handler in use ; 0 if not in use
162 | ; B4 byte keyboard mode: 0 = keymap, 1 = scancodes
163 | ;
164 | ; 90000 -> 9FFFF tmp
165 | ; A0000 -> AFFFF screen access area
166 | ; B0000 -> FFFFF bios rest in peace -area
167 | ; 100000 -> 27FFFF diskette image
168 | ; 280000 -> 281FFF ramdisk fat
169 | ; 282000 -> 283FFF floppy fat
170 | ;
171 | ; 284000 -> 28FFFF free
172 | ;
173 | ; 290000 -> 297FFF TSS's of interrupts
174 | ; 298000 -> 29FFFF TSS's of SYSTEM interrupts - 256 entries
175 | ; 2A0000 -> 2B00ff wav device data
176 | ; 2C0000 -> 2C3fff button info
177 | ;
178 | ; 0000 word number of buttons
179 | ; first button entry at 0x10
180 | ; +0000 word process number
181 | ; +0002 word button id number : bits 00-15
182 | ; +0004 word x start
183 | ; +0006 word x size
184 | ; +0008 word y start
185 | ; +000A word y size
186 | ; +000C word button id number : bits 16-31
187 | ;
188 | ; 2D0000 -> 2DFFFF reserved port area
189 | ;
190 | ; 0000 dword no of port areas reserved
191 | ; 0010 dword process id
192 | ; dword start port
193 | ; dword end port
194 | ; dword 0
195 | ;
196 | ; 2E0000 -> 2EFFFF irq data area
197 | ; 2F0000 -> 2FFFFF low memory save
198 | ;
199 | ; 300000 -> 45FFFF background image, max 1 M
200 | ;
201 | ; 460000 -> 5FFFFF display info
202 | ;
203 | ; 600000 -> 6FFFFF hd cache
204 | ;
205 | ; 700000 -> 71ffff tcp memory (128 kb)
206 | ; 720000 -> 75ffff interrupt stacks (256 kpl * 1024)
207 | ;
208 | ; 760000 -> 76ffff !vrr driver
209 | ; 770000 -> 777fff tcp memory ( 32 kb)
210 | ;
211 | ; 778000 -> 77ffff window skinning ( 32 kb)
212 | ; 780000 -> 7fffff free
213 | ;
214 | ; 800000 -> BFFFFF mapped to LFB
215 | ;
216 | ; C00000 -> DFFFFF * Application information
217 | ;
218 | ; C00000 -> C01FFF draw_data - 256 entries
219 | ;
220 | ; 00 dword draw limit - x start
221 | ; 04 dword draw limit - y start
222 | ; 08 dword draw limit - x end
223 | ; 0C dword draw limit - y end
224 | ; 1C dword app int vector
225 | ;
226 | ; C03000 -> D11fff sysint_stack_data
227 | ; - system interrupt stacks
228 | ; - 256 entries * 4096 step
229 | ;
230 | ; D20000 -> DA8000 TSS and IO map for (2048*8)=16384 ports
231 | ; (128+2048)*256 = 557956 = 0x88000
232 | ;
233 | ; 1000000 -> 3FFFFFF for applications
234 | ;
235 |
236 |
237 |
238 |
239 |
240 |
--------------------------------------------------------------------------------
/network/ip.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; IP.INC ;;
4 | ;; ;;
5 | ;; IP Processes for Menuet OS TCP/IP stack ;;
6 | ;; ;;
7 | ;; Version 0.3 29 August 2002 ;;
8 | ;; ;;
9 | ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
10 | ;; ;;
11 | ;; See file COPYING for details ;;
12 | ;; ;;
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 |
15 |
16 | ;*******************************************************************
17 | ; Interface
18 | ;
19 | ; ip_rx processes all packets received by the network layer
20 | ; It calls the appropriate protocol handler
21 | ;
22 | ;
23 | ;
24 | ;*******************************************************************
25 |
26 |
27 | ;***************************************************************************
28 | ; Function
29 | ; ip_rx
30 | ;
31 | ; Description
32 | ; Handles received IP packets
33 | ; This is a kernel function, called by stack_handler
34 | ;
35 | ;***************************************************************************
36 | ip_rx:
37 | ; Look for a buffer to tx
38 | mov eax, IPIN_QUEUE
39 | call dequeue
40 | cmp ax, NO_BUFFER
41 | je ipr_exit ; Exit if no buffer available
42 |
43 | push eax
44 |
45 | ; convert buffer pointer eax to the absolute address
46 | mov ecx, IPBUFFSIZE
47 | mul ecx
48 | add eax, IPbuffs
49 |
50 | mov edx, eax ; Save the address in edx for use by future processes
51 |
52 | ; Validate the IP checksum
53 | mov ebx, edx
54 | mov ah, [ebx + 10]
55 | mov al, [ebx + 11] ; Get the checksum in intel format
56 | mov [ebx + 10], word 0 ; clear checksum field - need to when
57 | ; recalculating checksum
58 |
59 | ; this needs two data pointers and two size #.
60 | ; 2nd pointer can be of length 0
61 | mov ebx, edx
62 | mov [checkAdd1], ebx
63 | mov [checkSize1], word 20
64 | mov [checkAdd2], dword 0
65 | mov [checkSize2], word 0
66 |
67 | call checksum ; Recalculate IP checksum
68 | cmp ax, [checkResult]
69 | jnz ipr_dump
70 |
71 | ; If the IP address is 255.255.255.255, accept it
72 | ; - it is a broadcast packet, which we need for dhcp
73 | mov eax, [edx + 16]
74 | cmp eax, 0xffffffff
75 | je ipr_p0
76 |
77 | ; Validate the IP address, if it isn't broadcast
78 | cmp eax, [stack_ip]
79 | jnz ipr_dump
80 |
81 | ipr_p0:
82 | mov al, [edx]
83 | and al, 0x0f
84 | cmp al, 0x05
85 | jnz ipr_dump
86 |
87 | cmp [edx+8], byte 0
88 | jz ipr_dump
89 |
90 | mov ax, [edx + 6]
91 | and ax, 0xFFBF
92 | cmp ax, 0
93 | jnz ipr_dump
94 |
95 | ; Check the protocol, and call the appropriate handler
96 | ; Each handler will re-use or free the queue buffer as appropriate
97 | mov al, [edx + 9]
98 | cmp al , PROTOCOL_ICMP
99 | jnz ipr_p1
100 | pop eax
101 | call icmp_rx
102 | jmp ipr_exit
103 |
104 | ipr_p1:
105 | cmp al , PROTOCOL_TCP
106 | jnz ipr_p2
107 | pop eax
108 | call tcp_rx
109 | jmp ipr_exit
110 |
111 | ipr_p2:
112 | cmp al , PROTOCOL_UDP
113 | jnz ipr_dump
114 | pop eax
115 | call udp_rx
116 | jmp ipr_exit
117 |
118 | ipr_dump:
119 | ; No protocol handler available, so
120 | ; silently dump the packet, freeing up the queue buffer
121 |
122 | ; inc dword [dumped_rx_count]
123 |
124 | pop eax
125 | call freeBuff
126 |
127 | ipr_exit:
128 | ret
129 |
130 |
131 |
132 | ;***************************************************************************
133 | ; Function
134 | ; icmp_rx
135 | ;
136 | ; Description
137 | ; ICMP protocol handler
138 | ; This is a kernel function, called by ip_rx
139 | ; edx contains the address of the buffer in use.
140 | ; This buffer must be reused or marked as empty afterwards
141 | ;
142 | ;***************************************************************************
143 | icmp_rx:
144 | cmp [edx + 20], byte 8 ; Is this an echo request? discard if not
145 | jz icmp_echo
146 |
147 | call freeBuff
148 | jmp icmp_exit
149 |
150 | icmp_echo:
151 | push eax
152 | mov [edx + 10], word 0 ; I think this was already done by IP rx
153 |
154 | ; swap the source and destination addresses
155 | mov ecx, [edx + 16]
156 | mov eax, [edx + 12]
157 | mov [edx + 16], eax
158 | mov [edx + 12], ecx
159 |
160 | ; recaluculate the IP header checksum
161 |
162 | mov ebx, edx
163 | mov [checkAdd1], ebx
164 | mov [checkSize1], word 20
165 | mov [checkAdd2], dword 0
166 | mov [checkSize2], word 0
167 |
168 | call checksum
169 | mov ax, [checkResult]
170 | mov [edx + 10], ah
171 | mov [edx + 11], al ; ?? correct byte order?
172 |
173 | mov [edx + 20], byte 0 ; change the request to a response
174 | mov [edx + 22], word 0 ; clear ICMP checksum prior to re-calc
175 |
176 | ; Calculate the length of the ICMP data ( IP payload)
177 | mov ah, [edx + 2]
178 | mov al, [edx + 3]
179 | sub ax, 20
180 |
181 | mov [checkSize1], ax
182 | mov ebx, edx
183 | add ebx, 20
184 |
185 | mov [checkAdd1], ebx
186 | mov [checkAdd2], dword 0
187 | mov [checkSize2], word 0
188 |
189 | call checksum
190 |
191 | mov ax, [checkResult]
192 | mov [edx + 22], ah
193 | mov [edx + 23], al
194 |
195 | ; Queue packet for transmission
196 |
197 | pop ebx
198 | mov eax, NET1OUT_QUEUE
199 | call queue
200 |
201 | icmp_exit:
202 | ret
--------------------------------------------------------------------------------
/network/queue.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; QUEUE.INC ;;
4 | ;; ;;
5 | ;; Buffer queue management for Menuet OS TCP/IP Stack ;;
6 | ;; ;;
7 | ;; Version 0.3 29 August 2002 ;;
8 | ;; ;;
9 | ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
10 | ;; ;;
11 | ;; See file COPYING for details ;;
12 | ;; ;;
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 |
15 |
16 | ;*******************************************************************
17 | ; Interface
18 | ;
19 | ; queueInit Configures the queues to empty
20 | ; dequeue Removes a buffer pointer from a queue
21 | ; queue Inserts a buffer pointer into a queue
22 | ; freeBuff Adds the buffer pointer to the list of free buffers
23 | ; queueSize Returns the number of entries in a queue
24 | ;
25 | ; The various defines for queue names can be found in stack.inc
26 | ;
27 | ;*******************************************************************
28 |
29 |
30 | ;***************************************************************************
31 | ; Function
32 | ; freeBuff
33 | ;
34 | ; Description
35 | ; Adds a buffer number to the beginning of the free list.
36 | ; buffer number in eax ( ms word zeroed )
37 | ; all other registers preserved
38 | ; This always works, so no error returned
39 | ;***************************************************************************
40 | freeBuff:
41 | push ebx
42 | push ecx
43 | mov ebx, EMPTY_QUEUE
44 | shl ebx, 1
45 | add ebx, queues
46 | cli ; Ensure that another process does not interfer
47 | movzx ecx, word [ebx]
48 | mov [ebx], ax
49 | shl eax, 1
50 | add eax, queueList
51 | mov [eax], cx
52 | sti
53 | pop ecx
54 | pop ebx
55 |
56 | ret
57 |
58 |
59 | ;***************************************************************************
60 | ; Function
61 | ; queueSize
62 | ;
63 | ; Description
64 | ; Counts the number of entries in a queue
65 | ; queue number in ebx ( ms word zeroed )
66 | ; Queue size returned in eax
67 | ; This always works, so no error returned
68 | ;***************************************************************************
69 | queueSize:
70 | xor eax, eax
71 | shl ebx, 1
72 | add ebx, queues
73 | movzx ecx, word [ebx]
74 | cmp cx, NO_BUFFER
75 | je qs_exit
76 |
77 | qs_001:
78 | inc eax
79 | shl ecx, 1
80 | add ecx, queueList
81 | movzx ecx, word [ecx]
82 | cmp cx, NO_BUFFER
83 | je qs_exit
84 | jmp qs_001
85 |
86 | qs_exit:
87 | ret
88 |
89 |
90 | ;***************************************************************************
91 | ; Function
92 | ; queue
93 | ;
94 | ; Description
95 | ; Adds a buffer number to the *end* of a queue
96 | ; This is quite quick because these queues will be short
97 | ; queue number in eax ( ms word zeroed )
98 | ; buffer number in ebx ( ms word zeroed )
99 | ; all other registers preserved
100 | ; This always works, so no error returned
101 | ;***************************************************************************
102 | queue:
103 | push ebx
104 | shl ebx, 1
105 | add ebx, queueList ; eax now holds address of queue entry
106 | mov [ebx], word NO_BUFFER ; This buffer will be the last
107 |
108 | cli
109 | shl eax, 1
110 | add eax, queues ; eax now holds address of queue
111 | movzx ebx, word [eax]
112 |
113 | cmp bx, NO_BUFFER
114 | jne qu_001
115 |
116 | pop ebx
117 | ; The list is empty, so add this to the head
118 | mov [eax], bx
119 | jmp qu_exit
120 |
121 | qu_001:
122 | ; Find the last entry
123 | shl ebx, 1
124 | add ebx, queueList
125 | mov eax, ebx
126 | movzx ebx, word [ebx]
127 | cmp bx, NO_BUFFER
128 | jne qu_001
129 |
130 | mov ebx, eax
131 | pop eax
132 | mov [ebx], ax
133 |
134 | qu_exit:
135 | sti
136 | ret
137 |
138 |
139 |
140 | ;***************************************************************************
141 | ; Function
142 | ; dequeue
143 | ;
144 | ; Description
145 | ; removes a buffer number from the head of a queue
146 | ; This is fast, as it unlinks the first entry in the list
147 | ; queue number in eax ( ms word zeroed )
148 | ; buffer number returned in eax ( ms word zeroed )
149 | ; all other registers preserved
150 | ;
151 | ;***************************************************************************
152 | dequeue:
153 | push ebx
154 | shl eax, 1
155 | add eax, queues ; eax now holds address of queue
156 | mov ebx, eax
157 | cli
158 | movzx eax, word [eax]
159 | cmp ax, NO_BUFFER
160 | je dq_exit
161 | push eax
162 | shl eax, 1
163 | add eax, queueList ; eax now holds address of queue entry
164 | mov ax, [eax]
165 | mov [ebx], ax
166 | pop eax
167 |
168 | dq_exit:
169 | sti
170 | pop ebx
171 | ret
172 |
173 |
174 | ;***************************************************************************
175 | ; Function
176 | ; queueInit
177 | ;
178 | ; Description
179 | ; Initialises the queues to empty, and creates the free queue
180 | ; list.
181 | ;
182 | ;***************************************************************************
183 | queueInit:
184 | mov esi, queues
185 | mov ecx, NUMQUEUES
186 | mov ax, NO_BUFFER
187 |
188 | qi001:
189 | mov [esi], ax
190 | inc esi
191 | inc esi
192 | loop qi001
193 |
194 | mov esi, queues + ( 2 * EMPTY_QUEUE )
195 |
196 | ; Initialise empty queue list
197 |
198 | xor ax, ax
199 | mov [esi], ax
200 |
201 | mov ecx, NUMQUEUEENTRIES - 1
202 | mov esi, queueList
203 |
204 | qi002:
205 | inc ax
206 | mov [esi], ax
207 | inc esi
208 | inc esi
209 | loop qi002
210 |
211 | mov ax, NO_BUFFER
212 | mov [esi], ax
213 |
214 | ret
215 |
--------------------------------------------------------------------------------
/network/udp.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; UDP.INC ;;
4 | ;; ;;
5 | ;; UDP Processes for Menuet OS TCP/IP stack ;;
6 | ;; ;;
7 | ;; Version 0.3 29 August 2002 ;;
8 | ;; ;;
9 | ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
10 | ;; ;;
11 | ;; See file COPYING for details ;;
12 | ;; ;;
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 |
15 |
16 | ;*******************************************************************
17 | ; Interface
18 | ;
19 | ; udp_rx Handles received IP packets with the UDP protocol
20 | ;
21 | ;*******************************************************************
22 |
23 |
24 |
25 |
26 | ;***************************************************************************
27 | ; Function
28 | ; udp_rx
29 | ;
30 | ; Description
31 | ; UDP protocol handler
32 | ; This is a kernel function, called by ip_rx
33 | ; IP buffer address given in edx
34 | ; Free up (or re-use) IP buffer when finished
35 | ;
36 | ;***************************************************************************
37 | udp_rx:
38 | push eax
39 |
40 | ; First validate the header & checksum. Discard buffer if error
41 |
42 | ; Look for a socket where
43 | ; IP Packet UDP Destination Port = local Port
44 | ; IP Packet SA = Remote IP
45 |
46 | movzx ebx, word [edx + 22] ; get the local port from
47 | ; the IP packet's UDP header
48 | mov eax, SOCKETBUFFSIZE * NUM_SOCKETS
49 | mov ecx, NUM_SOCKETS
50 |
51 | fs1:
52 | sub eax, SOCKETBUFFSIZE
53 | cmp [eax + sockets + 12], bx ; bx will hold the 'wrong' value,
54 | ; but the comparision is correct
55 | loopnz fs1 ; Return back if no match
56 | jz fs_done
57 |
58 | ; No match, so exit
59 | jmp udprx_001
60 |
61 | fs_done:
62 | ; For dhcp, we must allow any remote server to respond.
63 | ; I will accept the first incoming response to be the one
64 | ; I bind to, if the socket is opened with a destination IP address of
65 | ; 255.255.255.255
66 | mov ebx, [eax + sockets + 16]
67 | cmp ebx, 0xffffffff
68 | je udprx_002
69 |
70 | mov ebx, [edx + 12] ; get the Source address from the IP packet
71 | cmp [eax + sockets + 16], ebx
72 | jne udprx_001 ; Quit if the source IP is not valid
73 |
74 | udprx_002:
75 | ; OK - we have a valid UDP packet for this socket.
76 | ; First, update the sockets remote port number with the incoming msg
77 | ; - it will have changed
78 | ; from the original ( 69 normally ) to allow further connects
79 | movzx ebx, word [edx + 20] ; get the UDP source port
80 | ; ( was 69, now new )
81 | mov [eax + sockets + 20], bx
82 |
83 | ; Now, copy data to socket. We have socket address as [eax + sockets].
84 | ; We have IP packet in edx
85 |
86 | ; get # of bytes in ecx
87 | movzx ecx, byte [edx + 3] ; total length of IP packet. Subtract
88 | mov ch, byte [edx + 2] ; 20 + 8 gives data length
89 | sub ecx, 28
90 |
91 | mov ebx, eax
92 | add ebx, sockets ; ebx = address of actual socket
93 |
94 | mov eax, [ebx+ 4] ; get socket owner PID
95 | push eax
96 |
97 | mov eax, [ebx + 24] ; get # of bytes already in buffer
98 | add [ebx + 24], ecx ; increment the count of bytes in buffer
99 |
100 | ; point to the location to store the data
101 | add ebx, eax
102 | add ebx, SOCKETHEADERSIZE
103 |
104 | ; ebx = location for first byte, ecx has count,
105 | ; edx points to data
106 |
107 | add edx, 28 ; edx now points to the data
108 | mov edi, ebx
109 | mov esi, edx
110 |
111 | cld
112 | rep movsb ; copy the data across
113 |
114 | ; flag an event to the application
115 | pop eax
116 | mov ecx,1
117 | mov esi,0x3020+0x4
118 |
119 | newsearch:
120 | cmp [esi],eax
121 | je foundPID
122 | inc ecx
123 | add esi,0x20
124 | cmp ecx,[0x3004]
125 | jbe newsearch
126 |
127 | foundPID:
128 | shl ecx,8
129 | or dword [ecx+0x80000+0xA8],dword 10000000b ; stack event
130 |
131 | mov [check_idle_semaphore],200
132 |
133 | udprx_001:
134 | pop eax
135 | call freeBuff ; Discard the packet
136 | ret
137 |
--------------------------------------------------------------------------------
/sound/playnote.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; PLAYNOTE.INC version 1.1 22 November 2003 ;;
4 | ;; ;;
5 | ;; Player Notes for Speaker PC ;;
6 | ;; subfunction #55 from function #55 Menuet OS ;;
7 | ;; ;;
8 | ;; Copyright 2003 VaStaNi ;;
9 | ;; vastani@ukr.net ;;
10 | ;; >>>- SIMPLY - QUICKLY - SHORTLY -<<< ;;
11 | ;; ;;
12 | ;; Note: playnote.txt ;;
13 | ;; ;;
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15 |
16 | kontrOctave dw 0x4742, 0x4342, 0x3F7C, 0x3BEC, 0x388F, 0x3562
17 | dw 0x3264, 0x2F8F, 0x2CE4, 0x2A5F, 0x2802, 0x25BF
18 | memAdrNote dd 0
19 | pidProcessNote dd 0
20 | slotProcessNote dd 0
21 | count_timer_Note dd 1
22 | mem8253r42 dw 0
23 | countDelayNote db 0
24 |
25 | playNote:
26 | ; jmp NotPlayNotes
27 | mov esi, [memAdrNote]
28 | or esi, esi ; ESI = 0 ? - OFF Notes Play ?
29 | jz NotPlayNotes ; if ESI = 0 -> ignore play pocedure
30 | cmp eax, [count_timer_Note]
31 | jb NotPlayNotes
32 | push eax
33 | inc eax
34 | mov [count_timer_Note], eax
35 | mov al, [countDelayNote]
36 | dec al ; decrement counter Delay for Playing Note
37 | jz NewLoadNote@Delay
38 | cmp al, 0xFF ; this is first Note Play ?
39 | jne NextDelayNote
40 | ;This is FIRST Note, save counter channel 2 chip 8253
41 | mov al, 0xB6 ; control byte to timer chip 8253
42 | out 0x43, al ; Send it to the control port chip 8253
43 | in al, 0x42 ; Read Lower byte counter channel 2 chip 8253
44 | mov ah, al ; AH = Lower byte counter channel 2
45 | in al, 0x42 ; Read Upper byte counter channel 2 chip 8253
46 | mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253
47 | NewLoadNote@Delay:
48 | cld
49 | ; lodsb ; load AL - counter Delay
50 | call ReadNoteByte
51 | or al, al ; THE END ?
52 | jz EndPlayNote
53 | cmp al, 0x81
54 | jnc NoteforOctave
55 | mov [countDelayNote], al
56 | ; lodsw ; load AX - counter for Note!
57 | call ReadNoteByte
58 | mov ah,al
59 | call ReadNoteByte
60 | xchg al,ah
61 | jmp pokeNote
62 |
63 | EndPlayNote: ; THE END Play Notes!
64 | in al, 0x61 ; Get contents of system port B chip 8255
65 | and al, 0xFC ; Turn OFF timer and speaker
66 | out 0x61, al ; Send out new values to port B chip 8255
67 | mov ax, [mem8253r42] ; memorize counter channel 2 timer chip 8253
68 | xchg al, ah ; reverse byte in word
69 | out 0x42, al ; restore Lower byte counter channel 2
70 | mov al, ah ; AL = Upper byte counter channel 2
71 | out 0x42, al ; restore Upper byte channel 2
72 | xor eax, eax ; EAX = 0
73 | mov [memAdrNote], eax ; clear header control Delay-Note string
74 | NextDelayNote:
75 | mov [countDelayNote], al ; save new counter delay Note
76 | pop eax
77 | NotPlayNotes:
78 | RET
79 |
80 | NoteforOctave:
81 | sub al, 0x81 ; correction value for delay Note
82 | mov [countDelayNote], al ; save counter delay this new Note
83 | ; lodsb ; load pack control code
84 | call ReadNoteByte
85 | cmp al, 0xFF ; this is PAUSE ?
86 | jne packCode ; no, this is PACK CODE
87 | in al, 0x61 ; Get contents of system port B chip 8255
88 | and al, 0xFC ; Turn OFF timer and speaker
89 | out 0x61, al ; Send out new values to port B chip 8255
90 | jmp saveESI
91 |
92 | packCode:
93 | mov cl, al ; save code
94 | and al, 0xF ; clear upper bits
95 | dec al ; correction
96 | add al, al ; transform number to offset constant
97 | movsx eax, al ; EAX - offset
98 | add eax, dword kontrOctave ; EAX - address from constant
99 | mov ax, [eax] ; read constant
100 | shr cl, 4 ; transform for number Octave
101 | shr ax, cl ; calculate from Note this Octave!
102 | pokeNote:
103 | out 0x42, al ; Lower byte Out to channel 2 timer chip 8253
104 | mov al, ah
105 | out 0x42, al ; Upper byte Out to channel 2 timer chip 8253
106 | in al, 0x61 ; Get contents of system port B chip 8255
107 | or al, 3 ; Turn ON timer and speaker
108 | out 0x61, al ; Send out new values to port B chip 8255
109 | saveESI:
110 | ; mov [memAdrNote], esi ; save new header control Delay-Note string
111 | pop eax
112 | RET
113 | ReadNoteByte:
114 | ;result:
115 | ; al - note
116 | push eax
117 | push ebx
118 | push ecx
119 | push edx
120 | mov eax,[pidProcessNote]
121 | call pid_to_slot
122 | test eax,eax
123 | jz .failed
124 | lea ebx,[esp+12]
125 | mov ecx,1
126 | mov edx,[memAdrNote]
127 | inc [memAdrNote]
128 | call read_process_memory
129 | .failed:
130 | pop edx
131 | pop ecx
132 | pop ebx
133 | pop eax
134 | ret
135 | ;------------------- END CODE -------------------
136 |
--------------------------------------------------------------------------------
/sound/sb16.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; SB16.INC ;;
4 | ;; ;;
5 | ;; Sound Blaster 16 functions for MenuetOS ;;
6 | ;; ;;
7 | ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
8 | ;; ;;
9 | ;; See file COPYING for details ;;
10 | ;; ;;
11 | ;; - 11.07.2002 8 bit stereo mode - Ville Turjanmaa ;;
12 | ;; ;;
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 |
15 |
16 | SB16_load_music equ 0xc0000000
17 | SB16_play_music equ 0xc0000001
18 | DMAPage equ 0x2A
19 | Rate equ 44100
20 | SB16Buffer equ 0x2A0000
21 | SB16_Status equ SB16Buffer+65536
22 |
23 | iglobal
24 | sound_data_format dd 0x1
25 | sound_data_length dd 65536
26 | sound_data_freq dd 44100
27 | endg
28 |
29 | sound_interface:
30 |
31 | cmp eax,0 ; Load data
32 | jne no_SB16_load_music
33 | mov edi,[0x3010]
34 | add edi,0x10
35 | add ebx,[edi]
36 | call code_SB16_load_music
37 | ret
38 | no_SB16_load_music:
39 |
40 | cmp eax,1 ; Play data
41 | jne no_SB16_play_music
42 | call code_SB16_play_music
43 | ret
44 | no_SB16_play_music:
45 |
46 | cmp eax,2 ; Set data formats
47 | jne no_SB16_data_format
48 | cmp ebx,0 ; ebx=0 play format
49 | jne no_sound_format
50 | mov [sound_data_format],ecx ; 1=8b mono, 2=8b stereo
51 | ret
52 | no_sound_format:
53 | cmp ebx,1 ; ebx=1 data length
54 | jne no_sound_length
55 | mov [sound_data_length],ecx ;
56 | ret
57 | no_sound_length:
58 | cmp ebx,2 ; ebx=2 sound data frequency
59 | jne no_sound_freq
60 | mov [sound_data_freq],ecx
61 | ret
62 | no_sound_freq:
63 | ret
64 |
65 | no_SB16_data_format:
66 |
67 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
68 | cmp eax, edi ; this is subfunction #55 ?
69 | jne retFunc55 ; if no then return.
70 | cmp byte [sound_flag],0
71 | jne retFunc55
72 | movzx eax, byte [countDelayNote]
73 | or al, al ; player is busy ?
74 | jnz retFunc55 ; return counter delay Note
75 | ; mov eax, [0x3010]
76 | ; mov eax, [eax+0x10] ; address application im memory
77 | ; add eax, edx ; add offset Delay-Note string
78 | ; mov [memAdrNote], eax
79 | mov [memAdrNote],edx
80 | mov eax,[0x3010]
81 | mov eax,[eax+4]
82 | mov [pidProcessNote],eax
83 | xor eax, eax ; Ok! EAX = 0
84 | retFunc55:
85 | mov [esp+36], eax ; return value EAX for application
86 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
87 |
88 | ret
89 |
90 |
91 |
92 |
93 | code_SB16_play_music:
94 |
95 | cmp [sound_data_format],1
96 | jne no_sound_8bm
97 | call sb_play_8b_mono
98 | ret
99 | no_sound_8bm:
100 |
101 | cmp [sound_data_format],2
102 | jne no_sound_8bs
103 | call sb_play_8b_stereo
104 | ret
105 | no_sound_8bs:
106 |
107 | ret
108 |
109 |
110 |
111 |
112 |
113 | Blaster_command:
114 |
115 | push eax
116 | push ecx
117 | push edx
118 |
119 | mov dx,word [sb16]
120 | add dx,0xc
121 | mov cx,1000
122 | bcl1:
123 | in al,dx
124 | and al,128
125 | jz bcl2
126 | loop bcl1
127 | bcl2:
128 | mov al,[esp+8]
129 | mov dx,[esp+0]
130 | add dx,word [sb16]
131 | out dx,al
132 |
133 | pop edx
134 | pop ecx
135 | pop eax
136 |
137 | ret
138 |
139 |
140 | sb_play_8b_stereo:
141 |
142 | pusha
143 |
144 | call sb_set_dma
145 |
146 | call sb_set_stereo
147 |
148 | mov dx,0xc
149 | mov al,0xa8
150 | call Blaster_command
151 |
152 | mov al,0x40
153 | call Blaster_command
154 |
155 | mov al,245
156 | call Blaster_command
157 |
158 | mov al,0x48
159 | call Blaster_command
160 |
161 | mov al,0xff
162 | call Blaster_command
163 | call Blaster_command
164 |
165 | mov al,0x91
166 | call Blaster_command
167 |
168 | popa
169 | ret
170 |
171 |
172 |
173 | sb_set_stereo:
174 |
175 | push eax
176 | push edx
177 |
178 | call sb_wait
179 |
180 | mov dx,word [sb16]
181 | add dx,0x4
182 | mov al,0xe
183 | out dx,al
184 | inc dx
185 | in al,dx
186 | and al,253
187 | or al,2 ; stereo
188 | out dx,al
189 |
190 | pop edx
191 | pop eax
192 | ret
193 |
194 |
195 |
196 | code_SB16_load_music:
197 |
198 | cmp byte [SB16_Status],1
199 | je nol
200 | mov edi,SB16Buffer
201 | mov esi,ebx
202 | mov ecx,65536/4
203 | cld
204 | rep movsd
205 | nol: ret
206 |
207 |
208 | iglobal
209 | dma_table db 0x87,0x83,0x81,0x82
210 | endg
211 |
212 |
213 |
214 | ;--------------------------------
215 | ; program dma
216 | ;--------------------------------
217 |
218 | sb_set_dma:
219 |
220 | pusha
221 |
222 | mov eax,[sound_dma]
223 | add eax,4
224 | out 0xa,al
225 |
226 | mov al,0
227 | out 0xc,al
228 |
229 | mov eax,[sound_dma]
230 | add eax,0x48
231 | out 0xb,al
232 |
233 | mov edx,[sound_dma]
234 | shl edx,1
235 | mov al,0
236 | out dx,al
237 |
238 | mov al,0
239 | out dx,al
240 |
241 | mov edx,[sound_dma]
242 | add edx,dma_table
243 | movzx edx,byte [edx]
244 | mov al,DMAPage
245 | out dx,al
246 |
247 | mov edx,[sound_dma]
248 | shl edx,1
249 | inc edx
250 | mov eax,[sound_data_length]
251 | dec eax
252 | and eax,0xff
253 | ; mov al,(DataLength-1) and 0xff
254 | out dx,al
255 |
256 | mov eax,[sound_data_length]
257 | dec eax
258 | shr eax,8
259 | ; mov al,(DataLength-1) shr 8
260 | out dx,al
261 |
262 | mov eax,[sound_dma] ; DMA
263 | out 0xa,al
264 |
265 | popa
266 | ret
267 |
268 |
269 |
270 | sb_play_8b_mono:
271 |
272 |
273 | call sb_set_dma
274 |
275 | cmp byte [SB16_Status],1
276 | jne contsb16
277 | jmp retserve
278 | contsb16:
279 |
280 | mov dx,word [sb16]
281 | add dx,4
282 | mov ecx,[sound_dma]
283 | mov ax,0x01
284 | shl ax,cl
285 | shl ax,8
286 | add ax,0x81
287 | out dx,ax
288 |
289 | mov ax,0f280h ;enable irq5
290 | out dx,ax
291 |
292 |
293 | adr1_SB: mov dx,word [sb16]
294 | add dx,0ch
295 | in al,dx
296 | and al,080h
297 | jnz adr1_SB
298 |
299 | call sb_set_stereo
300 |
301 | mov al,0d1h
302 | out dx,al
303 |
304 |
305 | mov dx,word [sb16]
306 | add dx,0ch
307 |
308 | call sb_wait
309 |
310 | mov al,40h ; Rate
311 | out dx,al
312 | call sb_wait
313 | mov al,256-1000000/Rate
314 | out dx,al
315 |
316 | call sb_wait
317 |
318 | mov al,14h ; Datalength
319 | out dx,al
320 | call sb_wait
321 |
322 | mov eax,[sound_data_length]
323 | dec eax
324 | and eax,0xff
325 | ;mov al,(DataLength-1) and 0xff
326 | out dx,al
327 | call sb_wait
328 | mov eax,[sound_data_length]
329 | dec eax
330 | shr eax,8
331 | ;mov al,(DataLength-1) shr 8
332 | out dx,al
333 |
334 | retserve:
335 |
336 | ret
337 |
338 |
339 | sb_wait: in al,dx ;wait
340 | and al,080h
341 | jnz sb_wait
342 |
343 | ret
344 |
345 |
346 |
347 |
348 | ;****************************************
349 | ; END CODE SB16 by Minazzi Paolo
350 | ;***************************************
351 |
--------------------------------------------------------------------------------
/video/vga.inc:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; ;;
3 | ;; VGA.INC ;;
4 | ;; ;;
5 | ;; 640x480 mode 0x12 VGA functions for MenuetOS ;;
6 | ;; ;;
7 | ;; Paul Butcher, paul.butcher@asa.co.uk ;;
8 | ;; ;;
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10 |
11 |
12 |
13 | paletteVGA:
14 |
15 | ;16 colour palette
16 | mov dx,0x3c8
17 | mov al,0
18 | out dx,al
19 |
20 | mov ecx,16
21 | mov dx,0x3c9
22 | xor eax,eax
23 |
24 | palvganew:
25 |
26 | mov al,0
27 | test ah,4
28 | jz palvgalbl1
29 | add al,31
30 | test ah,8
31 | jz palvgalbl1
32 | add al,32
33 | palvgalbl1:
34 | out dx,al ; red 0,31 or 63
35 | mov al,0
36 | test ah,2
37 | jz palvgalbl2
38 | add al,31
39 | test ah,8
40 | jz palvgalbl2
41 | add al,32
42 | palvgalbl2:
43 | out dx,al ; blue 0,31 or 63
44 | mov al,0
45 | test ah,1
46 | jz palvgalbl3
47 | add al,31
48 | test ah,8
49 | jz palvgalbl3
50 | add al,32
51 | palvgalbl3:
52 | out dx,al ; green 0,31 or 63
53 | add ah,1
54 | loop palvganew
55 |
56 | ret
57 |
58 |
59 | vga_putimage:
60 |
61 | push ebp ;
62 | push esi ;
63 | push edi ;
64 |
65 | push eax ;
66 | push ebx ; +8 [ptrImage]
67 | push ecx ; +4 [BH]
68 | push edx ; +0 [xy]
69 |
70 | movzx eax,word [esp+2] ; eax:=x
71 | movzx ebx,word [esp+0] ; ebx:=y
72 | mov ecx,[0x3010] ;
73 | add eax,[ecx-twdw] ; eax+=Xwin
74 | add ebx,[ecx-twdw+4] ; ebx+=Ywin
75 | mov ecx,ebx ; ecx = y+Ywin
76 | mov edx,eax ; edx = x+Xwin
77 |
78 | imul ebx, 640*4 ; (y+Ywin)*BytesPerScanLine
79 | shl eax,2 ; (x+Xwin)*BytesPerPixel
80 | add eax,ebx ;
81 | mov edi,eax ; store copy
82 | add eax,[0xfe80] ; +AddrLFB
83 | ;entry point in LFB >> EAX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrLFB
84 |
85 | shr edi,5 ; change from 4 to 1/8 BytesPerPixel
86 | add edi,0xa0000 ; + VGABasePtr
87 | ;VGA start address >> EDI:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrVGA
88 |
89 | mov ebx, [0xfe00] ; ScreenXSize
90 | inc ebx ; +1
91 | imul ebx,ecx ; *(y+Ywin)
92 | mov ebp, ebx ;
93 | add ebp, edx ; +(x+Xwin)
94 | add ebp, WinMapAddress ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
95 |
96 | mov esi,[esp+8] ; esi:=AddrImg
97 | movzx ecx,word [esp+6] ; ecx:=B
98 | movzx ebx,word [esp+4] ; ebx:=H
99 |
100 | ; check limits while draw ?
101 |
102 | push ecx ; B
103 | push eax ; LFB address
104 |
105 | mov eax,[0x3010]
106 | mov ecx,[eax+draw_data-0x3000+0]
107 | cmp ecx,0
108 | jnz dbcblimitlset_vga
109 |
110 | mov ecx,[eax+draw_data-0x3000+4]
111 | cmp ecx,0
112 | jnz dbcblimitlset_vga
113 |
114 | mov ecx,[eax+draw_data-0x3000+8]
115 | cmp ecx,[0xfe00] ; ecx <> Screen X size
116 | jnz dbcblimitlset_vga
117 |
118 | mov ecx,[eax+draw_data-0x3000+12]
119 | cmp ecx,[0xfe04] ; ecx <> Screen Y size
120 | jnz dbcblimitlset_vga
121 |
122 | pop eax ; LFB address
123 | pop ecx ; B
124 |
125 | push dword 0
126 |
127 | jmp pimvga
128 |
129 | dbcblimitlset_vga:
130 |
131 | pop eax ; LFB address
132 | pop ecx ; B
133 |
134 | push dword 1
135 |
136 | pimvga:
137 | push edi
138 | push esi
139 | push eax ; LFB address
140 | push ecx ; B
141 | push ebx ; H
142 | push edx ; x+Xwin
143 |
144 | mov ebx,[0x3010]
145 | mov bl,[ebx+0xe]
146 | mov bh,[esp+6*4]
147 |
148 | cld
149 |
150 | npvga:
151 |
152 | cmp bl,[ds:ebp]
153 | jnz impvgano
154 |
155 | ; cmp bh,0
156 | ; jz impvgayes
157 |
158 | ; call voodoodbcplimit
159 | ; jnz impvgano
160 |
161 | ; impvgayes:
162 |
163 | push eax ; LFB address
164 | push ebx ; app no.
165 | push ecx ; B
166 | push edx ; x+Xwin
167 |
168 | mov edx,[esi] ; color
169 | mov [eax],dx
170 | shr edx,16
171 | mov [eax+2],dl
172 |
173 | mov eax,[esi] ; color
174 | mov ecx,[esp] ; x+Xwin
175 | and ecx,0x07 ; modulo 8
176 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address
177 |
178 | pop edx
179 | pop ecx
180 | pop ebx
181 | pop eax
182 |
183 | impvgano:
184 |
185 | add esi,3 ; esi+=3 ptrImage+=3
186 | add eax,4 ; eax+=4 LFBaddr +=4
187 | inc ebp
188 | inc edx ; x+Xwin+n
189 |
190 | test edx,0x07 ; test modulo 8
191 | jnz impvgacont
192 | inc edi
193 |
194 | impvgacont:
195 | dec ecx ; B--
196 | jnz npvga
197 |
198 | pop edx
199 | pop ebx
200 | pop ecx
201 | pop eax
202 | pop esi
203 | pop edi
204 |
205 | add edi,640/8 ; add one VGA line
206 | add eax,640*4 ; add one LFB line
207 |
208 | sub ebp, ecx ; -B
209 | add ebp, [0xfe00] ;
210 | inc ebp ; ptrBuffer:=ptrBuffer-B+Screen_Xsize+1
211 |
212 | push ecx
213 | lea ecx,[ecx+ecx*2] ;
214 | add esi,ecx ; ptrImage:=ptrImage+B*3
215 | pop ecx
216 |
217 | dec ebx ; H--
218 | jnz near pimvga
219 |
220 | add esp,4 ; jump saved limit byte
221 | pop edx
222 | pop ecx
223 | pop ebx
224 | pop eax
225 | pop edi
226 | pop esi
227 | pop ebp
228 |
229 | ret
230 |
231 |
232 | VGA_putpixel:
233 |
234 | ; eax = x
235 | ; ebx = y
236 |
237 | mov ecx,eax
238 | mov eax, [esp+32-8+4] ; color
239 |
240 | imul ebx, 640*4 ; y*BytesPerLine (Vesa2.0 32)
241 | lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32)
242 |
243 | mov edi,edx
244 | add edi, [0xfe80] ; + LFB address
245 | mov [edi], eax ; write to LFB for Vesa2.0
246 |
247 | shr edx,5 ; change BytesPerPixel to 1/8
248 | mov edi,edx
249 | add edi, 0x0a0000 ; address of pixel in VGA area
250 |
251 | and ecx,0x07 ; bit no. (modulo 8)
252 |
253 | setvgapixel:
254 |
255 | ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8)
256 |
257 | push eax
258 | mov ebx,eax ; color
259 |
260 | ;mov al,0x08
261 | ;mov dx,0x03ce
262 | ;out dx,al ; select GDC bit mask register
263 |
264 | inc cl
265 | mov ax, 0x100
266 | shr ax,cl
267 | mov dx,0x03cf
268 | out dx,al ; set bit mask for pixel
269 |
270 | mov dl,0
271 | mov eax,ebx
272 | and eax,0x000000ff ; blue
273 | cmp eax,85
274 | jle p13green
275 | or dl,0x01
276 | cmp eax,170
277 | jle p13green
278 | or dl,0x08
279 |
280 | p13green:
281 | and ebx,0x0000ff00 ; green
282 | cmp ebx,85*256
283 | jle p13red
284 | or dl,0x02
285 | cmp ebx,170*256
286 | jle p13red
287 | or dl,0x08
288 |
289 | p13red:
290 | pop ebx
291 | and ebx,0x00ff0000 ; red
292 | cmp ebx,85*256*256
293 | jle p13cont
294 | or dl,0x04
295 | cmp ebx,170*256*256
296 | jle p13cont
297 | or dl,0x08
298 |
299 | p13cont:
300 | mov al,[edi] ; dummy read
301 | mov [edi],dl
302 |
303 | ret
304 |
305 |
306 | vga_drawbar:
307 |
308 | sub edx,ebx ; edx:=Yend-Ystart=H
309 | sub ecx,eax ; ecx:=Xend-Xstat=B
310 |
311 | push ebp ; +24
312 | push esi ; +20
313 | push edi ; +16
314 | push eax ; +12
315 | push ebx ; +8
316 | push ecx ; +4
317 | push edx ; +0
318 |
319 | mov ecx,[0x3010] ;
320 | add eax,[ecx-twdw] ; eax:=Xwin+x
321 | add ebx,[ecx-twdw+4] ; ebx:=Ywin+y
322 | mov ecx, eax ; ecx:=(x+Xwin)
323 | mov edx, ebx ; edx:=(y+Ywin)
324 |
325 | imul ebx, 640/8 ;
326 | mov edi, ebx ; edi:=BytesPerScanLine*(y+Ywin)
327 | shr eax, 3 ;
328 | add edi, eax ; + (x+Xwin)*BytesPerPixel
329 | add edi,0xa0000 ; + VGAbaseaddress
330 |
331 | mov eax, [0xfe00] ; ScreenXSize
332 | inc eax ; +1
333 | imul eax,edx ; *(y+Ywin)
334 | mov ebp, eax ;
335 | add ebp, ecx ; +(x+Win)
336 | add ebp, WinMapAddress ; +AddrBuffer
337 |
338 | mov eax, [0xfe08] ; BytesPerScanLine - LFB
339 | mul edx ; *(y+Ywin)
340 | mov esi,eax
341 | add esi,ecx
342 | add esi,ecx
343 | add esi,ecx
344 | add esi,ecx ; + 4*(x+Xwin)
345 | add esi,[0xfe80] ; +AddrLFB
346 |
347 | ; edi:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel + AddrVGA
348 | ; esi:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel + AddrLFB
349 | ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
350 |
351 | ; x size
352 |
353 | mov eax,[esp+4] ; B [esp+4]
354 | mov ebx,[esp+0] ; H
355 |
356 | mov edx,[esp+16] ; color
357 | test edx,0x80000000
358 | jz nodbglvga
359 |
360 | ; no color glide for VGA - set to half glide
361 | shr ebx,1 ; H/2
362 | sub edx,ebx
363 | mov [esp+16],edx
364 | mov ebx,[esp+0] ; reset to H
365 |
366 | nodbglvga:
367 | ; check limits ?
368 |
369 | push eax
370 | push ecx
371 |
372 | mov eax,[0x3010]
373 |
374 | mov ecx,[eax+draw_data-0x3000+0]
375 | cmp ecx,0
376 | jnz dbcblimitlset_vga2
377 |
378 | mov ecx,[eax+draw_data-0x3000+4]
379 | cmp ecx,0
380 | jnz dbcblimitlset_vga2
381 |
382 | mov ecx,[eax+draw_data-0x3000+8]
383 | cmp ecx,[0xfe00]
384 | jnz dbcblimitlset_vga2
385 |
386 | mov ecx,[eax+draw_data-0x3000+12]
387 | cmp ecx,[0xfe04]
388 | jnz dbcblimitlset_vga2
389 |
390 | pop ecx
391 | pop eax
392 |
393 | push dword 0
394 |
395 | jmp dbnewpivga
396 |
397 | dbcblimitlset_vga2:
398 |
399 | pop ecx ; x+Xwin
400 | pop eax ; B
401 |
402 | push dword 1
403 |
404 | dbnewpivga:
405 |
406 | push eax; B
407 | push ebx ; H
408 | push edi
409 | push esi
410 | push ecx ; x+Xwin
411 |
412 | mov ebx,[0x3010]
413 | movzx ebx,byte[ebx+0xe]
414 |
415 | cld
416 |
417 | dbnpvga:
418 |
419 | mov dl,[ds:ebp]
420 |
421 | cmp dl,bl
422 | jnz dbimpvgano
423 |
424 | ; mov edx,[esp+5*4] ; check limit?
425 | ; cmp edx,0
426 | ; jz dbimpvgayes
427 |
428 | ; call voodoodbcplimit
429 | ; jnz dbimpvgano
430 |
431 | ; dbimpvgayes:
432 |
433 | push eax ; B
434 | push ebx
435 | push ecx ; x+Xwin
436 |
437 | mov eax,[esp+12+20+16+4] ; color
438 | mov ebx,eax
439 |
440 | mov [esi],bx ; write LFB pixel
441 | shr ebx,16
442 | mov [esi+2],bl
443 |
444 | and ecx,0x07 ; modulo 8
445 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address
446 |
447 | pop ecx
448 | pop ebx
449 | pop eax
450 |
451 | dbimpvgano:
452 |
453 | add esi,4 ; ptrLFB+=4
454 | inc ebp ; address buffer
455 | inc ecx ; x posn++
456 | test ecx,0x07 ; test modulo 8
457 | jnz dbvgacont
458 | inc edi ; VGA screen ptr++
459 |
460 | dbvgacont:
461 | dec eax ; B-- NB ecx in Vesa20 fn?
462 | jnz dbnpvga
463 |
464 | dbnpvgad:
465 |
466 | pop ecx
467 | pop esi
468 | pop edi
469 | pop ebx
470 | pop eax
471 |
472 | add esi,[0xfe08] ; ptrLFB+=BytesPerScanLine
473 | add edi,640/8 ; ptrScreen+=BytesPerScanLine
474 |
475 | add ebp,[0xfe00] ;
476 | sub ebp, eax ; was ecx in vesa20 fn?
477 | inc ebp ; ptrBuffer:=ptrBuffer-B+BytesPerLine+1
478 |
479 | dec ebx ; H--
480 | jz nodbnewpivga ; H<>0
481 |
482 | jmp dbnewpivga
483 |
484 | nodbnewpivga:
485 |
486 | add esp,7*4 ; NB includes limit check flag
487 | ;pop ebx
488 | ;pop eax
489 | ;pop edi
490 | ;pop esi
491 | pop ebp
492 |
493 | ;pop edx
494 | ;pop ecx
495 |
496 | ret
497 |
498 |
499 | vga_drawbackground_tiled:
500 |
501 | push ebp
502 | push eax
503 | push ebx
504 | push ecx
505 | push edx
506 |
507 | mov edx,dword [0x400000-8] ; B
508 | add edx,dword [WinMapAddress-8] ; +B
509 | add edx,dword [WinMapAddress-8] ; +B
510 | push edx
511 |
512 | mov eax,[draw_data+32+0] ; x start:=(x+Xwin)
513 | mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
514 | mov ecx,eax
515 | mov edx,ebx
516 |
517 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine
518 | shl ecx,2 ; (x+Xwin)*BytesPerPixel
519 | add ecx,edx ;
520 | mov ebp,ecx ; store copy
521 | add ecx,[0xfe80] ; +AddrLFB
522 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
523 |
524 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel
525 | add ebp,0xa0000 ; + VGABasePtr
526 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV
527 |
528 |
529 | call calculate_edi
530 |
531 | dp3vga: ; MAIN LOOP
532 |
533 | cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
534 | je ybgpvga
535 |
536 | jmp nbgpvga
537 |
538 | ybgpvga:
539 |
540 | push eax ; x
541 | push ebx ; y
542 | push ecx ; LFB address
543 |
544 | mov ecx,dword [WinMapAddress-8] ; B
545 | xor edx,edx ; edx:=0
546 | div ecx ; Xstart/B
547 |
548 | ; eax=Int(qn) edx:=Rem
549 |
550 | lea esi,[edx+edx*2] ; esi:=edx*3
551 |
552 | mov ecx,dword [WinMapAddress-4] ; ecx:=H
553 | mov eax,[esp+4] ; eax:=Ystart
554 | xor edx,edx ;
555 | div ecx ; Ystart/H
556 |
557 | mov eax,edx ; eax:=Rem
558 | xor edx,edx ;
559 | mov ebx,[esp+12] ; ebx:=B*3
560 | mul ebx ;
561 | add esi,eax ;
562 |
563 | mov eax,[esi+0x300000] ; color
564 | and eax,0xffffff
565 |
566 | mov ecx, [esp] ; LFB address
567 | mov ebx,eax ; copy color
568 | mov [ecx],bx
569 | shr ebx,16
570 | mov [ecx+2],bl
571 |
572 | xchg edi, ebp
573 | mov ecx,[esp+8] ; x position
574 | and ecx,0x07 ; x modulo 8
575 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address
576 | xchg ebp, edi
577 |
578 | pop ecx
579 | pop ebx
580 | pop eax
581 |
582 | nbgpvga:
583 |
584 | inc eax ; x++
585 | cmp eax,[draw_data+32+8] ; X > xend?
586 | jg nodp3vga
587 |
588 | test eax,0x07 ; x test modulo 8
589 | jnz hook1vga
590 | inc ebp ; VGA address++
591 |
592 | hook1vga:
593 | add ecx,4 ; LFB address += 4
594 | inc edi ; ptrBuffer++
595 | add esi,3 ; ptrImage+=3
596 | jmp dp3vga
597 |
598 | nodp3vga:
599 |
600 | mov eax,[draw_data+32+0] ; x+Xwin
601 | inc ebx ; y position
602 | mov ecx,eax
603 | mov edx,ebx
604 |
605 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine
606 | shl ecx,2 ; (x+Xwin)*BytesPerPixel
607 | add ecx,edx ;
608 | mov ebp,ecx ; store copy
609 | add ecx,[0xfe80] ; +AddrLFB
610 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
611 |
612 |
613 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel
614 | add ebp,0xa0000 ; + VGABasePtr
615 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV
616 |
617 |
618 | call calculate_edi
619 |
620 | cmp ebx,[draw_data+32+12] ; Y > yend
621 | jg dp4vga
622 |
623 | jmp dp3vga
624 |
625 | dp4vga:
626 |
627 | add esp,4
628 |
629 | pop edx
630 | pop ecx
631 | pop ebx
632 | pop eax
633 | pop ebp
634 |
635 | ret
636 |
637 | ; ----------
638 |
639 |
640 |
641 | vga_drawbackground_stretch:
642 |
643 |
644 | push ebp
645 | push eax
646 | push ebx
647 | push ecx
648 | push edx
649 |
650 | mov edx,dword [WinMapAddress-8] ; B
651 | add edx,dword [WinMapAddress-8] ; +B
652 | add edx,dword [WinMapAddress-8] ; +B
653 | push edx
654 |
655 | mov eax,[draw_data+32+0] ; x start:=(x+Xwin)
656 | mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
657 | mov ecx,eax
658 | mov edx,ebx
659 |
660 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine
661 | shl ecx,2 ; (x+Xwin)*BytesPerPixel
662 | add ecx,edx ;
663 | mov ebp,ecx ; store copy
664 | add ecx,[0xfe80] ; +AddrLFB
665 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
666 |
667 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel
668 | add ebp,0xa0000 ; + VGABasePtr
669 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV
670 |
671 |
672 | call calculate_edi
673 |
674 | sdp3vga: ; MAIN LOOP
675 |
676 | cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
677 | je sybgpvga
678 |
679 | jmp snbgpvga
680 |
681 | sybgpvga:
682 |
683 | push eax ; x
684 | push ebx ; y
685 | push ecx ; LFB address
686 |
687 | mov eax,dword [WinMapAddress-8] ; B
688 | xor edx,edx
689 | mov ebx,[esp+8] ; Xstart
690 | mul ebx ; B*Xstart
691 | xor edx,edx
692 | mov ebx,[0xfe00] ; x screen width
693 | div ebx ; B*Xstart/xwidth
694 | lea esi,[eax+eax*2] ; *3
695 | mov eax,dword [WinMapAddress-4] ; H
696 | xor edx,edx
697 | mov ebx,[esp+4] ; Ystart
698 | mul ebx ; H*Ystart
699 | xor edx,edx
700 | mov ebx,[0xfe04] ; y screen height
701 | div ebx ; H*Ystart/yheight
702 |
703 | xor edx,edx
704 | mov ebx,[esp+12] ; B*3
705 | mul ebx ;
706 | add esi,eax
707 | mov eax,[esi+0x300000] ; color
708 | and eax,0xffffff
709 |
710 | mov ecx, [esp] ; LFB address
711 | mov ebx,eax ; copy color
712 | mov [ecx],bx
713 | shr ebx,16
714 | mov [ecx+2],bl
715 |
716 | xchg edi, ebp
717 | mov ecx,[esp+8] ; x position
718 | and ecx,0x07 ; x modulo 8
719 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address
720 | xchg ebp, edi ; ebp+=3
721 |
722 | pop ecx
723 | pop ebx
724 | pop eax
725 |
726 | snbgpvga:
727 |
728 | inc eax ; x++
729 | cmp eax,[draw_data+32+8] ; X > xend?
730 | jg snodp3vga
731 |
732 | test eax,0x07 ; x test modulo 8
733 | jnz shook1vga
734 | inc ebp ; VGA address++
735 |
736 | shook1vga:
737 | add ecx,4 ; LFB address += 4
738 | inc edi ; ptrBuffer++
739 | add esi,3 ; ptrImage+=3
740 | jmp sdp3vga
741 |
742 | snodp3vga:
743 |
744 | mov eax,[draw_data+32+0] ; x+Xwin
745 | inc ebx ; y position
746 | mov ecx,eax
747 | mov edx,ebx
748 |
749 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine
750 | shl ecx,2 ; (x+Xwin)*BytesPerPixel
751 | add ecx,edx ;
752 | mov ebp,ecx ; store copy
753 | add ecx,[0xfe80] ; +AddrLFB
754 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
755 |
756 |
757 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel
758 | add ebp,0xa0000 ; + VGABasePtr
759 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+A
760 |
761 |
762 | call calculate_edi
763 |
764 | cmp ebx,[draw_data+32+12] ; Y > yend
765 | jg sdp4vga
766 |
767 | jmp sdp3vga
768 |
769 | sdp4vga:
770 |
771 | add esp,4
772 |
773 | pop edx
774 | pop ecx
775 | pop ebx
776 | pop eax
777 | pop ebp
778 |
779 | ret
780 |
781 |
782 |
--------------------------------------------------------------------------------
/vmodeint.inc:
--------------------------------------------------------------------------------
1 | ;
2 | ; Call of videomode driver's functions
3 | ;
4 | ; (Add in System function 21 (and/or 26) as a subfunction 13)
5 | ;
6 | ; Author: Trans
7 | ; Date: 19.07.2003
8 | ;
9 | ; Include in MeOS kernel and compile with FASM
10 | ;
11 | cmp eax,13 ; CALL VIDEOMODE DRIVER FUNCTIONS
12 | jne .no_vmode_drv_access
13 | or eax,-1 ; If driver is absent then eax does not change
14 | call 0x760100 ; Entry point of video driver
15 | mov [esp+36],eax
16 | mov [esp+24],ebx
17 | mov [esp+32],ecx
18 | ; mov [esp+28],edx
19 | ret
20 | .no_vmode_drv_access:
21 |
--------------------------------------------------------------------------------
/vmodeld.inc:
--------------------------------------------------------------------------------
1 | ;
2 | ; Load of videomode driver in memory
3 | ;
4 | ; (driver is located at 0x760000-0x768000 - 32kb) // if this area not occuped anything
5 | ;
6 | ; Author: Trans
7 | ; Date: 19.07.2003
8 | ;
9 | ; Include in MeOS kernel and compile with FASM
10 | ;
11 |
12 |
13 | ;vmode db 'VMODE MDR' ; MDR - Menuet Driver
14 | ; must be located after fonts filenames in kernel.asm
15 |
16 | ; LOAD VIDEOMODE DRIVER
17 | ; If vmode.mdr file not found
18 | or eax,-1 ; Driver ID = -1 (not present in system)
19 | mov [0x760000],eax ;
20 | mov [0x760100],byte 0xC3 ; Instruction RETN - driver loop
21 |
22 | mov eax,vmode ; File name of driver
23 | mov esi,12
24 | mov ebx,0
25 | mov ecx,26000
26 | mov edx,0x760000 ; Memory position of driver
27 | call fileread
--------------------------------------------------------------------------------