flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Mouse driver (problem) (SOLVED) |
Author |
|
grunge 22 Feb 2007, 23:38
Hi All
I have news tests.... but not success.... when I change for not load DOS int.... the program dead... looping forever!!! ... I go continue my tests... as soon as I will have a solution I communicate to all… grunge |
|||
22 Feb 2007, 23:38 |
|
rugxulo 22 Feb 2007, 23:40
moderator, please move this to the DOS subforum (unless I misunderstood the poster's intentions).
|
|||
22 Feb 2007, 23:40 |
|
grunge 23 Feb 2007, 00:35
Hi rugxulo
No delete it... please!!! I have problem with change the code for "pure" code... one code that load and run the mouse without DOS... Thanks and sorry for my explanation of problem... |
|||
23 Feb 2007, 00:35 |
|
grunge 23 Feb 2007, 01:39
Hi All
I happy... my mouse run without DOS... I have smalls bugs... but tomorrow I work for solution it... Bugs: Mouse run loop... (I not move the mouse... but the pixel run in screen (is one ghost bug ) Last edited by grunge on 10 Mar 2007, 21:34; edited 1 time in total |
|||
23 Feb 2007, 01:39 |
|
rugxulo 23 Feb 2007, 20:37
grunge wrote: Hi rugxulo I thought you'd said without DOS, but here's what confused me: Quote:
Also, FYI, if you're writing 16-bit, 8086-compatible code, check out MCD's ONLY8086.INC include. P.S. You can "push ax bx cx dx" all on one line (but, unlike Octasm, you'll have to pop in reverse: "pop dx cx bx ax"). Also, don't forget that local labels exist: "good_hor[12] and good_ver[12]" -> "good: .hor1: .hor2: .ver1: .ver2:". (Not that it matters, but you may prefer a cleaner approach). |
|||
23 Feb 2007, 20:37 |
|
grunge 24 Feb 2007, 02:07
Thanks for yours suggestions... the ps2 mouse runs in "pure mode"... but the source have few small (logical bug) problems... but I work for solution it... All help is Welcome!!!
Quote:
This block code is for my tests when I working in FreeDos. (for not have restart and boot the mouse program all time) grunge |
|||
24 Feb 2007, 02:07 |
|
grunge 05 Mar 2007, 03:02
Hi All
I have changed the code for load mouse out DOS... but not success... this is source with run in DOS: Code: ORG 100h Jmp InstallMouse ; Load the mouse MainCode: ; Use the mouse loaded Mov AX,12h Int 10h MainLoop: ; My Main Loop, show pixel with mouse coordinates Call get_pos Mov AH,0Ch Mov CX,CX Mov DX,DX Mov AL,15 Int 10h Xor AX,AX Mov AH,11h Int 16h Jnz Exit Jmp MainLoop Exit: ; Exit code Mov AX,3h Int 10h Mov AX,0x4C00 Int 21h InstallMouse: ; Load mouse in DOS, create one int mov bl,0adh call keyboard_cmd call keyboard_read ; Pac 1 call keyboard_read ; Pac 2 call keyboard_read ; Pac 3 mov bl,0aeh call keyboard_cmd mov al,20h out 0a0h,al out 20h,al mov ax,0x2574 mov dx,mouse_code int 21h cli mov bl,0a8h call keyboard_cmd mov bl,20h call keyboard_cmd call keyboard_read or al,2 mov bl,60h push ax call keyboard_cmd pop ax call keyboard_write mov bl,0d4h call keyboard_cmd mov al,0f4h call keyboard_write Jmp MainCode ; Return to MainCode (mouse loaded, then: use mouse ) mouse_code: ; Mouse codes push ax push bx push cx push dx push di push si push es push ds push cs pop ds mov bl,0adh call keyboard_cmd call keyboard_read ; for first byte call keyboard_read cbw add word [pos_x],ax mov ax,word [x_min] cmp word [pos_x],ax jg .goodhor1 mov word [pos_x],ax .goodhor1: mov ax,word [x_max] cmp word [pos_x],ax jle .goodhor2 mov word [pos_x],ax .goodhor2: call keyboard_read neg al cbw add word [pos_y],ax mov ax,[y_min] cmp word [pos_y],ax jg .goodver1 mov word [pos_y],ax .goodver1: mov ax,word [y_max] cmp word [pos_y],ax jle no_show mov word [pos_y],ax no_show: mov bl,0aeh call keyboard_cmd mov al,20h out 0a0h,al out 20h,al pop ds pop es pop si pop di pop dx pop cx pop bx pop ax iret get_pos: mov cx,word [pos_x] mov dx,word [pos_y] ret ;------------------------------------------------------------------------ pos_x dw 0 pos_y dw 0 x_max dw 639 x_min dw 0 y_max dw 479 y_min dw 0 keyboard_read: push cx push dx xor cx,cx key_read_loop: in al,64h test al,1 jnz key_read_ready loop key_read_loop mov ah,1 jmp key_read_exit key_read_ready: push cx mov cx,32 key_read_delay: loop key_read_delay pop cx in al,60h xor ah,ah key_read_exit: pop dx pop cx ret keyboard_write: push cx push dx mov dl,al xor cx,cx kbd_wrt_loop1: in al,64h test al,20h jz kbd_wrt_ok1 loop kbd_wrt_loop1 mov ah,1 jmp kbd_wrt_exit kbd_wrt_ok1: in al,60h xor cx,cx kbd_wrt_loop: in al,64h test al,2 jz kbd_wrt_ok loop kbd_wrt_loop mov ah,1 jmp kbd_wrt_exit kbd_wrt_ok: mov al,dl out 60h,al xor cx,cx kbd_wrt_loop3: in al,64h test al,2 jz kbd_wrt_ok3 loop kbd_wrt_loop3 mov ah,1 jmp kbd_wrt_exit kbd_wrt_ok3: mov ah,8 kbd_wrt_loop4: xor cx,cx kbd_wrt_loop5: in al,64h test al,1 jnz kbd_wrt_ok4 loop kbd_wrt_loop5 dec ah jnz kbd_wrt_loop4 kbd_wrt_ok4: xor ah,ah kbd_wrt_exit: pop dx pop cx ret keyboard_cmd: xor cx,cx cmd_wait: in al,64h test al,2 jz cmd_send loop cmd_wait jmp cmd_error cmd_send: mov al,bl out 64h,al xor cx,cx cmd_accept: in al,64h test al,2 jz cmd_ok loop cmd_accept cmd_error: mov ah,1 jmp cmd_exit cmd_ok: xor ah,ah cmd_exit: ret And this is my code changed for run out DOS (when I run it... not run correct) Code: ORG 100h Jmp InstallMouse ; Load the mouse MainCode: ; Use the mouse loaded Mov AX,12h Int 10h MainLoop: ; My Main Loop, show pixel with mouse coordinates Call mouse_code Call get_pos Mov AH,0Ch Mov CX,CX Mov DX,DX Mov AL,15 Int 10h Xor AX,AX Mov AH,11h Int 16h Jnz Exit Jmp MainLoop Exit: ; Exit code Mov AX,3h Int 10h Jmp $ InstallMouse: ; Load mouse in DOS, create one int mov bl,0adh call keyboard_cmd call keyboard_read ; Pac 1 call keyboard_read ; Pac 2 call keyboard_read ; Pac 3 mov bl,0aeh call keyboard_cmd mov al,20h out 0a0h,al out 20h,al ; mov ax,0x2574 ; mov dx,mouse_code ; int 21h cli mov bl,0a8h call keyboard_cmd mov bl,20h call keyboard_cmd call keyboard_read or al,2 mov bl,60h push ax call keyboard_cmd pop ax call keyboard_write mov bl,0d4h call keyboard_cmd mov al,0f4h call keyboard_write Jmp MainCode ; Return to MainCode (mouse loaded, then: use mouse ) mouse_code: ; Mouse codes push ax push bx push cx push dx push di push si push es push ds push cs pop ds mov bl,0adh call keyboard_cmd call keyboard_read ; for first byte call keyboard_read cbw add word [pos_x],ax mov ax,word [x_min] cmp word [pos_x],ax jg .goodhor1 mov word [pos_x],ax .goodhor1: mov ax,word [x_max] cmp word [pos_x],ax jle .goodhor2 mov word [pos_x],ax .goodhor2: call keyboard_read neg al cbw add word [pos_y],ax mov ax,[y_min] cmp word [pos_y],ax jg .goodver1 mov word [pos_y],ax .goodver1: mov ax,word [y_max] cmp word [pos_y],ax jle no_show mov word [pos_y],ax no_show: mov bl,0aeh call keyboard_cmd mov al,20h out 0a0h,al out 20h,al pop ds pop es pop si pop di pop dx pop cx pop bx pop ax ; iret ret get_pos: mov cx,word [pos_x] mov dx,word [pos_y] ret ;------------------------------------------------------------------------ pos_x dw 0 pos_y dw 0 x_max dw 639 x_min dw 0 y_max dw 479 y_min dw 0 keyboard_read: push cx push dx xor cx,cx key_read_loop: in al,64h test al,1 jnz key_read_ready loop key_read_loop mov ah,1 jmp key_read_exit key_read_ready: push cx mov cx,32 key_read_delay: loop key_read_delay pop cx in al,60h xor ah,ah key_read_exit: pop dx pop cx ret keyboard_write: push cx push dx mov dl,al xor cx,cx kbd_wrt_loop1: in al,64h test al,20h jz kbd_wrt_ok1 loop kbd_wrt_loop1 mov ah,1 jmp kbd_wrt_exit kbd_wrt_ok1: in al,60h xor cx,cx kbd_wrt_loop: in al,64h test al,2 jz kbd_wrt_ok loop kbd_wrt_loop mov ah,1 jmp kbd_wrt_exit kbd_wrt_ok: mov al,dl out 60h,al xor cx,cx kbd_wrt_loop3: in al,64h test al,2 jz kbd_wrt_ok3 loop kbd_wrt_loop3 mov ah,1 jmp kbd_wrt_exit kbd_wrt_ok3: mov ah,8 kbd_wrt_loop4: xor cx,cx kbd_wrt_loop5: in al,64h test al,1 jnz kbd_wrt_ok4 loop kbd_wrt_loop5 dec ah jnz kbd_wrt_loop4 kbd_wrt_ok4: xor ah,ah kbd_wrt_exit: pop dx pop cx ret keyboard_cmd: xor cx,cx cmd_wait: in al,64h test al,2 jz cmd_send loop cmd_wait jmp cmd_error cmd_send: mov al,bl out 64h,al xor cx,cx cmd_accept: in al,64h test al,2 jz cmd_ok loop cmd_accept cmd_error: mov ah,1 jmp cmd_exit cmd_ok: xor ah,ah cmd_exit: ret All help for correct the bug is welcome... or reply for why the bug is occurred.... thanks for all... and sorry for my problem... but I have much time in it... and not find one solution... grunge |
|||
05 Mar 2007, 03:02 |
|
DOS386 07 Mar 2007, 17:01
I had a look at your code (did not anlyze the port accesses in detail,
use my hints with care) and tested it. The no-OS version ends up in a hard freezer in text screen mode. Quote: This block code is for my tests when I working in FreeDos. (for not have restart and boot the mouse program all time) Quote: but here's what confused me: It's perfectly possible and useful to test no-OS code in FreeDOS Also INT $21,$4C00 is no problem ... you just have to explain it better Code: Jmp InstallMouse ; Load the mouse MainCode: ; Use the mouse loaded Mov AX,12h Int 10h You probably should swap them: 1. Set video mode 2. Activate mouse Code: Mov CX,CX Mov DX,DX What does this code do ? Code: mov ax,0x2574 mov dx,mouse_code int 21h This is the problem. This must be kicked in the no-OS version, as you found out and commented it out with no replacement Maybe an unhandled IRQ occurs Code: cli Why do you ban interrupts ? Where do you re-allow them ? Seems to be part of the problem as well Quote:
This probably also contributes to the problem. After hacking on IRQ's and ports you maybe should no longer use BIOS INT's either _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
07 Mar 2007, 17:01 |
|
grunge 10 Mar 2007, 21:37
Hi all
I correct the mouse driver... source1 (DOS) Code: mov ax,0x2574 mov dx,mouse_code int 21h NTOSKRNL_VXE Thanks for your help, your helps is correct! I have changed it for create one "Interrupt vector" without DOS, I only changed it... now... mouse runs correct in pure code!!! Thanks for all help... grunge |
|||
10 Mar 2007, 21:37 |
|
Dex4u 11 Mar 2007, 19:44
There has been alot of people with mouse problem in the forum, so i have code a simple demo, of a working mouse driver, that does not use any OS code and is fully self contained.
Here is the fasm code and a bootable program to test it, (Note: it will run from dos, but not a dosbox under windows). http://www.dex4u.com/tuts/MouseDemo.zip I will add comment in the next day or two, but for now, the code is there. PS: The demo is running in MiniDos, if you want the code let me know. |
|||
11 Mar 2007, 19:44 |
|
grunge 12 Mar 2007, 22:57
Hi Dex4u
Good idea... it help very developers... my mouse already runs correct... I use "Set Interrupt Vector" of "MiniDos" (I already the source)... ... this is very util... my code is very small... I think... thanks for you initiative and good work. grunge |
|||
12 Mar 2007, 22:57 |
|
Dex4u 13 Mar 2007, 00:34
@grunge, Thanks for you kind words and good luck with your OS .
|
|||
13 Mar 2007, 00:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.