mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
Fire: Use LibC srand()
This commit is contained in:
parent
23ec578a01
commit
c4d3723087
1 changed files with 2 additions and 18 deletions
|
@ -70,22 +70,6 @@ static const Color s_palette[] = {
|
||||||
Color(0xCF, 0xCF, 0x6F), Color(0xEF, 0xEF, 0xC7), Color(0xFF, 0xFF, 0xFF)
|
Color(0xCF, 0xCF, 0x6F), Color(0xEF, 0xEF, 0xC7), Color(0xFF, 0xFF, 0xFF)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Random functions...
|
|
||||||
* These are from musl libc's prng/rand.c
|
|
||||||
*/
|
|
||||||
static uint64_t seed;
|
|
||||||
|
|
||||||
void my_srand(unsigned s)
|
|
||||||
{
|
|
||||||
seed = s - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int my_rand(void)
|
|
||||||
{
|
|
||||||
seed = 6364136223846793005ULL * seed + 1;
|
|
||||||
return seed >> 33;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fire Widget
|
* Fire Widget
|
||||||
*/
|
*/
|
||||||
|
@ -129,7 +113,7 @@ Fire::Fire()
|
||||||
cycles = 0;
|
cycles = 0;
|
||||||
phase = 0;
|
phase = 0;
|
||||||
|
|
||||||
my_srand(time(nullptr));
|
srand(time(nullptr));
|
||||||
stop_timer();
|
stop_timer();
|
||||||
start_timer(20);
|
start_timer(20);
|
||||||
|
|
||||||
|
@ -170,7 +154,7 @@ void Fire::timer_event(Core::TimerEvent&)
|
||||||
/* Paint our palettized buffer to screen */
|
/* Paint our palettized buffer to screen */
|
||||||
for (int px = 0 + phase; px < FIRE_WIDTH; px += 2) {
|
for (int px = 0 + phase; px < FIRE_WIDTH; px += 2) {
|
||||||
for (int py = 1; py < 200; py++) {
|
for (int py = 1; py < 200; py++) {
|
||||||
int rnd = my_rand() % 3;
|
int rnd = rand() % 3;
|
||||||
|
|
||||||
/* Calculate new pixel value, don't go below 0 */
|
/* Calculate new pixel value, don't go below 0 */
|
||||||
u8 nv = bitmap->bits(py)[px];
|
u8 nv = bitmap->bits(py)[px];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue