Proper Player Movement

Page 2/2
1 |

By Metalion

Paragon (1456)

Metalion's picture

14-09-2021, 20:17

And how are we supposed to know that you come here, on an MSX forum (of all places), to ask questions about programming for another system ? Read again your first post, nothing says that anywhere ...

Chilly Willy wrote:

Every time I get into these back and forth I end up offending the same type of cancel dogs when what should of happened is if you don't know then do not say anything.

I don't even know what a "cancel dog" is, but I suppose this is not a positive thing...
Telling people to shut up when you "think" they cannot help you is not a good thing either.

Anyway, I don't want to add anything to any bonfire, let's end this thing right here.
And I can assure you, I really don't know who ChibiAkumas is.

Have a good evening, sir.

By Chilly Willy

Expert (66)

Chilly Willy's picture

14-09-2021, 21:20

Thank you once again but other than that in and out function what does it matter.
Code is Code...It either works or it does not.
I was asking help with a routine, I did not ask for BIOS calls.

But again, thank you for your help because this is not going anywhere other than arguing.
I am pretty sure that the wonderful people on this message board have other things to do.

Again, I apologize but at the same time for some reason you can not edit or delete old posts where I would have reworded whatever offends which seems to be anything these days.

I would rather get on to making great games that can work on any nostalgia system and sharing with my friends instead of hanging out in the negative.

By Timmy

Master (177)

Timmy's picture

15-09-2021, 00:06

The problem is that your problem is a really hard one.

Processing and Applying, Diagonal movement and Shooting, is a Really Hard Subject for You. It's probably a subject you will take (about 3) weeks to grasp and understand, and it would also take people this long to explain it to you. There is no shortcut to make you understand this faster. The fact that you want an "universal routine" will make it about another 2 weeks longer.

I'm sorry that I can't help you with this, since I don't have 3+ weeks of free time. Neither does Akuma. (Then again, I write really slow and this post already took half an hour.)

And it's not strange or wrong to ask these questions. I see people asking this kind of questions on the Spectrum forums too, there's always someone asking about how to get a software sprite routine, or how to have a colour fill routine, or how to finish the RPG game for them, or how to compress everything down to 15 bytes. And if possible, a solution that fits my problem perfectly. And preferably delivered yesterday. These are all legitimate and really good questions.

By Grauw

Ascended (10321)

Grauw's picture

15-09-2021, 01:16

I don’t really get the question, so I’m guessing my answer…

If you want to decompose the bits into a direction vector, you can do something like:

; a = Controller input with bits 0-3 indicating up, down, left, right (0 = pressed)
; d <- y (signed 2’s complement)
; e <- x (signed 2’s complement)
    ld de,0
    bit 0,a
    jr nz,Down
    dec d
    bit 1,a
    jr nz,Left
    inc d
    bit 2,a
    jr nz,Right
    dec e
    bit 3,a
    jr nz,Done
    inc e

You can then add this vector to coordinates as needed:

    ld a,(lastJoystickInput)
    call ControllerInputToDirectionVector
    ld a,(ix + Player.y)
    add a,d
    ld (ix + Player.y),a
    ld a,(ix + Player.x)
    add a,e
    ld (ix + Player.x),a

Multiply (shift) to increase speed, add to another vector to combine velocities, store as bullet velocity when fire button is pressed and add that to bullet position every frame until it hits something, etc.

Of course the example above is not for efficiency but for understandability. The fastest way is to get the vector is probably to use a small 16-word LUT. Also useful if you want to hardcode a different velocity, or add something other than a motion vector, e.g. I have an animation number in there as well.

If this does not address your question then please restate it more clearly.

p.s. What are ports $C0 and $FC? That’s not MSX…

By gdx

Enlighted (5026)

gdx's picture

15-09-2021, 02:47

theNestruo wrote:

BIOS is standard... and will work on any MSX.

As long as you use the jump table.

Chilly Willy wrote:

I was very specific on the format because it will be UNIVERSAL code and not specific to the MSX.

This does not prevent it from being "universal". Just do a similar routine for the other machines.

Here is a routine to read a joystick by direct access:

	ld	a,15
;	di
	out	(0A0h),a
	in	a,(0A2h)	; Read register 15
	and	08Fh		; and 10001111 for joystick 1 (This line must be removed when joystick 2)
;	or	040h		; or 01000000 for joystick 2 (This line must be removed when joystick 1)
	out	(0A1h),a

	ld	a,14
	out	(0A0h),a
;	ei
	in	a,(0A2h)

By Chilly Willy

Expert (66)

Chilly Willy's picture

19-09-2021, 03:33

Thank you everyone for your input, great ideas.

What I ultimately had done is delegate my routines as in one for input, one for animation of all actors.

I used a table in IY that has who, y, x, pattern, color, active state.
So when y and x are changed by the input I can check which direction with y and x.
If y is only changing then it would be north or south, x for east and west.

now if y and x changed then it will be any of the other 4 diagonal directions.

Now pass a value from 1 to 8 which will give the direction for animation.

Yes it sounds convoluted and I will hone it however it has saved me a ton of extra space because now I don't have to create subroutines for the 4 diagonal directions on top of offset check for the diagonal collisions.
Not only that, because I delegated routines I have increased speed and there are no pauses waiting for animation routines to cause.

I will post the code for all to follow when I am done.

Page 2/2
1 |