I can't get cpct_drawSpriteBlended to work. All I get is a garbled mess as in the image.
Also, having the parameters in a different order to the rest of the sprite commands is confusing. Can I suggest having them all in the same order?
To change the parameter order to "norm" (void* *sprite*, void* *memory*, <u8> *width*, <u8> *height*) this could help:
change part of "cpct_drawSpriteBlended_cbindings.s"
to
_cpct_drawSpriteBlended::
;; GET Parameters from the stack
pop hl ;; [3] HL = Return Address
pop bc ;; [3] BC = Height/Width (C = Width, B = Height)
ld a,c ;; change b/c
ld c,b
ld b,a
pop de ;; [3] DE = Destination address (Video memory location)
ex (sp), hl ;; [6] HL = Source Address (Sprite data array)
;; ... And put returning address in the stack again
;; as this function uses __z88dk_callee convention
.include /cpct_drawSpriteBlended.asm/
@EgoTrip (http://www.cpcwiki.eu/forum/index.php?action=profile;u=337) : Can you show me the code you are using? I cannot imagine what's happenning to you without having a deeper look at it :) .
Order of parameters is always selected to improve performance of the function. That's the reason why some of them are in different orders: it depends on implementation.
However, there is an easy way to change parameter order of any function: you may define a custom macro. For instance, to change parameter order of cpct_drawSpriteBlended (https://github.com/lronaldo/cpctelera/blob/master/cpctelera/src/sprites/cpct_drawSpriteBlended.asm) you may do this:
// Change parameter order of cpct_drawSpriteBlended(memory, height, width, sprite)
#define drawSpBlended(S,M,H,W) cpct_drawSpriteBlended( (M), (H), (W), (S) )
//.... After some code, we use our macro ...
drawSpBlended(mySprite, CPCT_VMEM_START, SP_WIDTH, SP_HEIGHT);
That should do the trick for you, without losing bytes/time and without having to compile CPCtelera (https://lronaldo.github.io/cpctelera) again.
Makros :) - never think of them if I can recode something :D
the code is literally this:
pvideomem = cpct_getScreenPtr((u8*)0xC000, 48, 128);
cpct_drawSpriteBlended(pvideomem,4,16,frame);
where frame is the sprite pointer.
I gave up on it and used masked sprites in the end. I am sticking with masked sprites for this game now anyway as I have put in backgrounds and its easier to just redraw them than XOR and have messed up colours.
Is your sprite 8-mode-0-pixels or 16-mode-1-pixels wide?
SideNote: In the present version of CPCtelera (http://lronaldo.github.io/cpctelera), there is a macro called cpctm_screenPtr that works similar to cpct_getScreenPtr but is advisable for constant values. Constant values yield always same result, so calling cpct_getScreenPtr for them wastes time on calculating the resulting value. cpctm_screenPtr does this calculation during compile time, and your final binary only gets the final constant value, saving you CPU time.
16 mode 1
Does your sprite have interlaced mask or not?
Quote from: ronaldo on 21:22, 14 April 16
Does your sprite have interlaced mask or not?
No not that one, its just a standard sprite.
Ok then. Can you attach me your project including the sprite to check what happens?
I just do it in a new project. Just that code, and this sprite:
const u8 G_S07_Jewel[64] = {
0xF0, 0xF0, 0xF0, 0xF0,
0xE0, 0xA0, 0xA0, 0xB0,
0xC0, 0x00, 0x00, 0x10,
0x91, 0xFF, 0xFF, 0x10,
0xB2, 0xF0, 0xF0, 0x98,
0xE4, 0x77, 0xDE, 0xD4,
0xC8, 0x77, 0xCF, 0xF2,
0xC8, 0x77, 0xCF, 0x7A,
0xFB, 0x8F, 0x0C, 0x72,
0xF5, 0x8F, 0x0C, 0xE4,
0x32, 0xCF, 0x18, 0x88,
0x11, 0xC7, 0x39, 0x80,
0x30, 0xEB, 0x62, 0x00,
0x40, 0x65, 0xC4, 0x20,
0x00, 0x32, 0xC8, 0x00,
0xA0, 0xF1, 0xE0, 0xA0};
Oh, man, blimey! Height and width were inverted and none of use did notice :picard:
// Draw the sprite to screen with blending
cpct_drawSpriteBlended(p, height, width, sprite);
So, your code should be,
cpct_drawSpriteBlended(pvideomem, 16, 4, frame);
I clearly agree with you, parameters are confusing. For next version I'll think about including macros with a standard order by default.
I recommend you to include and use this macro in your code
// Change parameter order of cpct_drawSpriteBlended(memory, height, width, sprite)
#define drawSpBlended(S,M,H,W) cpct_drawSpriteBlended( (M), (H), (W), (S) )
Thanks