sp1 - where is stored the graphic pointer

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
fraespre
Member
Posts: 56
Joined: Mon Aug 19, 2019 8:08 pm

sp1 - where is stored the graphic pointer

Post by fraespre »

Hi folks,

I'm searching into the sp1_ss and sp1_cs where is stored the graphic pointer, but I can't find it.
*sp1_CreateSpr_callee(void *drawf, uchar type, uchar height, int graphic, uchar plane)

At first, I suspited would be in sp1_ss:
sp1_ss->frame // No, this is the frame address added
sp1_ss->e_offset // May be, effective offset to add to graphic pointers
...

And afer, I followed the track to the first sp1_cs:
sp1_ss->first->def // May be, graphic definition pointer
sp1_ss->first->l_def // May be, graphic definition pointer for sprite character to left of this one

Well, I've checked all this, but none of them has the address, which I input in the createSpr.

Could you help me with this issue?


References:
https://github.com/z88dk/z88dk/blob/mas ... trum-sp1.h
https://github.com/z88dk/z88dk/blob/mas ... callee.asm
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

Post by derekfountain »

There are two ways to use the sp1_CreateSpr() function, and they use that graphic value differently. The first, simple way is discussed in the getting started guide here:

https://github.com/z88dk/z88dk/blob/mas ... rites-code

The second approach is covered here:

https://github.com/z88dk/z88dk/blob/mas ... -animation

Which approach are you using?
fraespre
Member
Posts: 56
Joined: Mon Aug 19, 2019 8:08 pm

Post by fraespre »

Hi derekfountain,

For now, I don't see where you want to go. Anyway I respond you.
This is the code of my approach:

Code: Select all

  sprRat= sp1_CreateSpr(                SP1_DRAW_MASK2LB, SP1_TYPE_2BYTE, 5, (uint16_t)sprRat_adr+RAT_BLANK+RAT_COLOFF(0), 0);
                  sp1_AddColSpr(sprRat, SP1_DRAW_MASK2,   SP1_TYPE_2BYTE,    (uint16_t)sprRat_adr+RAT_BLANK+RAT_COLOFF(1), 0);
                  sp1_AddColSpr(sprRat, SP1_DRAW_MASK2,   SP1_TYPE_2BYTE,    (uint16_t)sprRat_adr+RAT_BLANK+RAT_COLOFF(2), 0);
                  sp1_AddColSpr(sprRat, SP1_DRAW_MASK2RB, SP1_TYPE_2BYTE, 0, 0);
Of course it's a sprite with mask and 4 rows per 3 columns. I think it could fit with the 2 links that you mention.
The sprite works perfectly !!!

I want to know in which memory struct of the sp1 is stored the absolute address that I inputed in the sprite creation. Where does sp1 store this memory address "sprRat_adr+RAT_BLANK+RAT_COLOFF(0)" in form of 2bytes number ?

Best regards,
fraespre
Member
Posts: 56
Joined: Mon Aug 19, 2019 8:08 pm

Post by fraespre »

Sorry , now I see the difference:

In the first approach you put the absolute address at the beginning. And in the sp1_MoveSprPix op you say the frame offset. This is my approach.

In the second you initialize to 0 and in the sp1_MoveSprPix op you put the final address directly. I haven't probe this option.

Is it correct?
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

Post by derekfountain »

Yes, your understanding of the two approaches is correct. :)

I have to be honest and say I've not done anything with SP1 for about a year, so understanding how values are stored in the data structures is beyond me these days. Hopefully you can find what you need now you understand a bit better.
fraespre
Member
Posts: 56
Joined: Mon Aug 19, 2019 8:08 pm

Post by fraespre »

jajajajaja ok Derek, this isn't the answer I expected.

However, the second approach that you forced me to review ... has gave some new ideas to solve the issue I have.

Thank you.
Post Reply