Skip to content

Commit

Permalink
Add LICENSE
Browse files Browse the repository at this point in the history
Other changes:
* For some reason rand() was returning negative numbers, so fix that
* Add README.md
* Also add a demo image
* Pre-release -> release
  • Loading branch information
radiantly committed Mar 26, 2022
1 parent 0698f2e commit 3f48e2d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
Binary file added .github/demo-qemu.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ jobs:
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: "latest"
prerelease: true
files: wordle-uefi.img.zip
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 All contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ disk-image: all
# and an EFI partition.
# The EFI partition needs to contain a FAT32 filesystem (this is the most
# supported EFI partition type).
# The minimum size of a FAT partition is (sector size) 512 * 65527 = ~32MiB
# The minimum size of a FAT32 fs is (sector size) 512 * (clusters) 65525 = ~32MiB
# Here we create a disk file of 48MiB to account for that and extras
# 1024 * 1024 * 48 / 512 = 98304
dd if=/dev/zero of=$(IMG_FILE) bs=512 count=$(IMG_DD_COUNT)
Expand All @@ -33,6 +33,7 @@ disk-image: all

# Create a temporary image file that serves as our FAT32 partition
$(eval IMG_PART_FILE := $(shell mktemp XXXXXXXX.img))

# Partition size = Total size - first sector + 1
dd if=/dev/zero of=$(IMG_PART_FILE) bs=512 count=$(IMG_PART_DD_COUNT)

Expand All @@ -50,4 +51,4 @@ disk-image: all
# Delete the temporary image file
rm $(IMG_PART_FILE)

.PHONY: disk-image
.PHONY: disk-image
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Wordle for UEFI

> Who says you need an operating system to play Wordle?
A clone of the popular word game, Wordle, for UEFI.

<details>
<summary>What's UEFI?</summary>

Let's start with the BIOS - which you might have heard of before. BIOS stands for Basic Input Output System and is a program that runs when you start your computer. It's in charge of reading and executing the bootloader from a drive, which then loads your operating system.

UEFI is a modern replacement for BIOS that most computers today run. It has more features and is way easier to program with! When your computer boots up, the UEFI firmware looks for a special EFI file to run (which might eventually load a full-fledged os). This project compiles to a `.efi` file that the UEFI firmware of your computer can run.

</details>

![Demo](.github/demo-qemu.gif)

## How do I run this?

### On your computer

The UEFI image is built for x86_64 systems running UEFI class 2 or above. Basically any modern computer in use today should support this without problems. Also: Secure Boot will need to be disabled in the settings.

1. Download the zipped disk image file from [here](https://github.com/radiantly/Wordle-UEFI/releases/download/latest/wordle-uefi.img.zip).
2. Flash the file to a disk

- **On Windows**, you can use the [rufus utility](https://github.com/pbatard/rufus) to save the disk image to a pen drive.
- **On Linux**, you can use `unzip` and `dd` as shown below. Replace `/dev/sdX` with the path of the drive you would like to write to.

```sh
unzip -p wordle-uefi.img.zip | sudo dd bs=512 of=/dev/sdX conv=fdatasync status=progress
```

3. You can now boot from the device you created!

### On QEMU

[Download](https://github.com/radiantly/Wordle-UEFI/releases/download/latest/wordle-uefi.img.zip), extract, and run using the following command:

```sh
qemu-system-x86_64 -cpu qemu64 -bios /usr/share/edk2-ovmf/x64/OVMF.fd -drive file=wordle-uefi.img,if=ide,format=raw
```

To boot with UEFI on QEMU, you will need to install the edk2-ovmf package. Replace `/usr/share/edk2-ovmf/x64/OVMF.fd` in the above command with the path where it is saved.

## License

MIT

## Contributing

Found a mistake or want to add a feature? Open an issue/PR!
7 changes: 5 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ int checkGuess(const char *buffer, const char *word_today) {
return correct == 0x1f;
}

inline int positive_modulo(int a, int b) {
return (a % b + b) % b;
}

int main(int argc, char **argv) {
ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL);

struct tm *local_time = localtime(NULL);
unsigned int seed = local_time->tm_year * 10000 + local_time->tm_mon * 100 + local_time->tm_mday;
srand(seed);

const char *word_today = answers[rand() % answerCount];
const char *word_today = answers[positive_modulo(rand(), answerCount)];

ST->ConOut->ClearScreen(ST->ConOut);

Expand Down

0 comments on commit 3f48e2d

Please sign in to comment.