Skip to content

Commit

Permalink
Toypad is being detected by the game | Merge pull request #1 from Seg…
Browse files Browse the repository at this point in the history
…erEnd/dev

The toypad is being detected by the game! 🎉, Now need to figure out how to send a minifigure
  • Loading branch information
SegerEnd authored Jan 3, 2025
2 parents a2ff945 + 9659409 commit fa19abc
Show file tree
Hide file tree
Showing 18 changed files with 1,822 additions and 617 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dist/*
.vscode
.clang-format
.editorconfig
.clangd
.editorconfig
.env
.ufbt
6 changes: 2 additions & 4 deletions application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ App(
name="LEGO Dimensions Toy Pad", # Displayed in menus
apptype=FlipperAppType.EXTERNAL,
entry_point="ldtoypad_app",
stack_size=2 * 1024,
stack_size=4 * 1024,
fap_category="USB",
requires=[
"gui",
"dialogs",
"notifications",
],
# Optional values
order=60,
# fap_version="0.1",
fap_icon="ldtoypad.png", # 10x10 1-bit PNG
fap_description="USB Toy Pad emulator for Lego Dimensions",
fap_author="Seger",
# fap_weburl="https://github.com/user/ldtoypad",
fap_weburl="https://github.com/SegerEnd/Flipper-Zero-LD-Toypad-Emulator",
fap_icon_assets="images", # Image assets to compile for this application
)
25 changes: 25 additions & 0 deletions burtle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "burtle.h"

// Helper function for rotation
static uint32_t rot(uint32_t a, int b) {
return (a << b) | (a >> (32 - b));
}

// Constructor equivalent
void burtle_init(Burtle* b, uint32_t seed) {
b->a = 0xf1ea5eed;
b->b = b->c = b->d = seed;
for(int i = 0; i < 42; ++i) {
burtle_rand(b); // Initialize with 42 iterations
}
}

// rand method
uint32_t burtle_rand(Burtle* b) {
uint32_t e = b->a - rot(b->b, 21);
b->a = b->b ^ rot(b->c, 19);
b->b = b->c + rot(b->d, 6);
b->c = b->d + e;
b->d = e + b->a;
return b->d;
}
19 changes: 19 additions & 0 deletions burtle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
uint32_t a, b, c, d;
} Burtle;

void burtle_init(Burtle* b, uint32_t seed);
uint32_t burtle_rand(Burtle* b);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit fa19abc

Please sign in to comment.