|
Post by gamer on Jul 19, 2014 7:31:23 GMT -8
Hi,
Can someone please explain how the functions GD.wr() and GD.rd() work, specifically relating to reading the TAG at a given position. Referring to the frogger demo, in lines 218, 219, GD.wr(REG_TAG_X, frogx-8); GD.wr(REG_TAG_Y, frogy);
and then in line 370, byte tag = GD.rd(REG_TAG);
I see that GD.get_inputs() is being called just before the rd() call. Why is this so?
|
|
bubu
Junior Member
Posts: 17
|
Post by bubu on Jul 21, 2014 11:28:31 GMT -8
I tested this code some weeks ago myself and this is what I figured out:
GD.wr writes to Registers and GD.rd reads it.
First, the two GD.wr commands write coordinate values of the frog into corresponding registers for x and y. Then GD.get_inputs - among other Tasks - proceses these registers and fills register REG_TAG with the value of the tag on that position(if there is any). Without get_inputs there would be no Change to REG_TAG no matter what values you write to REG_TAG_X / REG_TAG_Y. Byte tag=GD.rd(REG_TAG) then stores the value of the TAG in a variable which can be adressed by further commands.
So, if there is a car (drawn with a specific tag value) on coordinates frogx-8 and frogy, tag will have it´s tag value.
A simple "one pixel collision Routine".
|
|