Mail Archives: djgpp/1998/07/15/17:01:04
From: | "John Owens" <assembly AT swbell DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | I need help to convert my old inline asm to djgpp inline asm.
|
Date: | Wed, 15 Jul 1998 15:51:14 -0500
|
Organization: | Southwestern Bell Internet Services, Richardson, TX
|
Lines: | 47
|
Message-ID: | <6oj4vt$420$1@nnrp3>
|
NNTP-Posting-Host: | ppp-207-193-22-59.stlsmo.swbell.net
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I'am making my own 2d game kit and I need help to convert my inline asm
over.. here is the code I need to be convert over.
unsigned int Joystick(unsigned char stick)
{
// reads the joystick values manually by conting how long the capacitors
take
// to charge/discharge
// let's use the inline assembler. It's Cool!
__asm
{
cli ; disable interupts
mov ah, byte ptr stick ; get mask into ah to selct joystick to read
xor al,al ; zero out al, xor is a trick
xor cx,cx ; same with cx which we will use as a counter
mov dx,JOYPORT ; dx is used by inp and outp
out dx,al ; write 0's to the port
discharge:
in al,dx ; read the data back from port
test al,ah ; has the bit in question changed?
loopne discharge ; if the stick isn't ready then --cx and loop
sti ; re-enable interrupts
xor ax,ax ; zero out ax
sub ax,cx ; ax now holds the position of the axis switch
} // end asm
// since ax has the result the function will return it properly
} // end Joystick
i just been with djgpp for 3 days now.. Trying to convert my inline asm
codes over..
PS I'am not using allegro.. I'am making my own 2d game kit..
Thanks..
assembly AT swbell DOT net
- Raw text -