Tile Directly Under sprite

Por Chilly Willy

Expert (108)

imagem de Chilly Willy

04-02-2023, 07:09

This leads into my previous question about the C++ compiler.

As part of a...Basic GUI.
I have a mouse pointer moving around but where can I find an example code of what tile is directly under the sprite.

Earlier posts I was shown this formula.

; In: HL = XY
; Out: HL = Pointer to buffer
LD A, L
RRA
RRA
RRA
RRA
RR H
RRA
RR H
RRA
RR H
LD L, H
AND 3
ADD A, VRAM_NAME/256
LD H, A

CALL SETRD

XOR A
OUT (DATA_PORT), A

Which will take the Y/X coordinates of the sprite and give the tile underneath.

If I could be shown the formula which goes in the opposite direction.

I would like to put a sprite in an area of the screen, press a key which would place whatever value at that location.
So if I load a, with 'P' and press enter the value of 'P' will be entered into that vram address.

I would have thought that same formula would have resulted in the proper address except an in, you use an out.

Like LD A, 'P'
OUT (DATA_PORT), A
But it seems to go to the address to the right of where I need it.
My offsets are correct but, just not working out the way I planed.

Entrar ou registrar-se para comentar

Por Grauw

Ascended (10821)

imagem de Grauw

04-02-2023, 11:42

Besides changing the IN to OUT, did you also change SETRD to SETWRT?

Por Chilly Willy

Expert (108)

imagem de Chilly Willy

04-02-2023, 17:33

Grauw wrote:

Besides changing the IN to OUT, did you also change SETRD to SETWRT?

Maybe I should change it to write, I will try that common sense thing and let you know.

EDIT.....
That was the issue.

My only excuse is that when you stare at the screen for 14 hours and take a nyquil tab you miss the little things.