flat assembler
Message board for the users of flat assembler.
Index
> DOS > INT 33 mouse demo Goto page 1, 2 Next |
Author |
|
rCX 02 May 2009, 05:15
Hey, this is almost exactly what first asm program did.
Code:
int 0x20
ret
Last edited by rCX on 02 May 2009, 05:27; edited 2 times in total |
|||
02 May 2009, 05:15 |
|
bitshifter 02 May 2009, 05:23
Sweet, now if only the next 32 bytes can be shaved just as easily...
_________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
02 May 2009, 05:23 |
|
rCX 02 May 2009, 05:28
If you are on a 386 or above this...
Code: push cx push dx ...can be replaced with "pusha" and this... Code: pop dx pop cx ... can be replaced with "popa" to trim off 2 more bytes. |
|||
02 May 2009, 05:28 |
|
bitshifter 02 May 2009, 05:32
Wow, 4 bytes in under 4 minutes...
Do you have another 28 minutes? _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
02 May 2009, 05:32 |
|
rCX 02 May 2009, 05:39
Hmm. I guess i'm out of any good ideas for now
|
|||
02 May 2009, 05:39 |
|
bitshifter 02 May 2009, 05:48
Thanks for the help, you have been great.
(I cant expect to learn everything from one place, right...) _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
02 May 2009, 05:48 |
|
revolution 02 May 2009, 06:43
Well if you are serious about saving bytes then you have to be brutal:
Code: ... int 0x20 ; ret <--- not needed ; These might be zero upon startup to ensure the pixel ; index is at top left and its color is set to black. ; otherwise we get a random pixel somewhere with a random colour oldposx dw ? ;uninitialised random junk oldposy dw ? ;uninitialised random junk oldcolor db ? ;uninitialised random junk |
|||
02 May 2009, 06:43 |
|
bitshifter 02 May 2009, 09:16
Quote: Well if you are serious about saving bytes then you have to be brutal: I think to shave this many bytes off it will have to be real dirty. Maybe i leave it like it is and work on something a bit more usefull. I just have a goal to try and use all of the bios interrupts in one way or another. _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
02 May 2009, 09:16 |
|
revolution 02 May 2009, 09:32
bitshifter wrote: So does this mean the general flow of the program is pretty good? |
|||
02 May 2009, 09:32 |
|
rugxulo 02 May 2009, 10:25
1). Don't remove the final "ret", remove the "int 0x20", saves two bytes instead of one!
|
|||
02 May 2009, 10:25 |
|
LocoDelAssembly 02 May 2009, 15:52
Untested, not flexible and probably changes behavior a bit too:
Code: mloop: ; get mouse state mov ax,0x0003 int 0x33 shr cx,0x01 ; adjust for mode 0x0013 and bl, 0x03 jz update not bl and bl, 0x02 mov [oldcolor], bl update: |
|||
02 May 2009, 15:52 |
|
bitshifter 03 May 2009, 01:28
So to increase the mouse resolution i would have
to cheat by connecting the two points into a line? _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
03 May 2009, 01:28 |
|
Dex4u 03 May 2009, 19:58
Just for fun this is a DexOS ver
Code: use32 org 400000h jmp start db 'DEX2' start: ; setup call-table mov edi,Functions mov al,0 mov ah,0x0a int 40h ; setup mouse call [ResetMouse] ; setup min-max XY xor eax,eax mov edx,eax mov ax,319 mov dx,199 call [SetMouseMaxMinXY] ; set graphics video mode mov ax,0x0013 call [RealModeInt10h] mloop: ; get mouse state call [GetMousePos] test BL,00000100b ;left jnz lbdown ; 00000010b = center test BL,00000001b ;right jnz rbdown jmp update lbdown: mov [oldcolor],0x02 ; set color under mouse to green jmp update rbdown: mov [oldcolor],0x00 ; set color under mouse to black update: ; set pixel at old mouse position push dx push cx mov cx,[oldposx] mov dx,[oldposy] call PutPix mov al,[oldcolor] ;Note: fs the only zero based deseptor in DexOS. mov byte[fs:edi],al pop cx pop dx ; save current mouse position mov [oldposx],cx mov [oldposy],dx ; save pixel at current mouse position call PutPix mov al, byte[fs:edi] mov [oldcolor],al mov byte[fs:edi],0x0f ; check for keypress call [KeyPressedNoWait] cmp al,0 je mloop ; set text video mode call [SetDex4uFonts] ret ;----------------------------------------------------; ; PutPix ; ;----------------------------------------------------; PutPix: shl ecx,16 shr ecx,16 mov edi,0xa0000 ;ScreenBuff mov bx,dx shl bx,8 shl dx,6 add bx,dx add cx,bx add edi,ecx ret ; These must be zero upon startup to ensure the pixel ; index is at top left and its color is set to black. oldcolor db 0x00 oldposx dw 0x00 oldposy dw 0x00 include "dex.inc" I have made no attempt to optimizing the code, just convert. |
|||
03 May 2009, 19:58 |
|
Coddy41 04 May 2009, 20:36
@bitshifter: Awesome! I was wondering how to make a mouse work, also I like
how you made the right and left clicks handle @Dex: what version of the assembler do you use, all of the DexOS apps I try to compile and they never come out right yes I included dex.inc _________________ Want hosting for free for your asm project? You can PM me. (*.fasm4u.net) |
|||
04 May 2009, 20:36 |
|
Dex4u 04 May 2009, 22:04
Coddy41 wrote:
That's too broad a statement for me to help you, If for example you take the above code, make sure the Dex.inc is in the same dir Then in window (you are using window ? ) Type in a command box C:\fasm mouse.asm mouse.dex <enter> Then put the file on a DexOS floppy and run the file from the cli by typing mouse <enter> Where is it you are having a problem ? PS: I keep seing start1: in the header of your examples, that should not be there. |
|||
04 May 2009, 22:04 |
|
DOS386 05 May 2009, 12:31
> learned how to use mouse through bios.
NO you didn't. > ------------------------------------------------ > ; bios driven mouse demo by bitshifter > ;------------------------------------------------ > use16 > org 0x100 > ; return to operating system > int 0x20 > ret Does it boot into your PC ? Looks like a DOS COM executable > ; setup mouse > xor ax,ax > int 0x33 Here you talk to a mouse driver , NOT to the BIOS |
|||
05 May 2009, 12:31 |
|
bitshifter 05 May 2009, 13:02
Hey DOS386, your right about that.
(Stupid me thought it was bios int) I change name to 'INT 33 mouse demo' _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
05 May 2009, 13:02 |
|
Coddy41 05 May 2009, 13:27
So it doesn't use bios? will this work without windows?
|
|||
05 May 2009, 13:27 |
|
Dex4u 05 May 2009, 17:00
Not unless you load a dos mouse driver.
|
|||
05 May 2009, 17:00 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.