add rockets

This commit is contained in:
PoliEcho 2025-08-16 16:29:37 +02:00
parent 8c53885621
commit 91001e09ba
7 changed files with 82 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,5 +1,6 @@
#!/bin/bash
export PACKAGES_PATH=$PWD:$PWD/edk2
magick assets/rocket_orig.bmp -type TrueColor -define bmp:format=bmp3 -compress None assets/rocket.bmp
xxd -i assets/rocket.bmp > src/UEFI_fireworks/rocket.c
if [ "$1" == "debug" ]; then
build -a X64 -t GCC5 -p UEFI_fireworks.dsc -b DEBUG

View File

@ -6,7 +6,6 @@
#include "rng.h"
#include "time.h"
#include "types.h"
#include <../MdeModulePkg/Include/Library/BmpSupportLib.h>
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
@ -55,6 +54,7 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GraphicsOutput->Mode->FrameBufferBase;
init_rng();
init_rocket_blt();
if (SerialPortInitialize() == RETURN_SUCCESS) {
SERIAL_PRINT("Serial initialized\n");
@ -74,6 +74,13 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
milisleep(1);
clear_screen();
/*rocket_instance rocket = {
.x = GraphicsOutput->Mode->Info->HorizontalResolution / 2,
.y = GraphicsOutput->Mode->Info->VerticalResolution - 50};
while (step_rocket(&rocket, 100)) {
milisleep(10);
}*/
while (TRUE) {
UINT8 random;
fill_random_bytes(&random, sizeof(random));
@ -88,7 +95,8 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
*new_firework_instence = create_firework();
for (UINT8 i = 0; i < ARRAY_SIZE(firework_array); i++) {
if (firework_array[i] == NULL || firework_array[i]->status != TRUE) {
if (firework_array[i] == NULL ||
firework_array[i]->status == INACTIVE) {
if (firework_array[i] != NULL) {
FreePool(firework_array[i]); // free firework
firework_array[i] = NULL;
@ -106,6 +114,10 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
if (!step_firework(firework_array[i])) {
firework_array[i]->status = INACTIVE;
}
} else if (firework_array[i]->status == LAUNCHING) {
if (!step_rocket(&firework_array[i]->rocket, firework_array[i]->y)) {
firework_array[i]->status = ACTIVE;
}
} else {
FreePool(firework_array[i]); // free firework
firework_array[i] = NULL;
@ -138,6 +150,8 @@ firework_instance create_firework() {
firework.y = random % GraphicsOutput->Mode->Info->VerticalResolution /
2; // spawn only on upper half of the screen
firework.status = ACTIVE; // TODO set to LAUNCHING when implemented
firework.rocket.x = firework.x + rocket_asset.width / 2;
firework.rocket.y = GraphicsOutput->Mode->Info->VerticalResolution;
firework.status = LAUNCHING; // TODO set to LAUNCHING when implemented
return firework;
}

View File

@ -1,8 +1,11 @@
#include "Base.h"
#include "Library/UefiLib.h"
#include "ProcessorBind.h"
#include "bmp.h"
#include "const.h"
#include "global.h"
#include "types.h"
#include <../MdeModulePkg/Include/Library/BmpSupportLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Protocol/GraphicsOutput.h>
@ -104,5 +107,52 @@ BOOLEAN step_firework(firework_instance *firework) {
}
return TRUE;
}
rocket_blt rocket_asset;
BOOLEAN step_rocket(rocket_instance *rocket) {}
EFI_GRAPHICS_OUTPUT_BLT_PIXEL **mask_stack;
BOOLEAN **rocket_alfa_mask;
void init_rocket_blt() {
EFI_STATUS Status = TranslateBmpToGopBlt(
assets_rocket_bmp, assets_rocket_bmp_len, &rocket_asset.blt,
&rocket_asset.blt_size, &rocket_asset.height, &rocket_asset.width);
if (EFI_ERROR(Status)) {
Print(L"Failed to load rocket asset: %r\n", Status);
Exit(Status);
}
}
BOOLEAN step_rocket(rocket_instance *rocket, UINT32 max_y) {
GraphicsOutput->Blt(GraphicsOutput,
rocket_asset.blt, // BltBuffer
EfiBltBufferToVideo, // BltOperation
0, // src X
0, // src Y
rocket->x, // dst X
rocket->y, // dst Y
rocket_asset.width, rocket_asset.height,
0 // unused Delta
);
if (rocket->y <= max_y) {
GraphicsOutput->Blt(
GraphicsOutput,
&night_sky, // BltBuffer
EfiBltVideoFill, // BltOperation
0, // SourceX
0, // SourceY
rocket->x, // DestinationX
rocket->y, // DestinationY
rocket_asset.width, // Width
rocket_asset.height + 1, // Height // remove trail from previous frame
0 // Delta (not used for fill operations)
);
return FALSE;
} else {
for (UINT8 i = 0; i < rocket_asset.width; i++) {
draw_pixel(rocket->x + i, rocket->y + rocket_asset.height, night_sky);
}
rocket->y--;
return TRUE;
}
}

View File

@ -5,3 +5,5 @@ void draw_circle(int xc, int yc, int r,
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void clear_screen();
BOOLEAN step_firework(firework_instance *firework);
void init_rocket_blt();
BOOLEAN step_rocket(rocket_instance *rocket, UINT32 max_y);

View File

@ -1,4 +1,6 @@
#pragma once
#include "types.h"
#include <Protocol/GraphicsOutput.h>
extern EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL *framebuffer;
extern rocket_blt rocket_asset;

View File

@ -19,3 +19,10 @@ typedef struct {
UINT16 cleanup_r;
rocket_instance rocket;
} firework_instance;
typedef struct {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *blt;
UINTN blt_size;
UINTN height;
UINTN width;
} rocket_blt;