Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4922 → Rev 4923

/kernel/branches/kolibri-process/kernel.asm
343,78 → 343,17
call mutex_init
mov ecx, ide_channel2_mutex
call mutex_init
mov ecx, ide_channel3_mutex
call mutex_init
mov ecx, ide_channel4_mutex
call mutex_init
mov ecx, ide_channel5_mutex
call mutex_init
mov ecx, ide_channel6_mutex
call mutex_init
;-----------------------------------------------------------------------------
; SAVE REAL MODE VARIABLES
;-----------------------------------------------------------------------------
save_variables_IDE_controller:
xor eax, eax
mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16]
mov [IDE_Interrupt], ax
;--------------------------------------
mov ax, [BOOT_VARS + BOOT_IDE_PI_16]
mov [IDEContrProgrammingInterface], ax
;--------------------------------------
mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR]
mov [IDEContrRegsBaseAddr], ax
;--------------------------------------
mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16]
cmp ax, 0
je @f
cmp ax, 1
jne .no_PATA_BAR0
@@:
mov ax, 0x1F0
jmp @f
.no_PATA_BAR0:
and ax, 0xFFFC
@@:
mov [StandardATABases], ax
mov [hd_address_table], eax
mov [hd_address_table+8], eax
mov [IDE_BAR0_val], ax
;--------------------------------------
mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16]
cmp ax, 0
je @f
cmp ax, 1
jne .no_PATA_BAR1
@@:
mov ax, 0x3F4
jmp @f
.no_PATA_BAR1:
and ax, 0xFFFC
@@:
mov [IDE_BAR1_val], ax
;--------------------------------------
mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16]
cmp ax, 0
je @f
cmp ax, 1
jne .no_PATA_BAR2
@@:
mov ax, 0x170
jmp @f
.no_PATA_BAR2:
and ax, 0xFFFC
@@:
mov [StandardATABases+2], ax
mov [hd_address_table+16], eax
mov [hd_address_table+24], eax
mov [IDE_BAR2_val], ax
;--------------------------------------
mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16]
cmp ax, 0
je @f
cmp ax, 1
jne .no_PATA_BAR3
@@:
mov ax, 0x374
jmp @f
.no_PATA_BAR3:
and ax, 0xFFFC
@@:
mov [IDE_BAR3_val], ax
 
; --------------- APM ---------------------
 
; init selectors
742,8 → 681,12
mov esi, boot_v86machine
call boot_log
; Initialize system V86 machine
call init_sys_v86
; call init_sys_v86
 
xchg bx, bx
 
call v86_init
 
mov esi, boot_inittimer
call boot_log
; Initialize system timer (IRQ0)
750,10 → 693,12
call PIT_init
 
; Register ramdisk file system
mov esi, boot_initramdisk
call boot_log
call ramdisk_init
cmp [boot_dev+OS_BASE+0x10000], 1
je @f
 
call register_ramdisk
;--------------------------------------
@@:
mov esi, boot_initapic
call boot_log
; Try to Initialize APIC
766,6 → 711,48
call unmask_timer
stdcall enable_irq, 2 ; @#$%! PIC
stdcall enable_irq, 13 ; co-processor
 
; Setup serial output console (if enabled)
if defined debug_com_base
 
; reserve port so nobody else will use it
xor ebx, ebx
mov ecx, debug_com_base
mov edx, debug_com_base+7
call r_f_port_area
 
; enable Divisor latch
mov dx, debug_com_base+3
mov al, 1 shl 7
out dx, al
 
; Set speed to 115200 baud (max speed)
mov dx, debug_com_base
mov al, 0x01
out dx, al
 
mov dx, debug_com_base+1
mov al, 0x00
out dx, al
 
; No parity, 8bits words, one stop bit, dlab bit back to 0
mov dx, debug_com_base+3
mov al, 3
out dx, al
 
; disable interrupts
mov dx, debug_com_base+1
mov al, 0
out dx, al
 
; clear + enable fifo (64 bits)
mov dx, debug_com_base+2
mov al, 0x7 + 1 shl 5
out dx, al
 
end if
 
 
;-----------------------------------------------------------------------------
; show SVN version of kernel on the message board
;-----------------------------------------------------------------------------
787,184 → 774,15
call boot_log
include 'detect/dev_fd.inc'
;-----------------------------------------------------------------------------
; START of initialisation IDE ATA code
; create pci-devices list
;-----------------------------------------------------------------------------
cmp [IDEContrProgrammingInterface], 0
je @f
 
mov esi, boot_disabling_ide
call boot_log
;--------------------------------------
; Disable IDE interrupts, because the search
; for IDE partitions is in the PIO mode.
;--------------------------------------
.disable_IDE_interrupt:
; Disable interrupts in IDE controller for PIO
mov al, 2
mov dx, [IDE_BAR1_val] ;0x3F4
add dx, 2 ;0x3F6
out dx, al
mov dx, [IDE_BAR3_val] ;0x374
add dx, 2 ;0x376
out dx, al
@@:
; show base variables of IDE controller
DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4
DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4
DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4
DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4
DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4
DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4
DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4
mov [pci_access_enabled], 1
call pci_enum
;-----------------------------------------------------------------------------
mov esi, boot_detecthdcd
call boot_log
include 'detect/dev_hdcd.inc'
mov esi, boot_getcache
call boot_log
include 'detect/getcache.inc'
mov esi, boot_detectpart
call boot_log
include 'detect/sear_par.inc'
; initialisation IDE ATA code
;-----------------------------------------------------------------------------
mov dx, [IDEContrRegsBaseAddr]
; test whether it is our interrupt?
add dx, 2
in al, dx
test al, 100b
jz @f
; clear Bus Master IDE Status register
; clear Interrupt bit
out dx, al
@@:
add dx, 8
; test whether it is our interrupt?
in al, dx
test al, 100b
jz @f
; clear Bus Master IDE Status register
; clear Interrupt bit
out dx, al
@@:
; read status register and remove the interrupt request
mov dx, [IDE_BAR0_val] ;0x1F0
add dx, 0x7 ;0x1F7
in al, dx
mov dx, [IDE_BAR2_val] ;0x170
add dx, 0x7 ;0x177
in al, dx
include 'detect/init_ata.inc'
;-----------------------------------------------------------------------------
push eax edx
mov dx, [IDEContrRegsBaseAddr]
xor eax, eax
add dx, 2
in al, dx
DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax
 
add dx, 8
in al, dx
DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax
pop edx eax
 
cmp [IDEContrRegsBaseAddr], 0
setnz [dma_hdd]
 
cmp [IDEContrProgrammingInterface], 0
je set_interrupts_for_IDE_controllers.continue
;-----------------------------------------------------------------------------
; set interrupts for IDE Controller
;-----------------------------------------------------------------------------
mov esi, boot_set_int_IDE
call boot_log
set_interrupts_for_IDE_controllers:
mov ax, [IDEContrProgrammingInterface]
cmp ax, 0x0180
je .pata_ide
 
cmp ax, 0x018a
jne .sata_ide
;--------------------------------------
.pata_ide:
cmp [IDEContrRegsBaseAddr], 0
je .end_set_interrupts
 
stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
jmp .enable_IDE_interrupt
;--------------------------------------
.sata_ide:
cmp ax, 0x0185
je .sata_ide_1
 
cmp ax, 0x018f
jne .end_set_interrupts
;--------------------------------------
.sata_ide_1:
cmp [IDEContrRegsBaseAddr], 0
je .end_set_interrupts
 
mov ax, [IDE_Interrupt]
movzx eax, al
stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax
;--------------------------------------
.enable_IDE_interrupt:
mov esi, boot_enabling_ide
call boot_log
; Enable interrupts in IDE controller for DMA
mov al, 0
mov ah, [DRIVE_DATA+1]
test ah, 10100000b
jz @f
 
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
jmp .ch2_check
@@:
mov dx, [IDE_BAR1_val] ;0x3F4
add dx, 2 ;0x3F6
out dx, al
DEBUGF 1, "K : IDE CH1 DMA enabled\n"
.ch2_check:
test ah, 1010b
jz @f
 
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
jmp .end_set_interrupts
@@:
mov dx, [IDE_BAR3_val] ;0x374
add dx, 2 ;0x376
out dx, al
DEBUGF 1, "K : IDE CH2 DMA enabled\n"
;--------------------------------------
.end_set_interrupts:
;-----------------------------------------------------------------------------
cmp [dma_hdd], 0
je .print_pio
.print_dma:
DEBUGF 1, "K : IDE DMA mode\n"
jmp .continue
 
.print_pio:
DEBUGF 1, "K : IDE PIO mode\n"
.continue:
;-----------------------------------------------------------------------------
; END of initialisation IDE ATA code
;-----------------------------------------------------------------------------
mov esi, boot_init_sys
call boot_log
call Parser_params
 
if ~ defined extended_primary_loader
; ramdisk image should be loaded by extended primary loader if it exists
; READ RAMDISK IMAGE FROM HD
 
;!!!!!!!!!!!!!!!!!!!!!!!
include 'boot/rdload.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
end if
 
if 0
mov ax, [OS_BASE+0x10000+bx_from_load]
cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba}
1015,8 → 833,6
; mov esi, boot_devices
; call boot_log
 
mov [pci_access_enabled], 1
call pci_enum
call clear_pci_ide_interrupts
 
include "detect/vortex86.inc" ; Vortex86 SoC detection code
1092,7 → 908,7
 
; STACK AND FDC
 
; call stack_init
call stack_init
call fdc_init
 
; PALETTE FOR 320x200 and 640x480 16 col
1135,7 → 951,7
mov ebp, firstapp
call fs_execute_from_sysdir
test eax, eax
jnz first_app_found
jns first_app_found
 
mov esi, boot_failed
call boot_log
1186,7 → 1002,7
call set_lights
;// mike.dld ]
stdcall attach_int_handler, 1, irq1, 0
DEBUGF 1, "K : IRQ1 error code %x\n", eax
DEBUGF 1, "K : IRQ1 return code %x\n", eax
.no_keyboard:
 
; Load PS/2 mouse driver
1198,45 → 1014,6
call boot_log
call setmouse
 
; Setup serial output console (if enabled)
if defined debug_com_base
 
; reserve port so nobody else will use it
xor ebx, ebx
mov ecx, debug_com_base
mov edx, debug_com_base+7
call r_f_port_area
 
; enable Divisor latch
mov dx, debug_com_base+3
mov al, 1 shl 7
out dx, al
 
; Set speed to 115200 baud (max speed)
mov dx, debug_com_base
mov al, 0x01
out dx, al
 
mov dx, debug_com_base+1
mov al, 0x00
out dx, al
 
; No parity, 8bits words, one stop bit, dlab bit back to 0
mov dx, debug_com_base+3
mov al, 3
out dx, al
 
; disable interrupts
mov dx, debug_com_base+1
mov al, 0
out dx, al
 
; clear + enable fifo (64 bits)
mov dx, debug_com_base+2
mov al, 0x7 + 1 shl 5
out dx, al
 
end if
; START MULTITASKING
 
; A 'All set - press ESC to start' messages if need
1252,8 → 1029,9
mov [timer_ticks_enable], 1 ; for cd driver
 
sti
; call change_task
 
call mtrr_validate
 
jmp osloop
 
 
1341,12 → 1119,13
xchg eax, [osloop_nonperiodic_work]
test eax, eax
jz .no_periodic
; call [draw_pointer]
 
call __sys_draw_pointer
call window_check_events
call mouse_check_events
call checkmisc
call checkVga_N13
;--------------------------------------
.no_periodic:
call stack_handler
call check_fdd_motor_status
1353,6 → 1132,7
call check_ATAPI_device_event
call check_lights_state
call check_timers
 
jmp osloop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
1720,266 → 1500,231
mov eax, [esp+64+8] ; background color (if given)
mov edi, [esp+64+4]
jmp dtext
 
;-----------------------------------------------------------------------------
iglobal
midi_base dw 0
endg
;-----------------------------------------------------------------------------
align 4
 
sys_setup:
 
; 1=roland mpu midi base , base io address
; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave
; 3 = not used
; 4 = not used
; 5=system language, 1eng 2fi 3ger 4rus
; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave
; 8=fat32 partition in hd
; 9
; 10 = sound dma channel
; 6 = not used
; 7 = not used
; 8 = not used
; 9 = not used
; 10 = not used
; 11 = enable lba read
; 12 = enable pci access
;-----------------------------------------------------------------------------
and [esp+32], dword 0
; F.21.1 - set MPU MIDI base port
dec ebx
jnz @f
 
 
and [esp+32], dword 0
dec ebx ; MIDI
jnz nsyse1
cmp ecx, 0x100
jb @f
 
jb nsyse1
mov esi, 65535
cmp esi, ecx
jb @f
 
jb nsyse1
mov [midi_base], cx ;bx
mov word [mididp], cx;bx
inc cx ;bx
mov word [midisp], cx;bx
mov [midi_base], cx
mov word [mididp], cx
inc cx
mov word [midisp], cx
ret
;--------------------------------------
@@:
; F.21.2 - set keyboard layout
dec ebx
jnz @f
 
iglobal
midi_base dw 0
endg
 
nsyse1:
dec ebx ; KEYBOARD
jnz nsyse2
mov edi, [TASK_BASE]
mov eax, [edi+TASKDATA.mem_start]
add eax, edx
; 1 = normal layout
dec ecx
jnz .shift
 
dec ecx
jnz kbnobase
mov ebx, keymap
mov ecx, 128
call memmove
ret
kbnobase:
;--------------------------------------
.shift:
; 2 = layout at pressed Shift
dec ecx
jnz kbnoshift
jnz .alt
 
mov ebx, keymap_shift
mov ecx, 128
call memmove
ret
kbnoshift:
;--------------------------------------
.alt:
; 3 = layout at pressed Alt
dec ecx
jnz kbnoalt
jnz .country
 
mov ebx, keymap_alt
mov ecx, 128
call memmove
ret
kbnoalt:
;--------------------------------------
.country:
; country identifier
sub ecx, 6
jnz kbnocountry
jnz .error
 
mov word [keyboard], dx
ret
kbnocountry:
mov [esp+32], dword 1
ret
nsyse2:
dec ebx ; CD
jnz nsyse4
;--------------------------------------
@@:
; F.21.5 - set system language
sub ebx, 3
jnz @f
 
test ecx, ecx
jz nosesl
 
cmp ecx, 4
ja nosesl
mov [cd_base], cl
 
dec ecx
jnz noprma
mov eax, [hd_address_table]
mov [cdbase], eax ;0x1f0
mov [cdid], 0xa0
noprma:
 
dec ecx
jnz noprsl
mov eax, [hd_address_table]
mov [cdbase], eax ;0x1f0
mov [cdid], 0xb0
noprsl:
dec ecx
jnz nosema
mov eax, [hd_address_table+16]
mov [cdbase], eax ;0x170
mov [cdid], 0xa0
nosema:
dec ecx
jnz nosesl
mov eax, [hd_address_table+16]
mov [cdbase], eax ;0x170
mov [cdid], 0xb0
nosesl:
ret
 
iglobal
cd_base db 0
 
endg
nsyse4:
 
sub ebx, 2 ; SYSTEM LANGUAGE
jnz nsyse5
mov [syslang], ecx
ret
nsyse5:
;--------------------------------------
@@:
; F.21.11 - enable/disable low-level access to HD
and ecx, 1
sub ebx, 6
jnz @f
 
sub ebx, 2 ; HD BASE - obsolete
jnz nsyse7
 
nosethd:
mov [lba_read_enabled], ecx
ret
 
nsyse7:
 
; cmp eax,8 ; HD PARTITION - obsolete
;--------------------------------------
@@:
; F.21.12 - enable/disable low-level access to PCI
dec ebx
jnz nsyse8
ret
jnz .error
 
nsyse8:
; cmp eax,11 ; ENABLE LBA READ
and ecx, 1
sub ebx, 3
jnz no_set_lba_read
mov [lba_read_enabled], ecx
ret
 
no_set_lba_read:
; cmp eax,12 ; ENABLE PCI ACCESS
dec ebx
jnz sys_setup_err
mov [pci_access_enabled], ecx
ret
 
sys_setup_err:
;--------------------------------------
.error:
or [esp+32], dword -1
ret
 
;-----------------------------------------------------------------------------
align 4
 
sys_getsetup:
 
; 1=roland mpu midi base , base io address
; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave
; 3 = not used
; 4 = not used
; 5=system language, 1eng 2fi 3ger 4rus
; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave
; 8=fat32 partition in hd
; 6 = not used
; 7 = not used
; 8 = not used
; 9=get hs timer tic
; 10 = not used
; 11 = get the state "lba read"
; 12 = get the state "pci access"
;-----------------------------------------------------------------------------
; F.26.1 - get MPU MIDI base port
dec ebx
jnz @f
 
; cmp eax,1
dec ebx
jnz ngsyse1
movzx eax, [midi_base]
mov [esp+32], eax
ret
ngsyse1:
; cmp eax,2
;--------------------------------------
@@:
; F.26.2 - get keyboard layout
dec ebx
jnz ngsyse2
jnz @f
 
mov edi, [TASK_BASE]
mov ebx, [edi+TASKDATA.mem_start]
add ebx, edx
; 1 = normal layout
dec ecx
jnz .shift
 
; cmp ebx,1
dec ecx
jnz kbnobaseret
mov eax, keymap
mov ecx, 128
call memmove
ret
kbnobaseret:
; cmp ebx,2
;--------------------------------------
.shift:
; 2 = layout with pressed Shift
dec ecx
jnz kbnoshiftret
jnz .alt
 
mov eax, keymap_shift
mov ecx, 128
call memmove
ret
kbnoshiftret:
; cmp ebx,3
;--------------------------------------
.alt:
; 3 = layout with pressed Alt
dec ecx
jne kbnoaltret
jne .country
 
mov eax, keymap_alt
mov ecx, 128
call memmove
ret
kbnoaltret:
; cmp ebx,9
;--------------------------------------
.country:
; 9 = country identifier
sub ecx, 6
jnz ngsyse2
jnz .error
 
movzx eax, word [keyboard]
mov [esp+32], eax
ret
;--------------------------------------
@@:
; F.26.5 - get system language
sub ebx, 3
jnz @f
 
 
ngsyse2:
; cmp eax,3
dec ebx
jnz ngsyse3
movzx eax, [cd_base]
mov [esp+32], eax
ret
ngsyse3:
; cmp eax,5
sub ebx, 2
jnz ngsyse5
mov eax, [syslang]
mov [esp+32], eax
ret
ngsyse5:
; cmp eax,9
;--------------------------------------
@@:
; F.26.9 - get the value of the time counter
sub ebx, 4
jnz ngsyse9
mov eax, [timer_ticks];[0xfdf0]
jnz @f
 
mov eax, [timer_ticks]
mov [esp+32], eax
ret
ngsyse9:
; cmp eax,11
;--------------------------------------
@@:
; F.26.11 - Find out whether low-level HD access is enabled
sub ebx, 2
jnz ngsyse11
jnz @f
 
mov eax, [lba_read_enabled]
mov [esp+32], eax
ret
ngsyse11:
; cmp eax,12
;--------------------------------------
@@:
; F.26.12 - Find out whether low-level PCI access is enabled
dec ebx
jnz ngsyse12
jnz .error
 
mov eax, [pci_access_enabled]
mov [esp+32], eax
ret
ngsyse12:
mov [esp+32], dword 1
;--------------------------------------
.error:
or [esp+32], dword -1
ret
 
 
;-----------------------------------------------------------------------------
get_timer_ticks:
mov eax, [timer_ticks]
ret
 
;-----------------------------------------------------------------------------
iglobal
align 4
mousefn dd msscreen, mswin, msbutton, msset
1988,7 → 1733,7
dd app_delete_cursor
dd msz
endg
 
;-----------------------------------------------------------------------------
readmousepos:
 
; eax=0 screen relative
2461,27 → 2206,15
;------------------------------------------------------------------------------
align 4
sysfn_getdiskinfo: ; 18.11 = get disk info table
; cmp ecx,1
dec ecx
jnz full_table
small_table:
call for_all_tables
mov ecx, 10
cld
rep movsb
ret
for_all_tables:
jnz .exit
.small_table:
mov edi, edx
mov esi, DRIVE_DATA
ret
full_table:
; cmp ecx,2
dec ecx
jnz exit_for_anyone
call for_all_tables
mov ecx, DRIVE_DATA_SIZE/4
mov ecx, DRIVE_DATA_SIZE ;10
cld
rep movsd
rep movsb
.exit:
ret
;------------------------------------------------------------------------------
sysfn_lastkey: ; 18.12 = return 0 (backward compatibility)
2513,10 → 2246,10
;* mouse centered - start code- Mario79
;mouse_centered:
; push eax
mov eax, [Screen_Max_X]
mov eax, [_display.width]
shr eax, 1
mov [MOUSE_X], ax
mov eax, [Screen_Max_Y]
mov eax, [_display.height]
shr eax, 1
mov [MOUSE_Y], ax
call wakeup_osloop
2558,11 → 2291,11
; cmp ecx,4 ; set mouse pointer position
dec ecx
jnz .set_mouse_button
cmp dx, word[Screen_Max_Y]
ja .end
cmp dx, word[_display.height]
jae .end
rol edx, 16
cmp dx, word[Screen_Max_X]
ja .end
cmp dx, word[_display.width]
jae .end
mov [MOUSE_X], edx
mov [mouse_active], 1
call wakeup_osloop
2989,22 → 2722,22
jnz nosb9
; ecx = [left]*65536 + [right]
; edx = [top]*65536 + [bottom]
mov eax, [Screen_Max_X]
mov ebx, [Screen_Max_Y]
mov eax, [_display.width]
mov ebx, [_display.height]
; check [right]
cmp cx, ax
ja .exit
jae .exit
; check [left]
ror ecx, 16
cmp cx, ax
ja .exit
jae .exit
; check [bottom]
cmp dx, bx
ja .exit
jae .exit
; check [top]
ror edx, 16
cmp dx, bx
ja .exit
jae .exit
 
movzx eax, cx ; [left]
movzx ebx, dx ; [top]
3117,8 → 2850,10
jne .finish
cmp [KEY_COUNT], byte 0
je .finish
movzx eax, byte [KEY_BUFF]
movzx ax, byte [KEY_BUFF + 120 + 2]
shl eax, 8
mov al, byte [KEY_BUFF]
shl eax, 8
push eax
dec byte [KEY_COUNT]
and byte [KEY_COUNT], 127
3127,6 → 2862,9
mov eax, KEY_BUFF + 1
mov ebx, KEY_BUFF
call memmove
add eax, 120 + 2
add ebx, 120 + 2
call memmove
pop eax
;--------------------------------------
align 4
4969,9 → 4707,9
jnz @f
mov word [msg_board_pos+2], (42*6)
add word [msg_board_pos], 10
mov ax, word [Screen_Max_Y]
mov ax, word [_display.height]
cmp word [msg_board_pos], ax
jbe @f
jb @f
mov word [msg_board_pos], 10
@@:
; // end if
5281,38 → 5019,61
mov ax, word [Screen_Max_Y]
mov [esp + 32], eax
ret
 
;-----------------------------------------------------------------------------
align 4
syscall_cdaudio:
; ECX - position of CD/DVD-drive
; from 0=Primary Master to 3=Secondary Slave for first IDE contr.
; from 4=Primary Master to 7=Secondary Slave for second IDE contr.
; from 8=Primary Master to 11=Secondary Slave for third IDE contr.
cmp ecx, 11
ja .exit
 
syscall_cdaudio: ; CD
mov eax, ecx
shr eax, 2
lea eax, [eax*5]
mov al, [eax+DRIVE_DATA+1]
 
push ecx ebx
mov ebx, ecx
and ebx, 11b
shl ebx, 1
mov cl, 6
sub cl, bl
shr al, cl
test al, 2 ; it's not an ATAPI device
pop ebx ecx
 
jz .exit
 
cmp ebx, 4
jb .audio
jz .eject
je .eject
 
cmp ebx, 5
jnz .ret
je .load
;--------------------------------------
.exit:
ret
;--------------------------------------
.load:
call .reserve
call LoadMedium
;call .free
jmp .free
; ret
;--------------------------------------
.eject:
call .reserve
call clear_CD_cache
call allow_medium_removal
call EjectMedium
; call .free
jmp .free
; ret
.audio:
call sys_cd_audio
mov [esp+36-4], eax
.ret:
ret
 
;--------------------------------------
.reserve:
call reserve_cd
 
mov ebx, ecx
inc ebx
mov [cdpos], ebx
 
mov eax, ecx
shr eax, 1
and eax, 1
5322,32 → 5083,19
and eax, 1
mov [DiskNumber], al
call reserve_cd_channel
and ebx, 3
inc ebx
mov [cdpos], ebx
add ebx, ebx
mov cl, 8
sub cl, bl
mov al, [DRIVE_DATA+1]
shr al, cl
test al, 2
jz .free;.err
ret
;--------------------------------------
.free:
call free_cd_channel
and [cd_status], 0
ret
.err:
call .free
; pop eax
ret
;-----------------------------------------------------------------------------
align 4
syscall_getpixel_WinMap: ; GetPixel WinMap
cmp ebx, [Screen_Max_X]
jbe @f
cmp ecx, [Screen_Max_Y]
jbe @f
cmp ebx, [_display.width]
jb @f
cmp ecx, [_display.height]
jb @f
xor eax, eax
jmp .store
;--------------------------------------
5364,8 → 5112,7
;-----------------------------------------------------------------------------
align 4
syscall_getpixel: ; GetPixel
mov ecx, [Screen_Max_X]
inc ecx
mov ecx, [_display.width]
xor edx, edx
mov eax, ebx
div ecx
5738,8 → 5485,6
ret
@@:
call stop_all_services
movi eax, 3
call sys_cd_audio
 
yes_shutdown_param:
cli