forked from KolibriOS/kolibrios
Compare commits
287 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0502a61207 | ||
|
|
76d3050df9 | ||
|
|
1aafb8c866 | ||
|
|
de9db47e0a | ||
|
|
271a1c2ecd | ||
|
|
3ea0750ebe | ||
|
|
579829b9f9 | ||
|
|
cc80eeaa07 | ||
|
|
5b0eb8ab98 | ||
|
|
db4ac47e56 | ||
|
|
979e9112da | ||
|
|
ef27b83e97 | ||
|
|
21572e62ae | ||
|
|
075c0ea71a | ||
|
|
c682e2d8c0 | ||
|
|
a89bf95159 | ||
|
|
13528c5c97 | ||
|
|
b661da340a | ||
|
|
82fe412a09 | ||
|
|
5a467f60e3 | ||
|
|
dfe81eb28d | ||
|
|
a79e7c4171 | ||
|
|
3111c3f230 | ||
|
|
0989244bd5 | ||
|
|
a6c8d276c3 | ||
|
|
5121a68d46 | ||
|
|
1ace68286b | ||
|
|
5756e1bfc8 | ||
|
|
8d88fe9531 | ||
|
|
577eed1321 | ||
|
|
4256086104 | ||
|
|
f2647d013c | ||
|
|
71974025fe | ||
|
|
822a9715c4 | ||
|
|
e7d381a4b4 | ||
|
|
2c4d922032 | ||
|
|
f050c18f32 | ||
|
|
c5afda25bd | ||
|
|
487569711c | ||
|
|
7038d7bc41 | ||
|
|
a17b90b7b3 | ||
|
|
e7be690de5 | ||
|
|
dbd82dd523 | ||
|
|
254c631866 | ||
|
|
d51f1259a0 | ||
|
|
d1b95f89ef | ||
|
|
b5e0fe41ca | ||
|
|
0e85b8f362 | ||
|
|
c40426acda | ||
|
|
e15c3449f3 | ||
|
|
b542bfb588 | ||
|
|
c3a36dffbc | ||
|
|
94747a3d1a | ||
|
|
3f37e88368 | ||
|
|
73aa6c6d6a | ||
|
|
72cb45f7f1 | ||
|
|
98348199e8 | ||
|
|
da76b9b73a | ||
|
|
aef32ec859 | ||
|
|
6cda8bcecd | ||
|
|
ad7724b20b | ||
|
|
a646a65def | ||
|
|
6ab013ea0b | ||
|
|
5462727f9c | ||
|
|
b1fda0395c | ||
|
|
983c7036a5 | ||
|
|
15170454cc | ||
|
|
c6080c59e9 | ||
|
|
14256358ea | ||
|
|
f825a71d89 | ||
|
|
a9706fb6ca | ||
|
|
1e7402569a | ||
|
|
55ed9e2720 | ||
|
|
1db135d09c | ||
|
|
7cae037e85 | ||
|
|
0cb93396cf | ||
|
|
b9300edb72 | ||
|
|
d6ffa8cd02 | ||
|
|
2f3e0a30ee | ||
|
|
62f0273742 | ||
|
|
da2d1b6055 | ||
|
|
fd12438007 | ||
|
|
18334aa2f8 | ||
|
|
49830b7fd4 | ||
|
|
dd99e0d71a | ||
|
|
3fd82557ce | ||
|
|
853d0ada7d | ||
|
|
7fe01d3053 | ||
|
|
ce67c673a0 | ||
|
|
82ef5da45f | ||
|
|
acc759e3d8 | ||
|
|
b308bbdde7 | ||
|
|
af99f0b88d | ||
|
|
f5b902bbee | ||
|
|
d40f7261aa | ||
|
|
63e2b216d4 | ||
|
|
016250f984 | ||
|
|
9d8d99d478 | ||
|
|
c0f513c3db | ||
|
|
62564c56b0 | ||
|
|
88e9e4be91 | ||
|
|
08a4dc7f2d | ||
|
|
c4329e6227 | ||
|
|
6ec45316ae | ||
|
|
b22c241723 | ||
|
|
3a022d4441 | ||
|
|
e85c475db0 | ||
|
|
c30932c83e | ||
|
|
0575dbf098 | ||
|
|
a337842d61 | ||
|
|
54e1aacfec | ||
|
|
46d4105bf9 | ||
|
|
79e75903db | ||
|
|
2a4b34f171 | ||
|
|
d510d16f49 | ||
|
|
1ad99d565b | ||
|
|
62c4becf44 | ||
|
|
01056f99f2 | ||
|
|
1c9a42e362 | ||
|
|
86db9e1fc4 | ||
|
|
36ae3b7991 | ||
|
|
94294b0b80 | ||
|
|
7d89df5d1b | ||
|
|
077f779dea | ||
|
|
8871a59fcf | ||
|
|
b648a77792 | ||
|
|
7f38fb4c37 | ||
|
|
eefd849556 | ||
|
|
0d0ebf947b | ||
|
|
4b390b8b1a | ||
|
|
957f33b4ba | ||
|
|
e1c5ec4c11 | ||
|
|
1391dd1d1d | ||
|
|
00b8fb388c | ||
|
|
44a74d9138 | ||
|
|
f96c2c867c | ||
|
|
763bc3ad70 | ||
|
|
fa83bf6c24 | ||
|
|
ca9c99d8c9 | ||
|
|
9e37e39a22 | ||
|
|
4584e8c2df | ||
|
|
7c1c3a07a8 | ||
|
|
3eda462807 | ||
|
|
e7139a65a7 | ||
|
|
c6d6567ec3 | ||
|
|
4b73c68fff | ||
|
|
c9a1b11964 | ||
|
|
ed2a996944 | ||
|
|
f5c7d5551c | ||
|
|
40b1c24dc3 | ||
|
|
7206330557 | ||
|
|
8e9cf5aa3a | ||
|
|
ae5e114234 | ||
|
|
ef2a2e0e6a | ||
|
|
1668ac9032 | ||
|
|
be5ccc0bc1 | ||
|
|
1d515a0c77 | ||
|
|
4708579954 | ||
|
|
ad550e216e | ||
|
|
ad55c9aee2 | ||
|
|
7d1826758e | ||
|
|
85aa5c3167 | ||
|
|
5e5bb72582 | ||
|
|
ddb7a72c8b | ||
|
|
fc4d6ab4af | ||
|
|
b4dd0c152f | ||
|
|
aacb4b7591 | ||
|
|
7c8ba5ff40 | ||
|
|
f9f3d06971 | ||
|
|
95366971d1 | ||
|
|
5a16823ef7 | ||
|
|
bed870101d | ||
|
|
ab3caba8a7 | ||
|
|
de97cea06c | ||
|
|
e60d47ae50 | ||
|
|
174a707452 | ||
|
|
8609e45095 | ||
|
|
9395f92693 | ||
|
|
6c854695d0 | ||
|
|
233c3e6435 | ||
|
|
6f8abcc3e7 | ||
|
|
ec7c8397d5 | ||
|
|
1634ac97c2 | ||
|
|
b6950333ac | ||
|
|
0e39a3fffe | ||
|
|
2e850e52f6 | ||
|
|
603863d00c | ||
|
|
393a43c2ba | ||
|
|
4d719e6bc5 | ||
|
|
6127c7381d | ||
|
|
69e4361cc8 | ||
|
|
b239f46ecb | ||
|
|
1e0680aa80 | ||
|
|
7f1f402a78 | ||
|
|
2665e9eebc | ||
|
|
bede2c62e6 | ||
|
|
cfec947b3a | ||
|
|
18c3550908 | ||
|
|
94b3a5b74e | ||
|
|
58ea327b12 | ||
|
|
990e3f745c | ||
|
|
87aca91906 | ||
|
|
51d395d0cc | ||
|
|
7df9c18621 | ||
|
|
55d060c456 | ||
|
|
7e19914ef4 | ||
|
|
1eba0190d0 | ||
|
|
bb515acb25 | ||
|
|
d3ae4b4e07 | ||
|
|
c32993d622 | ||
|
|
d37931f10a | ||
|
|
334f7721de | ||
|
|
65cbed8f0d | ||
|
|
dde2612191 | ||
|
|
ec76c66cd2 | ||
|
|
8df5cba38d | ||
|
|
16091ddd9e | ||
|
|
b573c43d09 | ||
|
|
e3172037f7 | ||
|
|
19bd066c8c | ||
|
|
10aa08b39b | ||
|
|
c0ef030710 | ||
|
|
615d8e83ab | ||
|
|
5551095432 | ||
|
|
fdae3a8463 | ||
|
|
11c04adbbc | ||
|
|
857f757f85 | ||
|
|
28e25be617 | ||
|
|
df2e1aa3a9 | ||
|
|
d99e3ea921 | ||
|
|
5638fe22ff | ||
|
|
bf63dda480 | ||
|
|
3e2bc5b35f | ||
|
|
9a27b206b3 | ||
|
|
7a1e29cbc9 | ||
|
|
849b393cad | ||
|
|
fca11d7700 | ||
|
|
f9a3eb973f | ||
|
|
630234432f | ||
|
|
5aa9386dcc | ||
|
|
bbc7ddcf4f | ||
|
|
07ff3f1978 | ||
|
|
82859246df | ||
|
|
45e9240e92 | ||
|
|
16e3ab15b2 | ||
|
|
c5b30426a8 | ||
|
|
ad532cdbaa | ||
|
|
d925b54ad5 | ||
|
|
ad6d923147 | ||
|
|
251420e666 | ||
|
|
400f8f145d | ||
|
|
0727181583 | ||
|
|
548cefab68 | ||
|
|
497393b8cb | ||
|
|
e44a4705bc | ||
|
|
56d23ae060 | ||
|
|
c1783c769f | ||
|
|
3ac6e40242 | ||
|
|
6cc0b12acb | ||
|
|
b429107fec | ||
|
|
4a1560020b | ||
|
|
b3a457d97d | ||
|
|
62da2ad490 | ||
|
|
8c3875e438 | ||
|
|
1e5f55f29c | ||
|
|
26d6c6af0e | ||
|
|
858db1a8a3 | ||
|
|
cb6852bc2c | ||
|
|
65a732dc5a | ||
|
|
60290f1452 | ||
|
|
0b65f18e93 | ||
|
|
c9d4558817 | ||
|
|
17da7e7f7a | ||
|
|
9d76fed06e | ||
|
|
a939e78130 | ||
|
|
0d97209173 | ||
|
|
7c7f68ee6f | ||
|
|
12ecff7fb2 | ||
|
|
7e96e14297 | ||
|
|
09f8067f56 | ||
|
|
d3d3fc15c6 | ||
|
|
aa7be4e6f1 | ||
|
|
9b016cea47 | ||
|
|
f08ff6ca70 | ||
|
|
5db3c3adc1 | ||
|
|
e9e0059192 | ||
|
|
03b4d7367e |
546
kernel/branches/gfx_kernel/blkdev/cd_drv.inc
Normal file
546
kernel/branches/gfx_kernel/blkdev/cd_drv.inc
Normal file
@@ -0,0 +1,546 @@
|
||||
;**********************************************************
|
||||
; Непосредственная работа с устройством СD (ATAPI)
|
||||
;**********************************************************
|
||||
; Автор исходного текста Кулаков Владимир Геннадьевич.
|
||||
; Адаптация и доработка Mario79
|
||||
|
||||
; Процедура для полного считывания всех
|
||||
; данных из сектора компакт-диска
|
||||
; Автор текста программы Кулаков Владимир Геннадьевич.
|
||||
|
||||
|
||||
; Максимальное количество повторений операции чтения
|
||||
MaxRetr equ 3
|
||||
; Предельное время ожидания готовности к приему команды
|
||||
; (в тиках)
|
||||
BSYWaitTime equ 1000 ;2
|
||||
|
||||
;*************************************************
|
||||
;* ПОЛНОЕ ЧТЕНИЕ СЕКТОРА КОМПАКТ-ДИСКА *
|
||||
;* Считываются данные пользователя, информация *
|
||||
;* субканала и контрольная информация *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале; *
|
||||
;* CDSectorAddress - адрес считываемого сектора. *
|
||||
;* Данные считывается в массив CDDataBuf. *
|
||||
;*************************************************
|
||||
ReadCD:
|
||||
pusha
|
||||
; Задать размер сектора
|
||||
mov [CDBlockSize],2048 ;2352
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать пакетную команду для считывания
|
||||
; сектора данных
|
||||
; Задать код команды Read CD
|
||||
mov [PacketCommand],byte 0x28 ;0xBE
|
||||
; Задать адрес сектора
|
||||
mov AX,word [CDSectorAddress+2]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+2],AX
|
||||
mov AX,word [CDSectorAddress]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+4],AX
|
||||
; mov eax,[CDSectorAddress]
|
||||
; mov [PacketCommand+2],eax
|
||||
; Задать количество считываемых секторов
|
||||
mov [PacketCommand+8],byte 1
|
||||
; Задать считывание данных в полном объеме
|
||||
; mov [PacketCommand+9],byte 0xF8
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
; call test_mario79
|
||||
popa
|
||||
ret
|
||||
|
||||
;********************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА С ПОВТОРАМИ *
|
||||
;* Многократное повторение чтения при сбоях *
|
||||
;********************************************
|
||||
ReadCDWRetr:
|
||||
pusha
|
||||
; Цикл, пока команда не выполнена успешно или не
|
||||
; исчерпано количество попыток
|
||||
mov ECX,MaxRetr
|
||||
@@NextRetr:
|
||||
; Подать команду
|
||||
call ReadCD
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_4
|
||||
; Задержка на 2,5 секунды
|
||||
mov EAX,[timer_ticks]
|
||||
add EAX,250 ;50
|
||||
@@Wait:
|
||||
call change_task
|
||||
cmp EAX,[timer_ticks]
|
||||
ja @@Wait
|
||||
loop @@NextRetr
|
||||
; call test_mario79
|
||||
; Сообщение об ошибке
|
||||
; mov SI,offset ErrS
|
||||
; call FatalError
|
||||
@@End_4:
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; Универсальные процедуры, обеспечивающие выполнение
|
||||
; пакетных команд в режиме PIO
|
||||
;
|
||||
; Автор текста программы Кулаков Владимир Геннадьевич.
|
||||
|
||||
; Максимально допустимое время ожидания реакции
|
||||
; устройства на пакетную команду (в тиках)
|
||||
MaxCDWaitTime equ 1000 ;200 ;10 секунд
|
||||
|
||||
; Область памяти для формирования пакетной команды
|
||||
PacketCommand: rb 12 ;DB 12 DUP (?)
|
||||
; Область памяти для приема данных от дисковода
|
||||
;CDDataBuf DB 4096 DUP (0)
|
||||
; Размер принимаемого блока данных в байтах
|
||||
CDBlockSize DW ?
|
||||
; Адрес считываемого сектора данных
|
||||
CDSectorAddress: DD ?
|
||||
; Время начала очередной операции с диском
|
||||
TickCounter_1 DD 0
|
||||
; Время начала ожидания готовности устройства
|
||||
WURStartTime DD 0
|
||||
; указатель буфера для считывания
|
||||
CDDataBuf_pointer dd 0
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ УСТРОЙСТВУ ATAPI ПАКЕТНУЮ КОМАНДУ, *
|
||||
;* ПРЕДУСМАТРИВАЮЩУЮ ПЕРЕДАЧУ ОДНОГО СЕКТОРА ДАННЫХ *
|
||||
;* РАЗМЕРОМ 2048 БАЙТ ОТ УСТРОЙСТВА К ХОСТУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале; *
|
||||
;* PacketCommand - 12-байтный командный пакет; *
|
||||
;* CDBlockSize - размер принимаемого блока данных. *
|
||||
;****************************************************
|
||||
SendPacketDatCommand:
|
||||
pushad
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать ATA-команду передачи пакетной команды
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
; Загрузить размер передаваемого блока
|
||||
mov AX,[CDBlockSize]
|
||||
mov [ATACylinder],AX
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
; call test_mario79
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End_8 ;закончить, сохранив код ошибки
|
||||
|
||||
; Ожидание готовности дисковода к приему
|
||||
; пакетной команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
@@WaitDevice0:
|
||||
call change_task
|
||||
; Проверить время выполнения команды
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice0
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitDevice0
|
||||
; Послать пакетную команду
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,[PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+10]
|
||||
out DX,AX
|
||||
sti
|
||||
; Ожидание готовности данных
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
@@WaitDevice1:
|
||||
call change_task
|
||||
; Проверить время выполнения команды
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6_temp
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitDevice1
|
||||
cli
|
||||
; Принять блок данных от контроллера
|
||||
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf
|
||||
; Загрузить адрес регистра данных контроллера
|
||||
mov DX,[ATABasePortAddr] ;порт 1x0h
|
||||
; Загрузить в счетчик размер блока в байтах
|
||||
mov CX,[CDBlockSize]
|
||||
; Вычислить размер блока в 16-разрядных словах
|
||||
shr CX,1 ;разделить размер блока на 2
|
||||
; Принять блок данных
|
||||
cld
|
||||
rep insw
|
||||
sti
|
||||
; Успешное завершение приема данных
|
||||
jmp @@End_8
|
||||
|
||||
; Записать код ошибки
|
||||
@@Err1_1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_8
|
||||
@@Err6_temp:
|
||||
mov [DevErrorCode],7
|
||||
jmp @@End_8
|
||||
@@Err6:
|
||||
mov [DevErrorCode],6
|
||||
|
||||
@@End_8:
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***********************************************
|
||||
;* ПОСЛАТЬ УСТРОЙСТВУ ATAPI ПАКЕТНУЮ КОМАНДУ, *
|
||||
;* НЕ ПРЕДУСМАТРИВАЮЩУЮ ПЕРЕДАЧИ ДАННЫХ *
|
||||
;* Входные параметры передаются через *
|
||||
;* глобальные перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале; *
|
||||
;* PacketCommand - 12-байтный командный пакет. *
|
||||
;***********************************************
|
||||
SendPacketNoDatCommand:
|
||||
pushad
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать ATA-команду передачи пакетной команды
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End_9 ;закончить, сохранив код ошибки
|
||||
; Ожидание готовности дисковода к приему
|
||||
; пакетной команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
@@WaitDevice0_1:
|
||||
call change_task
|
||||
; Проверить время ожидания
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_3 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice0_1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6_1
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitDevice0_1
|
||||
; Послать пакетную команду
|
||||
; cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,word [PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+10]
|
||||
out DX,AX
|
||||
; sti
|
||||
; Ожидание подтверждения приема команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
@@WaitDevice1_1:
|
||||
call change_task
|
||||
; Проверить время выполнения команды
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_3 ;ошибка тайм-аута
|
||||
; Ожидать освобождения устройства
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice1_1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6_1
|
||||
test AL,40h ;состояние сигнала DRDY
|
||||
jz @@WaitDevice1_1
|
||||
jmp @@End_9
|
||||
|
||||
; Записать код ошибки
|
||||
@@Err1_3:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_9
|
||||
@@Err6_1:
|
||||
mov [DevErrorCode],6
|
||||
@@End_9:
|
||||
popad
|
||||
ret
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска (0 или 1); *
|
||||
;* ATAFeatures - "особенности"; *
|
||||
;* ATASectorCount - количество секторов; *
|
||||
;* ATASectorNumber - номер начального сектора; *
|
||||
;* ATACylinder - номер начального цилиндра; *
|
||||
;* ATAHead - номер начальной головки; *
|
||||
;* ATAAddressMode - режим адресации (0-CHS, 1-LBA); *
|
||||
;* ATACommand - код команды. *
|
||||
;* После успешного выполнения функции: *
|
||||
;* в ATABasePortAddr - базовый адрес HDD; *
|
||||
;* в DevErrorCode - ноль. *
|
||||
;* При возникновении ошибки в DevErrorCode будет *
|
||||
;* возвращен код ошибки. *
|
||||
;****************************************************
|
||||
SendCommandToHDD_1:
|
||||
pushad
|
||||
; Проверить значение кода режима
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2_4
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_4
|
||||
cmp BX,2
|
||||
ja @@Err3_4
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Выбрать нужный диск
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;адрес регистра головок
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;проверить номера диска
|
||||
ja @@Err4_4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Ожидать, пока диск не будет готов
|
||||
inc DX
|
||||
; mov ecx,0xfff
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter_1],eax
|
||||
@@WaitHDReady_2:
|
||||
call change_task
|
||||
; Проверить время ожидания
|
||||
; dec ecx
|
||||
; cmp ecx,0
|
||||
; je @@Err1
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter_1]
|
||||
cmp eax,BSYWaitTime ;300 ;ожидать 3 сек.
|
||||
ja @@Err1_4 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояния
|
||||
in AL,DX
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_2
|
||||
; Проверить состояние сигнала DRQ
|
||||
test AL,08h
|
||||
jnz @@WaitHDReady_2
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
inc DX ;регистр "особенностей"
|
||||
mov AL,[ATAFeatures]
|
||||
out DX,AL
|
||||
inc DX ;счетчик секторов
|
||||
mov AL,[ATASectorCount]
|
||||
out DX,AL
|
||||
inc DX ;регистр номера сектора
|
||||
mov AL,[ATASectorNumber]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (младший байт)
|
||||
mov AX,[ATACylinder]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (старший байт)
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
inc DX ;номер головки/номер диска
|
||||
mov AL,[DiskNumber]
|
||||
shl AL,4
|
||||
cmp [ATAHead],0Fh ;проверить номер головки
|
||||
ja @@Err5_4
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
; Послать команду
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;регистр команд
|
||||
out DX,AL
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_10
|
||||
; Записать код ошибки
|
||||
@@Err1_4:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_10
|
||||
@@Err2_4:
|
||||
mov [DevErrorCode],2
|
||||
jmp @@End_10
|
||||
@@Err3_4:
|
||||
mov [DevErrorCode],3
|
||||
jmp @@End_10
|
||||
@@Err4_4:
|
||||
mov [DevErrorCode],4
|
||||
jmp @@End_10
|
||||
@@Err5_4:
|
||||
mov [DevErrorCode],5
|
||||
; Завершение работы программы
|
||||
@@End_10:
|
||||
sti
|
||||
popad
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ОЖИДАНИЕ ГОТОВНОСТИ УСТРОЙСТВА К РАБОТЕ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
WaitUnitReady:
|
||||
pusha
|
||||
; Запомнить время начала операции
|
||||
mov EAX,[timer_ticks]
|
||||
mov [WURStartTime],EAX
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду TEST UNIT READY
|
||||
mov [PacketCommand],word 00h
|
||||
; ЦИКЛ ОЖИДАНИЯ ГОТОВНОСТИ УСТРОЙСТВА
|
||||
@@SendCommand:
|
||||
; Подать команду проверки готовности
|
||||
call SendPacketNoDatCommand
|
||||
call change_task
|
||||
; Проверить код ошибки
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_11
|
||||
; Проверить время ожидания готовности
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[WURStartTime]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
jb @@SendCommand
|
||||
; Ошибка тайм-аута
|
||||
mov [DevErrorCode],1
|
||||
@@End_11:
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
;*************************************************
|
||||
;* ЗАГРУЗИТЬ НОСИТЕЛЬ В ДИСКОВОД *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
LoadMedium:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду START/STOP UNIT
|
||||
; Задать код команды
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Задать операцию загрузки носителя
|
||||
mov [PacketCommand+4],word 00000011b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ИЗВЛЕЧЬ НОСИТЕЛЬ ИЗ ДИСКОВОДА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
UnloadMedium:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду START/STOP UNIT
|
||||
; Задать код команды
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Задать операцию извлечения носителя
|
||||
mov [PacketCommand+4],word 00000010b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ОПРЕДЕЛИТЬ ОБЩЕЕ КОЛИЧЕСТВО СЕКТОРОВ НА ДИСКЕ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
ReadCapacity:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Задать размер буфера в байтах
|
||||
mov [CDBlockSize],8
|
||||
; Сформировать команду READ CAPACITY
|
||||
mov [PacketCommand],word 25h
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
clear_packet_buffer:
|
||||
; Очистить буфер пакетной команды
|
||||
mov [PacketCommand],dword 0
|
||||
mov [PacketCommand+4],dword 0
|
||||
mov [PacketCommand+8],dword 0
|
||||
ret
|
||||
|
||||
261
kernel/branches/gfx_kernel/blkdev/cdrom.inc
Normal file
261
kernel/branches/gfx_kernel/blkdev/cdrom.inc
Normal file
@@ -0,0 +1,261 @@
|
||||
sys_cd_audio:
|
||||
|
||||
cmp word [cdbase],word 0
|
||||
jnz @f
|
||||
mov eax,1
|
||||
ret
|
||||
@@:
|
||||
|
||||
; eax=1 cdplay at ebx 0x00FFSSMM
|
||||
; eax=2 get tracklist size of ecx to [ebx]
|
||||
; eax=3 stop/pause playing
|
||||
|
||||
cmp eax,1
|
||||
jnz nocdp
|
||||
call sys_cdplay
|
||||
ret
|
||||
nocdp:
|
||||
|
||||
cmp eax,2
|
||||
jnz nocdtl
|
||||
mov edi,[0x3010]
|
||||
add edi,TASKDATA.mem_start
|
||||
add ebx,[edi]
|
||||
call sys_cdtracklist
|
||||
ret
|
||||
nocdtl:
|
||||
|
||||
cmp eax,3
|
||||
jnz nocdpause
|
||||
call sys_cdpause
|
||||
ret
|
||||
nocdpause:
|
||||
|
||||
mov eax,0xffffff01
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sys_cd_atapi_command:
|
||||
|
||||
pushad
|
||||
|
||||
mov dx,word [cdbase]
|
||||
add dx,6
|
||||
mov ax,word [cdid]
|
||||
out dx,al
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
in al,dx
|
||||
and al,0x80
|
||||
cmp al,0
|
||||
jnz res
|
||||
jmp cdl6
|
||||
res:
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
mov al,0x8
|
||||
out dx,al
|
||||
mov dx,word [cdbase]
|
||||
add dx,0x206
|
||||
mov al,0xe
|
||||
out dx,al
|
||||
mov esi,1
|
||||
call delay_ms
|
||||
mov dx,word [cdbase]
|
||||
add dx,0x206
|
||||
mov al,0x8
|
||||
out dx,al
|
||||
mov esi,30
|
||||
call delay_ms
|
||||
xor cx,cx
|
||||
cdl5:
|
||||
inc cx
|
||||
cmp cx,10
|
||||
jz cdl6
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
in al,dx
|
||||
and al,0x88
|
||||
cmp al,0x00
|
||||
jz cdl5
|
||||
mov esi,100
|
||||
call delay_ms
|
||||
jmp cdl5
|
||||
cdl6:
|
||||
mov dx,word [cdbase]
|
||||
add dx,4
|
||||
mov al,0
|
||||
out dx,al
|
||||
mov dx,word [cdbase]
|
||||
add dx,5
|
||||
mov al,0
|
||||
out dx,al
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
mov al,0xec
|
||||
out dx,al
|
||||
mov esi,5
|
||||
call delay_ms
|
||||
mov dx,word [cdbase]
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,128
|
||||
out dx,al
|
||||
add dx,2
|
||||
mov al,0xa0
|
||||
out dx,al
|
||||
xor cx,cx
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
cdl1:
|
||||
inc cx
|
||||
cmp cx,100
|
||||
jz cdl2
|
||||
in al,dx
|
||||
and ax,0x88
|
||||
cmp al,0x8
|
||||
jz cdl2
|
||||
mov esi,2
|
||||
call delay_ms
|
||||
jmp cdl1
|
||||
cdl2:
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
sys_cdplay:
|
||||
|
||||
mov ax,5
|
||||
push ax
|
||||
push ebx
|
||||
cdplay:
|
||||
call sys_cd_atapi_command
|
||||
cli
|
||||
mov dx,word [cdbase]
|
||||
mov ax,0x0047
|
||||
out dx,ax
|
||||
mov al,1
|
||||
mov ah,[esp+0] ; min xx
|
||||
out dx,ax
|
||||
mov ax,[esp+1] ; fr sec
|
||||
out dx,ax
|
||||
mov ax,256+99
|
||||
out dx,ax
|
||||
mov ax,0x0001
|
||||
out dx,ax
|
||||
mov ax,0x0000
|
||||
out dx,ax
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
sti
|
||||
add dx,7
|
||||
in al,dx
|
||||
test al,1
|
||||
jz cdplayok
|
||||
mov ax,[esp+4]
|
||||
dec ax
|
||||
mov [esp+4],ax
|
||||
cmp ax,0
|
||||
jz cdplayfail
|
||||
jmp cdplay
|
||||
cdplayfail:
|
||||
cdplayok:
|
||||
pop ebx
|
||||
pop ax
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
||||
sys_cdtracklist:
|
||||
|
||||
push ebx
|
||||
tcdplay:
|
||||
call sys_cd_atapi_command
|
||||
mov dx,word [cdbase]
|
||||
mov ax,0x43+2*256
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
mov ax,200
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
in al,dx
|
||||
mov cx,1000
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
cld
|
||||
cdtrnwewait:
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
in al,dx
|
||||
and al,128
|
||||
cmp al,0
|
||||
jz cdtrl1
|
||||
loop cdtrnwewait
|
||||
cdtrl1:
|
||||
; read the result
|
||||
mov ecx,[esp+0]
|
||||
mov dx,word [cdbase]
|
||||
cdtrread:
|
||||
add dx,7
|
||||
in al,dx
|
||||
and al,8
|
||||
cmp al,8
|
||||
jnz cdtrdone
|
||||
sub dx,7
|
||||
in ax,dx
|
||||
mov [ecx],ax
|
||||
add ecx,2
|
||||
jmp cdtrread
|
||||
cdtrdone:
|
||||
pop ecx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
||||
sys_cdpause:
|
||||
|
||||
call sys_cd_atapi_command
|
||||
|
||||
mov dx,word [cdbase]
|
||||
mov ax,0x004B
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
add dx,7
|
||||
in al,dx
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
73
kernel/branches/gfx_kernel/blkdev/fdc.inc
Normal file
73
kernel/branches/gfx_kernel/blkdev/fdc.inc
Normal file
@@ -0,0 +1,73 @@
|
||||
iglobal
|
||||
;function pointers.
|
||||
fdc_irq_func dd fdc_null
|
||||
endg
|
||||
|
||||
uglobal
|
||||
dmasize db 0x0
|
||||
dmamode db 0x0
|
||||
endg
|
||||
|
||||
fdc_init: ;start with clean tracks.
|
||||
mov edi,0xD201
|
||||
mov al,0
|
||||
mov ecx,160
|
||||
rep stosb
|
||||
ret
|
||||
|
||||
fdc_filesave: ;ebx: cluster to be saved.
|
||||
pusha ;returns immediately. does not trigger a write.
|
||||
mov eax,ebx
|
||||
add eax,31
|
||||
mov bl,18
|
||||
div bl
|
||||
mov ah,0
|
||||
add eax,0xD201
|
||||
mov [eax],byte 1 ;This track is now dirty.
|
||||
popa
|
||||
ret
|
||||
|
||||
fdc_irq:
|
||||
call [fdc_irq_func]
|
||||
fdc_null:
|
||||
ret
|
||||
|
||||
save_image:
|
||||
call reserve_flp
|
||||
call restorefatchain
|
||||
pusha
|
||||
call check_label
|
||||
cmp [FDC_Status],0
|
||||
jne unnecessary_save_image
|
||||
mov [FDD_Track],0 ; Öèëèíäð
|
||||
mov [FDD_Head],0 ; Ñòîðîíà
|
||||
mov [FDD_Sector],1 ; Ñåêòîð
|
||||
mov esi,0x100000
|
||||
call SeekTrack
|
||||
save_image_1:
|
||||
push esi
|
||||
call take_data_from_application_1
|
||||
pop esi
|
||||
add esi,512
|
||||
call WriteSectWithRetr
|
||||
; call WriteSector
|
||||
cmp [FDC_Status],0
|
||||
jne unnecessary_save_image
|
||||
inc [FDD_Sector]
|
||||
cmp [FDD_Sector],19
|
||||
jne save_image_1
|
||||
mov [FDD_Sector],1
|
||||
inc [FDD_Head]
|
||||
cmp [FDD_Head],2
|
||||
jne save_image_1
|
||||
mov [FDD_Head],0
|
||||
inc [FDD_Track]
|
||||
call SeekTrack
|
||||
cmp [FDD_Track],80
|
||||
jne save_image_1
|
||||
unnecessary_save_image:
|
||||
mov [fdc_irq_func],fdc_null
|
||||
popa
|
||||
mov [flp_status],0
|
||||
ret
|
||||
|
||||
615
kernel/branches/gfx_kernel/blkdev/flp_drv.inc
Normal file
615
kernel/branches/gfx_kernel/blkdev/flp_drv.inc
Normal file
@@ -0,0 +1,615 @@
|
||||
;**********************************************************
|
||||
; Непосредственная работа с контроллером гибкого диска
|
||||
;**********************************************************
|
||||
; Автор исходного текста Кулаков Владимир Геннадьевич.
|
||||
; Адаптация и доработка Mario79
|
||||
|
||||
give_back_application_data: ; переслать приложению
|
||||
mov edi,[0x3010]
|
||||
mov edi,[edi+TASKDATA.mem_start]
|
||||
add edi,ecx
|
||||
give_back_application_data_1:
|
||||
mov esi,0xD000 ;FDD_DataBuffer ;0x40000
|
||||
xor ecx,ecx
|
||||
mov cx,128
|
||||
cld
|
||||
rep movsd
|
||||
ret
|
||||
|
||||
take_data_from_application: ; взять из приложения
|
||||
mov esi,[0x3010]
|
||||
mov esi,[esi+TASKDATA.mem_start]
|
||||
add esi,ecx
|
||||
take_data_from_application_1:
|
||||
mov edi,0xD000 ;FDD_DataBuffer ;0x40000
|
||||
xor ecx,ecx
|
||||
mov cx,128
|
||||
cld
|
||||
rep movsd
|
||||
ret
|
||||
|
||||
; Коды завершения операции с контроллером (FDC_Status)
|
||||
FDC_Normal equ 0 ;нормальное завершение
|
||||
FDC_TimeOut equ 1 ;ошибка тайм-аута
|
||||
FDC_DiskNotFound equ 2 ;в дисководе нет диска
|
||||
FDC_TrackNotFound equ 3 ;дорожка не найдена
|
||||
FDC_SectorNotFound equ 4 ;сектор не найден
|
||||
|
||||
; Максимальные значения координат сектора (заданные
|
||||
; значения соответствуют параметрам стандартного
|
||||
; трехдюймового гибкого диска объемом 1,44 Мб)
|
||||
MAX_Track equ 79
|
||||
MAX_Head equ 1
|
||||
MAX_Sector equ 18
|
||||
|
||||
uglobal
|
||||
; Счетчик тиков таймера
|
||||
TickCounter dd ?
|
||||
; Код завершения операции с контроллером НГМД
|
||||
FDC_Status DB ?
|
||||
; Флаг прерывания от НГМД
|
||||
FDD_IntFlag DB ?
|
||||
; Момент начала последней операции с НГМД
|
||||
FDD_Time DD ?
|
||||
; Номер дисковода
|
||||
FDD_Type db 0
|
||||
; Координаты сектора
|
||||
FDD_Track DB ?
|
||||
FDD_Head DB ?
|
||||
FDD_Sector DB ?
|
||||
|
||||
; Блок результата операции
|
||||
FDC_ST0 DB ?
|
||||
FDC_ST1 DB ?
|
||||
FDC_ST2 DB ?
|
||||
FDC_C DB ?
|
||||
FDC_H DB ?
|
||||
FDC_R DB ?
|
||||
FDC_N DB ?
|
||||
; Счетчик повторения операции чтения
|
||||
ReadRepCounter DB ?
|
||||
; Счетчик повторения операции рекалибровки
|
||||
RecalRepCounter DB ?
|
||||
endg
|
||||
; Область памяти для хранения прочитанного сектора
|
||||
;FDD_DataBuffer: times 512 db 0 ;DB 512 DUP (?)
|
||||
fdd_motor_status db 0
|
||||
timer_fdd_motor dd 0
|
||||
|
||||
;*************************************
|
||||
;* ИНИЦИАЛИЗАЦИЯ РЕЖИМА ПДП ДЛЯ НГМД *
|
||||
;*************************************
|
||||
Init_FDC_DMA:
|
||||
pushad
|
||||
mov al,0
|
||||
out 0x0c,al ; reset the flip-flop to a known state.
|
||||
mov al,6 ; mask channel 2 so we can reprogram it.
|
||||
out 0x0a,al
|
||||
mov al,[dmamode] ; 0x46 -> Read from floppy - 0x4A Write to floppy
|
||||
out 0x0b,al
|
||||
mov al,0
|
||||
out 0x0c,al ; reset the flip-flop to a known state.
|
||||
mov eax,0xD000
|
||||
out 0x04,al ; set the channel 2 starting address to 0
|
||||
shr eax,8
|
||||
out 0x04,al
|
||||
shr eax,8
|
||||
out 0x81,al
|
||||
mov al,0
|
||||
out 0x0c, al ; reset flip-flop
|
||||
mov al, 0xff ;set count (actual size -1)
|
||||
out 0x5, al
|
||||
mov al,0x1 ;[dmasize] ;(0x1ff = 511 / 0x23ff =9215)
|
||||
out 0x5,al
|
||||
mov al,2
|
||||
out 0xa,al
|
||||
popad
|
||||
ret
|
||||
|
||||
;***********************************
|
||||
;* ЗАПИСАТЬ БАЙТ В ПОРТ ДАННЫХ FDC *
|
||||
;* Параметры: *
|
||||
;* AL - выводимый байт. *
|
||||
;***********************************
|
||||
FDCDataOutput:
|
||||
; pusha
|
||||
push eax ecx edx
|
||||
mov AH,AL ;запомнить байт в AH
|
||||
; Сбросить переменную состояния контроллера
|
||||
mov [FDC_Status],FDC_Normal
|
||||
; Проверить готовность контроллера к приему данных
|
||||
mov DX,3F4h ;(порт состояния FDC)
|
||||
mov ecx, 0x10000 ;установить счетчик тайм-аута
|
||||
@@TestRS:
|
||||
in AL,DX ;прочитать регистр RS
|
||||
and AL,0C0h ;выделить разряды 6 и 7
|
||||
cmp AL,80h ;проверить разряды 6 и 7
|
||||
je @@OutByteToFDC
|
||||
loop @@TestRS
|
||||
; Ошибка тайм-аута
|
||||
mov [FDC_Status],FDC_TimeOut
|
||||
jmp @@End_5
|
||||
; Вывести байт в порт данных
|
||||
@@OutByteToFDC:
|
||||
inc DX
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
@@End_5:
|
||||
; popa
|
||||
pop edx ecx eax
|
||||
ret
|
||||
|
||||
;******************************************
|
||||
;* ПРОЧИТАТЬ БАЙТ ИЗ ПОРТА ДАННЫХ FDC *
|
||||
;* Процедура не имеет входных параметров. *
|
||||
;* Выходные данные: *
|
||||
;* AL - считанный байт. *
|
||||
;******************************************
|
||||
FDCDataInput:
|
||||
push ECX
|
||||
push DX
|
||||
; Сбросить переменную состояния контроллера
|
||||
mov [FDC_Status],FDC_Normal
|
||||
; Проверить готовность контроллера к передаче данных
|
||||
mov DX,3F4h ;(порт состояния FDC)
|
||||
xor CX,CX ;установить счетчик тайм-аута
|
||||
@@TestRS_1:
|
||||
in AL,DX ;прочитать регистр RS
|
||||
and AL,0C0h ;выдлить разряды 6 и 7
|
||||
cmp AL,0C0h ;проверить разряды 6 и 7
|
||||
je @@GetByteFromFDC
|
||||
loop @@TestRS_1
|
||||
; Ошибка тайм-аута
|
||||
mov [FDC_Status],FDC_TimeOut
|
||||
jmp @@End_6
|
||||
; Ввести байт из порта данных
|
||||
@@GetByteFromFDC:
|
||||
inc DX
|
||||
in AL,DX
|
||||
@@End_6: pop DX
|
||||
pop ECX
|
||||
ret
|
||||
|
||||
;*********************************************
|
||||
;* ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ КОНТРОЛЛЕРА НГМД *
|
||||
;*********************************************
|
||||
FDCInterrupt:
|
||||
; Установить флаг прерывания
|
||||
mov [FDD_IntFlag],1
|
||||
ret
|
||||
|
||||
|
||||
;******************************************
|
||||
;* УСТАНОВИТЬ НОВЫЙ ОБРАБОТЧИК ПРЕРЫВАНИЙ *
|
||||
;* НГМД *
|
||||
;******************************************
|
||||
SetUserInterrupts:
|
||||
mov [fdc_irq_func],FDCInterrupt
|
||||
ret
|
||||
|
||||
;*******************************************
|
||||
;* ОЖИДАНИЕ ПРЕРЫВАНИЯ ОТ КОНТРОЛЛЕРА НГМД *
|
||||
;*******************************************
|
||||
WaitFDCInterrupt:
|
||||
pusha
|
||||
; Сбросить байт состояния операции
|
||||
mov [FDC_Status],FDC_Normal
|
||||
; Сбросить флаг прерывания
|
||||
mov [FDD_IntFlag],0
|
||||
; Обнулить счетчик тиков
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter],eax
|
||||
; Ожидать установки флага прерывания НГМД
|
||||
@@TestRS_2:
|
||||
cmp [FDD_IntFlag],0
|
||||
jnz @@End_7 ;прерывание произошло
|
||||
call change_task
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter]
|
||||
cmp eax,50 ;25 ;5 ;ожидать 5 тиков
|
||||
jb @@TestRS_2
|
||||
; jl @@TestRS_2
|
||||
; Ошибка тайм-аута
|
||||
mov [FDC_Status],FDC_TimeOut
|
||||
; mov [flp_status],0
|
||||
@@End_7: popa
|
||||
ret
|
||||
|
||||
;*********************************
|
||||
;* ВКЛЮЧИТЬ МОТОР ДИСКОВОДА "A:" *
|
||||
;*********************************
|
||||
FDDMotorON:
|
||||
pusha
|
||||
; cmp [fdd_motor_status],1
|
||||
; je fdd_motor_on
|
||||
mov al,[flp_number]
|
||||
cmp [fdd_motor_status],al
|
||||
je fdd_motor_on
|
||||
; Произвести сброс контроллера НГМД
|
||||
mov DX,3F2h ;порт управления двигателями
|
||||
mov AL,0
|
||||
out DX,AL
|
||||
; Выбрать и включить мотор дисковода
|
||||
cmp [flp_number],1
|
||||
jne FDDMotorON_B
|
||||
; call FDDMotorOFF_B
|
||||
mov AL,1Ch ; Floppy A
|
||||
jmp FDDMotorON_1
|
||||
FDDMotorON_B:
|
||||
; call FDDMotorOFF_A
|
||||
mov AL,2Dh ; Floppy B
|
||||
FDDMotorON_1:
|
||||
out DX,AL
|
||||
; Обнулить счетчик тиков
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter],eax
|
||||
; Ожидать 0,5 с
|
||||
@@dT:
|
||||
call change_task
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter]
|
||||
cmp eax,50 ;10
|
||||
jb @@dT
|
||||
cmp [flp_number],1
|
||||
jne fdd_motor_on_B
|
||||
mov [fdd_motor_status],1
|
||||
jmp fdd_motor_on
|
||||
fdd_motor_on_B:
|
||||
mov [fdd_motor_status],2
|
||||
fdd_motor_on:
|
||||
call save_timer_fdd_motor
|
||||
popa
|
||||
ret
|
||||
|
||||
;*****************************************
|
||||
;* СОХРАНЕНИЕ УКАЗАТЕЛЯ ВРЕМЕНИ *
|
||||
;*****************************************
|
||||
save_timer_fdd_motor:
|
||||
mov eax,[timer_ticks]
|
||||
mov [timer_fdd_motor],eax
|
||||
ret
|
||||
|
||||
;*****************************************
|
||||
;* ПРОВЕРКА ЗАДЕРЖКИ ВЫКЛЮЧЕНИЯ МОТОРА *
|
||||
;*****************************************
|
||||
check_fdd_motor_status:
|
||||
cmp [fdd_motor_status],0
|
||||
je end_check_fdd_motor_status_1
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[timer_fdd_motor]
|
||||
cmp eax,500
|
||||
jb end_check_fdd_motor_status
|
||||
call FDDMotorOFF
|
||||
mov [fdd_motor_status],0
|
||||
end_check_fdd_motor_status_1:
|
||||
mov [flp_status],0
|
||||
end_check_fdd_motor_status:
|
||||
ret
|
||||
|
||||
;**********************************
|
||||
;* ВЫКЛЮЧИТЬ МОТОР ДИСКОВОДА *
|
||||
;**********************************
|
||||
FDDMotorOFF:
|
||||
push AX
|
||||
push DX
|
||||
cmp [flp_number],1
|
||||
jne FDDMotorOFF_1
|
||||
call FDDMotorOFF_A
|
||||
jmp FDDMotorOFF_2
|
||||
FDDMotorOFF_1:
|
||||
call FDDMotorOFF_B
|
||||
FDDMotorOFF_2:
|
||||
pop DX
|
||||
pop AX
|
||||
; сброс флагов кеширования в связи с устареванием информации
|
||||
mov [root_read],0
|
||||
mov [flp_fat],0
|
||||
ret
|
||||
|
||||
FDDMotorOFF_A:
|
||||
mov DX,3F2h ;порт управления двигателями
|
||||
mov AL,0Ch ; Floppy A
|
||||
out DX,AL
|
||||
ret
|
||||
|
||||
FDDMotorOFF_B:
|
||||
mov DX,3F2h ;порт управления двигателями
|
||||
mov AL,5h ; Floppy B
|
||||
out DX,AL
|
||||
ret
|
||||
|
||||
;*******************************
|
||||
;* РЕКАЛИБРОВКА ДИСКОВОДА "A:" *
|
||||
;*******************************
|
||||
RecalibrateFDD:
|
||||
pusha
|
||||
call save_timer_fdd_motor
|
||||
; Подать команду "Рекалибровка"
|
||||
mov AL,07h
|
||||
call FDCDataOutput
|
||||
mov AL,00h
|
||||
call FDCDataOutput
|
||||
; Ожидать завершения операции
|
||||
call WaitFDCInterrupt
|
||||
; cmp [FDC_Status],0
|
||||
; je no_fdc_status_error
|
||||
; mov [flp_status],0
|
||||
;no_fdc_status_error:
|
||||
call save_timer_fdd_motor
|
||||
popa
|
||||
ret
|
||||
|
||||
;*****************************************************
|
||||
;* ПОИСК ДОРОЖКИ *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;*****************************************************
|
||||
SeekTrack:
|
||||
pusha
|
||||
call save_timer_fdd_motor
|
||||
; Подать команду "Поиск"
|
||||
mov AL,0Fh
|
||||
call FDCDataOutput
|
||||
; Передать байт номера головки/накопителя
|
||||
mov AL,[FDD_Head]
|
||||
shl AL,2
|
||||
call FDCDataOutput
|
||||
; Передать байт номера дорожки
|
||||
mov AL,[FDD_Track]
|
||||
call FDCDataOutput
|
||||
; Ожидать завершения операции
|
||||
call WaitFDCInterrupt
|
||||
cmp [FDC_Status],FDC_Normal
|
||||
jne @@Exit
|
||||
; Сохранить результат поиска
|
||||
mov AL,08h
|
||||
call FDCDataOutput
|
||||
call FDCDataInput
|
||||
mov [FDC_ST0],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_C],AL
|
||||
; Проверить результат поиска
|
||||
; Поиск завершен?
|
||||
test [FDC_ST0],100000b
|
||||
je @@Err
|
||||
; Заданный трек найден?
|
||||
mov AL,[FDC_C]
|
||||
cmp AL,[FDD_Track]
|
||||
jne @@Err
|
||||
; Номер головки совпадает с заданным?
|
||||
mov AL,[FDC_ST0]
|
||||
and AL,100b
|
||||
shr AL,2
|
||||
cmp AL,[FDD_Head]
|
||||
jne @@Err
|
||||
; Операция завершена успешно
|
||||
mov [FDC_Status],FDC_Normal
|
||||
jmp @@Exit
|
||||
@@Err: ; Трек не найден
|
||||
mov [FDC_Status],FDC_TrackNotFound
|
||||
; mov [flp_status],0
|
||||
@@Exit:
|
||||
call save_timer_fdd_motor
|
||||
popa
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА ДАННЫХ *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции чтения *
|
||||
;* содержимое сектора будет занесено в FDD_DataBuffer. *
|
||||
;*******************************************************
|
||||
ReadSector:
|
||||
pushad
|
||||
call save_timer_fdd_motor
|
||||
; Установить скорость передачи 500 Кбайт/с
|
||||
mov AX,0
|
||||
mov DX,03F7h
|
||||
out DX,AL
|
||||
; Инициализировать канал прямого доступа к памяти
|
||||
mov [dmamode],0x46
|
||||
call Init_FDC_DMA
|
||||
; Подать команду "Чтение данных"
|
||||
mov AL,0E6h ;чтение в мультитрековом режиме
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
shl AL,2
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Track]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Sector]
|
||||
call FDCDataOutput
|
||||
mov AL,2 ;код размера сектора (512 байт)
|
||||
call FDCDataOutput
|
||||
mov AL,18 ;+1; 3Fh ;число секторов на дорожке
|
||||
call FDCDataOutput
|
||||
mov AL,1Bh ;значение GPL
|
||||
call FDCDataOutput
|
||||
mov AL,0FFh ;значение DTL
|
||||
call FDCDataOutput
|
||||
; Ожидаем прерывание по завершении операции
|
||||
call WaitFDCInterrupt
|
||||
cmp [FDC_Status],FDC_Normal
|
||||
jne @@Exit_1
|
||||
; Считываем статус завершения операции
|
||||
call GetStatusInfo
|
||||
test [FDC_ST0],11011000b
|
||||
jnz @@Err_1
|
||||
mov [FDC_Status],FDC_Normal
|
||||
jmp @@Exit_1
|
||||
@@Err_1: mov [FDC_Status],FDC_SectorNotFound
|
||||
; mov [flp_status],0
|
||||
@@Exit_1:
|
||||
call save_timer_fdd_motor
|
||||
popad
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА (С ПОВТОРЕНИЕМ ОПЕРАЦИИ ПРИ СБОЕ) *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции чтения *
|
||||
;* содержимое сектора будет занесено в FDD_DataBuffer. *
|
||||
;*******************************************************
|
||||
ReadSectWithRetr:
|
||||
pusha
|
||||
; Обнулить счетчик повторения операции рекалибровки
|
||||
mov [RecalRepCounter],0
|
||||
@@TryAgain:
|
||||
; Обнулить счетчик повторения операции чтения
|
||||
mov [ReadRepCounter],0
|
||||
@@ReadSector_1:
|
||||
call ReadSector
|
||||
cmp [FDC_Status],0
|
||||
je @@Exit_2
|
||||
cmp [FDC_Status],1
|
||||
je @@Err_3
|
||||
; Троекратное повторение чтения
|
||||
inc [ReadRepCounter]
|
||||
cmp [ReadRepCounter],3
|
||||
jb @@ReadSector_1
|
||||
; Троекратное повторение рекалибровки
|
||||
call RecalibrateFDD
|
||||
call SeekTrack
|
||||
inc [RecalRepCounter]
|
||||
cmp [RecalRepCounter],3
|
||||
jb @@TryAgain
|
||||
; mov [flp_status],0
|
||||
@@Exit_2:
|
||||
popa
|
||||
ret
|
||||
@@Err_3:
|
||||
mov [flp_status],0
|
||||
popa
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЗАПИСЬ СЕКТОРА ДАННЫХ *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции записи *
|
||||
;* содержимое FDD_DataBuffer будет занесено в сектор. *
|
||||
;*******************************************************
|
||||
WriteSector:
|
||||
pushad
|
||||
call save_timer_fdd_motor
|
||||
; Установить скорость передачи 500 Кбайт/с
|
||||
mov AX,0
|
||||
mov DX,03F7h
|
||||
out DX,AL
|
||||
; Инициализировать канал прямого доступа к памяти
|
||||
mov [dmamode],0x4A
|
||||
call Init_FDC_DMA
|
||||
; Подать команду "Запись данных"
|
||||
mov AL,0xC5 ;0x45 ;запись в мультитрековом режиме
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
shl AL,2
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Track]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Sector]
|
||||
call FDCDataOutput
|
||||
mov AL,2 ;код размера сектора (512 байт)
|
||||
call FDCDataOutput
|
||||
mov AL,18; 3Fh ;число секторов на дорожке
|
||||
call FDCDataOutput
|
||||
mov AL,1Bh ;значение GPL
|
||||
call FDCDataOutput
|
||||
mov AL,0FFh ;значение DTL
|
||||
call FDCDataOutput
|
||||
; Ожидаем прерывание по завершении операции
|
||||
call WaitFDCInterrupt
|
||||
cmp [FDC_Status],FDC_Normal
|
||||
jne @@Exit_3
|
||||
; Считываем статус завершения операции
|
||||
call GetStatusInfo
|
||||
test [FDC_ST0],11000000b ;11011000b
|
||||
jnz @@Err_2
|
||||
mov [FDC_Status],FDC_Normal
|
||||
jmp @@Exit_3
|
||||
@@Err_2: mov [FDC_Status],FDC_SectorNotFound
|
||||
@@Exit_3:
|
||||
call save_timer_fdd_motor
|
||||
popad
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЗАПИСЬ СЕКТОРА (С ПОВТОРЕНИЕМ ОПЕРАЦИИ ПРИ СБОЕ) *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции записи *
|
||||
;* содержимое FDD_DataBuffer будет занесено в сектор. *
|
||||
;*******************************************************
|
||||
WriteSectWithRetr:
|
||||
pusha
|
||||
; Обнулить счетчик повторения операции рекалибровки
|
||||
mov [RecalRepCounter],0
|
||||
@@TryAgain_1:
|
||||
; Обнулить счетчик повторения операции чтения
|
||||
mov [ReadRepCounter],0
|
||||
@@WriteSector_1:
|
||||
call WriteSector
|
||||
cmp [FDC_Status],0
|
||||
je @@Exit_4
|
||||
cmp [FDC_Status],1
|
||||
je @@Err_4
|
||||
; Троекратное повторение чтения
|
||||
inc [ReadRepCounter]
|
||||
cmp [ReadRepCounter],3
|
||||
jb @@WriteSector_1
|
||||
; Троекратное повторение рекалибровки
|
||||
call RecalibrateFDD
|
||||
call SeekTrack
|
||||
inc [RecalRepCounter]
|
||||
cmp [RecalRepCounter],3
|
||||
jb @@TryAgain_1
|
||||
@@Exit_4:
|
||||
popa
|
||||
ret
|
||||
@@Err_4:
|
||||
mov [flp_status],0
|
||||
popa
|
||||
ret
|
||||
|
||||
;*********************************************
|
||||
;* ПОЛУЧИТЬ ИНФОРМАЦИЮ О РЕЗУЛЬТАТЕ ОПЕРАЦИИ *
|
||||
;*********************************************
|
||||
GetStatusInfo:
|
||||
push AX
|
||||
call FDCDataInput
|
||||
mov [FDC_ST0],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_ST1],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_ST2],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_C],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_H],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_R],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_N],AL
|
||||
pop AX
|
||||
ret
|
||||
|
||||
2292
kernel/branches/gfx_kernel/blkdev/rd.inc
Normal file
2292
kernel/branches/gfx_kernel/blkdev/rd.inc
Normal file
File diff suppressed because it is too large
Load Diff
25
kernel/branches/gfx_kernel/blkdev/rdsave.inc
Normal file
25
kernel/branches/gfx_kernel/blkdev/rdsave.inc
Normal file
@@ -0,0 +1,25 @@
|
||||
sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
|
||||
cmp ebx,1
|
||||
jnz img_save_hd_1
|
||||
mov edx,bootpath ; path = '/KOLIBRI '
|
||||
jmp img_save_hd_3
|
||||
img_save_hd_1:
|
||||
cmp ebx,2
|
||||
jnz img_save_hd_2
|
||||
mov edx,bootpath2 ; path = 0 (root dir)
|
||||
jmp img_save_hd_3
|
||||
img_save_hd_2:
|
||||
cmp ebx,3
|
||||
jnz exit_for_anyone
|
||||
mov edx,[0x3010]
|
||||
mov edx,[edx+TASKDATA.mem_start]
|
||||
add edx,ecx
|
||||
img_save_hd_3:
|
||||
call reserve_hd1
|
||||
call restorefatchain ; restore FAT !!!
|
||||
mov eax,image_save
|
||||
mov ebx,1440*1024 ; size 1440 Kb
|
||||
mov ecx,0x100000 ; address of image
|
||||
call file_write
|
||||
mov [esp+36],eax
|
||||
ret
|
||||
1123
kernel/branches/gfx_kernel/boot/bootcode.inc
Normal file
1123
kernel/branches/gfx_kernel/boot/bootcode.inc
Normal file
File diff suppressed because it is too large
Load Diff
134
kernel/branches/gfx_kernel/boot/booteng.inc
Normal file
134
kernel/branches/gfx_kernel/boot/booteng.inc
Normal file
@@ -0,0 +1,134 @@
|
||||
;======================================================================
|
||||
;
|
||||
; BOOT DATA
|
||||
;
|
||||
;======================================================================
|
||||
|
||||
macro line_full_top {
|
||||
db 201
|
||||
times 78 db 205
|
||||
db 187
|
||||
}
|
||||
macro line_full_bottom {
|
||||
db 200
|
||||
times 78 db 205
|
||||
db 188
|
||||
}
|
||||
macro line_half {
|
||||
db 186,' '
|
||||
times 76 db 0xc4
|
||||
db ' ',186
|
||||
}
|
||||
macro line_space {
|
||||
db 186
|
||||
times 78 db 32
|
||||
db 186
|
||||
}
|
||||
|
||||
d80x25_top:
|
||||
line_full_top
|
||||
verstr2:
|
||||
; line_space
|
||||
; version string
|
||||
db 186,32
|
||||
repeat 78
|
||||
load a byte from version+%-1
|
||||
if a = 13
|
||||
break
|
||||
end if
|
||||
db a
|
||||
end repeat
|
||||
repeat 78 - ($-verstr2)
|
||||
db ' '
|
||||
end repeat
|
||||
db 32,186
|
||||
verstr:
|
||||
line_half
|
||||
space_msg: line_space
|
||||
d80x25_top_num = 3
|
||||
d80x25_bottom:
|
||||
db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY '
|
||||
db 'NO WARRANTY ',186
|
||||
db 186,' See file COPYING for details '
|
||||
db ' ',186
|
||||
line_full_bottom
|
||||
d80x25_bottom_num = 3
|
||||
|
||||
msg_apm db " APM x.x ", 0
|
||||
|
||||
novesa db "Display: EGA/CGA",13,10,0
|
||||
s_vesa db "VESA version: "
|
||||
.ver db "?.? ("
|
||||
.mem db "??? Mbytes)",13,10,0
|
||||
gr_mode db "Select mode: ",13,10,0
|
||||
s_bpp db 13,10,186," Bits per pixel: "
|
||||
.bpp dw "??"
|
||||
db 13,10,0
|
||||
vrrmprint db "Apply VRR? (picture frequency greater than 60Hz"
|
||||
db " only for transfers:",13,10
|
||||
db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0
|
||||
gr_acc db "Vesa 2.0+ : MTRR graphics acceleration [1-yes/2-no] ? ",0
|
||||
bdev db "Load ramdisk from [1-floppy; 2-C:\menuet.img (FAT32);"
|
||||
db " 3-use preloaded ram-image from kernel restart]: ",0
|
||||
not386 db "Fatal - CPU 386+ required.",0
|
||||
fatalsel db 13,10,"Error - Selected mode is not supported.",0
|
||||
badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0
|
||||
memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0
|
||||
okt db " ... OK"
|
||||
linef db 13,10,0
|
||||
diskload db "Loading diskette: 00 %",8,8,8,8,0
|
||||
pros db "00"
|
||||
backspace2 db 8,8,0
|
||||
boot_dev db 0 ; 0=floppy, 1=hd
|
||||
start_msg db "Press [abcd] to change settings, press [Enter] to continue booting",13,10,0
|
||||
time_msg db " or wait "
|
||||
time_str db " 5 seconds"
|
||||
db " before automatical continuation",13,10,0
|
||||
current_cfg_msg db "Current settings:",13,10,0
|
||||
curvideo_msg db " [a] Videomode: ",0
|
||||
modevesa20 db " with LFB",0
|
||||
modevesa12 db ", VESA 1.2 Bnk",0
|
||||
mode9 db "320x200, EGA/CGA 256 colors",0
|
||||
mode10 db "640x480, VGA 16 colors",0
|
||||
mtrr_msg db " [b] Use MTRR for graphics acceleration:",0
|
||||
on_msg db " on",13,10,0
|
||||
off_msg db " off",13,10,0
|
||||
vrrm_msg db " [c] Use VRR:",0
|
||||
preboot_device_msg db " [d] Floppy image: ",0
|
||||
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000
|
||||
pdm1 db "real floppy",13,10,0
|
||||
pdm2 db "C:\menuet.img (FAT32)",13,10,0
|
||||
pdm3 db "use already loaded image",13,10,0
|
||||
loading_msg db "Loading KolibriOS...",0
|
||||
save_quest db "Remember current settings? [y/n]: ",0
|
||||
loader_block_error db "Bootloader data invalid, I cannot continue. Stopped.",0
|
||||
|
||||
_oem db 'oem: ',0
|
||||
|
||||
db 5
|
||||
s_ven_intel db 'Intel'
|
||||
db 2
|
||||
s_ven_s3 db 'S3'
|
||||
;db 5
|
||||
;s_ven_bochs db 'Bochs'
|
||||
;db 8
|
||||
;s_ven_vmware db 'V M ware'
|
||||
|
||||
s_mode db " ????-????-?? (?) ",0
|
||||
s_mode1 db " 0640-0480-04 (a) 0320-0200-08 (b) ",13,10,0
|
||||
|
||||
;_tl db 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿',13,10,\
|
||||
; '³ resolution ³ 4 ³ 8 ³ 15 ³ 16 ³ 24 ³ 32 ³',13,10,\
|
||||
; 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄ´',13,10,0
|
||||
;_rs db '³ ????x???? ³ - ³ - ³ - ³ - ³ - ³ - ³',13,10,0
|
||||
;_bt db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÙ',13,10,0
|
||||
|
||||
_tl db 186,' ÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿',13,10,\
|
||||
186,' ³ 4 ³ 8 ³ 15 ³ 16 ³ 24 ³ 32 ³',13,10,\
|
||||
186,' ÚÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄ¿',13,10,0
|
||||
_rs db 186,' ³ ????x???? ³ ? ³ ? ³ ? ³ ? ³ ? ³ ? ³Û³',13,10,0
|
||||
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÙ',13,10,0
|
||||
|
||||
|
||||
_sel1 db 0x1A,0
|
||||
_sel2 db 0x1B,0
|
||||
148
kernel/branches/gfx_kernel/boot/bootru.inc
Normal file
148
kernel/branches/gfx_kernel/boot/bootru.inc
Normal file
@@ -0,0 +1,148 @@
|
||||
;======================================================================
|
||||
;
|
||||
; BOOT DATA
|
||||
;
|
||||
;======================================================================
|
||||
|
||||
macro line_full_top {
|
||||
db 201
|
||||
times 78 db 205
|
||||
db 187
|
||||
}
|
||||
macro line_full_bottom {
|
||||
db 200
|
||||
times 78 db 205
|
||||
db 188
|
||||
}
|
||||
macro line_half {
|
||||
db 186,' '
|
||||
times 76 db 0xc4
|
||||
db ' ',186
|
||||
}
|
||||
macro line_space {
|
||||
db 186
|
||||
times 78 db 32
|
||||
db 186
|
||||
}
|
||||
|
||||
d80x25_top:
|
||||
line_full_top
|
||||
verstr2:
|
||||
; line_space
|
||||
; version string
|
||||
db 186,32
|
||||
repeat 78
|
||||
load a byte from version+%-1
|
||||
if a = 13
|
||||
break
|
||||
end if
|
||||
db a
|
||||
end repeat
|
||||
repeat 78 - ($-verstr2)
|
||||
db ' '
|
||||
end repeat
|
||||
db 32,186
|
||||
verstr:
|
||||
line_half
|
||||
space_msg: line_space
|
||||
d80x25_top_num = 3
|
||||
d80x25_bottom:
|
||||
db 186,' Kolibri OS ®á®¢ Menuet OS ¨ ¥ ¯à¥¤®áâ ¢«ï¥â '
|
||||
db '¨ª ª¨å £ àa⨩. ',186
|
||||
db 186,' <20>®¤à®¡¥¥ ᬮâà¨â¥ ä ©« GNU.TXT '
|
||||
db ' ',186
|
||||
line_full_bottom
|
||||
d80x25_bottom_num = 3
|
||||
|
||||
msg_apm db " APM x.x ",0
|
||||
|
||||
novesa db "‚¨¤¥®ª àâ : EGA/CGA",13,10,0
|
||||
s_vesa db "‚¥àá¨ï VESA: "
|
||||
.ver db "?.? ("
|
||||
.mem db "??? Œ¡)",13,10,0
|
||||
gr_mode db "‚ë¡¥à¨â¥ ¢¨¤¥®à¥¦¨¬: ",13,10,0
|
||||
s_bpp db 13,10,186," ƒ«ã¡¨ 梥â : "
|
||||
.bpp dw "??"
|
||||
db 13,10,0
|
||||
vrrmprint db "ˆá¯®«ì§®¢ âì VRR? (ç áâ®â ª ¤à®¢ ¢ëè¥ 60 ƒæ"
|
||||
db " ⮫쪮 ¤«ï ¯¥à¥å®¤®¢:",13,10
|
||||
db 186," 1024*768>800*600 ¨ 800*600>640*480) [1-¤ , 2-¥â]: ",0
|
||||
gr_acc db "Vesa 2.0+: ‚ª«îç¨âì MTRR ¤«ï ãáª®à¥¨ï £à 䨪¨? "
|
||||
db "[1-¤ /2-¥â]: ",0
|
||||
bdev db "‡ £à㧨âì ®¡à § ¨§ [1-¤¨áª¥â ; 2-C:\menuet.img (FAT32);"
|
||||
db 13,10,186," "
|
||||
db "3-¨á¯®«ì§®¢ âì 㦥 § £àã¦¥ë© ®¡à §]: ",0
|
||||
probetext db 13,10,13,10,186," ‘â ¤ àâë© ¢¨¤¥®à¥¦¨¬? [1-¤ , "
|
||||
db "2-¯à®¢¥à¨âì ¤à㣨¥ (Vesa 3.0)]: ",0
|
||||
prnotfnd db "Žè¨¡ª - ‚¨¤¥®à¥¦¨¬ ¥ ©¤¥.",0
|
||||
;modena db "Žè¨¡ª - ’ॡã¥âáï ¯®¤¤¥à¦ª VBE 0x112+.",0
|
||||
not386 db "Žè¨¡ª - ’ॡã¥âáï ¯à®æ¥áá®à 386+.",0
|
||||
btns db "Žè¨¡ª - <20>¥ ¬®£ã ®¯à¥¤¥«¨âì £«ã¡¨ã 梥â .",0
|
||||
fatalsel db "Žè¨¡ª - ‚ë¡à ë© ¢¨¤¥®à¥¦¨¬ ¥ ¯®¤¤¥à¦¨¢ ¥âáï.",0
|
||||
badsect db 13,10,186," Žè¨¡ª - „¨áª¥â ¯®¢à¥¦¤¥ . <20>®¯à®¡ã©â¥ ¤àã£ãî.",0
|
||||
memmovefailed db 13,10,186," Žè¨¡ª - Int 0x15 move failed.",0
|
||||
okt db " ... OK"
|
||||
linef db 13,10,0
|
||||
diskload db "‡ £à㧪 ¤¨áª¥âë: 00 %",8,8,8,8,0
|
||||
pros db "00"
|
||||
backspace2 db 8,8,0
|
||||
boot_dev db 0
|
||||
start_msg db "<EFBFBD> ¦¬¨â¥ [abcd] ¤«ï ¨§¬¥¥¨ï áâ஥ª, [Enter] ¤«ï ¯à®¤®«¦¥¨ï § £à㧪¨",13,10,0
|
||||
time_msg db " ¨«¨ ¯®¤®¦¤¨â¥ "
|
||||
time_str db " 5 ᥪ㤠"
|
||||
db " ¤® ¢â®¬ â¨ç¥áª®£® ¯à®¤®«¦¥¨ï",13,10,0
|
||||
current_cfg_msg db "’¥ªã騥 áâனª¨:",13,10,0
|
||||
curvideo_msg db " [a] ‚¨¤¥®à¥¦¨¬: ",0
|
||||
mode1 db "640x480",0
|
||||
mode2 db "800x600",0
|
||||
mode3 db "1024x768",0
|
||||
mode4 db "1280x1024",0
|
||||
modes_msg dw mode4-0x10000,mode1-0x10000,mode2-0x10000,mode3-0x10000
|
||||
modevesa20 db " á LFB",0
|
||||
modevesa12 db ", VESA 1.2 Bnk",0
|
||||
mode9 db "320x200, EGA/CGA 256 梥⮢",0
|
||||
mode10 db "640x480, VGA 16 梥⮢",0
|
||||
probeno_msg db " (áâ ¤ àâë© ¢¨¤¥®à¥¦¨¬)",0
|
||||
probeok_msg db " (¯à®¢¥à¨âì ¥áâ ¤ àâë¥ à¥¦¨¬ë)",0
|
||||
mtrr_msg db " [b] ˆá¯®«ì§®¢ ¨¥ MTRR ¤«ï ãáª®à¥¨ï £à 䨪¨:",0
|
||||
on_msg db " ¢ª«",13,10,0
|
||||
off_msg db " ¢ëª«",13,10,0
|
||||
vrrm_msg db " [c] ˆá¯®«ì§®¢ ¨¥ VRR:",0
|
||||
preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0
|
||||
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000
|
||||
pdm1 db " áâ®ïé ï ¤¨áª¥â ",13,10,0
|
||||
pdm2 db "C:\menuet.img (FAT32)",13,10,0
|
||||
pdm3 db "¨á¯®«ì§®¢ âì 㦥 § £àã¦¥ë© ®¡à §",13,10,0
|
||||
loading_msg db "ˆ¤ñâ § £à㧪 KolibriOS...",0
|
||||
save_quest db "‡ ¯®¬¨âì ⥪ã騥 áâனª¨? [y/n]: ",0
|
||||
loader_block_error db "Žè¨¡ª ¢ ¤ ëå ç «ì®£® § £àã§ç¨ª , ¯à®¤®«¦¥¨¥ ¥¢®§¬®¦®.",0
|
||||
|
||||
_oem db 'oem: ',0
|
||||
|
||||
db 5
|
||||
s_ven_intel db 'Intel'
|
||||
db 2
|
||||
s_ven_s3 db 'S3'
|
||||
;db 5
|
||||
;s_ven_bochs db 'Bochs'
|
||||
;db 8
|
||||
;s_ven_vmware db 'V M ware'
|
||||
|
||||
s_mode db " ????-????-?? (?) ",0
|
||||
s_mode1 db " 0640-0480-04 (a) 0320-0200-08 (b) ",13,10,0
|
||||
|
||||
;_tl db 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿',13,10,\
|
||||
; '³ à §à¥è¥¨¥ ³ 4 ³ 8 ³ 15 ³ 16 ³ 24 ³ 32 ³',13,10,\
|
||||
; 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄ´',13,10,0
|
||||
;_rs db '³ ????x???? ³ - ³ - ³ - ³ - ³ - ³ - ³',13,10,0
|
||||
;_bt db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÙ',13,10,0
|
||||
|
||||
_tl db 186,' ÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿',13,10,\
|
||||
186,' ³ 4 ³ 8 ³ 15 ³ 16 ³ 24 ³ 32 ³',13,10,\
|
||||
186,' ÚÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄ¿',13,10,0
|
||||
_rs db 186,' ³ ????x???? ³ ? ³ ? ³ ? ³ ? ³ ? ³ ? ³Û³',13,10,0
|
||||
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÁÄÙ',13,10,0
|
||||
|
||||
|
||||
_sel1 db 0x1A,0
|
||||
_sel2 db 0x1B,0
|
||||
1080
kernel/branches/gfx_kernel/boot/bootvesa.inc
Normal file
1080
kernel/branches/gfx_kernel/boot/bootvesa.inc
Normal file
File diff suppressed because it is too large
Load Diff
44
kernel/branches/gfx_kernel/boot/drawtext.inc
Normal file
44
kernel/branches/gfx_kernel/boot/drawtext.inc
Normal file
@@ -0,0 +1,44 @@
|
||||
substr:
|
||||
push si di cx
|
||||
movzx cx,byte[ds:si-1]
|
||||
@@: mov al,[ds:si]
|
||||
cmp al,[es:di]
|
||||
jne @f
|
||||
inc si
|
||||
inc di
|
||||
dec cx
|
||||
jnz @b
|
||||
; cld
|
||||
; repe cmps byte[ds:si],[es:di]
|
||||
@@: pop cx di si
|
||||
ret
|
||||
|
||||
int2str:
|
||||
dec bl
|
||||
jz @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call int2str
|
||||
pop eax
|
||||
@@: cmp al,10
|
||||
sbb al,$69
|
||||
das
|
||||
mov [ds:di],al
|
||||
inc di
|
||||
ret
|
||||
|
||||
int2strnz:
|
||||
cmp eax,ecx
|
||||
jb @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call int2strnz
|
||||
pop eax
|
||||
@@: cmp al,10
|
||||
sbb al,$69
|
||||
das
|
||||
mov [ds:di],al
|
||||
inc di
|
||||
ret
|
||||
26
kernel/branches/gfx_kernel/boot/preboot.inc
Normal file
26
kernel/branches/gfx_kernel/boot/preboot.inc
Normal file
@@ -0,0 +1,26 @@
|
||||
display_modechg db 0 ; display mode change for text, yes/no (0 or 2)
|
||||
;
|
||||
; !! Important note !!
|
||||
;
|
||||
; Must be set to 2, to avoid two screenmode
|
||||
; changes within a very short period of time.
|
||||
|
||||
display_atboot db 0 ; show boot screen messages ( 2-no )
|
||||
|
||||
preboot_graph db 0 ; graph mode
|
||||
preboot_gprobe db 0 ; probe vesa3 videomodes (1-no, 2-yes)
|
||||
preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no)
|
||||
;;preboot_mouse db 0 ; mouse port (1-PS2, 2-COM1, 3-COM2)
|
||||
preboot_mtrr db 0 ; mtrr acceleration (1-yes, 2-no)
|
||||
preboot_device db 0 ; boot device
|
||||
; (1-floppy 2-harddisk 3-kernel restart)
|
||||
;;preboot_memory db 0 ; amount of memory
|
||||
; (1-16Mb;2-32Mb;3-64Mb;4-128Mb;5-256Mb)
|
||||
; !!!! 0 - autodetect !!!!
|
||||
preboot_blogesc db 1 ; start immediately after bootlog
|
||||
|
||||
if $>10200h
|
||||
ERROR: prebooting parameters must fit in first sector!!!
|
||||
end if
|
||||
hdsysimage db 'MENUET IMG' ; load from
|
||||
image_save db 'MENUET IMG' ; save to
|
||||
95
kernel/branches/gfx_kernel/boot/rdload.inc
Normal file
95
kernel/branches/gfx_kernel/boot/rdload.inc
Normal file
@@ -0,0 +1,95 @@
|
||||
; READ RAMDISK IMAGE FROM HD
|
||||
|
||||
cmp [boot_dev],1
|
||||
jne no_sys_on_hd
|
||||
|
||||
test [0x40001],byte 0x40
|
||||
jz position_2
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],1
|
||||
mov [fat32part],0
|
||||
position_1_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [0x40002]
|
||||
cmp [fat32part],eax
|
||||
jle position_1_1
|
||||
position_2:
|
||||
test [0x40001],byte 0x10
|
||||
jz position_3
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],2
|
||||
mov [fat32part],0
|
||||
position_2_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [0x40003]
|
||||
cmp eax,[fat32part]
|
||||
jle position_2_1
|
||||
position_3:
|
||||
test [0x40001],byte 0x4
|
||||
jz position_4
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],3
|
||||
mov [fat32part],0
|
||||
position_3_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [0x40004]
|
||||
cmp eax,[fat32part]
|
||||
jle position_3_1
|
||||
position_4:
|
||||
test [0x40001],byte 0x1
|
||||
jz no_sys_on_hd
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],4
|
||||
mov [fat32part],0
|
||||
position_4_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [0x40005]
|
||||
cmp eax,[fat32part]
|
||||
jle position_4_1
|
||||
jmp yes_sys_on_hd
|
||||
|
||||
search_and_read_image:
|
||||
; mov [0xfe10],dword 0 ; entries in hd cache
|
||||
call set_FAT32_variables
|
||||
mov edx, bootpath
|
||||
call read_image
|
||||
test eax, eax
|
||||
jz image_present
|
||||
mov edx, bootpath2
|
||||
call read_image
|
||||
test eax, eax
|
||||
jz image_present
|
||||
ret
|
||||
image_present:
|
||||
mov [image_retrieved],1
|
||||
ret
|
||||
|
||||
read_image:
|
||||
mov eax, hdsysimage
|
||||
mov ebx, 1474560/512
|
||||
mov ecx, 0x100000
|
||||
mov esi, 0
|
||||
mov edi, 12
|
||||
call file_read
|
||||
ret
|
||||
|
||||
image_retrieved db 0
|
||||
counter_of_partitions db 0
|
||||
no_sys_on_hd:
|
||||
yes_sys_on_hd:
|
||||
92
kernel/branches/gfx_kernel/boot/ru.inc
Normal file
92
kernel/branches/gfx_kernel/boot/ru.inc
Normal file
@@ -0,0 +1,92 @@
|
||||
; Generated by RUFNT.EXE
|
||||
; By BadBugsKiller (C)
|
||||
; Modifyed by BadBugsKiller 12.01.2004 17:45
|
||||
; Øðèôò óìåíüøåí â ðàçìåðå è òåïåðü ñîñòîèò èç 2-óõ ÷àñòåé,
|
||||
; ñîäåðæàùèõ òîëüêî ñèìâîëû ðóññêîãî àëôàâèòà.
|
||||
; ñèìâîëû â êîäèðîâêå ASCII (ÄÎÑ'îâñêàÿ), êîäîâàÿ ñòàíèöà 866.
|
||||
RU_FNT1:
|
||||
db 0x00, 0x00, 0x1E, 0x36, 0x66, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0x62, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0x66, 0x62, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, 0x81, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xDB, 0xDB, 0x5A, 0x5A, 0x7E, 0x7E, 0x5A, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xE6, 0x66, 0x6C, 0x6C, 0x78, 0x78, 0x6C, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x1F, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xCF, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
db 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC0, 0xC0, 0xC0, 0xC0, 0xC2, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFF, 0xDB, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0x6C, 0x7C, 0x38, 0x38, 0x7C, 0x6C, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFF, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFF, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xF8, 0xF0, 0xB0, 0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x7E, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xF3, 0xDB, 0xDB, 0xDB, 0xDB, 0xF3, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x26, 0x3E, 0x26, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xCE, 0xDB, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xDB, 0xDB, 0xCE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x3F, 0x66, 0x66, 0x66, 0x3E, 0x3E, 0x66, 0x66, 0x66, 0xE7, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x02, 0x06, 0x7C, 0xC0, 0xC0, 0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x62, 0x62, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, 0xC3, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0x54, 0x7C, 0x54, 0xD6, 0xD6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x38, 0xC6, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xD6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
RU_FNT2:
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x3C, 0x18, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x18, 0x3C, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x38, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFF, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB0, 0xB0, 0x3E, 0x33, 0x33, 0x7E, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xF6, 0xDE, 0xDE, 0xF6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x3E, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xCE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xC6, 0xC6, 0x7E, 0x36, 0x66, 0xE7, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
db 0x6C, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, 0xFC, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC8, 0xF8, 0xC8, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xF8, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00
|
||||
db 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xCF, 0xCD, 0xEF, 0xEC, 0xFF, 0xDC, 0xDC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
521
kernel/branches/gfx_kernel/boot/shutdown.inc
Normal file
521
kernel/branches/gfx_kernel/boot/shutdown.inc
Normal file
@@ -0,0 +1,521 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Shutdown for Menuet
|
||||
;;
|
||||
;; Distributed under General Public License
|
||||
;; See file COPYING for details.
|
||||
;; Copyright 2003 Ville Turjanmaa
|
||||
;;
|
||||
|
||||
|
||||
system_shutdown: ; shut down the system
|
||||
|
||||
push 3 ; stop playing cd
|
||||
pop eax
|
||||
call sys_cd_audio
|
||||
cld
|
||||
|
||||
mov al,[0x2f0000+0x9030]
|
||||
cmp al,1
|
||||
jl no_shutdown_parameter
|
||||
cmp al,4
|
||||
jle yes_shutdown_param
|
||||
no_shutdown_parameter:
|
||||
|
||||
; movzx ecx,word [0x2f0000+0x900A]
|
||||
; movzx esi,word [0x2f0000+0x900C]
|
||||
; imul ecx,esi ;[0xfe04]
|
||||
;; mov ecx,0x500000/4 ;3fff00/4 ; darken screen
|
||||
; push ecx
|
||||
; mov esi,[0xfe80]
|
||||
; cmp esi,32*0x100000
|
||||
; jbe no_darken_screen
|
||||
; mov edi,16*0x100000
|
||||
; push esi edi
|
||||
; sdnewpix:
|
||||
; lodsd
|
||||
; shr eax,1
|
||||
; and eax,0x7f7f7f7f
|
||||
; stosd
|
||||
; loop sdnewpix
|
||||
; pop ecx
|
||||
; pop esi edi
|
||||
; rep movsd
|
||||
; no_darken_screen:
|
||||
|
||||
; read shutdown code:
|
||||
; 1) display shutdown "window"
|
||||
|
||||
mov eax,[0xfe00]
|
||||
shr eax,1
|
||||
lea esi,[eax+220] ; x end
|
||||
sub eax,220 ; x start
|
||||
|
||||
mov ebx,[0xfe04]
|
||||
shr ebx,1
|
||||
mov [shutdownpos],ebx
|
||||
lea ebp,[ebx+105] ; y end
|
||||
sub ebx,120 ; y start
|
||||
|
||||
xor edi,edi
|
||||
inc edi ; force putpixel & dtext
|
||||
mov ecx,0x0000ff
|
||||
|
||||
; vertical loop begin
|
||||
sdnewpix1:
|
||||
push eax ; save x start
|
||||
|
||||
; horizontal loop begin
|
||||
sdnewpix2:
|
||||
|
||||
call [putpixel]
|
||||
|
||||
inc eax
|
||||
cmp eax,esi
|
||||
jnz sdnewpix2
|
||||
; horizontal loop end
|
||||
|
||||
dec ecx ; color
|
||||
pop eax ; restore x start
|
||||
|
||||
inc ebx ; advance y pos
|
||||
cmp ebx,ebp
|
||||
jnz sdnewpix1
|
||||
; vertical loop end
|
||||
|
||||
; 2) display text strings
|
||||
; a) version
|
||||
mov eax,[0xfe00]
|
||||
shr eax,1
|
||||
shl eax,16
|
||||
mov ax,word [shutdownpos]
|
||||
push eax
|
||||
sub eax,(220-27)*10000h + 105
|
||||
mov ebx,0xffff00
|
||||
mov ecx,version
|
||||
push 34
|
||||
pop edx
|
||||
call dtext
|
||||
|
||||
; b) variants
|
||||
add eax,105+33
|
||||
push 6
|
||||
pop esi
|
||||
; mov ebx,0xffffff
|
||||
mov bl,0xFF
|
||||
mov ecx,shutdowntext
|
||||
mov dl,40
|
||||
newsdt:
|
||||
call dtext
|
||||
add eax,10
|
||||
add ecx,edx
|
||||
dec esi
|
||||
jnz newsdt
|
||||
|
||||
; 3) load & display rose.txt
|
||||
mov eax,rosef ; load rose.txt
|
||||
xor ebx,ebx
|
||||
push 2
|
||||
pop ecx
|
||||
mov edx,0x90000
|
||||
push edx
|
||||
push 12
|
||||
pop esi
|
||||
push edi ; may be destroyed
|
||||
call fileread
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
inc ecx ; do not display stars from rose.txt
|
||||
pop eax
|
||||
add eax,20*10000h - 110
|
||||
|
||||
mov ebx,0x00ff00
|
||||
push 27
|
||||
pop edx
|
||||
|
||||
nrl:
|
||||
call dtext
|
||||
sub ebx,0x050000
|
||||
add eax,8
|
||||
add ecx,31
|
||||
cmp cx,word 0x0001+25*31
|
||||
jnz nrl
|
||||
|
||||
call checkVga_N13
|
||||
|
||||
yes_shutdown_param:
|
||||
cli
|
||||
|
||||
mov eax,kernel ; load kernel.mnt to 0x8000:0
|
||||
push 12
|
||||
pop esi
|
||||
xor ebx,ebx
|
||||
or ecx,-1
|
||||
mov edx,0x80000
|
||||
call fileread
|
||||
|
||||
mov esi,restart_kernel_4000+0x10000 ; move kernel re-starter to 0x4000:0
|
||||
mov edi,0x40000
|
||||
mov ecx,1000
|
||||
rep movsb
|
||||
|
||||
mov eax,0x2F0000 ; restore 0x0 - 0xffff
|
||||
xor ebx,ebx
|
||||
mov ecx,0x10000
|
||||
call memmove
|
||||
|
||||
call restorefatchain
|
||||
|
||||
mov word [0x467+0],pr_mode_exit-0x10000
|
||||
mov word [0x467+2],0x1000
|
||||
|
||||
mov al,0x0F
|
||||
out 0x70,al
|
||||
mov al,0x05
|
||||
out 0x71,al
|
||||
|
||||
mov al,0xFE
|
||||
out 0x64,al
|
||||
hlt
|
||||
|
||||
use16
|
||||
|
||||
pr_mode_exit:
|
||||
org $-0x10000
|
||||
|
||||
; setup stack
|
||||
mov ax, 3000h
|
||||
mov ss, ax
|
||||
mov esp, 0EC00h
|
||||
; setup ds
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
lidt [old_ints_h-0x10000]
|
||||
;remap IRQs
|
||||
mov al,0x11
|
||||
out 0x20,al
|
||||
call rdelay
|
||||
out 0xA0,al
|
||||
call rdelay
|
||||
|
||||
mov al,0x08
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
mov al,0x70
|
||||
out 0xA1,al
|
||||
call rdelay
|
||||
|
||||
mov al,0x04
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
mov al,0x02
|
||||
out 0xA1,al
|
||||
call rdelay
|
||||
|
||||
mov al,0x01
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
out 0xA1,al
|
||||
call rdelay
|
||||
|
||||
mov al,0
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
out 0xA1,al
|
||||
sti
|
||||
|
||||
temp_3456:
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov al,byte [es:0x9030]
|
||||
cmp al,1
|
||||
jl nbw
|
||||
cmp al,4
|
||||
jle nbw32
|
||||
|
||||
nbw:
|
||||
in al,0x60
|
||||
call pause_key
|
||||
cmp al,6
|
||||
jae nbw
|
||||
mov bl,al
|
||||
nbw2:
|
||||
in al,0x60
|
||||
call pause_key
|
||||
cmp al,bl
|
||||
je nbw2
|
||||
cmp al,240 ;ax,240
|
||||
jne nbw31
|
||||
mov al,bl
|
||||
dec ax
|
||||
jmp nbw32
|
||||
nbw31:
|
||||
add bl,128
|
||||
cmp al,bl
|
||||
jne nbw
|
||||
sub al,129
|
||||
|
||||
nbw32:
|
||||
|
||||
dec ax ; 1 = write floppy
|
||||
js nbw
|
||||
jnz no_floppy_write
|
||||
call floppy_write
|
||||
jmp temp_3456 ;nbw
|
||||
no_floppy_write:
|
||||
|
||||
dec ax ; 2 = power off
|
||||
jnz no_apm_off
|
||||
call APM_PowerOff
|
||||
jmp $
|
||||
no_apm_off:
|
||||
|
||||
dec ax ; 3 = reboot
|
||||
jnz restart_kernel ; 4 = restart kernel
|
||||
push 0x40
|
||||
pop ds
|
||||
mov word[0x0072],0x1234
|
||||
jmp 0xF000:0xFFF0
|
||||
|
||||
pause_key:
|
||||
mov cx,100
|
||||
pause_key_1:
|
||||
loop pause_key_1
|
||||
ret
|
||||
org $+0x10000
|
||||
old_ints_h:
|
||||
dw 0x400
|
||||
dd 0
|
||||
dw 0
|
||||
org $-0x10000
|
||||
|
||||
rdelay:
|
||||
ret
|
||||
|
||||
iglobal
|
||||
kernel db 'KERNEL MNT'
|
||||
; shutdown_parameter db 0
|
||||
endg
|
||||
|
||||
restart_kernel:
|
||||
|
||||
mov ax,0x0003 ; set text mode for screen
|
||||
int 0x10
|
||||
|
||||
jmp 0x4000:0000
|
||||
|
||||
|
||||
restart_kernel_4000:
|
||||
cli
|
||||
|
||||
; mov di,0x1000 ; load kernel image from 0x8000:0 -> 0x1000:0
|
||||
;
|
||||
; new_kernel_block_move:
|
||||
;
|
||||
; mov ebx,0
|
||||
;
|
||||
; new_kernel_byte_move:
|
||||
;
|
||||
; mov ax,di
|
||||
; add ax,0x7000
|
||||
; mov es,ax
|
||||
; mov dl,[es:bx]
|
||||
; mov es,di
|
||||
; mov [es:bx],dl
|
||||
;
|
||||
; inc ebx
|
||||
; cmp ebx,65536
|
||||
; jbe new_kernel_byte_move
|
||||
;
|
||||
; add di,0x1000
|
||||
; cmp di,0x2000
|
||||
; jbe new_kernel_block_move
|
||||
push ds
|
||||
pop es
|
||||
mov cx, 0x8000
|
||||
push cx
|
||||
mov ds, cx
|
||||
xor si, si
|
||||
xor di, di
|
||||
rep movsw
|
||||
push 0x9000
|
||||
pop ds
|
||||
push 0x2000
|
||||
pop es
|
||||
pop cx
|
||||
rep movsw
|
||||
|
||||
wbinvd ; write and invalidate cache
|
||||
|
||||
; mov ax,0x1000
|
||||
; mov es,ax
|
||||
; mov ax,0x3000
|
||||
; mov ss,ax
|
||||
; mov sp,0xec00
|
||||
; restore timer
|
||||
mov al, 00110100b
|
||||
out 43h, al
|
||||
jcxz $+2
|
||||
mov al, 0xFF
|
||||
out 40h, al
|
||||
jcxz $+2
|
||||
out 40h, al
|
||||
jcxz $+2
|
||||
sti
|
||||
|
||||
; bootloader interface
|
||||
push 0x1000
|
||||
pop ds
|
||||
mov si, .bootloader_block;-0x10000
|
||||
mov ax, 'KL'
|
||||
jmp 0x1000:0000
|
||||
|
||||
.bootloader_block:
|
||||
db 1 ; version
|
||||
dw 1 ; floppy image is in memory
|
||||
dd 0 ; cannot save parameters
|
||||
|
||||
APM_PowerOff:
|
||||
mov ax, 5304h
|
||||
xor bx, bx
|
||||
int 15h
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
mov ax,0x5300
|
||||
xor bx,bx
|
||||
int 0x15
|
||||
push ax
|
||||
|
||||
mov ax,0x5301
|
||||
xor bx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x5308
|
||||
mov bx,1
|
||||
mov cx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x530E
|
||||
xor bx,bx
|
||||
pop cx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x530D
|
||||
mov bx,1
|
||||
mov cx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x530F
|
||||
mov bx,1
|
||||
mov cx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x5307
|
||||
mov bx,1
|
||||
mov cx,3
|
||||
int 0x15
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
fwwritedone:
|
||||
ret
|
||||
org $+0x10000
|
||||
flm db 0
|
||||
org $-0x10000
|
||||
|
||||
floppy_write: ; write diskette image to physical floppy
|
||||
|
||||
cmp [flm-0x10000],byte 1
|
||||
je fwwritedone
|
||||
mov [flm-0x10000],byte 1
|
||||
|
||||
xor ax, ax ; reset drive
|
||||
xor dx, dx
|
||||
int 0x13
|
||||
|
||||
mov cx,0x0001 ; startcyl,startsector
|
||||
; mov dx,0x0000 ; starthead,drive
|
||||
xor dx, dx
|
||||
mov ax, 80*2 ; read no of sect
|
||||
|
||||
fwwrites:
|
||||
push ax
|
||||
|
||||
; move 1mb+ -> 0:a000
|
||||
|
||||
pusha
|
||||
mov si,fwmovedesc -0x10000
|
||||
mov cx,256*18
|
||||
mov ah,0x87
|
||||
push ds
|
||||
pop es
|
||||
int 0x15
|
||||
add dword [fwmovedesc-0x10000+0x12], 512*18
|
||||
popa
|
||||
|
||||
xor si,si
|
||||
mov es,si
|
||||
fwnewwrite:
|
||||
mov bx,0xa000 ; es:bx -> data area
|
||||
mov ax,0x0300+18 ; read, no of sectors to read
|
||||
int 0x13
|
||||
|
||||
test ah, ah
|
||||
jz fwgoodwrite
|
||||
|
||||
inc si
|
||||
cmp si,10
|
||||
jnz fwnewwrite
|
||||
|
||||
; can't access diskette - return
|
||||
pop ax
|
||||
ret
|
||||
|
||||
fwgoodwrite:
|
||||
inc dh
|
||||
cmp dh,2
|
||||
jnz fwbb2
|
||||
mov dh,0
|
||||
inc ch
|
||||
fwbb2:
|
||||
pop ax
|
||||
dec ax
|
||||
jnz fwwrites
|
||||
ret
|
||||
org $+0x10000
|
||||
fwmovedesc:
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
|
||||
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
org $-0x10000
|
||||
use32
|
||||
org $+0x10000
|
||||
uglobal
|
||||
shutdownpos dd 0x0
|
||||
endg
|
||||
|
||||
iglobal
|
||||
if lang eq en
|
||||
shutdowntext:
|
||||
db "IT'S SAFE TO POWER OFF COMPUTER OR "
|
||||
db ' '
|
||||
db '1) SAVE RAMDISK TO FLOPPY '
|
||||
db '2) APM - POWEROFF '
|
||||
db '3) REBOOT '
|
||||
db '4) RESTART KERNEL '
|
||||
else
|
||||
shutdowntext:
|
||||
db "<EFBFBD>¥§®¯ ᮥ ¢ëª«î票¥ ª®¬¯ìîâ¥à ¨«¨ "
|
||||
db ' '
|
||||
db '1) ‘®åà ¨âì à ¬¤¨áª ¤¨áª¥âã '
|
||||
db '2) APM - ¢ëª«î票¥ ¯¨â ¨ï '
|
||||
db '3) <20>¥à¥§ £à㧪 á¨á⥬ë '
|
||||
db '4) <20>¥áâ àâ ï¤à ¨§ އ“ '
|
||||
end if
|
||||
rosef:
|
||||
db 'ROSE TXT'
|
||||
endg
|
||||
5
kernel/branches/gfx_kernel/build_en.bat
Normal file
5
kernel/branches/gfx_kernel/build_en.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm kernel.asm kernel.mnt
|
||||
@erase lang.inc
|
||||
@pause
|
||||
5
kernel/branches/gfx_kernel/build_ru.bat
Normal file
5
kernel/branches/gfx_kernel/build_ru.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm kernel.asm kernel.mnt
|
||||
@erase lang.inc
|
||||
@pause
|
||||
46
kernel/branches/gfx_kernel/bus/pci/pci16.inc
Normal file
46
kernel/branches/gfx_kernel/bus/pci/pci16.inc
Normal file
@@ -0,0 +1,46 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; PCI16.INC ;;
|
||||
;; ;;
|
||||
;; 16 bit PCI driver code ;;
|
||||
;; ;;
|
||||
;; Version 0.2 December 21st, 2002 ;;
|
||||
;; ;;
|
||||
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
init_pci_16:
|
||||
|
||||
pushad
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov byte [es:0x9020],1 ;default mechanism:1
|
||||
mov ax,0xb101
|
||||
int 0x1a
|
||||
or ah,ah
|
||||
jnz pci16skip
|
||||
|
||||
mov [es:0x9021],cl ;last PCI bus in system
|
||||
mov [es:0x9022],bx
|
||||
mov [es:0x9024],edi
|
||||
|
||||
; we have a PCI BIOS, so check which configuration mechanism(s)
|
||||
; it supports
|
||||
; AL = PCI hardware characteristics (bit0 => mechanism1, bit1 => mechanism2)
|
||||
test al,1
|
||||
jnz pci16skip
|
||||
test al,2
|
||||
jz pci16skip
|
||||
mov byte [es:0x9020],2 ; if (al&3)==2 => mechanism 2
|
||||
|
||||
pci16skip:
|
||||
|
||||
mov ax,0x1000
|
||||
mov es,ax
|
||||
|
||||
popad
|
||||
358
kernel/branches/gfx_kernel/bus/pci/pci32.inc
Normal file
358
kernel/branches/gfx_kernel/bus/pci/pci32.inc
Normal file
@@ -0,0 +1,358 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; PCI32.INC ;;
|
||||
;; ;;
|
||||
;; 32 bit PCI driver code ;;
|
||||
;; ;;
|
||||
;; Version 0.2 December 21st, 2002 ;;
|
||||
;; ;;
|
||||
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
|
||||
;; Credits: ;;
|
||||
;; Ralf Brown ;;
|
||||
;; Mike Hibbett, mikeh@oceanfree.net ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_api:
|
||||
;
|
||||
; Description
|
||||
; entry point for system PCI calls
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_api:
|
||||
|
||||
cmp [pci_access_enabled],1
|
||||
jne no_pci_access_for_applications
|
||||
|
||||
or al,al
|
||||
jnz pci_fn_1
|
||||
; PCI function 0: get pci version (AH.AL)
|
||||
movzx eax,word [0x2F0000+0x9022]
|
||||
ret
|
||||
|
||||
pci_fn_1:
|
||||
cmp al,1
|
||||
jnz pci_fn_2
|
||||
|
||||
; PCI function 1: get last bus in AL
|
||||
mov al,[0x2F0000+0x9021]
|
||||
ret
|
||||
|
||||
pci_fn_2:
|
||||
cmp al,2
|
||||
jne pci_fn_3
|
||||
; PCI function 2: get pci access mechanism
|
||||
mov al,[0x2F0000+0x9020]
|
||||
ret
|
||||
pci_fn_3:
|
||||
|
||||
cmp al,4
|
||||
jz pci_read_reg ;byte
|
||||
cmp al,5
|
||||
jz pci_read_reg ;word
|
||||
cmp al,6
|
||||
jz pci_read_reg ;dword
|
||||
|
||||
cmp al,8
|
||||
jz pci_write_reg ;byte
|
||||
cmp al,9
|
||||
jz pci_write_reg ;word
|
||||
cmp al,10
|
||||
jz pci_write_reg ;dword
|
||||
|
||||
no_pci_access_for_applications:
|
||||
|
||||
mov eax,-1
|
||||
|
||||
ret
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_make_config_cmd
|
||||
;
|
||||
; Description
|
||||
; creates a command dword for use with the PCI bus
|
||||
; bus # in ah
|
||||
; device+func in bh (dddddfff)
|
||||
; register in bl
|
||||
;
|
||||
; command dword returned in eax ( 10000000 bbbbbbbb dddddfff rrrrrr00 )
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_make_config_cmd:
|
||||
shl eax,8 ; move bus to bits 16-23
|
||||
mov ax,bx ; combine all
|
||||
and eax,0xffffff
|
||||
or eax,0x80000000
|
||||
ret
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_read_reg:
|
||||
;
|
||||
; Description
|
||||
; read a register from the PCI config space into EAX/AX/AL
|
||||
; IN: ah=bus,device+func=bh,register address=bl
|
||||
; number of bytes to read (1,2,4) coded into AL, bits 0-1
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_read_reg:
|
||||
cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use?
|
||||
je pci_read_reg_2
|
||||
|
||||
; mechanism 1
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
call pci_make_config_cmd
|
||||
mov ebx,eax
|
||||
; get current state
|
||||
mov dx,0xcf8
|
||||
in eax, dx
|
||||
push eax
|
||||
; set up addressing to config data
|
||||
mov eax,ebx
|
||||
and al,0xfc ; make address dword-aligned
|
||||
out dx,eax
|
||||
; get requested DWORD of config data
|
||||
mov dl,0xfc
|
||||
and bl,3
|
||||
or dl,bl ; add to port address first 2 bits of register address
|
||||
|
||||
or esi,esi
|
||||
jz pci_read_byte1
|
||||
cmp esi,1
|
||||
jz pci_read_word1
|
||||
cmp esi,2
|
||||
jz pci_read_dword1
|
||||
jmp pci_fin_read1
|
||||
|
||||
pci_read_byte1:
|
||||
in al,dx
|
||||
jmp pci_fin_read1
|
||||
pci_read_word1:
|
||||
in ax,dx
|
||||
jmp pci_fin_read1
|
||||
pci_read_dword1:
|
||||
in eax,dx
|
||||
jmp pci_fin_read1
|
||||
pci_fin_read1:
|
||||
; restore configuration control
|
||||
xchg eax,[esp]
|
||||
mov dx,0xcf8
|
||||
out dx,eax
|
||||
|
||||
pop eax
|
||||
pop esi
|
||||
ret
|
||||
pci_read_reg_2:
|
||||
|
||||
test bh,128 ;mech#2 only supports 16 devices per bus
|
||||
jnz pci_read_reg_err
|
||||
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
push eax
|
||||
;store current state of config space
|
||||
mov dx,0xcf8
|
||||
in al,dx
|
||||
mov ah,al
|
||||
mov dl,0xfa
|
||||
in al,dx
|
||||
|
||||
xchg eax,[esp]
|
||||
; out 0xcfa,bus
|
||||
mov al,ah
|
||||
out dx,al
|
||||
; out 0xcf8,0x80
|
||||
mov dl,0xf8
|
||||
mov al,0x80
|
||||
out dx,al
|
||||
; compute addr
|
||||
shr bh,3 ; func is ignored in mechanism 2
|
||||
or bh,0xc0
|
||||
mov dx,bx
|
||||
|
||||
or esi,esi
|
||||
jz pci_read_byte2
|
||||
cmp esi,1
|
||||
jz pci_read_word2
|
||||
cmp esi,2
|
||||
jz pci_read_dword2
|
||||
jmp pci_fin_read2
|
||||
|
||||
pci_read_byte2:
|
||||
in al,dx
|
||||
jmp pci_fin_read2
|
||||
pci_read_word2:
|
||||
in ax,dx
|
||||
jmp pci_fin_read2
|
||||
pci_read_dword2:
|
||||
in eax,dx
|
||||
; jmp pci_fin_read2
|
||||
pci_fin_read2:
|
||||
|
||||
; restore configuration space
|
||||
xchg eax,[esp]
|
||||
mov dx,0xcfa
|
||||
out dx,al
|
||||
mov dl,0xf8
|
||||
mov al,ah
|
||||
out dx,al
|
||||
|
||||
pop eax
|
||||
pop esi
|
||||
ret
|
||||
|
||||
pci_read_reg_err:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
ret
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_write_reg:
|
||||
;
|
||||
; Description
|
||||
; write a register from ECX/CX/CL into the PCI config space
|
||||
; IN: ah=bus,device+func=bh,register address (dword aligned)=bl,
|
||||
; value to write in ecx
|
||||
; number of bytes to write (1,2,4) coded into AL, bits 0-1
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_write_reg:
|
||||
cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use?
|
||||
je pci_write_reg_2
|
||||
|
||||
; mechanism 1
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
call pci_make_config_cmd
|
||||
mov ebx,eax
|
||||
; get current state into ecx
|
||||
mov dx,0xcf8
|
||||
in eax, dx
|
||||
push eax
|
||||
; set up addressing to config data
|
||||
mov eax,ebx
|
||||
and al,0xfc ; make address dword-aligned
|
||||
out dx,eax
|
||||
; write DWORD of config data
|
||||
mov dl,0xfc
|
||||
and bl,3
|
||||
or dl,bl
|
||||
mov eax,ecx
|
||||
|
||||
or esi,esi
|
||||
jz pci_write_byte1
|
||||
cmp esi,1
|
||||
jz pci_write_word1
|
||||
cmp esi,2
|
||||
jz pci_write_dword1
|
||||
jmp pci_fin_write1
|
||||
|
||||
pci_write_byte1:
|
||||
out dx,al
|
||||
jmp pci_fin_write1
|
||||
pci_write_word1:
|
||||
out dx,ax
|
||||
jmp pci_fin_write1
|
||||
pci_write_dword1:
|
||||
out dx,eax
|
||||
jmp pci_fin_write1
|
||||
pci_fin_write1:
|
||||
|
||||
; restore configuration control
|
||||
pop eax
|
||||
mov dl,0xf8
|
||||
out dx,eax
|
||||
|
||||
xor eax,eax
|
||||
pop esi
|
||||
|
||||
ret
|
||||
pci_write_reg_2:
|
||||
|
||||
test bh,128 ;mech#2 only supports 16 devices per bus
|
||||
jnz pci_write_reg_err
|
||||
|
||||
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
push eax
|
||||
;store current state of config space
|
||||
mov dx,0xcf8
|
||||
in al,dx
|
||||
mov ah,al
|
||||
mov dl,0xfa
|
||||
in al,dx
|
||||
xchg eax,[esp]
|
||||
; out 0xcfa,bus
|
||||
mov al,ah
|
||||
out dx,al
|
||||
; out 0xcf8,0x80
|
||||
mov dl,0xf8
|
||||
mov al,0x80
|
||||
out dx,al
|
||||
; compute addr
|
||||
shr bh,3 ; func is ignored in mechanism 2
|
||||
or bh,0xc0
|
||||
mov dx,bx
|
||||
; write register
|
||||
mov eax,ecx
|
||||
|
||||
or esi,esi
|
||||
jz pci_write_byte2
|
||||
cmp esi,1
|
||||
jz pci_write_word2
|
||||
cmp esi,2
|
||||
jz pci_write_dword2
|
||||
jmp pci_fin_write2
|
||||
|
||||
pci_write_byte2:
|
||||
out dx,al
|
||||
jmp pci_fin_write2
|
||||
pci_write_word2:
|
||||
out dx,ax
|
||||
jmp pci_fin_write2
|
||||
pci_write_dword2:
|
||||
out dx,eax
|
||||
jmp pci_fin_write2
|
||||
pci_fin_write2:
|
||||
; restore configuration space
|
||||
pop eax
|
||||
mov dx,0xcfa
|
||||
out dx,al
|
||||
mov dl,0xf8
|
||||
mov al,ah
|
||||
out dx,al
|
||||
|
||||
xor eax,eax
|
||||
pop esi
|
||||
ret
|
||||
|
||||
pci_write_reg_err:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
ret
|
||||
499
kernel/branches/gfx_kernel/core/debug.inc
Normal file
499
kernel/branches/gfx_kernel/core/debug.inc
Normal file
@@ -0,0 +1,499 @@
|
||||
; diamond, 2006
|
||||
sys_debug_services:
|
||||
cmp eax, 9
|
||||
ja @f
|
||||
jmp dword [sys_debug_services_table+eax*4]
|
||||
@@: ret
|
||||
sys_debug_services_table:
|
||||
dd debug_set_event_data
|
||||
dd debug_getcontext
|
||||
dd debug_setcontext
|
||||
dd debug_detach
|
||||
dd debug_suspend
|
||||
dd debug_resume
|
||||
dd debug_read_process_memory
|
||||
dd debug_write_process_memory
|
||||
dd debug_terminate
|
||||
dd debug_set_drx
|
||||
|
||||
debug_set_event_data:
|
||||
; in: ebx = pointer
|
||||
; destroys eax
|
||||
mov eax, [0x3000]
|
||||
shl eax, 8
|
||||
mov [eax+0x80000+APPDATA.dbg_event_mem], ebx
|
||||
ret
|
||||
|
||||
get_debuggee_slot:
|
||||
; in: ebx=PID
|
||||
; out: CF=1 if error
|
||||
; CF=0 and eax=slot*0x20 if ok
|
||||
; out: interrupts disabled
|
||||
cli
|
||||
mov eax, ebx
|
||||
call pid_to_slot
|
||||
test eax, eax
|
||||
jz .ret_bad
|
||||
shl eax, 5
|
||||
push ebx
|
||||
mov ebx, [0x3000]
|
||||
cmp [0x80000+eax*8+APPDATA.debugger_slot], ebx
|
||||
pop ebx
|
||||
jnz .ret_bad
|
||||
; clc ; automatically
|
||||
ret
|
||||
.ret_bad:
|
||||
stc
|
||||
ret
|
||||
|
||||
debug_detach:
|
||||
; in: ebx=pid
|
||||
; destroys eax,ebx
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
and dword [eax*8+0x80000+APPDATA.debugger_slot], 0
|
||||
call do_resume
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
|
||||
debug_terminate:
|
||||
; in: ebx=pid
|
||||
call get_debuggee_slot
|
||||
jc debug_detach.ret
|
||||
mov ebx, eax
|
||||
shr ebx, 5
|
||||
push 2
|
||||
pop eax
|
||||
jmp sys_system
|
||||
|
||||
debug_suspend:
|
||||
; in: ebx=pid
|
||||
; destroys eax,ebx
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
mov bl, [0x3000+eax+TASKDATA.state] ; process state
|
||||
test bl, bl
|
||||
jz .1
|
||||
cmp bl, 5
|
||||
jnz .ret
|
||||
mov bl, 2
|
||||
.2: mov [0x3000+eax+TASKDATA.state], bl
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
.1:
|
||||
inc ebx
|
||||
jmp .2
|
||||
|
||||
do_resume:
|
||||
mov bl, [0x3000+eax+TASKDATA.state]
|
||||
cmp bl, 1
|
||||
jz .1
|
||||
cmp bl, 2
|
||||
jnz .ret
|
||||
mov bl, 5
|
||||
.2: mov [0x3000+eax+TASKDATA.state], bl
|
||||
.ret: ret
|
||||
.1: dec ebx
|
||||
jmp .2
|
||||
|
||||
debug_resume:
|
||||
; in: ebx=pid
|
||||
; destroys eax,ebx
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
call do_resume
|
||||
.ret: sti
|
||||
ret
|
||||
|
||||
debug_getcontext:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=sizeof(CONTEXT)
|
||||
; edx->CONTEXT
|
||||
; destroys eax,ecx,edx,esi,edi
|
||||
cmp ecx, 28h
|
||||
jnz .ret
|
||||
add edx, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz .ret
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
imul eax, tss_step/32
|
||||
add eax, tss_data
|
||||
mov edi, edx
|
||||
cmp [l.cs - tss_sceleton + eax], app_code
|
||||
jnz .ring0
|
||||
lea esi, [l.eip - tss_sceleton + eax]
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
jmp .ret
|
||||
.ring0:
|
||||
; note that following code assumes that all interrupt/exception handlers
|
||||
; saves ring-3 context by push ds es, pushad in this order
|
||||
mov esi, [l.esp0 - tss_sceleton + eax]
|
||||
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), ds, es, pushad
|
||||
sub esi, 8+12+8+20h
|
||||
lodsd
|
||||
mov [edi+24h], eax
|
||||
lodsd
|
||||
mov [edi+20h], eax
|
||||
lodsd
|
||||
mov [edi+1Ch], eax
|
||||
lodsd
|
||||
lodsd
|
||||
mov [edi+14h], eax
|
||||
lodsd
|
||||
mov [edi+10h], eax
|
||||
lodsd
|
||||
mov [edi+0Ch], eax
|
||||
lodsd
|
||||
mov [edi+8], eax
|
||||
add esi, 8
|
||||
lodsd
|
||||
mov [edi], eax
|
||||
lodsd
|
||||
lodsd
|
||||
mov [edi+4], eax
|
||||
lodsd
|
||||
mov [edi+18h], eax
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
|
||||
debug_setcontext:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=sizeof(CONTEXT)
|
||||
; edx->CONTEXT
|
||||
; destroys eax,ecx,edx,esi,edi
|
||||
cmp ecx, 28h
|
||||
jnz .ret
|
||||
add edx, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz .ret
|
||||
call get_debuggee_slot
|
||||
jc .stiret
|
||||
imul eax, tss_step/32
|
||||
add eax, tss_data
|
||||
mov esi, edx
|
||||
cmp [l.cs - tss_sceleton + eax], app_code
|
||||
jnz .ring0
|
||||
lea edi, [l.eip - tss_sceleton + eax]
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
jmp .stiret
|
||||
.ring0:
|
||||
mov edi, [l.esp0 - tss_sceleton + eax]
|
||||
sub edi, 8+12+8+20h
|
||||
mov eax, [esi+24h]
|
||||
stosd
|
||||
mov eax, [esi+20h]
|
||||
stosd
|
||||
mov eax, [esi+1Ch]
|
||||
stosd
|
||||
scasd
|
||||
mov eax, [esi+14h]
|
||||
stosd
|
||||
mov eax, [esi+10h]
|
||||
stosd
|
||||
mov eax, [esi+0Ch]
|
||||
stosd
|
||||
mov eax, [esi+8]
|
||||
stosd
|
||||
add edi, 8
|
||||
mov eax, [esi]
|
||||
stosd
|
||||
scasd
|
||||
mov eax, [esi+4]
|
||||
stosd
|
||||
mov eax, [esi+18h]
|
||||
stosd
|
||||
.stiret:
|
||||
sti
|
||||
.ret:
|
||||
ret
|
||||
|
||||
debug_set_drx:
|
||||
call get_debuggee_slot
|
||||
jc .errret
|
||||
mov ebp, eax
|
||||
lea eax, [eax*8+0x80000+APPDATA.dbg_regs]
|
||||
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
|
||||
; [eax+10]=dr7
|
||||
add edx, std_application_base_address
|
||||
jc .errret
|
||||
cmp cl, 3
|
||||
ja .errret
|
||||
mov ebx, dr7
|
||||
shr ebx, cl
|
||||
shr ebx, cl
|
||||
test ebx, 2 ; bit 1+2*index = G0..G3, global break enable
|
||||
jnz .errret2
|
||||
test ch, ch
|
||||
jns .new
|
||||
; clear breakpoint
|
||||
movzx ecx, cl
|
||||
add ecx, ecx
|
||||
and dword [eax+ecx*2], 0 ; clear DR<i>
|
||||
btr dword [eax+10h], ecx ; clear L<i> bit
|
||||
test byte [eax+10h], 55h
|
||||
jnz .okret
|
||||
imul eax, ebp, tss_step/32
|
||||
and byte [eax + tss_data + l.trap - tss_sceleton], not 1
|
||||
.okret:
|
||||
and dword [esp+36], 0
|
||||
sti
|
||||
ret
|
||||
.errret:
|
||||
sti
|
||||
mov dword [esp+36], 1
|
||||
ret
|
||||
.errret2:
|
||||
sti
|
||||
mov dword [esp+36], 2
|
||||
ret
|
||||
.new:
|
||||
; add new breakpoint
|
||||
; cl=index; ch=flags; edx=address
|
||||
test ch, 0xF0
|
||||
jnz .errret
|
||||
mov bl, ch
|
||||
and bl, 3
|
||||
cmp bl, 2
|
||||
jz .errret
|
||||
mov bl, ch
|
||||
shr bl, 2
|
||||
cmp bl, 2
|
||||
jz .errret
|
||||
test dl, bl
|
||||
jnz .errret
|
||||
or byte [eax+10h+1], 3 ; set GE and LE flags
|
||||
movzx ebx, ch
|
||||
movzx ecx, cl
|
||||
add ecx, ecx
|
||||
bts dword [eax+10h], ecx ; set L<i> flag
|
||||
add ecx, ecx
|
||||
mov [eax+ecx], edx ; set DR<i>
|
||||
shl ebx, cl
|
||||
mov edx, 0xF
|
||||
shl edx, cl
|
||||
not edx
|
||||
and [eax+10h+2], dx
|
||||
or [eax+10h+2], bx ; set R/W and LEN fields
|
||||
imul eax, ebp, tss_step/32
|
||||
or byte [eax + tss_data + l.trap - tss_sceleton], 1
|
||||
jmp .okret
|
||||
|
||||
debug_read_process_memory:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=length
|
||||
; esi->buffer in debugger
|
||||
; edx=address in debuggee
|
||||
; out: [esp+36]=sizeof(read)
|
||||
; destroys all
|
||||
add esi, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, esi
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz .err
|
||||
call get_debuggee_slot
|
||||
jc .err
|
||||
shr eax, 5
|
||||
mov ebx, esi
|
||||
call read_process_memory
|
||||
sti
|
||||
mov dword [esp+36], eax
|
||||
ret
|
||||
.err:
|
||||
or dword [esp+36], -1
|
||||
ret
|
||||
|
||||
debug_write_process_memory:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=length
|
||||
; esi->buffer in debugger
|
||||
; edx=address in debuggee
|
||||
; out: [esp+36]=sizeof(write)
|
||||
; destroys all
|
||||
add esi, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, esi
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz debug_read_process_memory.err
|
||||
call get_debuggee_slot
|
||||
jc debug_read_process_memory.err
|
||||
shr eax, 5
|
||||
mov ebx, esi
|
||||
call write_process_memory
|
||||
sti
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
|
||||
debugger_notify:
|
||||
; in: eax=debugger slot
|
||||
; ecx=size of debug message
|
||||
; [esp+4]..[esp+4+ecx]=message
|
||||
; interrupts must be disabled!
|
||||
; destroys all general registers
|
||||
; interrupts remain disabled
|
||||
xchg ebp, eax
|
||||
mov edi, [timer_ticks]
|
||||
add edi, 500 ; 5 sec timeout
|
||||
.1:
|
||||
mov eax, ebp
|
||||
shl eax, 8
|
||||
mov edx, [0x80000+eax+APPDATA.dbg_event_mem]
|
||||
test edx, edx
|
||||
jz .ret
|
||||
; read buffer header
|
||||
push ecx
|
||||
push eax
|
||||
push eax
|
||||
mov eax, ebp
|
||||
mov ebx, esp
|
||||
mov ecx, 8
|
||||
call read_process_memory
|
||||
cmp eax, ecx
|
||||
jz @f
|
||||
add esp, 12
|
||||
jmp .ret
|
||||
@@:
|
||||
cmp dword [ebx], 0
|
||||
jg @f
|
||||
.2:
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
cmp dword [0x3000], 1
|
||||
jnz .notos
|
||||
cmp [timer_ticks], edi
|
||||
jae .ret
|
||||
.notos:
|
||||
sti
|
||||
call change_task
|
||||
cli
|
||||
jmp .1
|
||||
@@:
|
||||
mov ecx, [ebx+8]
|
||||
add ecx, [ebx+4]
|
||||
cmp ecx, [ebx]
|
||||
ja .2
|
||||
; advance buffer position
|
||||
push ecx
|
||||
mov ecx, 4
|
||||
sub ebx, ecx
|
||||
mov eax, ebp
|
||||
add edx, ecx
|
||||
call write_process_memory
|
||||
pop eax
|
||||
; write message
|
||||
mov eax, ebp
|
||||
add edx, ecx
|
||||
add edx, [ebx+8]
|
||||
add ebx, 20
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
call write_process_memory
|
||||
; new debug event
|
||||
mov eax, ebp
|
||||
shl eax, 8
|
||||
or byte [0x80000+eax+APPDATA.event_mask+1], 1 ; set flag 100h
|
||||
.ret:
|
||||
ret
|
||||
|
||||
debug_exc:
|
||||
; int 1 = #DB
|
||||
save_ring3_context
|
||||
cld
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov eax, dr6
|
||||
test ax, ax
|
||||
jns @f
|
||||
; this is exception from task switch
|
||||
; set DRx registers for task and continue
|
||||
mov eax, [0x3000]
|
||||
shl eax, 8
|
||||
add eax, 0x80000+APPDATA.dbg_regs
|
||||
mov ecx, [eax+0]
|
||||
mov dr0, ecx
|
||||
mov ecx, [eax+4]
|
||||
mov dr1, ecx
|
||||
mov ecx, [eax+8]
|
||||
mov dr2, ecx
|
||||
mov ecx, [eax+0Ch]
|
||||
mov dr3, ecx
|
||||
xor ecx, ecx
|
||||
mov dr6, ecx
|
||||
mov ecx, [eax+10h]
|
||||
mov dr7, ecx
|
||||
restore_ring3_context
|
||||
iretd
|
||||
@@:
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
; test if debugging
|
||||
cli
|
||||
mov eax, [0x3000]
|
||||
shl eax, 8
|
||||
mov eax, [0x80000+eax+APPDATA.debugger_slot]
|
||||
test eax, eax
|
||||
jnz .debug
|
||||
sti
|
||||
; not debuggee => say error and terminate
|
||||
add esp, 28h+4
|
||||
mov [error_interrupt], 1
|
||||
call show_error_parameters
|
||||
mov edx, [0x3010]
|
||||
mov byte [edx+TASKDATA.state], 4
|
||||
jmp change_task
|
||||
.debug:
|
||||
; we are debugged process, notify debugger and suspend ourself
|
||||
; eax=debugger PID
|
||||
pop edx
|
||||
mov ebx, dr7
|
||||
mov cl, not 1
|
||||
.l1:
|
||||
test bl, 1
|
||||
jnz @f
|
||||
and dl, cl
|
||||
@@:
|
||||
shr ebx, 2
|
||||
add cl, cl
|
||||
inc ecx
|
||||
cmp cl, not 10h
|
||||
jnz .l1
|
||||
push edx ; DR6 image
|
||||
mov ecx, [0x3010]
|
||||
push dword [ecx+TASKDATA.pid] ; PID
|
||||
push 12
|
||||
pop ecx
|
||||
push 3 ; 3 = debug exception
|
||||
call debugger_notify
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
mov edx, [0x3010]
|
||||
mov byte [edx+TASKDATA.state], 1 ; suspended
|
||||
call change_task
|
||||
restore_ring3_context
|
||||
iretd
|
||||
@@ -25,7 +25,7 @@ create_general_page_table:
|
||||
mov eax,[general_page_table]
|
||||
call MEM_Get_Linear_Address ;eax - linear address of page directory
|
||||
mov edi,eax
|
||||
mov ebx,eax
|
||||
mov ebx,eax ;copy address of page directory to safe place
|
||||
xor eax,eax
|
||||
mov ecx,4096/4
|
||||
cld
|
||||
@@ -52,19 +52,6 @@ create_general_page_table:
|
||||
mov ecx,4096/4
|
||||
;ecx (counter) - number of pages in page table
|
||||
;current address=4Mb*esi
|
||||
cmp esi,2
|
||||
jz .start_lfb_map ;lfb map begin at 0x800000
|
||||
cmp esi,3
|
||||
jz .end_lfb_map ;lfb map end at 0xC00000
|
||||
jmp .loop1
|
||||
.start_lfb_map:
|
||||
;current address=lfb address
|
||||
mov ebp,[0x2f0000+0x9018]
|
||||
add ebp,7 ;add flags
|
||||
jmp .loop1
|
||||
.end_lfb_map:
|
||||
;current address=linear address
|
||||
mov ebp,12*0x100000+7
|
||||
|
||||
.loop1:
|
||||
mov [eax],ebp ;write page address (with flags) in page table
|
||||
@@ -76,24 +63,33 @@ create_general_page_table:
|
||||
cmp esi,edx
|
||||
jnz .loop
|
||||
|
||||
;map region 0x80000000-0x803fffff to 0x800000-0xcfffff
|
||||
mov eax,1 ;size of the region is 4Mb so only 1 page table needed
|
||||
;map region 0x80000000-0x807fffff to LFB
|
||||
mov eax,2 ;size of the region is 4Mb so only 1 page table needed
|
||||
mov edx,ebx ;ebx still contains linear address of the page directory
|
||||
add ebx,0x800
|
||||
call MEM_Alloc_Pages ;alloc page table for the region
|
||||
mov eax,[ebx]
|
||||
add dword [ebx],7 ;add flags
|
||||
call MEM_Get_Linear_Address ;get linear address of the page table
|
||||
mov ebx,eax
|
||||
mov ecx,4096/4 ;number of pages in page table
|
||||
mov eax,8*0x100000+7
|
||||
mov edi,[0xfe80]
|
||||
add edi,7
|
||||
.loop3:
|
||||
;ebx - linear address of page table
|
||||
;eax - current linear address with flags
|
||||
mov [ebx],eax
|
||||
add ebx,4
|
||||
add eax,4096
|
||||
;eax - linear address of page table
|
||||
;edi - current linear address with flags
|
||||
mov [eax],edi
|
||||
add eax,4
|
||||
add edi,4096
|
||||
loop .loop3
|
||||
mov eax,[ebx+4]
|
||||
call MEM_Get_Linear_Address
|
||||
add dword [ebx+4],7
|
||||
mov ecx,4096/4
|
||||
.loop31:
|
||||
mov [eax],edi
|
||||
add eax,4
|
||||
add edi,4096
|
||||
loop .loop31
|
||||
|
||||
;map region 0xC0000000-* to 0x0-*
|
||||
mov esi,edx ;esi=linear address of the page directory
|
||||
@@ -192,7 +188,7 @@ create_app_cr3_table:
|
||||
mov eax,[general_page_table]
|
||||
call simple_clone_cr3_table ;clone general page table
|
||||
shl ebx,8
|
||||
mov [second_base_address+0x80000+ebx+0xB8],eax ;save address of page directory
|
||||
mov [second_base_address+0x80000+ebx+APPDATA.dir_table],eax ;save address of page directory
|
||||
|
||||
pop ebx
|
||||
ret
|
||||
@@ -203,7 +199,7 @@ get_cr3_table:
|
||||
;result:
|
||||
; eax - physical address of page directory
|
||||
shl eax,8 ;size of process extended information=256 bytes
|
||||
mov eax,[second_base_address+0x80000+eax+0xB8]
|
||||
mov eax,[second_base_address+0x80000+eax+APPDATA.dir_table]
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
dispose_app_cr3_table:
|
||||
@@ -217,7 +213,7 @@ dispose_app_cr3_table:
|
||||
mov ebp,eax
|
||||
;ebp = process slot in the procedure.
|
||||
shl eax,8
|
||||
mov eax,[second_base_address+0x80000+eax+0xB8]
|
||||
mov eax,[second_base_address+0x80000+eax+APPDATA.dir_table]
|
||||
mov ebx,eax
|
||||
;ebx = physical address of page directory
|
||||
call MEM_Get_Linear_Address
|
||||
@@ -238,10 +234,10 @@ dispose_app_cr3_table:
|
||||
;eax = current slot of process
|
||||
mov ecx,eax
|
||||
shl ecx,5
|
||||
cmp byte [second_base_address+0x3000+ecx+0xa],9 ;if process running?
|
||||
cmp byte [second_base_address+0x3000+ecx+TASKDATA.state],9 ;if process running?
|
||||
jz .next ;skip empty slots
|
||||
shl ecx,3
|
||||
cmp [second_base_address+0x80000+ecx+0xB8],ebx ;compare page directory addresses
|
||||
cmp [second_base_address+0x80000+ecx+APPDATA.dir_table],ebx ;compare page directory addresses
|
||||
jnz .next
|
||||
inc edx ;thread found
|
||||
.next:
|
||||
@@ -33,7 +33,7 @@ find_new_process_place:
|
||||
cmp eax,ebx
|
||||
jz .endnewprocessplace ;empty slot after high boundary
|
||||
add eax,0x20
|
||||
cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty
|
||||
cmp word [eax+TASKDATA.state],9 ;check process state, 9 means that process slot is empty
|
||||
jnz .newprocessplace
|
||||
.endnewprocessplace:
|
||||
mov ebx,eax
|
||||
@@ -41,7 +41,7 @@ find_new_process_place:
|
||||
shr eax,5 ;calculate slot index
|
||||
cmp eax,256
|
||||
jge .failed ;it should be <256
|
||||
mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary)
|
||||
mov word [ebx+TASKDATA.state],9 ;set process state to 9 (for slot after hight boundary)
|
||||
mov [new_process_place],eax ;save process slot
|
||||
pop ebx
|
||||
ret
|
||||
@@ -86,6 +86,7 @@ new_start_application_floppy:
|
||||
call find_new_process_place ;find empty process slot
|
||||
sti
|
||||
test eax,eax
|
||||
mov ecx, -0x20 ; too many processes
|
||||
jz .failed
|
||||
|
||||
mov edi,eax
|
||||
@@ -97,9 +98,9 @@ new_start_application_floppy:
|
||||
rep stosd ;clean extended information about process
|
||||
|
||||
;set new process name
|
||||
xor eax,eax
|
||||
mov [appl_path_size],eax
|
||||
mov eax,[esp] ;+8]
|
||||
pop eax
|
||||
push eax
|
||||
.find_last_byte:
|
||||
cmp byte [eax],0
|
||||
jz .find_last_byte_end
|
||||
@@ -112,7 +113,7 @@ new_start_application_floppy:
|
||||
; mov eax,[esp] ;eax - pointer to file name
|
||||
mov ebx,[new_process_place]
|
||||
shl ebx,8
|
||||
add ebx,0x80000
|
||||
add ebx,0x80000 + APPDATA.app_name
|
||||
mov ecx,11
|
||||
call memmove
|
||||
|
||||
@@ -126,19 +127,21 @@ new_start_application_floppy:
|
||||
; cli
|
||||
call floppy_fileread ;read file from FD
|
||||
; sti
|
||||
cmp eax,0
|
||||
jne .cleanfailed
|
||||
;check MENUET signature
|
||||
mov ecx, eax
|
||||
neg ecx
|
||||
jnz .cleanfailed
|
||||
;check MENUET signature
|
||||
mov ecx, -0x1F ; not Menuet/Kolibri executable
|
||||
cmp [0x90000],dword 'MENU'
|
||||
jnz .cleanfailed
|
||||
cmp [0x90004],word 'ET'
|
||||
jnz .cleanfailed
|
||||
|
||||
call get_app_params ;parse header fields
|
||||
cmp esi,0
|
||||
jz .cleanfailed
|
||||
jc .cleanfailed
|
||||
|
||||
mov eax,[new_process_place]
|
||||
inc ecx ; -0x1E = no memory
|
||||
call create_app_cr3_table ;create page directory for new process
|
||||
test eax,eax
|
||||
jz .cleanfailed_mem
|
||||
@@ -152,6 +155,7 @@ new_start_application_floppy:
|
||||
mov edx,eax
|
||||
call mem_alloc_specified_region ;allocate memory for application
|
||||
test eax,eax
|
||||
mov ecx, -0x1E
|
||||
jz .cleanfailed_mem1
|
||||
|
||||
mov eax,[edx+(std_application_base_address shr 20)]
|
||||
@@ -172,6 +176,7 @@ new_start_application_floppy:
|
||||
mov edx,eax ;read file block to current page
|
||||
mov eax,[esp+4] ;restore pointer to file name
|
||||
mov ecx,8 ;number of blocks read
|
||||
mov ebp,edx ;save buffer address for .endofimage
|
||||
push ebx
|
||||
mov edi,[esp+16]
|
||||
; cli
|
||||
@@ -179,17 +184,33 @@ new_start_application_floppy:
|
||||
;ebx=file size
|
||||
; sti
|
||||
pop ecx
|
||||
add ecx,8
|
||||
test eax,eax
|
||||
jnz .endloop1 ;check io errors
|
||||
mov eax,[app_i_end]
|
||||
add eax,511
|
||||
shr eax,9
|
||||
cmp ecx,eax
|
||||
jg .endofimage ;we have loaded whole program
|
||||
add ebx,511
|
||||
shr ebx,9
|
||||
cmp ecx,ebx
|
||||
jg .endloop1 ;if end of file?
|
||||
mov ebx,ecx
|
||||
test eax,eax
|
||||
jnz .endloop1 ;check io errors
|
||||
pop edx
|
||||
add ebx,8 ;go to next page
|
||||
add edx,4
|
||||
jmp .loop1
|
||||
|
||||
.endofimage: ;set to zero memory at end of page
|
||||
mov ecx,[app_i_end]
|
||||
and ecx,4096-1
|
||||
jz .endloop1
|
||||
lea edi,[ebp+ecx]
|
||||
neg ecx
|
||||
add ecx,4096
|
||||
xor eax,eax
|
||||
cld
|
||||
rep stosb
|
||||
.endloop1:
|
||||
add esp,8+4 ;pop linear address of page table entry and pointer to file name
|
||||
call new_start_application_fl.add_app_parameters
|
||||
@@ -202,29 +223,31 @@ new_start_application_floppy:
|
||||
;so free directory entry
|
||||
mov eax,[new_process_place]
|
||||
shl eax,8
|
||||
mov eax,[0x80000+eax+0xB8]
|
||||
mov eax,[0x80000+eax+APPDATA.dir_table]
|
||||
call MEM_Free_Page
|
||||
.cleanfailed_mem:
|
||||
;there is no mem for directory entry, display message.
|
||||
mov esi,start_not_enough_memory
|
||||
call sys_msg_board_str
|
||||
.cleanfailed: ;clean process name
|
||||
push ecx ; save error code
|
||||
;can't read file, clean process name.
|
||||
;this avoid problems with panel application.
|
||||
mov edi,[new_process_place]
|
||||
shl edi,8
|
||||
add edi,0x80000
|
||||
add edi,0x80000 + APPDATA.app_name
|
||||
mov ecx,11
|
||||
mov eax,' '
|
||||
cld
|
||||
rep stosb
|
||||
pop eax
|
||||
.failed:
|
||||
;no more slots
|
||||
add esp,8+4
|
||||
mov [application_table_status],0
|
||||
mov [esp+1Ch], eax
|
||||
popad
|
||||
sti
|
||||
mov eax,-1
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
@@ -258,6 +281,7 @@ new_start_application_fl:
|
||||
call find_new_process_place ;find empty process slot
|
||||
call safe_sti
|
||||
test eax,eax
|
||||
mov ecx, -0x20 ; too many processes
|
||||
jz .failed
|
||||
|
||||
mov edi,eax
|
||||
@@ -272,7 +296,7 @@ new_start_application_fl:
|
||||
mov eax,[esp] ;eax - pointer to file name
|
||||
mov ebx,[new_process_place]
|
||||
shl ebx,8
|
||||
add ebx,0x80000
|
||||
add ebx,0x80000 + APPDATA.app_name
|
||||
mov ecx,11
|
||||
call memmove
|
||||
|
||||
@@ -284,19 +308,21 @@ new_start_application_fl:
|
||||
cli
|
||||
call fileread ;read file from RD
|
||||
call safe_sti
|
||||
cmp eax,0
|
||||
jne .cleanfailed
|
||||
;check MENUET signature
|
||||
mov ecx, eax
|
||||
neg ecx
|
||||
jnz .cleanfailed
|
||||
;check MENUET signature
|
||||
mov ecx, -0x1F ; not Menuet/Kolibri executable
|
||||
cmp [0x90000],dword 'MENU'
|
||||
jnz .cleanfailed
|
||||
cmp [0x90004],word 'ET'
|
||||
jnz .cleanfailed
|
||||
|
||||
call get_app_params ;parse header fields
|
||||
cmp esi,0
|
||||
jz .cleanfailed
|
||||
jc .cleanfailed
|
||||
|
||||
mov eax,[new_process_place]
|
||||
inc ecx ; -0x1E = no memory
|
||||
call create_app_cr3_table ;create page directory for new process
|
||||
test eax,eax
|
||||
jz .cleanfailed_mem
|
||||
@@ -310,6 +336,7 @@ new_start_application_fl:
|
||||
mov edx,eax
|
||||
call mem_alloc_specified_region ;allocate memory for application
|
||||
test eax,eax
|
||||
mov ecx, -0x1E
|
||||
jz .cleanfailed_mem1
|
||||
|
||||
mov eax,[edx+(std_application_base_address shr 20)]
|
||||
@@ -330,23 +357,40 @@ new_start_application_fl:
|
||||
mov edx,eax ;read file block to current page
|
||||
mov eax,[esp+4] ;restore pointer to file name
|
||||
mov ecx,8 ;number of blocks read
|
||||
mov ebp,edx ;save buffer address for .endofimage
|
||||
push ebx
|
||||
cli
|
||||
call fileread
|
||||
;ebx=file size
|
||||
call safe_sti
|
||||
pop ecx
|
||||
add ecx,8
|
||||
test eax,eax
|
||||
jnz .endloop1 ;check io errors
|
||||
mov eax,[app_i_end]
|
||||
add eax,511
|
||||
shr eax,9
|
||||
cmp ecx,eax
|
||||
jg .endofimage ;we have loaded whole program
|
||||
add ebx,511
|
||||
shr ebx,9
|
||||
cmp ecx,ebx
|
||||
jg .endloop1 ;if end of file?
|
||||
mov ebx,ecx
|
||||
test eax,eax
|
||||
jnz .endloop1 ;check io errors
|
||||
pop edx
|
||||
add ebx,8 ;go to next page
|
||||
add edx,4
|
||||
jmp .loop1
|
||||
|
||||
.endofimage: ;set to zero memory at end of page
|
||||
mov ecx,[app_i_end]
|
||||
and ecx,4096-1
|
||||
jz .endloop1
|
||||
lea edi,[ebp+ecx]
|
||||
neg ecx
|
||||
add ecx,4096
|
||||
xor eax,eax
|
||||
cld
|
||||
rep stosb
|
||||
.endloop1:
|
||||
add esp,8 ;pop linear address of page table entry and pointer to file name
|
||||
call .add_app_parameters
|
||||
@@ -359,29 +403,31 @@ new_start_application_fl:
|
||||
;so free directory entry
|
||||
mov eax,[new_process_place]
|
||||
shl eax,8
|
||||
mov eax,[0x80000+eax+0xB8]
|
||||
mov eax,[0x80000+eax+APPDATA.dir_table]
|
||||
call MEM_Free_Page
|
||||
.cleanfailed_mem:
|
||||
;there is no mem for directory entry, display message.
|
||||
mov esi,start_not_enough_memory
|
||||
call sys_msg_board_str
|
||||
.cleanfailed: ;clean process name
|
||||
push ecx ; save error code
|
||||
;can't read file, clean process name.
|
||||
;this avoid problems with panel application.
|
||||
mov edi,[new_process_place]
|
||||
shl edi,8
|
||||
add edi,0x80000
|
||||
add edi,0x80000+APPDATA.app_name
|
||||
mov ecx,11
|
||||
mov eax,' '
|
||||
cld
|
||||
rep stosb
|
||||
pop eax
|
||||
.failed:
|
||||
;no more slots
|
||||
add esp,8
|
||||
mov [application_table_status],0
|
||||
mov [esp+1Ch], eax
|
||||
popad
|
||||
call safe_sti
|
||||
mov eax,-1
|
||||
ret
|
||||
|
||||
.add_app_parameters:
|
||||
@@ -403,13 +449,13 @@ new_start_application_fl:
|
||||
;(size of application memory)
|
||||
shl ebx,8
|
||||
mov eax,[app_mem]
|
||||
mov [second_base_address+0x80000+0x8c+ebx],eax
|
||||
mov [second_base_address+0x80000+APPDATA.mem_size+ebx],eax
|
||||
;set 0x10 field of information about process
|
||||
;(application base address)
|
||||
; mov ebx,[new_process_place]
|
||||
; shl ebx,5
|
||||
shr ebx,3
|
||||
mov dword [second_base_address+0x3000+ebx+0x10],std_application_base_address
|
||||
mov dword [second_base_address+0x3000+ebx+TASKDATA.mem_start],std_application_base_address
|
||||
|
||||
;add command line parameters
|
||||
.add_command_line:
|
||||
@@ -422,6 +468,7 @@ new_start_application_fl:
|
||||
;calculate parameter length
|
||||
mov esi,eax
|
||||
xor ecx,ecx
|
||||
inc ecx ; include terminating null
|
||||
.command_line_len:
|
||||
cmp byte [esi],0
|
||||
jz .command_line_len_end
|
||||
@@ -452,29 +499,29 @@ new_start_application_fl:
|
||||
mov eax,ebx
|
||||
shl ebx,5
|
||||
add ebx,0x3000 ;ebx - pointer to information about process
|
||||
mov [ebx+0xe],al ;set window number on screen = process slot
|
||||
mov [ebx+TASKDATA.wnd_number],al ;set window number on screen = process slot
|
||||
|
||||
mov [ebx],dword 1+2+4 ;set default event flags (see 40 function)
|
||||
mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function)
|
||||
|
||||
inc dword [process_number]
|
||||
mov eax,[process_number]
|
||||
mov [ebx+4],eax ;set PID
|
||||
mov [ebx+TASKDATA.pid],eax ;set PID
|
||||
|
||||
mov ecx,ebx
|
||||
add ecx,draw_data-0x3000 ;ecx - pointer to draw data
|
||||
;set draw data to full screen
|
||||
mov [ecx+0],dword 0
|
||||
mov [ecx+4],dword 0
|
||||
mov [ecx+RECT.left],dword 0
|
||||
mov [ecx+RECT.top],dword 0
|
||||
mov eax,[0xfe00]
|
||||
mov [ecx+8],eax
|
||||
mov [ecx+RECT.right],eax
|
||||
mov eax,[0xfe04]
|
||||
mov [ecx+12],eax
|
||||
mov [ecx+RECT.bottom],eax
|
||||
;set window state to 'normal' (non-minimized/maximized/rolled-up) state
|
||||
mov [ecx+WDATA.fl_wstate],WSTATE_NORMAL
|
||||
;set cr3 register in TSS of application
|
||||
mov ecx,[new_process_place]
|
||||
shl ecx,8
|
||||
mov eax,[0x800B8+ecx]
|
||||
mov eax,[0x80000+APPDATA.dir_table+ecx]
|
||||
add eax,8+16 ;add flags
|
||||
mov [l.cr3],eax
|
||||
|
||||
@@ -549,14 +596,16 @@ new_start_application_fl:
|
||||
|
||||
mov ebx,[new_process_place]
|
||||
shl ebx,5
|
||||
mov [0x3000+ebx+0xa],byte 0 ;set process state - running
|
||||
; set if debuggee
|
||||
test byte [esp+28], 1
|
||||
jz .no_debug
|
||||
mov [0x3000+ebx+0xa],byte 1 ;set process state - suspended
|
||||
mov eax,[0x3000]
|
||||
mov [0x80000+ebx*8+0xac],eax ;set debugger PID - current
|
||||
test byte [esp+28], 1
|
||||
jz .no_debug
|
||||
mov [0x3000+ebx+TASKDATA.state], 1 ; set process state - suspended
|
||||
mov eax, [0x3000]
|
||||
mov [0x80000+ebx*8+APPDATA.debugger_slot], eax ;set debugger PID - current
|
||||
jmp .debug
|
||||
.no_debug:
|
||||
mov [0x3000+ebx+TASKDATA.state], 0 ; set process state - running
|
||||
.debug:
|
||||
|
||||
mov esi,new_process_running
|
||||
call sys_msg_board_str ;output information about succefull startup
|
||||
@@ -606,22 +655,22 @@ new_sys_threads:
|
||||
|
||||
mov esi,[0x3000]
|
||||
shl esi,8
|
||||
add esi,0x80000
|
||||
add esi,0x80000+APPDATA.app_name
|
||||
mov ebx,esi ;ebx=esi - pointer to extended information about current thread
|
||||
|
||||
mov edi,[new_process_place]
|
||||
shl edi,8
|
||||
add edi,0x80000
|
||||
mov edx,edi ;edx=edi - pointer to extended infomation about new thread
|
||||
lea edx, [edi+APPDATA.app_name] ;edx=edi - pointer to extended infomation about new thread
|
||||
mov ecx,256/4
|
||||
rep stosd ;clean extended information about new thread
|
||||
mov edi,edx
|
||||
mov ecx,11
|
||||
rep movsb ;copy process name
|
||||
mov eax,[ebx+0x8c]
|
||||
mov eax,[ebx+APPDATA.mem_size]
|
||||
mov [app_mem],eax ;set memory size
|
||||
mov eax,[ebx+0xb8]
|
||||
mov [edx+0xb8],eax ;copy page directory
|
||||
mov eax,[ebx+APPDATA.dir_table]
|
||||
mov dword [edx-APPDATA.app_name+APPDATA.dir_table],eax ;copy page directory
|
||||
; mov eax,[new_process_place]
|
||||
; mov ebx,[0x3000]
|
||||
; call addreference_app_cr3_table
|
||||
@@ -653,10 +702,10 @@ new_mem_resize:
|
||||
and ebx,not (4096-1) ;round up size
|
||||
mov ecx,[0x3000]
|
||||
shl ecx,8
|
||||
mov edx,[0x8008C+ecx]
|
||||
mov edx,[0x80000 + APPDATA.mem_size +ecx]
|
||||
add edx,4095
|
||||
and edx,not (4096-1) ;old size
|
||||
mov eax,[0x800B8+ecx]
|
||||
mov eax,[0x80000 + APPDATA.dir_table+ecx]
|
||||
call MEM_Get_Linear_Address
|
||||
;eax - linear address of page directory
|
||||
call MEM_Heap_Lock ;guarantee that two threads willn't
|
||||
@@ -688,10 +737,10 @@ new_mem_resize:
|
||||
mov ebx,esi
|
||||
mov eax,[0x3000]
|
||||
shl eax,8
|
||||
mov [eax+0x8008c],ebx ;write new memory size
|
||||
mov [eax+0x80000 + APPDATA.mem_size],ebx ;write new memory size
|
||||
;search threads and update
|
||||
;application memory size infomation
|
||||
mov ecx,[eax+0x800b8]
|
||||
mov ecx,[eax+0x80000 + APPDATA.dir_table]
|
||||
mov eax,2
|
||||
|
||||
.search_threads:
|
||||
@@ -702,12 +751,12 @@ new_mem_resize:
|
||||
jg .search_threads_end
|
||||
mov edx,eax
|
||||
shl edx,5
|
||||
cmp word [0x3000+edx+0xa],9 ;if slot empty?
|
||||
cmp word [0x3000+edx+TASKDATA.state],9 ;if slot empty?
|
||||
jz .search_threads_next
|
||||
shl edx,3
|
||||
cmp [edx+0x800b8],ecx ;if it is our thread?
|
||||
cmp [edx+0x80000+APPDATA.dir_table],ecx ;if it is our thread?
|
||||
jnz .search_threads_next
|
||||
mov [edx+0x8008c],ebx ;update memory size
|
||||
mov [edx+0x80000+APPDATA.mem_size],ebx ;update memory size
|
||||
.search_threads_next:
|
||||
inc eax
|
||||
jmp .search_threads
|
||||
@@ -737,9 +786,9 @@ pid_to_slot:
|
||||
.loop:
|
||||
;ecx=offset of current process info entry
|
||||
;ebx=maximum permitted offset
|
||||
cmp byte [second_base_address+0x3000+ecx+0xa],9
|
||||
cmp byte [second_base_address+0x3000+ecx+TASKDATA.state],9
|
||||
jz .endloop ;skip empty slots
|
||||
cmp [second_base_address+0x3000+ecx+0x4],eax ;check PID
|
||||
cmp [second_base_address+0x3000+ecx+TASKDATA.pid],eax ;check PID
|
||||
jz .pid_found
|
||||
.endloop:
|
||||
add ecx,32
|
||||
@@ -785,7 +834,7 @@ write_process_memory:
|
||||
; eax - number of bytes written
|
||||
pushad
|
||||
shl eax,8
|
||||
mov eax,[0x80000+eax+0xB8]
|
||||
mov eax,[0x80000+eax+APPDATA.dir_table]
|
||||
call MEM_Get_Linear_Address
|
||||
mov ebp,eax
|
||||
;ebp=linear address of page directory of other process.
|
||||
@@ -890,7 +939,7 @@ read_process_memory:
|
||||
; eax - number of bytes read.
|
||||
pushad
|
||||
shl eax,8
|
||||
mov eax,[0x80000+eax+0xB8]
|
||||
mov eax,[0x80000+eax+APPDATA.dir_table]
|
||||
call MEM_Get_Linear_Address
|
||||
mov ebp,eax
|
||||
add edx,std_application_base_address
|
||||
@@ -993,10 +1042,10 @@ check_process_region:
|
||||
test ecx,ecx
|
||||
jle .ok
|
||||
shl eax,5
|
||||
cmp word [0x3000+eax+0xa],0
|
||||
cmp word [0x3000+eax+TASKDATA.state],0
|
||||
jnz .failed
|
||||
shl eax,3
|
||||
mov eax,[0x80000+eax+0xb8]
|
||||
mov eax,[0x80000+eax+APPDATA.dir_table]
|
||||
test eax,eax
|
||||
jz .failed
|
||||
call MEM_Get_Linear_Address
|
||||
@@ -1065,8 +1114,8 @@ new_sys_ipc:
|
||||
shl edi,8
|
||||
add edi,0x80000
|
||||
cli
|
||||
mov [edi+0xA0],ebx ;set fields in extended information area
|
||||
mov [edi+0xA4],ecx
|
||||
mov [edi+APPDATA.ipc_start],ebx ;set fields in extended information area
|
||||
mov [edi+APPDATA.ipc_size],ecx
|
||||
sti
|
||||
mov [esp+36],dword 0 ;success
|
||||
ret
|
||||
@@ -1084,10 +1133,10 @@ new_sys_ipc:
|
||||
mov ebp,eax
|
||||
;ebp = slot of other process
|
||||
shl eax,8
|
||||
mov edi,[eax+0x80000+0xa0] ;is ipc area defined?
|
||||
mov edi,[eax+0x80000+APPDATA.ipc_start] ;is ipc area defined?
|
||||
test edi,edi
|
||||
jz .no_ipc_area
|
||||
mov esi,[eax+0x80000+0xa4] ;esi - size of buffer
|
||||
mov esi,[eax+0x80000+APPDATA.ipc_size] ;esi - size of buffer
|
||||
push dword -1 ;temp variable for read_process_memory
|
||||
mov ebx,esp
|
||||
push ecx
|
||||
@@ -1115,7 +1164,7 @@ new_sys_ipc:
|
||||
add edx,esi
|
||||
sub edx,4 ;move to beginning of place for our message
|
||||
mov eax,[second_base_address+0x3010]
|
||||
mov eax,[eax+0x4] ;eax - our PID
|
||||
mov eax,[eax+TASKDATA.pid] ;eax - our PID
|
||||
mov [esp+8],eax
|
||||
mov eax,ebp
|
||||
call write_process_memory ;write PID
|
||||
@@ -1135,7 +1184,7 @@ new_sys_ipc:
|
||||
;awake other process
|
||||
shl ebp,8
|
||||
mov eax,ebp
|
||||
or [eax+0x800A8],dword 0x40
|
||||
or [eax+0x80000+APPDATA.event_mask],dword 0x40
|
||||
|
||||
cmp dword [check_idle_semaphore],20
|
||||
jge .ipc_no_cis
|
||||
@@ -1203,6 +1252,7 @@ new_start_application_hd:
|
||||
call find_new_process_place ;find new process slot
|
||||
sti
|
||||
test eax,eax
|
||||
mov ecx, -0x20 ; too many processes
|
||||
jz .failed
|
||||
|
||||
;write application name
|
||||
@@ -1220,7 +1270,7 @@ new_start_application_hd:
|
||||
lea esi,[eax-11] ;last 11 bytes = application name
|
||||
mov edi,[new_process_place]
|
||||
shl edi,8
|
||||
add edi,0x80000
|
||||
add edi,0x80000+APPDATA.app_name
|
||||
mov ecx,11
|
||||
cld
|
||||
rep movsb ;copy name to extended information about process
|
||||
@@ -1231,11 +1281,14 @@ new_start_application_hd:
|
||||
mov ecx,1 ;read from first block
|
||||
mov edx,1 ;read 1 block
|
||||
call read_hd_file
|
||||
test eax,eax
|
||||
jnz .cleanfailed
|
||||
mov ecx, eax
|
||||
neg ecx
|
||||
jnz .cleanfailed
|
||||
|
||||
mov esi,[esp]
|
||||
;check menuet signature
|
||||
pop esi
|
||||
push esi
|
||||
;check menuet signature
|
||||
mov ecx, -0x1F ; not Menuet/Kolibri executable
|
||||
cmp [esi+1024+0],dword 'MENU' ;read_hd_file function write file to +1024 offset
|
||||
jnz .cleanfailed
|
||||
cmp [esi+1024+4],word 'ET'
|
||||
@@ -1246,10 +1299,11 @@ new_start_application_hd:
|
||||
cld
|
||||
rep movsd ;copy first block to 0x90000 address for get_app_params function
|
||||
call get_app_params
|
||||
test esi,esi
|
||||
jz .cleanfailed
|
||||
mov ecx, -0x1F ; not Menuet/Kolibri executable
|
||||
jc .cleanfailed
|
||||
|
||||
mov eax,[new_process_place]
|
||||
inc ecx ; -0x1E = no memory
|
||||
call create_app_cr3_table ;create page directory
|
||||
test eax,eax
|
||||
jz .cleanfailed_mem
|
||||
@@ -1262,6 +1316,7 @@ new_start_application_hd:
|
||||
shr ecx,12
|
||||
mov edx,eax ;edx - linear address of page directory
|
||||
call mem_alloc_specified_region ;allocate memory for application
|
||||
mov ecx, -0x1E ; no memory
|
||||
test eax,eax
|
||||
jz .cleanfailed_mem1
|
||||
|
||||
@@ -1343,30 +1398,254 @@ new_start_application_hd:
|
||||
;so free directory entry
|
||||
mov eax,[new_process_place]
|
||||
shl eax,8
|
||||
mov eax,[0x80000+eax+0xB8]
|
||||
mov eax,[0x80000+eax+APPDATA.dir_table]
|
||||
call MEM_Free_Page
|
||||
.cleanfailed_mem:
|
||||
;there is no mem for directory entry, display message.
|
||||
mov esi,start_not_enough_memory
|
||||
call sys_msg_board_str
|
||||
.cleanfailed: ;clean process name
|
||||
push ecx
|
||||
;can't read file, clean process name.
|
||||
;this avoid problems with panel application.
|
||||
mov edi,[new_process_place]
|
||||
shl edi,8
|
||||
add edi,0x80000
|
||||
add edi,0x80000+APPDATA.app_name
|
||||
mov ecx,11
|
||||
mov eax,' '
|
||||
cld
|
||||
rep stosb
|
||||
rep stosb
|
||||
pop eax
|
||||
.failed:
|
||||
;no more slots
|
||||
add esp,16
|
||||
popad
|
||||
mov eax,-1
|
||||
mov [esp+1Ch], eax
|
||||
popad
|
||||
mov [application_table_status],0
|
||||
sti
|
||||
ret
|
||||
end if
|
||||
|
||||
include 'debug.inc'
|
||||
; \begin{diamond}
|
||||
include 'debug.inc'
|
||||
|
||||
fs_execute:
|
||||
; ebx - cmdline
|
||||
; edx - flags
|
||||
; ebp - full filename
|
||||
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
|
||||
pushad
|
||||
; check filename length - with terminating NULL must be no more than 1024 symbols
|
||||
mov edi, ebp
|
||||
mov ecx, 1024
|
||||
xor eax, eax
|
||||
repnz scasb
|
||||
jz @f
|
||||
popad
|
||||
mov eax, -ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
@@:
|
||||
|
||||
mov esi, new_process_loading
|
||||
call sys_msg_board_str ; write message to message board
|
||||
|
||||
; lock application_table_status mutex
|
||||
.table_status:
|
||||
cli
|
||||
cmp [application_table_status], 0
|
||||
jz .stf
|
||||
sti
|
||||
call change_task
|
||||
jmp .table_status
|
||||
.stf:
|
||||
call set_application_table_status
|
||||
push ebx ; save command line pointer for add_app_parameters
|
||||
|
||||
call find_new_process_place ; find new process slot
|
||||
call safe_sti
|
||||
test eax, eax
|
||||
mov ecx, -0x20 ; too many processes
|
||||
jz .failed
|
||||
|
||||
; write application name
|
||||
push edi
|
||||
mov ecx, edi
|
||||
sub ecx, ebp
|
||||
mov [appl_path], ebp
|
||||
mov [appl_path_size], ecx
|
||||
dec edi
|
||||
std
|
||||
mov al, '/'
|
||||
repnz scasb
|
||||
cld
|
||||
jnz @f
|
||||
inc edi
|
||||
@@:
|
||||
inc edi
|
||||
; now edi points to name without path
|
||||
mov esi, edi
|
||||
mov ecx, 8 ; 8 chars for name
|
||||
mov edi, [new_process_place]
|
||||
shl edi, cl
|
||||
add edi, 0x80000+APPDATA.app_name
|
||||
.copy_process_name_loop:
|
||||
lodsb
|
||||
cmp al, '.'
|
||||
jz .copy_process_name_done
|
||||
test al, al
|
||||
jz .copy_process_name_done
|
||||
stosb
|
||||
loop .copy_process_name_loop
|
||||
.copy_process_name_done:
|
||||
mov al, ' '
|
||||
rep stosb
|
||||
pop eax
|
||||
mov cl, 3 ; 3 chars for extension
|
||||
dec esi
|
||||
@@:
|
||||
dec eax
|
||||
cmp eax, esi
|
||||
jbe .copy_process_ext_done
|
||||
cmp byte [eax], '.'
|
||||
jnz @b
|
||||
lea esi, [eax+1]
|
||||
.copy_process_ext_loop:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .copy_process_ext_done
|
||||
stosb
|
||||
loop .copy_process_ext_loop
|
||||
.copy_process_ext_done:
|
||||
mov al, ' '
|
||||
rep stosb
|
||||
|
||||
; read header
|
||||
lea eax, [esp+8+36]
|
||||
mov edi, 0x90000
|
||||
call dword [eax-4]
|
||||
mov ecx, eax
|
||||
neg ecx
|
||||
jnz .cleanfailed
|
||||
; check menuet signature
|
||||
mov ecx, -0x1F
|
||||
cmp dword [0x90000], 'MENU'
|
||||
jnz .cleanfailed
|
||||
cmp word [0x90004], 'ET'
|
||||
jnz .cleanfailed
|
||||
call get_app_params
|
||||
mov ecx, -0x1F
|
||||
jc .cleanfailed
|
||||
; sanity check - because we will load all file,
|
||||
; file size must be not greater than memory size
|
||||
mov eax, [esp+8+36]
|
||||
cmp [app_mem], eax
|
||||
jb .cleanfailed
|
||||
|
||||
mov eax, [new_process_place]
|
||||
inc ecx ; -0x1E = no memory
|
||||
call create_app_cr3_table
|
||||
test eax, eax
|
||||
jz .cleanfailed_mem
|
||||
|
||||
call MEM_Get_Linear_Address
|
||||
|
||||
mov ebx, std_application_base_address
|
||||
mov ecx, [app_mem]
|
||||
add ecx, 4095
|
||||
shr ecx, 12
|
||||
mov edx, eax ; edx - linear address of page directory
|
||||
call mem_alloc_specified_region
|
||||
mov ecx, -0x1E ; no memory
|
||||
test eax, eax
|
||||
jz .cleanfailed_mem1
|
||||
|
||||
add edx, std_application_base_address shr 20
|
||||
mov eax, [edx]
|
||||
and eax, not 4095
|
||||
call MEM_Get_Linear_Address
|
||||
push edx ; save pointer to first page table
|
||||
mov edx, eax
|
||||
; read file
|
||||
; first block is already read to 0x90000
|
||||
mov eax, [edx]
|
||||
and eax, not 0xFFF
|
||||
call MEM_Get_Linear_Address
|
||||
mov esi, 0x90000
|
||||
mov edi, eax
|
||||
mov ecx, 512/4
|
||||
rep movsd
|
||||
sub edi, eax
|
||||
.loop1:
|
||||
; [esp] = pointer to current page directory entry
|
||||
; edx = pointer to current page table
|
||||
; edi = offset in page
|
||||
mov eax, [edx]
|
||||
and eax, not 0xFFF
|
||||
call MEM_Get_Linear_Address
|
||||
push edi
|
||||
add edi, eax
|
||||
lea eax, [esp+8+36+8]
|
||||
call dword [eax-4]
|
||||
pop edi
|
||||
test eax, eax
|
||||
jnz .endloop1
|
||||
add edi, 512 ; new offset
|
||||
cmp edi, 4096
|
||||
jb .loop1
|
||||
xor edi, edi
|
||||
add edx, 4 ; go to next page
|
||||
test edx, 4096-1
|
||||
jnz .loop1
|
||||
pop eax
|
||||
add eax, 4 ; go to next directory entry
|
||||
push eax
|
||||
mov eax, [eax]
|
||||
and eax, not 0xFFF
|
||||
call MEM_Get_Linear_Address
|
||||
mov edx, eax
|
||||
jmp .loop1
|
||||
.endloop1:
|
||||
pop edx
|
||||
cmp eax, 6
|
||||
jnz .cleanfailed_mem2
|
||||
call new_start_application_fl.add_app_parameters
|
||||
mov [esp+28], eax
|
||||
popad
|
||||
ret
|
||||
|
||||
.cleanfailed_mem2:
|
||||
; file read error; free all allocated mem
|
||||
mov ecx, eax
|
||||
neg ecx
|
||||
mov eax, [new_process_place]
|
||||
call dispose_app_cr3_table
|
||||
jmp .cleanfailed
|
||||
.cleanfailed_mem1:
|
||||
; there is mem for directory entry, but there is no mem for pages
|
||||
; so free directory entry
|
||||
mov eax, [new_process_place]
|
||||
shl eax, 8
|
||||
mov eax, [0x80000+eax+0xB8]
|
||||
call MEM_Free_Page
|
||||
.cleanfailed_mem:
|
||||
; there is no mem for directory entry, display message
|
||||
mov esi, start_not_enough_memory
|
||||
call sys_msg_board_str
|
||||
.cleanfailed:
|
||||
push ecx
|
||||
; clean process name, this avoid problems with @panel
|
||||
mov edi, [new_process_place]
|
||||
shl edi, 8
|
||||
add edi, 0x80000+APPDATA.app_name
|
||||
mov ecx, 11
|
||||
mov al, ' '
|
||||
rep stosb
|
||||
pop eax
|
||||
.failed:
|
||||
pop ebx
|
||||
mov [esp+28], eax
|
||||
popad
|
||||
mov [application_table_status], 0
|
||||
call safe_sti
|
||||
ret
|
||||
; \end{diamond}
|
||||
@@ -95,7 +95,7 @@ Allocate_Physical_Block:
|
||||
mov eax,[esi+physical_mem_block.start]
|
||||
mov [esp+28],eax
|
||||
mov eax,[0x3010]
|
||||
mov eax,[eax+0x4]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
mov [esi+physical_mem_block.flags],eax
|
||||
popad
|
||||
ret
|
||||
@@ -105,7 +105,7 @@ Allocate_Physical_Block:
|
||||
mov eax,[esi+physical_mem_block.start]
|
||||
mov [esp+28],eax
|
||||
mov ecx,[0x3010]
|
||||
mov ecx,[ecx+0x4]
|
||||
mov ecx,[ecx+TASKDATA.pid]
|
||||
mov [esi+physical_mem_block.flags],ecx
|
||||
mov ecx,[esi+physical_mem_block.size]
|
||||
mov [esi+physical_mem_block.size],ebx
|
||||
@@ -190,6 +190,7 @@ isys_set_buffer: ;for using in kernel
|
||||
lea edi,[ebx+second_base_address]
|
||||
mov esi,ecx
|
||||
mov ecx,edx
|
||||
cld
|
||||
rep movsb
|
||||
ret
|
||||
sys_get_buffer:
|
||||
@@ -202,6 +203,7 @@ isys_get_buffer: ;for using in kernel
|
||||
mov edi,ecx
|
||||
lea esi,[ebx+second_base_address]
|
||||
mov ecx,edx
|
||||
cld
|
||||
rep movsb
|
||||
ret
|
||||
sys_internal_services:
|
||||
191
kernel/branches/gfx_kernel/core/sched.inc
Normal file
191
kernel/branches/gfx_kernel/core/sched.inc
Normal file
@@ -0,0 +1,191 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
align 32
|
||||
irq0:
|
||||
save_ring3_context
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
inc dword [timer_ticks]
|
||||
|
||||
mov eax, [timer_ticks]
|
||||
call playNote ; <<<--- Speaker driver
|
||||
|
||||
cmp eax,[next_usage_update]
|
||||
jb .nocounter
|
||||
add eax,100
|
||||
mov [next_usage_update],eax
|
||||
call updatecputimes
|
||||
.nocounter:
|
||||
|
||||
cmp [0xffff], byte 1
|
||||
jne .change_task
|
||||
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
mov [0xffff], byte 0
|
||||
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
.change_task:
|
||||
call update_counters
|
||||
|
||||
call find_next_task
|
||||
mov ecx, eax
|
||||
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
test ecx, ecx ; if there is only one running process
|
||||
jnz .return
|
||||
|
||||
call do_change_task
|
||||
|
||||
.return:
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
|
||||
align 4
|
||||
change_task:
|
||||
|
||||
pushfd
|
||||
cli
|
||||
pushad
|
||||
|
||||
call update_counters
|
||||
call find_next_task
|
||||
test eax, eax ; the same task -> skip switch
|
||||
jnz .return
|
||||
|
||||
mov [0xffff],byte 1
|
||||
call do_change_task
|
||||
|
||||
.return:
|
||||
popad
|
||||
popfd
|
||||
|
||||
ret
|
||||
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
far_jump:
|
||||
.offs dd ?
|
||||
.sel dw ?
|
||||
context_counter dd ? ;noname & halyavin
|
||||
next_usage_update dd ?
|
||||
timer_ticks dd ?
|
||||
prev_slot dd ?
|
||||
event_sched dd ?
|
||||
endg
|
||||
|
||||
|
||||
update_counters:
|
||||
mov edi, [0x3010]
|
||||
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
|
||||
call _rdtsc
|
||||
sub eax, ebx
|
||||
add eax, [edi+TASKDATA.counter_sum] ; counter sum
|
||||
mov [edi+TASKDATA.counter_sum], eax
|
||||
ret
|
||||
|
||||
|
||||
; Find next task to execute
|
||||
; result: ebx = number of the selected task
|
||||
; eax = 1 if the task is the same
|
||||
; edi = address of the data for the task in ebx
|
||||
; [0x3000] = ebx and [0x3010] = edi
|
||||
; corrupts other regs
|
||||
find_next_task:
|
||||
mov ebx, [0x3000]
|
||||
mov edi, [0x3010]
|
||||
mov [prev_slot], ebx
|
||||
|
||||
.waiting_for_termination:
|
||||
.waiting_for_reuse:
|
||||
.waiting_for_event:
|
||||
.suspended:
|
||||
cmp ebx, [0x3004]
|
||||
jb @f
|
||||
mov edi, 0x3000
|
||||
xor ebx, ebx
|
||||
@@:
|
||||
|
||||
add edi,0x20
|
||||
inc ebx
|
||||
|
||||
mov al, byte [edi+TASKDATA.state]
|
||||
test al, al
|
||||
jz .found
|
||||
cmp al, 1
|
||||
jz .suspended
|
||||
cmp al, 2
|
||||
jz .suspended
|
||||
cmp al, 3
|
||||
je .waiting_for_termination
|
||||
cmp al, 4
|
||||
je .waiting_for_termination
|
||||
cmp al, 9
|
||||
je .waiting_for_reuse
|
||||
|
||||
mov [0x3000],ebx
|
||||
mov [0x3010],edi
|
||||
|
||||
cmp al, 5
|
||||
jne .noevents
|
||||
call get_event_for_app
|
||||
test eax, eax
|
||||
jz .waiting_for_event
|
||||
mov [event_sched], eax
|
||||
mov [edi+TASKDATA.state], byte 0
|
||||
.noevents:
|
||||
.found:
|
||||
mov [0x3000],ebx
|
||||
mov [0x3010],edi
|
||||
call _rdtsc
|
||||
mov [edi+TASKDATA.counter_add],eax
|
||||
|
||||
xor eax, eax
|
||||
cmp ebx, [prev_slot]
|
||||
sete al
|
||||
ret
|
||||
|
||||
; in: ebx = TSS selector index
|
||||
do_change_task:
|
||||
shl ebx, 3
|
||||
xor eax, eax
|
||||
add ebx, tss0
|
||||
mov [far_jump.sel], bx ; selector
|
||||
mov [far_jump.offs], eax ; offset
|
||||
jmp pword [far_jump]
|
||||
inc [context_counter] ;noname & halyavin
|
||||
ret
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
updatecputimes:
|
||||
|
||||
mov eax,[idleuse]
|
||||
mov [idleusesec],eax
|
||||
mov [idleuse],dword 0
|
||||
mov ecx, [0x3004]
|
||||
mov edi, 0x3020
|
||||
.newupdate:
|
||||
mov ebx,[edi+TASKDATA.counter_sum]
|
||||
mov [edi+TASKDATA.cpu_usage],ebx
|
||||
mov [edi+TASKDATA.counter_sum],dword 0
|
||||
add edi,0x20
|
||||
dec ecx
|
||||
jnz .newupdate
|
||||
|
||||
ret
|
||||
111
kernel/branches/gfx_kernel/core/sync.inc
Normal file
111
kernel/branches/gfx_kernel/core/sync.inc
Normal file
@@ -0,0 +1,111 @@
|
||||
if ~defined sync_inc
|
||||
sync_inc_fix:
|
||||
sync_inc fix sync_inc_fix
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;Synhronization for MenuetOS. ;;
|
||||
;;Author: Halyavin Andrey, halyavin@land.ru ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;simplest mutex.
|
||||
macro SimpleMutex name
|
||||
{
|
||||
; iglobal
|
||||
name dd 0
|
||||
name#.type = 1
|
||||
; endg
|
||||
}
|
||||
macro WaitSimpleMutex name
|
||||
{
|
||||
local start_wait,ok
|
||||
start_wait=$
|
||||
cli
|
||||
cmp [name],dword 0
|
||||
jz ok
|
||||
sti
|
||||
call change_task
|
||||
jmp start_wait
|
||||
ok=$
|
||||
push eax
|
||||
mov eax,dword [0x3010+second_base_address]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
mov [name],eax
|
||||
pop eax
|
||||
sti
|
||||
}
|
||||
macro ReleaseSimpleMutex name
|
||||
{
|
||||
mov [name],dword 0
|
||||
}
|
||||
macro TryWaitSimpleMutex name ;result in eax and in flags
|
||||
{
|
||||
local ok,try_end
|
||||
cmp [name],dword 0
|
||||
jz ok
|
||||
xor eax,eax
|
||||
jmp try_end
|
||||
ok=$
|
||||
xor eax,eax
|
||||
inc eax
|
||||
try_end=$
|
||||
}
|
||||
macro SimpleCriticalSection name
|
||||
{
|
||||
; iglobal
|
||||
name dd 0
|
||||
dd 0
|
||||
name#.type=2
|
||||
; endg
|
||||
}
|
||||
macro WaitSimpleCriticalSection name
|
||||
{
|
||||
local start_wait,first_wait,inc_counter,end_wait
|
||||
push eax
|
||||
mov eax,[0x3010+second_base_address]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
start_wait=$
|
||||
cli
|
||||
cmp [name],dword 0
|
||||
jz first_wait
|
||||
cmp [name],eax
|
||||
jz inc_counter
|
||||
sti
|
||||
call change_task
|
||||
jmp start_wait
|
||||
first_wait=$
|
||||
mov [name],eax
|
||||
mov [name+4],dword 1
|
||||
jmp end_wait
|
||||
inc_counter=$
|
||||
inc dword [name+4]
|
||||
end_wait=$
|
||||
sti
|
||||
pop eax
|
||||
}
|
||||
macro ReleaseSimpleCriticalSection name
|
||||
{
|
||||
local release_end
|
||||
dec dword [name+4]
|
||||
jnz release_end
|
||||
mov [name],dword 0
|
||||
release_end=$
|
||||
}
|
||||
macro TryWaitSimpleCriticalSection name ;result in eax and in flags
|
||||
{
|
||||
local ok,try_end
|
||||
mov eax,[0x3000+second_base_address]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
cmp [name],eax
|
||||
jz ok
|
||||
cmp [name],0
|
||||
jz ok
|
||||
xor eax,eax
|
||||
jmp try_end
|
||||
ok=$
|
||||
xor eax,eax
|
||||
inc eax
|
||||
try_end=$
|
||||
}
|
||||
_cli equ call MEM_HeapLock
|
||||
_sti equ call MEM_HeapUnLock
|
||||
end if
|
||||
|
||||
1027
kernel/branches/gfx_kernel/core/sys32.inc
Normal file
1027
kernel/branches/gfx_kernel/core/sys32.inc
Normal file
File diff suppressed because it is too large
Load Diff
151
kernel/branches/gfx_kernel/core/syscall.inc
Normal file
151
kernel/branches/gfx_kernel/core/syscall.inc
Normal file
@@ -0,0 +1,151 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSTEM CALL ENTRY ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
align 32
|
||||
i40:
|
||||
push ds es
|
||||
pushad
|
||||
cld
|
||||
|
||||
mov ax,word os_data
|
||||
mov ds,ax
|
||||
mov es,ax
|
||||
|
||||
; for syscall trace function
|
||||
call save_registers
|
||||
|
||||
; load all registers in crossed order
|
||||
mov edi,[esp+28] ; eax
|
||||
mov eax,[esp+16] ; ebx
|
||||
mov ebx,[esp+24] ; ecx
|
||||
mov ecx,[esp+20] ; edx
|
||||
mov edx,[esp+4] ; esi
|
||||
mov esi,[esp+0] ; edi
|
||||
|
||||
; enable interupts - a task switch or an IRQ _CAN_ interrupt i40 handler
|
||||
sti
|
||||
push eax
|
||||
and edi,0xff
|
||||
call dword [servetable+edi*4]
|
||||
pop eax
|
||||
cli
|
||||
|
||||
popad
|
||||
pop es ds
|
||||
iretd
|
||||
|
||||
align 4
|
||||
save_registers:
|
||||
mov esi, [0x3010]
|
||||
mov eax, [esi+TASKDATA.pid] ; load PID
|
||||
lea esi, [esp+4]
|
||||
inc [save_syscall_count]
|
||||
mov edi,[save_syscall_count]
|
||||
and edi,0xF
|
||||
shl edi,6
|
||||
add edi,save_syscall_data+32
|
||||
mov [edi-32],eax
|
||||
mov ecx,32 / 4
|
||||
cld
|
||||
rep movsd
|
||||
ret
|
||||
|
||||
uglobal
|
||||
save_syscall_count dd 0x0
|
||||
endg
|
||||
|
||||
label save_syscall_data dword at 0x5000
|
||||
|
||||
|
||||
iglobal
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SYSTEM FUNCTIONS TABLE ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
align 4
|
||||
servetable:
|
||||
|
||||
dd sys_drawwindow ; 0-DrawWindow
|
||||
dd syscall_setpixel ; 1-SetPixel
|
||||
dd sys_getkey ; 2-GetKey
|
||||
dd sys_clock ; 3-GetTime
|
||||
dd syscall_writetext ; 4-WriteText
|
||||
dd delay_hs ; 5-DelayHs
|
||||
dd syscall_openramdiskfile ; 6-OpenRamdiskFile
|
||||
dd syscall_putimage ; 7-PutImage
|
||||
dd sys_button ; 8-DefineButton
|
||||
dd sys_cpuusage ; 9-GetProcessInfo
|
||||
dd sys_waitforevent ; 10-WaitForEvent
|
||||
dd sys_getevent ; 11-CheckForEvent
|
||||
dd sys_redrawstat ; 12-BeginDraw and EndDraw
|
||||
dd syscall_drawrect ; 13-DrawRect
|
||||
dd syscall_getscreensize ; 14-GetScreenSize
|
||||
dd sys_background ; 15-bgr
|
||||
dd sys_cachetodiskette ; 16-FlushFloppyCache
|
||||
dd sys_getbutton ; 17-GetButton
|
||||
dd sys_system ; 18-System Services
|
||||
dd syscall_startapp ; 19-StartApp
|
||||
dd sys_midi ; 20-ResetMidi and OutputMidi
|
||||
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
|
||||
dd sys_settime ; 22-setting date,time,clock and alarm-clock
|
||||
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
|
||||
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist
|
||||
dd sys_sb16 ; 25-SetSb16
|
||||
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
|
||||
dd sys_wss ; 27-SetWssMainVol and SetWssCdVol
|
||||
dd sys_sb16II ; 28-SetSb16
|
||||
dd sys_date ; 29-GetDate
|
||||
; dd syscall_readhd ; 30-ReadHd - obsolete <diamond>
|
||||
dd undefined_syscall ; 30-reserved
|
||||
; dd syscall_starthdapp ; 31-StartHdApp - obsolete <diamond>
|
||||
dd undefined_syscall ; 31-reserved
|
||||
dd syscall_delramdiskfile ; 32-DelRamdiskFile
|
||||
dd syscall_writeramdiskfile; 33-WriteRamdiskFile
|
||||
; dd read_floppy_file ; 34-ReadFloppyDrive - obsolete <diamond>
|
||||
dd undefined_syscall ; 34-reserved
|
||||
dd syscall_getpixel ; 35-GetPixel
|
||||
dd syscall_readstring ; 36-ReadString (not yet ready)
|
||||
dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
|
||||
dd syscall_drawline ; 38-DrawLine
|
||||
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
|
||||
dd set_app_param ; 40-WantEvents
|
||||
dd syscall_getirqowner ; 41-GetIrqOwner
|
||||
dd get_irq_data ; 42-ReadIrqData
|
||||
dd sys_outport ; 43-SendDeviceData
|
||||
dd sys_programirq ; 44-ProgramIrqs
|
||||
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
|
||||
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
|
||||
dd display_number ; 47-WriteNum
|
||||
dd display_settings ; 48-SetRedrawType and SetButtonType
|
||||
dd sys_apm ; 49-Advanced Power Management (APM)
|
||||
dd random_shaped_window ; 50-Window shape & scale
|
||||
dd syscall_threads ; 51-Threads
|
||||
dd stack_driver_stat ; 52-Stack driver status
|
||||
dd socket ; 53-Socket interface
|
||||
dd user_events ; 54-User events
|
||||
dd sound_interface ; 55-Sound interface
|
||||
dd write_to_hd ; 56-Write a file to hd
|
||||
; dd delete_from_hd ; 57-Delete a file from hd - obsolete <diamond>
|
||||
dd undefined_syscall ; 57-reserved
|
||||
dd file_system ; 58-Common file system interface
|
||||
dd sys_trace ; 59-System call trace
|
||||
dd new_sys_ipc ; 60-Inter Process Communication
|
||||
dd sys_gs ; 61-Direct graphics access
|
||||
dd sys_pci ; 62-PCI functions
|
||||
dd sys_msg_board ; 63-System message board
|
||||
dd sys_resize_app_memory ; 64-Resize application memory usage
|
||||
dd undefined_syscall ; 65-UTF
|
||||
dd sys_process_def ; 66-Process definitions - keyboard
|
||||
dd sys_window_move ; 67-Window move or resize
|
||||
dd sys_internal_services ; 68-Some internal services
|
||||
dd sys_debug_services ; 69-Debug
|
||||
dd file_system_lfn ; 70-Common file system interface, version 2
|
||||
dd syscall_windowsettings ; 71-Window settings
|
||||
|
||||
times 255 - ( ($-servetable) /4 ) dd undefined_syscall
|
||||
|
||||
dd sys_end ; -1-end application
|
||||
endg
|
||||
135
kernel/branches/gfx_kernel/detect/commouse.inc
Normal file
135
kernel/branches/gfx_kernel/detect/commouse.inc
Normal file
@@ -0,0 +1,135 @@
|
||||
;**************************************************
|
||||
;* ПОИСК МЫШИ ПО ПОСЛЕДОВАТЕЛЬНЫМ ПОРТАМ *
|
||||
;* Процедура подготавливает глобальные переменные *
|
||||
;* COMPortNum и COMPortBaseAddr для подпрограммы *
|
||||
;* установки обработчика прерывания *
|
||||
;**************************************************
|
||||
; Автор исходного текста Кулаков Владимир Геннадьевич.
|
||||
; Адаптация и доработка Mario79
|
||||
|
||||
Detect_COM_Mouse:
|
||||
pusha
|
||||
call MSMouseSearch
|
||||
cmp AL,'M'
|
||||
jne @f
|
||||
mov [com1_mouse_detected],1
|
||||
pusha
|
||||
|
||||
mov eax,4
|
||||
shl eax,2
|
||||
mov [irq_owner+eax],byte 1
|
||||
|
||||
inc dword [0x2d0000]
|
||||
mov edi,[0x2d0000]
|
||||
shl edi,4
|
||||
mov [0x2d0000+edi+0],dword 1
|
||||
mov [0x2d0000+edi+4],dword 0x3f0
|
||||
mov [0x2d0000+edi+8],dword 0x3ff
|
||||
|
||||
popa
|
||||
mov esi,boot_setmouse_type+22
|
||||
call boot_log
|
||||
@@:
|
||||
sub [COMPortBaseAddr],100h
|
||||
call MSMouseSearch
|
||||
cmp AL,'M'
|
||||
jne @f
|
||||
mov [com2_mouse_detected],1
|
||||
pusha
|
||||
|
||||
mov eax,3
|
||||
shl eax,2
|
||||
mov [irq_owner+eax],byte 1
|
||||
|
||||
inc dword [0x2d0000]
|
||||
mov edi,[0x2d0000]
|
||||
shl edi,4
|
||||
mov [0x2d0000+edi+0],dword 1
|
||||
mov [0x2d0000+edi+4],dword 0x2f0
|
||||
mov [0x2d0000+edi+8],dword 0x2ff
|
||||
|
||||
popa
|
||||
mov esi,boot_setmouse_type+44
|
||||
call boot_log
|
||||
@@:
|
||||
popa
|
||||
jmp end_detecting_mouse
|
||||
|
||||
MSMouseSearch:
|
||||
; ПОИСК МЫШИ ЧЕРЕЗ COM-ПОРТЫ
|
||||
MouseSearch:
|
||||
; Устанавливаем скорость
|
||||
; приема/передачи 1200 бод
|
||||
mov DX,[COMPortBaseAddr]
|
||||
add DX,3
|
||||
in AL,DX
|
||||
or AL,80h ;установить бит DLAB
|
||||
out DX,AL
|
||||
mov DX,[COMPortBaseAddr]
|
||||
mov AL,60h ;1200 бод
|
||||
out DX,AL
|
||||
inc DX
|
||||
mov AL,0
|
||||
out DX,AL
|
||||
; Установить длину слова 7 бит, 1 стоповый бит,
|
||||
; четность не контролировать
|
||||
mov DX,[COMPortBaseAddr]
|
||||
add DX,3
|
||||
mov AL,00000010b
|
||||
out DX,AL
|
||||
; Запретить все прерывания
|
||||
mov DX,[COMPortBaseAddr]
|
||||
inc DX
|
||||
mov AL,0
|
||||
out DX,AL
|
||||
; Проверить, что устройство подключено и является
|
||||
; мышью типа MSMouse
|
||||
; Отключить питание мыши и прерывания
|
||||
mov DX,[COMPortBaseAddr]
|
||||
add DX,4 ;регистр управления модемом
|
||||
mov AL,0 ;сбросить DTR, RTS и OUT2
|
||||
out DX,AL
|
||||
; Ожидать 5 "тиков" (0,2 с)
|
||||
mov ecx,0xffff
|
||||
dT_1:
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
jne dT_1
|
||||
mov ecx,0xffff
|
||||
; Включить питание мыши
|
||||
mov AL,11b ;установить DTR и RTS
|
||||
out DX,AL
|
||||
; Очистить регистр данных
|
||||
mov DX,[COMPortBaseAddr]
|
||||
in AL,DX
|
||||
; Цикл опроса порта
|
||||
WaitData:
|
||||
; Ожидать еще 10 "тиков"
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je NoMouse
|
||||
; Проверить наличие идентификационного байта
|
||||
mov DX,[COMPortBaseAddr]
|
||||
add DX,5
|
||||
in AL,DX
|
||||
test AL,1 ;Данные готовы?
|
||||
jz WaitData
|
||||
; Ввести данные
|
||||
mov DX,[COMPortBaseAddr]
|
||||
in AL,DX
|
||||
NoMouse:
|
||||
ret
|
||||
|
||||
iglobal
|
||||
COMPortBaseAddr dw 3F8h
|
||||
;COMPortNum dw 0
|
||||
endg
|
||||
|
||||
iglobal
|
||||
boot_setmouse_type db 'Detected - PS2 mouse',0
|
||||
db 'Detected - COM1 mouse',0
|
||||
db 'Detected - COM2 mouse',0
|
||||
endg
|
||||
|
||||
end_detecting_mouse:
|
||||
|
||||
20
kernel/branches/gfx_kernel/detect/dev_fd.inc
Normal file
20
kernel/branches/gfx_kernel/detect/dev_fd.inc
Normal file
@@ -0,0 +1,20 @@
|
||||
;***************************************************
|
||||
; предварительная очистка области таблицы
|
||||
; поиск и занесение в таблицу приводов FDD
|
||||
; автор Mario79
|
||||
;***************************************************
|
||||
xor eax,eax
|
||||
mov edi,0x40000
|
||||
mov ecx,16384
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov al,0x10
|
||||
out 0x70,al
|
||||
mov cx,0xff
|
||||
wait_cmos:
|
||||
dec cx
|
||||
cmp cx,0
|
||||
jne wait_cmos
|
||||
in al,0x71
|
||||
mov [0x40000],al
|
||||
374
kernel/branches/gfx_kernel/detect/dev_hdcd.inc
Normal file
374
kernel/branches/gfx_kernel/detect/dev_hdcd.inc
Normal file
@@ -0,0 +1,374 @@
|
||||
;******************************************************
|
||||
; поиск приводов HDD и CD
|
||||
; автор исходного текста Кулаков Владимир Геннадьевич.
|
||||
; адаптация и доработка Mario79
|
||||
;******************************************************
|
||||
|
||||
;****************************************************
|
||||
;* ПОИСК HDD и CD *
|
||||
;****************************************************
|
||||
FindHDD:
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
; mov ax,[Sector512+176]
|
||||
; mov [0x40006],ax
|
||||
; mov ax,[Sector512+126]
|
||||
; mov [0x40008],ax
|
||||
; mov ax,[Sector512+128]
|
||||
; mov [0x40008],ax
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_3
|
||||
; mov al,[Sector512+176]
|
||||
; mov [0x40007],al
|
||||
inc [ChannelNumber]
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
; mov al,[Sector512+176]
|
||||
; mov [0x40008],al
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_1
|
||||
; mov al,[Sector512+176]
|
||||
; mov [0x40009],al
|
||||
|
||||
jmp EndFindHDD
|
||||
|
||||
FindHDD_1:
|
||||
call ReadHDD_ID
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2
|
||||
cmp [Sector512+6],word 16
|
||||
ja FindHDD_2
|
||||
cmp [Sector512+12],word 255
|
||||
ja FindHDD_2
|
||||
inc byte [0x40001]
|
||||
jmp FindHDD_2_2
|
||||
FindHDD_2:
|
||||
call DeviceReset
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2_2
|
||||
call ReadCD_ID
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2_2
|
||||
inc byte [0x40001]
|
||||
inc byte [0x40001]
|
||||
FindHDD_2_2:
|
||||
ret
|
||||
|
||||
FindHDD_3:
|
||||
call FindHDD_1
|
||||
shl byte [0x40001],2
|
||||
ret
|
||||
|
||||
|
||||
; Адрес считываемого сектора в режиме LBA
|
||||
SectorAddress DD ?
|
||||
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска на канале (0 или 1). *
|
||||
;* Идентификационный блок данных считывается *
|
||||
;* в массив Sector512. *
|
||||
;*************************************************
|
||||
ReadHDD_ID:
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0ECh
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End ;закончить, сохранив код ошибки
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;адрес регистра состояния
|
||||
mov ecx,0xffff
|
||||
@@WaitCompleet:
|
||||
; Проверить время выполнения команды
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Error1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Error6
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;регистр данных
|
||||
mov CX,256 ;число считываемых слов
|
||||
rep insw ;принять блок данных
|
||||
jmp @@End
|
||||
; Записать код ошибки
|
||||
@@Error1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End
|
||||
@@Error6:
|
||||
mov [DevErrorCode],6
|
||||
@@End: ret
|
||||
|
||||
|
||||
|
||||
; Стандартные базовые адреса каналов 1 и 2
|
||||
StandardATABases DW 1F0h, 170h
|
||||
; Номер канала
|
||||
ChannelNumber DW ?
|
||||
; Номер диска
|
||||
DiskNumber DB ?
|
||||
; Базовый адрес группы портов контроллера ATA
|
||||
ATABasePortAddr DW ?
|
||||
; Параметры ATA-команды
|
||||
ATAFeatures DB ? ;особенности
|
||||
ATASectorCount DB ? ;количество обрабатываемых секторов
|
||||
ATASectorNumber DB ? ;номер начального сектора
|
||||
ATACylinder DW ? ;номер начального цилиндра
|
||||
ATAHead DB ? ;номер начальной головки
|
||||
ATAAddressMode DB ? ;режим адресации (0 - CHS, 1 - LBA)
|
||||
ATACommand DB ? ;код команды, подлежащей выполнению
|
||||
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
|
||||
; интервал ожидания, 2 - неверный код режима адресации,
|
||||
; 3 - неверный номер канала, 4 - неверный номер диска,
|
||||
; 5 - неверный номер головки, 6 - ошибка при выполнении
|
||||
; команды)
|
||||
DevErrorCode DB ?
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска (0 или 1); *
|
||||
;* ATAFeatures - "особенности"; *
|
||||
;* ATASectorCount - количество секторов; *
|
||||
;* ATASectorNumber - номер начального сектора; *
|
||||
;* ATACylinder - номер начального цилиндра; *
|
||||
;* ATAHead - номер начальной головки; *
|
||||
;* ATAAddressMode - режим адресации (0-CHS, 1-LBA); *
|
||||
;* ATACommand - код команды. *
|
||||
;* После успешного выполнения функции: *
|
||||
;* в ATABasePortAddr - базовый адрес HDD; *
|
||||
;* в DevErrorCode - ноль. *
|
||||
;* При возникновении ошибки в DevErrorCode будет *
|
||||
;* возвращен код ошибки. *
|
||||
;****************************************************
|
||||
SendCommandToHDD:
|
||||
; Проверить значение кода режима
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3
|
||||
cmp BX,2
|
||||
ja @@Err3
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Выбрать нужный диск
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;адрес регистра головок
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;проверить номера диска
|
||||
ja @@Err4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Ожидать, пока диск не будет готов
|
||||
inc DX
|
||||
mov ecx,0xfff
|
||||
; mov eax,[timer_ticks]
|
||||
; mov [TickCounter_1],eax
|
||||
@@WaitHDReady:
|
||||
; Проверить время ожидания
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1
|
||||
; mov eax,[timer_ticks]
|
||||
; sub eax,[TickCounter_1]
|
||||
; cmp eax,300 ;ожидать 300 тиков
|
||||
; ja @@Err1 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояния
|
||||
in AL,DX
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady
|
||||
; Проверить состояние сигнала DRQ
|
||||
test AL,08h
|
||||
jnz @@WaitHDReady
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
inc DX ;регистр "особенностей"
|
||||
mov AL,[ATAFeatures]
|
||||
out DX,AL
|
||||
inc DX ;счетчик секторов
|
||||
mov AL,[ATASectorCount]
|
||||
out DX,AL
|
||||
inc DX ;регистр номера сектора
|
||||
mov AL,[ATASectorNumber]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (младший байт)
|
||||
mov AX,[ATACylinder]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (старший байт)
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
inc DX ;номер головки/номер диска
|
||||
mov AL,[DiskNumber]
|
||||
shl AL,4
|
||||
cmp [ATAHead],0Fh ;проверить номер головки
|
||||
ja @@Err5
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
; Послать команду
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;регистр команд
|
||||
out DX,AL
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_2
|
||||
; Записать код ошибки
|
||||
@@Err1: mov [DevErrorCode],1
|
||||
jmp @@End_2
|
||||
@@Err2: mov [DevErrorCode],2
|
||||
jmp @@End_2
|
||||
@@Err3: mov [DevErrorCode],3
|
||||
jmp @@End_2
|
||||
@@Err4: mov [DevErrorCode],4
|
||||
jmp @@End_2
|
||||
@@Err5: mov [DevErrorCode],5
|
||||
; Завершение работы программы
|
||||
@@End_2:
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;* Идентификационный блок данных считывается *
|
||||
;* в массив Sector512. *
|
||||
;*************************************************
|
||||
ReadCD_ID:
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A1h
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End_1 ;закончить, сохранив код ошибки
|
||||
; Ожидать готовность данных HDD
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
mov ecx,0xffff
|
||||
@@WaitCompleet_1:
|
||||
; Проверить время
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Error1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet_1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Error6_1
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet_1
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;порт 1x0h
|
||||
mov CX,256 ;число считываемых слов
|
||||
rep insw
|
||||
jmp @@End_1
|
||||
; Записать код ошибки
|
||||
@@Error1_1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_1
|
||||
@@Error6_1:
|
||||
mov [DevErrorCode],6
|
||||
@@End_1:
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* СБРОС УСТРОЙСТВА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска (0 или 1). *
|
||||
;*************************************************
|
||||
DeviceReset:
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_2
|
||||
cmp BX,2
|
||||
ja @@Err3_2
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov DX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],DX
|
||||
; Выбрать нужный диск
|
||||
add DX,6 ;адрес регистра головок
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;проверить номера диска
|
||||
ja @@Err4_2
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Послать команду "Сброс"
|
||||
mov AL,08h
|
||||
inc DX ;регистр команд
|
||||
out DX,AL
|
||||
mov ecx,0xffff
|
||||
@@WaitHDReady_1:
|
||||
; Проверить время ожидания
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_2 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояния
|
||||
in AL,DX
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_1
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_3
|
||||
; Обработка ошибок
|
||||
@@Err1_2: mov [DevErrorCode],1
|
||||
jmp @@End_3
|
||||
@@Err3_2: mov [DevErrorCode],3
|
||||
jmp @@End_3
|
||||
@@Err4_2: mov [DevErrorCode],4
|
||||
; Записать код ошибки
|
||||
@@End_3:
|
||||
ret
|
||||
|
||||
EndFindHDD:
|
||||
|
||||
4
kernel/branches/gfx_kernel/detect/disks.inc
Normal file
4
kernel/branches/gfx_kernel/detect/disks.inc
Normal file
@@ -0,0 +1,4 @@
|
||||
include 'dev_fd.inc'
|
||||
include 'dev_hdcd.inc'
|
||||
include 'sear_par.inc'
|
||||
|
||||
69
kernel/branches/gfx_kernel/detect/ps2mouse.inc
Normal file
69
kernel/branches/gfx_kernel/detect/ps2mouse.inc
Normal file
@@ -0,0 +1,69 @@
|
||||
MouseSearch_PS2:
|
||||
|
||||
pusha
|
||||
mov bl, 0xAD
|
||||
call kb_cmd
|
||||
|
||||
mov bl,0xa8 ; enable mouse cmd
|
||||
call kb_cmd
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
|
||||
mov bl,0xd4 ; for mouse
|
||||
call kb_cmd
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
mov al,0xeb ;
|
||||
call kb_write
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
call kb_read ; Acknowledge
|
||||
call kb_read
|
||||
mov [ps2_mouse_detected],0
|
||||
test al,18h
|
||||
jz @f
|
||||
mov [ps2_mouse_detected],1
|
||||
@@:
|
||||
call kb_read ;
|
||||
call kb_read ;
|
||||
|
||||
mov bl,0x20 ; get command byte
|
||||
call kb_cmd
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
call kb_read
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
or al,3 ; enable interrupt
|
||||
mov bl,0x60 ; write command
|
||||
push eax
|
||||
call kb_cmd
|
||||
pop eax
|
||||
call kb_write
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
|
||||
mov bl,0xd4 ; for mouse
|
||||
call kb_cmd
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
mov al,0xf4 ; enable mouse device
|
||||
call kb_write
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
call kb_read ; read status return
|
||||
cmp ah,1
|
||||
je @@DataInputError
|
||||
cmp AL,0FAh
|
||||
jnz @@DataInputError ;íåò ïîäòâåðæäåíèÿ
|
||||
|
||||
@@DataInputError:
|
||||
cmp [ps2_mouse_detected],0
|
||||
je @f
|
||||
mov esi,boot_setmouse_type
|
||||
call boot_log
|
||||
@@:
|
||||
mov bl, 0xAE
|
||||
call kb_cmd
|
||||
popa
|
||||
|
||||
118
kernel/branches/gfx_kernel/detect/sear_par.inc
Normal file
118
kernel/branches/gfx_kernel/detect/sear_par.inc
Normal file
@@ -0,0 +1,118 @@
|
||||
;****************************************************
|
||||
; ïîèñê ëîãè÷åñêèõ äèñêîâ íà îáíàðóæåííûõ HDD
|
||||
; è çàíåñåíèå äàííûõ â îáëàñòü òàáëèöû
|
||||
; àâòîð Mario79
|
||||
;****************************************************
|
||||
mov [transfer_adress],0x4000a
|
||||
search_partitions_ide0:
|
||||
test [0x40001],byte 0x40
|
||||
jz search_partitions_ide1
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],1
|
||||
mov [fat32part],1
|
||||
search_partitions_ide0_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide1
|
||||
inc byte [0x40002]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide0_1
|
||||
|
||||
search_partitions_ide1:
|
||||
test [0x40001],byte 0x10
|
||||
jz search_partitions_ide2
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],2
|
||||
mov [fat32part],1
|
||||
search_partitions_ide1_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide2
|
||||
inc byte [0x40003]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide1_1
|
||||
|
||||
search_partitions_ide2:
|
||||
test [0x40001],byte 0x4
|
||||
jz search_partitions_ide3
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],3
|
||||
mov [fat32part],1
|
||||
search_partitions_ide2_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide3
|
||||
inc byte [0x40004]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide2_1
|
||||
|
||||
search_partitions_ide3:
|
||||
test [0x40001],byte 0x1
|
||||
jz end_search_partitions_ide
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],4
|
||||
mov [fat32part],1
|
||||
search_partitions_ide3_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne end_search_partitions_ide
|
||||
inc byte [0x40005]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide3_1
|
||||
|
||||
|
||||
partition_data_transfer:
|
||||
mov edi,[transfer_adress]
|
||||
mov esi,PARTITION_START
|
||||
xor ecx,ecx
|
||||
mov cx,69 ;100
|
||||
rep movsb
|
||||
ret
|
||||
transfer_adress dd 0
|
||||
partition_data_transfer_1:
|
||||
cli
|
||||
push edi
|
||||
mov edi,PARTITION_START
|
||||
mov esi,[transfer_adress]
|
||||
xor ecx,ecx
|
||||
mov cx,69 ;100
|
||||
rep movsb
|
||||
pop edi
|
||||
sti
|
||||
ret
|
||||
|
||||
end_search_partitions_ide:
|
||||
|
||||
;PARTITION_START dd 0x3f
|
||||
;PARTITION_END dd 0
|
||||
;SECTORS_PER_FAT dd 0x1f3a
|
||||
;NUMBER_OF_FATS dd 0x2
|
||||
;SECTORS_PER_CLUSTER dd 0x8
|
||||
;BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes
|
||||
;ROOT_CLUSTER dd 2 ; first rootdir cluster
|
||||
;FAT_START dd 0 ; start of fat table
|
||||
;ROOT_START dd 0 ; start of rootdir (only fat16)
|
||||
;ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16)
|
||||
;DATA_START dd 0 ; start of data area (=first cluster 2)
|
||||
;LAST_CLUSTER dd 0 ; last availabe cluster
|
||||
;ADR_FSINFO dd 0 ; used only by fat32
|
||||
;
|
||||
;fatRESERVED dd 0x0FFFFFF6
|
||||
;fatBAD dd 0x0FFFFFF7
|
||||
;fatEND dd 0x0FFFFFF8
|
||||
;fatMASK dd 0x0FFFFFFF
|
||||
;
|
||||
;fat_type db 0 ; 0=none, 16=fat16, 32=fat32
|
||||
|
||||
255
kernel/branches/gfx_kernel/docs/apm/README.TXT
Normal file
255
kernel/branches/gfx_kernel/docs/apm/README.TXT
Normal file
@@ -0,0 +1,255 @@
|
||||
Advanced Power Management
|
||||
|
||||
SYSTEM CALL
|
||||
|
||||
eax = 70
|
||||
dx = íîìåð ôóíêöèè APM BIOS (àíàëîãè÷åí ax â ðåàëüíîì ðåæèìå)
|
||||
îñòàëüíûå (bx, cx) ðåãèñòðû ïî ñïåöèôèêàöèè (ñì. apm.txt)
|
||||
ðåçóëüòàò : ïî ñïåöèôèêàöèè (âêëþ÷àÿ CF), ñòàðøàÿ ÷àñòü 32 áèòíûõ ðåãèñòðîâ íå îïðåäåëåíà
|
||||
|
||||
|
||||
MEMORY MAP
|
||||
|
||||
Boot:
|
||||
0x9040 - dword - entry point of APM BIOS
|
||||
0x9044 - word - version (BCD)
|
||||
0x9046 - word - flags
|
||||
|
||||
|
||||
ÈÇÌÅÍÅÍÈß
|
||||
|
||||
sys32.inc
|
||||
syscall.inc
|
||||
kernel.asm
|
||||
bootcode.inc
|
||||
|
||||
##############[core\sys32.inc]#####################
|
||||
|
||||
Òðè íîâûõ äåñêðèïòîðà
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
; GDT TABLE
|
||||
|
||||
gdts:
|
||||
|
||||
dw gdte-$-1
|
||||
dd gdts
|
||||
dw 0
|
||||
|
||||
int_code_l:
|
||||
os_code_l:
|
||||
|
||||
dw 0xffff
|
||||
dw 0x0000
|
||||
db 0x00
|
||||
dw 11011111b *256 +10011010b
|
||||
db 0x00
|
||||
|
||||
int_data_l:
|
||||
os_data_l:
|
||||
|
||||
dw 0xffff
|
||||
dw 0x0000
|
||||
db 0x00
|
||||
dw 11011111b *256 +10010010b
|
||||
db 0x00
|
||||
; --------------- APM ---------------------
|
||||
apm_code_32:
|
||||
dw 0x10 ; limit 64kb
|
||||
db 0, 0, 0
|
||||
dw 11011111b *256 +10011010b
|
||||
db 0x00
|
||||
apm_code_16:
|
||||
dw 0x10
|
||||
db 0, 0, 0
|
||||
dw 10011111b *256 +10011010b
|
||||
db 0x00
|
||||
apm_data_16:
|
||||
dw 0x10
|
||||
db 0, 0, 0
|
||||
dw 10011111b *256 +10010010b
|
||||
db 0x00
|
||||
; -----------------------------------------
|
||||
app_code_l:
|
||||
dw ((0x80000000-std_application_base_address) shr 12) and 0xffff
|
||||
dw 0
|
||||
db 0
|
||||
dw 11010000b*256+11111010b+256*((0x80000000-std_application_base_address) shr 28)
|
||||
db std_application_base_address shr 24
|
||||
|
||||
app_data_l:
|
||||
dw (0x80000000-std_application_base_address) shr 12 and 0xffff
|
||||
dw 0
|
||||
db 0
|
||||
dw 11010000b*256+11110010b+256*((0x80000000-std_application_base_address) shr 28)
|
||||
db std_application_base_address shr 24
|
||||
|
||||
graph_data_l:
|
||||
|
||||
dw 0x3ff
|
||||
dw 0x0000
|
||||
db 0x00
|
||||
dw 11010000b *256 +11110010b
|
||||
db 0x00
|
||||
|
||||
tss0_l:
|
||||
times (max_processes+10) dd 0,0
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
##############[core\syscall.inc]###################
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
|
||||
dd undefined_syscall ; 65-UTF
|
||||
dd sys_process_def ; 66-Process definitions - keyboard
|
||||
dd sys_window_move ; 67-Window move or resize
|
||||
dd sys_internal_services ; 68-Some internal services
|
||||
dd sys_debug_services ; 69-Debug
|
||||
dd sys_apm ; 70-APM
|
||||
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
##############[kernel.asm]#########################
|
||||
|
||||
|
||||
×àñòü 1 (ïîñëå ìåòêè "; SAVE REAL MODE VARIABLES"):
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
; SAVE REAL MODE VARIABLES
|
||||
|
||||
; --------------- APM ---------------------
|
||||
mov eax, [0x2f0000 + 0x9040] ; entry point
|
||||
mov dword[apm_entry], eax
|
||||
mov word [apm_entry + 4], apm_code_32 - gdts
|
||||
|
||||
mov eax, [0x2f0000 + 0x9044] ; version & flags
|
||||
mov [apm_vf], eax
|
||||
; -----------------------------------------
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
×àñòü 2 (ñèñòåìíûé âûçîâ, ðàñïîëîæåíèå íå êðèòè÷íî,
|
||||
ÿ ðàñïîëîæèë ïåðåä ìåòêîé "undefined_syscall:")
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
; --------------- APM ---------------------
|
||||
apm_entry dp 0
|
||||
apm_vf dd 0
|
||||
align 4
|
||||
sys_apm:
|
||||
cmp word [apm_vf], 0 ; Check APM BIOS enable
|
||||
jne @f
|
||||
or [esp + 40], byte 1 ; error
|
||||
mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported
|
||||
ret
|
||||
|
||||
@@: xchg eax, ecx
|
||||
xchg ebx, ecx
|
||||
|
||||
cmp al, 3
|
||||
ja @f
|
||||
and [esp + 40], byte 0xfe ; emulate func 0..3 as func 0
|
||||
mov eax, [apm_vf]
|
||||
mov [esp + 36], eax
|
||||
shr eax, 16
|
||||
mov [esp + 32], eax
|
||||
ret
|
||||
|
||||
@@: call pword [apm_entry] ; call APM BIOS
|
||||
mov [esp + 8 ], edi
|
||||
mov [esp + 12], esi
|
||||
mov [esp + 24], ebx
|
||||
mov [esp + 28], edx
|
||||
mov [esp + 32], ecx
|
||||
mov [esp + 36], eax
|
||||
setc al
|
||||
and [esp + 40], byte 0xfe
|
||||
or [esp + 40], al
|
||||
ret
|
||||
; -----------------------------------------
|
||||
|
||||
align 4
|
||||
|
||||
undefined_syscall: ; Undefined system call
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
##############[boot\bootcode.inc]##################
|
||||
|
||||
Ïåðåä ìåòêîé "; DISPLAY VESA INFORMATION"
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
; --------------- APM ---------------------
|
||||
push 0
|
||||
pop es
|
||||
mov word [es : 0x9044], 0 ; ver = 0.0 (APM not found)
|
||||
mov ax, 0x5300
|
||||
xor bx, bx
|
||||
int 0x15
|
||||
jc apm_end ; APM not found
|
||||
test cx, 2
|
||||
jz apm_end ; APM 32-bit protected-mode interface not supported
|
||||
mov [es : 0x9044], ax ; Save APM Version
|
||||
mov [es : 0x9046], cx ; Save APM flags
|
||||
|
||||
; Write APM ver ----
|
||||
jmp @f
|
||||
msg_apm:db ' APM x.x ', 0
|
||||
@@: and ax, 0xf0f
|
||||
add ax, '00'
|
||||
mov [msg_apm - 0x10000 + 5], ah
|
||||
mov [msg_apm - 0x10000 + 7], al
|
||||
_setcursor 0, 3
|
||||
mov si, msg_apm - 0x10000
|
||||
call printplain
|
||||
_setcursor d80x25_top_num,0
|
||||
; ------------------
|
||||
|
||||
mov ax, 0x5304 ; Disconnect interface
|
||||
xor bx, bx
|
||||
int 0x15
|
||||
mov ax, 0x5303 ; Connect 32 bit mode interface
|
||||
xor bx, bx
|
||||
int 0x15
|
||||
; init selectors
|
||||
movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
|
||||
shl eax, 4
|
||||
mov [apm_code_32 - 0x10000 + 2], ax
|
||||
shr eax, 16
|
||||
mov [apm_code_32 - 0x10000 + 4], al
|
||||
movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
|
||||
shl ecx, 4
|
||||
mov [apm_code_16 - 0x10000 + 2], cx
|
||||
shr ecx, 16
|
||||
mov [apm_code_16 - 0x10000 + 4], cl
|
||||
movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
|
||||
shl edx, 4
|
||||
mov [apm_data_16 - 0x10000 + 2], dx
|
||||
shr edx, 16
|
||||
mov [apm_data_16 - 0x10000 + 4], dl
|
||||
mov [es : 0x9040], ebx ; offset of APM entry point
|
||||
apm_end:
|
||||
; -----------------------------------------
|
||||
|
||||
|
||||
; DISPLAY VESA INFORMATION
|
||||
|
||||
.............
|
||||
.............
|
||||
|
||||
518
kernel/branches/gfx_kernel/docs/apm/apm.txt
Normal file
518
kernel/branches/gfx_kernel/docs/apm/apm.txt
Normal file
@@ -0,0 +1,518 @@
|
||||
--------p-155300-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - INSTALLATION CHECK
|
||||
AX = 5300h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
AH = major version (BCD)
|
||||
AL = minor version (BCD)
|
||||
BX = 504Dh ("PM")
|
||||
CX = flags (see #00472)
|
||||
CF set on error
|
||||
AH = error code (06h,09h,86h) (see #00473)
|
||||
BUG: early versions of the Award Modular BIOS with built-in APM support
|
||||
reportedly do not set BX on return
|
||||
|
||||
Bitfields for APM flags:
|
||||
Bit(s) Description (Table 00472)
|
||||
0 16-bit protected mode interface supported
|
||||
1 32-bit protected mode interface supported
|
||||
2 CPU idle call reduces processor speed
|
||||
3 BIOS power management disabled
|
||||
4 BIOS power management disengaged (APM v1.1)
|
||||
5-7 reserved
|
||||
|
||||
(Table 00473)
|
||||
Values for APM error code:
|
||||
01h power management functionality disabled
|
||||
02h interface connection already in effect
|
||||
03h interface not connected
|
||||
04h real-mode interface not connected
|
||||
05h 16-bit protected-mode interface already connected
|
||||
06h 16-bit protected-mode interface not supported
|
||||
07h 32-bit protected-mode interface already connected
|
||||
08h 32-bit protected-mode interface not supported
|
||||
09h unrecognized device ID
|
||||
0Ah invalid parameter value in CX
|
||||
0Bh (APM v1.1) interface not engaged
|
||||
0Ch (APM v1.2) function not supported
|
||||
0Dh (APM v1.2) Resume Timer disabled
|
||||
0Eh-1Fh reserved for other interface and general errors
|
||||
20h-3Fh reserved for CPU errors
|
||||
40h-5Fh reserved for device errors
|
||||
60h can't enter requested state
|
||||
61h-7Fh reserved for other system errors
|
||||
80h no power management events pending
|
||||
81h-85h reserved for other power management event errors
|
||||
86h APM not present
|
||||
87h-9Fh reserved for other power management event errors
|
||||
A0h-FEh reserved
|
||||
FFh undefined
|
||||
--------p-155301-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CONNECT REAL-MODE INTERFACE
|
||||
AX = 5301h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (02h,05h,07h,09h) (see #00473)
|
||||
Note: on connection, an APM v1.1 or v1.2 BIOS switches to APM v1.0
|
||||
compatibility mode until it is informed that the user supports a
|
||||
newer version of APM (see AX=530Eh)
|
||||
SeeAlso: AX=5302h,AX=5303h,AX=5304h
|
||||
--------p-155302-----------------------------
|
||||
INT 15 R - Advanced Power Management v1.0+ - CONNECT 16-BIT PROTMODE INTERFACE
|
||||
AX = 5302h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
AX = real-mode segment base address of protected-mode 16-bit code
|
||||
segment
|
||||
BX = offset of entry point
|
||||
CX = real-mode segment base address of protected-mode 16-bit data
|
||||
segment
|
||||
---APM v1.1---
|
||||
SI = APM BIOS code segment length
|
||||
DI = APM BIOS data segment length
|
||||
CF set on error
|
||||
AH = error code (02h,05h,06h,07h,09h) (see #00473)
|
||||
Notes: the caller must initialize two consecutive descriptors with the
|
||||
returned segment base addresses; these descriptors must be valid
|
||||
whenever the protected-mode interface is called, and will have
|
||||
their limits arbitrarily set to 64K.
|
||||
the protected mode interface is invoked by making a far call with the
|
||||
same register values as for INT 15; it must be invoked while CPL=0,
|
||||
the code segment descriptor must have a DPL of 0, the stack must be
|
||||
in a 16-bit segment and have enough room for BIOS use and possible
|
||||
interrupts, and the current I/O permission bit map must allow access
|
||||
to the I/O ports used for power management.
|
||||
functions 00h-03h are not available from protected mode
|
||||
on connection, an APM v1.1 or v1.2 BIOS switches to APM v1.0
|
||||
compatibility mode until it is informed that the user supports a
|
||||
newer version of APM (see AX=530Eh)
|
||||
SeeAlso: AX=5301h,AX=5303h,AX=5304h
|
||||
--------p-155303-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CONNECT 32-BIT PROTMODE INTERFACE
|
||||
AX = 5303h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
AX = real-mode segment base address of protected-mode 32-bit code
|
||||
segment
|
||||
EBX = offset of entry point
|
||||
CX = real-mode segment base address of protected-mode 16-bit code
|
||||
segment
|
||||
DX = real-mode segment base address of protected-mode 16-bit data
|
||||
segment
|
||||
---APM v1.1---
|
||||
SI = APM BIOS code segment length
|
||||
DI = APM BIOS data segment length
|
||||
CF set on error
|
||||
AH = error code (02h,05h,07h,08h,09h) (see #00473)
|
||||
Notes: the caller must initialize three consecutive descriptors with the
|
||||
returned segment base addresses for 32-bit code, 16-bit code, and
|
||||
16-bit data, respectively; these descriptors must be valid whenever
|
||||
the protected-mode interface is called, and will have their limits
|
||||
arbitrarily set to 64K.
|
||||
the protected mode interface is invoked by making a far call to the
|
||||
32-bit code segment with the same register values as for INT 15; it
|
||||
must be invoked while CPL=0, the code segment descriptor must have a
|
||||
DPL of 0, the stack must be in a 32-bit segment and have enough room
|
||||
for BIOS use and possible interrupts, and the current I/O permission
|
||||
bit map must allow access to the I/O ports used for power management.
|
||||
functions 00h-03h are not available from protected mode
|
||||
on connection, an APM v1.1 or v1.2 BIOS switches to APM v1.0
|
||||
compatibility mode until it is informed that the user supports a
|
||||
newer version of APM (see AX=530Eh)
|
||||
SeeAlso: AX=5301h,AX=5302h,AX=5304h
|
||||
--------p-155304-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - DISCONNECT INTERFACE
|
||||
AX = 5304h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (03h,09h) (see #00473)
|
||||
SeeAlso: AX=5301h,AX=5302h,AX=5303h
|
||||
--------p-155305-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CPU IDLE
|
||||
AX = 5305h
|
||||
Return: CF clear if successful (after system leaves idle state)
|
||||
CF set on error
|
||||
AH = error code (03h,0Bh) (see #00473)
|
||||
Notes: call when the system is idle and should be suspended until the next
|
||||
system event or interrupt
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
if an interrupt causes the system to resume normal processing, the
|
||||
interrupt may or may not have been handled when the BIOS returns
|
||||
from this call; thus, the caller should allow interrupts on return
|
||||
interrupt handlers may not retain control if the BIOS allows
|
||||
interrupts while in idle mode even if they are able to determine
|
||||
that they were called from idle mode
|
||||
the caller should issue this call continuously in a loop until it needs
|
||||
to perform some processing of its own
|
||||
SeeAlso: AX=1000h,AX=5306h,INT 2F/AX=1680h
|
||||
--------p-155306-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CPU BUSY
|
||||
AX = 5306h
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (03h,0Bh) (see #00473)
|
||||
Notes: called to ensure that the system runs at full speed even on systems
|
||||
where the BIOS is unable to recognize increased activity (especially
|
||||
if interrupts are hooked by other programs and not chained to the
|
||||
BIOS)
|
||||
this call may be made even when the system is already running at full
|
||||
speed, but it will create unnecessary overhead
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=5305h
|
||||
--------p-155307-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - SET POWER STATE
|
||||
AX = 5307h
|
||||
BX = device ID (see #00474)
|
||||
CX = system state ID (see #00475)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,03h,09h,0Ah,0Bh,60h) (see #00473)
|
||||
Note: should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=530Ch
|
||||
|
||||
(Table 00474)
|
||||
Values for APM device IDs:
|
||||
0000h system BIOS
|
||||
0001h all devices for which the system BIOS manages power
|
||||
01xxh display (01FFh for all attached display devices)
|
||||
02xxh secondary storage (02FFh for all attached secondary storage devices)
|
||||
03xxh parallel ports (03FFh for all attached parallel ports)
|
||||
04xxh serial ports (04FFh for all attached serial ports)
|
||||
---APM v1.1+ ---
|
||||
05xxh network adapters (05FFh for all attached network adapters)
|
||||
06xxh PCMCIA sockets (06FFh for all)
|
||||
0700h-7FFFh reserved
|
||||
80xxh system battery devices (APM v1.2)
|
||||
8100h-DFFFh reserved
|
||||
Exxxh OEM-defined power device IDs
|
||||
F000h-FFFFh reserved
|
||||
|
||||
(Table 00475)
|
||||
Values for system state ID:
|
||||
0000h ready (not supported for device ID 0001h)
|
||||
0001h stand-by
|
||||
0002h suspend
|
||||
0003h off (not supported for device ID 0001h in APM v1.0)
|
||||
---APM v1.1---
|
||||
0004h last request processing notification (only for device ID 0001h)
|
||||
0005h last request rejected (only for device ID 0001h)
|
||||
0006h-001Fh reserved system states
|
||||
0020h-003Fh OEM-defined system states
|
||||
0040h-007Fh OEM-defined device states
|
||||
0080h-FFFFh reserved device states
|
||||
--------p-155307CX0001-----------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - SYSTEM STAND-BY
|
||||
AX = 5307h
|
||||
CX = 0001h
|
||||
BX = 0001h (device ID for all power-managed devices)
|
||||
Return: CF clear
|
||||
Notes: puts the entire system into stand-by mode; normally called in response
|
||||
to a System Stand-by Request notification after any necessary
|
||||
processing, but may also be invoked at the caller's discretion
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
the stand-by state is typically exited on an interrupt
|
||||
SeeAlso: AX=4280h,AX=5307h/CX=0002h"SUSPEND",AX=5307h/CX=0003h,AX=530Bh
|
||||
--------p-155307CX0002-----------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - SUSPEND SYSTEM
|
||||
AX = 5307h
|
||||
CX = 0002h
|
||||
BX = 0001h (device ID for all power-managed devices)
|
||||
Return: after system is resumed
|
||||
CF clear
|
||||
Notes: puts the entire system into a low-power suspended state; normally
|
||||
called in response to a Suspend System Request notification after
|
||||
any necessary processing, but may also be invoked at the caller's
|
||||
discretion
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
the caller may need to update its date and time values because the
|
||||
system could have been suspended for a long period of time
|
||||
SeeAlso: AX=5307h/CX=0001h"STAND-BY",AX=530Bh
|
||||
--------p-155307CX0003-----------------------
|
||||
INT 15 - Advanced Power Management v1.2 - TURN OFF SYSTEM
|
||||
AX = 5307h
|
||||
CX = 0003h
|
||||
BX = 0001h (device ID for all power-managed devices)
|
||||
Return: after system is resumed
|
||||
CF clear
|
||||
Notes: if supported by the system's power supply, turns off the system power
|
||||
SeeAlso: AX=5307h/CX=0001h"STAND-BY",AX=530Bh
|
||||
--------p-155308-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - ENABLE/DISABLE POWER MANAGEMENT
|
||||
AX = 5308h
|
||||
BX = device ID for all devices power-managed by APM
|
||||
0001h (APM v1.1+)
|
||||
FFFFh (APM v1.0)
|
||||
CX = new state
|
||||
0000h disabled
|
||||
0001h enabled
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,03h,09h,0Ah,0Bh) (see #00473)
|
||||
Notes: when power management is disabled, the system BIOS will not
|
||||
automatically power down devices, enter stand-by or suspended mode,
|
||||
or perform any power-saving actions in response to AX=5305h calls
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
the APM BIOS should never be both disabled and disengaged at the same
|
||||
time
|
||||
SeeAlso: AX=5309h,AX=530Dh,AX=530Fh
|
||||
--------p-155309-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - RESTORE POWER-ON DEFAULTS
|
||||
AX = 5309h
|
||||
BX = device ID for all devices power-managed by APM
|
||||
0001h (APM v1.1)
|
||||
FFFFh (APM v1.0)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Bh) (see #00473)
|
||||
Note: should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=5308h
|
||||
--------p-15530A-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - GET POWER STATUS
|
||||
AX = 530Ah
|
||||
BX = device ID
|
||||
0001h all devices power-managed by APM
|
||||
80xxh specific battery unit number XXh (01h-FFh) (APM v1.2)
|
||||
Return: CF clear if successful
|
||||
BH = AC line status
|
||||
00h off-line
|
||||
01h on-line
|
||||
02h on backup power (APM v1.1)
|
||||
FFh unknown
|
||||
other reserved
|
||||
BL = battery status (see #00476)
|
||||
CH = battery flag (APM v1.1+) (see #00477)
|
||||
CL = remaining battery life, percentage
|
||||
00h-64h (0-100) percentage of full charge
|
||||
FFh unknown
|
||||
DX = remaining battery life, time (APM v1.1) (see #00478)
|
||||
---if specific battery unit specified---
|
||||
SI = number of battery units currently installed
|
||||
CF set on error
|
||||
AH = error code (09h,0Ah) (see #00473)
|
||||
Notes: should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
supported in real mode (INT 15) and both 16-bit and 32-bit protected
|
||||
mode
|
||||
|
||||
(Table 00476)
|
||||
Values for APM v1.0+ battery status:
|
||||
00h high
|
||||
01h low
|
||||
02h critical
|
||||
03h charging
|
||||
FFh unknown
|
||||
other reserved
|
||||
SeeAlso: #00477,#00478
|
||||
|
||||
Bitfields for APM v1.1+ battery flag:
|
||||
Bit(s) Description (Table 00477)
|
||||
0 high
|
||||
1 low
|
||||
2 critical
|
||||
3 charging
|
||||
4 selected battery not present (APM v1.2)
|
||||
5-6 reserved (0)
|
||||
7 no system battery
|
||||
Note: all bits set (FFh) if unknown
|
||||
SeeAlso: #00476,#00478
|
||||
|
||||
Bitfields for APM v1.1+ remaining battery life:
|
||||
Bit(s) Description (Table 00478)
|
||||
15 time units: 0=seconds, 1=minutes
|
||||
14-0 battery life in minutes or seconds
|
||||
Note: all bits set (FFFFh) if unknown
|
||||
SeeAlso: #00476,#00477
|
||||
--------p-15530B-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - GET POWER MANAGEMENT EVENT
|
||||
AX = 530Bh
|
||||
Return: CF clear if successful
|
||||
BX = event code (see #00479)
|
||||
CX = event information (APM v1.2) if BX=0003h or BX=0004h
|
||||
bit 0: PCMCIA socket was powered down in suspend state
|
||||
CF set on error
|
||||
AH = error code (03h,0Bh,80h) (see #00473)
|
||||
Notes: although power management events are often asynchronous, notification
|
||||
will not be made until polled via this call to permit software to
|
||||
only receive event notification when it is prepared to process
|
||||
power management events; since these events are not very time-
|
||||
critical, it should be sufficient to poll once or twice per second
|
||||
the critical resume notification is made after the system resumes
|
||||
from an emergency suspension; normally, the system BIOS only notifies
|
||||
its partner that it wishes to suspend and relies on the partner to
|
||||
actually request the suspension, but no notification is made on an
|
||||
emergency suspension
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=5307h,AX=5307h/CX=0001h"STAND-BY",AX=5307h/CX=0002h"SUSPEND"
|
||||
|
||||
(Table 00479)
|
||||
Values for APM event code:
|
||||
0001h system stand-by request
|
||||
0002h system suspend request
|
||||
0003h normal resume system notification
|
||||
0004h critical resume system notification
|
||||
0005h battery low notification
|
||||
---APM v1.1---
|
||||
0006h power status change notification
|
||||
0007h update time notification
|
||||
0008h critical system suspend notification
|
||||
0009h user system standby request notification
|
||||
000Ah user system suspend request notification
|
||||
000Bh system standby resume notification
|
||||
---APM v1.2---
|
||||
000Ch capabilities change notification (see AX=5310h)
|
||||
------
|
||||
000Dh-00FFh reserved system events
|
||||
01xxh reserved device events
|
||||
02xxh OEM-defined APM events
|
||||
0300h-FFFFh reserved
|
||||
--------p-15530C-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - GET POWER STATE
|
||||
AX = 530Ch
|
||||
BX = device ID (see #00474)
|
||||
Return: CF clear if successful
|
||||
CX = system state ID (see #00475)
|
||||
CF set on error
|
||||
AH = error code (01h,09h) (see #00473)
|
||||
SeeAlso: AX=5307h
|
||||
--------p-15530D-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - EN/DISABLE DEVICE POWER MANAGEMENT
|
||||
AX = 530Dh
|
||||
BX = device ID (see #00474)
|
||||
CX = function
|
||||
0000h disable power management
|
||||
0001h enable power management
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,03h,09h,0Ah,0Bh) (see #00473)
|
||||
Desc: specify whether automatic power management should be active for a
|
||||
given device
|
||||
SeeAlso: AX=5308h,AX=530Fh
|
||||
--------p-15530E-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - DRIVER VERSION
|
||||
AX = 530Eh
|
||||
BX = device ID of system BIOS (0000h)
|
||||
CH = APM driver major version (BCD)
|
||||
CL = APM driver minor version (BCD) (02h for APM v1.2)
|
||||
Return: CF clear if successful
|
||||
AH = APM connection major version (BCD)
|
||||
AL = APM connection minor version (BCD)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Bh) (see #00473)
|
||||
SeeAlso: AX=5300h,AX=5303h
|
||||
--------p-15530F-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - ENGAGE/DISENGAGE POWER MANAGEMENT
|
||||
AX = 530Fh
|
||||
BX = device ID (see #00474)
|
||||
CX = function
|
||||
0000h disengage power management
|
||||
0001h engage power management
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,09h) (see #00473)
|
||||
Notes: unlike AX=5308h, this call does not affect the functioning of the APM
|
||||
BIOS
|
||||
when cooperative power management is disengaged, the APM BIOS performs
|
||||
automatic power management of the system or device
|
||||
SeeAlso: AX=5308h,AX=530Dh
|
||||
--------p-155310-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - GET CAPABILITIES
|
||||
AX = 5310h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
Return: CF clear if successful
|
||||
BL = number of battery units supported (00h if no system batteries)
|
||||
CX = capabilities flags (see #00480)
|
||||
CF set on error
|
||||
AH = error code (01h,09h,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces; it does not require that a
|
||||
connection be established prior to use
|
||||
this function will return the capabilities currently in effect, not
|
||||
any new settings which have been made but do not take effect until
|
||||
a system restart
|
||||
SeeAlso: AX=5300h,AX=530Fh,AX=5311h,AX=5312h,AX=5313h
|
||||
|
||||
Bitfields for APM v1.2 capabilities flags:
|
||||
Bit(s) Description (Table 00480)
|
||||
15-8 reserved
|
||||
7 PCMCIA Ring Indicator will wake up system from suspend mode
|
||||
6 PCMCIA Ring Indicator will wake up system from standby mode
|
||||
5 Resume on Ring Indicator will wake up system from suspend mode
|
||||
4 Resume on Ring Indicator will wake up system from standby mode
|
||||
3 resume timer will wake up system from suspend mode
|
||||
2 resume timer will wake up system from standby mode
|
||||
1 can enter global suspend state
|
||||
0 can enter global standby state
|
||||
--------p-155311-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - GET/SET/DISABLE RESUME TIMER
|
||||
AX = 5311h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
CL = function
|
||||
00h disable Resume Timer
|
||||
01h get Resume Timer
|
||||
02h set Resume Timer
|
||||
CH = resume time, seconds (BCD)
|
||||
DL = resume time, minutes (BCD)
|
||||
DH = resume time, hours (BCD)
|
||||
SI = resume date (BCD), high byte = month, low byte = day
|
||||
DI = resume date, year (BCD)
|
||||
Return: CF clear if successful
|
||||
---if getting timer---
|
||||
CH = resume time, seconds (BCD)
|
||||
DL = resume time, minutes (BCD)
|
||||
DH = resume time, hours (BCD)
|
||||
SI = resume date (BCD), high byte = month, low byte = day
|
||||
DI = resume date, year (BCD)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Ah,0Bh,0Ch,0Dh,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces
|
||||
SeeAlso: AX=5300h,AX=5310h,AX=5312h,AX=5313h
|
||||
--------p-155312-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - ENABLE/DISABLE RESUME ON RING
|
||||
AX = 5312h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
CL = function
|
||||
00h disable Resume on Ring Indicator
|
||||
01h enable Resume on Ring Indicator
|
||||
02h get Resume on Ring Indicator status
|
||||
Return: CF clear if successful
|
||||
CX = resume status (0000h disabled, 0001h enabled)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Ah,0Bh,0Ch,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces
|
||||
SeeAlso: AX=5300h,AX=5310h,AX=5311h,AX=5313h
|
||||
--------p-155313-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - ENABLE/DISABLE TIMER-BASED REQUESTS
|
||||
AX = 5313h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
CL = function
|
||||
00h disable timer-based requests
|
||||
01h enable timer-based requests
|
||||
02h get timer-based requests status
|
||||
Return: CF clear if successful
|
||||
CX = timer-based requests status (0000h disabled, 0001h enabled)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Ah,0Bh,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces
|
||||
some BIOSes set AH on return even when successful
|
||||
SeeAlso: AX=5300h,AX=5310h,AX=5311h,AX=5312h
|
||||
4512
kernel/branches/gfx_kernel/docs/sysfuncr.txt
Normal file
4512
kernel/branches/gfx_kernel/docs/sysfuncr.txt
Normal file
File diff suppressed because it is too large
Load Diff
4467
kernel/branches/gfx_kernel/docs/sysfuncs.txt
Normal file
4467
kernel/branches/gfx_kernel/docs/sysfuncs.txt
Normal file
File diff suppressed because it is too large
Load Diff
2576
kernel/branches/gfx_kernel/fs/fat12.inc
Normal file
2576
kernel/branches/gfx_kernel/fs/fat12.inc
Normal file
File diff suppressed because it is too large
Load Diff
4162
kernel/branches/gfx_kernel/fs/fat32.inc
Normal file
4162
kernel/branches/gfx_kernel/fs/fat32.inc
Normal file
File diff suppressed because it is too large
Load Diff
1025
kernel/branches/gfx_kernel/fs/fs.inc
Normal file
1025
kernel/branches/gfx_kernel/fs/fs.inc
Normal file
File diff suppressed because it is too large
Load Diff
661
kernel/branches/gfx_kernel/fs/fs_lfn.inc
Normal file
661
kernel/branches/gfx_kernel/fs/fs_lfn.inc
Normal file
@@ -0,0 +1,661 @@
|
||||
; System function 70 - files with long names (LFN)
|
||||
; diamond, 2006
|
||||
|
||||
iglobal
|
||||
; in this table names must be in lowercase
|
||||
rootdirs:
|
||||
db 2,'rd'
|
||||
dd fs_OnRamdisk
|
||||
dd fs_NextRamdisk
|
||||
db 7,'ramdisk'
|
||||
dd fs_OnRamdisk
|
||||
dd fs_NextRamdisk
|
||||
db 2,'fd'
|
||||
dd fs_OnFloppy
|
||||
dd fs_NextFloppy
|
||||
db 10,'floppydisk'
|
||||
dd fs_OnFloppy
|
||||
dd fs_NextFloppy
|
||||
db 3,'hd0'
|
||||
dd fs_OnHd0
|
||||
dd fs_NextHd0
|
||||
db 3,'hd1'
|
||||
dd fs_OnHd1
|
||||
dd fs_NextHd1
|
||||
db 3,'hd2'
|
||||
dd fs_OnHd2
|
||||
dd fs_NextHd2
|
||||
db 3,'hd3'
|
||||
dd fs_OnHd3
|
||||
dd fs_NextHd3
|
||||
;**********************************************
|
||||
db 3,'cd0'
|
||||
dd fs_OnCd0
|
||||
dd fs_NextCd
|
||||
db 3,'cd1'
|
||||
dd fs_OnCd1
|
||||
dd fs_NextCd
|
||||
db 3,'cd2'
|
||||
dd fs_OnCd2
|
||||
dd fs_NextCd
|
||||
db 3,'cd3'
|
||||
dd fs_OnCd3
|
||||
dd fs_NextCd
|
||||
;***********************************************
|
||||
db 0
|
||||
|
||||
|
||||
virtual_root_query:
|
||||
dd fs_HasRamdisk
|
||||
db 'rd',0
|
||||
dd fs_HasFloppy
|
||||
db 'fd',0
|
||||
dd fs_HasHd0
|
||||
db 'hd0',0
|
||||
dd fs_HasHd1
|
||||
db 'hd1',0
|
||||
dd fs_HasHd2
|
||||
db 'hd2',0
|
||||
dd fs_HasHd3
|
||||
db 'hd3',0
|
||||
;**********************************************
|
||||
dd fs_HasCd0
|
||||
db 'cd0',0
|
||||
dd fs_HasCd1
|
||||
db 'cd1',0
|
||||
dd fs_HasCd2
|
||||
db 'cd2',0
|
||||
dd fs_HasCd3
|
||||
db 'cd3',0
|
||||
;**********************************************
|
||||
dd 0
|
||||
endg
|
||||
|
||||
file_system_lfn:
|
||||
; in: eax->fileinfo block
|
||||
; operation codes:
|
||||
; 0 : read file
|
||||
; 1 : read folder
|
||||
; 2 : create/rewrite file
|
||||
; 3 : write/append to file
|
||||
; 4 : set end of file
|
||||
; 5 : get file/directory attributes structure
|
||||
; 6 : set file/directory attributes structure
|
||||
; 7 : start application
|
||||
; 8 : delete file - not implemented yet
|
||||
; 9 : create directory - not implemented yet
|
||||
; 10: rename file/directory - not implemented yet
|
||||
|
||||
add eax, std_application_base_address
|
||||
; parse file name
|
||||
xchg ebx, eax
|
||||
lea esi, [ebx+20]
|
||||
mov ebp, esi ; for 'start app' function full path must be known
|
||||
lodsb
|
||||
test al, al
|
||||
jnz @f
|
||||
mov esi, [esi]
|
||||
add esi, std_application_base_address
|
||||
mov ebp, esi
|
||||
lodsb
|
||||
@@:
|
||||
cmp al, '/'
|
||||
jz @f
|
||||
.notfound:
|
||||
mov dword [esp+36], 5 ; file not found
|
||||
ret
|
||||
@@:
|
||||
cmp byte [esi], 0
|
||||
jz .rootdir
|
||||
mov edi, rootdirs-8
|
||||
xor ecx, ecx
|
||||
push esi
|
||||
.scan1:
|
||||
pop esi
|
||||
add edi, ecx
|
||||
scasd
|
||||
scasd
|
||||
mov cl, byte [edi]
|
||||
jecxz .notfound
|
||||
inc edi
|
||||
push esi
|
||||
@@:
|
||||
lodsb
|
||||
or al, 20h
|
||||
scasb
|
||||
loopz @b
|
||||
jnz .scan1
|
||||
lodsb
|
||||
cmp al, '/'
|
||||
jz .found1
|
||||
test al, al
|
||||
jnz .scan1
|
||||
pop eax
|
||||
; directory /xxx
|
||||
.maindir:
|
||||
cmp dword [ebx], 1
|
||||
jnz .access_denied
|
||||
xor eax, eax
|
||||
mov ebp, [ebx+12]
|
||||
mov edx, [ebx+16]
|
||||
add edx, std_application_base_address
|
||||
push dword [ebx+4] ; first block
|
||||
mov ebx, [ebx+8] ; flags
|
||||
mov esi, [edi+4]
|
||||
; ebx=flags, [esp]=first block, ebp=number of blocks, edx=return area, esi='Next' handler
|
||||
mov edi, edx
|
||||
mov ecx, 32/4
|
||||
rep stosd
|
||||
mov byte [edx], 1 ; version
|
||||
.maindir_loop:
|
||||
call esi
|
||||
jc .maindir_done
|
||||
inc dword [edx+8]
|
||||
dec dword [esp]
|
||||
jns .maindir_loop
|
||||
dec ebp
|
||||
js .maindir_loop
|
||||
inc dword [edx+4]
|
||||
mov dword [edi], 0x10 ; attributes: folder
|
||||
mov dword [edi+4], 1 ; name type: UNICODE
|
||||
push eax
|
||||
xor eax, eax
|
||||
add edi, 8
|
||||
mov ecx, 40/4-2
|
||||
rep stosd
|
||||
pop eax
|
||||
push eax edx
|
||||
; convert number in eax to decimal UNICODE string
|
||||
push edi
|
||||
push -'0'
|
||||
mov cl, 10
|
||||
@@:
|
||||
xor edx, edx
|
||||
div ecx
|
||||
push edx
|
||||
test eax, eax
|
||||
jnz @b
|
||||
@@:
|
||||
pop eax
|
||||
add al, '0'
|
||||
stosb
|
||||
test bl, 1 ; UNICODE name?
|
||||
jz .ansi2
|
||||
mov byte [edi], 0
|
||||
inc edi
|
||||
.ansi2:
|
||||
test al, al
|
||||
jnz @b
|
||||
mov byte [edi-1], 0
|
||||
pop edi
|
||||
; UNICODE name length is 520 bytes, ANSI - 264
|
||||
add edi, 520
|
||||
test bl, 1
|
||||
jnz @f
|
||||
sub edi, 520-264
|
||||
@@:
|
||||
pop edx eax
|
||||
jmp .maindir_loop
|
||||
.maindir_done:
|
||||
pop eax
|
||||
mov ebx, [edx+4]
|
||||
xor eax, eax
|
||||
dec ebp
|
||||
js @f
|
||||
mov al, ERROR_END_OF_FILE
|
||||
@@:
|
||||
mov [esp+36], eax
|
||||
mov [esp+24], ebx
|
||||
ret
|
||||
; directory /
|
||||
.rootdir:
|
||||
cmp dword [ebx], 1 ; read folder?
|
||||
jz .readroot
|
||||
.access_denied:
|
||||
mov dword [esp+36], 10 ; access denied
|
||||
ret
|
||||
|
||||
.readroot:
|
||||
; virtual root folder - special handler
|
||||
mov esi, virtual_root_query
|
||||
mov ebp, [ebx+12]
|
||||
mov edx, [ebx+16]
|
||||
add edx, std_application_base_address
|
||||
push dword [ebx+4] ; first block
|
||||
mov ebx, [ebx+8] ; flags
|
||||
xor eax, eax
|
||||
; eax=0, [esp]=first block, ebx=flags, ebp=number of blocks, edx=return area
|
||||
mov edi, edx
|
||||
mov ecx, 32/4
|
||||
rep stosd
|
||||
mov byte [edx], 1 ; version
|
||||
.readroot_loop:
|
||||
cmp dword [esi], eax
|
||||
jz .readroot_done
|
||||
call dword [esi]
|
||||
add esi, 4
|
||||
test eax, eax
|
||||
jnz @f
|
||||
.readroot_next:
|
||||
or ecx, -1
|
||||
xchg esi, edi
|
||||
repnz scasb
|
||||
xchg esi, edi
|
||||
jmp .readroot_loop
|
||||
@@:
|
||||
xor eax, eax
|
||||
inc dword [edx+8]
|
||||
dec dword [esp]
|
||||
jns .readroot_next
|
||||
dec ebp
|
||||
js .readroot_next
|
||||
inc dword [edx+4]
|
||||
mov dword [edi], 0x10 ; attributes: folder
|
||||
mov dword [edi+4], 1 ; name type: UNICODE
|
||||
add edi, 8
|
||||
mov ecx, 40/4-2
|
||||
rep stosd
|
||||
push edi
|
||||
@@:
|
||||
lodsb
|
||||
stosb
|
||||
test bl, 1
|
||||
jz .ansi
|
||||
mov byte [edi], 0
|
||||
inc edi
|
||||
.ansi:
|
||||
test eax, eax
|
||||
jnz @b
|
||||
pop edi
|
||||
add edi, 520
|
||||
test bl, 1
|
||||
jnz .readroot_loop
|
||||
sub edi, 520-264
|
||||
jmp .readroot_loop
|
||||
.readroot_done:
|
||||
pop eax
|
||||
mov ebx, [edx+4]
|
||||
xor eax, eax
|
||||
dec ebp
|
||||
js @f
|
||||
mov al, ERROR_END_OF_FILE
|
||||
@@:
|
||||
mov [esp+36], eax
|
||||
mov [esp+24], ebx
|
||||
ret
|
||||
|
||||
.found1:
|
||||
pop eax
|
||||
cmp byte [esi], 0
|
||||
jz .maindir
|
||||
; read partition number
|
||||
xor ecx, ecx
|
||||
xor eax, eax
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, '/'
|
||||
jz .done1
|
||||
test al, al
|
||||
jz .done1
|
||||
sub al, '0'
|
||||
cmp al, 9
|
||||
ja .notfound
|
||||
imul ecx, 10
|
||||
add ecx, eax
|
||||
jmp @b
|
||||
.done1:
|
||||
test ecx, ecx
|
||||
jz .notfound
|
||||
test al, al
|
||||
jnz @f
|
||||
dec esi
|
||||
@@:
|
||||
; now [edi] contains handler address, ecx - partition number,
|
||||
; esi points to ASCIIZ string - rest of name
|
||||
jmp dword [edi]
|
||||
|
||||
; handlers for devices
|
||||
; in: ecx = 0 => query virtual directory /xxx
|
||||
; in: ecx = partition number
|
||||
; esi -> relative (for device) name
|
||||
; ebx -> fileinfo
|
||||
; out: [esp+36]=image of eax, [esp+24]=image of ebx
|
||||
|
||||
fs_OnRamdisk:
|
||||
cmp ecx, 1
|
||||
jnz file_system_lfn.notfound
|
||||
mov eax, [ebx]
|
||||
cmp eax, fs_NumRamdiskServices
|
||||
jae .not_impl
|
||||
mov ecx, [ebx+12]
|
||||
mov edx, [ebx+16]
|
||||
add edx, std_application_base_address
|
||||
add ebx, 4
|
||||
call dword [fs_RamdiskServices + eax*4]
|
||||
mov [esp+36], eax
|
||||
mov [esp+24], ebx
|
||||
ret
|
||||
.not_impl:
|
||||
mov dword [esp+36], 2 ; not implemented
|
||||
ret
|
||||
|
||||
fs_NotImplemented:
|
||||
mov eax, 2
|
||||
ret
|
||||
|
||||
fs_RamdiskServices:
|
||||
dd fs_RamdiskRead
|
||||
dd fs_RamdiskReadFolder
|
||||
dd fs_RamdiskRewrite
|
||||
dd fs_RamdiskWrite
|
||||
dd fs_RamdiskSetFileEnd
|
||||
dd fs_RamdiskGetFileInfo
|
||||
dd fs_RamdiskSetFileInfo
|
||||
dd fs_RamdiskExecute
|
||||
fs_NumRamdiskServices = ($ - fs_RamdiskServices)/4
|
||||
|
||||
fs_OnFloppy:
|
||||
cmp ecx, 2
|
||||
ja file_system_lfn.notfound
|
||||
mov eax, [ebx]
|
||||
cmp eax, fs_NumFloppyServices
|
||||
jae fs_OnRamdisk.not_impl
|
||||
call reserve_flp
|
||||
mov [flp_number], cl
|
||||
mov ecx, [ebx+12]
|
||||
mov edx, [ebx+16]
|
||||
add edx, std_application_base_address
|
||||
add ebx, 4
|
||||
call dword [fs_FloppyServices + eax*4]
|
||||
and [flp_status], 0
|
||||
mov [esp+36], eax
|
||||
mov [esp+24], ebx
|
||||
ret
|
||||
|
||||
fs_FloppyServices:
|
||||
dd fs_FloppyRead
|
||||
dd fs_FloppyReadFolder
|
||||
dd fs_FloppyRewrite
|
||||
dd fs_FloppyWrite
|
||||
dd fs_FloppySetFileEnd
|
||||
dd fs_FloppyGetFileInfo
|
||||
dd fs_FloppySetFileInfo
|
||||
dd fs_FloppyExecute
|
||||
fs_NumFloppyServices = ($ - fs_FloppyServices)/4
|
||||
|
||||
fs_OnHd0:
|
||||
call reserve_hd1
|
||||
mov [hdbase], 0x1F0
|
||||
mov [hdid], 0
|
||||
push 1
|
||||
jmp fs_OnHd
|
||||
fs_OnHd1:
|
||||
call reserve_hd1
|
||||
mov [hdbase], 0x1F0
|
||||
mov [hdid], 0x10
|
||||
push 2
|
||||
jmp fs_OnHd
|
||||
fs_OnHd2:
|
||||
call reserve_hd1
|
||||
mov [hdbase], 0x170
|
||||
mov [hdid], 0
|
||||
push 3
|
||||
jmp fs_OnHd
|
||||
fs_OnHd3:
|
||||
call reserve_hd1
|
||||
mov [hdbase], 0x170
|
||||
mov [hdid], 0x10
|
||||
push 4
|
||||
fs_OnHd:
|
||||
call reserve_hd_channel
|
||||
pop eax
|
||||
mov [hdpos], eax
|
||||
cmp ecx, 0x100
|
||||
jae .nf
|
||||
cmp cl, [0x40001+eax]
|
||||
jbe @f
|
||||
.nf:
|
||||
call free_hd_channel
|
||||
and [hd1_status], 0
|
||||
mov dword [esp+36], 5 ; not found
|
||||
ret
|
||||
@@:
|
||||
mov [fat32part], ecx
|
||||
push ebx esi
|
||||
call choice_necessity_partition_1
|
||||
pop esi ebx
|
||||
mov ecx, [ebx+12]
|
||||
mov edx, [ebx+16]
|
||||
add edx, std_application_base_address
|
||||
mov eax, [ebx]
|
||||
cmp eax, fs_NumHdServices
|
||||
jae .not_impl
|
||||
add ebx, 4
|
||||
call dword [fs_HdServices + eax*4]
|
||||
call free_hd_channel
|
||||
and [hd1_status], 0
|
||||
mov [esp+36], eax
|
||||
mov [esp+24], ebx
|
||||
ret
|
||||
.not_impl:
|
||||
call free_hd_channel
|
||||
and [hd1_status], 0
|
||||
mov dword [esp+36], 2 ; not implemented
|
||||
ret
|
||||
|
||||
fs_HdServices:
|
||||
dd fs_HdRead
|
||||
dd fs_HdReadFolder
|
||||
dd fs_HdRewrite
|
||||
dd fs_HdWrite
|
||||
dd fs_HdSetFileEnd
|
||||
dd fs_HdGetFileInfo
|
||||
dd fs_HdSetFileInfo
|
||||
dd fs_HdExecute
|
||||
fs_NumHdServices = ($ - fs_HdServices)/4
|
||||
|
||||
;*******************************************************
|
||||
fs_OnCd0:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],0
|
||||
push 6
|
||||
jmp fs_OnCd
|
||||
fs_OnCd1:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],1
|
||||
push 4
|
||||
jmp fs_OnCd
|
||||
fs_OnCd2:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber],2
|
||||
mov [DiskNumber],0
|
||||
push 2
|
||||
jmp fs_OnCd
|
||||
fs_OnCd3:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber],2
|
||||
mov [DiskNumber],1
|
||||
push 0
|
||||
fs_OnCd:
|
||||
call reserve_cd_channel
|
||||
pop eax
|
||||
mov [hdpos], eax
|
||||
cmp ecx, 0x100
|
||||
jae .nf
|
||||
push ecx ebx
|
||||
mov cl,al
|
||||
mov bl,[0x40001]
|
||||
shr bl,cl
|
||||
test bl,2
|
||||
pop ebx ecx
|
||||
|
||||
jnz @f
|
||||
.nf:
|
||||
call free_cd_channel
|
||||
and [cd_status], 0
|
||||
mov dword [esp+36], 5 ; not found
|
||||
ret
|
||||
@@:
|
||||
mov ecx, [ebx+12]
|
||||
mov edx, [ebx+16]
|
||||
add edx, std_application_base_address
|
||||
mov eax, [ebx]
|
||||
cmp eax,fs_NumCdServices
|
||||
jae .not_impl
|
||||
add ebx, 4
|
||||
call dword [fs_CdServices + eax*4]
|
||||
call free_cd_channel
|
||||
and [cd_status], 0
|
||||
mov [esp+36], eax
|
||||
mov [esp+24], ebx
|
||||
ret
|
||||
.not_impl:
|
||||
call free_cd_channel
|
||||
and [cd_status], 0
|
||||
mov dword [esp+36], 2 ; not implemented
|
||||
ret
|
||||
|
||||
fs_CdServices:
|
||||
dd fs_CdRead
|
||||
dd fs_CdReadFolder
|
||||
dd fs_NotImplemented
|
||||
dd fs_NotImplemented
|
||||
dd fs_NotImplemented
|
||||
dd fs_CdGetFileInfo
|
||||
dd fs_NotImplemented
|
||||
dd fs_CdExecute
|
||||
fs_NumCdServices = ($ - fs_CdServices)/4
|
||||
|
||||
;*******************************************************
|
||||
|
||||
fs_HasRamdisk:
|
||||
mov al, 1 ; we always have ramdisk
|
||||
ret
|
||||
|
||||
fs_HasFloppy:
|
||||
cmp byte [0x40000], 0
|
||||
setnz al
|
||||
ret
|
||||
|
||||
fs_HasHd0:
|
||||
mov al, [0x40001]
|
||||
and al, 11000000b
|
||||
cmp al, 01000000b
|
||||
setz al
|
||||
ret
|
||||
fs_HasHd1:
|
||||
mov al, [0x40001]
|
||||
and al, 00110000b
|
||||
cmp al, 00010000b
|
||||
setz al
|
||||
ret
|
||||
fs_HasHd2:
|
||||
mov al, [0x40001]
|
||||
and al, 00001100b
|
||||
cmp al, 00000100b
|
||||
setz al
|
||||
ret
|
||||
fs_HasHd3:
|
||||
mov al, [0x40001]
|
||||
and al, 00000011b
|
||||
cmp al, 00000001b
|
||||
setz al
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
fs_HasCd0:
|
||||
mov al, [0x40001]
|
||||
and al, 11000000b
|
||||
cmp al, 10000000b
|
||||
setz al
|
||||
ret
|
||||
fs_HasCd1:
|
||||
mov al, [0x40001]
|
||||
and al, 00110000b
|
||||
cmp al, 00100000b
|
||||
setz al
|
||||
ret
|
||||
fs_HasCd2:
|
||||
mov al, [0x40001]
|
||||
and al, 00001100b
|
||||
cmp al, 00001000b
|
||||
setz al
|
||||
ret
|
||||
fs_HasCd3:
|
||||
mov al, [0x40001]
|
||||
and al, 00000011b
|
||||
cmp al, 00000010b
|
||||
setz al
|
||||
ret
|
||||
;*******************************************************
|
||||
|
||||
; fs_NextXXX functions:
|
||||
; in: eax = partition number, from which start to scan
|
||||
; out: CF=1 => no more partitions
|
||||
; CF=0 => eax=next partition number
|
||||
|
||||
fs_NextRamdisk:
|
||||
; we always have /rd/1
|
||||
test eax, eax
|
||||
stc
|
||||
jnz @f
|
||||
mov al, 1
|
||||
clc
|
||||
@@:
|
||||
ret
|
||||
|
||||
fs_NextFloppy:
|
||||
; we have /fd/1 iff (([0x40000] and 0xF0) != 0) and /fd/2 iff (([0x40000] and 0x0F) != 0)
|
||||
test byte [0x40000], 0xF0
|
||||
jz .no1
|
||||
test eax, eax
|
||||
jnz .no1
|
||||
inc eax
|
||||
ret ; CF cleared
|
||||
.no1:
|
||||
test byte [0x40000], 0x0F
|
||||
jz .no2
|
||||
cmp al, 2
|
||||
jae .no2
|
||||
mov al, 2
|
||||
clc
|
||||
ret
|
||||
.no2:
|
||||
stc
|
||||
ret
|
||||
|
||||
; on hdx, we have partitions from 1 to [0x40002+x]
|
||||
fs_NextHd0:
|
||||
push 0
|
||||
jmp fs_NextHd
|
||||
fs_NextHd1:
|
||||
push 1
|
||||
jmp fs_NextHd
|
||||
fs_NextHd2:
|
||||
push 2
|
||||
jmp fs_NextHd
|
||||
fs_NextHd3:
|
||||
push 3
|
||||
fs_NextHd:
|
||||
pop ecx
|
||||
movzx ecx, byte [0x40002+ecx]
|
||||
cmp eax, ecx
|
||||
jae fs_NextFloppy.no2
|
||||
inc eax
|
||||
clc
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
fs_NextCd:
|
||||
; we always have /cdX/1
|
||||
test eax, eax
|
||||
stc
|
||||
jnz @f
|
||||
mov al, 1
|
||||
clc
|
||||
@@:
|
||||
ret
|
||||
;*******************************************************
|
||||
|
||||
823
kernel/branches/gfx_kernel/fs/iso9660.inc
Normal file
823
kernel/branches/gfx_kernel/fs/iso9660.inc
Normal file
@@ -0,0 +1,823 @@
|
||||
|
||||
uglobal
|
||||
cd_current_pointer_of_input dd 0
|
||||
cd_current_pointer_of_input_2 dd 0
|
||||
cd_mem_location dd 0
|
||||
cd_counter_block dd 0
|
||||
IDE_Channel_1 db 0
|
||||
IDE_Channel_2 db 0
|
||||
endg
|
||||
|
||||
CDDataBuf equ 0x7000
|
||||
|
||||
reserve_cd:
|
||||
|
||||
cli
|
||||
cmp [cd_status],0
|
||||
je reserve_ok2
|
||||
|
||||
sti
|
||||
call change_task
|
||||
jmp reserve_cd
|
||||
|
||||
reserve_ok2:
|
||||
|
||||
push eax
|
||||
mov eax,[0x3000]
|
||||
shl eax,5
|
||||
mov eax,[eax+0x3000+TASKDATA.pid]
|
||||
mov [cd_status],eax
|
||||
pop eax
|
||||
sti
|
||||
ret
|
||||
|
||||
reserve_cd_channel:
|
||||
cmp [ChannelNumber],1
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
cli
|
||||
cmp [IDE_Channel_1],0
|
||||
je .reserve_ok_1
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
.IDE_Channel_2:
|
||||
cli
|
||||
cmp [IDE_Channel_2],0
|
||||
je .reserve_ok_2
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
.reserve_ok_1:
|
||||
mov [IDE_Channel_1],1
|
||||
ret
|
||||
.reserve_ok_2:
|
||||
mov [IDE_Channel_2],1
|
||||
ret
|
||||
|
||||
free_cd_channel:
|
||||
cmp [ChannelNumber],1
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
mov [IDE_Channel_1],0
|
||||
ret
|
||||
.IDE_Channel_2:
|
||||
mov [IDE_Channel_2],0
|
||||
ret
|
||||
|
||||
cd_status dd 0
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdRead - LFN variant for reading CD disk
|
||||
;
|
||||
; esi points to filename /dir1/dir2/.../dirn/file,0
|
||||
; ebx pointer to 64-bit number = first wanted byte, 0+
|
||||
; may be ebx=0 - start from first byte
|
||||
; ecx number of bytes to read, 0+
|
||||
; edx mem location to return data
|
||||
;
|
||||
; ret ebx = bytes read or 0xffffffff file not found
|
||||
; eax = 0 ok read or other = errormsg
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
fs_CdRead:
|
||||
push edi
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
.noaccess:
|
||||
pop edi
|
||||
.noaccess_2:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
|
||||
.noaccess_3:
|
||||
pop eax edx ecx edi
|
||||
jmp .noaccess_2
|
||||
|
||||
@@:
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_2
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
|
||||
.found:
|
||||
mov edi,[cd_current_pointer_of_input]
|
||||
test byte [edi+25],10b ; do not allow read directories
|
||||
jnz .noaccess
|
||||
test ebx, ebx
|
||||
jz .l1
|
||||
cmp dword [ebx+4], 0
|
||||
jz @f
|
||||
xor ebx, ebx
|
||||
.reteof:
|
||||
mov eax, 6 ; end of file
|
||||
pop edi
|
||||
ret
|
||||
@@:
|
||||
mov ebx, [ebx]
|
||||
.l1:
|
||||
push ecx edx
|
||||
push 0
|
||||
mov eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
|
||||
sub eax, ebx
|
||||
jb .eof
|
||||
cmp eax, ecx
|
||||
jae @f
|
||||
mov ecx, eax
|
||||
mov byte [esp], 6
|
||||
@@:
|
||||
mov eax,[edi+2]
|
||||
mov [CDSectorAddress],eax
|
||||
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
|
||||
.new_sector:
|
||||
test ecx, ecx
|
||||
jz .done
|
||||
sub ebx, 2048
|
||||
jae .next
|
||||
add ebx, 2048
|
||||
jnz .incomplete_sector
|
||||
cmp ecx, 2048
|
||||
jb .incomplete_sector
|
||||
; we may read and memmove complete sector
|
||||
mov [CDDataBuf_pointer],edx
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_3
|
||||
add edx, 2048
|
||||
sub ecx, 2048
|
||||
.next:
|
||||
inc dword [CDSectorAddress]
|
||||
jmp .new_sector
|
||||
.incomplete_sector:
|
||||
; we must read and memmove incomplete sector
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_3
|
||||
push ecx
|
||||
add ecx, ebx
|
||||
cmp ecx, 2048
|
||||
jbe @f
|
||||
mov ecx, 2048
|
||||
@@:
|
||||
sub ecx, ebx
|
||||
push edi esi ecx
|
||||
mov edi,edx
|
||||
lea esi, [CDDataBuf + ebx]
|
||||
cld
|
||||
rep movsb
|
||||
pop ecx esi edi
|
||||
add edx, ecx
|
||||
sub [esp], ecx
|
||||
pop ecx
|
||||
xor ebx, ebx
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx edi
|
||||
sub ebx, edx
|
||||
ret
|
||||
.eof:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx
|
||||
sub ebx, edx
|
||||
jmp .reteof
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdReadFolder - LFN variant for reading CD disk folder
|
||||
;
|
||||
; esi points to filename /dir1/dir2/.../dirn/file,0
|
||||
; ebx pointer to structure 32-bit number = first wanted block, 0+
|
||||
; & flags (bitfields)
|
||||
; flags: bit 0: 0=ANSI names, 1=UNICODE names
|
||||
; ecx number of blocks to read, 0+
|
||||
; edx mem location to return data
|
||||
;
|
||||
; ret ebx = blocks read or 0xffffffff folder not found
|
||||
; eax = 0 ok read or other = errormsg
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
fs_CdReadFolder:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_1
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
.found:
|
||||
mov edi,[cd_current_pointer_of_input]
|
||||
test byte [edi+25],10b ; do not allow read directories
|
||||
jnz .found_dir
|
||||
pop edi
|
||||
.noaccess_1:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
.found_dir:
|
||||
mov eax,[edi+2] ; eax=cluster
|
||||
mov [CDSectorAddress],eax
|
||||
mov eax,[edi+10] ; ðàçìåð äèðåêòðîðèè
|
||||
.doit:
|
||||
; init header
|
||||
push eax ecx
|
||||
mov edi, edx
|
||||
mov ecx, 32/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop ecx eax
|
||||
mov byte [edx], 1 ; version
|
||||
mov [cd_mem_location],edx
|
||||
add [cd_mem_location],32
|
||||
; íà÷èíàåì ïåðåáðîñêó ÁÄÂÊ â ÓÑÂÊ
|
||||
;.mainloop:
|
||||
mov [cd_counter_block],dword 0
|
||||
dec dword [CDSectorAddress]
|
||||
push ecx
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_1
|
||||
call .get_names_from_buffer
|
||||
sub eax,2048
|
||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||
cmp eax,0
|
||||
ja .read_to_buffer
|
||||
mov edi,[cd_counter_block]
|
||||
mov [edx+8],edi
|
||||
mov edi,[ebx]
|
||||
sub [edx+4],edi
|
||||
pop ecx edi
|
||||
mov ebx, [edx+4]
|
||||
mov eax,ERROR_SUCCESS
|
||||
ret
|
||||
|
||||
.get_names_from_buffer:
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
push eax esi edi edx
|
||||
.get_names_from_buffer_1:
|
||||
call cd_get_name
|
||||
jc .end_buffer
|
||||
inc dword [cd_counter_block]
|
||||
mov eax,[cd_counter_block]
|
||||
cmp [ebx],eax
|
||||
jae .get_names_from_buffer_1
|
||||
test ecx, ecx
|
||||
jz .get_names_from_buffer_1
|
||||
mov edi,[cd_counter_block]
|
||||
mov [edx+4],edi
|
||||
dec ecx
|
||||
mov esi,ebp
|
||||
mov edi,[cd_mem_location]
|
||||
add edi,40
|
||||
test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE
|
||||
jnz .unicode
|
||||
; jmp .unicode
|
||||
.ansi:
|
||||
cmp [cd_counter_block],2
|
||||
jbe .ansi_parent_directory
|
||||
cld
|
||||
lodsw
|
||||
xchg ah,al
|
||||
call uni2ansi_char
|
||||
cld
|
||||
stosb
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
mov ax,[esi]
|
||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .cd_get_parameters_of_file_1
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp esi,eax
|
||||
je .cd_get_parameters_of_file_1
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp esi,eax
|
||||
jb .ansi
|
||||
.cd_get_parameters_of_file_1:
|
||||
mov [edi],byte 0
|
||||
call cd_get_parameters_of_file
|
||||
add [cd_mem_location],304
|
||||
jmp .get_names_from_buffer_1
|
||||
|
||||
.ansi_parent_directory:
|
||||
cmp [cd_counter_block],2
|
||||
je @f
|
||||
mov [edi],byte '.'
|
||||
inc edi
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
@@:
|
||||
mov [edi],word '..'
|
||||
add edi,2
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
|
||||
.unicode:
|
||||
cmp [cd_counter_block],2
|
||||
jbe .unicode_parent_directory
|
||||
cld
|
||||
movsw
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
mov ax,[esi]
|
||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .cd_get_parameters_of_file_2
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp esi,eax
|
||||
je .cd_get_parameters_of_file_2
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp esi,eax
|
||||
jb .unicode
|
||||
.cd_get_parameters_of_file_2:
|
||||
mov [edi],word 0
|
||||
call cd_get_parameters_of_file
|
||||
add [cd_mem_location],560
|
||||
jmp .get_names_from_buffer_1
|
||||
|
||||
.unicode_parent_directory:
|
||||
cmp [cd_counter_block],2
|
||||
je @f
|
||||
mov [edi],word 2E00h ; '.'
|
||||
add edi,2
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
@@:
|
||||
mov [edi],dword 2E002E00h ; '..'
|
||||
add edi,4
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
|
||||
.end_buffer:
|
||||
pop edx edi esi eax
|
||||
ret
|
||||
|
||||
cd_get_parameters_of_file:
|
||||
mov edi,[cd_mem_location]
|
||||
cd_get_parameters_of_file_1:
|
||||
; ïîëó÷àåì àòðèáóòû ôàéëà
|
||||
xor eax,eax
|
||||
; ôàéë íå àðõèâèðîâàëñÿ
|
||||
inc al
|
||||
shl eax,1
|
||||
; ýòî êàòàëîã?
|
||||
test [ebp-8],byte 2
|
||||
jz .file
|
||||
inc al
|
||||
.file:
|
||||
; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò
|
||||
; ôàéë íå ÿâëÿåòñÿ ñèñòåìíûì
|
||||
shl eax,3
|
||||
; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå)
|
||||
test [ebp-8],byte 1
|
||||
jz .hidden
|
||||
inc al
|
||||
.hidden:
|
||||
shl eax,1
|
||||
; ôàéë âñåãäà òîëüêî äëÿ ÷òåíèÿ, òàê êàê ýòî CD
|
||||
inc al
|
||||
mov [edi],eax
|
||||
; ïîëó÷àåì âðåìÿ äëÿ ôàéëà
|
||||
;÷àñ
|
||||
movzx eax,byte [ebp-12]
|
||||
shl eax,8
|
||||
;ìèíóòà
|
||||
mov al,[ebp-11]
|
||||
shl eax,8
|
||||
;ñåêóíäà
|
||||
mov al,[ebp-10]
|
||||
;âðåìÿ ñîçäàíèÿ ôàéëà
|
||||
mov [edi+8],eax
|
||||
;âðåìÿ ïîñëåäíåãî äîñòóïà
|
||||
mov [edi+16],eax
|
||||
;âðåìÿ ïîñëåäíåé çàïèñè
|
||||
mov [edi+24],eax
|
||||
; ïîëó÷àåì äàòó äëÿ ôàéëà
|
||||
;ãîä
|
||||
movzx eax,byte [ebp-15]
|
||||
add eax,1900
|
||||
shl eax,8
|
||||
;ìåñÿö
|
||||
mov al,[ebp-14]
|
||||
shl eax,8
|
||||
;äåíü
|
||||
mov al,[ebp-13]
|
||||
;äàòà ñîçäàíèÿ ôàéëà
|
||||
mov [edi+12],eax
|
||||
;âðåìÿ ïîñëåäíåãî äîñòóïà
|
||||
mov [edi+20],eax
|
||||
;âðåìÿ ïîñëåäíåé çàïèñè
|
||||
mov [edi+28],eax
|
||||
; ïîëó÷àåì òèï äàííûõ èìåíè
|
||||
xor eax,eax
|
||||
test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE
|
||||
jnz .unicode_1
|
||||
mov [edi+4],eax
|
||||
jmp @f
|
||||
.unicode_1:
|
||||
inc eax
|
||||
mov [edi+4],eax
|
||||
@@:
|
||||
; ïîëó÷àåì ðàçìåð ôàéëà â áàéòàõ
|
||||
xor eax,eax
|
||||
mov [edi+32+4],eax
|
||||
mov eax,[ebp-23]
|
||||
mov [edi+32],eax
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdGetFileInfo - LFN variant for CD
|
||||
; get file/directory attributes structure
|
||||
;
|
||||
;----------------------------------------------------------------
|
||||
fs_CdGetFileInfo:
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov eax, 2
|
||||
ret
|
||||
@@:
|
||||
push edi ebp
|
||||
call cd_find_lfn
|
||||
pushfd
|
||||
cmp [DevErrorCode], 0
|
||||
jz @f
|
||||
popfd
|
||||
pop ebp edi
|
||||
mov eax, 11
|
||||
ret
|
||||
@@:
|
||||
popfd
|
||||
jnc @f
|
||||
pop ebp edi
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
@@:
|
||||
|
||||
mov edi, edx
|
||||
call cd_get_parameters_of_file_1
|
||||
and dword [edi+4], 0
|
||||
pop ebp edi
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdExecute - LFN variant for executing from CD
|
||||
;
|
||||
; esi points to hd filename (e.g. 'dir1/name')
|
||||
; ebp points to full filename (e.g. '/hd0/1/dir1/name')
|
||||
; dword [ebx] = flags
|
||||
; dword [ebx+4] = cmdline
|
||||
;
|
||||
; ret ebx,edx destroyed
|
||||
; eax > 0 - PID, < 0 - error
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
fs_CdExecute:
|
||||
mov edx, [ebx]
|
||||
mov ebx, [ebx+4]
|
||||
test ebx, ebx
|
||||
jz @f
|
||||
add ebx, std_application_base_address
|
||||
@@:
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdExecute.flags - second entry
|
||||
;
|
||||
; esi points to floppy filename (kernel address)
|
||||
; ebp points to full filename
|
||||
; edx flags
|
||||
; ebx cmdline (kernel address)
|
||||
;
|
||||
; ret eax > 0 - PID, < 0 - error
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
|
||||
.flags:
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
; cannot execute root!
|
||||
mov eax, -ERROR_ACCESS_DENIED
|
||||
ret
|
||||
@@:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
mov eax, -ERROR_FILE_NOT_FOUND
|
||||
cmp [DevErrorCode], 0
|
||||
jz @f
|
||||
mov al, -11
|
||||
@@:
|
||||
ret
|
||||
.found:
|
||||
mov edi,[cd_current_pointer_of_input]
|
||||
mov eax,[edi+2]
|
||||
push 0
|
||||
push eax
|
||||
push dword [edi+10] ; size
|
||||
push .DoRead
|
||||
call fs_execute
|
||||
add esp, 16
|
||||
pop edi
|
||||
ret
|
||||
|
||||
.DoRead:
|
||||
; read next block
|
||||
; in: eax->parameters, edi->buffer
|
||||
; out: eax = error code
|
||||
pushad
|
||||
cmp dword [eax], 0 ; file size
|
||||
jz .eof
|
||||
cmp [eax+8],dword 0
|
||||
jne @f
|
||||
mov ecx,[eax+4]
|
||||
inc dword [eax+4]
|
||||
mov [CDSectorAddress],ecx
|
||||
mov [CDDataBuf_pointer],CDDataBuf ;edi
|
||||
call ReadCDWRetr
|
||||
cmp [DevErrorCode], 0
|
||||
jnz .err
|
||||
@@:
|
||||
push esi edi ecx
|
||||
mov esi,512
|
||||
imul esi,[eax+8]
|
||||
add esi,CDDataBuf
|
||||
mov ecx,512/4
|
||||
cld
|
||||
rep movsd
|
||||
pop ecx edi esi
|
||||
|
||||
mov eax, [esp+28]
|
||||
mov ecx, [eax]
|
||||
sub ecx, 512
|
||||
jae @f
|
||||
lea edi, [edi+ecx+512]
|
||||
neg ecx
|
||||
push eax
|
||||
xor eax, eax
|
||||
rep stosb
|
||||
pop eax
|
||||
@@:
|
||||
mov [eax], ecx
|
||||
mov edx, [eax+8]
|
||||
inc edx
|
||||
cmp edx, 4 ; 2048/512=4
|
||||
jb @f
|
||||
xor edx, edx
|
||||
@@:
|
||||
mov [eax+8], edx
|
||||
popad
|
||||
xor eax, eax
|
||||
ret
|
||||
.eof:
|
||||
popad
|
||||
mov eax, 6
|
||||
ret
|
||||
.err:
|
||||
popad
|
||||
mov eax, 11
|
||||
ret
|
||||
|
||||
cd_find_lfn:
|
||||
; in: esi->name
|
||||
; out: CF=1 - file not found
|
||||
; else CF=0 and [cd_current_pointer_of_input] direntry
|
||||
push eax esi
|
||||
; 16 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ
|
||||
mov [CDSectorAddress],dword 15
|
||||
.start:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
; ïðîâåðêà íà âøèâîñòü
|
||||
cmp [CDDataBuf+1],dword 'CD00'
|
||||
jne .access_denied
|
||||
cmp [CDDataBuf+5],byte '1'
|
||||
jne .access_denied
|
||||
; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ?
|
||||
cmp [CDDataBuf],byte 0xff
|
||||
je .access_denied
|
||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà?
|
||||
cmp [CDDataBuf],byte 0x2
|
||||
jne .start
|
||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà?
|
||||
cmp [CDDataBuf+6],byte 0x1
|
||||
jne .start
|
||||
; ïàðàìåòðû root äèðåêòðîðèè
|
||||
mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè
|
||||
mov [CDSectorAddress],eax
|
||||
mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov [cd_current_pointer_of_input],CDDataBuf+0x9c
|
||||
jmp .done
|
||||
@@:
|
||||
; íà÷èíàåì ïîèñê
|
||||
.mainloop:
|
||||
dec dword [CDSectorAddress]
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
call cd_find_name_in_buffer
|
||||
jnc .found
|
||||
sub eax,2048
|
||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||
cmp eax,0
|
||||
ja .read_to_buffer
|
||||
; íåò èñêîìîãî ýëåìåíòà öåïî÷êè
|
||||
.access_denied:
|
||||
pop esi eax
|
||||
stc
|
||||
ret
|
||||
; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí
|
||||
.found:
|
||||
; êîíåö ïóòè ôàéëà
|
||||
cmp byte [esi-1], 0
|
||||
jz .done
|
||||
mov eax,[cd_current_pointer_of_input]
|
||||
add eax,2
|
||||
mov eax,[eax]
|
||||
mov [CDSectorAddress],eax ; íà÷àëî äèðåêòîðèè
|
||||
add eax,8
|
||||
mov eax,[eax] ; ðàçìåð äèðåêòîðèè
|
||||
jmp .mainloop
|
||||
; óêàçàòåëü ôàéëà íàéäåí
|
||||
.done:
|
||||
pop esi eax
|
||||
clc
|
||||
ret
|
||||
|
||||
cd_find_name_in_buffer:
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
.start:
|
||||
call cd_get_name
|
||||
jc .not_found
|
||||
call cd_compare_name
|
||||
jc .start
|
||||
.found:
|
||||
clc
|
||||
ret
|
||||
.not_found:
|
||||
stc
|
||||
ret
|
||||
|
||||
cd_get_name:
|
||||
push eax
|
||||
mov ebp,[cd_current_pointer_of_input_2]
|
||||
mov [cd_current_pointer_of_input],ebp
|
||||
mov eax,[ebp]
|
||||
cmp eax,0 ; âõîäû çàêîí÷èëèñü?
|
||||
je .next_sector
|
||||
cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ?
|
||||
jae .next_sector
|
||||
movzx eax, byte [ebp]
|
||||
add [cd_current_pointer_of_input_2],eax ; ñëåäóþùèé âõîä êàòàëîãà
|
||||
add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè
|
||||
pop eax
|
||||
clc
|
||||
ret
|
||||
.next_sector:
|
||||
pop eax
|
||||
stc
|
||||
ret
|
||||
|
||||
cd_compare_name:
|
||||
; compares ASCIIZ-names, case-insensitive (cp866 encoding)
|
||||
; in: esi->name, ebp->name
|
||||
; out: if names match: ZF=1 and esi->next component of name
|
||||
; else: ZF=0, esi is not changed
|
||||
; destroys eax
|
||||
push esi eax edi
|
||||
mov edi,ebp
|
||||
.loop:
|
||||
cld
|
||||
lodsb
|
||||
push ax
|
||||
call char_todown
|
||||
call ansi2uni_char
|
||||
xchg ah,al
|
||||
cld
|
||||
scasw
|
||||
pop ax
|
||||
je .coincides
|
||||
call char_toupper
|
||||
call ansi2uni_char
|
||||
xchg ah,al
|
||||
cld
|
||||
sub edi,2
|
||||
scasw
|
||||
jne .name_not_coincide
|
||||
.coincides:
|
||||
cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
jmp .loop
|
||||
.name_not_coincide:
|
||||
pop edi eax esi
|
||||
stc
|
||||
ret
|
||||
.done:
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .done_1
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp edi,eax
|
||||
je .done_1
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp edi,eax
|
||||
jne .name_not_coincide
|
||||
.done_1:
|
||||
pop edi eax
|
||||
add esp,4
|
||||
inc esi
|
||||
clc
|
||||
ret
|
||||
|
||||
char_todown:
|
||||
; convert character to uppercase, using cp866 encoding
|
||||
; in: al=symbol
|
||||
; out: al=converted symbol
|
||||
cmp al, 'A'
|
||||
jb .ret
|
||||
cmp al, 'Z'
|
||||
jbe .az
|
||||
cmp al, '€'
|
||||
jb .ret
|
||||
cmp al, '<27>'
|
||||
jb .rus1
|
||||
cmp al, 'Ÿ'
|
||||
ja .ret
|
||||
; 0x90-0x9F -> 0xE0-0xEF
|
||||
add al, 'à'-'<27>'
|
||||
.ret:
|
||||
ret
|
||||
.rus1:
|
||||
; 0x80-0x8F -> 0xA0-0xAF
|
||||
.az:
|
||||
add al, 0x20
|
||||
ret
|
||||
|
||||
uni2ansi_char:
|
||||
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
|
||||
; in: ax=UNICODE character
|
||||
; out: al=converted ANSI character
|
||||
cmp ax, 0x80
|
||||
jb .ascii
|
||||
cmp ax, 0x401
|
||||
jz .yo1
|
||||
cmp ax, 0x451
|
||||
jz .yo2
|
||||
cmp ax, 0x410
|
||||
jb .unk
|
||||
cmp ax, 0x440
|
||||
jb .rus1
|
||||
cmp ax, 0x450
|
||||
jb .rus2
|
||||
.unk:
|
||||
mov al, '_'
|
||||
jmp .doit
|
||||
.yo1:
|
||||
mov al, 'ð'
|
||||
jmp .doit
|
||||
.yo2:
|
||||
mov al, 'ñ'
|
||||
jmp .doit
|
||||
.rus1:
|
||||
; 0x410-0x43F -> 0x80-0xAF
|
||||
add al, 0x70
|
||||
jmp .doit
|
||||
.rus2:
|
||||
; 0x440-0x44F -> 0xE0-0xEF
|
||||
add al, 0xA0
|
||||
.ascii:
|
||||
.doit:
|
||||
ret
|
||||
351
kernel/branches/gfx_kernel/fs/part_set.inc
Normal file
351
kernel/branches/gfx_kernel/fs/part_set.inc
Normal file
@@ -0,0 +1,351 @@
|
||||
;*************************************************************
|
||||
;* 29.04.2006 Elimination of hangup after the *
|
||||
;* expiration hd_wait_timeout - Mario79 *
|
||||
;* 28.01.2006 find all Fat16/32 partition in all input point *
|
||||
;* to MBR - Mario79 *
|
||||
;*************************************************************
|
||||
|
||||
align 4
|
||||
;******************************************************
|
||||
; Please do not change this place - variables in text
|
||||
; Mario79
|
||||
; START place
|
||||
;******************************************************
|
||||
PARTITION_START dd 0x3f
|
||||
PARTITION_END dd 0
|
||||
SECTORS_PER_FAT dd 0x1f3a
|
||||
NUMBER_OF_FATS dd 0x2
|
||||
SECTORS_PER_CLUSTER dd 0x8
|
||||
BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes
|
||||
ROOT_CLUSTER dd 2 ; first rootdir cluster
|
||||
FAT_START dd 0 ; start of fat table
|
||||
ROOT_START dd 0 ; start of rootdir (only fat16)
|
||||
ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16)
|
||||
DATA_START dd 0 ; start of data area (=first cluster 2)
|
||||
LAST_CLUSTER dd 0 ; last availabe cluster
|
||||
ADR_FSINFO dd 0 ; used only by fat32
|
||||
|
||||
fatRESERVED dd 0x0FFFFFF6
|
||||
fatBAD dd 0x0FFFFFF7
|
||||
fatEND dd 0x0FFFFFF8
|
||||
fatMASK dd 0x0FFFFFFF
|
||||
|
||||
fat_type db 0 ; 0=none, 16=fat16, 32=fat32
|
||||
;***************************************************************************
|
||||
; End place
|
||||
; Mario79
|
||||
;***************************************************************************
|
||||
|
||||
iglobal
|
||||
partition_types: ; list of fat16/32 partitions
|
||||
db 0x04 ; DOS: fat16 <32M
|
||||
db 0x06 ; DOS: fat16 >32M
|
||||
db 0x0b ; WIN95: fat32
|
||||
db 0x0c ; WIN95: fat32, LBA-mapped
|
||||
db 0x0e ; WIN95: fat16, LBA-mapped
|
||||
db 0x14 ; Hidden DOS: fat16 <32M
|
||||
db 0x16 ; Hidden DOS: fat16 >32M
|
||||
db 0x1b ; Hidden WIN95: fat32
|
||||
db 0x1c ; Hidden WIN95: fat32, LBA-mapped
|
||||
db 0x1e ; Hidden WIN95: fat16, LBA-mapped
|
||||
db 0xc4 ; DRDOS/secured: fat16 <32M
|
||||
db 0xc6 ; DRDOS/secured: fat16 >32M
|
||||
db 0xcb ; DRDOS/secured: fat32
|
||||
db 0xcc ; DRDOS/secured: fat32, LBA-mapped
|
||||
db 0xce ; DRDOS/secured: fat16, LBA-mapped
|
||||
db 0xd4 ; Old Multiuser DOS secured: fat16 <32M
|
||||
db 0xd6 ; Old Multiuser DOS secured: fat16 >32M
|
||||
partition_types_end:
|
||||
|
||||
|
||||
extended_types: ; list of extended partitions
|
||||
db 0x05 ; DOS: extended partition
|
||||
db 0x0f ; WIN95: extended partition, LBA-mapped
|
||||
db 0xc5 ; DRDOS/secured: extended partition
|
||||
db 0xd5 ; Old Multiuser DOS secured: extended partition
|
||||
extended_types_end:
|
||||
|
||||
endg
|
||||
|
||||
; Partition chain used:
|
||||
; MBR ; PARTITION2 ; PARTITION3 ; PARTITION4
|
||||
;==========================================================
|
||||
; fat16/32 +-- fat16/32 +-- fat16/32 +-- fat16/32 +--
|
||||
; extended --+ extended --+ extended --+ extended --+
|
||||
; 0 0 0 0
|
||||
; 0 0 0 0
|
||||
; Notes:
|
||||
; - extended partition need to be in second entry on table
|
||||
; - it will skip over removed partitions
|
||||
|
||||
set_FAT32_variables:
|
||||
mov [0xfe10],dword 0 ; entries in hd cache
|
||||
mov [problem_partition],0
|
||||
call reserve_hd1
|
||||
call clear_hd_cache
|
||||
|
||||
cmp dword [hdpos],0
|
||||
je problem_hd
|
||||
|
||||
pushad
|
||||
xor ecx,ecx ; partition count
|
||||
mov edx,-1 ; flag for partition
|
||||
xor eax,eax ; read MBR
|
||||
xor ebp,ebp ; extended partition start
|
||||
|
||||
new_partition:
|
||||
test ebp,ebp ; is there extended partition?
|
||||
jnz extended_already_set ; yes
|
||||
xchg ebp,eax ; no. set it now
|
||||
|
||||
extended_already_set:
|
||||
add eax,ebp ; mbr=mbr+0, ext_part=ext_start+relat_start
|
||||
mov ebx,buffer
|
||||
call hd_read
|
||||
cmp [hd_error],0
|
||||
jne problem_hd
|
||||
|
||||
cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector?
|
||||
jnz end_partition_chain
|
||||
cmp dword [ebx+0x1be+0xc],0 ; skip over empty partition
|
||||
jz next_partition
|
||||
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4] ; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_primary_partition ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_primary_partition ; no
|
||||
|
||||
mov edx,eax ; start sector
|
||||
add edx,[ebx+0x1be+8] ; add relative start
|
||||
|
||||
next_primary_partition:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4+16] ; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_primary_partition_1 ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_primary_partition_1 ; no
|
||||
|
||||
mov edx,eax ; start sector
|
||||
add edx,[ebx+0x1be+8+16] ; add relative start
|
||||
|
||||
next_primary_partition_1:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4+16+16] ; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_primary_partition_2 ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_primary_partition_2 ; no
|
||||
|
||||
mov edx,eax ; start sector
|
||||
add edx,[ebx+0x1be+8+16+16] ; add relative start
|
||||
|
||||
next_primary_partition_2:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4+16+16+16] ; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_partition ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_partition ; no
|
||||
|
||||
mov edx,eax ; start sector
|
||||
add edx,[ebx+0x1be+8+16+16+16] ; add relative start
|
||||
|
||||
next_partition:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4] ; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz next_partition_1
|
||||
|
||||
mov eax,[ebx+0x1be+8] ; add relative start
|
||||
test eax,eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
|
||||
next_partition_1:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4+16] ; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz next_partition_2
|
||||
|
||||
mov eax,[ebx+0x1be+8+16] ; add relative start
|
||||
test eax,eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
|
||||
next_partition_2:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4+16+16] ; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz next_partition_3
|
||||
|
||||
mov eax,[ebx+0x1be+8+16+16] ; add relative start
|
||||
test eax,eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
|
||||
next_partition_3:
|
||||
push eax
|
||||
mov al,[ebx+0x1be+4+16+16+16] ; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz end_partition_chain ; no. end chain
|
||||
|
||||
mov eax,[ebx+0x1be+8+16+16+16] ; get start of extended partition
|
||||
test eax,eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
|
||||
end_partition_chain:
|
||||
mov [partition_count],ecx
|
||||
|
||||
cmp edx,-1 ; found wanted partition?
|
||||
jnz hd_and_partition_ok ; yes. install it
|
||||
jmp problem_partition_or_fat
|
||||
|
||||
scan_partition_types:
|
||||
push ecx
|
||||
mov edi,partition_types
|
||||
mov ecx,partition_types_end-partition_types
|
||||
cld
|
||||
repne scasb ; is partition type ok?
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
scan_extended_types:
|
||||
push ecx
|
||||
mov edi,extended_types
|
||||
mov ecx,extended_types_end-extended_types
|
||||
cld
|
||||
repne scasb ; is it extended partition?
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
problem_fat_dec_count: ; bootsector is missing or another problem
|
||||
dec [partition_count] ; remove it from partition_count
|
||||
|
||||
problem_partition_or_fat:
|
||||
popad
|
||||
|
||||
problem_hd:
|
||||
mov [fat_type],0
|
||||
mov [hd1_status],0 ; free
|
||||
mov [problem_partition],1
|
||||
ret
|
||||
|
||||
hd_and_partition_ok:
|
||||
mov eax,edx
|
||||
mov [PARTITION_START],eax
|
||||
|
||||
mov [hd_setup],1
|
||||
mov ebx,buffer
|
||||
call hd_read ; read boot sector of partition
|
||||
cmp [hd_error],0
|
||||
jne problem_fat_dec_count
|
||||
|
||||
mov [hd_setup],0
|
||||
|
||||
cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector?
|
||||
jnz problem_fat_dec_count
|
||||
|
||||
movzx eax,word [ebx+0xe] ; sectors reserved
|
||||
add eax,[PARTITION_START]
|
||||
mov [FAT_START],eax ; fat_start = partition_start + reserved
|
||||
|
||||
movzx eax,byte [ebx+0xd] ; sectors per cluster
|
||||
mov [SECTORS_PER_CLUSTER],eax
|
||||
|
||||
movzx ecx,word [ebx+0xb] ; bytes per sector
|
||||
mov [BYTES_PER_SECTOR],ecx
|
||||
|
||||
movzx eax,word [ebx+0x11] ; count of rootdir entries (=0 fat32)
|
||||
mov edx,32
|
||||
mul edx
|
||||
dec ecx
|
||||
add eax,ecx ; round up if not equal count
|
||||
inc ecx ; bytes per sector
|
||||
div ecx
|
||||
mov [ROOT_SECTORS],eax ; count of rootdir sectors
|
||||
|
||||
movzx eax,word [ebx+0x16] ; sectors per fat <65536
|
||||
test eax,eax
|
||||
jnz fat16_fatsize
|
||||
mov eax,[ebx+0x24] ; sectors per fat
|
||||
fat16_fatsize:
|
||||
mov [SECTORS_PER_FAT],eax
|
||||
|
||||
movzx eax,byte [ebx+0x10] ; number of fats
|
||||
test eax,eax ; if 0 it's not fat partition
|
||||
jz problem_fat_dec_count
|
||||
mov [NUMBER_OF_FATS],eax
|
||||
imul eax,[SECTORS_PER_FAT]
|
||||
add eax,[FAT_START]
|
||||
mov [ROOT_START],eax ; rootdir = fat_start + fat_size * fat_count
|
||||
add eax,[ROOT_SECTORS] ; rootdir sectors should be 0 on fat32
|
||||
mov [DATA_START],eax ; data area = rootdir + rootdir_size
|
||||
|
||||
movzx eax,word [ebx+0x13] ; total sector count <65536
|
||||
test eax,eax
|
||||
jnz fat16_total
|
||||
mov eax,[ebx+0x20] ; total sector count
|
||||
fat16_total:
|
||||
add eax,[PARTITION_START]
|
||||
dec eax
|
||||
mov [PARTITION_END],eax
|
||||
inc eax
|
||||
sub eax,[DATA_START] ; eax = count of data sectors
|
||||
xor edx,edx
|
||||
div dword [SECTORS_PER_CLUSTER]
|
||||
inc eax
|
||||
mov [LAST_CLUSTER],eax
|
||||
dec eax ; cluster count
|
||||
|
||||
; limits by Microsoft Hardware White Paper v1.03
|
||||
cmp eax,4085 ; 0xff5
|
||||
jb problem_fat_dec_count ; fat12 not supported
|
||||
cmp eax,65525 ; 0xfff5
|
||||
jb fat16_partition
|
||||
|
||||
fat32_partition:
|
||||
mov eax,[ebx+0x2c] ; rootdir cluster
|
||||
mov [ROOT_CLUSTER],eax
|
||||
movzx eax,word [ebx+0x30] ; fs info sector
|
||||
add eax,[PARTITION_START]
|
||||
mov [ADR_FSINFO],eax
|
||||
|
||||
popad
|
||||
|
||||
mov [fatRESERVED],0x0FFFFFF6
|
||||
mov [fatBAD],0x0FFFFFF7
|
||||
mov [fatEND],0x0FFFFFF8
|
||||
mov [fatMASK],0x0FFFFFFF
|
||||
mov [fat_type],32 ; Fat32
|
||||
mov [hd1_status],0 ; free
|
||||
ret
|
||||
|
||||
fat16_partition:
|
||||
xor eax,eax
|
||||
mov [ROOT_CLUSTER],eax
|
||||
|
||||
popad
|
||||
|
||||
mov [fatRESERVED],0x0000FFF6
|
||||
mov [fatBAD],0x0000FFF7
|
||||
mov [fatEND],0x0000FFF8
|
||||
mov [fatMASK],0x0000FFFF
|
||||
mov [fat_type],16 ; Fat16
|
||||
mov [hd1_status],0 ; free
|
||||
ret
|
||||
649
kernel/branches/gfx_kernel/gui/button.inc
Normal file
649
kernel/branches/gfx_kernel/gui/button.inc
Normal file
@@ -0,0 +1,649 @@
|
||||
max_buttons=4095
|
||||
dececx:
|
||||
push edx
|
||||
push ecx
|
||||
|
||||
mov edx,2
|
||||
.loop:
|
||||
|
||||
cmp byte [esp+edx],0x20
|
||||
jae @f
|
||||
mov [esp+edx],byte 0x20
|
||||
@@:
|
||||
sub [esp+edx],byte 0x20
|
||||
|
||||
dec edx
|
||||
jns .loop
|
||||
|
||||
pop ecx
|
||||
pop edx
|
||||
ret
|
||||
|
||||
incecx:
|
||||
push edx
|
||||
push ecx
|
||||
|
||||
mov edx,2
|
||||
.loop:
|
||||
|
||||
cmp byte [esp+edx],0xdf
|
||||
jbe @f
|
||||
mov [esp+edx],byte 0xdf
|
||||
@@:
|
||||
add [esp+edx],byte 0x20
|
||||
|
||||
dec edx
|
||||
jns .loop
|
||||
pop ecx
|
||||
pop edx
|
||||
ret
|
||||
|
||||
incecx2:
|
||||
push edx
|
||||
push ecx
|
||||
|
||||
mov edx,2
|
||||
.loop:
|
||||
|
||||
cmp byte [esp+edx],0xeb
|
||||
jbe @f
|
||||
mov [esp+edx],byte 0xeb
|
||||
@@:
|
||||
add [esp+edx],byte 0x14
|
||||
|
||||
dec edx
|
||||
jns .loop
|
||||
pop ecx
|
||||
pop edx
|
||||
ret
|
||||
|
||||
drawbuttonframes:
|
||||
|
||||
push esi
|
||||
push edi
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
shr eax,16
|
||||
shr ebx,16
|
||||
mov edx,[0x3010]
|
||||
|
||||
add eax,[edx-twdw + WDATA.box.left]
|
||||
add ebx,[edx-twdw + WDATA.box.top]
|
||||
mov cx,ax
|
||||
mov dx,bx
|
||||
shl eax,16
|
||||
shl ebx,16
|
||||
mov ax,cx
|
||||
mov bx,dx
|
||||
add ax,word [esp+12]
|
||||
mov esi,ebx
|
||||
mov edi,0
|
||||
mov ecx,[esp+0]
|
||||
call incecx
|
||||
call [draw_line]
|
||||
|
||||
movzx edx,word [esp+8]
|
||||
add ebx,edx
|
||||
shl edx,16
|
||||
add ebx,edx
|
||||
mov ecx,[esp+0]
|
||||
call dececx
|
||||
call [draw_line]
|
||||
|
||||
mov ebx,esi
|
||||
push edx
|
||||
mov edx,eax
|
||||
shr edx,16
|
||||
mov ax,dx
|
||||
mov edx,ebx
|
||||
shr edx,16
|
||||
mov bx,dx
|
||||
mov dx,[esp+8+4]
|
||||
add bx,dx
|
||||
pop edx
|
||||
mov edi,0
|
||||
mov ecx,[esp+0]
|
||||
call incecx
|
||||
call [draw_line]
|
||||
|
||||
mov esi,edx
|
||||
mov dx,[esp+12]
|
||||
add ax,dx
|
||||
shl edx,16
|
||||
add eax,edx
|
||||
add ebx,1*65536
|
||||
mov edx,esi
|
||||
mov ecx,[esp+0]
|
||||
call dececx
|
||||
call [draw_line]
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
pop edi
|
||||
pop esi
|
||||
|
||||
ret
|
||||
|
||||
button_dececx:
|
||||
|
||||
cmp [buttontype],dword 1
|
||||
jne .finish
|
||||
; je bdece
|
||||
; ret
|
||||
; bdece:
|
||||
push eax
|
||||
mov eax,0x01
|
||||
cmp edi,20
|
||||
jg @f
|
||||
mov eax,0x02
|
||||
@@:
|
||||
test ecx,0xff
|
||||
jz @f
|
||||
sub ecx,eax
|
||||
@@:
|
||||
shl eax,8
|
||||
test ecx,0xff00
|
||||
jz @f
|
||||
sub ecx,eax
|
||||
@@:
|
||||
shl eax,8
|
||||
test ecx,0xff0000
|
||||
jz @f
|
||||
sub ecx,eax
|
||||
@@:
|
||||
pop eax
|
||||
.finish:
|
||||
ret
|
||||
|
||||
|
||||
sys_button:
|
||||
|
||||
push edi
|
||||
mov edi,[0x3000]
|
||||
shl edi,8
|
||||
rol eax,16
|
||||
add ax,word[edi+0x80000+APPDATA.wnd_clientbox.left]
|
||||
rol eax,16
|
||||
rol ebx,16
|
||||
add bx,word[edi+0x80000+APPDATA.wnd_clientbox.top]
|
||||
rol ebx,16
|
||||
pop edi
|
||||
.forced:
|
||||
|
||||
test ecx,0x80000000
|
||||
jnz remove_button
|
||||
|
||||
push esi
|
||||
push edi
|
||||
push eax ; <x,xs>
|
||||
push ebx ; <y,ys>
|
||||
push ecx ; <id>
|
||||
push edx
|
||||
|
||||
or ax,ax
|
||||
jle noaddbutt
|
||||
or bx,bx
|
||||
jle noaddbutt
|
||||
|
||||
test ecx,0x40000000
|
||||
jnz button_no_draw
|
||||
|
||||
pushad ; button body
|
||||
push ebx
|
||||
sar eax,16
|
||||
sar ebx,16
|
||||
mov edx,[0x3010]
|
||||
mov esi,[edx-twdw + WDATA.box.left]
|
||||
mov edi,[edx-twdw + WDATA.box.top]
|
||||
add eax,esi
|
||||
add ebx,edi
|
||||
mov cx,ax
|
||||
mov dx,bx
|
||||
shl eax,16
|
||||
shl ebx,16
|
||||
mov ax,cx
|
||||
mov bx,dx
|
||||
add ax,[4+32+esp+12]
|
||||
mov ecx,[4+32+esp+0]
|
||||
cmp [buttontype],dword 0
|
||||
je @f
|
||||
call incecx2
|
||||
@@:
|
||||
movzx edi,word [esp]
|
||||
|
||||
pop edx
|
||||
and edx, 0xFFFF
|
||||
|
||||
.newline:
|
||||
call button_dececx
|
||||
push edi
|
||||
xor edi, edi
|
||||
call [draw_line]
|
||||
pop edi
|
||||
inc bx
|
||||
rol ebx,16
|
||||
inc bx
|
||||
dec edx
|
||||
jnz .newline
|
||||
popad
|
||||
|
||||
call drawbuttonframes
|
||||
|
||||
button_no_draw:
|
||||
|
||||
and ecx,0xffff
|
||||
|
||||
mov edi,[0xfe88]
|
||||
movzx eax,word [edi]
|
||||
cmp eax,max_buttons
|
||||
jge noaddbutt
|
||||
inc eax
|
||||
mov [edi],ax
|
||||
|
||||
shl eax,4
|
||||
add eax,edi
|
||||
|
||||
mov bx,[0x3000]
|
||||
mov [eax],bx
|
||||
|
||||
add eax,2 ; save button id number
|
||||
mov ebx,[esp+4]
|
||||
mov [eax],bx ; bits 0-15
|
||||
shr ebx,16
|
||||
mov [eax-2+0xc],bx; bits 16-31
|
||||
add eax,2 ; x start
|
||||
mov bx,[esp+12+2]
|
||||
mov [eax],bx
|
||||
add eax,2 ; x size
|
||||
mov bx,[esp+12+0]
|
||||
mov [eax],bx
|
||||
add eax,2 ; y start
|
||||
mov bx,[esp+8+2]
|
||||
mov [eax],bx
|
||||
add eax,2 ; y size
|
||||
mov bx,[esp+8+0]
|
||||
mov [eax],bx
|
||||
|
||||
noaddbutt:
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
pop edi
|
||||
pop esi
|
||||
|
||||
ret
|
||||
|
||||
|
||||
remove_button:
|
||||
|
||||
and ecx,0x7fffffff
|
||||
|
||||
rnewba2:
|
||||
|
||||
mov edi,[0xfe88]
|
||||
mov eax,edi
|
||||
movzx ebx,word [edi]
|
||||
inc bx
|
||||
|
||||
rnewba:
|
||||
|
||||
dec bx
|
||||
jz rnmba
|
||||
|
||||
add eax,0x10
|
||||
|
||||
mov dx,[0x3000]
|
||||
cmp dx,[eax]
|
||||
jnz rnewba
|
||||
|
||||
cmp cx,[eax+2]
|
||||
jnz rnewba
|
||||
|
||||
pushad
|
||||
mov ecx,ebx
|
||||
inc ecx
|
||||
shl ecx,4
|
||||
mov ebx,eax
|
||||
add eax,0x10
|
||||
call memmove
|
||||
dec dword [edi]
|
||||
popad
|
||||
|
||||
jmp rnewba2
|
||||
|
||||
rnmba:
|
||||
|
||||
ret
|
||||
|
||||
find_pressed_button_frames:
|
||||
|
||||
pushad
|
||||
|
||||
movzx ebx,word [eax+0]
|
||||
shl ebx,5
|
||||
add ebx,window_data
|
||||
mov ecx, [ebx+ WDATA.box.left] ; window x start
|
||||
movsx edx,word [eax+4] ; button x start
|
||||
add ecx,edx
|
||||
push ecx
|
||||
|
||||
movzx edx,word[eax+6] ; button x size
|
||||
add ecx,edx
|
||||
mov esi,ecx
|
||||
inc esi
|
||||
mov ecx, [ebx+WDATA.box.top] ; window y start
|
||||
movsx edx,word[eax+8] ; button y start
|
||||
add ecx,edx
|
||||
mov ebx,ecx
|
||||
movzx edx,word[eax+10] ; button y size
|
||||
add edx,ecx
|
||||
inc edx
|
||||
|
||||
pop eax
|
||||
|
||||
; eax x beginning
|
||||
; ebx y beginning
|
||||
; esi x end
|
||||
; edx y end
|
||||
; ecx color
|
||||
|
||||
mov [pressed_button_eax],eax
|
||||
mov [pressed_button_ebx],ebx
|
||||
mov [pressed_button_ecx],ecx
|
||||
mov [pressed_button_edx],edx
|
||||
mov [pressed_button_esi],esi
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
uglobal
|
||||
pressed_button_eax dd 0
|
||||
pressed_button_ebx dd 0
|
||||
pressed_button_ecx dd 0
|
||||
pressed_button_edx dd 0
|
||||
pressed_button_esi dd 0
|
||||
endg
|
||||
|
||||
; negative button image
|
||||
|
||||
negativebutton:
|
||||
; If requested, do not display button
|
||||
; boarder on press.
|
||||
test ebx,0x20000000
|
||||
jz draw_negative_button
|
||||
ret
|
||||
draw_negative_button:
|
||||
|
||||
pushad
|
||||
|
||||
mov eax,[pressed_button_eax]
|
||||
mov ebx,[pressed_button_ebx]
|
||||
mov ecx,[pressed_button_ecx]
|
||||
mov edx,[pressed_button_edx]
|
||||
mov esi,[pressed_button_esi]
|
||||
mov ecx,0x01000000
|
||||
|
||||
dec edx
|
||||
push edx
|
||||
inc edx
|
||||
dec esi
|
||||
push esi
|
||||
inc esi
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
|
||||
call [disable_mouse]
|
||||
|
||||
bdbnewline:
|
||||
mov edi,1 ; force
|
||||
cmp eax,[esp+16]
|
||||
jz bneg
|
||||
cmp eax,[esp+20]
|
||||
jz bneg
|
||||
cmp ebx,[esp+12]
|
||||
jz bneg
|
||||
cmp ebx,[esp+24]
|
||||
jnz nbneg
|
||||
; jz bneg
|
||||
; jmp nbneg
|
||||
|
||||
bneg:
|
||||
|
||||
;;;call [disable_mouse]
|
||||
call [putpixel]
|
||||
|
||||
nbneg:
|
||||
|
||||
inc eax
|
||||
cmp eax,esi
|
||||
jnz bdbnewline
|
||||
mov eax,[esp+16]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jnz bdbnewline
|
||||
|
||||
add esp,28
|
||||
|
||||
popad
|
||||
|
||||
ret
|
||||
|
||||
; check buttons
|
||||
|
||||
|
||||
; 0000 word process number
|
||||
; 0002 word button id number : bits 0-15
|
||||
; 0004 word x start
|
||||
; 0006 word x size
|
||||
; 0008 word y start
|
||||
; 000A word y size
|
||||
; 000C word button id number : bits 16-31
|
||||
;
|
||||
; button table in 0x10 increments
|
||||
;
|
||||
; first at 0x10
|
||||
|
||||
|
||||
checkbuttons:
|
||||
|
||||
cmp [0xfb40],byte 0 ; mouse buttons pressed
|
||||
jnz @f
|
||||
ret
|
||||
@@:
|
||||
|
||||
pushad
|
||||
|
||||
xor esi, esi
|
||||
mov edi, [0xfe88]
|
||||
movzx edx, word [edi]
|
||||
test edx, edx
|
||||
jne @f
|
||||
popad
|
||||
ret
|
||||
|
||||
@@:
|
||||
|
||||
push esi
|
||||
inc edx
|
||||
push edx
|
||||
|
||||
buttonnewcheck:
|
||||
|
||||
pop edx
|
||||
pop esi
|
||||
inc esi
|
||||
cmp edx,esi
|
||||
jge bch
|
||||
|
||||
popad ; no button pressed
|
||||
ret
|
||||
|
||||
bch:
|
||||
|
||||
push esi
|
||||
push edx
|
||||
mov eax,esi
|
||||
shl eax,4
|
||||
add eax,edi
|
||||
|
||||
;......................start 1/2 : modified by vhanla .............................
|
||||
mov [buttonid],eax
|
||||
;......................end 1/2 : modified by vhanla .............................
|
||||
|
||||
; check that button is at top of windowing stack
|
||||
|
||||
movzx ebx,word [eax]
|
||||
movzx ecx,word [0xC000 + ebx * 2]
|
||||
cmp ecx,[0x3004]
|
||||
jne buttonnewcheck
|
||||
|
||||
; check that button start is inside window x/y end
|
||||
|
||||
movzx ebx,word [eax+0]
|
||||
shl ebx,5
|
||||
|
||||
test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
|
||||
jnz buttonnewcheck
|
||||
|
||||
; add ebx,window_data
|
||||
; mov ecx,[window_data+ebx+8] ; window end X
|
||||
movsx edx,word [eax+4] ; button start X
|
||||
cmp edx, [window_data+ebx+WDATA.box.width] ;ecx
|
||||
jge buttonnewcheck
|
||||
|
||||
; mov ecx,[window_data+ebx+12] ; window end Y
|
||||
movsx edx, word [eax+8] ; button start Y
|
||||
cmp edx, [window_data+ebx+WDATA.box.height] ;ecx
|
||||
jge buttonnewcheck
|
||||
|
||||
; check coordinates
|
||||
; mouse x >= button x ?
|
||||
movzx ebx,word [eax+0]
|
||||
shl ebx,5
|
||||
add ebx,window_data
|
||||
mov ecx, [ebx+WDATA.box.left] ; window x start
|
||||
movsx edx,word [eax+4] ; button x start
|
||||
add edx,ecx
|
||||
movzx ecx,word[0xfb0a]
|
||||
cmp ecx,edx
|
||||
jl buttonnewcheck
|
||||
|
||||
movzx ebx,word [eax+6] ; button x size
|
||||
add edx,ebx
|
||||
cmp ecx,edx
|
||||
jg buttonnewcheck
|
||||
|
||||
; mouse y >= button y ?
|
||||
movzx ebx,word [eax+0]
|
||||
shl ebx,5
|
||||
add ebx,window_data
|
||||
mov ecx, [ebx+WDATA.box.top] ; window y start
|
||||
movsx edx,word [eax+8] ; button y start
|
||||
add edx,ecx
|
||||
movzx ecx,word[0xfb0c]
|
||||
cmp ecx,edx
|
||||
jl buttonnewcheck
|
||||
|
||||
movzx ebx,word [eax+10] ; button y size
|
||||
add edx,ebx
|
||||
cmp ecx,edx
|
||||
jg buttonnewcheck
|
||||
|
||||
; mouse on button
|
||||
|
||||
pop edx
|
||||
pop esi
|
||||
|
||||
mov bx,[eax+0xc] ; button id : bits 16-31
|
||||
shl ebx,16
|
||||
mov bx,[eax+2] ; button id : bits 00-16
|
||||
push ebx
|
||||
|
||||
mov [0xfb44],byte 1 ; no mouse down checks
|
||||
call find_pressed_button_frames
|
||||
call negativebutton
|
||||
|
||||
pushad
|
||||
cbwaitmouseup:
|
||||
|
||||
call checkidle
|
||||
|
||||
call [draw_pointer]
|
||||
|
||||
pushad
|
||||
call stack_handler
|
||||
popad
|
||||
|
||||
cmp [0xfb40],byte 0 ; mouse buttons pressed ?
|
||||
jnz cbwaitmouseup
|
||||
popad
|
||||
|
||||
call negativebutton
|
||||
mov [0xfff4],byte 0 ; no mouse background
|
||||
mov [0xfff5],byte 0 ; draw mouse
|
||||
;..................................... start 2/2 : modified by vhanla .............................
|
||||
; check coordinates
|
||||
jmp afterbuttonid
|
||||
buttonid dd 0x0 ;here a will backup the eax value
|
||||
afterbuttonid:
|
||||
|
||||
pusha
|
||||
; mouse x >= button x ?
|
||||
movzx ebx,word [eax+0]
|
||||
shl ebx,5
|
||||
add ebx,window_data
|
||||
mov ecx, [ebx+WDATA.box.left] ; window x start
|
||||
movsx edx,word [eax+4] ; button x start
|
||||
add edx,ecx
|
||||
movzx ecx,word[0xfb0a]
|
||||
cmp edx,ecx
|
||||
jg no_on_button ;if we release the pointer out of the button area
|
||||
|
||||
movzx ebx,word [eax+6] ; button x size
|
||||
add edx,ebx
|
||||
cmp ecx,edx
|
||||
jg no_on_button
|
||||
|
||||
; mouse y >= button y ?
|
||||
movzx ebx,word [eax+0]
|
||||
shl ebx,5
|
||||
add ebx,window_data
|
||||
mov ecx, [ebx+WDATA.box.top] ; window y start
|
||||
movsx edx,word [eax+8] ; button y start
|
||||
add edx,ecx
|
||||
movzx ecx,word[0xfb0c]
|
||||
cmp edx,ecx
|
||||
jg no_on_button
|
||||
|
||||
movzx ebx,word [eax+10] ; button y size
|
||||
add edx,ebx
|
||||
cmp ecx,edx
|
||||
jg no_on_button
|
||||
popa
|
||||
mov [0xf500],byte 1 ; no of buttons in buffer
|
||||
pop ebx
|
||||
mov [0xf501],ebx ; lets put the button id in buffer
|
||||
push ebx
|
||||
pusha
|
||||
jmp yes_on_button
|
||||
no_on_button:
|
||||
mov [0xf500],byte 0 ; no of buttons in buffer
|
||||
yes_on_button:
|
||||
mov [0xfb44],byte 0 ; mouse down -> do not draw
|
||||
popa
|
||||
pop ebx
|
||||
popa
|
||||
ret
|
||||
|
||||
;..................................... end 2/2 : modified by vhanla ................................
|
||||
215
kernel/branches/gfx_kernel/gui/event.inc
Normal file
215
kernel/branches/gfx_kernel/gui/event.inc
Normal file
@@ -0,0 +1,215 @@
|
||||
sys_getevent:
|
||||
|
||||
call get_event_for_app
|
||||
mov [esp+36],eax
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
sys_wait_event_timeout:
|
||||
|
||||
mov ebx,[timer_ticks]
|
||||
add ebx,eax
|
||||
cmp ebx,[timer_ticks]
|
||||
jna .swfet2
|
||||
.swfet1:
|
||||
call get_event_for_app
|
||||
test eax,eax
|
||||
jne .eventoccur_time
|
||||
call change_task
|
||||
cmp ebx,[timer_ticks]
|
||||
jg .swfet1
|
||||
.swfet2:
|
||||
xor eax,eax
|
||||
.eventoccur_time:
|
||||
mov [esp+36],eax
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
sys_waitforevent:
|
||||
|
||||
call get_event_for_app
|
||||
test eax,eax
|
||||
jne eventoccur
|
||||
newwait:
|
||||
|
||||
mov eax, [0x3010]
|
||||
mov [eax+TASKDATA.state], byte 5
|
||||
call change_task
|
||||
|
||||
mov eax, [event_sched]
|
||||
|
||||
eventoccur:
|
||||
mov [esp+36],eax
|
||||
ret
|
||||
|
||||
|
||||
get_event_for_app:
|
||||
|
||||
pushad
|
||||
|
||||
mov edi,[0x3010] ; WINDOW REDRAW
|
||||
test [edi+TASKDATA.event_mask],dword 1
|
||||
jz no_eventoccur1
|
||||
;mov edi,[0x3010]
|
||||
cmp [edi-twdw+WDATA.fl_redraw],byte 0
|
||||
je no_eventoccur1
|
||||
popad
|
||||
mov eax,1
|
||||
ret
|
||||
no_eventoccur1:
|
||||
|
||||
;mov edi,[0x3010] ; KEY IN BUFFER
|
||||
test [edi+TASKDATA.event_mask],dword 2
|
||||
jz no_eventoccur2
|
||||
mov ecx, [0x3000]
|
||||
movzx edx,word [0xC000+ecx*2]
|
||||
mov eax, [0x3004]
|
||||
cmp eax,edx
|
||||
jne no_eventoccur2x
|
||||
cmp [0xf400],byte 0
|
||||
je no_eventoccur2x
|
||||
eventoccur2:
|
||||
popad
|
||||
mov eax,2
|
||||
ret
|
||||
no_eventoccur2x:
|
||||
mov eax, hotkey_buffer
|
||||
@@:
|
||||
cmp [eax], ecx
|
||||
jz eventoccur2
|
||||
add eax, 8
|
||||
cmp eax, hotkey_buffer+120*8
|
||||
jb @b
|
||||
no_eventoccur2:
|
||||
|
||||
;mov edi,[0x3010] ; BUTTON IN BUFFER
|
||||
test [edi+TASKDATA.event_mask],dword 4
|
||||
jz no_eventoccur3
|
||||
cmp [0xf500],byte 0
|
||||
je no_eventoccur3
|
||||
mov ecx, [0x3000]
|
||||
movzx edx, word [0xC000+ecx*2]
|
||||
mov eax, [0x3004]
|
||||
cmp eax,edx
|
||||
jnz no_eventoccur3
|
||||
popad
|
||||
mov eax,[0xf501]
|
||||
cmp eax,65535
|
||||
je no_event_1
|
||||
mov eax,3
|
||||
ret
|
||||
|
||||
no_event_1:
|
||||
mov [window_minimize],1
|
||||
mov [0xf500],byte 0
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
no_eventoccur3:
|
||||
|
||||
|
||||
;mov edi,[0x3010] ; mouse event
|
||||
test [edi+TASKDATA.event_mask],dword 00100000b
|
||||
jz no_mouse_event
|
||||
mov eax,[0x3000]
|
||||
shl eax,8
|
||||
test [eax+0x80000+APPDATA.event_mask],dword 00100000b
|
||||
jz no_mouse_event
|
||||
and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-00100000b
|
||||
popad
|
||||
mov eax,6
|
||||
ret
|
||||
no_mouse_event:
|
||||
|
||||
|
||||
;mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW
|
||||
test [edi+TASKDATA.event_mask],dword 16
|
||||
jz no_eventoccur5
|
||||
cmp [0xfff0],byte 2
|
||||
jnz no_eventoccur5
|
||||
popad
|
||||
mov eax,5
|
||||
ret
|
||||
no_eventoccur5:
|
||||
|
||||
;mov edi,[0x3010] ; IPC
|
||||
test [edi+TASKDATA.event_mask],dword 01000000b
|
||||
jz no_ipc
|
||||
mov eax,[0x3000]
|
||||
shl eax,8
|
||||
test [eax+0x80000+APPDATA.event_mask],dword 01000000b
|
||||
jz no_ipc
|
||||
and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-01000000b
|
||||
popad
|
||||
mov eax,7
|
||||
ret
|
||||
no_ipc:
|
||||
|
||||
|
||||
;mov edi,[0x3010] ; STACK
|
||||
test [edi+TASKDATA.event_mask],dword 10000000b
|
||||
jz no_stack_event
|
||||
mov eax,[0x3000]
|
||||
shl eax,8
|
||||
test [eax+0x80000+APPDATA.event_mask],dword 10000000b
|
||||
jz no_stack_event
|
||||
and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-10000000b
|
||||
popad
|
||||
mov eax,8
|
||||
ret
|
||||
no_stack_event:
|
||||
|
||||
test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG
|
||||
jz no_debug_event
|
||||
mov eax, [0x3000]
|
||||
shl eax, 8
|
||||
test byte [eax+0x80000+APPDATA.event_mask+1], byte 1
|
||||
jz no_debug_event
|
||||
and byte [eax+0x80000+APPDATA.event_mask+1], not 1
|
||||
popad
|
||||
mov eax, 9
|
||||
ret
|
||||
no_debug_event:
|
||||
|
||||
cmp dword [edi+TASKDATA.event_mask], 0xFFFF
|
||||
jbe no_events
|
||||
|
||||
mov esi,0x2e0000 ; IRQ'S AND DATA
|
||||
mov ebx,0x00010000
|
||||
xor ecx, ecx
|
||||
irq_event_test:
|
||||
mov edi,[0x3010]
|
||||
test [edi+TASKDATA.event_mask],ebx
|
||||
jz no_irq_event
|
||||
mov edi,ecx
|
||||
shl edi,2
|
||||
add edi,irq_owner
|
||||
mov edx,[edi]
|
||||
mov eax,[0x3010]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
cmp edx,eax
|
||||
jne no_irq_event
|
||||
cmp [esi],dword 0
|
||||
jz no_irq_event
|
||||
mov eax,ecx
|
||||
add eax,16
|
||||
mov [esp+28],eax
|
||||
popad
|
||||
ret
|
||||
no_irq_event:
|
||||
add esi,0x1000
|
||||
shl ebx,1
|
||||
inc ecx
|
||||
cmp ecx,16
|
||||
jb irq_event_test
|
||||
|
||||
no_events:
|
||||
popad
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
||||
107
kernel/branches/gfx_kernel/gui/font.inc
Normal file
107
kernel/branches/gfx_kernel/gui/font.inc
Normal file
@@ -0,0 +1,107 @@
|
||||
align 4
|
||||
dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org])
|
||||
; eax x & y
|
||||
; ebx style ( 0xX0000000 ) & color ( 0x00RRGGBB )
|
||||
; X = ABnnb:
|
||||
; nn = font
|
||||
; A = 0 <=> output edx characters; otherwise output ASCIIZ string
|
||||
; B = 1 <=> fill background with color esi
|
||||
; ecx start of text
|
||||
; edi 1 force
|
||||
|
||||
pushad
|
||||
call [disable_mouse]
|
||||
|
||||
mov ebp, ecx ; ebp=pointer to text
|
||||
mov ecx, ebx ; ecx=color
|
||||
movsx ebx, ax ; ebx=y
|
||||
sar eax, 16 ; eax=x
|
||||
cmp edx, 255
|
||||
jb .loop
|
||||
mov edx, 255
|
||||
.loop:
|
||||
test ecx, ecx
|
||||
js .test_asciiz
|
||||
dec edx
|
||||
js .end
|
||||
jmp @f
|
||||
.test_asciiz:
|
||||
cmp byte [ebp], 0
|
||||
jz .end
|
||||
@@:
|
||||
push edx
|
||||
movzx edx, byte [ebp]
|
||||
inc ebp
|
||||
test ecx, 0x10000000
|
||||
jnz .font2
|
||||
pushad
|
||||
mov esi, 9
|
||||
lea ebp, [0x3F600+8*edx+edx]
|
||||
.symloop1:
|
||||
mov dl, byte [ebp]
|
||||
or dl, 1 shl 6
|
||||
.pixloop1:
|
||||
shr dl, 1
|
||||
jz .pixloop1end
|
||||
jnc .nopix
|
||||
call [putpixel]
|
||||
jmp .pixloop1cont
|
||||
.nopix:
|
||||
test ecx, 0x40000000
|
||||
jz .pixloop1cont
|
||||
push ecx
|
||||
mov ecx, [esp+4+4]
|
||||
call [putpixel]
|
||||
pop ecx
|
||||
.pixloop1cont:
|
||||
inc eax
|
||||
jmp .pixloop1
|
||||
.pixloop1end:
|
||||
sub eax, 6
|
||||
inc ebx
|
||||
inc ebp
|
||||
dec esi
|
||||
jnz .symloop1
|
||||
popad
|
||||
add eax, 6
|
||||
pop edx
|
||||
jmp .loop
|
||||
.font2:
|
||||
pushad
|
||||
add edx, edx
|
||||
lea ebp, [0x3EC00+4*edx+edx+1]
|
||||
push 9
|
||||
movzx esi, byte [ebp-1]
|
||||
.symloop2:
|
||||
mov dl, byte [ebp]
|
||||
push esi
|
||||
.pixloop2:
|
||||
shr dl, 1
|
||||
jnc .nopix2
|
||||
call [putpixel]
|
||||
jmp .pixloop2cont
|
||||
.nopix2:
|
||||
test ecx, 0x40000000
|
||||
jz .pixloop2cont
|
||||
push ecx
|
||||
mov ecx, [esp+12+4]
|
||||
call [putpixel]
|
||||
pop ecx
|
||||
.pixloop2cont:
|
||||
inc eax
|
||||
dec esi
|
||||
jnz .pixloop2
|
||||
pop esi
|
||||
sub eax, esi
|
||||
inc ebx
|
||||
inc ebp
|
||||
dec dword [esp]
|
||||
jnz .symloop2
|
||||
pop eax
|
||||
add dword [esp+28], esi
|
||||
popad
|
||||
pop edx
|
||||
jmp .loop
|
||||
.end:
|
||||
popad
|
||||
ret
|
||||
11
kernel/branches/gfx_kernel/gui/mouse.inc
Normal file
11
kernel/branches/gfx_kernel/gui/mouse.inc
Normal file
@@ -0,0 +1,11 @@
|
||||
uglobal
|
||||
mouseunder:
|
||||
times 32*32*3+1 db ?
|
||||
mousecomb = $ - mouseunder
|
||||
times 32*32*3+1 db ?
|
||||
endg
|
||||
|
||||
uglobal
|
||||
mousepointer:
|
||||
times 4608 db 0 ; 32*32*4+62 = 4286
|
||||
endg
|
||||
438
kernel/branches/gfx_kernel/gui/skincode.inc
Normal file
438
kernel/branches/gfx_kernel/gui/skincode.inc
Normal file
@@ -0,0 +1,438 @@
|
||||
include "skindata.inc"
|
||||
|
||||
skin_data = 0x00778000
|
||||
|
||||
load_skin_file:
|
||||
; eax = filename
|
||||
; edx = destination
|
||||
mov ebx,1
|
||||
or ecx,-1
|
||||
mov esi,12
|
||||
call fileread
|
||||
ret
|
||||
|
||||
struct SKIN_HEADER
|
||||
.ident dd ?
|
||||
.version dd ?
|
||||
.params dd ?
|
||||
.buttons dd ?
|
||||
.bitmaps dd ?
|
||||
ends
|
||||
|
||||
struct SKIN_PARAMS
|
||||
.skin_height dd ?
|
||||
.margin.right dw ?
|
||||
.margin.left dw ?
|
||||
.margin.bottom dw ?
|
||||
.margin.top dw ?
|
||||
.colors.inner dd ?
|
||||
.colors.outer dd ?
|
||||
.colors.frame dd ?
|
||||
.colors_1.inner dd ?
|
||||
.colors_1.outer dd ?
|
||||
.colors_1.frame dd ?
|
||||
.dtp.size dd ?
|
||||
.dtp.data db 40 dup (?)
|
||||
ends
|
||||
|
||||
struct SKIN_BUTTONS
|
||||
.type dd ?
|
||||
.pos:
|
||||
.left dw ?
|
||||
.top dw ?
|
||||
.size:
|
||||
.width dw ?
|
||||
.height dw ?
|
||||
ends
|
||||
|
||||
struct SKIN_BITMAPS
|
||||
.kind dw ?
|
||||
.type dw ?
|
||||
.data dd ?
|
||||
ends
|
||||
|
||||
load_skin:
|
||||
pushad
|
||||
mov [_skinh],22
|
||||
mov eax,_skin_file
|
||||
mov edx,skin_data
|
||||
mov [edx+SKIN_HEADER.ident],'????'
|
||||
call load_skin_file
|
||||
cmp eax,ERROR_SUCCESS
|
||||
je @f
|
||||
cmp eax,ERROR_END_OF_FILE
|
||||
jne .exit
|
||||
@@: call parse_skin_data
|
||||
.exit:
|
||||
popad
|
||||
ret
|
||||
|
||||
parse_skin_data:
|
||||
mov ebp,skin_data
|
||||
cmp [ebp+SKIN_HEADER.ident],'SKIN'
|
||||
jne .exit
|
||||
|
||||
mov edi,skin_udata
|
||||
mov ecx,(skin_udata.end-skin_udata)/4
|
||||
xor eax,eax
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov ebx,[ebp+SKIN_HEADER.params]
|
||||
add ebx,skin_data
|
||||
mov eax,[ebx+SKIN_PARAMS.skin_height]
|
||||
mov [_skinh],eax
|
||||
mov eax,[ebx+SKIN_PARAMS.colors.inner]
|
||||
mov [skin_active.colors.inner],eax
|
||||
mov eax,[ebx+SKIN_PARAMS.colors.outer]
|
||||
mov [skin_active.colors.outer],eax
|
||||
mov eax,[ebx+SKIN_PARAMS.colors.frame]
|
||||
mov [skin_active.colors.frame],eax
|
||||
mov eax,[ebx+SKIN_PARAMS.colors_1.inner]
|
||||
mov [skin_inactive.colors.inner],eax
|
||||
mov eax,[ebx+SKIN_PARAMS.colors_1.outer]
|
||||
mov [skin_inactive.colors.outer],eax
|
||||
mov eax,[ebx+SKIN_PARAMS.colors_1.frame]
|
||||
mov [skin_inactive.colors.frame],eax
|
||||
lea esi,[ebx+SKIN_PARAMS.dtp.data]
|
||||
mov edi,common_colours
|
||||
mov ecx,[ebx+SKIN_PARAMS.dtp.size]
|
||||
and ecx,127
|
||||
rep movsb
|
||||
mov eax,dword[ebx+SKIN_PARAMS.margin.right]
|
||||
mov dword[_skinmargins+0],eax
|
||||
mov eax,dword[ebx+SKIN_PARAMS.margin.bottom]
|
||||
mov dword[_skinmargins+4],eax
|
||||
|
||||
mov ebx,[ebp+SKIN_HEADER.bitmaps]
|
||||
add ebx,skin_data
|
||||
.lp1: cmp dword[ebx],0
|
||||
je .end_bitmaps
|
||||
movzx eax,[ebx+SKIN_BITMAPS.kind]
|
||||
movzx ecx,[ebx+SKIN_BITMAPS.type]
|
||||
dec eax
|
||||
jnz .not_left
|
||||
xor eax,eax
|
||||
mov edx,skin_active.left.data
|
||||
or ecx,ecx
|
||||
jnz @f
|
||||
mov edx,skin_inactive.left.data
|
||||
@@: jmp .next_bitmap
|
||||
.not_left:
|
||||
dec eax
|
||||
jnz .not_oper
|
||||
mov esi,[ebx+SKIN_BITMAPS.data]
|
||||
add esi,skin_data
|
||||
mov eax,[esi+0]
|
||||
neg eax
|
||||
mov edx,skin_active.oper.data
|
||||
or ecx,ecx
|
||||
jnz @f
|
||||
mov edx,skin_inactive.oper.data
|
||||
@@: jmp .next_bitmap
|
||||
.not_oper:
|
||||
dec eax
|
||||
jnz .not_base
|
||||
mov eax,[skin_active.left.width]
|
||||
mov edx,skin_active.base.data
|
||||
or ecx,ecx
|
||||
jnz @f
|
||||
mov eax,[skin_inactive.left.width]
|
||||
mov edx,skin_inactive.base.data
|
||||
@@: jmp .next_bitmap
|
||||
.not_base:
|
||||
add ebx,8
|
||||
jmp .lp1
|
||||
.next_bitmap:
|
||||
mov ecx,[ebx+SKIN_BITMAPS.data]
|
||||
add ecx,skin_data
|
||||
mov [edx+4],eax
|
||||
mov eax,[ecx+0]
|
||||
mov [edx+8],eax
|
||||
add ecx,8
|
||||
mov [edx+0],ecx
|
||||
add ebx,8
|
||||
jmp .lp1
|
||||
.end_bitmaps:
|
||||
|
||||
mov ebx,[ebp+SKIN_HEADER.buttons]
|
||||
add ebx,skin_data
|
||||
.lp2: cmp dword[ebx],0
|
||||
je .end_buttons
|
||||
mov eax,[ebx+SKIN_BUTTONS.type]
|
||||
dec eax
|
||||
jnz .not_close
|
||||
mov edx,skin_btn_close
|
||||
jmp .next_button
|
||||
.not_close:
|
||||
dec eax
|
||||
jnz .not_minimize
|
||||
mov edx,skin_btn_minimize
|
||||
jmp .next_button
|
||||
.not_minimize:
|
||||
add ebx,12
|
||||
jmp .lp2
|
||||
.next_button:
|
||||
movsx eax,[ebx+SKIN_BUTTONS.left]
|
||||
mov [edx+SKIN_BUTTON.left],eax
|
||||
movsx eax,[ebx+SKIN_BUTTONS.top]
|
||||
mov [edx+SKIN_BUTTON.top],eax
|
||||
movsx eax,[ebx+SKIN_BUTTONS.width]
|
||||
mov [edx+SKIN_BUTTON.width],eax
|
||||
movsx eax,[ebx+SKIN_BUTTONS.height]
|
||||
mov [edx+SKIN_BUTTON.height],eax
|
||||
add ebx,12
|
||||
jmp .lp2
|
||||
.end_buttons:
|
||||
|
||||
.exit:
|
||||
ret
|
||||
|
||||
sys_putimage_with_check:
|
||||
or ebx,ebx
|
||||
jz @f
|
||||
call [putimage]
|
||||
@@: ret
|
||||
|
||||
drawwindow_IV_caption:
|
||||
|
||||
mov ebp,skin_active
|
||||
or al,al
|
||||
jnz @f
|
||||
mov ebp,skin_inactive
|
||||
@@:
|
||||
|
||||
mov esi,[esp+4]
|
||||
mov eax,[esi+WDATA.box.width] ; window width
|
||||
mov edx,[ebp+SKIN_DATA.left.left]
|
||||
shl edx,16
|
||||
mov ecx,[ebp+SKIN_DATA.left.width]
|
||||
shl ecx,16
|
||||
add ecx,[_skinh]
|
||||
|
||||
mov ebx, [ebp+SKIN_DATA.left.data]
|
||||
call sys_putimage_with_check
|
||||
|
||||
mov esi,[esp+4]
|
||||
mov eax,[esi+WDATA.box.width]
|
||||
sub eax,[ebp+SKIN_DATA.left.width]
|
||||
sub eax,[ebp+SKIN_DATA.oper.width]
|
||||
cmp eax,[ebp+SKIN_DATA.base.left]
|
||||
jng .non_base
|
||||
xor edx,edx
|
||||
mov ecx,[ebp+SKIN_DATA.base.width]
|
||||
jecxz .non_base
|
||||
div ecx
|
||||
|
||||
inc eax
|
||||
|
||||
mov ebx,[ebp+SKIN_DATA.base.data]
|
||||
mov ecx,[ebp+SKIN_DATA.base.width]
|
||||
shl ecx,16
|
||||
add ecx,[_skinh]
|
||||
mov edx,[ebp+SKIN_DATA.base.left]
|
||||
sub edx,[ebp+SKIN_DATA.base.width]
|
||||
shl edx,16
|
||||
.baseskinloop:
|
||||
shr edx,16
|
||||
add edx,[ebp+SKIN_DATA.base.width]
|
||||
shl edx,16
|
||||
|
||||
push eax ebx ecx edx
|
||||
call sys_putimage_with_check
|
||||
pop edx ecx ebx eax
|
||||
|
||||
dec eax
|
||||
jnz .baseskinloop
|
||||
.non_base:
|
||||
|
||||
mov esi,[esp+4]
|
||||
mov edx,[esi+WDATA.box.width]
|
||||
sub edx,[ebp+SKIN_DATA.oper.width]
|
||||
inc edx
|
||||
shl edx,16
|
||||
mov ebx,[ebp+SKIN_DATA.oper.data]
|
||||
|
||||
mov ecx,[ebp+SKIN_DATA.oper.width]
|
||||
shl ecx,16
|
||||
add ecx,[_skinh]
|
||||
call sys_putimage_with_check
|
||||
|
||||
ret
|
||||
|
||||
;//mike.dld, 2006-08-02 ]
|
||||
|
||||
|
||||
drawwindow_IV:
|
||||
;param1 - aw_yes
|
||||
|
||||
pusha
|
||||
|
||||
push edx
|
||||
|
||||
mov edi,[esp] ; RECTANGLE
|
||||
|
||||
mov ebp,skin_active
|
||||
cmp byte [esp+32+4+4],0
|
||||
jne @f
|
||||
mov ebp,skin_inactive
|
||||
@@:
|
||||
|
||||
mov eax,[edi+WDATA.box.left]
|
||||
shl eax,16
|
||||
mov ax,word [edi+WDATA.box.left]
|
||||
add ax,word [edi+WDATA.box.width]
|
||||
mov ebx,[edi+WDATA.box.top]
|
||||
shl ebx,16
|
||||
mov bx,word [edi+WDATA.box.top]
|
||||
add bx,word [edi+WDATA.box.height]
|
||||
; mov esi,[edi+24]
|
||||
; shr esi,1
|
||||
; and esi,0x007f7f7f
|
||||
mov esi,[ebp+SKIN_DATA.colors.outer]
|
||||
call draw_rectangle
|
||||
mov ecx,3
|
||||
_dw3l:
|
||||
add eax,1*65536-1
|
||||
add ebx,1*65536-1
|
||||
test ax,ax
|
||||
js no_skin_add_button
|
||||
test bx,bx
|
||||
js no_skin_add_button
|
||||
mov esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24]
|
||||
call draw_rectangle
|
||||
dec ecx
|
||||
jnz _dw3l
|
||||
mov esi,[ebp+SKIN_DATA.colors.inner]
|
||||
add eax,1*65536-1
|
||||
add ebx,1*65536-1
|
||||
test ax,ax
|
||||
js no_skin_add_button
|
||||
test bx,bx
|
||||
js no_skin_add_button
|
||||
call draw_rectangle
|
||||
|
||||
cmp dword[skin_data],'SKIN'
|
||||
je @f
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
mov esi,[esp]
|
||||
mov ecx,[esi+WDATA.box.width]
|
||||
inc ecx
|
||||
mov edx,[_skinh]
|
||||
mov edi,[common_colours+4] ; standard grab color
|
||||
call [drawbar]
|
||||
jmp draw_clientbar
|
||||
@@:
|
||||
|
||||
mov al,[esp+32+4+4]
|
||||
call drawwindow_IV_caption
|
||||
|
||||
draw_clientbar:
|
||||
|
||||
mov esi,[esp]
|
||||
|
||||
mov edx,[esi+WDATA.box.top] ; WORK AREA
|
||||
add edx,21+5
|
||||
mov ebx,[esi+WDATA.box.top]
|
||||
add ebx,[esi+WDATA.box.height]
|
||||
cmp edx,ebx
|
||||
jg _noinside2
|
||||
mov eax,5
|
||||
mov ebx,[_skinh]
|
||||
mov ecx,[esi+WDATA.box.width]
|
||||
mov edx,[esi+WDATA.box.height]
|
||||
sub ecx,4
|
||||
sub edx,4
|
||||
mov edi,[esi+WDATA.cl_workarea]
|
||||
call [drawbar]
|
||||
_noinside2:
|
||||
|
||||
cmp dword[skin_data],'SKIN'
|
||||
jne no_skin_add_button
|
||||
|
||||
;* close button
|
||||
mov edi,[0xfe88]
|
||||
movzx eax,word [edi]
|
||||
cmp eax,1000
|
||||
jge no_skin_add_button
|
||||
inc eax
|
||||
mov [edi],ax
|
||||
|
||||
shl eax,4
|
||||
add eax,edi
|
||||
|
||||
mov bx,[0x3000]
|
||||
mov [eax],bx
|
||||
|
||||
add eax,2 ; save button id number
|
||||
mov bx,1
|
||||
mov [eax],bx
|
||||
add eax,2 ; x start
|
||||
xor ebx,ebx
|
||||
cmp [skin_btn_close.left],0
|
||||
jge _bCx_at_right
|
||||
mov ebx,[esp]
|
||||
mov ebx,[ebx+WDATA.box.width]
|
||||
inc ebx
|
||||
_bCx_at_right:
|
||||
add ebx,[skin_btn_close.left]
|
||||
mov [eax],bx
|
||||
add eax,2 ; x size
|
||||
mov ebx,[skin_btn_close.width]
|
||||
dec ebx
|
||||
mov [eax],bx
|
||||
add eax,2 ; y start
|
||||
mov ebx,[skin_btn_close.top]
|
||||
mov [eax],bx
|
||||
add eax,2 ; y size
|
||||
mov ebx,[skin_btn_close.height]
|
||||
dec ebx
|
||||
mov [eax],bx
|
||||
|
||||
;* minimize button
|
||||
mov edi,[0xfe88]
|
||||
movzx eax,word [edi]
|
||||
cmp eax,1000
|
||||
jge no_skin_add_button
|
||||
inc eax
|
||||
mov [edi],ax
|
||||
|
||||
shl eax,4
|
||||
add eax,edi
|
||||
|
||||
mov bx,[0x3000]
|
||||
mov [eax],bx
|
||||
|
||||
add eax,2 ; save button id number
|
||||
mov bx,65535 ;999
|
||||
mov [eax],bx
|
||||
add eax,2 ; x start
|
||||
xor ebx,ebx
|
||||
cmp [skin_btn_minimize.left],0
|
||||
jge _bMx_at_right
|
||||
mov ebx,[esp]
|
||||
mov ebx,[ebx+WDATA.box.width]
|
||||
inc ebx
|
||||
_bMx_at_right:
|
||||
add ebx,[skin_btn_minimize.left]
|
||||
mov [eax],bx
|
||||
add eax,2 ; x size
|
||||
mov ebx,[skin_btn_minimize.width]
|
||||
dec ebx
|
||||
mov [eax],bx
|
||||
add eax,2 ; y start
|
||||
mov ebx,[skin_btn_minimize.top]
|
||||
mov [eax],bx
|
||||
add eax,2 ; y size
|
||||
mov ebx,[skin_btn_minimize.height]
|
||||
dec ebx
|
||||
mov [eax],bx
|
||||
|
||||
no_skin_add_button:
|
||||
|
||||
add esp,4
|
||||
popa
|
||||
|
||||
ret 4
|
||||
|
||||
56
kernel/branches/gfx_kernel/gui/skindata.inc
Normal file
56
kernel/branches/gfx_kernel/gui/skindata.inc
Normal file
@@ -0,0 +1,56 @@
|
||||
;
|
||||
; WINDOW SKIN DATA
|
||||
;
|
||||
|
||||
iglobal
|
||||
_skin_file_default db 'DEFAULT SKN',0
|
||||
endg
|
||||
|
||||
struct SKIN_DATA
|
||||
.colors.inner dd ?
|
||||
.colors.outer dd ?
|
||||
.colors.frame dd ?
|
||||
.left.data dd ?
|
||||
.left.left dd ?
|
||||
.left.width dd ?
|
||||
.oper.data dd ?
|
||||
.oper.left dd ?
|
||||
.oper.width dd ?
|
||||
.base.data dd ?
|
||||
.base.left dd ?
|
||||
.base.width dd ?
|
||||
ends
|
||||
|
||||
struct SKIN_BUTTON
|
||||
.left dd ?
|
||||
.top dd ?
|
||||
.width dd ?
|
||||
.height dd ?
|
||||
ends
|
||||
|
||||
uglobal
|
||||
|
||||
align 4
|
||||
|
||||
skin_udata:
|
||||
_skinh dd ?
|
||||
|
||||
_skinmargins: ; rw 4
|
||||
.right dw ?
|
||||
.left dw ?
|
||||
.bottom dw ?
|
||||
.top dw ?
|
||||
|
||||
skin_btn_close SKIN_BUTTON
|
||||
skin_btn_minimize SKIN_BUTTON
|
||||
|
||||
skin_active SKIN_DATA
|
||||
skin_inactive SKIN_DATA
|
||||
|
||||
_skin_file rb 256
|
||||
|
||||
align 4
|
||||
|
||||
skin_udata.end:
|
||||
|
||||
endg
|
||||
1494
kernel/branches/gfx_kernel/gui/window.inc
Normal file
1494
kernel/branches/gfx_kernel/gui/window.inc
Normal file
File diff suppressed because it is too large
Load Diff
293
kernel/branches/gfx_kernel/hid/keyboard.inc
Normal file
293
kernel/branches/gfx_kernel/hid/keyboard.inc
Normal file
@@ -0,0 +1,293 @@
|
||||
;// mike.dld [
|
||||
|
||||
VKEY_LSHIFT = 0000000000000001b
|
||||
VKEY_RSHIFT = 0000000000000010b
|
||||
VKEY_LCONTROL = 0000000000000100b
|
||||
VKEY_RCONTROL = 0000000000001000b
|
||||
VKEY_LALT = 0000000000010000b
|
||||
VKEY_RALT = 0000000000100000b
|
||||
VKEY_CAPSLOCK = 0000000001000000b
|
||||
VKEY_NUMLOCK = 0000000010000000b
|
||||
VKEY_SCRLOCK = 0000000100000000b
|
||||
|
||||
VKEY_SHIFT = 0000000000000011b
|
||||
VKEY_CONTROL = 0000000000001100b
|
||||
VKEY_ALT = 0000000000110000b
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
kb_state dd 0
|
||||
ext_code db 0
|
||||
|
||||
keyboard_mode db 0
|
||||
keyboard_data db 0
|
||||
|
||||
altmouseb db 0
|
||||
ctrl_alt_del db 0
|
||||
|
||||
kb_lights db 0
|
||||
|
||||
align 4
|
||||
hotkey_scancodes rd 256 ; we have 256 scancodes
|
||||
hotkey_list rd 256*4 ; max 256 defined hotkeys
|
||||
hotkey_buffer rd 120*2 ; buffer for 120 hotkeys
|
||||
endg
|
||||
|
||||
iglobal
|
||||
hotkey_tests dd hotkey_test0
|
||||
dd hotkey_test1
|
||||
dd hotkey_test2
|
||||
dd hotkey_test3
|
||||
dd hotkey_test4
|
||||
hotkey_tests_num = 5
|
||||
endg
|
||||
|
||||
hotkey_test0:
|
||||
test al, al
|
||||
setz al
|
||||
ret
|
||||
hotkey_test1:
|
||||
test al, al
|
||||
setnp al
|
||||
ret
|
||||
hotkey_test2:
|
||||
cmp al, 3
|
||||
setz al
|
||||
ret
|
||||
hotkey_test3:
|
||||
cmp al, 1
|
||||
setz al
|
||||
ret
|
||||
hotkey_test4:
|
||||
cmp al, 2
|
||||
setz al
|
||||
ret
|
||||
|
||||
hotkey_do_test:
|
||||
push eax
|
||||
mov edx, [kb_state]
|
||||
shr edx, cl
|
||||
add cl, cl
|
||||
mov eax, [eax+4]
|
||||
shr eax, cl
|
||||
and eax, 15
|
||||
cmp al, hotkey_tests_num
|
||||
jae .fail
|
||||
xchg eax, edx
|
||||
and al, 3
|
||||
call [hotkey_tests + edx*4]
|
||||
cmp al, 1
|
||||
pop eax
|
||||
ret
|
||||
.fail:
|
||||
stc
|
||||
pop eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
irq1:
|
||||
save_ring3_context
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov eax, [0x3004] ; top window process
|
||||
movzx eax,word[0xC400+eax*2]
|
||||
shl eax,8
|
||||
mov al,[0x80000+eax+APPDATA.keyboard_mode]
|
||||
mov [keyboard_mode],al
|
||||
|
||||
in al,0x60
|
||||
mov [keyboard_data],al
|
||||
|
||||
; ch = scancode
|
||||
; cl = ext_code
|
||||
; bh = 0 - normal key
|
||||
; bh = 1 - modifier (Shift/Ctrl/Alt)
|
||||
; bh = 2 - extended code
|
||||
|
||||
mov ch,al
|
||||
cmp al,0xE0
|
||||
je @f
|
||||
cmp al,0xE1
|
||||
jne .normal_code
|
||||
@@:
|
||||
mov bh, 2
|
||||
mov [ext_code], al
|
||||
jmp .writekey
|
||||
.normal_code:
|
||||
mov cl, 0
|
||||
xchg cl, [ext_code]
|
||||
and al,0x7F
|
||||
mov bh, 1
|
||||
@@: cmp al,0x2A
|
||||
jne @f
|
||||
cmp cl,0xE0
|
||||
je .writekey
|
||||
mov eax,VKEY_LSHIFT
|
||||
jmp .modifier
|
||||
@@: cmp al,0x36
|
||||
jne @f
|
||||
cmp cl,0xE0
|
||||
je .writekey
|
||||
mov eax,VKEY_RSHIFT
|
||||
jmp .modifier
|
||||
@@: cmp al,0x38
|
||||
jne @f
|
||||
mov eax, VKEY_LALT
|
||||
test cl, cl
|
||||
jz .modifier
|
||||
mov al, VKEY_RALT
|
||||
jmp .modifier
|
||||
@@: cmp al,0x1D
|
||||
jne @f
|
||||
mov eax, VKEY_LCONTROL
|
||||
test cl, cl
|
||||
jz .modifier
|
||||
mov al, VKEY_RCONTROL
|
||||
cmp cl, 0xE0
|
||||
jz .modifier
|
||||
mov [ext_code], cl
|
||||
jmp .writekey
|
||||
@@: cmp al,0x3A
|
||||
jne @f
|
||||
mov bl,4
|
||||
mov eax,VKEY_CAPSLOCK
|
||||
jmp .no_key.xor
|
||||
@@: cmp al,0x45
|
||||
jne @f
|
||||
test cl, cl
|
||||
jnz .writekey
|
||||
mov bl,2
|
||||
mov eax,VKEY_NUMLOCK
|
||||
jmp .no_key.xor
|
||||
@@: cmp al,0x46
|
||||
jne @f
|
||||
mov bl,1
|
||||
mov eax,VKEY_SCRLOCK
|
||||
jmp .no_key.xor
|
||||
@@:
|
||||
test ch,ch
|
||||
js .writekey
|
||||
movzx eax,ch ; plain key
|
||||
mov bl,[keymap+eax]
|
||||
mov edx,[kb_state]
|
||||
test dl,VKEY_CONTROL ; ctrl alt del
|
||||
jz .noctrlaltdel
|
||||
test dl,VKEY_ALT
|
||||
jz .noctrlaltdel
|
||||
cmp ch,53h
|
||||
jne .noctrlaltdel
|
||||
mov [ctrl_alt_del],1
|
||||
.noctrlaltdel:
|
||||
test dl,VKEY_CONTROL ; ctrl on ?
|
||||
jz @f
|
||||
sub bl,0x60
|
||||
@@: test dl,VKEY_SHIFT ; shift on ?
|
||||
jz @f
|
||||
mov bl,[keymap_shift+eax]
|
||||
@@: test dl,VKEY_ALT ; alt on ?
|
||||
jz @f
|
||||
mov bl,[keymap_alt+eax]
|
||||
@@:
|
||||
mov bh, 0
|
||||
jmp .writekey
|
||||
.modifier:
|
||||
test ch, ch
|
||||
js .modifier.up
|
||||
or [kb_state], eax
|
||||
jmp .writekey
|
||||
.modifier.up:
|
||||
not eax
|
||||
and [kb_state], eax
|
||||
jmp .writekey
|
||||
.no_key.xor:
|
||||
mov bh, 0
|
||||
test ch, ch
|
||||
js .writekey
|
||||
xor [kb_state], eax
|
||||
xor [kb_lights], bl
|
||||
call set_lights
|
||||
|
||||
.writekey:
|
||||
; test for system hotkeys
|
||||
movzx eax, ch
|
||||
cmp bh, 1
|
||||
ja .nohotkey
|
||||
jb @f
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov eax, [hotkey_scancodes + eax*4]
|
||||
.hotkey_loop:
|
||||
test eax, eax
|
||||
jz .nohotkey
|
||||
mov cl, 0
|
||||
call hotkey_do_test
|
||||
jc .hotkey_cont
|
||||
mov cl, 2
|
||||
call hotkey_do_test
|
||||
jc .hotkey_cont
|
||||
mov cl, 4
|
||||
call hotkey_do_test
|
||||
jnc .hotkey_found
|
||||
.hotkey_cont:
|
||||
mov eax, [eax]
|
||||
jmp .hotkey_loop
|
||||
.hotkey_found:
|
||||
mov eax, [eax+8]
|
||||
; put key in buffer for process in slot eax
|
||||
mov edi, hotkey_buffer
|
||||
@@:
|
||||
cmp dword [edi], 0
|
||||
jz .found_free
|
||||
add edi, 8
|
||||
cmp edi, hotkey_buffer+120*8
|
||||
jb @b
|
||||
; no free space - replace first entry
|
||||
mov edi, hotkey_buffer
|
||||
.found_free:
|
||||
mov [edi], eax
|
||||
movzx eax, ch
|
||||
cmp bh, 1
|
||||
jnz @f
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov [edi+4], ax
|
||||
mov eax, [kb_state]
|
||||
mov [edi+6], ax
|
||||
jmp .exit.irq1
|
||||
.nohotkey:
|
||||
cmp [keyboard_mode],0 ; return from keymap
|
||||
jne .scancode
|
||||
test bh, bh
|
||||
jnz .exit.irq1
|
||||
test bl, bl
|
||||
jz .exit.irq1
|
||||
jmp .dowrite
|
||||
.scancode:
|
||||
mov bl, ch
|
||||
.dowrite:
|
||||
movzx eax,byte[0xF400]
|
||||
cmp al,120
|
||||
jae .exit.irq1
|
||||
inc eax
|
||||
mov [0xF400],al
|
||||
mov [0xF400+eax],bl
|
||||
|
||||
.exit.irq1:
|
||||
mov [check_idle_semaphore],5
|
||||
|
||||
mov al,0x20 ; ready for next irq
|
||||
out 0x20,al
|
||||
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
set_lights:
|
||||
mov al,0xED
|
||||
call kb_write
|
||||
mov al,[kb_lights]
|
||||
call kb_write
|
||||
ret
|
||||
|
||||
;// mike.dld ]
|
||||
130
kernel/branches/gfx_kernel/hid/m_com1.inc
Normal file
130
kernel/branches/gfx_kernel/hid/m_com1.inc
Normal file
@@ -0,0 +1,130 @@
|
||||
; Номер принимаемого от мыши байта
|
||||
MouseByteNumber DB 0
|
||||
; Трехбайтовая структура данных, передаваемая мышью
|
||||
FirstByte DB 0
|
||||
SecondByte DB 0
|
||||
ThirdByte DB 0
|
||||
timer_ticks_com dd 0
|
||||
;***************************************
|
||||
;* НОВЫЙ ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ МЫШИ *
|
||||
;***************************************
|
||||
check_mouse_data_com1:
|
||||
; cmp [com1_mouse_detected],0
|
||||
; je @@EndMouseInterrupt
|
||||
; Проверить наличие данных
|
||||
mov DX,3F8h ;[COMPortBaseAddr]
|
||||
add DX,5 ;xFDh
|
||||
in AL,DX
|
||||
test AL,1 ;Данные готовы?
|
||||
jz @@Error
|
||||
; Ввести данные
|
||||
mov DX,3F8h ;[COMPortBaseAddr] ;xF8h
|
||||
in AL,DX
|
||||
; Сбросить старший незначащий бит
|
||||
and AL,01111111b
|
||||
|
||||
; Определить порядковый номер принимаемого байта
|
||||
cmp [MouseByteNumber],0
|
||||
je @@FirstByte
|
||||
cmp [MouseByteNumber],1
|
||||
je @@SecondByte
|
||||
cmp [MouseByteNumber],2
|
||||
je @@ThirdByte
|
||||
jmp @@Error
|
||||
|
||||
; Сохранить первый байт данных
|
||||
@@FirstByte:
|
||||
test AL,1000000b ;Первый байт посылки?
|
||||
jz @@Error
|
||||
mov [FirstByte],AL
|
||||
inc [MouseByteNumber] ;увеличить счетчик
|
||||
jmp @@EndMouseInterrupt
|
||||
; Сохранить второй байт данных
|
||||
@@SecondByte:
|
||||
test AL,1000000b
|
||||
jnz @@Error
|
||||
mov [SecondByte],AL
|
||||
inc [MouseByteNumber] ;увеличить счетчик
|
||||
jmp @@EndMouseInterrupt
|
||||
; Сохранить третий байт данных
|
||||
@@ThirdByte:
|
||||
test AL,1000000b
|
||||
jnz @@Error
|
||||
mov [ThirdByte],AL ;увеличить счетчик
|
||||
mov [MouseByteNumber],0
|
||||
; (Пакет данных от мыши принят полностью).
|
||||
; Записать новое значение состояния кнопок мыши
|
||||
mov al,[FirstByte] ;[0xfb01]
|
||||
mov ah,al
|
||||
shr al,3
|
||||
and al,2
|
||||
shr ah,5
|
||||
and ah,1
|
||||
add al,ah
|
||||
mov [0xfb40],al
|
||||
mov [mouse_active],1
|
||||
; Прибавить перемещение по X к координате X
|
||||
mov AL,[FirstByte]
|
||||
shl AL,6
|
||||
or AL,[SecondByte]
|
||||
cbw
|
||||
call mouse_acceleration_com1
|
||||
add AX,[0xFB0A] ;[XCoordinate]
|
||||
; Курсор не должен выходить за левую или
|
||||
; правую границу экрана
|
||||
js @@X1
|
||||
cmp AX,[0xFE00] ;ScreenLength
|
||||
jb @@X2
|
||||
; Установить координату X по правой границе
|
||||
mov AX,[0xFE00] ;ScreenLength-1
|
||||
dec ax
|
||||
jmp @@X2
|
||||
@@X1:
|
||||
; Установить координату X по левой границе
|
||||
xor AX,AX
|
||||
@@X2:
|
||||
mov [0xFB0A],AX ;[XCoordinate]
|
||||
; Прибавить перемещение по Y к координате Y
|
||||
mov AL,[FirstByte]
|
||||
and AL,00001100b
|
||||
shl AL,4
|
||||
or AL,[ThirdByte]
|
||||
cbw
|
||||
call mouse_acceleration_com1
|
||||
add AX,[0xFB0C] ;[YCoordinate]
|
||||
; Курсор не должен выходить за верхнюю или
|
||||
; нижнюю границу экрана
|
||||
js @@Y1
|
||||
cmp AX,[0xFE04] ;ScreenHeigth
|
||||
jb @@Y2
|
||||
; Установить координату X по нижней границе
|
||||
mov AX,[0xFE04] ;ScreenHeigth-1
|
||||
dec ax
|
||||
jmp @@Y2
|
||||
@@Y1:
|
||||
; Установить координату X по верхней границе
|
||||
xor AX,AX
|
||||
@@Y2:
|
||||
mov [0xFB0C],AX ;[YCoordinate]
|
||||
mov eax,[timer_ticks]
|
||||
mov [timer_ticks_com],eax
|
||||
jmp @@EndMouseInterrupt
|
||||
|
||||
@@Error:
|
||||
; Произошел сбой в порядке передачи информации от
|
||||
; мыши, обнулить счетчик байтов пакета данных
|
||||
mov [MouseByteNumber],0
|
||||
@@EndMouseInterrupt:
|
||||
call ready_for_next_irq
|
||||
ret
|
||||
|
||||
mouse_acceleration_com1:
|
||||
push eax
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[timer_ticks_com]
|
||||
cmp eax,[mouse_delay]
|
||||
pop eax
|
||||
ja @f
|
||||
shl ax,1
|
||||
@@:
|
||||
ret
|
||||
130
kernel/branches/gfx_kernel/hid/m_com2.inc
Normal file
130
kernel/branches/gfx_kernel/hid/m_com2.inc
Normal file
@@ -0,0 +1,130 @@
|
||||
; Номер принимаемого от мыши байта
|
||||
MouseByteNumber_1 DB 0
|
||||
; Трехбайтовая структура данных, передаваемая мышью
|
||||
FirstByte_1 DB 0
|
||||
SecondByte_1 DB 0
|
||||
ThirdByte_1 DB 0
|
||||
timer_ticks_com_1 dd 0
|
||||
;***************************************
|
||||
;* НОВЫЙ ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ МЫШИ *
|
||||
;***************************************
|
||||
check_mouse_data_com2:
|
||||
; cmp [com2_mouse_detected],0
|
||||
; je @@EndMouseInterrupt_1
|
||||
; Проверить наличие данных
|
||||
mov DX,2F8h ;[COMPortBaseAddr]
|
||||
add DX,5 ;xFDh
|
||||
in AL,DX
|
||||
test AL,1 ;Данные готовы?
|
||||
jz @@Error_1
|
||||
; Ввести данные
|
||||
mov DX,2F8h ;[COMPortBaseAddr] ;xF8h
|
||||
in AL,DX
|
||||
; Сбросить старший незначащий бит
|
||||
and AL,01111111b
|
||||
|
||||
; Определить порядковый номер принимаемого байта
|
||||
cmp [MouseByteNumber_1],0
|
||||
je @@FirstByte_1
|
||||
cmp [MouseByteNumber_1],1
|
||||
je @@SecondByte_1
|
||||
cmp [MouseByteNumber_1],2
|
||||
je @@ThirdByte_1
|
||||
jmp @@Error_1
|
||||
|
||||
; Сохранить первый байт данных
|
||||
@@FirstByte_1:
|
||||
test AL,1000000b ;Первый байт посылки?
|
||||
jz @@Error_1
|
||||
mov [FirstByte_1],AL
|
||||
inc [MouseByteNumber_1] ;увеличить счетчик
|
||||
jmp @@EndMouseInterrupt_1
|
||||
; Сохранить второй байт данных
|
||||
@@SecondByte_1:
|
||||
test AL,1000000b
|
||||
jnz @@Error_1
|
||||
mov [SecondByte_1],AL
|
||||
inc [MouseByteNumber_1] ;увеличить счетчик
|
||||
jmp @@EndMouseInterrupt_1
|
||||
; Сохранить третий байт данных
|
||||
@@ThirdByte_1:
|
||||
test AL,1000000b
|
||||
jnz @@Error_1
|
||||
mov [ThirdByte_1],AL ;увеличить счетчик
|
||||
mov [MouseByteNumber_1],0
|
||||
; (Пакет данных от мыши принят полностью).
|
||||
; Записать новое значение состояния кнопок мыши
|
||||
mov al,[FirstByte_1] ;[0xfb01]
|
||||
mov ah,al
|
||||
shr al,3
|
||||
and al,2
|
||||
shr ah,5
|
||||
and ah,1
|
||||
add al,ah
|
||||
mov [0xfb40],al
|
||||
mov [mouse_active],1
|
||||
; Прибавить перемещение по X к координате X
|
||||
mov AL,[FirstByte_1]
|
||||
shl AL,6
|
||||
or AL,[SecondByte_1]
|
||||
cbw
|
||||
call mouse_acceleration_com2
|
||||
add AX,[0xFB0A] ;[XCoordinate]
|
||||
; Курсор не должен выходить за левую или
|
||||
; правую границу экрана
|
||||
js @@X1_1
|
||||
cmp AX,[0xFE00] ;ScreenLength
|
||||
jb @@X2_1
|
||||
; Установить координату X по правой границе
|
||||
mov AX,[0xFE00] ;ScreenLength-1
|
||||
dec ax
|
||||
jmp @@X2_1
|
||||
@@X1_1:
|
||||
; Установить координату X по левой границе
|
||||
xor AX,AX
|
||||
@@X2_1:
|
||||
mov [0xFB0A],AX ;[XCoordinate]
|
||||
; Прибавить перемещение по Y к координате Y
|
||||
mov AL,[FirstByte_1]
|
||||
and AL,00001100b
|
||||
shl AL,4
|
||||
or AL,[ThirdByte_1]
|
||||
cbw
|
||||
call mouse_acceleration_com2
|
||||
add AX,[0xFB0C] ;[YCoordinate]
|
||||
; Курсор не должен выходить за верхнюю или
|
||||
; нижнюю границу экрана
|
||||
js @@Y1_1
|
||||
cmp AX,[0xFE04] ;ScreenHeigth
|
||||
jb @@Y2_1
|
||||
; Установить координату X по нижней границе
|
||||
mov AX,[0xFE04] ;ScreenHeigth-1
|
||||
dec ax
|
||||
jmp @@Y2_1
|
||||
@@Y1_1:
|
||||
; Установить координату X по верхней границе
|
||||
xor AX,AX
|
||||
@@Y2_1:
|
||||
mov [0xFB0C],AX ;[YCoordinate]
|
||||
mov eax,[timer_ticks]
|
||||
mov [timer_ticks_com_1],eax
|
||||
jmp @@EndMouseInterrupt_1
|
||||
|
||||
@@Error_1:
|
||||
; Произошел сбой в порядке передачи информации от
|
||||
; мыши, обнулить счетчик байтов пакета данных
|
||||
mov [MouseByteNumber_1],0
|
||||
@@EndMouseInterrupt_1:
|
||||
call ready_for_next_irq
|
||||
ret
|
||||
|
||||
mouse_acceleration_com2:
|
||||
push eax
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[timer_ticks_com_1]
|
||||
cmp eax,[mouse_delay]
|
||||
pop eax
|
||||
ja @f
|
||||
shl ax,1
|
||||
@@:
|
||||
ret
|
||||
170
kernel/branches/gfx_kernel/hid/m_ps2.inc
Normal file
170
kernel/branches/gfx_kernel/hid/m_ps2.inc
Normal file
@@ -0,0 +1,170 @@
|
||||
; Номер принимаемого от мыши байта
|
||||
MouseByteNumber_2 DB 0
|
||||
; Трехбайтовая структура данных, передаваемая мышью
|
||||
FirstByte_2 DB 0
|
||||
SecondByte_2 DB 0
|
||||
ThirdByte_2 DB 0
|
||||
timer_ticks_ps2 dd 0
|
||||
|
||||
;**************************************
|
||||
;* ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ МЫШИ PS/2 *
|
||||
;**************************************
|
||||
check_mouse_data_ps2:
|
||||
cmp [ps2_mouse_detected],0
|
||||
je @@EndMouseInterrupt_2
|
||||
call Wait8042BufferEmpty ;очистка буфера
|
||||
in AL,0x60 ;получить скэн-код
|
||||
; Выбирать порядковый номер принимаемого байта
|
||||
cmp [MouseByteNumber_2],0
|
||||
je @@SaveFirstByte
|
||||
cmp [MouseByteNumber_2],1
|
||||
je @@SaveSecondByte
|
||||
cmp [MouseByteNumber_2],2
|
||||
je @@SaveThirdByte
|
||||
jmp @@Error_2
|
||||
; Записать первый байт посылки
|
||||
@@SaveFirstByte:
|
||||
test AL,1000b ;первый байт посылки?
|
||||
jz @@Error_2 ;сбой синхронизации
|
||||
mov [FirstByte_2],AL
|
||||
inc [MouseByteNumber_2]
|
||||
jmp @@EndMouseInterrupt_2
|
||||
; Записать второй байт посылки
|
||||
@@SaveSecondByte:
|
||||
mov [SecondByte_2],AL
|
||||
inc [MouseByteNumber_2]
|
||||
jmp @@EndMouseInterrupt_2
|
||||
; Записать третий байт посылки
|
||||
@@SaveThirdByte:
|
||||
mov [ThirdByte_2],AL
|
||||
mov [MouseByteNumber_2],0
|
||||
; (пакет данных от мыши принят полностью)
|
||||
; Записать новое значение байта состояния кнопок
|
||||
mov al,[FirstByte_2] ;[0xfb01]
|
||||
and eax,3
|
||||
mov [0xfb40],al
|
||||
mov [mouse_active],1
|
||||
; Вычислить новую X-координату курсора
|
||||
; Занести в AX перемещение по X
|
||||
mov AH,0 ;дублируем знак во все разряды AH
|
||||
mov AL,[FirstByte_2]
|
||||
test AL,10000b
|
||||
jz @@M0
|
||||
mov AH,0FFh
|
||||
; Занести в AL младший байт
|
||||
@@M0:
|
||||
mov AL,[SecondByte_2]
|
||||
call mouse_acceleration_ps2
|
||||
; Вычислить новое значение координаты
|
||||
; курсора по X
|
||||
add AX,[0xFB0A] ;[XCoordinate]
|
||||
cmp AX,0
|
||||
jge @@M1
|
||||
mov AX,0
|
||||
jmp @@M2
|
||||
@@M1:
|
||||
cmp AX,[0xFE00] ;ScreenLength
|
||||
jl @@M2
|
||||
mov AX,[0xFE00] ;ScreenLength-1
|
||||
dec ax
|
||||
@@M2:
|
||||
mov [0xFB0A],AX ;[XCoordinate]
|
||||
|
||||
; Вычисляем новую Y-координату курсора
|
||||
; Занести в AX перемещение по Y
|
||||
mov AH,0 ;дублируем знак во все разряды AH
|
||||
mov AL,[FirstByte_2]
|
||||
test AL,100000b
|
||||
jz @@M3
|
||||
mov AH,0FFh
|
||||
; Занести в AL младший байт
|
||||
@@M3:
|
||||
mov AL,[ThirdByte_2]
|
||||
call mouse_acceleration_ps2
|
||||
; Вычислить новое значение координаты курсора
|
||||
; по Y (Y-координата мыши PS/2 направлена
|
||||
; противоположно экранной)
|
||||
neg AX
|
||||
add AX,[0xFB0C] ;[YCoordinate]
|
||||
cmp AX,0
|
||||
jge @@M4
|
||||
mov AX,0
|
||||
jmp @@M5
|
||||
@@M4:
|
||||
cmp AX,[0xFE04] ;ScreenHeigth
|
||||
jl @@M5
|
||||
mov AX,[0xFE04] ;ScreenHeigth-1
|
||||
dec ax
|
||||
@@M5:
|
||||
mov [0xFB0C],AX ;[YCoordinate]
|
||||
|
||||
; Показать курсор в новой позиции
|
||||
mov eax,[timer_ticks]
|
||||
mov [timer_ticks_ps2],eax
|
||||
jmp @@EndMouseInterrupt_2
|
||||
|
||||
; Обнаружен сбой в порядке передачи информации от мыши
|
||||
@@Error_2:
|
||||
mov [MouseByteNumber_2],0
|
||||
; Нормальное завершение прерывания
|
||||
@@EndMouseInterrupt_2:
|
||||
call ready_for_next_irq_1
|
||||
ret
|
||||
|
||||
mouse_acceleration_ps2:
|
||||
push eax
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[timer_ticks_ps2]
|
||||
cmp eax,[mouse_delay]
|
||||
pop eax
|
||||
ja @f
|
||||
imul ax,[mouse_speed_factor]
|
||||
@@:
|
||||
ret
|
||||
;***********************************************
|
||||
;* ОЖИДАНИЕ ОЧИСТКИ ВХОДНОГО БУФЕРА I8042 *
|
||||
;* При выходе из процедуры: *
|
||||
;* флаг ZF установлен - нормальное завершение, *
|
||||
;* флаг ZF сброшен - ошибка тайм-аута. *
|
||||
;***********************************************
|
||||
Wait8042BufferEmpty:
|
||||
; push CX
|
||||
; mov CX,0FFFFh ;задать число циклов ожидания
|
||||
;@@kb:
|
||||
; in AL,64h ;получить статус
|
||||
; test AL,10b ;буфер i8042 свободен?
|
||||
; loopnz @@kb ;если нет, то цикл
|
||||
; pop CX
|
||||
push ecx
|
||||
xor ecx,ecx
|
||||
@@:
|
||||
in al,64h
|
||||
test al,00000010b
|
||||
loopnz @b
|
||||
pop ecx
|
||||
;Если при выходе из подпрограммы сброшен
|
||||
;флаг ZF - ошибка
|
||||
ret ;возврат в подпрограмму
|
||||
|
||||
;***************************************
|
||||
;* ОЖИДАНИЕ ПОСТУПЛЕНИЯ ДАННЫХ ОТ МЫШИ *
|
||||
;***************************************
|
||||
WaitMouseData:
|
||||
; push CX
|
||||
; mov CX,0FFFFh ;задать число циклов ожидания
|
||||
;@@mouse:
|
||||
; in AL,64h ;опросить регистр статуса
|
||||
; test AL,100000b ;данные поступили?
|
||||
; loopz @@mouse ;если нет, то цикл
|
||||
; pop CX
|
||||
push ecx
|
||||
mov ECX,0FFFFh
|
||||
@@:
|
||||
in al,64h
|
||||
test al,100000b
|
||||
loopz @b
|
||||
pop ecx
|
||||
;Если при выходе из подпрограммы установлен
|
||||
;флаг ZF - ошибка
|
||||
ret
|
||||
|
||||
366
kernel/branches/gfx_kernel/hid/mousedrv.inc
Normal file
366
kernel/branches/gfx_kernel/hid/mousedrv.inc
Normal file
@@ -0,0 +1,366 @@
|
||||
; check mouse
|
||||
;
|
||||
;
|
||||
; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y
|
||||
; FB10 -> FB17 mouse color mem
|
||||
; FB21 x move
|
||||
; FB22 y move
|
||||
; FB30 color temp
|
||||
; FB28 high bits temp
|
||||
; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under
|
||||
; FC00 -> FCFE com1/ps2 buffer
|
||||
; FCFF com1/ps2 buffer count starting from FC00
|
||||
|
||||
uglobal
|
||||
mousecount dd 0x0
|
||||
mousedata dd 0x0
|
||||
endg
|
||||
|
||||
mouse_delay dd 10
|
||||
mouse_speed_factor dw 3
|
||||
|
||||
include 'm_ps2.inc'
|
||||
include 'm_com1.inc'
|
||||
include 'm_com2.inc'
|
||||
|
||||
|
||||
;test_mario79:
|
||||
; push esi
|
||||
; push eax
|
||||
; mov [write_error_to],process_test_m79+43
|
||||
; movzx eax,al ;[DevErrorCode]
|
||||
; call writehex
|
||||
; mov esi,process_test_m79
|
||||
; call sys_msg_board_str
|
||||
; pop eax
|
||||
; pop esi
|
||||
; ret
|
||||
;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0
|
||||
|
||||
__sys_draw_mouse_under:
|
||||
; return old picture
|
||||
|
||||
pushad
|
||||
|
||||
xor ecx,ecx
|
||||
xor edx,edx
|
||||
mov esi,mouseunder-4
|
||||
|
||||
align 4
|
||||
mres:
|
||||
|
||||
add esi,4
|
||||
|
||||
movsx eax,word[0xfb4a]
|
||||
add eax,ecx
|
||||
js .skip
|
||||
movsx ebx,word[0xfb4c]
|
||||
add ebx,edx
|
||||
js .skip
|
||||
|
||||
push ecx
|
||||
push edx
|
||||
mov ecx,[esi]
|
||||
|
||||
mov edi,1 ;force
|
||||
push esi
|
||||
call [putpixel]
|
||||
pop esi
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
.skip:
|
||||
inc ecx
|
||||
cmp ecx,32
|
||||
|
||||
jnz mres
|
||||
xor ecx, ecx
|
||||
inc edx
|
||||
cmp edx,32
|
||||
jnz mres
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
save_draw_mouse:
|
||||
pushad
|
||||
; save & draw
|
||||
mov [0xfb4a],ax
|
||||
mov [0xfb4c],bx
|
||||
push eax
|
||||
push ebx
|
||||
xor ecx,ecx
|
||||
mov edx,ecx
|
||||
mov esi,mouseunder-4;3
|
||||
mov edi,mousepointer+62-4
|
||||
|
||||
mov dword[0x6900],mouseunder+mousecomb
|
||||
|
||||
drm:
|
||||
|
||||
add esi,4;3
|
||||
add edi,4
|
||||
|
||||
push eax ebx ecx edx
|
||||
|
||||
push eax ebx
|
||||
add eax,ecx ; save picture under mouse
|
||||
js @f
|
||||
add ebx,edx
|
||||
js @f
|
||||
push esi edi
|
||||
call [getpixel]
|
||||
pop edi esi
|
||||
mov [esi],ecx
|
||||
pop ebx eax
|
||||
|
||||
push esi edi
|
||||
call combine_colors
|
||||
pop edi esi
|
||||
mov [0xfb10],ecx
|
||||
|
||||
pop edx ecx ebx eax
|
||||
|
||||
xchg esi,[0x6900]
|
||||
push dword[0xFB10]
|
||||
pop dword[esi]
|
||||
add esi,3
|
||||
xchg esi,[0x6900]
|
||||
|
||||
jc mnext
|
||||
|
||||
add eax,ecx ; we have x coord+cycle
|
||||
js mnext
|
||||
add ebx,edx ; and y coord+cycle
|
||||
js mnext
|
||||
|
||||
push ecx edi esi
|
||||
mov ecx, [0xfb10]
|
||||
mov edi, 1
|
||||
call [putpixel]
|
||||
pop esi edi ecx
|
||||
jmp mnext
|
||||
@@: add esp,8
|
||||
pop edx ecx ebx eax
|
||||
mnext:
|
||||
|
||||
mov ebx,[esp+0] ; pure y coord again
|
||||
mov eax,[esp+4] ; and x
|
||||
|
||||
inc ecx ; +1 cycle
|
||||
cmp ecx,32
|
||||
jnz drm
|
||||
xor ecx,ecx
|
||||
inc edx
|
||||
cmp edx,32
|
||||
jnz drm
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
combine_colors:
|
||||
; in
|
||||
; ecx - color ( 00 RR GG BB )
|
||||
; edi - ref to new color byte
|
||||
; esi - ref to alpha byte
|
||||
;
|
||||
; out
|
||||
; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
|
||||
; colors:
|
||||
; [esp] = background:
|
||||
; [edi] = cursor
|
||||
; <ecx> = combined
|
||||
|
||||
cmp byte[edi+3],0
|
||||
jne @f
|
||||
stc
|
||||
ret
|
||||
@@:
|
||||
cmp byte[edi+3],255
|
||||
jne @f
|
||||
mov ecx,[edi]
|
||||
and ecx,0x00FFFFFF
|
||||
clc
|
||||
ret
|
||||
@@:
|
||||
push ecx
|
||||
|
||||
xor ecx,ecx
|
||||
|
||||
movzx eax,byte[edi+2]
|
||||
movzx ebx,byte[esp+2]
|
||||
sub eax,ebx
|
||||
movzx ebx,byte[edi+3]
|
||||
imul ebx
|
||||
xor edx,edx
|
||||
mov ebx,255
|
||||
div ebx
|
||||
add al,[esp+2]
|
||||
mov cl,al
|
||||
shl ecx,8
|
||||
|
||||
movzx eax,byte[edi+1]
|
||||
movzx ebx,byte[esp+1]
|
||||
sub eax,ebx
|
||||
movzx ebx,byte[edi+3]
|
||||
imul ebx
|
||||
xor edx,edx
|
||||
mov ebx,255
|
||||
div ebx
|
||||
add al,[esp+1]
|
||||
mov cl,al
|
||||
shl ecx,8
|
||||
|
||||
movzx eax,byte[edi+0]
|
||||
movzx ebx,byte[esp+0]
|
||||
sub eax,ebx
|
||||
movzx ebx,byte[edi+3]
|
||||
imul ebx
|
||||
xor edx,edx
|
||||
mov ebx,255
|
||||
div ebx
|
||||
add al,[esp+0]
|
||||
mov cl,al
|
||||
|
||||
add esp,4
|
||||
|
||||
clc
|
||||
ret
|
||||
|
||||
|
||||
__sys_disable_mouse:
|
||||
cmp dword [0xf204],dword 0
|
||||
je @f
|
||||
ret
|
||||
@@:
|
||||
pushad
|
||||
cmp [0x3000],dword 1
|
||||
je disable_m
|
||||
mov edx,[0x3000]
|
||||
shl edx,5
|
||||
add edx,window_data
|
||||
movzx eax,word[0xfb0a]
|
||||
movzx ecx,word[mousepointer+10]
|
||||
sub eax,ecx
|
||||
movzx ebx,word[0xfb0c]
|
||||
movzx ecx,word[mousepointer+12]
|
||||
sub ebx,ecx
|
||||
mov ecx,[0xfe00]
|
||||
imul ecx,ebx
|
||||
add ecx,eax
|
||||
add ecx, display_data
|
||||
; mov eax, [0x3000]
|
||||
movzx eax, byte [edx+twdw+0xe]
|
||||
movzx ebx, byte [ecx]
|
||||
cmp eax,ebx
|
||||
je yes_mouse_disable
|
||||
movzx ebx, byte [ecx+32]
|
||||
cmp eax,ebx
|
||||
je yes_mouse_disable
|
||||
mov ebx,[0xfe00]
|
||||
inc ebx
|
||||
imul ebx,32
|
||||
add ecx,ebx
|
||||
movzx ebx, byte [ecx]
|
||||
cmp eax,ebx
|
||||
je yes_mouse_disable
|
||||
movzx ebx, byte [ecx+32]
|
||||
cmp eax,ebx
|
||||
je yes_mouse_disable
|
||||
jmp no_mouse_disable
|
||||
yes_mouse_disable:
|
||||
mov edx,[0x3000]
|
||||
shl edx,5
|
||||
add edx,window_data
|
||||
movzx eax, word [0xfb0a]
|
||||
movzx ebx, word [0xfb0c]
|
||||
movzx ecx,word[mousepointer+10]
|
||||
sub eax,ecx
|
||||
movzx ecx,word[mousepointer+12]
|
||||
sub ebx,ecx
|
||||
mov ecx,[edx+0] ; mouse inside the area ?
|
||||
add eax,32
|
||||
cmp eax,ecx
|
||||
jl no_mouse_disable
|
||||
sub eax,32
|
||||
add ecx,[edx+8]
|
||||
cmp eax,ecx
|
||||
jg no_mouse_disable
|
||||
mov ecx,[edx+4]
|
||||
add ebx,32
|
||||
cmp ebx,ecx
|
||||
jl no_mouse_disable
|
||||
sub ebx,32
|
||||
add ecx,[edx+12]
|
||||
cmp ebx,ecx
|
||||
jg no_mouse_disable
|
||||
disable_m:
|
||||
cmp dword [0xf204],dword 0
|
||||
jne no_mouse_disable
|
||||
cli
|
||||
call [draw_mouse_under]
|
||||
sti
|
||||
mov [0xf204],dword 1
|
||||
no_mouse_disable:
|
||||
popad
|
||||
ret
|
||||
|
||||
__sys_draw_pointer:
|
||||
cmp [mouse_pause],0
|
||||
je @f
|
||||
ret
|
||||
@@:
|
||||
push eax
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[MouseTickCounter]
|
||||
cmp eax,1
|
||||
ja @f
|
||||
pop eax
|
||||
ret
|
||||
@@:
|
||||
mov eax,[timer_ticks]
|
||||
mov [MouseTickCounter],eax
|
||||
pop eax
|
||||
pushad
|
||||
cmp dword [0xf204],dword 0 ; mouse visible ?
|
||||
je chms00
|
||||
mov [0xf204], dword 0
|
||||
movzx ebx,word [0xfb0c]
|
||||
movzx eax,word [0xfb0a]
|
||||
movzx esi,word[mousepointer+10]
|
||||
sub eax,esi
|
||||
movzx esi,word[mousepointer+12]
|
||||
sub ebx,esi
|
||||
cli
|
||||
call save_draw_mouse
|
||||
sti
|
||||
nodmu2:
|
||||
popad
|
||||
ret
|
||||
chms00:
|
||||
movsx ecx,word[0xfb4a]
|
||||
movsx edx,word[0xfb4c]
|
||||
movzx ebx,word [0xfb0c]
|
||||
movzx eax,word [0xfb0a]
|
||||
movzx esi,word[mousepointer+10]
|
||||
sub eax,esi
|
||||
movzx esi,word[mousepointer+12]
|
||||
sub ebx,esi
|
||||
cmp eax,ecx
|
||||
jne redrawmouse
|
||||
cmp ebx,edx
|
||||
jne redrawmouse
|
||||
jmp nodmp
|
||||
redrawmouse:
|
||||
cli
|
||||
call [draw_mouse_under]
|
||||
call save_draw_mouse
|
||||
sti
|
||||
nodmp:
|
||||
popad
|
||||
ret
|
||||
|
||||
191
kernel/branches/gfx_kernel/hid/set_dtc.inc
Normal file
191
kernel/branches/gfx_kernel/hid/set_dtc.inc
Normal file
@@ -0,0 +1,191 @@
|
||||
;setting date,time,clock and alarm-clock
|
||||
;add sys_settime at servetable as for ex. 22 fcn:
|
||||
; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK
|
||||
; ebx =0 - set time ecx - 00SSMMHH
|
||||
; ebx =1 - set date ecx=00DDMMYY
|
||||
; ebx =2 - set day of week ecx- 1-7
|
||||
; ebx =3 - set alarm-clock ecx - 00SSMMHH
|
||||
; out: 0 -Ok 1 -wrong format 2 -battery low
|
||||
sys_settime:
|
||||
mov ecx,eax
|
||||
cli
|
||||
mov al,0x0d
|
||||
out 0x70,al
|
||||
in al,0x71
|
||||
bt ax,7
|
||||
jnc bat_low
|
||||
cmp ecx,2 ;day of week
|
||||
jne nosetweek
|
||||
test ebx,ebx ;test day of week
|
||||
je wrongtime
|
||||
cmp ebx,7
|
||||
ja wrongtime
|
||||
mov dx,0x70
|
||||
call startstopclk
|
||||
dec edx
|
||||
mov al,6
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bl
|
||||
out dx,al
|
||||
jmp endsettime
|
||||
nosetweek: ;set date
|
||||
cmp ecx,1
|
||||
jne nosetdate
|
||||
cmp bl,0x99 ;test year
|
||||
ja wrongtime
|
||||
shl ebx,4
|
||||
cmp bl,0x90
|
||||
ja wrongtime
|
||||
cmp bh,0x99 ;test month
|
||||
ja wrongtime
|
||||
shr ebx,4
|
||||
test bh,bh
|
||||
je wrongtime
|
||||
cmp bh,0x12
|
||||
ja wrongtime
|
||||
shl ebx,8
|
||||
bswap ebx ;ebx=00YYMMDD
|
||||
test bl,bl ;test day
|
||||
je wrongtime
|
||||
shl ebx,4
|
||||
cmp bl,0x90
|
||||
ja wrongtime
|
||||
shr ebx,4
|
||||
cmp bh,2 ;February
|
||||
jne testday
|
||||
cmp bl,0x29
|
||||
ja wrongtime
|
||||
jmp setdate
|
||||
testday:
|
||||
cmp bh,8
|
||||
jb testday1 ;Aug-Dec
|
||||
bt bx,8
|
||||
jnc days31
|
||||
jmp days30
|
||||
testday1:
|
||||
bt bx,8 ;Jan-Jul ex.Feb
|
||||
jnc days30
|
||||
days31:
|
||||
cmp bl,0x31
|
||||
ja wrongtime
|
||||
jmp setdate
|
||||
days30:
|
||||
cmp bl,0x30
|
||||
ja wrongtime
|
||||
setdate:
|
||||
mov dx,0x70
|
||||
call startstopclk
|
||||
dec edx
|
||||
mov al,7 ;set days
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bl
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,8 ;set months
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bh
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,9 ;set years
|
||||
out dx,al
|
||||
inc edx
|
||||
shr ebx,8
|
||||
mov al,bh
|
||||
out dx,al
|
||||
jmp endsettime
|
||||
nosetdate: ;set time or alarm-clock
|
||||
cmp ecx,3
|
||||
ja wrongtime
|
||||
cmp bl,0x23
|
||||
ja wrongtime
|
||||
cmp bh,0x59
|
||||
ja wrongtime
|
||||
shl ebx,4
|
||||
cmp bl,0x90
|
||||
ja wrongtime
|
||||
cmp bh,0x92
|
||||
ja wrongtime
|
||||
shl ebx,4
|
||||
bswap ebx ;00HHMMSS
|
||||
cmp bl,0x59
|
||||
ja wrongtime
|
||||
shl ebx,4
|
||||
cmp bl,0x90
|
||||
ja wrongtime
|
||||
shr ebx,4
|
||||
mov dx,0x70
|
||||
call startstopclk
|
||||
dec edx
|
||||
cmp ecx,3
|
||||
je setalarm
|
||||
xor eax,eax ;al=0-set seconds
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bl
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,2 ;set minutes
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bh
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,4 ;set hours
|
||||
out dx,al
|
||||
inc edx
|
||||
shr ebx,8
|
||||
mov al,bh
|
||||
out dx,al
|
||||
jmp endsettime
|
||||
setalarm:
|
||||
mov al,1 ;set seconds for al.
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bl
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,3 ;set minutes for al.
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,bh
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,5 ;set hours for al.
|
||||
out dx,al
|
||||
inc edx
|
||||
shr ebx,8
|
||||
mov al,bh
|
||||
out dx,al
|
||||
dec edx
|
||||
mov al,0x0b ;enable irq's
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
bts ax,5 ;set bit 5
|
||||
out dx,al
|
||||
endsettime:
|
||||
dec edx
|
||||
call startstopclk
|
||||
sti
|
||||
mov [esp+36],dword 0
|
||||
ret
|
||||
bat_low:
|
||||
sti
|
||||
mov [esp+36],dword 2
|
||||
ret
|
||||
wrongtime:
|
||||
sti
|
||||
mov [esp+36],dword 1
|
||||
ret
|
||||
|
||||
startstopclk:
|
||||
mov al,0x0b
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
btc ax,7
|
||||
out dx,al
|
||||
ret
|
||||
5301
kernel/branches/gfx_kernel/kernel.asm
Normal file
5301
kernel/branches/gfx_kernel/kernel.asm
Normal file
File diff suppressed because it is too large
Load Diff
32
kernel/branches/gfx_kernel/kernel16.inc
Normal file
32
kernel/branches/gfx_kernel/kernel16.inc
Normal file
@@ -0,0 +1,32 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; KERNEL16.INC ;;
|
||||
;; ;;
|
||||
;; Included 16 bit kernel files for MenuetOS ;;
|
||||
;; ;;
|
||||
;; This file is kept separate as it will be easier to ;;
|
||||
;; maintain and compile with an automated SETUP program ;;
|
||||
;; in the future. ;;
|
||||
;; ;;
|
||||
;; Copyright Ville Turjanmaa, see file COPYING for details. ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;% +include
|
||||
|
||||
;!!!
|
||||
if lang eq en
|
||||
include "boot/booteng.inc" ; english system boot messages
|
||||
else
|
||||
include "boot/bootru.inc" ; russian system boot messages
|
||||
;!!!
|
||||
end if
|
||||
include "boot/ru.inc" ; Russian font
|
||||
org $-0x10000
|
||||
|
||||
include "boot/bootcode.inc" ; 16 bit system boot code
|
||||
|
||||
include "bus/pci/pci16.inc"
|
||||
|
||||
;% -include
|
||||
256
kernel/branches/gfx_kernel/kernel32.inc
Normal file
256
kernel/branches/gfx_kernel/kernel32.inc
Normal file
@@ -0,0 +1,256 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; KERNEL32.INC ;;
|
||||
;; ;;
|
||||
;; Included 32 bit kernel files for MenuetOS ;;
|
||||
;; ;;
|
||||
;; This file is kept separate as it will be easier to ;;
|
||||
;; maintain and compile with an automated SETUP program ;;
|
||||
;; in the future. ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; structure definition helper
|
||||
macro struct name, [arg]
|
||||
{
|
||||
common
|
||||
name@struct equ name
|
||||
struc name arg {
|
||||
}
|
||||
|
||||
macro struct_helper name
|
||||
{
|
||||
match xname,name
|
||||
\{
|
||||
virtual at 0
|
||||
xname xname
|
||||
sizeof.#xname = $ - xname
|
||||
name equ sizeof.#xname
|
||||
end virtual
|
||||
\}
|
||||
}
|
||||
|
||||
ends fix } struct_helper name@struct
|
||||
|
||||
;// mike.dld, 2006-29-01 [
|
||||
|
||||
; macros definition
|
||||
macro diff16 title,l1,l2
|
||||
{
|
||||
local s,d
|
||||
s = l2-l1
|
||||
display title,': 0x'
|
||||
repeat 8
|
||||
d = 48 + s shr ((8-%) shl 2) and $0F
|
||||
if d > 57
|
||||
d = d + 65-57-1
|
||||
end if
|
||||
display d
|
||||
end repeat
|
||||
display 13,10
|
||||
}
|
||||
|
||||
;struc db [a] { common . db a
|
||||
; if ~used .
|
||||
; display 'not used db: ',`.,13,10
|
||||
; end if }
|
||||
;struc dw [a] { common . dw a
|
||||
; if ~used .
|
||||
; display 'not used dw: ',`.,13,10
|
||||
; end if }
|
||||
;struc dd [a] { common . dd a
|
||||
; if ~used .
|
||||
; display 'not used dd: ',`.,13,10
|
||||
; end if }
|
||||
;struc dp [a] { common . dp a
|
||||
; if ~used .
|
||||
; display 'not used dp: ',`.,13,10
|
||||
; end if }
|
||||
;struc dq [a] { common . dq a
|
||||
; if ~used .
|
||||
; display 'not used dq: ',`.,13,10
|
||||
; end if }
|
||||
;struc dt [a] { common . dt a
|
||||
; if ~used .
|
||||
; display 'not used dt: ',`.,13,10
|
||||
; end if }
|
||||
|
||||
struc RECT {
|
||||
.left dd ?
|
||||
.top dd ?
|
||||
.right dd ?
|
||||
.bottom dd ?
|
||||
}
|
||||
virtual at 0
|
||||
RECT RECT
|
||||
end virtual
|
||||
|
||||
struc BOX {
|
||||
.left dd ?
|
||||
.top dd ?
|
||||
.width dd ?
|
||||
.height dd ?
|
||||
}
|
||||
virtual at 0
|
||||
BOX BOX
|
||||
end virtual
|
||||
|
||||
; constants definition
|
||||
WSTATE_NORMAL = 00000000b
|
||||
WSTATE_MAXIMIZED = 00000001b
|
||||
WSTATE_MINIMIZED = 00000010b
|
||||
WSTATE_ROLLEDUP = 00000100b
|
||||
|
||||
WSTATE_REDRAW = 00000001b
|
||||
WSTATE_WNDDRAWN = 00000010b
|
||||
|
||||
WSTYLE_HASCAPTION = 00010000b
|
||||
WSTYLE_CLIENTRELATIVE = 00100000b
|
||||
|
||||
struc TASKDATA
|
||||
{
|
||||
.event_mask dd ?
|
||||
.pid dd ?
|
||||
dw ?
|
||||
.state db ?
|
||||
db ?
|
||||
dw ?
|
||||
.wnd_number db ?
|
||||
db ?
|
||||
.mem_start dd ?
|
||||
.counter_sum dd ?
|
||||
.counter_add dd ?
|
||||
.cpu_usage dd ?
|
||||
}
|
||||
virtual at 0
|
||||
TASKDATA TASKDATA
|
||||
end virtual
|
||||
|
||||
; structures definition
|
||||
struc WDATA {
|
||||
.box BOX
|
||||
.cl_workarea dd ?
|
||||
.cl_titlebar dd ?
|
||||
.cl_frames dd ?
|
||||
.reserved db ?
|
||||
.fl_wstate db ?
|
||||
.fl_wdrawn db ?
|
||||
.fl_redraw db ?
|
||||
}
|
||||
virtual at 0
|
||||
WDATA WDATA
|
||||
end virtual
|
||||
label WDATA.fl_wstyle byte at 0x13
|
||||
|
||||
struc APPDATA
|
||||
{
|
||||
.app_name db 11 dup(?)
|
||||
db 5 dup(?)
|
||||
.fpu_save_area: db 108 dup(?)
|
||||
db 3 dup(?)
|
||||
.is_fpu_saved db ?
|
||||
.wnd_shape dd ?
|
||||
.wnd_shape_scale dd ?
|
||||
dd ?
|
||||
.mem_size dd ?
|
||||
.saved_box BOX
|
||||
.ipc_start dd ?
|
||||
.ipc_size dd ?
|
||||
.event_mask dd ?
|
||||
.debugger_slot dd ?
|
||||
dd ?
|
||||
.keyboard_mode db ?
|
||||
db 3 dup(?)
|
||||
.dir_table dd ?
|
||||
.dbg_event_mem dd ?
|
||||
.dbg_regs:
|
||||
.dbg_regs.dr0 dd ?
|
||||
.dbg_regs.dr1 dd ?
|
||||
.dbg_regs.dr2 dd ?
|
||||
.dbg_regs.dr3 dd ?
|
||||
.dbg_regs.dr7 dd ?
|
||||
.wnd_caption dd ?
|
||||
.wnd_clientbox BOX
|
||||
}
|
||||
virtual at 0
|
||||
APPDATA APPDATA
|
||||
end virtual
|
||||
|
||||
;// mike.dld, 2006-29-01 ]
|
||||
|
||||
|
||||
; Core functions
|
||||
include "core/sync.inc" ; macros for synhronization objects
|
||||
include "core/sys32.inc" ; process management
|
||||
include "core/sched.inc" ; process scheduling
|
||||
include "core/syscall.inc" ; system call
|
||||
include "core/mem.inc" ; high-level memory management
|
||||
include "core/newproce.inc" ;new process management
|
||||
include "core/physmem.inc" ; access to physical memory for applications
|
||||
|
||||
; GUI stuff
|
||||
include "gui/window.inc"
|
||||
include "gui/event.inc"
|
||||
include "gui/font.inc"
|
||||
include "gui/button.inc"
|
||||
|
||||
; shutdown
|
||||
|
||||
include "boot/shutdown.inc" ; shutdown or restart
|
||||
|
||||
; file system
|
||||
|
||||
include "fs/fs.inc" ; syscall
|
||||
include "fs/fat32.inc" ; read / write for fat32 filesystem
|
||||
include "fs/fat12.inc" ; read / write for fat12 filesystem
|
||||
include "blkdev/rd.inc" ; ramdisk read /write
|
||||
include "fs/fs_lfn.inc" ; syscall, version 2
|
||||
include "fs/iso9660.inc" ; read for iso9660 filesystem CD
|
||||
|
||||
; sound
|
||||
|
||||
include "sound/sb16.inc" ; playback for Sound Blaster 16
|
||||
include "sound/playnote.inc" ; player Note for Speaker PC
|
||||
|
||||
; display
|
||||
|
||||
include "video/vesa12.inc" ; Vesa 1.2 functions
|
||||
include "video/vesa20.inc" ; Vesa 2.0 functions
|
||||
include "video/vga.inc" ; VGA 16 color functions
|
||||
|
||||
; Network Interface & TCPIP Stack
|
||||
|
||||
include "network/stack.inc"
|
||||
|
||||
; Mouse pointer
|
||||
|
||||
include "gui/mouse.inc"
|
||||
|
||||
; Window skinning
|
||||
|
||||
include "gui/skincode.inc"
|
||||
|
||||
; Pci functions
|
||||
|
||||
include "bus/pci/pci32.inc"
|
||||
|
||||
; Floppy drive controller
|
||||
|
||||
include "blkdev/fdc.inc"
|
||||
include "blkdev/flp_drv.inc"
|
||||
|
||||
; CD drive controller
|
||||
|
||||
include "blkdev/cdrom.inc"
|
||||
include "blkdev/cd_drv.inc"
|
||||
|
||||
; Character devices
|
||||
|
||||
include "hid/keyboard.inc"
|
||||
include "hid/mousedrv.inc"
|
||||
|
||||
; setting date,time,clock and alarm-clock
|
||||
|
||||
include "hid/set_dtc.inc"
|
||||
|
||||
;% -include
|
||||
50
kernel/branches/gfx_kernel/kglobals.inc
Normal file
50
kernel/branches/gfx_kernel/kglobals.inc
Normal file
@@ -0,0 +1,50 @@
|
||||
;------------------------------------------------------------------
|
||||
; use "iglobal" for inserting initialized global data definitions.
|
||||
;------------------------------------------------------------------
|
||||
macro iglobal {
|
||||
IGlobals equ IGlobals,
|
||||
macro __IGlobalBlock { }
|
||||
|
||||
;-------------------------------------------------------------
|
||||
; use 'uglobal' for inserting uninitialized global definitions.
|
||||
; even when you define some data values, these variables
|
||||
; will be stored as uninitialized data.
|
||||
;-------------------------------------------------------------
|
||||
macro uglobal {
|
||||
UGlobals equ UGlobals,
|
||||
macro __UGlobalBlock { }
|
||||
|
||||
endg fix } ; Use endg for ending iglobal and uglobal blocks.
|
||||
|
||||
macro IncludeIGlobals{
|
||||
macro IGlobals dummy,[n] \{ __IGlobalBlock
|
||||
purge __IGlobalBlock \}
|
||||
match I, IGlobals \{ I \} }
|
||||
|
||||
|
||||
macro IncludeUGlobals{
|
||||
macro UGlobals dummy,[n] \{
|
||||
\common
|
||||
\local begin, size
|
||||
begin = $
|
||||
virtual at $
|
||||
\forward
|
||||
__UGlobalBlock
|
||||
purge __UGlobalBlock
|
||||
\common
|
||||
size = $ - begin
|
||||
end virtual
|
||||
rb size
|
||||
\}
|
||||
match U, UGlobals \{ U \} }
|
||||
|
||||
macro IncludeAllGlobals {
|
||||
IncludeIGlobals
|
||||
IncludeUGlobals
|
||||
}
|
||||
|
||||
iglobal
|
||||
endg
|
||||
|
||||
uglobal
|
||||
endg
|
||||
1
kernel/branches/gfx_kernel/lang.inc
Normal file
1
kernel/branches/gfx_kernel/lang.inc
Normal file
@@ -0,0 +1 @@
|
||||
lang fix en
|
||||
16
kernel/branches/gfx_kernel/makefile
Normal file
16
kernel/branches/gfx_kernel/makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
FASM=fasm
|
||||
KSRC=kernel.asm
|
||||
KOUT=kernel.mnt
|
||||
|
||||
en: kernel.asm
|
||||
rm -f lang.inc
|
||||
echo lang fix en > lang.inc
|
||||
$(FASM) $(KSRC) $(KOUT)
|
||||
ru: kernel.asm
|
||||
rm -f lang.inc
|
||||
echo lang fix ru > lang.inc
|
||||
$(FASM) $(KSRC) $(KOUT)
|
||||
|
||||
clean:
|
||||
rm -f $(KOUT)
|
||||
rm -f lang.inc
|
||||
237
kernel/branches/gfx_kernel/memmap.inc
Normal file
237
kernel/branches/gfx_kernel/memmap.inc
Normal file
@@ -0,0 +1,237 @@
|
||||
;
|
||||
; MEMORY MAP
|
||||
;
|
||||
; Boot:
|
||||
;
|
||||
; 0:9000 byte bits per pixel
|
||||
; 0:9001 word scanline length
|
||||
; 0:9008 word vesa video mode
|
||||
; 0:900A word X res
|
||||
; 0:900C word Y res
|
||||
; 0:9010 byte mouse port - not used
|
||||
; 0:9014 dword Vesa 1.2 pm bank switch
|
||||
; 0:9018 dword Vesa 2.0 LFB address
|
||||
; 0:901C byte 0 or 1 : enable MTRR graphics acceleration
|
||||
; 0:901D byte not used anymore (0 or 1 : enable system log display)
|
||||
; 0:901E byte 0 or 1 : enable direct lfb write, paging disabled
|
||||
; 0:9020 8bytes pci data
|
||||
; 0:9030 byte VRR start enabled 1, 2-no
|
||||
; 0:9031 word IDEContrRegsBaseAddr
|
||||
; 0:9034 byte vesa major version number (ascii)
|
||||
; 0:9035 byte card vendor (intel=1, s3=2, other=3)
|
||||
; 0x9040 - dword - entry point of APM BIOS
|
||||
; 0x9044 - word - version (BCD)
|
||||
; 0x9046 - word - flags
|
||||
;
|
||||
; Runtime:
|
||||
;
|
||||
; 0000 -> 1FFF window_data - 256 entries
|
||||
;
|
||||
; 0000 dword x start
|
||||
; 0004 dword y start
|
||||
; 0008 dword x size
|
||||
; 000C dword y size
|
||||
; 0010 dword color of work area
|
||||
; 0014 dword color of grab bar
|
||||
; 0018 dword color of frames
|
||||
; 001C dword window flags, +30 = window drawn, +31 redraw flag
|
||||
;
|
||||
; 2000 -> 2FFF free
|
||||
;
|
||||
; 3000 -> 4FFF task list - 256 entries
|
||||
;
|
||||
; 00 dword process count
|
||||
; 04 dword no of processes
|
||||
; 10 dword base of running process at 0x3000+
|
||||
;
|
||||
; 20 dword application event mask
|
||||
; 24 dword PID - process identification number
|
||||
; 2a byte slot state: 0=running, 1,2=suspended
|
||||
; 3=zombie, 4=terminate,
|
||||
; 5=waiting for event, 9 = not used
|
||||
; 2e byte window number on screen
|
||||
; 30 dword exact position in memory
|
||||
; 34 dword counter sum
|
||||
; 38 dword time stamp counter add
|
||||
; 3c dword cpu usage in cpu timer tics
|
||||
;
|
||||
;
|
||||
; 5000 -> 5FFF save_syscall_data - syscall trace
|
||||
; 6000 -> 68FF free
|
||||
; 6900 -> 6EFF saved picture under mouse pointer
|
||||
;
|
||||
; 6F00 -> 6FFF free
|
||||
;
|
||||
; 7000 -> 7FFF used CD driver
|
||||
;
|
||||
; 8000 -> A3FF used FLOPPY driver
|
||||
;
|
||||
; A400 -> B0FF free
|
||||
|
||||
; B100 -> B2FF IDT
|
||||
|
||||
; B300 -> BFFF free
|
||||
|
||||
; C000 -> C3FF window stack C000 no of windows - all in words
|
||||
; C402 -> C7FF window position in stack
|
||||
; D000 -> D1FF FDC controller
|
||||
; D200 -> D3FF FDC controller for Fat12
|
||||
; D400 -> DFFF free
|
||||
; E000 byte multitasking started
|
||||
; E020 dword putpixel address
|
||||
; E024 dword getpixel address
|
||||
; E030 dword Vesa 1.2 pm bank switch address
|
||||
; E034 byte vesa major version number (ascii)
|
||||
; E035 byte card vendor (intel=1, s3=2, other=3)
|
||||
; F200 dword mousepicture -pointer
|
||||
; F204 dword mouse appearance counter
|
||||
; F300 dword x & y temp for windowmove
|
||||
; F400 byte no of keys in buffer
|
||||
; F401 byte 'buffer'
|
||||
; F402 -> F4FF reserved for keys
|
||||
; F500 byte no of buttons in buffer
|
||||
; F501 dword 'buffer'
|
||||
; F502 -> F5FF reserved for buttons
|
||||
; F600 dword tsc / second
|
||||
; F604 byte mouse port: 1 ps2, 2 com1, 3 com2
|
||||
; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y
|
||||
; FB10 -> FB17 mouse color mem
|
||||
; FB21 x move
|
||||
; FB22 y move
|
||||
; FB28 high bits temp
|
||||
; FB30 color temp
|
||||
; FB40 byte buttons down
|
||||
; FB44 byte 0 mouse down -> do not draw
|
||||
; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under
|
||||
; FBF1 byte bits per pixel
|
||||
; FC00 -> FCFE com1/ps2 buffer
|
||||
; FCFF com1/ps2 buffer count starting from FC00
|
||||
; FE00 dword screen x size
|
||||
; FE04 dword screen y size
|
||||
; FE08 dword screen y multiplier
|
||||
; FE0C dword screen mode
|
||||
; FE10 dword entries in hd cache
|
||||
; FE80 dword address of LFB in physical
|
||||
; FE84 dword address of applications memory start in physical
|
||||
; FE88 dword address of button list
|
||||
; FE8C dword memory to use
|
||||
; FF00 byte 1 = system shutdown request
|
||||
; FF01 dword free
|
||||
; FFF0 byte 1 = redraw background request from app
|
||||
; FFF1 byte 1 = diskette int occur
|
||||
; FFF2 write and read bank in screen
|
||||
; FFF4 byte 0 if first mouse draw & do not return picture under
|
||||
; FFF5 byte 1 do not draw pointer
|
||||
; FFFF byte do not change task for 1/100 sec.
|
||||
;
|
||||
; 10000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb)
|
||||
; 3DC00 -> 3EBFF stack at boot time (4Kb)
|
||||
; 3EC00 -> 3F5FF basic text font II
|
||||
; 3F600 -> 3FFFF basic text font I
|
||||
; 40000 -> 4FFFF data of retrieved disks and partitions (Mario79)
|
||||
|
||||
; 50000 -> 5FFFF free (64 Kb)
|
||||
|
||||
; 60000 -> 7FFFF reserved to physical memory manager
|
||||
; 80000 -> 8FFFF additional app info, in 256 byte steps - 256 entries
|
||||
;
|
||||
; 00 11db name of app running
|
||||
; 10 108db floating point unit save area
|
||||
; 7f byte 0= no fpu saved , 1= fpu saved to 0x10 -> restore
|
||||
; 80 dword address of random shaped window area
|
||||
; 84 byte shape area scale
|
||||
; 88 dword free
|
||||
; 8C dword application memory size
|
||||
; 90 dword window X position save
|
||||
; 94 dword window Y position save
|
||||
; 98 dword window X size save
|
||||
; 9C dword window Y size save
|
||||
; A0 dword IPC memory start
|
||||
; A4 dword IPC memory size
|
||||
; A8 dword event bits: mouse, stack,..
|
||||
; AC dword 0 or debugger slot
|
||||
; B0 dword free
|
||||
; B4 byte keyboard mode: 0 = keymap, 1 = scancodes
|
||||
; B8 dword physical address of directory table
|
||||
; BC dword address of debug event memory
|
||||
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
|
||||
;
|
||||
; 90000 -> 9FFFF tmp
|
||||
; A0000 -> AFFFF screen access area
|
||||
; B0000 -> FFFFF bios rest in peace -area
|
||||
; 100000 -> 27FFFF diskette image
|
||||
; 280000 -> 281FFF ramdisk fat
|
||||
; 282000 -> 283FFF floppy fat
|
||||
;
|
||||
; 284000 -> 29FFFF free (112 Kb)
|
||||
;
|
||||
; 2A0000 -> 2B00ff wav device data
|
||||
; 2C0000 -> 2C3fff button info
|
||||
;
|
||||
; 0000 word number of buttons
|
||||
; first button entry at 0x10
|
||||
; +0000 word process number
|
||||
; +0002 word button id number : bits 00-15
|
||||
; +0004 word x start
|
||||
; +0006 word x size
|
||||
; +0008 word y start
|
||||
; +000A word y size
|
||||
; +000C word button id number : bits 16-31
|
||||
;
|
||||
; 2C4000 -> 2CFFFF free (48Kb)
|
||||
;
|
||||
; 2D0000 -> 2DFFFF reserved port area
|
||||
;
|
||||
; 0000 dword no of port areas reserved
|
||||
; 0010 dword process id
|
||||
; dword start port
|
||||
; dword end port
|
||||
; dword 0
|
||||
;
|
||||
; 2E0000 -> 2EFFFF irq data area
|
||||
; 2F0000 -> 2FFFFF low memory save
|
||||
;
|
||||
; 300000 -> 45FFFF background image, max 1,375 M
|
||||
;
|
||||
; 460000 -> 5FFFFF display info
|
||||
;
|
||||
; 600000 -> 6FFFFF hd cache
|
||||
;
|
||||
; 700000 -> 71ffff tcp memory (128 kb)
|
||||
; 720000 -> 75ffff free (256 kb)
|
||||
;
|
||||
; 760000 -> 76ffff !vrr driver
|
||||
; 770000 -> 777fff tcp memory ( 32 kb)
|
||||
;
|
||||
; 778000 -> 77ffff window skinning ( 32 kb)
|
||||
; 780000 -> 7fffff reserved to physical memory manager
|
||||
;
|
||||
; 800000 -> BFFFFF mapped to LFB
|
||||
;
|
||||
;
|
||||
; C00000 -> C01FFF draw_data - 256 entries
|
||||
;
|
||||
; 00 dword draw limit - x start
|
||||
; 04 dword draw limit - y start
|
||||
; 08 dword draw limit - x end
|
||||
; 0C dword draw limit - y end
|
||||
;
|
||||
; C02000 -> C02fff free (4 Kb)
|
||||
;
|
||||
; C03000 -> D02fff sysint_stack_data
|
||||
; - ring0 stacks for ring3 processes
|
||||
; - used for interrupt handling
|
||||
; - 256 entries * 4096 step
|
||||
;
|
||||
; D03000 -> D1ffff free (116 Kb)
|
||||
;
|
||||
; D20000 -> F28000 TSS and IO map for (8192*8)=65536 ports
|
||||
; (128+8192)*256 = 557956 = 0x88000
|
||||
;
|
||||
; 1000000 -> 3FFFFFF for applications
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1701
kernel/branches/gfx_kernel/network/eth_drv/ethernet.inc
Normal file
1701
kernel/branches/gfx_kernel/network/eth_drv/ethernet.inc
Normal file
File diff suppressed because it is too large
Load Diff
202
kernel/branches/gfx_kernel/network/ip.inc
Normal file
202
kernel/branches/gfx_kernel/network/ip.inc
Normal file
@@ -0,0 +1,202 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; IP.INC ;;
|
||||
;; ;;
|
||||
;; IP Processes for Menuet OS TCP/IP stack ;;
|
||||
;; ;;
|
||||
;; Version 0.3 29 August 2002 ;;
|
||||
;; ;;
|
||||
;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;*******************************************************************
|
||||
; Interface
|
||||
;
|
||||
; ip_rx processes all packets received by the network layer
|
||||
; It calls the appropriate protocol handler
|
||||
;
|
||||
;
|
||||
;
|
||||
;*******************************************************************
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; ip_rx
|
||||
;
|
||||
; Description
|
||||
; Handles received IP packets
|
||||
; This is a kernel function, called by stack_handler
|
||||
;
|
||||
;***************************************************************************
|
||||
ip_rx:
|
||||
; Look for a buffer to tx
|
||||
mov eax, IPIN_QUEUE
|
||||
call dequeue
|
||||
cmp ax, NO_BUFFER
|
||||
je ipr_exit ; Exit if no buffer available
|
||||
|
||||
push eax
|
||||
|
||||
; convert buffer pointer eax to the absolute address
|
||||
mov ecx, IPBUFFSIZE
|
||||
mul ecx
|
||||
add eax, IPbuffs
|
||||
|
||||
mov edx, eax ; Save the address in edx for use by future processes
|
||||
|
||||
; Validate the IP checksum
|
||||
mov ebx, edx
|
||||
mov ah, [ebx + 10]
|
||||
mov al, [ebx + 11] ; Get the checksum in intel format
|
||||
mov [ebx + 10], word 0 ; clear checksum field - need to when
|
||||
; recalculating checksum
|
||||
|
||||
; this needs two data pointers and two size #.
|
||||
; 2nd pointer can be of length 0
|
||||
mov ebx, edx
|
||||
mov [checkAdd1], ebx
|
||||
mov [checkSize1], word 20
|
||||
mov [checkAdd2], dword 0
|
||||
mov [checkSize2], word 0
|
||||
|
||||
call checksum ; Recalculate IP checksum
|
||||
cmp ax, [checkResult]
|
||||
jnz ipr_dump
|
||||
|
||||
; If the IP address is 255.255.255.255, accept it
|
||||
; - it is a broadcast packet, which we need for dhcp
|
||||
mov eax, [edx + 16]
|
||||
cmp eax, 0xffffffff
|
||||
je ipr_p0
|
||||
|
||||
; Validate the IP address, if it isn't broadcast
|
||||
cmp eax, [stack_ip]
|
||||
jnz ipr_dump
|
||||
|
||||
ipr_p0:
|
||||
mov al, [edx]
|
||||
and al, 0x0f
|
||||
cmp al, 0x05
|
||||
jnz ipr_dump
|
||||
|
||||
cmp [edx+8], byte 0
|
||||
jz ipr_dump
|
||||
|
||||
mov ax, [edx + 6]
|
||||
and ax, 0xFFBF
|
||||
cmp ax, 0
|
||||
jnz ipr_dump
|
||||
|
||||
; Check the protocol, and call the appropriate handler
|
||||
; Each handler will re-use or free the queue buffer as appropriate
|
||||
mov al, [edx + 9]
|
||||
cmp al , PROTOCOL_ICMP
|
||||
jnz ipr_p1
|
||||
pop eax
|
||||
call icmp_rx
|
||||
jmp ipr_exit
|
||||
|
||||
ipr_p1:
|
||||
cmp al , PROTOCOL_TCP
|
||||
jnz ipr_p2
|
||||
pop eax
|
||||
call tcp_rx
|
||||
jmp ipr_exit
|
||||
|
||||
ipr_p2:
|
||||
cmp al , PROTOCOL_UDP
|
||||
jnz ipr_dump
|
||||
pop eax
|
||||
call udp_rx
|
||||
jmp ipr_exit
|
||||
|
||||
ipr_dump:
|
||||
; No protocol handler available, so
|
||||
; silently dump the packet, freeing up the queue buffer
|
||||
|
||||
; inc dword [dumped_rx_count]
|
||||
|
||||
pop eax
|
||||
call freeBuff
|
||||
|
||||
ipr_exit:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; icmp_rx
|
||||
;
|
||||
; Description
|
||||
; ICMP protocol handler
|
||||
; This is a kernel function, called by ip_rx
|
||||
; edx contains the address of the buffer in use.
|
||||
; This buffer must be reused or marked as empty afterwards
|
||||
;
|
||||
;***************************************************************************
|
||||
icmp_rx:
|
||||
cmp [edx + 20], byte 8 ; Is this an echo request? discard if not
|
||||
jz icmp_echo
|
||||
|
||||
call freeBuff
|
||||
jmp icmp_exit
|
||||
|
||||
icmp_echo:
|
||||
push eax
|
||||
mov [edx + 10], word 0 ; I think this was already done by IP rx
|
||||
|
||||
; swap the source and destination addresses
|
||||
mov ecx, [edx + 16]
|
||||
mov eax, [edx + 12]
|
||||
mov [edx + 16], eax
|
||||
mov [edx + 12], ecx
|
||||
|
||||
; recaluculate the IP header checksum
|
||||
|
||||
mov ebx, edx
|
||||
mov [checkAdd1], ebx
|
||||
mov [checkSize1], word 20
|
||||
mov [checkAdd2], dword 0
|
||||
mov [checkSize2], word 0
|
||||
|
||||
call checksum
|
||||
mov ax, [checkResult]
|
||||
mov [edx + 10], ah
|
||||
mov [edx + 11], al ; ?? correct byte order?
|
||||
|
||||
mov [edx + 20], byte 0 ; change the request to a response
|
||||
mov [edx + 22], word 0 ; clear ICMP checksum prior to re-calc
|
||||
|
||||
; Calculate the length of the ICMP data ( IP payload)
|
||||
mov ah, [edx + 2]
|
||||
mov al, [edx + 3]
|
||||
sub ax, 20
|
||||
|
||||
mov [checkSize1], ax
|
||||
mov ebx, edx
|
||||
add ebx, 20
|
||||
|
||||
mov [checkAdd1], ebx
|
||||
mov [checkAdd2], dword 0
|
||||
mov [checkSize2], word 0
|
||||
|
||||
call checksum
|
||||
|
||||
mov ax, [checkResult]
|
||||
mov [edx + 22], ah
|
||||
mov [edx + 23], al
|
||||
|
||||
; Queue packet for transmission
|
||||
|
||||
pop ebx
|
||||
mov eax, NET1OUT_QUEUE
|
||||
call queue
|
||||
|
||||
icmp_exit:
|
||||
ret
|
||||
214
kernel/branches/gfx_kernel/network/queue.inc
Normal file
214
kernel/branches/gfx_kernel/network/queue.inc
Normal file
@@ -0,0 +1,214 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; QUEUE.INC ;;
|
||||
;; ;;
|
||||
;; Buffer queue management for Menuet OS TCP/IP Stack ;;
|
||||
;; ;;
|
||||
;; Version 0.3 29 August 2002 ;;
|
||||
;; ;;
|
||||
;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;*******************************************************************
|
||||
; Interface
|
||||
;
|
||||
; queueInit Configures the queues to empty
|
||||
; dequeue Removes a buffer pointer from a queue
|
||||
; queue Inserts a buffer pointer into a queue
|
||||
; freeBuff Adds the buffer pointer to the list of free buffers
|
||||
; queueSize Returns the number of entries in a queue
|
||||
;
|
||||
; The various defines for queue names can be found in stack.inc
|
||||
;
|
||||
;*******************************************************************
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; freeBuff
|
||||
;
|
||||
; Description
|
||||
; Adds a buffer number to the beginning of the free list.
|
||||
; buffer number in eax ( ms word zeroed )
|
||||
; all other registers preserved
|
||||
; This always works, so no error returned
|
||||
;***************************************************************************
|
||||
freeBuff:
|
||||
push ebx
|
||||
push ecx
|
||||
mov ebx, EMPTY_QUEUE
|
||||
shl ebx, 1
|
||||
add ebx, queues
|
||||
cli ; Ensure that another process does not interfer
|
||||
movzx ecx, word [ebx]
|
||||
mov [ebx], ax
|
||||
shl eax, 1
|
||||
add eax, queueList
|
||||
mov [eax], cx
|
||||
sti
|
||||
pop ecx
|
||||
pop ebx
|
||||
|
||||
ret
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; queueSize
|
||||
;
|
||||
; Description
|
||||
; Counts the number of entries in a queue
|
||||
; queue number in ebx ( ms word zeroed )
|
||||
; Queue size returned in eax
|
||||
; This always works, so no error returned
|
||||
;***************************************************************************
|
||||
queueSize:
|
||||
xor eax, eax
|
||||
shl ebx, 1
|
||||
add ebx, queues
|
||||
movzx ecx, word [ebx]
|
||||
cmp cx, NO_BUFFER
|
||||
je qs_exit
|
||||
|
||||
qs_001:
|
||||
inc eax
|
||||
shl ecx, 1
|
||||
add ecx, queueList
|
||||
movzx ecx, word [ecx]
|
||||
cmp cx, NO_BUFFER
|
||||
je qs_exit
|
||||
jmp qs_001
|
||||
|
||||
qs_exit:
|
||||
ret
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; queue
|
||||
;
|
||||
; Description
|
||||
; Adds a buffer number to the *end* of a queue
|
||||
; This is quite quick because these queues will be short
|
||||
; queue number in eax ( ms word zeroed )
|
||||
; buffer number in ebx ( ms word zeroed )
|
||||
; all other registers preserved
|
||||
; This always works, so no error returned
|
||||
;***************************************************************************
|
||||
queue:
|
||||
push ebx
|
||||
shl ebx, 1
|
||||
add ebx, queueList ; eax now holds address of queue entry
|
||||
mov [ebx], word NO_BUFFER ; This buffer will be the last
|
||||
|
||||
cli
|
||||
shl eax, 1
|
||||
add eax, queues ; eax now holds address of queue
|
||||
movzx ebx, word [eax]
|
||||
|
||||
cmp bx, NO_BUFFER
|
||||
jne qu_001
|
||||
|
||||
pop ebx
|
||||
; The list is empty, so add this to the head
|
||||
mov [eax], bx
|
||||
jmp qu_exit
|
||||
|
||||
qu_001:
|
||||
; Find the last entry
|
||||
shl ebx, 1
|
||||
add ebx, queueList
|
||||
mov eax, ebx
|
||||
movzx ebx, word [ebx]
|
||||
cmp bx, NO_BUFFER
|
||||
jne qu_001
|
||||
|
||||
mov ebx, eax
|
||||
pop eax
|
||||
mov [ebx], ax
|
||||
|
||||
qu_exit:
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; dequeue
|
||||
;
|
||||
; Description
|
||||
; removes a buffer number from the head of a queue
|
||||
; This is fast, as it unlinks the first entry in the list
|
||||
; queue number in eax ( ms word zeroed )
|
||||
; buffer number returned in eax ( ms word zeroed )
|
||||
; all other registers preserved
|
||||
;
|
||||
;***************************************************************************
|
||||
dequeue:
|
||||
push ebx
|
||||
shl eax, 1
|
||||
add eax, queues ; eax now holds address of queue
|
||||
mov ebx, eax
|
||||
cli
|
||||
movzx eax, word [eax]
|
||||
cmp ax, NO_BUFFER
|
||||
je dq_exit
|
||||
push eax
|
||||
shl eax, 1
|
||||
add eax, queueList ; eax now holds address of queue entry
|
||||
mov ax, [eax]
|
||||
mov [ebx], ax
|
||||
pop eax
|
||||
|
||||
dq_exit:
|
||||
sti
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; queueInit
|
||||
;
|
||||
; Description
|
||||
; Initialises the queues to empty, and creates the free queue
|
||||
; list.
|
||||
;
|
||||
;***************************************************************************
|
||||
queueInit:
|
||||
mov esi, queues
|
||||
mov ecx, NUMQUEUES
|
||||
mov ax, NO_BUFFER
|
||||
|
||||
qi001:
|
||||
mov [esi], ax
|
||||
inc esi
|
||||
inc esi
|
||||
loop qi001
|
||||
|
||||
mov esi, queues + ( 2 * EMPTY_QUEUE )
|
||||
|
||||
; Initialise empty queue list
|
||||
|
||||
xor ax, ax
|
||||
mov [esi], ax
|
||||
|
||||
mov ecx, NUMQUEUEENTRIES - 1
|
||||
mov esi, queueList
|
||||
|
||||
qi002:
|
||||
inc ax
|
||||
mov [esi], ax
|
||||
inc esi
|
||||
inc esi
|
||||
loop qi002
|
||||
|
||||
mov ax, NO_BUFFER
|
||||
mov [esi], ax
|
||||
|
||||
ret
|
||||
1784
kernel/branches/gfx_kernel/network/stack.inc
Normal file
1784
kernel/branches/gfx_kernel/network/stack.inc
Normal file
File diff suppressed because it is too large
Load Diff
1243
kernel/branches/gfx_kernel/network/tcp.inc
Normal file
1243
kernel/branches/gfx_kernel/network/tcp.inc
Normal file
File diff suppressed because it is too large
Load Diff
137
kernel/branches/gfx_kernel/network/udp.inc
Normal file
137
kernel/branches/gfx_kernel/network/udp.inc
Normal file
@@ -0,0 +1,137 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; UDP.INC ;;
|
||||
;; ;;
|
||||
;; UDP Processes for Menuet OS TCP/IP stack ;;
|
||||
;; ;;
|
||||
;; Version 0.3 29 August 2002 ;;
|
||||
;; ;;
|
||||
;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;*******************************************************************
|
||||
; Interface
|
||||
;
|
||||
; udp_rx Handles received IP packets with the UDP protocol
|
||||
;
|
||||
;*******************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; udp_rx
|
||||
;
|
||||
; Description
|
||||
; UDP protocol handler
|
||||
; This is a kernel function, called by ip_rx
|
||||
; IP buffer address given in edx
|
||||
; Free up (or re-use) IP buffer when finished
|
||||
;
|
||||
;***************************************************************************
|
||||
udp_rx:
|
||||
push eax
|
||||
|
||||
; First validate the header & checksum. Discard buffer if error
|
||||
|
||||
; Look for a socket where
|
||||
; IP Packet UDP Destination Port = local Port
|
||||
; IP Packet SA = Remote IP
|
||||
|
||||
movzx ebx, word [edx + 22] ; get the local port from
|
||||
; the IP packet's UDP header
|
||||
mov eax, SOCKETBUFFSIZE * NUM_SOCKETS
|
||||
mov ecx, NUM_SOCKETS
|
||||
|
||||
fs1:
|
||||
sub eax, SOCKETBUFFSIZE
|
||||
cmp [eax + sockets + 12], bx ; bx will hold the 'wrong' value,
|
||||
; but the comparision is correct
|
||||
loopnz fs1 ; Return back if no match
|
||||
jz fs_done
|
||||
|
||||
; No match, so exit
|
||||
jmp udprx_001
|
||||
|
||||
fs_done:
|
||||
; For dhcp, we must allow any remote server to respond.
|
||||
; I will accept the first incoming response to be the one
|
||||
; I bind to, if the socket is opened with a destination IP address of
|
||||
; 255.255.255.255
|
||||
mov ebx, [eax + sockets + 16]
|
||||
cmp ebx, 0xffffffff
|
||||
je udprx_002
|
||||
|
||||
mov ebx, [edx + 12] ; get the Source address from the IP packet
|
||||
cmp [eax + sockets + 16], ebx
|
||||
jne udprx_001 ; Quit if the source IP is not valid
|
||||
|
||||
udprx_002:
|
||||
; OK - we have a valid UDP packet for this socket.
|
||||
; First, update the sockets remote port number with the incoming msg
|
||||
; - it will have changed
|
||||
; from the original ( 69 normally ) to allow further connects
|
||||
movzx ebx, word [edx + 20] ; get the UDP source port
|
||||
; ( was 69, now new )
|
||||
mov [eax + sockets + 20], bx
|
||||
|
||||
; Now, copy data to socket. We have socket address as [eax + sockets].
|
||||
; We have IP packet in edx
|
||||
|
||||
; get # of bytes in ecx
|
||||
movzx ecx, byte [edx + 3] ; total length of IP packet. Subtract
|
||||
mov ch, byte [edx + 2] ; 20 + 8 gives data length
|
||||
sub ecx, 28
|
||||
|
||||
mov ebx, eax
|
||||
add ebx, sockets ; ebx = address of actual socket
|
||||
|
||||
mov eax, [ebx+ 4] ; get socket owner PID
|
||||
push eax
|
||||
|
||||
mov eax, [ebx + 24] ; get # of bytes already in buffer
|
||||
add [ebx + 24], ecx ; increment the count of bytes in buffer
|
||||
|
||||
; point to the location to store the data
|
||||
add ebx, eax
|
||||
add ebx, SOCKETHEADERSIZE
|
||||
|
||||
; ebx = location for first byte, ecx has count,
|
||||
; edx points to data
|
||||
|
||||
add edx, 28 ; edx now points to the data
|
||||
mov edi, ebx
|
||||
mov esi, edx
|
||||
|
||||
cld
|
||||
rep movsb ; copy the data across
|
||||
|
||||
; flag an event to the application
|
||||
pop eax
|
||||
mov ecx,1
|
||||
mov esi,0x3020+TASKDATA.pid
|
||||
|
||||
newsearch:
|
||||
cmp [esi],eax
|
||||
je foundPID
|
||||
inc ecx
|
||||
add esi,0x20
|
||||
cmp ecx,[0x3004]
|
||||
jbe newsearch
|
||||
|
||||
foundPID:
|
||||
shl ecx,8
|
||||
or dword [ecx+0x80000+APPDATA.event_mask],dword 10000000b ; stack event
|
||||
|
||||
mov [check_idle_semaphore],200
|
||||
|
||||
udprx_001:
|
||||
pop eax
|
||||
call freeBuff ; Discard the packet
|
||||
ret
|
||||
|
||||
BIN
kernel/branches/gfx_kernel/skin/base.bmp
Normal file
BIN
kernel/branches/gfx_kernel/skin/base.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 584 B |
BIN
kernel/branches/gfx_kernel/skin/base_1.bmp
Normal file
BIN
kernel/branches/gfx_kernel/skin/base_1.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 584 B |
31
kernel/branches/gfx_kernel/skin/default.asm
Normal file
31
kernel/branches/gfx_kernel/skin/default.asm
Normal file
@@ -0,0 +1,31 @@
|
||||
include 'me_skin.inc'
|
||||
|
||||
SKIN_PARAMS \
|
||||
height = bmp_base.height,\ ; skin height
|
||||
margins = [5:1:43:1],\ ; margins [left:top:right:bottom]
|
||||
colors active = [binner=0x00081d:\ ; border inner color
|
||||
bouter=0x00081d:\ ; border outer color
|
||||
bframe=0x0054e7],\ ; border frame color
|
||||
colors inactive = [binner=0x00081d:\ ; border inner color
|
||||
bouter=0x00081d:\ ; border outer color
|
||||
bframe=0x1a8acc],\ ; border frame color
|
||||
dtp = 'myblue.dtp' ; dtp colors
|
||||
|
||||
SKIN_BUTTONS \
|
||||
close = [-21:3][16:16],\ ; buttons coordinates
|
||||
minimize = [-39:3][16:16] ; [left:top][width:height]
|
||||
|
||||
SKIN_BITMAPS \
|
||||
left active = bmp_left,\ ; skin bitmaps pointers
|
||||
left inactive = bmp_left1,\
|
||||
oper active = bmp_oper,\
|
||||
oper inactive = bmp_oper1,\
|
||||
base active = bmp_base,\
|
||||
base inactive = bmp_base1
|
||||
|
||||
BITMAP bmp_left ,'left.bmp' ; skin bitmaps
|
||||
BITMAP bmp_oper ,'oper.bmp'
|
||||
BITMAP bmp_base ,'base.bmp'
|
||||
BITMAP bmp_left1,'left_1.bmp'
|
||||
BITMAP bmp_oper1,'oper_1.bmp'
|
||||
BITMAP bmp_base1,'base_1.bmp'
|
||||
BIN
kernel/branches/gfx_kernel/skin/left.bmp
Normal file
BIN
kernel/branches/gfx_kernel/skin/left.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 670 B |
BIN
kernel/branches/gfx_kernel/skin/left_1.bmp
Normal file
BIN
kernel/branches/gfx_kernel/skin/left_1.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 670 B |
235
kernel/branches/gfx_kernel/skin/me_skin.inc
Normal file
235
kernel/branches/gfx_kernel/skin/me_skin.inc
Normal file
@@ -0,0 +1,235 @@
|
||||
;============================================================================
|
||||
; This file should be used to generate skins of new standard
|
||||
;============================================================================
|
||||
; skin file structure:
|
||||
;----------------------------------------------------------------------------
|
||||
; header:
|
||||
; dd 'SKIN'
|
||||
; dd = version (1 for now)
|
||||
; dd @ params
|
||||
; dd @ buttons
|
||||
; dd @ bitmaps
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; NOTE: order of sections listed below is insignificant
|
||||
; since they're identified by pointer in above header
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; params:
|
||||
; dd = skin height
|
||||
; dw = right margin
|
||||
; dw = left margin
|
||||
; dw = bottom margin
|
||||
; dw = top margin
|
||||
; dd = inner line color
|
||||
; dd = outer line color
|
||||
; dd = frame color
|
||||
; dd = dtp file size
|
||||
; ?? = dtp file itself
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; buttons:
|
||||
; dd = button type (1 = close, 2 = minimize)
|
||||
; dw = left button coord (could be negative)
|
||||
; dw = top button coord (could be negative)
|
||||
; dw = button width
|
||||
; dw = button height
|
||||
; ... etc for all buttons
|
||||
; dd = 0 (end of buttons list)
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; bitmaps:
|
||||
; dw = bitmap kind (1 = left, 2 = oper, 3 = base)
|
||||
; dw = bitmap type (1 = active, 0 = inactive)
|
||||
; dd @ bitmap
|
||||
; ... etc for all bitmaps
|
||||
; dd 0 (end of bitmaps list)
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; bitmap:
|
||||
; dd = bitmap width
|
||||
; dd = bitmap height
|
||||
; ?? = raw bitmap data
|
||||
; ... etc for all bitmaps
|
||||
; ...
|
||||
;============================================================================
|
||||
|
||||
dd 'SKIN',1,__params__,__buttons__,__bitmaps__
|
||||
|
||||
struc BITMAPFILEHEADER {
|
||||
.bfType dw ? ; WORD
|
||||
.bfSize dd ? ; DWORD
|
||||
.bfReserved1 dw ? ; WORD
|
||||
.bfReserved2 dw ? ; WORD
|
||||
.bfOffBits dd ? ; DWORD
|
||||
}
|
||||
|
||||
struc BITMAPINFOHEADER {
|
||||
.biSize dd ? ; DWORD
|
||||
.biWidth dd ? ; LONG
|
||||
.biHeight dd ? ; LONG
|
||||
.biPlanes dw ? ; WORD
|
||||
.biBitCount dw ? ; WORD
|
||||
.biCompression dd ? ; DWORD
|
||||
.biSizeImage dd ? ; DWORD
|
||||
.biXPelsPerMeter dd ? ; LONG
|
||||
.biYPelsPerMeter dd ? ; LONG
|
||||
.biClrUsed dd ? ; DWORD
|
||||
.biClrImportant dd ? ; DWORD
|
||||
}
|
||||
|
||||
struc _bmp {
|
||||
.h BITMAPFILEHEADER
|
||||
.i BITMAPINFOHEADER
|
||||
}
|
||||
virtual at 0
|
||||
_bmp _bmp
|
||||
end virtual
|
||||
|
||||
macro BITMAP _name*,_fname*
|
||||
{
|
||||
local w,h,a,r,g,b
|
||||
virtual at 0
|
||||
file _fname
|
||||
load w dword from _bmp.i.biWidth
|
||||
load h dword from _bmp.i.biHeight
|
||||
end virtual
|
||||
align 4
|
||||
label _name
|
||||
.width = w
|
||||
.height = h
|
||||
dd w,h
|
||||
a=54+(w*3+(w mod 4))*(h-1)
|
||||
size = $
|
||||
repeat h
|
||||
repeat w
|
||||
virtual at 0
|
||||
file _fname
|
||||
load r from a+0
|
||||
load g from a+1
|
||||
load b from a+2
|
||||
end virtual
|
||||
db r,g,b
|
||||
a=a+3
|
||||
end repeat
|
||||
a=a-w*3*2-(w mod 4)
|
||||
end repeat
|
||||
}
|
||||
|
||||
macro define_colors name,[col,val]
|
||||
{
|
||||
common
|
||||
local a,b,c
|
||||
forward
|
||||
match =binner,col \{ a = val \}
|
||||
match =bouter,col \{ b = val \}
|
||||
match =bframe,col \{ c = val \}
|
||||
common
|
||||
name equ a,b,c
|
||||
}
|
||||
|
||||
macro SKIN_PARAMS [a]
|
||||
{
|
||||
common
|
||||
local _height,_margins,_colors,_colors_1,_dtp,_dtp_sz
|
||||
__params__:
|
||||
forward
|
||||
match qq == ww,a
|
||||
\{
|
||||
match =height,qq \\{ _height = ww \\}
|
||||
match =margins,qq \\{
|
||||
match [q1:q2:q3:q4],ww
|
||||
\\\{
|
||||
_margins equ q3,q1,q4,q2
|
||||
\\\}
|
||||
\\}
|
||||
match =colors =active,qq
|
||||
\\{
|
||||
match [q10==q11:q20==q21:q30==q31],ww
|
||||
\\\{
|
||||
define_colors _colors,q10,q11,q20,q21,q30,q31
|
||||
\\\}
|
||||
\\}
|
||||
match =colors =inactive,qq
|
||||
\\{
|
||||
match [q10==q11:q20==q21:q30==q31],ww
|
||||
\\\{
|
||||
define_colors _colors_1,q10,q11,q20,q21,q30,q31
|
||||
\\\}
|
||||
\\}
|
||||
match =dtp,qq \\{ _dtp equ ww \\}
|
||||
\}
|
||||
common
|
||||
dd _height
|
||||
dw _margins
|
||||
dd _colors,_colors_1
|
||||
virtual at 0
|
||||
file _dtp
|
||||
_dtp_sz = $
|
||||
end virtual
|
||||
dd _dtp_sz
|
||||
file _dtp
|
||||
}
|
||||
|
||||
macro SKIN_BUTTONS [a]
|
||||
{
|
||||
common
|
||||
local btn
|
||||
__buttons__:
|
||||
forward
|
||||
match qq == ww,a
|
||||
\{
|
||||
btn = 0
|
||||
match =close,qq \\{ btn = 1 \\}
|
||||
match =minimize,qq \\{ btn = 2 \\}
|
||||
match [q1:q2][q3:q4],ww
|
||||
\\{
|
||||
if btn <> 0
|
||||
dd btn
|
||||
dw q1,q2,q3,q4
|
||||
end if
|
||||
\\}
|
||||
\}
|
||||
common
|
||||
dd 0
|
||||
}
|
||||
|
||||
macro SKIN_BITMAPS [a]
|
||||
{
|
||||
common
|
||||
local bmp
|
||||
__bitmaps__:
|
||||
forward
|
||||
match qq == ww,a
|
||||
\{
|
||||
bmp=-1
|
||||
match qqq =active,qq \\{ bmp = 1 \\}
|
||||
match qqq =inactive,qq \\{ bmp = 0 \\}
|
||||
match =left qqq,qq
|
||||
\\{
|
||||
if bmp >= 0
|
||||
dw 1,bmp
|
||||
dd ww
|
||||
end if
|
||||
\\}
|
||||
match =oper qqq,qq
|
||||
\\{
|
||||
if bmp >= 0
|
||||
dw 2,bmp
|
||||
dd ww
|
||||
end if
|
||||
\\}
|
||||
match =base qqq,qq
|
||||
\\{
|
||||
if bmp >= 0
|
||||
dw 3,bmp
|
||||
dd ww
|
||||
end if
|
||||
\\}
|
||||
\}
|
||||
common
|
||||
dd 0
|
||||
}
|
||||
BIN
kernel/branches/gfx_kernel/skin/myblue.dtp
Normal file
BIN
kernel/branches/gfx_kernel/skin/myblue.dtp
Normal file
Binary file not shown.
BIN
kernel/branches/gfx_kernel/skin/oper.bmp
Normal file
BIN
kernel/branches/gfx_kernel/skin/oper.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
kernel/branches/gfx_kernel/skin/oper_1.bmp
Normal file
BIN
kernel/branches/gfx_kernel/skin/oper_1.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
135
kernel/branches/gfx_kernel/sound/playnote.inc
Normal file
135
kernel/branches/gfx_kernel/sound/playnote.inc
Normal file
@@ -0,0 +1,135 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; PLAYNOTE.INC version 1.1 22 November 2003 ;;
|
||||
;; ;;
|
||||
;; Player Notes for Speaker PC ;;
|
||||
;; subfunction #55 from function #55 Menuet OS ;;
|
||||
;; ;;
|
||||
;; Copyright 2003 VaStaNi ;;
|
||||
;; vastani@ukr.net ;;
|
||||
;; >>>- SIMPLY - QUICKLY - SHORTLY -<<< ;;
|
||||
;; ;;
|
||||
;; Note: playnote.txt ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
kontrOctave dw 0x4742, 0x4342, 0x3F7C, 0x3BEC, 0x388F, 0x3562
|
||||
dw 0x3264, 0x2F8F, 0x2CE4, 0x2A5F, 0x2802, 0x25BF
|
||||
memAdrNote dd 0
|
||||
pidProcessNote dd 0
|
||||
slotProcessNote dd 0
|
||||
count_timer_Note dd 1
|
||||
mem8253r42 dw 0
|
||||
countDelayNote db 0
|
||||
|
||||
playNote:
|
||||
; jmp NotPlayNotes
|
||||
mov esi, [memAdrNote]
|
||||
or esi, esi ; ESI = 0 ? - OFF Notes Play ?
|
||||
jz NotPlayNotes ; if ESI = 0 -> ignore play pocedure
|
||||
cmp eax, [count_timer_Note]
|
||||
jb NotPlayNotes
|
||||
push eax
|
||||
inc eax
|
||||
mov [count_timer_Note], eax
|
||||
mov al, [countDelayNote]
|
||||
dec al ; decrement counter Delay for Playing Note
|
||||
jz NewLoadNote@Delay
|
||||
cmp al, 0xFF ; this is first Note Play ?
|
||||
jne NextDelayNote
|
||||
;This is FIRST Note, save counter channel 2 chip 8253
|
||||
mov al, 0xB6 ; control byte to timer chip 8253
|
||||
out 0x43, al ; Send it to the control port chip 8253
|
||||
in al, 0x42 ; Read Lower byte counter channel 2 chip 8253
|
||||
mov ah, al ; AH = Lower byte counter channel 2
|
||||
in al, 0x42 ; Read Upper byte counter channel 2 chip 8253
|
||||
mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253
|
||||
NewLoadNote@Delay:
|
||||
cld
|
||||
; lodsb ; load AL - counter Delay
|
||||
call ReadNoteByte
|
||||
or al, al ; THE END ?
|
||||
jz EndPlayNote
|
||||
cmp al, 0x81
|
||||
jnc NoteforOctave
|
||||
mov [countDelayNote], al
|
||||
; lodsw ; load AX - counter for Note!
|
||||
call ReadNoteByte
|
||||
mov ah,al
|
||||
call ReadNoteByte
|
||||
xchg al,ah
|
||||
jmp pokeNote
|
||||
|
||||
EndPlayNote: ; THE END Play Notes!
|
||||
in al, 0x61 ; Get contents of system port B chip 8255
|
||||
and al, 0xFC ; Turn OFF timer and speaker
|
||||
out 0x61, al ; Send out new values to port B chip 8255
|
||||
mov ax, [mem8253r42] ; memorize counter channel 2 timer chip 8253
|
||||
xchg al, ah ; reverse byte in word
|
||||
out 0x42, al ; restore Lower byte counter channel 2
|
||||
mov al, ah ; AL = Upper byte counter channel 2
|
||||
out 0x42, al ; restore Upper byte channel 2
|
||||
xor eax, eax ; EAX = 0
|
||||
mov [memAdrNote], eax ; clear header control Delay-Note string
|
||||
NextDelayNote:
|
||||
mov [countDelayNote], al ; save new counter delay Note
|
||||
pop eax
|
||||
NotPlayNotes:
|
||||
RET
|
||||
|
||||
NoteforOctave:
|
||||
sub al, 0x81 ; correction value for delay Note
|
||||
mov [countDelayNote], al ; save counter delay this new Note
|
||||
; lodsb ; load pack control code
|
||||
call ReadNoteByte
|
||||
cmp al, 0xFF ; this is PAUSE ?
|
||||
jne packCode ; no, this is PACK CODE
|
||||
in al, 0x61 ; Get contents of system port B chip 8255
|
||||
and al, 0xFC ; Turn OFF timer and speaker
|
||||
out 0x61, al ; Send out new values to port B chip 8255
|
||||
jmp saveESI
|
||||
|
||||
packCode:
|
||||
mov cl, al ; save code
|
||||
and al, 0xF ; clear upper bits
|
||||
dec al ; correction
|
||||
add al, al ; transform number to offset constant
|
||||
movsx eax, al ; EAX - offset
|
||||
add eax, dword kontrOctave ; EAX - address from constant
|
||||
mov ax, [eax] ; read constant
|
||||
shr cl, 4 ; transform for number Octave
|
||||
shr ax, cl ; calculate from Note this Octave!
|
||||
pokeNote:
|
||||
out 0x42, al ; Lower byte Out to channel 2 timer chip 8253
|
||||
mov al, ah
|
||||
out 0x42, al ; Upper byte Out to channel 2 timer chip 8253
|
||||
in al, 0x61 ; Get contents of system port B chip 8255
|
||||
or al, 3 ; Turn ON timer and speaker
|
||||
out 0x61, al ; Send out new values to port B chip 8255
|
||||
saveESI:
|
||||
; mov [memAdrNote], esi ; save new header control Delay-Note string
|
||||
pop eax
|
||||
RET
|
||||
ReadNoteByte:
|
||||
;result:
|
||||
; al - note
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
mov eax,[pidProcessNote]
|
||||
call pid_to_slot
|
||||
test eax,eax
|
||||
jz .failed
|
||||
lea ebx,[esp+12]
|
||||
mov ecx,1
|
||||
mov edx,[memAdrNote]
|
||||
inc [memAdrNote]
|
||||
call read_process_memory
|
||||
.failed:
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
ret
|
||||
;------------------- END CODE -------------------
|
||||
350
kernel/branches/gfx_kernel/sound/sb16.inc
Normal file
350
kernel/branches/gfx_kernel/sound/sb16.inc
Normal file
@@ -0,0 +1,350 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SB16.INC ;;
|
||||
;; ;;
|
||||
;; Sound Blaster 16 functions for MenuetOS ;;
|
||||
;; ;;
|
||||
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;; - 11.07.2002 8 bit stereo mode - Ville Turjanmaa ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
SB16_load_music equ 0xc0000000
|
||||
SB16_play_music equ 0xc0000001
|
||||
DMAPage equ 0x2A
|
||||
Rate equ 44100
|
||||
SB16Buffer equ 0x2A0000
|
||||
SB16_Status equ SB16Buffer+65536
|
||||
|
||||
iglobal
|
||||
sound_data_format dd 0x1
|
||||
sound_data_length dd 65536
|
||||
sound_data_freq dd 44100
|
||||
endg
|
||||
|
||||
sound_interface:
|
||||
|
||||
cmp eax,0 ; Load data
|
||||
jne no_SB16_load_music
|
||||
mov edi,[0x3010]
|
||||
add edi,TASKDATA.mem_start
|
||||
add ebx,[edi]
|
||||
call code_SB16_load_music
|
||||
ret
|
||||
no_SB16_load_music:
|
||||
|
||||
cmp eax,1 ; Play data
|
||||
jne no_SB16_play_music
|
||||
call code_SB16_play_music
|
||||
ret
|
||||
no_SB16_play_music:
|
||||
|
||||
cmp eax,2 ; Set data formats
|
||||
jne no_SB16_data_format
|
||||
cmp ebx,0 ; ebx=0 play format
|
||||
jne no_sound_format
|
||||
mov [sound_data_format],ecx ; 1=8b mono, 2=8b stereo
|
||||
ret
|
||||
no_sound_format:
|
||||
cmp ebx,1 ; ebx=1 data length
|
||||
jne no_sound_length
|
||||
mov [sound_data_length],ecx ;
|
||||
ret
|
||||
no_sound_length:
|
||||
cmp ebx,2 ; ebx=2 sound data frequency
|
||||
jne no_sound_freq
|
||||
mov [sound_data_freq],ecx
|
||||
ret
|
||||
no_sound_freq:
|
||||
ret
|
||||
|
||||
no_SB16_data_format:
|
||||
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
cmp eax, edi ; this is subfunction #55 ?
|
||||
jne retFunc55 ; if no then return.
|
||||
cmp byte [sound_flag],0
|
||||
jne retFunc55
|
||||
movzx eax, byte [countDelayNote]
|
||||
or al, al ; player is busy ?
|
||||
jnz retFunc55 ; return counter delay Note
|
||||
; mov eax, [0x3010]
|
||||
; mov eax, [eax+0x10] ; address application im memory
|
||||
; add eax, edx ; add offset Delay-Note string
|
||||
; mov [memAdrNote], eax
|
||||
mov [memAdrNote],edx
|
||||
mov eax,[0x3010]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
mov [pidProcessNote],eax
|
||||
xor eax, eax ; Ok! EAX = 0
|
||||
retFunc55:
|
||||
mov [esp+36], eax ; return value EAX for application
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
code_SB16_play_music:
|
||||
|
||||
cmp [sound_data_format],1
|
||||
jne no_sound_8bm
|
||||
call sb_play_8b_mono
|
||||
ret
|
||||
no_sound_8bm:
|
||||
|
||||
cmp [sound_data_format],2
|
||||
jne no_sound_8bs
|
||||
call sb_play_8b_stereo
|
||||
ret
|
||||
no_sound_8bs:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Blaster_command:
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov dx,word [sb16]
|
||||
add dx,0xc
|
||||
mov cx,1000
|
||||
bcl1:
|
||||
in al,dx
|
||||
and al,128
|
||||
jz bcl2
|
||||
loop bcl1
|
||||
bcl2:
|
||||
mov al,[esp+8]
|
||||
mov dx,[esp+0]
|
||||
add dx,word [sb16]
|
||||
out dx,al
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop eax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
sb_play_8b_stereo:
|
||||
|
||||
pusha
|
||||
|
||||
call sb_set_dma
|
||||
|
||||
call sb_set_stereo
|
||||
|
||||
mov dx,0xc
|
||||
mov al,0xa8
|
||||
call Blaster_command
|
||||
|
||||
mov al,0x40
|
||||
call Blaster_command
|
||||
|
||||
mov al,245
|
||||
call Blaster_command
|
||||
|
||||
mov al,0x48
|
||||
call Blaster_command
|
||||
|
||||
mov al,0xff
|
||||
call Blaster_command
|
||||
call Blaster_command
|
||||
|
||||
mov al,0x91
|
||||
call Blaster_command
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sb_set_stereo:
|
||||
|
||||
push eax
|
||||
push edx
|
||||
|
||||
call sb_wait
|
||||
|
||||
mov dx,word [sb16]
|
||||
add dx,0x4
|
||||
mov al,0xe
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
and al,253
|
||||
or al,2 ; stereo
|
||||
out dx,al
|
||||
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
|
||||
|
||||
code_SB16_load_music:
|
||||
|
||||
cmp byte [SB16_Status],1
|
||||
je nol
|
||||
mov edi,SB16Buffer
|
||||
mov esi,ebx
|
||||
mov ecx,65536/4
|
||||
cld
|
||||
rep movsd
|
||||
nol: ret
|
||||
|
||||
|
||||
iglobal
|
||||
dma_table db 0x87,0x83,0x81,0x82
|
||||
endg
|
||||
|
||||
|
||||
|
||||
;--------------------------------
|
||||
; program dma
|
||||
;--------------------------------
|
||||
|
||||
sb_set_dma:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,[sound_dma]
|
||||
add eax,4
|
||||
out 0xa,al
|
||||
|
||||
mov al,0
|
||||
out 0xc,al
|
||||
|
||||
mov eax,[sound_dma]
|
||||
add eax,0x48
|
||||
out 0xb,al
|
||||
|
||||
mov edx,[sound_dma]
|
||||
shl edx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov edx,[sound_dma]
|
||||
add edx,dma_table
|
||||
movzx edx,byte [edx]
|
||||
mov al,DMAPage
|
||||
out dx,al
|
||||
|
||||
mov edx,[sound_dma]
|
||||
shl edx,1
|
||||
inc edx
|
||||
mov eax,[sound_data_length]
|
||||
dec eax
|
||||
and eax,0xff
|
||||
; mov al,(DataLength-1) and 0xff
|
||||
out dx,al
|
||||
|
||||
mov eax,[sound_data_length]
|
||||
dec eax
|
||||
shr eax,8
|
||||
; mov al,(DataLength-1) shr 8
|
||||
out dx,al
|
||||
|
||||
mov eax,[sound_dma] ; DMA
|
||||
out 0xa,al
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sb_play_8b_mono:
|
||||
|
||||
|
||||
call sb_set_dma
|
||||
|
||||
cmp byte [SB16_Status],1
|
||||
jne contsb16
|
||||
jmp retserve
|
||||
contsb16:
|
||||
|
||||
mov dx,word [sb16]
|
||||
add dx,4
|
||||
mov ecx,[sound_dma]
|
||||
mov ax,0x01
|
||||
shl ax,cl
|
||||
shl ax,8
|
||||
add ax,0x81
|
||||
out dx,ax
|
||||
|
||||
mov ax,0f280h ;enable irq5
|
||||
out dx,ax
|
||||
|
||||
|
||||
adr1_SB: mov dx,word [sb16]
|
||||
add dx,0ch
|
||||
in al,dx
|
||||
and al,080h
|
||||
jnz adr1_SB
|
||||
|
||||
call sb_set_stereo
|
||||
|
||||
mov al,0d1h
|
||||
out dx,al
|
||||
|
||||
|
||||
mov dx,word [sb16]
|
||||
add dx,0ch
|
||||
|
||||
call sb_wait
|
||||
|
||||
mov al,40h ; Rate
|
||||
out dx,al
|
||||
call sb_wait
|
||||
mov al,256-1000000/Rate
|
||||
out dx,al
|
||||
|
||||
call sb_wait
|
||||
|
||||
mov al,14h ; Datalength
|
||||
out dx,al
|
||||
call sb_wait
|
||||
|
||||
mov eax,[sound_data_length]
|
||||
dec eax
|
||||
and eax,0xff
|
||||
;mov al,(DataLength-1) and 0xff
|
||||
out dx,al
|
||||
call sb_wait
|
||||
mov eax,[sound_data_length]
|
||||
dec eax
|
||||
shr eax,8
|
||||
;mov al,(DataLength-1) shr 8
|
||||
out dx,al
|
||||
|
||||
retserve:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
sb_wait: in al,dx ;wait
|
||||
and al,080h
|
||||
jnz sb_wait
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
;****************************************
|
||||
; END CODE SB16 by Minazzi Paolo
|
||||
;***************************************
|
||||
987
kernel/branches/gfx_kernel/video/vesa12.inc
Normal file
987
kernel/branches/gfx_kernel/video/vesa12.inc
Normal file
@@ -0,0 +1,987 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; VESA12.INC ;;
|
||||
;; ;;
|
||||
;; Vesa 1.2 functions for MenuetOS ;;
|
||||
;; ;;
|
||||
;; Copyright 2002 Ville Turjanmaa ;;
|
||||
;; ;;
|
||||
;; quickcode@mail.ru - bankswitch for S3 cards ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
; A complete video driver should include the following types of function
|
||||
;
|
||||
; Putpixel
|
||||
; Getpixel
|
||||
;
|
||||
; Drawimage
|
||||
; Drawbar
|
||||
;
|
||||
; Drawbackground
|
||||
;
|
||||
;
|
||||
; Modifying the set_bank -function is mostly enough
|
||||
; for different Vesa 1.2 setups.
|
||||
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
; set_bank for Trident videocards, work on Trident 9440
|
||||
; modified by Mario79
|
||||
;set_bank:
|
||||
;cli
|
||||
;cmp al,[0xfff2]
|
||||
;je retsb
|
||||
;mov [0xfff2],al
|
||||
;push dx
|
||||
;mov dx,3D8h
|
||||
;out dx,al
|
||||
;pop dx
|
||||
;retsb:
|
||||
;sti
|
||||
;ret
|
||||
|
||||
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
; set_bank for S3 videocards, work on S3 ViRGE PCI (325)
|
||||
; modified by kmeaw
|
||||
set_bank:
|
||||
pushfd
|
||||
cli
|
||||
cmp al,[0xfff2]
|
||||
je retsb
|
||||
mov [0xfff2],al
|
||||
push ax
|
||||
push dx
|
||||
push cx
|
||||
mov cl, al
|
||||
mov dx, 0x3D4
|
||||
mov al, 0x38
|
||||
out dx, al ;CR38 Register Lock 1 ;Note: Traditionally 48h is used to
|
||||
;unlock and 00h to lock
|
||||
inc dx
|
||||
mov al, 0x48
|
||||
out dx, al ;3d5 -?
|
||||
dec dx
|
||||
mov al, 0x31
|
||||
out dx, al ;CR31 Memory Configuration Register
|
||||
;0 Enable Base Address Offset (CPUA BASE). Enables bank operation if set, ;disables if clear.
|
||||
;4-5 Bit 16-17 of the Display Start Address. For the 801/5,928 see index 51h,
|
||||
;for the 864/964 see index 69h.
|
||||
|
||||
inc dx
|
||||
in al, dx
|
||||
dec dx
|
||||
mov ah, al
|
||||
mov al, 0x31
|
||||
out dx, ax
|
||||
mov al, ah
|
||||
or al, 9
|
||||
inc dx
|
||||
out dx, al
|
||||
dec dx
|
||||
mov al, 0x35
|
||||
out dx, al ;CR35 CRT Register Lock
|
||||
inc dx
|
||||
in al, dx
|
||||
dec dx
|
||||
and al, 0xF0
|
||||
mov ch, cl
|
||||
and ch, 0x0F
|
||||
or ch, al
|
||||
mov al, 0x35
|
||||
out dx, al
|
||||
inc dx
|
||||
mov al, ch
|
||||
out dx, ax
|
||||
dec dx
|
||||
mov al, 0x51 ;Extended System Control 2 Register
|
||||
out dx, al
|
||||
inc dx
|
||||
in al, dx
|
||||
dec dx
|
||||
and al, 0xF3
|
||||
shr cl, 2
|
||||
and cl, 0x0C
|
||||
or cl, al
|
||||
mov al, 0x51
|
||||
out dx, al
|
||||
inc dx
|
||||
mov al, cl
|
||||
out dx, al
|
||||
dec dx
|
||||
mov al, 0x38
|
||||
out dx, al
|
||||
inc dx
|
||||
xor al, al
|
||||
out dx, al
|
||||
dec dx
|
||||
pop cx
|
||||
pop dx
|
||||
pop ax
|
||||
retsb:
|
||||
popfd
|
||||
ret
|
||||
|
||||
;Set bank function for Intel 810/815 chipsets
|
||||
; *****Modified by Protopopius, Russia.*****
|
||||
; ********* http://menuetos.hut.ru **************
|
||||
; ************************************************
|
||||
;
|
||||
;set_bank:
|
||||
;cli
|
||||
;cmp al,[0xfff2]
|
||||
;je retsb
|
||||
;mov [0xfff2],al
|
||||
;push ax
|
||||
;push dx
|
||||
;mov dx,3CEh
|
||||
;mov ah,al ; Save value for later use
|
||||
;mov al,10h ; Index GR10 (Address Mapping)
|
||||
;out dx,al ; Select GR10
|
||||
;inc dl
|
||||
;mov al,3 ; Set bits 0 and 1 (Enable linear page mapping)
|
||||
;out dx,al ; Write value
|
||||
;dec dl
|
||||
;mov al,11h ; Index GR11 (Page Selector)
|
||||
;out dx,al ; Select GR11
|
||||
;inc dl
|
||||
;mov al,ah ; Write address
|
||||
;out dx,al ; Write the value
|
||||
;pop dx
|
||||
;pop ax
|
||||
;retsb:
|
||||
;sti
|
||||
;ret
|
||||
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
|
||||
|
||||
;set_bank:
|
||||
; cli
|
||||
; cmp al,[0xfff2]
|
||||
; je retsb
|
||||
; mov [0xfff2],al
|
||||
; push ax
|
||||
; push dx
|
||||
; mov ah,al
|
||||
; mov dx,0x03D4
|
||||
; mov al,0x39
|
||||
; out dx,al
|
||||
; inc dl
|
||||
; mov al,0xA5
|
||||
; out dx,al
|
||||
; dec dl
|
||||
; mov al,6Ah
|
||||
; out dx,al
|
||||
; inc dl
|
||||
; mov al,ah
|
||||
; out dx,al
|
||||
; dec dl
|
||||
; mov al,0x39
|
||||
; out dx,al
|
||||
; inc dl
|
||||
; mov al,0x5A
|
||||
; out dx,al
|
||||
; dec dl
|
||||
; pop dx
|
||||
; pop ax
|
||||
;
|
||||
; retsb:
|
||||
; ret
|
||||
|
||||
|
||||
vesa12_drawbackground:
|
||||
|
||||
call [disable_mouse]
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
xor edx,edx
|
||||
mov eax,dword[WinMapAddress-8]
|
||||
mov ebx,dword[WinMapAddress-4]
|
||||
mul ebx
|
||||
mov ebx,3
|
||||
mul ebx
|
||||
mov [imax],eax
|
||||
mov eax,[draw_data+32+RECT.left]
|
||||
mov ebx,[draw_data+32+RECT.top]
|
||||
mov edi,0 ;no force
|
||||
|
||||
v12dp3:
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
mov esi,0x300000
|
||||
|
||||
cmp [WinMapAddress-12],dword 1 ; tiled background
|
||||
jne no_vesa12_tiled_bgr
|
||||
|
||||
push edx
|
||||
|
||||
xor edx,edx
|
||||
mov ecx,[WinMapAddress-8]
|
||||
div ecx
|
||||
mov eax,edx
|
||||
|
||||
push eax
|
||||
mov eax,ebx
|
||||
xor edx,edx
|
||||
mov ecx,[WinMapAddress-4]
|
||||
div ecx
|
||||
mov ebx,edx
|
||||
pop eax
|
||||
|
||||
pop edx
|
||||
|
||||
no_vesa12_tiled_bgr:
|
||||
|
||||
cmp [WinMapAddress-12],dword 2 ; stretched background
|
||||
jne no_vesa12_stretched_bgr
|
||||
|
||||
push edx
|
||||
|
||||
imul eax,dword [WinMapAddress-8]
|
||||
xor edx,edx
|
||||
mov ecx,[0xfe00]
|
||||
inc ecx
|
||||
div ecx
|
||||
|
||||
push eax
|
||||
mov eax,ebx
|
||||
imul eax,dword [WinMapAddress-4]
|
||||
xor edx,edx
|
||||
mov ecx,[0xfe04]
|
||||
inc ecx
|
||||
div ecx
|
||||
mov ebx,eax
|
||||
pop eax
|
||||
|
||||
pop edx
|
||||
|
||||
no_vesa12_stretched_bgr:
|
||||
|
||||
|
||||
push eax
|
||||
mov eax,ebx
|
||||
xor edx,edx
|
||||
mov ebx,[WinMapAddress-8]
|
||||
add ebx,[WinMapAddress-8]
|
||||
add ebx,[WinMapAddress-8]
|
||||
mul ebx
|
||||
mov esi,eax
|
||||
pop eax
|
||||
add esi,eax
|
||||
add esi,eax
|
||||
add esi,eax
|
||||
add esi,0x300000
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
v12di4:
|
||||
|
||||
mov ecx,[esi]
|
||||
pusha
|
||||
mov esi,eax
|
||||
mov edi,ebx
|
||||
mov eax,[0xfe00]
|
||||
add eax,1
|
||||
mul ebx
|
||||
add eax,esi
|
||||
add eax,WinMapAddress
|
||||
cmp [eax],byte 1
|
||||
jnz v12nbgp
|
||||
mov eax,[0xfe08]
|
||||
mov ebx,edi
|
||||
mul ebx
|
||||
add eax,esi
|
||||
add eax,esi
|
||||
add eax,esi
|
||||
cmp [0xFBF1],byte 24
|
||||
jz v12bgl3
|
||||
add eax,esi
|
||||
|
||||
v12bgl3:
|
||||
|
||||
push ebx
|
||||
push eax
|
||||
|
||||
sub eax,[0xfe80]
|
||||
|
||||
shr eax,16
|
||||
call set_bank
|
||||
pop eax
|
||||
and eax,65535
|
||||
add eax,0xa0000
|
||||
pop ebx
|
||||
|
||||
mov [eax],cx
|
||||
add eax,2
|
||||
shr ecx,16
|
||||
mov [eax],cl
|
||||
sti
|
||||
|
||||
v12nbgp:
|
||||
|
||||
popa
|
||||
add esi,3
|
||||
inc eax
|
||||
cmp eax,[draw_data+32+RECT.right]
|
||||
jg v12nodp31
|
||||
jmp v12dp3
|
||||
|
||||
v12nodp31:
|
||||
|
||||
mov eax,[draw_data+32+RECT.left]
|
||||
inc ebx
|
||||
cmp ebx,[draw_data+32+RECT.bottom]
|
||||
jg v12dp4
|
||||
jmp v12dp3
|
||||
|
||||
v12dp4:
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
|
||||
vesa12_drawbar:
|
||||
|
||||
call [disable_mouse]
|
||||
|
||||
;; mov [novesachecksum],dword 0
|
||||
sub edx,ebx
|
||||
sub ecx,eax
|
||||
push esi
|
||||
push edi
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
mov ecx,[0x3010]
|
||||
add eax,[ecx-twdw+WDATA.box.left]
|
||||
add ebx,[ecx-twdw+WDATA.box.top]
|
||||
push eax
|
||||
mov eax,ebx ; y
|
||||
mov ebx,[0xfe08]
|
||||
mul ebx
|
||||
pop ecx
|
||||
add eax,ecx ; x
|
||||
add eax,ecx
|
||||
add eax,ecx
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ? - x start
|
||||
jz dbpi2412
|
||||
add eax,ecx
|
||||
|
||||
dbpi2412:
|
||||
|
||||
add eax,[0xfe80]
|
||||
mov edi,eax
|
||||
|
||||
; x size
|
||||
|
||||
mov eax,[esp+4] ; [esp+6]
|
||||
mov ecx,eax
|
||||
add ecx,eax
|
||||
add ecx,eax
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ? - x size
|
||||
jz dbpi24312
|
||||
add ecx,eax
|
||||
|
||||
dbpi24312:
|
||||
|
||||
mov ebx,[esp+0]
|
||||
|
||||
; check limits ?
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
mov eax,[0x3010]
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.left]
|
||||
cmp ecx,0
|
||||
jnz dbcblimitlset12
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.top]
|
||||
cmp ecx,0
|
||||
jnz dbcblimitlset12
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.right]
|
||||
cmp ecx,[0xfe00]
|
||||
jnz dbcblimitlset12
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.bottom]
|
||||
cmp ecx,[0xfe04]
|
||||
jnz dbcblimitlset12
|
||||
pop ecx
|
||||
pop eax
|
||||
push dword 0
|
||||
jmp dbcblimitlno12
|
||||
|
||||
dbcblimitlset12:
|
||||
|
||||
pop ecx
|
||||
pop eax
|
||||
push dword 1
|
||||
|
||||
dbcblimitlno12:
|
||||
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ?
|
||||
jz dbpi24bit12
|
||||
jmp dbpi32bit12
|
||||
|
||||
|
||||
; DRAWBAR 24 BBP
|
||||
|
||||
|
||||
dbpi24bit12:
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push edx
|
||||
mov eax,ecx
|
||||
mov ebx,3
|
||||
div ebx
|
||||
mov ecx,eax
|
||||
pop edx
|
||||
pop ebx
|
||||
pop eax
|
||||
cld
|
||||
|
||||
dbnewpi12:
|
||||
|
||||
push ebx
|
||||
push edi
|
||||
push ecx
|
||||
|
||||
xor edx,edx
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
mov ebx,3
|
||||
div ebx
|
||||
add eax,WinMapAddress
|
||||
mov ebx,[0x3000]
|
||||
cld
|
||||
|
||||
dbnp2412:
|
||||
|
||||
mov dl,[eax]
|
||||
push eax
|
||||
push ecx
|
||||
cmp dl,bl
|
||||
jnz dbimp24no12
|
||||
cmp [esp+5*4],dword 0
|
||||
jz dbimp24yes12
|
||||
; call dbcplimit
|
||||
; jnz dbimp24no12
|
||||
|
||||
dbimp24yes12:
|
||||
|
||||
push edi
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,0xffff
|
||||
add edi,0xa0000
|
||||
mov eax,[esp+8+3*4+16+4+4]
|
||||
stosw
|
||||
shr eax,16
|
||||
stosb
|
||||
sti
|
||||
pop edi
|
||||
add edi,3
|
||||
pop ecx
|
||||
pop eax
|
||||
inc eax
|
||||
loop dbnp2412
|
||||
jmp dbnp24d12
|
||||
|
||||
dbimp24no12:
|
||||
|
||||
pop ecx
|
||||
pop eax
|
||||
cld
|
||||
add edi,3
|
||||
inc eax
|
||||
loop dbnp2412
|
||||
|
||||
dbnp24d12:
|
||||
|
||||
mov eax,[esp+3*4+16+4]
|
||||
test eax,0x80000000
|
||||
jz nodbgl2412
|
||||
cmp al,0
|
||||
jz nodbgl2412
|
||||
dec eax
|
||||
mov [esp+3*4+16+4],eax
|
||||
|
||||
nodbgl2412:
|
||||
|
||||
pop ecx
|
||||
pop edi
|
||||
pop ebx
|
||||
add edi,[0xfe08]
|
||||
dec ebx
|
||||
jz dbnonewpi12
|
||||
jmp dbnewpi12
|
||||
|
||||
dbnonewpi12:
|
||||
|
||||
add esp,7*4
|
||||
|
||||
ret
|
||||
|
||||
|
||||
; DRAWBAR 32 BBP
|
||||
|
||||
|
||||
dbpi32bit12:
|
||||
|
||||
cld
|
||||
shr ecx,2
|
||||
|
||||
dbnewpi3212:
|
||||
|
||||
push ebx
|
||||
push edi
|
||||
push ecx
|
||||
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
shr eax,2
|
||||
add eax,WinMapAddress
|
||||
mov ebx,[0x3000]
|
||||
cld
|
||||
|
||||
dbnp3212:
|
||||
|
||||
mov dl,[eax]
|
||||
push eax
|
||||
push ecx
|
||||
cmp dl,bl
|
||||
jnz dbimp32no12
|
||||
cmp [esp+5*4],dword 0
|
||||
jz dbimp32yes12
|
||||
; call dbcplimit
|
||||
; jnz dbimp32no12
|
||||
|
||||
dbimp32yes12:
|
||||
|
||||
push edi
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,0xffff
|
||||
add edi,0xa0000
|
||||
mov eax,[esp+8+3*4+16+4+4]
|
||||
stosw
|
||||
shr eax,16
|
||||
stosb
|
||||
sti
|
||||
pop edi
|
||||
add edi,4
|
||||
inc ebp
|
||||
pop ecx
|
||||
pop eax
|
||||
inc eax
|
||||
loop dbnp3212
|
||||
jmp dbnp32d12
|
||||
|
||||
dbimp32no12:
|
||||
|
||||
pop ecx
|
||||
pop eax
|
||||
inc eax
|
||||
add edi,4
|
||||
inc ebp
|
||||
loop dbnp3212
|
||||
|
||||
dbnp32d12:
|
||||
|
||||
mov eax,[esp+12+16+4]
|
||||
test eax,0x80000000
|
||||
jz nodbgl3212
|
||||
cmp al,0
|
||||
jz nodbgl3212
|
||||
dec eax
|
||||
mov [esp+12+16+4],eax
|
||||
|
||||
nodbgl3212:
|
||||
|
||||
pop ecx
|
||||
pop edi
|
||||
pop ebx
|
||||
add edi,[0xfe08]
|
||||
dec ebx
|
||||
jz nodbnewpi3212
|
||||
jmp dbnewpi3212
|
||||
|
||||
nodbnewpi3212:
|
||||
|
||||
add esp,7*4
|
||||
ret
|
||||
|
||||
|
||||
Vesa12_putpixel24:
|
||||
|
||||
mov edi,eax ; x
|
||||
mov eax,ebx ; y
|
||||
lea edi,[edi+edi*2]
|
||||
mov ebx,[0xfe08]
|
||||
mul ebx
|
||||
add edi,eax
|
||||
mov eax,edi
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,65535
|
||||
add edi,0xa0000
|
||||
mov eax,[esp+28]
|
||||
stosw
|
||||
shr eax,16
|
||||
mov [edi],al
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
|
||||
Vesa12_putpixel32:
|
||||
|
||||
mov edi,eax ; x
|
||||
mov eax,ebx ; y
|
||||
shl edi,2
|
||||
mov ebx,[0xfe08]
|
||||
mul ebx
|
||||
add edi,eax
|
||||
mov eax,edi
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,65535
|
||||
add edi,0xa0000
|
||||
mov ecx,[esp+28]
|
||||
mov [edi],ecx
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
Vesa12_getpixel24:
|
||||
|
||||
mov edi,eax ; x
|
||||
mov eax,ebx ; y
|
||||
lea edi,[edi+edi*2]
|
||||
mov ebx,[0xfe08]
|
||||
mul ebx
|
||||
add edi,eax
|
||||
mov eax,edi
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,65535
|
||||
add edi,0xa0000
|
||||
mov ecx,[edi]
|
||||
and ecx,255*256*256+255*256+255
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
Vesa12_getpixel32:
|
||||
|
||||
mov edi,eax ; x
|
||||
mov eax,ebx ; y
|
||||
shl edi,2
|
||||
mov ebx,[0xfe08]
|
||||
xor edx,edx
|
||||
mul ebx
|
||||
add edi,eax
|
||||
mov eax,edi
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,65535
|
||||
add edi,0xa0000
|
||||
mov ecx,[edi]
|
||||
and ecx,255*256*256+255*256+255
|
||||
sti
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
vesa12_putimage:
|
||||
|
||||
; mov ebx,image
|
||||
; mov ecx,320*65536+240
|
||||
; mov edx,20*65536+20
|
||||
|
||||
call [disable_mouse]
|
||||
|
||||
mov [novesachecksum],dword 0
|
||||
push esi
|
||||
push edi
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
movzx eax,word [esp+2]
|
||||
movzx ebx,word [esp+0]
|
||||
mov ecx,[0x3010]
|
||||
add eax,[ecx-twdw+WDATA.box.left]
|
||||
add ebx,[ecx-twdw+WDATA.box.top]
|
||||
push eax
|
||||
mov eax,ebx ; y
|
||||
mov ebx,[0xfe08]
|
||||
mul ebx
|
||||
pop ecx
|
||||
add eax,ecx ; x
|
||||
add eax,ecx
|
||||
add eax,ecx
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ? - x start
|
||||
jz pi2412
|
||||
add eax,ecx
|
||||
|
||||
pi2412:
|
||||
|
||||
add eax,[0xfe80]
|
||||
mov edi,eax
|
||||
|
||||
; x size
|
||||
|
||||
movzx eax,word [esp+6]
|
||||
mov ecx,eax
|
||||
add ecx,eax
|
||||
add ecx,eax
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ? - x size
|
||||
jz pi24312
|
||||
add ecx,eax
|
||||
|
||||
pi24312:
|
||||
|
||||
mov esi,[esp+8]
|
||||
movzx ebx,word [esp+4]
|
||||
|
||||
; check limits while draw ?
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
mov eax,[0x3010]
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.left]
|
||||
cmp ecx,0
|
||||
jnz dbcblimitlset212
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.top]
|
||||
cmp ecx,0
|
||||
jnz dbcblimitlset212
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.right]
|
||||
cmp ecx,[0xfe00]
|
||||
jnz dbcblimitlset212
|
||||
mov ecx,[eax+draw_data-0x3000+RECT.bottom]
|
||||
cmp ecx,[0xfe04]
|
||||
jnz dbcblimitlset212
|
||||
pop ecx
|
||||
pop eax
|
||||
push dword 0
|
||||
jmp dbcblimitlno212
|
||||
|
||||
dbcblimitlset212:
|
||||
|
||||
pop ecx
|
||||
pop eax
|
||||
push dword 1
|
||||
|
||||
dbcblimitlno212:
|
||||
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ?
|
||||
jz pi24bit12
|
||||
jmp pi32bit12
|
||||
|
||||
pi24bit12:
|
||||
|
||||
cld
|
||||
push eax
|
||||
push ebx
|
||||
push edx
|
||||
xor edx,edx
|
||||
mov eax,ecx
|
||||
mov ebx,3
|
||||
div ebx
|
||||
mov ecx,eax
|
||||
pop edx
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
newpi12:
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ecx
|
||||
push ebx
|
||||
|
||||
xor edx,edx
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
mov ebx,3
|
||||
div ebx
|
||||
add eax,WinMapAddress
|
||||
mov ebx,[0x3000]
|
||||
mov bh,[esp+4*4]
|
||||
|
||||
np2412:
|
||||
|
||||
cmp bl,[eax]
|
||||
jnz imp24no12
|
||||
mov edx,[esi]
|
||||
cmp bh,0
|
||||
jz imp24yes12
|
||||
; call dbcplimit
|
||||
; jnz imp24no12
|
||||
|
||||
imp24yes12:
|
||||
|
||||
push eax
|
||||
push edi
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,0xffff
|
||||
add edi,0xa0000
|
||||
mov [edi],edx
|
||||
shr edx,2
|
||||
mov [edi+2],dl
|
||||
sti
|
||||
pop edi
|
||||
pop eax
|
||||
|
||||
imp24no12:
|
||||
|
||||
inc eax
|
||||
add esi,3
|
||||
add edi,3
|
||||
dec ecx
|
||||
jnz np2412
|
||||
|
||||
np24d12:
|
||||
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop esi
|
||||
pop edi
|
||||
|
||||
add edi,[0xfe08]
|
||||
xor eax,eax
|
||||
mov ax,[esp+4+2+4]
|
||||
lea eax,[eax+eax*2]
|
||||
add esi,eax
|
||||
dec ebx
|
||||
jz nonewpi12
|
||||
jmp newpi12
|
||||
|
||||
nonewpi12:
|
||||
|
||||
add esp,7*4
|
||||
mov eax,0
|
||||
ret
|
||||
|
||||
|
||||
pi32bit12:
|
||||
|
||||
cld
|
||||
shr ecx,2
|
||||
|
||||
newpi3212:
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ecx
|
||||
push ebx
|
||||
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
shr eax,2
|
||||
add eax,WinMapAddress
|
||||
mov ebx,[0x3000]
|
||||
mov bh,[esp+4*4]
|
||||
|
||||
np3212:
|
||||
|
||||
cmp bl,[eax]
|
||||
jnz imp32no12
|
||||
mov edx,[esi]
|
||||
cmp bh,0
|
||||
jz imp32yes12
|
||||
; call dbcplimit
|
||||
; jnz imp32no12
|
||||
|
||||
imp32yes12:
|
||||
|
||||
push eax
|
||||
push edi
|
||||
mov eax,edi
|
||||
sub eax,[0xfe80]
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,0xffff
|
||||
add edi,0xa0000
|
||||
mov [edi],edx
|
||||
sti
|
||||
pop edi
|
||||
pop eax
|
||||
|
||||
imp32no12:
|
||||
|
||||
inc eax
|
||||
add esi,3
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz np3212
|
||||
|
||||
np32d12:
|
||||
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop esi
|
||||
pop edi
|
||||
|
||||
add edi,[0xfe08]
|
||||
movzx eax,word [esp+4+2+4]
|
||||
lea eax,[eax+eax*2]
|
||||
add esi,eax
|
||||
dec ebx
|
||||
jz nonewpi3212
|
||||
jmp newpi3212
|
||||
|
||||
nonewpi3212:
|
||||
|
||||
add esp,7*4
|
||||
mov eax,0
|
||||
ret
|
||||
|
||||
|
||||
vesa12_read_screen_pixel:
|
||||
|
||||
and eax,0x3FFFFF
|
||||
cmp [0xfbf1],byte 24 ; 24 or 32 bpp ?
|
||||
jz v12rsp24
|
||||
mov edi,eax
|
||||
shl edi,2
|
||||
mov eax,edi
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,65535
|
||||
add edi,0xa0000
|
||||
mov eax,[edi]
|
||||
and eax,0x00ffffff
|
||||
ret
|
||||
v12rsp24:
|
||||
|
||||
imul eax,3
|
||||
mov edi,eax
|
||||
shr eax,16
|
||||
call set_bank
|
||||
and edi,65535
|
||||
add edi,0xa0000
|
||||
mov eax,[edi]
|
||||
and eax,0x00ffffff
|
||||
ret
|
||||
|
||||
|
||||
1122
kernel/branches/gfx_kernel/video/vesa20.inc
Normal file
1122
kernel/branches/gfx_kernel/video/vesa20.inc
Normal file
File diff suppressed because it is too large
Load Diff
446
kernel/branches/gfx_kernel/video/vga.inc
Normal file
446
kernel/branches/gfx_kernel/video/vga.inc
Normal file
@@ -0,0 +1,446 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; VGA.INC ;;
|
||||
;; ;;
|
||||
;; 640x480 mode 0x12 VGA functions for MenuetOS ;;
|
||||
;; ;;
|
||||
;; Paul Butcher, paul.butcher@asa.co.uk ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
|
||||
paletteVGA:
|
||||
|
||||
;16 colour palette
|
||||
mov dx,0x3c8
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov ecx,16
|
||||
mov dx,0x3c9
|
||||
xor eax,eax
|
||||
|
||||
palvganew:
|
||||
|
||||
mov al,0
|
||||
test ah,4
|
||||
jz palvgalbl1
|
||||
add al,31
|
||||
test ah,8
|
||||
jz palvgalbl1
|
||||
add al,32
|
||||
palvgalbl1:
|
||||
out dx,al ; red 0,31 or 63
|
||||
mov al,0
|
||||
test ah,2
|
||||
jz palvgalbl2
|
||||
add al,31
|
||||
test ah,8
|
||||
jz palvgalbl2
|
||||
add al,32
|
||||
palvgalbl2:
|
||||
out dx,al ; blue 0,31 or 63
|
||||
mov al,0
|
||||
test ah,1
|
||||
jz palvgalbl3
|
||||
add al,31
|
||||
test ah,8
|
||||
jz palvgalbl3
|
||||
add al,32
|
||||
palvgalbl3:
|
||||
out dx,al ; green 0,31 or 63
|
||||
add ah,1
|
||||
loop palvganew
|
||||
; mov dx, 3ceh
|
||||
; mov ax, 0005h
|
||||
; out dx, ax
|
||||
ret
|
||||
|
||||
palette320x200:
|
||||
|
||||
mov edx,0x3c8
|
||||
xor eax, eax
|
||||
out dx,al
|
||||
mov ecx,256
|
||||
mov edx,0x3c9
|
||||
xor eax,eax
|
||||
|
||||
palnew:
|
||||
mov al,0
|
||||
test ah,64
|
||||
jz pallbl1
|
||||
add al,21
|
||||
pallbl1:
|
||||
test ah,128
|
||||
jz pallbl2
|
||||
add al,42
|
||||
pallbl2:
|
||||
out dx,al
|
||||
mov al,0
|
||||
test ah,8
|
||||
jz pallbl3
|
||||
add al,8
|
||||
pallbl3:
|
||||
test ah,16
|
||||
jz pallbl4
|
||||
add al,15
|
||||
pallbl4:
|
||||
test ah,32
|
||||
jz pallbl5
|
||||
add al,40
|
||||
pallbl5:
|
||||
out dx,al
|
||||
mov al,0
|
||||
test ah,1
|
||||
jz pallbl6
|
||||
add al,8
|
||||
pallbl6:
|
||||
test ah,2
|
||||
jz pallbl7
|
||||
add al,15
|
||||
pallbl7:
|
||||
test ah,4
|
||||
jz pallbl8
|
||||
add al,40
|
||||
pallbl8:
|
||||
out dx,al
|
||||
add ah,1
|
||||
loop palnew
|
||||
|
||||
ret
|
||||
|
||||
uglobal
|
||||
novesachecksum dd 0x0
|
||||
EGA_counter db 0
|
||||
VGA_drawing_screen db 0
|
||||
VGA_8_pixels:
|
||||
rb 16
|
||||
temp:
|
||||
.cx dd 0
|
||||
endg
|
||||
|
||||
checkVga_N13:
|
||||
|
||||
cmp [0xfe0c],dword 0x13
|
||||
jne @f
|
||||
|
||||
; cnvl:
|
||||
pushad
|
||||
cmp [EGA_counter],1
|
||||
je novesal
|
||||
mov ecx,[0xfb0a]
|
||||
cmp ecx,[novesachecksum]
|
||||
jne novesal
|
||||
popad
|
||||
@@:
|
||||
ret
|
||||
|
||||
novesal:
|
||||
mov [novesachecksum],ecx
|
||||
mov ecx,0
|
||||
movzx eax,word [0xfb0c]
|
||||
cmp eax,100
|
||||
jge m13l3
|
||||
mov eax,100
|
||||
m13l3:
|
||||
cmp eax,480-100
|
||||
jbe m13l4
|
||||
mov eax,480-100
|
||||
m13l4:
|
||||
sub eax,100
|
||||
imul eax,640*4
|
||||
add ecx,eax
|
||||
movzx eax,word [0xfb0a]
|
||||
cmp eax,160
|
||||
jge m13l1
|
||||
mov eax,160
|
||||
m13l1:
|
||||
cmp eax,640-160
|
||||
jbe m13l2
|
||||
mov eax,640-160
|
||||
m13l2:
|
||||
sub eax,160
|
||||
shl eax,2
|
||||
add ecx,eax
|
||||
mov esi,[0xfe80]
|
||||
add esi,ecx
|
||||
mov edi,0xa0000
|
||||
mov edx,200
|
||||
mov ecx,320
|
||||
cld
|
||||
m13pix:
|
||||
lodsd
|
||||
cmp eax,0
|
||||
je .save_pixel
|
||||
push eax
|
||||
mov ebx,eax
|
||||
and eax,(128+64+32) ; blue
|
||||
shr eax,5
|
||||
and ebx,(128+64+32)*256 ; green
|
||||
shr ebx,8+2
|
||||
add eax,ebx
|
||||
pop ebx
|
||||
and ebx,(128+64)*256*256 ; red
|
||||
shr ebx,8+8
|
||||
add eax,ebx
|
||||
.save_pixel:
|
||||
stosb
|
||||
loop m13pix
|
||||
mov ecx,320
|
||||
add esi,4*(640-320)
|
||||
dec edx
|
||||
jnz m13pix
|
||||
mov [EGA_counter],0
|
||||
popad
|
||||
ret
|
||||
|
||||
VGA_drawbackground:
|
||||
; draw all
|
||||
cmp [0xfe0c],dword 0x12
|
||||
jne .end
|
||||
pushad
|
||||
mov esi,[0xfe80]
|
||||
mov edi,0xa0000
|
||||
mov ebx,640/32 ; 640*480/(8*4)
|
||||
mov edx,480
|
||||
@@:
|
||||
push ebx edx esi edi
|
||||
shl edx,9
|
||||
lea edx,[edx+edx*4]
|
||||
add esi,edx
|
||||
shr edx,5
|
||||
add edi,edx
|
||||
call VGA_draw_long_line
|
||||
pop edi esi edx ebx
|
||||
dec edx
|
||||
jnz @r
|
||||
call VGA_draw_long_line_1
|
||||
popad
|
||||
.end:
|
||||
ret
|
||||
|
||||
VGA_draw_long_line:
|
||||
mov dx,3ceh
|
||||
mov ax,0ff08h
|
||||
cli
|
||||
out dx, ax
|
||||
mov ax,0005h
|
||||
out dx, ax
|
||||
m12pix:
|
||||
call VGA_draw_32_pixels
|
||||
dec ebx
|
||||
jnz m12pix
|
||||
mov dx,3c4h
|
||||
mov ax,0ff02h
|
||||
out dx,ax
|
||||
mov dx,3ceh
|
||||
mov ax,0205h
|
||||
out dx,ax
|
||||
mov dx,3ceh
|
||||
mov al,08h
|
||||
out dx,al
|
||||
sti
|
||||
ret
|
||||
|
||||
VGA_draw_32_pixels:
|
||||
xor eax,eax
|
||||
mov ebp,VGA_8_pixels
|
||||
mov [ebp],eax
|
||||
mov [ebp+4],eax
|
||||
mov [ebp+8],eax
|
||||
mov [ebp+12],eax
|
||||
mov ch,4
|
||||
.main_loop:
|
||||
mov cl,8
|
||||
.convert_pixels_to_VGA:
|
||||
lodsd ; eax = 24bit colour
|
||||
cmp eax,0
|
||||
je .end
|
||||
rol eax,8
|
||||
mov al,ch
|
||||
ror eax,8
|
||||
mov ch,1
|
||||
dec cl
|
||||
shl ch,cl
|
||||
cmp al,85
|
||||
jbe .p13green
|
||||
or [ebp],ch
|
||||
cmp al,170
|
||||
jbe .p13green
|
||||
or [ebp+12],ch
|
||||
.p13green:
|
||||
cmp ah,85
|
||||
jbe .p13red
|
||||
or [ebp+4],ch
|
||||
cmp ah,170
|
||||
jbe .p13red
|
||||
or [ebp+12],ch
|
||||
.p13red:
|
||||
shr eax,8
|
||||
cmp ah,85
|
||||
jbe .p13cont
|
||||
or [ebp+8],ch
|
||||
cmp ah,170
|
||||
jbe .p13cont
|
||||
or [ebp+12],ch
|
||||
.p13cont:
|
||||
ror eax,8
|
||||
mov ch,ah
|
||||
inc cl
|
||||
.end:
|
||||
dec cl
|
||||
jnz .convert_pixels_to_VGA
|
||||
inc ebp
|
||||
dec ch
|
||||
jnz .main_loop
|
||||
push esi
|
||||
sub ebp,4
|
||||
mov esi,ebp
|
||||
mov dx, 3c4h
|
||||
mov ah, 1h
|
||||
@@:
|
||||
mov al, 02h
|
||||
out dx,ax
|
||||
xchg ax,bp
|
||||
lodsd
|
||||
mov [edi],eax
|
||||
xchg ax,bp
|
||||
shl ah, 1
|
||||
cmp ah, 10h
|
||||
jnz @r
|
||||
add edi,4
|
||||
pop esi
|
||||
ret
|
||||
|
||||
VGA_putpixel:
|
||||
; eax = x
|
||||
; ebx = y
|
||||
mov ecx,eax
|
||||
mov eax, [esp+32-8+4] ; color
|
||||
shl ebx,9
|
||||
lea ebx,[ebx+ebx*4] ; óìíîæåíèå íà 5
|
||||
lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32)
|
||||
mov edi,edx
|
||||
add edi, [0xfe80] ; + LFB address
|
||||
mov [edi], eax ; write to LFB for Vesa2.0
|
||||
shr edx,5 ; change BytesPerPixel to 1/8
|
||||
mov edi,edx
|
||||
add edi, 0x0a0000 ; address of pixel in VGA area
|
||||
and ecx,0x07 ; bit no. (modulo 8)
|
||||
pushfd
|
||||
; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8)
|
||||
xor edx,edx
|
||||
cmp eax,0
|
||||
je .p13cont
|
||||
cmp al,85
|
||||
jbe .p13green
|
||||
or dl,0x01
|
||||
cmp al,170
|
||||
jbe .p13green
|
||||
or dl,0x08
|
||||
.p13green:
|
||||
cmp ah,85
|
||||
jbe .p13red
|
||||
or dl,0x02
|
||||
cmp ah,170
|
||||
jbe .p13red
|
||||
or dl,0x08
|
||||
.p13red:
|
||||
shr eax,8
|
||||
cmp ah,85
|
||||
jbe .p13cont
|
||||
or dl,0x04
|
||||
cmp ah,170
|
||||
jbe .p13cont
|
||||
or dl,0x08
|
||||
.p13cont:
|
||||
ror edx,8
|
||||
inc cl
|
||||
xor eax,eax
|
||||
inc ah
|
||||
shr ax,cl
|
||||
mov dx,3cfh
|
||||
cli
|
||||
out dx,al
|
||||
mov al,[edi] ; dummy read
|
||||
rol edx,8
|
||||
mov [edi],dl
|
||||
popfd
|
||||
;.end:
|
||||
ret
|
||||
|
||||
VGA__putimage:
|
||||
; ecx = size [x|y]
|
||||
; edx = coordinates [x|y]
|
||||
cmp [0xfe0c],dword 0x12
|
||||
jne @f
|
||||
pushad
|
||||
rol edx,16
|
||||
movzx eax,dx
|
||||
rol edx,16
|
||||
movzx ebx,dx
|
||||
movzx edx,cx
|
||||
rol ecx,16
|
||||
movzx ecx,cx
|
||||
call VGA_draw_bar_1
|
||||
popad
|
||||
@@:
|
||||
ret
|
||||
|
||||
VGA_draw_bar:
|
||||
; eax cx
|
||||
; ebx cy
|
||||
; ecx xe
|
||||
; edx ye
|
||||
cmp [0xfe0c],dword 0x12
|
||||
jne @f
|
||||
pushad
|
||||
sub ecx,eax
|
||||
sub edx,ebx
|
||||
and eax,0xffff
|
||||
and ebx,0xffff
|
||||
and ecx,0xffff
|
||||
and edx,0xffff
|
||||
call VGA_draw_bar_1
|
||||
popad
|
||||
@@:
|
||||
ret
|
||||
|
||||
VGA_draw_bar_1:
|
||||
mov [temp.cx],eax
|
||||
mov eax, [0x3010]
|
||||
add ebx, [eax-twdw + 4]
|
||||
mov eax, [eax-twdw + 0]
|
||||
add eax, [temp.cx]
|
||||
and eax,0xfff8
|
||||
shl ebx,9
|
||||
lea ebx,[ebx+ebx*4] ; óìíîæåíèå íà 5
|
||||
lea ebx, [ebx+eax*4] ; + x*BytesPerPixel (Vesa2.0 32)
|
||||
mov esi,ebx
|
||||
add esi, [0xfe80] ; + LFB address
|
||||
shr ebx,5 ; change BytesPerPixel to 1/8
|
||||
mov edi,ebx
|
||||
add edi, 0x0a0000 ; address of pixel in VGA area
|
||||
mov ebx,ecx
|
||||
shr ebx,5
|
||||
inc ebx
|
||||
.main_loop:
|
||||
call VGA_draw_long_line_1
|
||||
dec edx
|
||||
jnz .main_loop
|
||||
call VGA_draw_long_line_1
|
||||
ret
|
||||
|
||||
VGA_draw_long_line_1:
|
||||
push ebx edx esi edi
|
||||
shl edx,9
|
||||
lea edx,[edx+edx*4]
|
||||
add esi,edx
|
||||
shr edx,5
|
||||
add edi,edx
|
||||
call VGA_draw_long_line
|
||||
pop edi esi edx ebx
|
||||
ret
|
||||
|
||||
|
||||
501
kernel/branches/gfx_kernel/vmode/clipping.asm
Executable file
501
kernel/branches/gfx_kernel/vmode/clipping.asm
Executable file
@@ -0,0 +1,501 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
;///// PART OF ATi RADEON 9000 DRIVER ////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; Copyright (c) 2004, mike.dld
|
||||
; Using BeOS driver - Copyright (c) 2002, Thomas Kurschel
|
||||
;-----------------------------------------------------------------------------
|
||||
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
; DEALINGS IN THE SOFTWARE.
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
include 'clipping.inc'
|
||||
|
||||
struct RECT
|
||||
left dd ?
|
||||
top dd ?
|
||||
right dd ?
|
||||
bottom dd ?
|
||||
ends
|
||||
|
||||
virtual at ebp
|
||||
r RECT
|
||||
end virtual
|
||||
|
||||
virtual at edi
|
||||
r2 RECT
|
||||
end virtual
|
||||
|
||||
SR = sizeof.RECT
|
||||
|
||||
macro movl val,reg {
|
||||
mov reg,val
|
||||
}
|
||||
|
||||
EQUAL_LEFT = 00000001b
|
||||
EQUAL_BOTTOM = 00000010b
|
||||
EQUAL_RIGHT = 00000100b
|
||||
EQUAL_TOP = 00001000b
|
||||
|
||||
func calc_clipping_rects
|
||||
begin
|
||||
mov [cnt],0
|
||||
movzx ebp,word[0x3000]
|
||||
shl ebp,5
|
||||
|
||||
cmp ebp,0x20
|
||||
jne @f
|
||||
mov esi,viewport
|
||||
mov edi,rct
|
||||
mov ecx,sizeof.RECT/4
|
||||
cld
|
||||
rep movsd
|
||||
jmp .lp1
|
||||
@@:
|
||||
movsx eax,word[ebp+0x00]
|
||||
mov [rct.left],eax
|
||||
mov [rct.right],eax
|
||||
movsx eax,word[ebp+0x04]
|
||||
mov [rct.top],eax
|
||||
mov [rct.bottom],eax
|
||||
movzx eax,word[ebp+0x08]
|
||||
inc eax
|
||||
add [rct.right],eax
|
||||
movzx eax,word[ebp+0x0C]
|
||||
inc eax
|
||||
add [rct.bottom],eax
|
||||
.lp1:
|
||||
mov esi,viewport
|
||||
mov edi,tr
|
||||
mov ecx,sizeof.RECT/4
|
||||
cld
|
||||
rep movsd
|
||||
mov ebp,rct
|
||||
call intersect_rect ; (ebp,tr)->(x1:edx,y1:eax,x2:ebx,y2:ecx)+CF
|
||||
jc .exit
|
||||
mov [rct.left],edx
|
||||
mov [rct.top],eax
|
||||
mov [rct.right],ebx
|
||||
mov [rct.bottom],ecx
|
||||
inc [cnt]
|
||||
comment ^
|
||||
movsx eax,word[ebp+0x00]
|
||||
mov [rct.left],eax
|
||||
mov [rct.right],eax
|
||||
movsx eax,word[ebp+0x04]
|
||||
mov [rct.top],eax
|
||||
mov [rct.bottom],eax
|
||||
movsx eax,word[ebp+0x08]
|
||||
inc eax
|
||||
add [rct.right],eax
|
||||
movsx eax,word[ebp+0x0C]
|
||||
inc eax
|
||||
add [rct.bottom],eax
|
||||
^
|
||||
movzx ecx,word[0x00003004] ; number of processes
|
||||
jif ecx,be,1,.exit
|
||||
|
||||
; calculate clipping rectangles
|
||||
|
||||
mov esi,1
|
||||
; go forward through all windows
|
||||
.next_window:
|
||||
movzx edi,word[0x00003000] ; calling process number
|
||||
|
||||
mov ax,[0x0000C000+esi*2]
|
||||
jif ax,be,[0x0000C000+edi*2],.end_window.2
|
||||
|
||||
mov ebp,[cnt]
|
||||
shl ebp,4 ; ebp *= SR
|
||||
jz .exit
|
||||
lea ebp,[rct+ebp-SR]
|
||||
|
||||
push esi ;ecx esi
|
||||
shl esi,5
|
||||
lodsd
|
||||
mov [tr.left],eax
|
||||
mov [tr.right],eax
|
||||
lodsd
|
||||
mov [tr.top],eax
|
||||
mov [tr.bottom],eax
|
||||
lodsd
|
||||
jif eax,z,eax,.end_window,test
|
||||
inc eax
|
||||
add [tr.right],eax
|
||||
lodsd
|
||||
jif eax,z,eax,.end_window,test
|
||||
inc eax
|
||||
add [tr.bottom],eax
|
||||
; go backward through all rectangles
|
||||
.next_rect:
|
||||
|
||||
rc_top equ eax
|
||||
rc_right equ ebx
|
||||
rc_bottom equ ecx
|
||||
rc_left equ edx
|
||||
|
||||
call intersect_rect ; (ebp,tr)->(x1:edx,y1:eax,x2:ebx,y2:ecx)+CF
|
||||
jc .is_finish
|
||||
xor edi,edi
|
||||
jif rc_top,ne,[r.top],@f
|
||||
or edi,EQUAL_TOP
|
||||
@@: jif rc_right,ne,[r.right],@f
|
||||
or edi,EQUAL_RIGHT
|
||||
@@: jif rc_bottom,ne,[r.bottom],@f
|
||||
or edi,EQUAL_BOTTOM
|
||||
@@: jif rc_left,ne,[r.left],@f
|
||||
or edi,EQUAL_LEFT
|
||||
@@: jmp [jtable_intersect+edi*4]
|
||||
|
||||
.is_0000:
|
||||
call copy_current
|
||||
mov [r.left ],rc_right
|
||||
mov [r2.right -SR],rc_left
|
||||
mov [r2.left ],rc_left
|
||||
mov [r2.right ],rc_right
|
||||
mov [r2.bottom ],rc_top
|
||||
mov [r2.left +SR],rc_left
|
||||
mov [r2.right +SR],rc_right
|
||||
mov [r2.top +SR],rc_bottom
|
||||
movl [r.top ],esi
|
||||
mov [r2.top ],esi
|
||||
movl [r.bottom ],esi
|
||||
mov [r2.bottom+SR],esi
|
||||
add [cnt],2
|
||||
jmp .is_finish
|
||||
.is_0001:
|
||||
call copy_current
|
||||
mov [r.top ],rc_bottom
|
||||
mov [r2.bottom-SR],rc_top
|
||||
mov [r2.left ],rc_right
|
||||
mov [r2.top ],rc_top
|
||||
mov [r2.bottom ],rc_bottom
|
||||
movl [r.right ],esi
|
||||
mov [r2.right ],esi
|
||||
inc [cnt]
|
||||
jmp .is_finish
|
||||
.is_0010:
|
||||
call copy_current
|
||||
mov [r.left ],rc_right
|
||||
mov [r2.right -SR],rc_left
|
||||
mov [r2.left ],rc_left
|
||||
mov [r2.right ],rc_right
|
||||
mov [r2.bottom ],rc_top
|
||||
movl [r.top ],esi
|
||||
mov [r2.top ],esi
|
||||
inc [cnt]
|
||||
jmp .is_finish
|
||||
.is_0011:
|
||||
call copy_current
|
||||
mov [r.bottom ],rc_top
|
||||
mov [r2.left -SR],rc_right
|
||||
mov [r2.top -SR],rc_top
|
||||
jmp .is_finish
|
||||
.is_0100:
|
||||
call copy_current
|
||||
mov [r.top ],rc_bottom
|
||||
mov [r2.bottom-SR],rc_top
|
||||
mov [r2.right ],rc_left
|
||||
mov [r2.top ],rc_top
|
||||
mov [r2.bottom ],rc_bottom
|
||||
movl [r.left ],esi
|
||||
mov [r2.left ],esi
|
||||
inc [cnt]
|
||||
jmp .is_finish
|
||||
.is_0101:
|
||||
call copy_current
|
||||
mov [r.top ],rc_bottom
|
||||
mov [r2.bottom-SR],rc_top
|
||||
jmp .is_finish
|
||||
.is_0110:
|
||||
call copy_current
|
||||
mov [r.bottom ],rc_top
|
||||
mov [r2.right -SR],rc_left
|
||||
mov [r2.top -SR],rc_top
|
||||
jmp .is_finish
|
||||
.is_0111:
|
||||
mov [r.bottom ],rc_top
|
||||
jmp .is_finish
|
||||
.is_1000:
|
||||
call copy_current
|
||||
mov [r.left ],rc_right
|
||||
mov [r2.right -SR],rc_left
|
||||
mov [r2.left ],rc_left
|
||||
mov [r2.right ],rc_right
|
||||
mov [r2.top ],rc_bottom
|
||||
movl [r.bottom ],esi
|
||||
mov [r2.bottom ],esi
|
||||
inc [cnt]
|
||||
jmp .is_finish
|
||||
.is_1001:
|
||||
call copy_current
|
||||
mov [r.top ],rc_bottom
|
||||
mov [r2.left -SR],rc_right
|
||||
mov [r2.bottom-SR],rc_bottom
|
||||
jmp .is_finish
|
||||
.is_1010:
|
||||
call copy_current
|
||||
mov [r.left ],rc_right
|
||||
mov [r2.right -SR],rc_left
|
||||
jmp .is_finish
|
||||
.is_1011:
|
||||
mov [r.left ],rc_right
|
||||
jmp .is_finish
|
||||
.is_1100:
|
||||
call copy_current
|
||||
mov [r.top ],rc_bottom
|
||||
mov [r2.right -SR],rc_left
|
||||
mov [r2.bottom-SR],rc_bottom
|
||||
jmp .is_finish
|
||||
.is_1101:
|
||||
mov [r.top ],rc_bottom
|
||||
jmp .is_finish
|
||||
.is_1110:
|
||||
mov [r.right ],rc_left
|
||||
jmp .is_finish
|
||||
.is_1111:
|
||||
call delete_current
|
||||
.is_finish:
|
||||
sub ebp,SR
|
||||
jif ebp,ae,rct,.next_rect
|
||||
.end_window:
|
||||
pop esi; ecx
|
||||
.end_window.2:
|
||||
inc esi
|
||||
jif esi,be,[0x00003004],.next_window
|
||||
; dec ecx
|
||||
; jnz .next_window
|
||||
|
||||
; combine some rectangles if possible
|
||||
; with Result do begin
|
||||
; for i := cnt-1 downto 0 do if rct[i].Left >= 0 then
|
||||
; for j := cnt-1 downto 0 do if (j <> i) and (rct[j].Left >= 0) then
|
||||
; if (rct[i].Left = rct[j].Left) and (rct[i].Right = rct[j].Right) then begin
|
||||
; end else if (rct[i].Top = rct[j].Top) and (rct[i].Bottom = rct[j].Bottom) then begin
|
||||
; if (rct[i].Left = rct[j].Right) then begin
|
||||
; rct[i].Left := rct[j].Left;
|
||||
; rct[j].Left := -1;
|
||||
; end else if (rct[i].Right = rct[j].Left) then begin
|
||||
; rct[i].Right := rct[j].Right;
|
||||
; rct[j].Left := -1;
|
||||
; end;
|
||||
; end;
|
||||
; for i := cnt-1 downto 0 do if rct[i].Left < 0 then begin
|
||||
; for j := i to cnt-2 do
|
||||
; rct[j] := rct[j+1];
|
||||
; dec(cnt);
|
||||
; end;
|
||||
; end;
|
||||
|
||||
.combine_rects:
|
||||
mov esi,[cnt]
|
||||
shl esi,4
|
||||
add esi,rct
|
||||
lea ebp,[esi-SR]
|
||||
push ebp
|
||||
.next_rect1:
|
||||
sub esi,SR
|
||||
jif esi,b,rct,.exit.combine
|
||||
jif [esi+RECT.left],e,-1,.next_rect1
|
||||
push ebp
|
||||
.next_rect2:
|
||||
jif ebp,e,esi,.next_rect2.ok
|
||||
jif [ebp+RECT.left],e,-1,.next_rect2.ok
|
||||
|
||||
mov eax,[ebp+RECT.left]
|
||||
mov ebx,[ebp+RECT.right]
|
||||
mov ecx,[ebp+RECT.top]
|
||||
mov edx,[ebp+RECT.bottom]
|
||||
jif eax,ne,[esi+RECT.left],.not_left_right
|
||||
jif ebx,ne,[esi+RECT.right],.not_left_right
|
||||
jif edx,ne,[esi+RECT.top],@f
|
||||
mov [esi+RECT.top],ecx
|
||||
jmp .next_rect2.mark
|
||||
@@: jif ecx,ne,[esi+RECT.bottom],.next_rect2.ok
|
||||
mov [esi+RECT.bottom],edx
|
||||
jmp .next_rect2.mark
|
||||
.not_left_right:
|
||||
jif ecx,ne,[esi+RECT.top],.next_rect2.ok
|
||||
jif edx,ne,[esi+RECT.bottom],.next_rect2.ok
|
||||
jif ebx,ne,[esi+RECT.left],@f
|
||||
mov [esi+RECT.left],eax
|
||||
jmp .next_rect2.mark
|
||||
@@: jif eax,ne,[esi+RECT.right],.next_rect2.ok
|
||||
mov [esi+RECT.right],ebx
|
||||
.next_rect2.mark:
|
||||
or [ebp+RECT.left],-1
|
||||
.next_rect2.ok:
|
||||
sub ebp,SR
|
||||
jif ebp,ae,rct,.next_rect2
|
||||
pop ebp
|
||||
jmp .next_rect1
|
||||
.exit.combine:
|
||||
|
||||
pop ebp
|
||||
.next_rect3:
|
||||
jif [ebp+RECT.left],ne,-1,@f
|
||||
call delete_current
|
||||
@@: sub ebp,SR
|
||||
jif ebp,ae,rct,.next_rect3
|
||||
|
||||
; remove unnecessary rectangles
|
||||
; for i := Result.cnt-1 downto 0 do with Result do
|
||||
; if not IntersectRect(rc,rct[i],r2) then begin
|
||||
; for j := i to cnt-2 do
|
||||
; rct[j] := rct[j+1];
|
||||
; dec(cnt);
|
||||
; end;
|
||||
|
||||
.exit:
|
||||
mov esi,rct
|
||||
mov ecx,[cnt]
|
||||
ret
|
||||
|
||||
delete_current:
|
||||
push ecx
|
||||
lea esi,[ebp+SR] ; esi = ebp+SR
|
||||
mov edi,ebp ; edi = ebp
|
||||
mov ecx,[cnt] ; ecx = cnt
|
||||
shl ecx,4 ; ecx *= SR
|
||||
add ecx,rct-SR ; ecx += rct-SR
|
||||
sub ecx,ebp ; ecx -= ebp
|
||||
cld
|
||||
rep movsb
|
||||
dec [cnt]
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
copy_current:
|
||||
push ecx
|
||||
mov edi,[cnt]
|
||||
shl edi,4
|
||||
lea edi,[rct+edi]
|
||||
mov esi,ebp
|
||||
mov ecx,4
|
||||
cld
|
||||
rep movsd
|
||||
pop ecx
|
||||
inc [cnt]
|
||||
ret
|
||||
|
||||
intersect_rect: ; ebp,tr
|
||||
mov rc_top,[tr.top]
|
||||
jif rc_top,ge,[r.bottom],.exit
|
||||
mov rc_right,[tr.right]
|
||||
jif rc_right,le,[r.left],.exit
|
||||
mov rc_bottom,[tr.bottom]
|
||||
jif rc_bottom,le,[r.top],.exit
|
||||
mov rc_left,[tr.left]
|
||||
jif rc_left,ge,[r.right],.exit
|
||||
|
||||
jif rc_top,ge,[r.top],@f
|
||||
mov rc_top,[r.top]
|
||||
@@: jif rc_right,le,[r.right],@f
|
||||
mov rc_right,[r.right]
|
||||
@@: jif rc_bottom,le,[r.bottom],@f
|
||||
mov rc_bottom,[r.bottom]
|
||||
@@: jif rc_left,ge,[r.left],@f
|
||||
mov rc_left,[r.left]
|
||||
@@: clc
|
||||
ret
|
||||
.exit:
|
||||
stc
|
||||
ret
|
||||
|
||||
endf
|
||||
|
||||
func FC
|
||||
begin
|
||||
.x00:
|
||||
.x01:
|
||||
.x02:
|
||||
.x04:
|
||||
.x05:
|
||||
.x06:
|
||||
.x08:
|
||||
.x09:
|
||||
.x0A:
|
||||
.x10:
|
||||
.x11:
|
||||
.x12:
|
||||
.x14:
|
||||
.x15:
|
||||
.x16:
|
||||
.x18:
|
||||
.x19:
|
||||
.x1A:
|
||||
.x20:
|
||||
.x21:
|
||||
.x22:
|
||||
.x24:
|
||||
.x25:
|
||||
.x26:
|
||||
.x28:
|
||||
.x29:
|
||||
.x2A:
|
||||
.x40:
|
||||
.x41:
|
||||
.x42:
|
||||
.x44:
|
||||
.x45:
|
||||
.x46:
|
||||
.x48:
|
||||
.x49:
|
||||
.x4A:
|
||||
.x50:
|
||||
.x51:
|
||||
.x52:
|
||||
.x54:
|
||||
.x55:
|
||||
.x56:
|
||||
.x58:
|
||||
.x59:
|
||||
.x5A:
|
||||
.x60:
|
||||
.x61:
|
||||
.x62:
|
||||
.x64:
|
||||
.x65:
|
||||
.x66:
|
||||
.x68:
|
||||
.x69:
|
||||
.x6A:
|
||||
.x80:
|
||||
.x81:
|
||||
.x82:
|
||||
.x84:
|
||||
.x85:
|
||||
.x86:
|
||||
.x88:
|
||||
.x89:
|
||||
.x8A:
|
||||
.x90:
|
||||
.x91:
|
||||
.x92:
|
||||
.x94:
|
||||
.x95:
|
||||
.x96:
|
||||
.x98:
|
||||
.x99:
|
||||
.x9A:
|
||||
.xA0:
|
||||
.xA1:
|
||||
.xA2:
|
||||
.xA4:
|
||||
.xA5:
|
||||
.xA6:
|
||||
.xA8:
|
||||
.xA9:
|
||||
.xAA:
|
||||
ret
|
||||
.xXX:
|
||||
ret
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
;///// END ///////////////////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
25
kernel/branches/gfx_kernel/vmode/clipping.inc
Executable file
25
kernel/branches/gfx_kernel/vmode/clipping.inc
Executable file
@@ -0,0 +1,25 @@
|
||||
align 4
|
||||
|
||||
jtable_intersect dd \
|
||||
calc_clipping_rects.is_0000,calc_clipping_rects.is_0001,calc_clipping_rects.is_0010,calc_clipping_rects.is_0011,\
|
||||
calc_clipping_rects.is_0100,calc_clipping_rects.is_0101,calc_clipping_rects.is_0110,calc_clipping_rects.is_0111,\
|
||||
calc_clipping_rects.is_1000,calc_clipping_rects.is_1001,calc_clipping_rects.is_1010,calc_clipping_rects.is_1011,\
|
||||
calc_clipping_rects.is_1100,calc_clipping_rects.is_1101,calc_clipping_rects.is_1110,calc_clipping_rects.is_1111
|
||||
|
||||
;jtable_fastclip dd \
|
||||
; FC.x00,FC.x01,FC.x02,FC.xXX,FC.x04,FC.x05,FC.x06,FC.xXX,FC.x08,FC.x09,FC.x0A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x10,FC.x11,FC.x12,FC.xXX,FC.x14,FC.x15,FC.x16,FC.xXX,FC.x18,FC.x19,FC.x1A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x20,FC.x21,FC.x22,FC.xXX,FC.x24,FC.x25,FC.x26,FC.xXX,FC.x28,FC.x29,FC.x2A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x40,FC.x41,FC.x42,FC.xXX,FC.x44,FC.x45,FC.x46,FC.xXX,FC.x48,FC.x49,FC.x4A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x50,FC.x51,FC.x52,FC.xXX,FC.x54,FC.x55,FC.x56,FC.xXX,FC.x58,FC.x59,FC.x5A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x60,FC.x61,FC.x62,FC.xXX,FC.x64,FC.x65,FC.x66,FC.xXX,FC.x68,FC.x69,FC.x6A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x80,FC.x81,FC.x82,FC.xXX,FC.x84,FC.x85,FC.x86,FC.xXX,FC.x88,FC.x89,FC.x8A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.x90,FC.x91,FC.x92,FC.xXX,FC.x94,FC.x95,FC.x96,FC.xXX,FC.x98,FC.x99,FC.x9A,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX,\
|
||||
; FC.xA0,FC.xA1,FC.xA2,FC.xXX,FC.xA4,FC.xA5,FC.xA6,FC.xXX,FC.xA8,FC.xA9,FC.xAA,FC.xXX,FC.xXX,FC.xXX,FC.xXX,FC.xXX;,\
|
||||
; FC.xB0,FC.xB1,FC.xB2,FC.xB3,FC.xB4,FC.xB5,FC.xB6,FC.xB7,FC.xB8,FC.xB9,FC.xBA,FC.xBB,FC.xBC,FC.xBD,FC.xBE,FC.xBF,\
|
||||
; FC.xC0,FC.xC1,FC.xC2,FC.xC3,FC.xC4,FC.xC5,FC.xC6,FC.xC7,FC.xC8,FC.xC9,FC.xCA,FC.xCB,FC.xCC,FC.xCD,FC.xCE,FC.xCF,\
|
||||
; FC.xD0,FC.xD1,FC.xD2,FC.xD3,FC.xD4,FC.xD5,FC.xD6,FC.xD7,FC.xD8,FC.xD9,FC.xDA,FC.xDB,FC.xDC,FC.xDD,FC.xDE,FC.xDF,\
|
||||
; FC.xE0,FC.xE1,FC.xE2,FC.xE3,FC.xE4,FC.xE5,FC.xE6,FC.xE7,FC.xE8,FC.xE9,FC.xEA,FC.xEB,FC.xEC,FC.xED,FC.xEE,FC.xEF,\
|
||||
; FC.xF0,FC.xF1,FC.xF2,FC.xF3,FC.xF4,FC.xF5,FC.xF6,FC.xF7,FC.xF8,FC.xF9,FC.xFA,FC.xFB,FC.xFC,FC.xFD,FC.xFE,FC.xFF
|
||||
12
kernel/branches/gfx_kernel/vmode/makefile
Executable file
12
kernel/branches/gfx_kernel/vmode/makefile
Executable file
@@ -0,0 +1,12 @@
|
||||
FASM=fasm
|
||||
FENV=fasminc=/usr/fasm/include
|
||||
KSRC=vmode.asm
|
||||
KOUT=vmode.mdr
|
||||
|
||||
en: $(KSRC)
|
||||
$(FENV) $(FASM) $(KSRC) $(KOUT)
|
||||
ru: $(KSRC)
|
||||
$(FENV) $(FASM) $(KSRC) $(KOUT)
|
||||
|
||||
clean:
|
||||
rm -f $(KOUT)
|
||||
1017
kernel/branches/gfx_kernel/vmode/norm_04.inc
Executable file
1017
kernel/branches/gfx_kernel/vmode/norm_04.inc
Executable file
File diff suppressed because it is too large
Load Diff
747
kernel/branches/gfx_kernel/vmode/norm_08.inc
Executable file
747
kernel/branches/gfx_kernel/vmode/norm_08.inc
Executable file
@@ -0,0 +1,747 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_rect.08 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax - x start
|
||||
; ebx - y start
|
||||
; ecx - x end
|
||||
; edx - y end
|
||||
; edi - color
|
||||
;-----------------------------------------------------------------------------
|
||||
;- eax(ebx) [x start]*65536 + [x size]
|
||||
;- ebx(ecx) [y start]*65536 + [y size]
|
||||
;- ecx(edx) color 0x00RRGGBB
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
jif eax,e,ecx,.exit
|
||||
jif ebx,e,edx,.exit
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,[0x3010]
|
||||
movsx esi,word[ebp-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[ebp-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[ebp-0x3000+0]
|
||||
; add ebx,[ebp-0x3000+4]
|
||||
; add ecx,[ebp-0x3000+0]
|
||||
; add edx,[ebp-0x3000+4]
|
||||
|
||||
push ecx
|
||||
mov ecx,edi
|
||||
call color_24_to_8_bits
|
||||
mov edi,ecx
|
||||
pop ecx
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
add ebp,eax
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
xchg eax,edi
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
mov [ebp],al
|
||||
pop ebp
|
||||
; mov [ebp],di
|
||||
inc ebp
|
||||
inc edi
|
||||
cmp edi,ecx
|
||||
jl @b
|
||||
xchg eax,edi
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_line.08 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) [x start] shl 16 + [x end]
|
||||
; ebx(ecx) [y start] shl 16 + [y end]
|
||||
; ecx(edx) colour 0x00RRGGBB
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov eax,ecx
|
||||
call color_24_to_8_bits
|
||||
and eax,0x01000000
|
||||
or ecx,eax
|
||||
|
||||
movsx eax,word[esp+4*7] ; x end
|
||||
cmp ax,[esp+4*7+2] ; x start
|
||||
je dl.08.vert_line
|
||||
movsx eax,word[esp+4*4] ; y end
|
||||
cmp ax,[esp+4*4+2] ; y start
|
||||
je dl.08.horz_line
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
dl.08.vert_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_vln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
add ebp,eax
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
movzx ecx,byte[ebp]
|
||||
mov ecx,dword[palette_8_256+ecx*3]
|
||||
not ecx
|
||||
call color_24_to_8_bits
|
||||
or ecx,0x01000000
|
||||
.dr: mov [ebp],cl
|
||||
pop ebp
|
||||
; test ecx,0x01000000
|
||||
; jz .dr
|
||||
; mov cx,[ebp]
|
||||
; not cx
|
||||
; .dr: mov [ebp],cx
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
jif ebx,e,edx,.exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.top],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
jif ebx,ge,[viewport.top],@f
|
||||
mov ebx,[viewport.top]
|
||||
@@: jif edx,l,[viewport.bottom],@f
|
||||
mov edx,[viewport.bottom]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
|
||||
dl.08.horz_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.top],.skip
|
||||
jif eax,ge,[rr.bottom],.skip
|
||||
jif edx,l,[rr.left],.skip
|
||||
jif ebx,ge,[rr.right],.skip
|
||||
jif ebx,ge,[rr.left],@f
|
||||
mov ebx,[rr.left]
|
||||
@@: jif edx,l,[rr.right],@f
|
||||
mov edx,[rr.right]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_hln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,eax
|
||||
add ebp,ebx
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
movzx ecx,byte[ebp]
|
||||
mov ecx,dword[palette_8_256+ecx*3]
|
||||
not ecx
|
||||
call color_24_to_8_bits
|
||||
or ecx,0x01000000
|
||||
.dr: mov [ebp],cl
|
||||
pop ebp
|
||||
; test ecx,0x01000000
|
||||
; jz .dr
|
||||
; mov cx,[ebp]
|
||||
; not cx
|
||||
; .dr: mov [ebp],cx
|
||||
inc ebp
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.bottom],.exit
|
||||
movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.left],.exit
|
||||
jif ebx,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.left],@f
|
||||
mov ebx,[viewport.left]
|
||||
@@: jif edx,l,[viewport.right],@f
|
||||
mov edx,[viewport.right]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
endf
|
||||
|
||||
func color_24_to_8_bits
|
||||
begin
|
||||
push ecx
|
||||
cmp byte[esp+2],0 ; red=0 ?
|
||||
pop ecx
|
||||
jne .lp1
|
||||
cmp ch,0 ; green=0 ?
|
||||
jne @f
|
||||
shr cl,2
|
||||
add cl,192
|
||||
ret
|
||||
@@: cmp cl,0 ; blue=0 ?
|
||||
jne .lp1
|
||||
shr cx,8+2
|
||||
add cl,128
|
||||
ret
|
||||
.lp1: cmp cx,0 ; green=0 && blue=0 ?
|
||||
jne @f
|
||||
shr ecx,16+2
|
||||
and cl,0x3F
|
||||
add cl,64
|
||||
ret
|
||||
@@: and ecx,0x00FFFFFF
|
||||
shr ecx,6
|
||||
shl cx,6
|
||||
shr ecx,6
|
||||
shl cl,6
|
||||
shr ecx,6
|
||||
ret
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_pixel.08 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
; ecx = ?? RR GG BB ; 0x01000000 negation
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
mov edx,[bytes_per_scanline]
|
||||
imul edx,ebx
|
||||
add edx,eax
|
||||
add edx,[lfb_address]
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif ebx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
call get_cursor_rect
|
||||
call is_intersect_pt
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz .lp1
|
||||
not byte[ebp]
|
||||
jmp .exit
|
||||
.lp1: call color_24_to_8_bits
|
||||
mov [ebp],cl
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz @b
|
||||
jmp .exit
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif ebx,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz @f
|
||||
movzx eax,byte[ebp]
|
||||
mov ecx,dword[palette_8_256+eax*3]
|
||||
not ecx
|
||||
call color_24_to_8_bits
|
||||
mov byte[ebp],cl
|
||||
;not byte[ebp]
|
||||
jmp .exit
|
||||
@@: call color_24_to_8_bits
|
||||
mov [ebp],cl
|
||||
jmp .exit
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_get_pixel.08 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
imul ebx,[bytes_per_scanline]
|
||||
add eax,ebx
|
||||
add eax,[lfb_address]
|
||||
push eax
|
||||
call [set_bank]
|
||||
pop eax
|
||||
movzx eax,byte[ebp]
|
||||
mov eax,dword[palette_8_256+eax*3]
|
||||
and eax,0x00FFFFFF
|
||||
mov [esp+4*6],eax
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_image.08 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
|
||||
; ebx(ecx) image size [x]*65536+[y]
|
||||
; ecx(edx) image position in window [x]*65536+[y]
|
||||
; ret: eax 0 succesful, 1 overlapped
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
mov eax,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,edx
|
||||
.direct:
|
||||
pushad
|
||||
cli
|
||||
jif ebx,z,0x0000FFFF,.exit,test
|
||||
jif ebx,z,0xFFFF0000,.exit,test
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,eax
|
||||
movsx eax,word[esp+4*6+2]
|
||||
movsx ebx,word[esp+4*6]
|
||||
movsx ecx,word[esp+4*4+2]
|
||||
movsx edx,word[esp+4*4]
|
||||
lea edi,[ecx*3]
|
||||
push edi
|
||||
add ecx,eax
|
||||
add edx,ebx
|
||||
mov edi,[0x00003010]
|
||||
movsx esi,word[edi-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[edi-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[esi-0x3000+0]
|
||||
; add ebx,[esi-0x3000+4]
|
||||
; add ecx,[esi-0x3000+0]
|
||||
; add edx,[esi-0x3000+4]
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
cld
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov esi,ebx
|
||||
sub esi,[esp+4*4]
|
||||
imul esi,[esp+4*8]
|
||||
mov edi,eax
|
||||
sub edi,[esp+4*7]
|
||||
lea edi,[edi*3]
|
||||
add esi,edi
|
||||
add esi,ebp
|
||||
mov edi,[bytes_per_scanline]
|
||||
imul edi,ebx
|
||||
add edi,eax
|
||||
add edi,[lfb_address]
|
||||
.xxx: push eax esi edi eax
|
||||
@@: lodsd
|
||||
xchg eax,ecx
|
||||
call color_24_to_8_bits
|
||||
xchg eax,ecx
|
||||
|
||||
push ebp edi
|
||||
call [set_bank]
|
||||
mov [ebp],al
|
||||
pop edi ebp
|
||||
inc edi
|
||||
|
||||
dec esi
|
||||
inc dword[esp]
|
||||
cmp [esp],ecx
|
||||
jl @b
|
||||
pop eax edi esi eax
|
||||
add esi,[esp+4*8]
|
||||
add edi,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
add esp,4
|
||||
sti
|
||||
popad
|
||||
xor eax,eax
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_bg.08 ;/////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
|
||||
mov eax,[viewport.left]
|
||||
mov ebx,[viewport.top]
|
||||
mov ecx,[viewport.right]
|
||||
mov edx,[viewport.bottom]
|
||||
|
||||
cli
|
||||
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
|
||||
mov esi,[CLIP_RECTS+4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: pushad
|
||||
; jif eax,ge,[rr.left],@f
|
||||
; mov eax,[rr.left]
|
||||
; @@: jif ebx,ge,[rr.top],@f
|
||||
; mov ebx,[rr.top]
|
||||
; @@: jif ecx,l,[rr.right],@f
|
||||
; mov ecx,[rr.right]
|
||||
; @@: jif edx,l,[rr.bottom],@f
|
||||
; mov edx,[rr.bottom]
|
||||
; @@:
|
||||
mov eax,[rr.left]
|
||||
mov ebx,[rr.top]
|
||||
mov ecx,[rr.right]
|
||||
mov edx,[rr.bottom]
|
||||
dec ecx
|
||||
dec edx
|
||||
mov edi,0x007F7F7F
|
||||
call vm_mike_draw_rect.08
|
||||
xor edi,edi
|
||||
pushad
|
||||
shl eax,16
|
||||
mov ax,cx
|
||||
push bx
|
||||
shl ebx,16
|
||||
pop bx
|
||||
mov ecx,0x00CCCCCC
|
||||
call vm_mike_draw_line.08
|
||||
add ebx,0x00010001
|
||||
call vm_mike_draw_line.08
|
||||
popad
|
||||
pushad
|
||||
shl ebx,16
|
||||
mov bx,dx
|
||||
push ax
|
||||
shl eax,16
|
||||
pop ax
|
||||
mov ecx,0x00CCCCCC
|
||||
call vm_mike_draw_line.08
|
||||
add eax,0x00010001
|
||||
call vm_mike_draw_line.08
|
||||
popad
|
||||
pushad
|
||||
shl eax,16
|
||||
mov ax,cx
|
||||
mov ebx,edx
|
||||
shl ebx,16
|
||||
mov bx,dx
|
||||
mov ecx,0x00333333
|
||||
call vm_mike_draw_line.08
|
||||
sub ebx,0x00010001
|
||||
add eax,0x00010000
|
||||
call vm_mike_draw_line.08
|
||||
popad
|
||||
pushad
|
||||
mov eax,ecx
|
||||
shl eax,16
|
||||
mov ax,cx
|
||||
shl ebx,16
|
||||
mov bx,dx
|
||||
mov ecx,0x00333333
|
||||
call vm_mike_draw_line.08
|
||||
sub eax,0x00010001
|
||||
add ebx,0x00010000
|
||||
call vm_mike_draw_line.08
|
||||
popad
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
macro sdfsdSAFSDFG {
|
||||
pushad
|
||||
|
||||
cmp byte[bg_type],BGT_TILE
|
||||
je .tiled
|
||||
|
||||
mov eax,[bg_width]
|
||||
cmp eax,[screen_width]
|
||||
jne @f
|
||||
mov eax,[bg_height]
|
||||
cmp eax,[screen_height]
|
||||
je .tiled
|
||||
@@:
|
||||
imul eax,[bg_width],3
|
||||
mov [bg_bytes_per_scanline],eax
|
||||
|
||||
mov eax,[viewport.left]
|
||||
mov ebx,[viewport.top]
|
||||
mov ecx,[viewport.right]
|
||||
mov edx,[viewport.bottom]
|
||||
|
||||
cmp [bg_width],1
|
||||
jne @f
|
||||
cmp [bg_height],1
|
||||
je .color
|
||||
@@:
|
||||
cli
|
||||
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
|
||||
mov esi,[CLIP_RECTS+4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
add ebp,eax
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
mov [ebp],di
|
||||
pop ebp
|
||||
; mov [ebp],di
|
||||
inc ebp
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
.tiled:
|
||||
mov eax,bg_address
|
||||
mov ebx,[bg_width-2]
|
||||
mov bx,word[bg_height]
|
||||
xor ecx,ecx
|
||||
.lp1: push eax
|
||||
call vm_mike_put_image.08.direct
|
||||
pop eax
|
||||
rol ecx,16
|
||||
add cx,word[bg_width]
|
||||
cmp cx,word[screen_width]
|
||||
jae @f
|
||||
rol ecx,16
|
||||
jmp .lp1
|
||||
@@: shr ecx,16
|
||||
add ecx,[bg_height]
|
||||
cmp ecx,[screen_height]
|
||||
jb .lp1
|
||||
popad
|
||||
retn
|
||||
|
||||
.color:
|
||||
mov edi,[bg_address]
|
||||
and edi,0x00FFFFFF
|
||||
call vm_mike_draw_rect.08
|
||||
popad
|
||||
retn
|
||||
}
|
||||
endf
|
||||
651
kernel/branches/gfx_kernel/vmode/norm_15.inc
Executable file
651
kernel/branches/gfx_kernel/vmode/norm_15.inc
Executable file
@@ -0,0 +1,651 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_rect.15 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax - x start
|
||||
; ebx - y start
|
||||
; ecx - x end
|
||||
; edx - y end
|
||||
; edi - color
|
||||
;-----------------------------------------------------------------------------
|
||||
;- eax(ebx) [x start]*65536 + [x size]
|
||||
;- ebx(ecx) [y start]*65536 + [y size]
|
||||
;- ecx(edx) color 0x00RRGGBB
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
jif eax,e,ecx,.exit
|
||||
jif ebx,e,edx,.exit
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,[0x3010]
|
||||
movsx esi,word[ebp-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[ebp-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[ebp-0x3000+0]
|
||||
; add ebx,[ebp-0x3000+4]
|
||||
; add ecx,[ebp-0x3000+0]
|
||||
; add edx,[ebp-0x3000+4]
|
||||
|
||||
push eax
|
||||
mov eax,edi
|
||||
shr eax,3
|
||||
shl ax,3
|
||||
shr eax,3
|
||||
shl al,3
|
||||
shr eax,3
|
||||
mov di,ax
|
||||
pop eax
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*2]
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
mov [ebp],di
|
||||
pop ebp
|
||||
; mov [ebp],di
|
||||
add ebp,2
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_line.15 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) [x start] shl 16 + [x end]
|
||||
; ebx(ecx) [y start] shl 16 + [y end]
|
||||
; ecx(edx) colour 0x00RRGGBB
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov eax,ecx
|
||||
shr ecx,3
|
||||
shl cx,3
|
||||
shr ecx,3
|
||||
shl cl,3
|
||||
shr ecx,3
|
||||
and eax,0x01000000
|
||||
or ecx,eax
|
||||
|
||||
movsx eax,word[esp+4*7] ; x end
|
||||
cmp ax,[esp+4*7+2] ; x start
|
||||
je dl.15.vert_line
|
||||
movsx eax,word[esp+4*4] ; y end
|
||||
cmp ax,[esp+4*4+2] ; y start
|
||||
je dl.15.horz_line
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
dl.15.vert_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_vln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*2]
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
mov cx,[ebp]
|
||||
not cx
|
||||
.dr: mov [ebp],cx
|
||||
pop ebp
|
||||
; test ecx,0x01000000
|
||||
; jz .dr
|
||||
; mov cx,[ebp]
|
||||
; not cx
|
||||
; .dr: mov [ebp],cx
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
jif ebx,e,edx,.exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.top],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
jif ebx,ge,[viewport.top],@f
|
||||
mov ebx,[viewport.top]
|
||||
@@: jif edx,l,[viewport.bottom],@f
|
||||
mov edx,[viewport.bottom]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
|
||||
dl.15.horz_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.top],.skip
|
||||
jif eax,ge,[rr.bottom],.skip
|
||||
jif edx,l,[rr.left],.skip
|
||||
jif ebx,ge,[rr.right],.skip
|
||||
jif ebx,ge,[rr.left],@f
|
||||
mov ebx,[rr.left]
|
||||
@@: jif edx,l,[rr.right],@f
|
||||
mov edx,[rr.right]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_hln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,eax
|
||||
lea ebp,[ebp+ebx*2]
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
mov cx,[ebp]
|
||||
not cx
|
||||
.dr: mov [ebp],cx
|
||||
pop ebp
|
||||
; test ecx,0x01000000
|
||||
; jz .dr
|
||||
; mov cx,[ebp]
|
||||
; not cx
|
||||
; .dr: mov [ebp],cx
|
||||
add ebp,2
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.bottom],.exit
|
||||
movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.left],.exit
|
||||
jif ebx,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.left],@f
|
||||
mov ebx,[viewport.left]
|
||||
@@: jif edx,l,[viewport.right],@f
|
||||
mov edx,[viewport.right]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_pixel.15 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
; ecx = ?? RR GG BB ; 0x01000000 negation
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
mov edx,[bytes_per_scanline]
|
||||
imul edx,ebx
|
||||
lea edx,[edx+eax*2]
|
||||
add edx,[lfb_address]
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif ebx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
call get_cursor_rect
|
||||
call is_intersect_pt
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz .lp1
|
||||
not word[ebp]
|
||||
jmp .exit
|
||||
.lp1: shr ecx,3
|
||||
shl cx,3
|
||||
shr ecx,3
|
||||
shl cl,3
|
||||
shr ecx,3
|
||||
mov [ebp],cx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz @b
|
||||
jmp .exit
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif ebx,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz @f
|
||||
not word[ebp]
|
||||
jmp .exit
|
||||
@@: shr ecx,3
|
||||
shl cx,3
|
||||
shr ecx,3
|
||||
shl cl,3
|
||||
shr ecx,3
|
||||
mov [ebp],cx
|
||||
jmp .exit
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_get_pixel.15 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
imul ebx,[bytes_per_scanline]
|
||||
shl eax,1
|
||||
add eax,ebx
|
||||
add eax,[lfb_address]
|
||||
push eax
|
||||
call [set_bank]
|
||||
pop eax
|
||||
movzx eax,word[ebp]
|
||||
|
||||
shl eax,3
|
||||
shr al,3
|
||||
shl eax,3
|
||||
shr ax,3
|
||||
shl eax,3
|
||||
|
||||
and eax,0x00FFFFFF
|
||||
mov [esp+4*6],eax
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_image.15 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
|
||||
; ebx(ecx) image size [x]*65536+[y]
|
||||
; ecx(edx) image position in window [x]*65536+[y]
|
||||
; ret: eax 0 succesful, 1 overlapped
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
mov eax,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,edx
|
||||
.direct:
|
||||
pushad
|
||||
cli
|
||||
jif ebx,z,0x0000FFFF,.exit,test
|
||||
jif ebx,z,0xFFFF0000,.exit,test
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,eax
|
||||
movsx eax,word[esp+4*6+2]
|
||||
movsx ebx,word[esp+4*6]
|
||||
movsx ecx,word[esp+4*4+2]
|
||||
movsx edx,word[esp+4*4]
|
||||
lea edi,[ecx*3]
|
||||
push edi
|
||||
add ecx,eax
|
||||
add edx,ebx
|
||||
mov edi,[0x00003010]
|
||||
movsx esi,word[edi-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[edi-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[esi-0x3000+0]
|
||||
; add ebx,[esi-0x3000+4]
|
||||
; add ecx,[esi-0x3000+0]
|
||||
; add edx,[esi-0x3000+4]
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
cld
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov esi,ebx
|
||||
sub esi,[esp+4*4]
|
||||
imul esi,[esp+4*8]
|
||||
mov edi,eax
|
||||
sub edi,[esp+4*7]
|
||||
lea edi,[edi*3]
|
||||
add esi,edi
|
||||
add esi,ebp
|
||||
mov edi,[bytes_per_scanline]
|
||||
imul edi,ebx
|
||||
lea edi,[edi+eax*2]
|
||||
add edi,[lfb_address]
|
||||
.xxx: push eax esi edi eax
|
||||
@@: lodsd
|
||||
shr eax,3
|
||||
shl ax,3
|
||||
shr eax,3
|
||||
shl al,3
|
||||
shr eax,3
|
||||
|
||||
push ebp edi
|
||||
call [set_bank]
|
||||
mov [ebp],ax
|
||||
pop edi ebp
|
||||
add edi,2
|
||||
|
||||
dec esi
|
||||
inc dword[esp]
|
||||
cmp [esp],ecx
|
||||
jl @b
|
||||
pop eax edi esi eax
|
||||
add esi,[esp+4*8]
|
||||
add edi,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
add esp,4
|
||||
sti
|
||||
popad
|
||||
xor eax,eax
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_bg.15 ;/////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
|
||||
cmp byte[bg_type],BGT_TILE
|
||||
je .tiled
|
||||
|
||||
mov eax,[bg_width]
|
||||
cmp eax,[screen_width]
|
||||
jne @f
|
||||
mov eax,[bg_height]
|
||||
cmp eax,[screen_height]
|
||||
je .tiled
|
||||
@@:
|
||||
imul eax,[bg_width],3
|
||||
mov [bg_bytes_per_scanline],eax
|
||||
|
||||
mov eax,[viewport.left]
|
||||
mov ebx,[viewport.top]
|
||||
mov ecx,[viewport.right]
|
||||
mov edx,[viewport.bottom]
|
||||
|
||||
cmp [bg_width],1
|
||||
jne @f
|
||||
cmp [bg_height],1
|
||||
je .color
|
||||
@@:
|
||||
cli
|
||||
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
|
||||
mov esi,[CLIP_RECTS+4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: ;call is_intersect_rc
|
||||
;jc .put
|
||||
;cmp [mouse_invisible],0
|
||||
;jne .put
|
||||
;call [SF.draw_mouse_under]
|
||||
;mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*2]
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
push eax edx
|
||||
mul [bg_width]
|
||||
div [screen_width]
|
||||
lea edi,[eax*3]
|
||||
mov eax,ebx
|
||||
mul [bg_height]
|
||||
div [screen_height]
|
||||
mul [bg_bytes_per_scanline]
|
||||
add edi,eax
|
||||
add edi,bg_address
|
||||
mov eax,[edi]
|
||||
shr eax,3
|
||||
shl ax,3
|
||||
shr eax,3
|
||||
shl al,3
|
||||
shr eax,3
|
||||
mov [ebp],ax
|
||||
pop edx eax
|
||||
pop ebp
|
||||
inc ebp
|
||||
inc ebp
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
.tiled:
|
||||
mov eax,bg_address
|
||||
mov ebx,[bg_width-2]
|
||||
mov bx,word[bg_height]
|
||||
xor ecx,ecx
|
||||
.lp1: push eax
|
||||
call vm_mike_put_image.15.direct
|
||||
pop eax
|
||||
rol ecx,16
|
||||
add cx,word[bg_width]
|
||||
cmp cx,word[screen_width]
|
||||
jae @f
|
||||
rol ecx,16
|
||||
jmp .lp1
|
||||
@@: shr ecx,16
|
||||
add ecx,[bg_height]
|
||||
cmp ecx,[screen_height]
|
||||
jb .lp1
|
||||
popad
|
||||
retn
|
||||
|
||||
.color:
|
||||
mov edi,[bg_address]
|
||||
and edi,0x00FFFFFF
|
||||
call vm_mike_draw_rect.15
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
646
kernel/branches/gfx_kernel/vmode/norm_16.inc
Executable file
646
kernel/branches/gfx_kernel/vmode/norm_16.inc
Executable file
@@ -0,0 +1,646 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_rect.16 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax - x start
|
||||
; ebx - y start
|
||||
; ecx - x end
|
||||
; edx - y end
|
||||
; edi - color
|
||||
;-----------------------------------------------------------------------------
|
||||
;- eax(ebx) [x start]*65536 + [x size]
|
||||
;- ebx(ecx) [y start]*65536 + [y size]
|
||||
;- ecx(edx) color 0x00RRGGBB
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
jif eax,e,ecx,.exit
|
||||
jif ebx,e,edx,.exit
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,[0x3010]
|
||||
movsx esi,word[ebp-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[ebp-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[ebp-0x3000+0]
|
||||
; add ebx,[ebp-0x3000+4]
|
||||
; add ecx,[ebp-0x3000+0]
|
||||
; add edx,[ebp-0x3000+4]
|
||||
|
||||
push eax
|
||||
mov eax,edi
|
||||
shr eax,3
|
||||
shl ax,3
|
||||
shr eax,2
|
||||
shl al,2
|
||||
shr eax,3
|
||||
mov di,ax
|
||||
pop eax
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*2]
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
mov [ebp],di
|
||||
pop ebp
|
||||
; mov [ebp],di
|
||||
add ebp,2
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_line.16 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) [x start] shl 16 + [x end]
|
||||
; ebx(ecx) [y start] shl 16 + [y end]
|
||||
; ecx(edx) colour 0x00RRGGBB
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov eax,ecx
|
||||
shr ecx,3
|
||||
shl cx,3
|
||||
shr ecx,2
|
||||
shl cl,2
|
||||
shr ecx,3
|
||||
and eax,0x01000000
|
||||
or ecx,eax
|
||||
|
||||
movsx eax,word[esp+4*7] ; x end
|
||||
cmp ax,[esp+4*7+2] ; x start
|
||||
je dl.16.vert_line
|
||||
movsx eax,word[esp+4*4] ; y end
|
||||
cmp ax,[esp+4*4+2] ; y start
|
||||
je dl.16.horz_line
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
dl.16.vert_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_vln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*2]
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
mov cx,[ebp]
|
||||
not cx
|
||||
.dr: mov [ebp],cx
|
||||
pop ebp
|
||||
; mov [ebp],cx
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
jif ebx,e,edx,.exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.top],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
jif ebx,ge,[viewport.top],@f
|
||||
mov ebx,[viewport.top]
|
||||
@@: jif edx,l,[viewport.bottom],@f
|
||||
mov edx,[viewport.bottom]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
|
||||
dl.16.horz_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.top],.skip
|
||||
jif eax,ge,[rr.bottom],.skip
|
||||
jif edx,l,[rr.left],.skip
|
||||
jif ebx,ge,[rr.right],.skip
|
||||
jif ebx,ge,[rr.left],@f
|
||||
mov ebx,[rr.left]
|
||||
@@: jif edx,l,[rr.right],@f
|
||||
mov edx,[rr.right]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_hln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,eax
|
||||
lea ebp,[ebp+ebx*2]
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
mov cx,[ebp]
|
||||
not cx
|
||||
.dr: mov [ebp],cx
|
||||
pop ebp
|
||||
; mov [ebp],cx
|
||||
add ebp,2
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.bottom],.exit
|
||||
movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.left],.exit
|
||||
jif ebx,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.left],@f
|
||||
mov ebx,[viewport.left]
|
||||
@@: jif edx,l,[viewport.right],@f
|
||||
mov edx,[viewport.right]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_pixel.16 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
; ecx = ?? RR GG BB ; 0x01000000 negation
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
mov edx,[bytes_per_scanline]
|
||||
imul edx,ebx
|
||||
lea edx,[edx+eax*2]
|
||||
add edx,[lfb_address]
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif ebx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
call get_cursor_rect
|
||||
call is_intersect_pt
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz .lp1
|
||||
not word[ebp]
|
||||
jmp .exit
|
||||
.lp1: shr ecx,3
|
||||
shl cx,3
|
||||
shr ecx,2
|
||||
shl cl,2
|
||||
shr ecx,3
|
||||
mov [ebp],cx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz @b
|
||||
jmp .exit
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif ebx,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
test ecx,0x01000000
|
||||
jz @f
|
||||
push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
not word[ebp]
|
||||
jmp .exit
|
||||
@@: shr ecx,3
|
||||
shl cx,3
|
||||
shr ecx,2
|
||||
shl cl,2
|
||||
shr ecx,3
|
||||
push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
mov [ebp],cx
|
||||
jmp .exit
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_get_pixel.16 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
imul ebx,[bytes_per_scanline]
|
||||
shl eax,1
|
||||
add eax,ebx
|
||||
add eax,[lfb_address]
|
||||
push eax
|
||||
call [set_bank]
|
||||
pop eax
|
||||
movzx eax,word[ebp]
|
||||
|
||||
shl eax,3
|
||||
shr al,2
|
||||
shl eax,2
|
||||
shr ax,3
|
||||
shl eax,3
|
||||
|
||||
and eax,0x00FFFFFF
|
||||
mov [esp+4*6],eax
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_image.16 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
|
||||
; ebx(ecx) image size [x]*65536+[y]
|
||||
; ecx(edx) image position in window [x]*65536+[y]
|
||||
; ret: eax 0 succesful, 1 overlapped
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
mov eax,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,edx
|
||||
.direct:
|
||||
pushad
|
||||
cli
|
||||
jif ebx,z,0x0000FFFF,.exit,test
|
||||
jif ebx,z,0xFFFF0000,.exit,test
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,eax
|
||||
movsx eax,word[esp+4*6+2]
|
||||
movsx ebx,word[esp+4*6]
|
||||
movsx ecx,word[esp+4*4+2]
|
||||
movsx edx,word[esp+4*4]
|
||||
lea edi,[ecx*3]
|
||||
push edi
|
||||
add ecx,eax
|
||||
add edx,ebx
|
||||
mov edi,[0x00003010]
|
||||
movsx esi,word[edi-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[edi-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[esi-0x3000+0]
|
||||
; add ebx,[esi-0x3000+4]
|
||||
; add ecx,[esi-0x3000+0]
|
||||
; add edx,[esi-0x3000+4]
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
cld
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov esi,ebx
|
||||
sub esi,[esp+4*4]
|
||||
imul esi,[esp+4*8]
|
||||
mov edi,eax
|
||||
sub edi,[esp+4*7]
|
||||
lea edi,[edi*3]
|
||||
add esi,edi
|
||||
add esi,ebp
|
||||
mov edi,[bytes_per_scanline]
|
||||
imul edi,ebx
|
||||
lea edi,[edi+eax*2]
|
||||
add edi,[lfb_address]
|
||||
.xxx: push eax esi edi eax
|
||||
@@: lodsd
|
||||
shr eax,3
|
||||
shl ax,3
|
||||
shr eax,2
|
||||
shl al,2
|
||||
shr eax,3
|
||||
|
||||
push ebp edi
|
||||
call [set_bank]
|
||||
mov [ebp],ax
|
||||
pop edi ebp
|
||||
add edi,2
|
||||
|
||||
dec esi
|
||||
inc dword[esp]
|
||||
cmp [esp],ecx
|
||||
jl @b
|
||||
pop eax edi esi eax
|
||||
add esi,[esp+4*8]
|
||||
add edi,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
add esp,4
|
||||
sti
|
||||
popad
|
||||
xor eax,eax
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_bg.16 ;/////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
|
||||
cmp byte[bg_type],BGT_TILE
|
||||
je .tiled
|
||||
|
||||
mov eax,[bg_width]
|
||||
cmp eax,[screen_width]
|
||||
jne @f
|
||||
mov eax,[bg_height]
|
||||
cmp eax,[screen_height]
|
||||
je .tiled
|
||||
@@:
|
||||
imul eax,[bg_width],3
|
||||
mov [bg_bytes_per_scanline],eax
|
||||
|
||||
mov eax,[viewport.left]
|
||||
mov ebx,[viewport.top]
|
||||
mov ecx,[viewport.right]
|
||||
mov edx,[viewport.bottom]
|
||||
|
||||
cmp [bg_width],1
|
||||
jne @f
|
||||
cmp [bg_height],1
|
||||
je .color
|
||||
@@:
|
||||
cli
|
||||
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
|
||||
mov esi,[CLIP_RECTS+4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: ;call is_intersect_rc
|
||||
;jc .put
|
||||
;cmp [mouse_invisible],0
|
||||
;jne .put
|
||||
;call [SF.draw_mouse_under]
|
||||
;mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*2]
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
push eax edx
|
||||
mul [bg_width]
|
||||
div [screen_width]
|
||||
lea edi,[eax*3]
|
||||
mov eax,ebx
|
||||
mul [bg_height]
|
||||
div [screen_height]
|
||||
mul [bg_bytes_per_scanline]
|
||||
add edi,eax
|
||||
add edi,bg_address
|
||||
mov eax,[edi]
|
||||
shr eax,3
|
||||
shl ax,3
|
||||
shr eax,2
|
||||
shl al,2
|
||||
shr eax,3
|
||||
mov [ebp],ax
|
||||
pop edx eax
|
||||
pop ebp
|
||||
inc ebp
|
||||
inc ebp
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
.tiled:
|
||||
mov eax,bg_address
|
||||
mov ebx,[bg_width-2]
|
||||
mov bx,word[bg_height]
|
||||
xor ecx,ecx
|
||||
.lp1: push eax
|
||||
call vm_mike_put_image.16.direct
|
||||
pop eax
|
||||
rol ecx,16
|
||||
add cx,word[bg_width]
|
||||
cmp cx,word[screen_width]
|
||||
jae @f
|
||||
rol ecx,16
|
||||
jmp .lp1
|
||||
@@: shr ecx,16
|
||||
add ecx,[bg_height]
|
||||
cmp ecx,[screen_height]
|
||||
jb .lp1
|
||||
popad
|
||||
retn
|
||||
|
||||
.color:
|
||||
mov edi,[bg_address]
|
||||
and edi,0x00FFFFFF
|
||||
call vm_mike_draw_rect.16
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
602
kernel/branches/gfx_kernel/vmode/norm_24.inc
Executable file
602
kernel/branches/gfx_kernel/vmode/norm_24.inc
Executable file
@@ -0,0 +1,602 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_rect.24 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax - x start
|
||||
; ebx - y start
|
||||
; ecx - x end
|
||||
; edx - y end
|
||||
; edi - color
|
||||
;-----------------------------------------------------------------------------
|
||||
;- eax(ebx) [x start]*65536 + [x size]
|
||||
;- ebx(ecx) [y start]*65536 + [y size]
|
||||
;- ecx(edx) color 0x00RRGGBB
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
jif eax,e,ecx,.exit
|
||||
jif ebx,e,edx,.exit
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,[0x3010]
|
||||
movsx esi,word[ebp-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[ebp-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[ebp-0x3000+0]
|
||||
; add ebx,[ebp-0x3000+4]
|
||||
; add ecx,[ebp-0x3000+0]
|
||||
; add edx,[ebp-0x3000+4]
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
push eax
|
||||
lea eax,[eax*3]
|
||||
add ebp,eax
|
||||
pop eax
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push eax
|
||||
mov eax,edi
|
||||
mov [ebp],ax
|
||||
shr eax,16
|
||||
mov [ebp+2],al
|
||||
pop eax
|
||||
add ebp,3
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_line.24 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) [x start] shl 16 + [x end]
|
||||
; ebx(ecx) [y start] shl 16 + [y end]
|
||||
; ecx(edx) colour 0x00RRGGBB
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
movsx eax,word[esp+4*7] ; x end
|
||||
cmp ax,[esp+4*7+2] ; x start
|
||||
je dl.24.vert_line
|
||||
movsx eax,word[esp+4*4] ; y end
|
||||
cmp ax,[esp+4*4+2] ; y start
|
||||
je dl.24.horz_line
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
dl.24.vert_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_vln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
push eax
|
||||
lea eax,[eax*3]
|
||||
add ebp,eax
|
||||
pop eax
|
||||
add ebp,[lfb_address]
|
||||
@@: test ecx,0x01000000
|
||||
jz .dr
|
||||
mov ecx,[ebp]
|
||||
not ecx
|
||||
or ecx,0x01000000
|
||||
.dr: mov [ebp],cx
|
||||
ror ecx,8
|
||||
mov [ebp+2],ch
|
||||
rol ecx,8
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
jif ebx,e,edx,.exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.top],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
jif ebx,ge,[viewport.top],@f
|
||||
mov ebx,[viewport.top]
|
||||
@@: jif edx,l,[viewport.bottom],@f
|
||||
mov edx,[viewport.bottom]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
|
||||
dl.24.horz_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.top],.skip
|
||||
jif eax,ge,[rr.bottom],.skip
|
||||
jif edx,l,[rr.left],.skip
|
||||
jif ebx,ge,[rr.right],.skip
|
||||
jif ebx,ge,[rr.left],@f
|
||||
mov ebx,[rr.left]
|
||||
@@: jif edx,l,[rr.right],@f
|
||||
mov edx,[rr.right]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_hln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,eax
|
||||
push eax
|
||||
lea eax,[ebx*3]
|
||||
add ebp,eax
|
||||
pop eax
|
||||
add ebp,[lfb_address]
|
||||
@@: test ecx,0x01000000
|
||||
jz .dr
|
||||
mov ecx,[ebp]
|
||||
not ecx
|
||||
or ecx,0x01000000
|
||||
.dr: mov [ebp],cx
|
||||
ror ecx,8
|
||||
mov [ebp+2],ch
|
||||
rol ecx,8
|
||||
add ebp,3
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.bottom],.exit
|
||||
movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.left],.exit
|
||||
jif ebx,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.left],@f
|
||||
mov ebx,[viewport.left]
|
||||
@@: jif edx,l,[viewport.right],@f
|
||||
mov edx,[viewport.right]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_pixel.24 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
; ecx = ?? RR GG BB ; 0x01000000 negation
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
mov edx,[bytes_per_scanline]
|
||||
imul edx,ebx
|
||||
add edx,eax ; lea esi,[eax*3]
|
||||
lea edx,[edx+eax*2] ; add edx,esi
|
||||
add edx,[lfb_address]
|
||||
test ecx,0x01000000
|
||||
jz @f
|
||||
mov ecx,[edx]
|
||||
not ecx
|
||||
@@: test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif ebx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
call get_cursor_rect
|
||||
call is_intersect_pt
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov [edx],cx
|
||||
shr ecx,16
|
||||
mov [edx+2],cl
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz @b
|
||||
jmp .exit
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif ebx,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
mov [edx],cx
|
||||
shr ecx,16
|
||||
mov [edx+2],cl
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_get_pixel.24 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
imul ebx,[bytes_per_scanline]
|
||||
lea eax,[eax*3]
|
||||
add eax,ebx
|
||||
add eax,[lfb_address]
|
||||
mov eax,[eax]
|
||||
and eax,0x00FFFFFF
|
||||
mov [esp+4*6],eax
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_image.24 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
|
||||
; ebx(ecx) image size [x]*65536+[y]
|
||||
; ecx(edx) image position in window [x]*65536+[y]
|
||||
; ret: eax 0 succesful, 1 overlapped
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
mov eax,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,edx
|
||||
|
||||
.direct:
|
||||
pushad
|
||||
cli
|
||||
jif ebx,z,0x0000FFFF,.exit,test
|
||||
jif ebx,z,0xFFFF0000,.exit,test
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,eax
|
||||
movsx eax,word[esp+4*6+2]
|
||||
movsx ebx,word[esp+4*6]
|
||||
movsx ecx,word[esp+4*4+2]
|
||||
movsx edx,word[esp+4*4]
|
||||
|
||||
lea edi,[ecx*3]
|
||||
push edi
|
||||
add ecx,eax
|
||||
add edx,ebx
|
||||
mov edi,[0x00003010]
|
||||
movsx esi,word[edi-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[edi-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[edi-0x3000+0]
|
||||
; add ebx,[edi-0x3000+4]
|
||||
; add ecx,[edi-0x3000+0]
|
||||
; add edx,[edi-0x3000+4]
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
cld
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov esi,ebx
|
||||
sub esi,[esp+4*4]
|
||||
imul esi,[esp+4*8]
|
||||
mov edi,eax
|
||||
sub edi,[esp+4*7]
|
||||
lea edi,[edi*3]
|
||||
add esi,edi
|
||||
add esi,ebp
|
||||
mov edi,[bytes_per_scanline]
|
||||
imul edi,ebx
|
||||
push eax
|
||||
lea eax,[eax*3]
|
||||
add edi,eax
|
||||
pop eax
|
||||
add edi,[lfb_address]
|
||||
.xxx: push eax esi edi eax
|
||||
@@: ;movsd
|
||||
;dec esi
|
||||
;dec edi
|
||||
movsw
|
||||
movsb
|
||||
inc dword[esp]
|
||||
cmp [esp],ecx
|
||||
jl @b
|
||||
pop eax edi esi eax
|
||||
add esi,[esp+4*8]
|
||||
add edi,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
add esp,4
|
||||
sti
|
||||
popad
|
||||
xor eax,eax
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_bg.24 ;/////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
|
||||
cmp byte[bg_type],BGT_TILE
|
||||
je .tiled
|
||||
|
||||
mov eax,[bg_width]
|
||||
cmp eax,[screen_width]
|
||||
jne @f
|
||||
mov eax,[bg_height]
|
||||
cmp eax,[screen_height]
|
||||
je .tiled
|
||||
@@:
|
||||
imul eax,[bg_width],3
|
||||
mov [bg_bytes_per_scanline],eax
|
||||
|
||||
mov eax,[viewport.left]
|
||||
mov ebx,[viewport.top]
|
||||
mov ecx,[viewport.right]
|
||||
mov edx,[viewport.bottom]
|
||||
|
||||
cmp [bg_width],1
|
||||
jne @f
|
||||
cmp [bg_height],1
|
||||
je .color
|
||||
@@:
|
||||
cli
|
||||
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
|
||||
mov esi,[CLIP_RECTS+4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: ;call is_intersect_rc
|
||||
;jc .put
|
||||
;cmp [mouse_invisible],0
|
||||
;jne .put
|
||||
;call [SF.draw_mouse_under]
|
||||
;mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
push eax
|
||||
lea eax,[eax*3]
|
||||
add ebp,eax
|
||||
pop eax
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
push eax edx
|
||||
mul [bg_width]
|
||||
div [screen_width]
|
||||
lea edi,[eax*3]
|
||||
mov eax,ebx
|
||||
mul [bg_height]
|
||||
div [screen_height]
|
||||
mul [bg_bytes_per_scanline]
|
||||
add edi,eax
|
||||
add edi,bg_address
|
||||
mov eax,[edi]
|
||||
mov [ebp],eax
|
||||
pop edx eax
|
||||
pop ebp
|
||||
add ebp,3
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
.tiled:
|
||||
mov eax,bg_address
|
||||
mov ebx,[bg_width-2]
|
||||
mov bx,word[bg_height]
|
||||
xor ecx,ecx
|
||||
.lp1: push eax
|
||||
call vm_mike_put_image.24.direct
|
||||
pop eax
|
||||
rol ecx,16
|
||||
add cx,word[bg_width]
|
||||
cmp cx,word[screen_width]
|
||||
jae @f
|
||||
rol ecx,16
|
||||
jmp .lp1
|
||||
@@: shr ecx,16
|
||||
add ecx,[bg_height]
|
||||
cmp ecx,[screen_height]
|
||||
jb .lp1
|
||||
popad
|
||||
retn
|
||||
|
||||
.color:
|
||||
mov edi,[bg_address]
|
||||
and edi,0x00FFFFFF
|
||||
call vm_mike_draw_rect.24
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
617
kernel/branches/gfx_kernel/vmode/norm_32.inc
Executable file
617
kernel/branches/gfx_kernel/vmode/norm_32.inc
Executable file
@@ -0,0 +1,617 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_rect.32 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax - x start
|
||||
; ebx - y start
|
||||
; ecx - x end
|
||||
; edx - y end
|
||||
; edi - color
|
||||
;-----------------------------------------------------------------------------
|
||||
;- eax(ebx) [x start]*65536 + [x size]
|
||||
;- ebx(ecx) [y start]*65536 + [y size]
|
||||
;- ecx(edx) color 0x00RRGGBB
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
jif eax,e,ecx,.exit
|
||||
jif ebx,e,edx,.exit
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,[0x3010]
|
||||
movsx esi,word[ebp-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[ebp-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[ebp-0x3000+0]
|
||||
; add ebx,[ebp-0x3000+4]
|
||||
; add ecx,[ebp-0x3000+0]
|
||||
; add edx,[ebp-0x3000+4]
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*4]
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
mov [ebp],edi
|
||||
pop ebp
|
||||
; mov [ebp],edi
|
||||
add ebp,4
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_line.32 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) [x start] shl 16 + [x end]
|
||||
; ebx(ecx) [y start] shl 16 + [y end]
|
||||
; ecx(edx) colour 0x00RRGGBB
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
movsx eax,word[esp+4*7] ; x end
|
||||
cmp ax,[esp+4*7+2] ; x start
|
||||
je dl.32.vert_line
|
||||
movsx eax,word[esp+4*4] ; y end
|
||||
cmp ax,[esp+4*4+2] ; y start
|
||||
je dl.32.horz_line
|
||||
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
dl.32.vert_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_vln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*4]
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
mov ecx,[ebp]
|
||||
not ecx
|
||||
or ecx,0x01000000
|
||||
.dr: mov [ebp],ecx
|
||||
pop ebp
|
||||
; test ecx,0x01000000
|
||||
; jz .dr
|
||||
; mov ecx,[ebp]
|
||||
; not ecx
|
||||
; or ecx,0x01000000
|
||||
; .dr: mov [ebp],ecx
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
movsx ebx,word[esp+4*4+2] ; y start
|
||||
movsx edx,word[esp+4*4] ; y end
|
||||
jif ebx,e,edx,.exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.top],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
jif ebx,ge,[viewport.top],@f
|
||||
mov ebx,[viewport.top]
|
||||
@@: jif edx,l,[viewport.bottom],@f
|
||||
mov edx,[viewport.bottom]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
|
||||
dl.32.horz_line:
|
||||
test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif eax,l,[rr.top],.skip
|
||||
jif eax,ge,[rr.bottom],.skip
|
||||
jif edx,l,[rr.left],.skip
|
||||
jif ebx,ge,[rr.right],.skip
|
||||
jif ebx,ge,[rr.left],@f
|
||||
mov ebx,[rr.left]
|
||||
@@: jif edx,l,[rr.right],@f
|
||||
mov edx,[rr.right]
|
||||
dec edx
|
||||
.draw:
|
||||
@@: call is_intersect_hln
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,eax
|
||||
lea ebp,[ebp+ebx*4]
|
||||
add ebp,[lfb_address]
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
test ecx,0x01000000
|
||||
jz .dr
|
||||
mov ecx,[ebp]
|
||||
not ecx
|
||||
or ecx,0x01000000
|
||||
.dr: mov [ebp],ecx
|
||||
pop ebp
|
||||
; test ecx,0x01000000
|
||||
; jz .dr
|
||||
; mov ecx,[ebp]
|
||||
; not ecx
|
||||
; or ecx,0x01000000
|
||||
; .dr: mov [ebp],ecx
|
||||
add ebp,4
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jle @b
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.forced:
|
||||
jif eax,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.bottom],.exit
|
||||
movsx ebx,word[esp+4*7+2] ; x start
|
||||
movsx edx,word[esp+4*7] ; x end
|
||||
cmp ebx,edx
|
||||
je .exit
|
||||
jl @f
|
||||
xchg ebx,edx
|
||||
@@: jif edx,l,[viewport.left],.exit
|
||||
jif ebx,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.left],@f
|
||||
mov ebx,[viewport.left]
|
||||
@@: jif edx,l,[viewport.right],@f
|
||||
mov edx,[viewport.right]
|
||||
dec edx
|
||||
@@: mov edi,1
|
||||
jmp .draw
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_pixel.32 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
; ecx = ?? RR GG BB ; 0x01000000 negation
|
||||
; edi = 0x00000001 force
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
mov edx,[bytes_per_scanline]
|
||||
imul edx,ebx
|
||||
lea edx,[edx+eax*4]
|
||||
add edx,[lfb_address]
|
||||
; test ecx,0x01000000
|
||||
; jz @f
|
||||
; mov ecx,[edx]
|
||||
; not ecx
|
||||
@@: test edi,1
|
||||
jnz .forced
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
@@: jif eax,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif ebx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
call get_cursor_rect
|
||||
call is_intersect_pt
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz .lp1
|
||||
not dword[ebp]
|
||||
jmp .exit
|
||||
.lp1: mov [ebp],ecx
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz @b
|
||||
jmp .exit
|
||||
.forced:
|
||||
jif eax,l,[viewport.left],.exit
|
||||
jif ebx,l,[viewport.top],.exit
|
||||
jif eax,ge,[viewport.right],.exit
|
||||
jif ebx,ge,[viewport.bottom],.exit
|
||||
push edx
|
||||
call [set_bank]
|
||||
pop edx
|
||||
test ecx,0x01000000
|
||||
jz .lp2
|
||||
not dword[ebp]
|
||||
jmp .exit
|
||||
.lp2: mov [ebp],ecx
|
||||
jmp .exit
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_get_pixel.32 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax = x coordinate
|
||||
; ebx = y coordinate
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
cli
|
||||
imul ebx,[bytes_per_scanline]
|
||||
shl eax,2
|
||||
add eax,ebx
|
||||
add eax,[lfb_address]
|
||||
push eax
|
||||
call [set_bank]
|
||||
pop eax
|
||||
mov eax,[ebp]
|
||||
and eax,0x00FFFFFF
|
||||
mov [esp+4*6],eax
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_put_image.32 ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
|
||||
; ebx(ecx) image size [x]*65536+[y]
|
||||
; ecx(edx) image position in window [x]*65536+[y]
|
||||
; ret: eax 0 succesful, 1 overlapped
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
mov eax,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,edx
|
||||
|
||||
.direct:
|
||||
pushad
|
||||
cli
|
||||
jif ebx,z,0x0000FFFF,.exit,test
|
||||
jif ebx,z,0xFFFF0000,.exit,test
|
||||
|
||||
call get_cursor_rect
|
||||
|
||||
mov ebp,eax
|
||||
movsx eax,word[esp+4*6+2]
|
||||
movsx ebx,word[esp+4*6]
|
||||
movsx ecx,word[esp+4*4+2]
|
||||
movsx edx,word[esp+4*4]
|
||||
|
||||
lea edi,[ecx*3]
|
||||
push edi
|
||||
add ecx,eax
|
||||
add edx,ebx
|
||||
mov edi,[0x00003010]
|
||||
movsx esi,word[edi-0x3000+0]
|
||||
add eax,esi
|
||||
add ecx,esi
|
||||
movsx esi,word[edi-0x3000+4]
|
||||
add ebx,esi
|
||||
add edx,esi
|
||||
; add eax,[esi-0x3000+0]
|
||||
; add ebx,[esi-0x3000+4]
|
||||
; add ecx,[esi-0x3000+0]
|
||||
; add edx,[esi-0x3000+4]
|
||||
|
||||
; cmp eax,640
|
||||
; jb @f
|
||||
; SHFLOW '%x %x %x %x',eax,ebx,ecx,edx
|
||||
; @@:
|
||||
|
||||
mov esi,[0x00003000]
|
||||
mov esi,[CLIP_RECTS+esi*4]
|
||||
mov edi,[esi]
|
||||
or edi,edi
|
||||
jz .exit
|
||||
add esi,4
|
||||
cld
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: call is_intersect_rc
|
||||
jc .put
|
||||
cmp [mouse_invisible],0
|
||||
jne .put
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
.put: mov esi,ebx
|
||||
sub esi,[esp+4*4]
|
||||
imul esi,[esp+4*8]
|
||||
mov edi,eax
|
||||
sub edi,[esp+4*7]
|
||||
lea edi,[edi*3]
|
||||
add esi,edi
|
||||
add esi,ebp
|
||||
mov edi,[bytes_per_scanline]
|
||||
imul edi,ebx
|
||||
lea edi,[edi+eax*4]
|
||||
add edi,[lfb_address]
|
||||
.xxx: push eax esi edi eax
|
||||
@@: lodsd
|
||||
|
||||
push ebp edi
|
||||
call [set_bank]
|
||||
mov [ebp],eax
|
||||
pop edi ebp
|
||||
add edi,4
|
||||
|
||||
dec esi
|
||||
inc dword[esp]
|
||||
cmp [esp],ecx
|
||||
jl @b
|
||||
pop eax edi esi eax
|
||||
add esi,[esp+4*8]
|
||||
add edi,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec edi
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
add esp,4
|
||||
sti
|
||||
popad
|
||||
xor eax,eax
|
||||
retn
|
||||
endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
func vm_mike_draw_bg.32 ;/////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
begin
|
||||
pushad
|
||||
|
||||
cmp byte[bg_type],BGT_TILE
|
||||
je .tiled
|
||||
|
||||
mov eax,[bg_width]
|
||||
cmp eax,[screen_width]
|
||||
jne @f
|
||||
mov eax,[bg_height]
|
||||
cmp eax,[screen_height]
|
||||
je .tiled
|
||||
@@:
|
||||
imul eax,[bg_width],3
|
||||
mov [bg_bytes_per_scanline],eax
|
||||
|
||||
mov eax,[viewport.left]
|
||||
mov ebx,[viewport.top]
|
||||
mov ecx,[viewport.right]
|
||||
mov edx,[viewport.bottom]
|
||||
|
||||
cmp [bg_width],1
|
||||
jne @f
|
||||
cmp [bg_height],1
|
||||
je .color
|
||||
@@:
|
||||
cli
|
||||
|
||||
call [SF.draw_mouse_under]
|
||||
mov [mouse_invisible],1
|
||||
|
||||
mov esi,[CLIP_RECTS+4]
|
||||
mov ebp,[esi]
|
||||
or ebp,ebp
|
||||
jz .exit
|
||||
add esi,4
|
||||
.nx: jif ecx,l,[rr.left],.skip
|
||||
jif eax,ge,[rr.right],.skip
|
||||
jif edx,l,[rr.top],.skip
|
||||
jif ebx,ge,[rr.bottom],.skip
|
||||
pushad
|
||||
jif eax,ge,[rr.left],@f
|
||||
mov eax,[rr.left]
|
||||
@@: jif ebx,ge,[rr.top],@f
|
||||
mov ebx,[rr.top]
|
||||
@@: jif ecx,l,[rr.right],@f
|
||||
mov ecx,[rr.right]
|
||||
@@: jif edx,l,[rr.bottom],@f
|
||||
mov edx,[rr.bottom]
|
||||
@@: ;call is_intersect_rc
|
||||
;jc .put
|
||||
;cmp [mouse_invisible],0
|
||||
;jne .put
|
||||
;call [SF.draw_mouse_under]
|
||||
;mov [mouse_invisible],1
|
||||
.put: mov ebp,[bytes_per_scanline]
|
||||
imul ebp,ebx
|
||||
lea ebp,[ebp+eax*4]
|
||||
add ebp,[lfb_address]
|
||||
.xxx: push eax ebp
|
||||
@@: push ebp
|
||||
call [set_bank]
|
||||
push eax edx
|
||||
mul [bg_width]
|
||||
div [screen_width]
|
||||
lea edi,[eax*3]
|
||||
mov eax,ebx
|
||||
mul [bg_height]
|
||||
div [screen_height]
|
||||
mul [bg_bytes_per_scanline]
|
||||
add edi,eax
|
||||
add edi,bg_address
|
||||
mov eax,[edi]
|
||||
mov [ebp],eax
|
||||
pop edx eax
|
||||
pop ebp
|
||||
add ebp,4
|
||||
inc eax
|
||||
cmp eax,ecx
|
||||
jl @b
|
||||
pop ebp eax
|
||||
add ebp,[bytes_per_scanline]
|
||||
inc ebx
|
||||
cmp ebx,edx
|
||||
jl .xxx
|
||||
popad
|
||||
.skip:
|
||||
add esi,SR
|
||||
dec ebp
|
||||
jnz .nx
|
||||
|
||||
.exit:
|
||||
sti
|
||||
popad
|
||||
retn
|
||||
|
||||
.tiled:
|
||||
mov eax,bg_address
|
||||
mov ebx,[bg_width-2]
|
||||
mov bx,word[bg_height]
|
||||
xor ecx,ecx
|
||||
.lp1: push eax
|
||||
call vm_mike_put_image.32.direct
|
||||
pop eax
|
||||
rol ecx,16
|
||||
add cx,word[bg_width]
|
||||
cmp cx,word[screen_width]
|
||||
jae @f
|
||||
rol ecx,16
|
||||
jmp .lp1
|
||||
@@: shr ecx,16
|
||||
add ecx,[bg_height]
|
||||
cmp ecx,[screen_height]
|
||||
jb .lp1
|
||||
popad
|
||||
retn
|
||||
|
||||
.color:
|
||||
mov edi,[bg_address]
|
||||
and edi,0x00FFFFFF
|
||||
call vm_mike_draw_rect.32
|
||||
popad
|
||||
retn
|
||||
endf
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user