How To

Maybe a Bug, Probably my Mistake

1

TheLivingBlooper 2020-06-13 19:20 (Edited)

I'm working on a project where I use POKEL for changing character data, and noticed some kind of strange behavior with the second-to-last bit in binary:

'         THIS BIT
'             V
POKEL $8002,%01000000010000000100000001000000
'            \______________________________/
'                            V
'                       32 BITS LONG

I'm pretty sure that the code above should draw a vertical line that is 4 pixels long and has an offset of (1, 2) in character 0, from the top left. Instead, it draws a line that is only three pixels long and is shifted downwards by 1 pixel. Both POKE and POKEW don't have this problem (I realize this doesn't seem like much, but I really need to be able to use that pixel). The pixels to it's left and right also both don't have this problem, which is really weird. I'm not sure why. If anyone knows, that'd be very helpful.

Strange Bit.nx | Open in app
2020-06-13 19:20

TheLivingBlooper 2020-06-13 19:26 (Edited)

You really only need the program for its screenshot. I didn't see a way to just attach images. Sorry. 🙃

I also forgot to mention that when the pixels to the left or right of the weird pixel are 1, the weird one works too (like 11000000010000000100000001000000, for the left).


Timo 2020-06-13 21:00

There is a problem I didn’t think about when adding POKEL: Numbers in LowRes NX are floats, which aren’t able to store 32 bit integers lossless.


TheLivingBlooper 2020-06-13 21:03

Should I use POKEW twice instead?


UxoZii 2020-06-13 21:17

Thats interesting, i was playing with this and i just fixed it using:

POKEL $8002,%010000000100000001000000
POKEL $8005,%01000000


TheLivingBlooper 2020-06-13 22:10

That's cool. I guess it's because $8005 overrides itself in the previous line?


TheLivingBlooper 2020-06-13 22:18

So that I don't have to start another discussion, I also found what I think is a bug in the gamepad for keyboard. It seems like left and down can't be true at the same time and up and right can't either. I don't mean to make too much of a mess!..


GAMELEGEND 2020-06-14 01:59

that's weird I have never had that problem with the gamepad and I have seen tons of programs that dont have that problem either

could you copy and paste some code


TheLivingBlooper 2020-06-14 02:31 (Edited)

Sure. I think it's just keyboards, and it may be me, but the code is simple enough:

GAMEPAD 1

'INITIAL SPRITE
SPRITE 0,76,60,1

DO
  'X VECTOR
  IF LEFT(0) THEN
    SPRITE 0,SPRITE.X(0)-1,,
  ELSE IF RIGHT(0) THEN
    SPRITE 0,SPRITE.X(0)+1,,
  END IF

  'Y VECTOR
  IF UP(0) THEN
    SPRITE 0,,SPRITE.Y(0)-1,
  ELSE IF DOWN(0) THEN
    SPRITE 0,,SPRITE.Y(0)+1,
  END IF

  WAIT VBL
LOOP


GAMELEGEND 2020-06-14 02:43 (Edited)

short answer:
its because you are using else if
you should have 4 separate if statements

I would give you the long answer about why it doesn't work but I'm not to good at explaining long answers


TheLivingBlooper 2020-06-14 03:12 (Edited)

Still not working. I tried:

GAMEPAD 1

'INITIAL SPRITE
SPRITE 0,76,60,1

DO
  'X VECTOR
  IF LEFT(0) THEN
    SPRITE 0,SPRITE.X(0)-1,,
  END IF
  IF RIGHT(0) THEN
    SPRITE 0,SPRITE.X(0)+1,,
  END IF

  'Y VECTOR
  IF UP(0) THEN
    SPRITE 0,,SPRITE.Y(0)-1,
  END IF
  IF DOWN(0) THEN
    SPRITE 0,,SPRITE.Y(0)+1,
  END IF

  WAIT VBL
LOOP


TheLivingBlooper 2020-06-14 03:15

I don't think the ELSE effects anything as far as the X and Y vectors' interaction goes, but again, I don't know.


GAMELEGEND 2020-06-14 03:16 (Edited)

this is how i do it

GAMEPAD 1

X = 60
Y = 60

SPRITE 0,X,Y,1

DO
CALL MOVE
WAIT VBL
LOOP

SUB MOVE
IF UP(0) THEN
DEC Y
END IF

IF DOWN(0) THEN
INC Y
END IF

IF RIGHT(0) THEN
INC X
END IF

IF LEFT(0) THEN
DEC X
END IF

SPRITE 0,X,Y,1

END SUB

this works every time


TheLivingBlooper 2020-06-14 03:22

Still has the same issue on keyboard. It seems to work on my phone, though.


GAMELEGEND 2020-06-14 03:25 (Edited)

my best guess is its just your keyboard acting up


TheLivingBlooper 2020-06-14 03:36

Mac keyboard, maybe? I may just be my exact keyboard...


GAMELEGEND 2020-06-14 03:41 (Edited)

can your keyboard take mulitple inputs at once


TheLivingBlooper 2020-06-14 03:43

Yes.


TheLivingBlooper 2020-06-14 03:45

Tbh, it could be the keyboard acting up. That'd make the most sense


GAMELEGEND 2020-06-14 03:45

yeah im goin with that one too


Log in to reply.