From c8a714e68423505c3be5716e8350d6144f93cd5f Mon Sep 17 00:00:00 2001 From: PoliEcho Date: Tue, 12 Aug 2025 15:48:40 +0200 Subject: [PATCH] basic firework --- src/UEFI_fireworks/UefiMain.c | 21 +++++++++++++++++++++ src/UEFI_fireworks/drawing.c | 28 +++++++++++++++++++++++++++- src/UEFI_fireworks/drawing.h | 4 +++- src/UEFI_fireworks/types.h | 19 +++++++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/UEFI_fireworks/types.h diff --git a/src/UEFI_fireworks/UefiMain.c b/src/UEFI_fireworks/UefiMain.c index b832ce0..1f523f4 100644 --- a/src/UEFI_fireworks/UefiMain.c +++ b/src/UEFI_fireworks/UefiMain.c @@ -1,6 +1,12 @@ +#include "ProcessorBind.h" #include "drawing.h" #include "global.h" +#include "macros.h" +#include "types.h" #include +#include +#include +#include #include #include #include @@ -32,5 +38,20 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle, 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; } diff --git a/src/UEFI_fireworks/drawing.c b/src/UEFI_fireworks/drawing.c index 3043a77..bd92ef7 100644 --- a/src/UEFI_fireworks/drawing.c +++ b/src/UEFI_fireworks/drawing.c @@ -1,8 +1,9 @@ +#include "Base.h" #include "Library/UefiLib.h" #include "ProcessorBind.h" #include "const.h" #include "global.h" -#include "macros.h" +#include "types.h" #include #include @@ -26,6 +27,10 @@ void draw_circle(int xc, int yc, int r, int x = r, y = 0; 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) { draw_pixel(x + xc, -y + 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; +} diff --git a/src/UEFI_fireworks/drawing.h b/src/UEFI_fireworks/drawing.h index 507ba81..806eea2 100644 --- a/src/UEFI_fireworks/drawing.h +++ b/src/UEFI_fireworks/drawing.h @@ -1,5 +1,7 @@ #pragma once +#include "types.h" #include void draw_circle(int xc, int yc, int r, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); -void clear_screen(EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput); \ No newline at end of file +void clear_screen(EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput); +BOOLEAN step_firework(struct firework_instance *firework); \ No newline at end of file diff --git a/src/UEFI_fireworks/types.h b/src/UEFI_fireworks/types.h new file mode 100644 index 0000000..3238ade --- /dev/null +++ b/src/UEFI_fireworks/types.h @@ -0,0 +1,19 @@ +#pragma once +#include "ProcessorBind.h" +#include "Protocol/GraphicsOutput.h" +#include +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') \ No newline at end of file