Skip to content

Commit b8c9084

Browse files
committed
bflibrary: Work continues on the sprite drawing test
1 parent 7cafec2 commit b8c9084

4 files changed

Lines changed: 44 additions & 13 deletions

File tree

bflibrary/src/general/gspr_enc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int LbScreenSpriteEncode(TbSprite *p_spr, TbSpriteData p_spr_data)
116116
p_spr->SWidth = lbDisplay.GraphicsWindowWidth;
117117
p_spr->SHeight = lbDisplay.GraphicsWindowHeight;
118118
assert(p_spr->SWidth == lbDisplay.GraphicsWindowWidth);
119-
assert(p_spr->SHeight = lbDisplay.GraphicsWindowHeight);
119+
assert(p_spr->SHeight == lbDisplay.GraphicsWindowHeight);
120120
p_spr->Data = p_spr_data;
121121

122122
return LbSpriteEncode(lbDisplay.GraphicsWindowPtr, lbDisplay.GraphicsScreenWidth, transcol, p_spr);

bflibrary/tests/bflib_test_sprdrw.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "bfpalcrss.h"
3131
#include "bffile.h"
3232
#include "bfpng.h"
33+
#include "bfscrcopy.h"
3334
#include "bfgentab.h"
3435
#include "bfutility.h"
3536
#include "bftstlog.h"
@@ -52,10 +53,12 @@ TbBool test_spritedraw(void)
5253
TbPixel unaffected_colours[] = {0,};
5354
TbScreenModeInfo *mdinfo;
5455
TbScreenMode mode;
55-
ubyte *texmap;
56+
ubyte *p_sprdata;
57+
TbSprite *p_sprlist;
5658
TbPixel *ref_buffer;
5759
ulong picno;
5860
int sprfile_no = 1;
61+
int tot_sprites;
5962
int len;
6063

6164
if (LbErrorLogSetup(NULL, "tst_sprdrw.log", Lb_ERROR_LOG_NEW) != Lb_SUCCESS) {
@@ -102,7 +105,16 @@ TbBool test_spritedraw(void)
102105
free(ref_buffer);
103106
}
104107

105-
//len = generate_example_sprites_from_screen(sprfile_no, pal, ubyte *p_dat, TbSprite *p_tab);
108+
tot_sprites = get_example_sprites_total_count(sprfile_no);
109+
len = (tot_sprites+1) * 8192;
110+
p_sprdata = LbMemoryAlloc(len);
111+
LbMemorySet(p_sprdata, 0, len);
112+
113+
len = (tot_sprites+1) * sizeof(TbSprite);
114+
p_sprlist = (TbSprite *)LbMemoryAlloc(len);
115+
LbMemorySet(p_sprlist, 0, len);
116+
117+
len = generate_example_sprites_from_screen(sprfile_no, pal, p_sprdata, p_sprlist);
106118

107119
MockScreenUnlock();
108120
MockScreenReset();
@@ -116,9 +128,6 @@ TbBool test_spritedraw(void)
116128

117129
MockScreenLock();
118130

119-
texmap = LbMemoryAlloc(256*256*1);
120-
LbMemorySet(texmap, 0, 256*256*1);
121-
122131
ref_buffer = malloc(mdinfo->Width * mdinfo->Height * (lbEngineBPP+7) / 8);
123132
if (ref_buffer == NULL) {
124133
LOGERR("reference screen buffer alloc failed");
@@ -134,6 +143,8 @@ TbBool test_spritedraw(void)
134143

135144
LbScreenClear(0);
136145
lbSeed = seeds[picno];
146+
147+
LbSpriteDraw(88, 88, &p_sprlist[0]);
137148
#if 0
138149
test_sprite_draw_random_sprites(pal, mdinfo->Height);
139150

@@ -161,7 +172,7 @@ TbBool test_spritedraw(void)
161172
#endif
162173
}
163174

164-
LbMemoryFree(texmap);
175+
LbMemoryFree(p_sprdata);
165176
free(ref_buffer);
166177

167178
MockScreenUnlock();

bflibrary/tests/helpers_sprite.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,38 +69,57 @@ TbScreenMode get_example_sprites_screen_mode(int sprfile_no)
6969
return LbRegisterVideoMode(locstr, img_width, img_height, img_bpp, flags);
7070
}
7171

72-
void generate_example_sprites_from_screen(int sprfile_no, const ubyte *pal,
72+
int get_example_sprites_total_count(int sprfile_no)
73+
{
74+
int tot_sprites;
75+
76+
switch (sprfile_no)
77+
{
78+
case 1:
79+
tot_sprites = sizeof(sprites1_list)/sizeof(sprites1_list[0]);
80+
break;
81+
default:
82+
tot_sprites = 0;
83+
break;
84+
}
85+
86+
return tot_sprites;
87+
}
88+
89+
int generate_example_sprites_from_screen(int sprfile_no, const ubyte *pal,
7390
ubyte *p_dat, TbSprite *p_tab)
7491
{
7592
TbSprite *p_spr;
93+
ubyte *p_sprdt;
7694
struct TbAnyWindow *p_wnd;
7795
int tot_sprites, i;
7896

7997
switch (sprfile_no)
8098
{
8199
case 1:
82-
tot_sprites = sizeof(sprites1_list)/sizeof(sprites1_list[0]);
83100
p_wnd = &sprites1_list[0];
84101
break;
85102
default:
86-
tot_sprites = 0;
87103
p_wnd = NULL;
88104
break;
89105
}
106+
tot_sprites = get_example_sprites_total_count(sprfile_no);
90107

91108
// Convert each area into a sprite
92109
p_spr = p_tab;
110+
p_sprdt = p_dat;
93111
for (i = 0; i < tot_sprites; i++)
94112
{
95113
int len;
96114

97115
LbScreenSetGraphicsWindow(p_wnd->x, p_wnd->y, p_wnd->width, p_wnd->height);
98-
len = LbScreenSpriteEncode(p_spr, p_dat);
99-
p_dat += len;
116+
len = LbScreenSpriteEncode(p_spr, p_sprdt);
117+
p_sprdt += len;
100118
p_spr++;
101119
p_wnd++;
102120
}
103121

122+
return p_sprdt - p_dat;
104123
}
105124

106125
void palette_remap_to_screen(TbPixel *p_remap, const TbPixel *p_altpal)

bflibrary/tests/helpers_sprite.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ extern "C" {
3030

3131
void get_example_sprites_file_name(int sprfile_no, char *fname);
3232
TbScreenMode get_example_sprites_screen_mode(int sprfile_no);
33+
int get_example_sprites_total_count(int sprfile_no);
3334
void palette_remap_to_screen(TbPixel *p_remap, const TbPixel *p_altpal);
3435

35-
void generate_example_sprites_from_screen(int sprfile_no, const ubyte *pal,
36+
int generate_example_sprites_from_screen(int sprfile_no, const ubyte *pal,
3637
ubyte *p_dat, TbSprite *p_tab);
3738

3839
#ifdef __cplusplus

0 commit comments

Comments
 (0)