basic firework
This commit is contained in:
parent
a8c9853065
commit
c8a714e684
@ -1,6 +1,12 @@
|
|||||||
|
#include "ProcessorBind.h"
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "macros.h"
|
||||||
|
#include "types.h"
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/TimerLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
#include <Protocol/GraphicsOutput.h>
|
#include <Protocol/GraphicsOutput.h>
|
||||||
@ -32,5 +38,20 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
|||||||
|
|
||||||
clear_screen(GraphicsOutput);
|
clear_screen(GraphicsOutput);
|
||||||
|
|
||||||
|
struct firework_instance firework = {500,
|
||||||
|
500,
|
||||||
|
100,
|
||||||
|
{0, 0, 0},
|
||||||
|
{COLOR_FROM_HEX(0xff0000),
|
||||||
|
COLOR_FROM_HEX(0x00ff00),
|
||||||
|
COLOR_FROM_HEX(0x0000ff)},
|
||||||
|
0};
|
||||||
|
while (step_firework(&firework)) {
|
||||||
|
MicroSecondDelay(50000);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIST_ENTRY firework_list;
|
||||||
|
InitializeListHead(&firework_list);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "Base.h"
|
||||||
#include "Library/UefiLib.h"
|
#include "Library/UefiLib.h"
|
||||||
#include "ProcessorBind.h"
|
#include "ProcessorBind.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "macros.h"
|
#include "types.h"
|
||||||
#include <Library/UefiApplicationEntryPoint.h>
|
#include <Library/UefiApplicationEntryPoint.h>
|
||||||
#include <Protocol/GraphicsOutput.h>
|
#include <Protocol/GraphicsOutput.h>
|
||||||
|
|
||||||
@ -26,6 +27,10 @@ void draw_circle(int xc, int yc, int r,
|
|||||||
int x = r, y = 0;
|
int x = r, y = 0;
|
||||||
draw_pixel(x + xc, y + yc, color);
|
draw_pixel(x + xc, y + yc, color);
|
||||||
|
|
||||||
|
// fix missng pixels
|
||||||
|
draw_pixel(xc - r, yc, color);
|
||||||
|
draw_pixel(xc, yc - r, color);
|
||||||
|
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
draw_pixel(x + xc, -y + yc, color);
|
draw_pixel(x + xc, -y + yc, color);
|
||||||
draw_pixel(y + xc, x + yc, color);
|
draw_pixel(y + xc, x + yc, color);
|
||||||
@ -78,3 +83,24 @@ void clear_screen() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN step_firework(struct firework_instance *firework) {
|
||||||
|
for (UINT8 i = 0; i < ARRAY_SIZE(firework->r); i++) {
|
||||||
|
if (firework->r[i] < firework->max_r) {
|
||||||
|
if (i == 0 || (firework->max_r / 3) * i <= firework->r[i - 1]) {
|
||||||
|
draw_circle(firework->x, firework->y, firework->r[i],
|
||||||
|
firework->color[i]);
|
||||||
|
firework->r[i]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (firework->r[1] >= firework->max_r) {
|
||||||
|
if (firework->cleanup_r < firework->max_r) {
|
||||||
|
draw_circle(firework->x, firework->y, firework->cleanup_r, night_sky);
|
||||||
|
firework->cleanup_r++;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "types.h"
|
||||||
#include <Protocol/GraphicsOutput.h>
|
#include <Protocol/GraphicsOutput.h>
|
||||||
void draw_circle(int xc, int yc, int r,
|
void draw_circle(int xc, int yc, int r,
|
||||||
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
|
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
|
||||||
void clear_screen(EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput);
|
void clear_screen(EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput);
|
||||||
|
BOOLEAN step_firework(struct firework_instance *firework);
|
19
src/UEFI_fireworks/types.h
Normal file
19
src/UEFI_fireworks/types.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "ProcessorBind.h"
|
||||||
|
#include "Protocol/GraphicsOutput.h"
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
struct firework_instance {
|
||||||
|
UINT32 x;
|
||||||
|
UINT32 y;
|
||||||
|
UINT16 max_r;
|
||||||
|
UINT16 r[3];
|
||||||
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color[3];
|
||||||
|
UINT16 cleanup_r;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct firework_node {
|
||||||
|
UINTN Signature;
|
||||||
|
struct firework_instance Firework;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
};
|
||||||
|
#define FIREWORK_NODE_SIGNATURE SIGNATURE_32('f', 'w', 'r', 'k')
|
Loading…
x
Reference in New Issue
Block a user