problem with mouse

Page 1/2
| 2

Par DanySoft

Champion (451)

Portrait de DanySoft

10-10-2011, 21:11

Hey, i'm make to binary, software to use mouse, but can't resolve the area to stop mouse
escape from screen....

I'm use assembler for make mouse (to send DEFUSR =X :A=USR() to use mouse Smile )

I'm use POKE to stop move mouse to left, right, up down ... see this :

if x=< 0 then x=0
if x=>255 then x=255
if y=<0 then y=0
if y=>192 then y=192

But use three mnemonics but not easy:

 JR P, <- max
 JR C, <- min
 JR Z, <- equ

note, the register <JR P,0000 > is mistery : to move the mouse from left (stop ok) to
right, not reaches to 255, fix 80 / 90, to 0. .... why this is bug ????

So, exist olther sources with mouse, but not easy... please , make this the example for
mouse for assembler (SJASM or GEN ) . And try this new to my source to future.
Talk you!
Tongue

!login ou Inscrivez-vous pour poster

Par pitpan

Prophet (3152)

Portrait de pitpan

10-10-2011, 22:09

'Cause you're using 8-bit integers. To make it simple: 0-1=255. That's why it isn't working.

Par DanySoft

Champion (451)

Portrait de DanySoft

10-10-2011, 22:17

???
better explained !!

Or course, make new sources to example:
I'm get

d=PAD(12) : x=x+pad(13):y=y+pad(14)

from BIOS-MSX, and done to move the mouse.
the area 0-255, the register <JR P, 0000> is not corret, but make the
example on new sources . help!

So the make the assembleer, i'm use this in BASIC with mouse. But I Prefet use assembler
to use mouse !!!!

Par pitpan

Prophet (3152)

Portrait de pitpan

10-10-2011, 23:09

An 8-bit unsigned integer is a number between 0 and 255. Therefore:

0-1=255

Or the other way round:

255+1=0

If you need to check if something is bigger than 255 but without an out-of-range problem, switch to 16-bit integers.

Par boblet

Master (187)

Portrait de boblet

10-10-2011, 23:10

if you use poke to store data, the data can never be <0 or >255 because all the integers from 0 to 255 are all that can be stored. And Poke in MSX basic stores only bytes.

if you add 1 to 255 you get 256, this cannot be stored in 1 byte. Therefore, you cannot check the state of a byte which can be a maximum of 255 being >255.

This is known as a boundary error. You overcome it by changing the boundaries or by modifying your algorithm or both, as needed.

There is no JR P, in z80. Please see the z80 instruction set to see what you wish to achieve. I'm not a z80 programmer, many here are.

I've never used the PAD command as I've not had hardware that used it.

If you're using assembly directly I suspect it might be better to read the actual values that the mouse is sending into the system and use these to control a virtual mouse pointer which you then clamp to your appropriate visual range. If everything I've just typed is nonsense, someone will come along and correct it. Smile

And what pitpan said made it simple.

I will now Running Naked in a Field of Flowers

edit: To add

Pitpan has now said the same thing, simpler, twice.

Par DanySoft

Champion (451)

Portrait de DanySoft

10-10-2011, 23:18

Switch to 16bit, please.
But I know very well the variables are from 0 to 256 are bytes!

Please make the example without hardware for mouse (mouse.asm)

The sources Need to add my sources to resolved to 100 % assembler.

Smile

Par DanySoft

Champion (451)

Portrait de DanySoft

10-10-2011, 23:23

Of recent, this assembler is the 90% (sorry), but games or util are stop and half.

This utility of mouse is 100% to correct and make games on MSX! Smile

Par pitpan

Prophet (3152)

Portrait de pitpan

11-10-2011, 00:10

I'm not coding for you, sorry. I just code for fun (and for me, of course). Sad

Par eisbaer23

Supporter (14)

Portrait de eisbaer23

11-10-2011, 07:34

why don't you check for 1 instead of 0 and 254 instead of 255?
oh sure, you'd lose a pixel on borders and strangely your mouse pointer won't be able to actually reach that border, but whatever, who cares.
do you really need that bad to go that far on the borders?

i will now Running Naked in a Field of Flowers too, but with a sweater, because it's FRICKING FREEZING here...

Par Huey

Prophet (2687)

Portrait de Huey

11-10-2011, 14:03

Perhaps this thread will help you: http://www.msx.org/forumtopic10388.html

This routine returns the offset (positive or negative) of the mouse (in relation to the last position). So you can still catch the screen borders yourself without switching to 16 bits.

Par DanySoft

Champion (451)

Portrait de DanySoft

11-10-2011, 20:58

Why? I'm get mouse on msx2 no msx1 if necessary, but the limit to area is not found for mouse ?
limit 0 - 255 for x
limit 0 -192 for y

The only solutions (and wrong solutions but not olther metod) is set mouse to BASIC and limit set is
O.K.

But olther application have use mouse with limit x,y area ! The mouse is necessary for ROM and
modify to graphics and map.

if x is 256 and not 255, then use 16bit as HL, and can't set the condition ?

cp H
or L 
jr  ??? , limit

So use mouse with limit is util, but this http://www.msx.org/forumtopic10388.html
is util for limit for mouse ?
wait ... the new source mouse and limit set !!

;) and you are the friend for msx !! talk you!!

Page 1/2
| 2