Skip to content

Commit

Permalink
Add progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
lhsazevedo committed Jul 19, 2024
1 parent ddda814 commit 76701e6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Tokyo Bus Guide Decompilation

![Decompiled](https://img.shields.io/badge/decompiled-12.6%25-teal)
[![Test](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/test.yml/badge.svg)](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/test.yml)
[![Build](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build.yml/badge.svg)](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build.yml)
[![Build Matching](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build_matching.yml/badge.svg)](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build_matching.yml)

## Decompilation progress: 12.64%

![Main function hero](./tbg.png)

_Yup, [this is a real file](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/blob/88fb8f87500f9474780cd9a0f7dafa00b14b0be7/src/010080_main.c)!_
Expand All @@ -28,6 +27,9 @@ framework](https://github.com/lhsazevedo/sh4objtest) to test decompiled function
original counterparts, ensuring they behave exactly the same.

## Project Status
#### Decompilation progress: 12.6%
![Progress Bar](https://progress-bar.dev/12/?width=300)

This project is ongoing and is being updated regularly. It is in a shiftable state, which means the
original code can be shifted around in memory, allowing for edits such as data modifications without
worrying about length changes. It is also possible to recompile the binary using the decompiled
Expand Down
37 changes: 28 additions & 9 deletions scripts/progress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ remaining_lines=$(grep -lE "SECTION\s+P" src/asm/*.src | xargs cat | grep -vE ".
decompiled_total=$((matched_lines + decompiled_lines))
total_lines=$((decompiled_total + remaining_lines))

if [ $total_lines -ne 0 ]; then
progress_percentage=$(echo "scale=4; $decompiled_total / $total_lines * 100" | bc)
progress_percentage=$(printf "%.2f" $progress_percentage)
else
progress_percentage=0
if [ $total_lines -eq 0 ]; then
echo "Total lines is 0!"
exit
fi

progress_percentage=$(echo "scale=4; $decompiled_total / $total_lines * 100" | bc)
progress_percentage=$(printf "%.1f" $progress_percentage)
progress_percentage_int=${progress_percentage%.*}

echo "Matched lines: $matched_lines"
echo "Decompiled lines: $decompiled_lines"
echo "Decompiled total: $decompiled_total"
Expand All @@ -25,9 +27,26 @@ echo "Progress percentage: $progress_percentage%"
# Update README file with progress
readme_file="README.md"

if grep -q "Decompilation Progress:" "$readme_file"; then
sed -i "s/Decompilation Progress: [0-9.]\+%/Decompilation progress: $progress_percentage%/" "$readme_file"
echo "README file updated with current progress."
else
if ! grep -q "https://img.shields.io/badge/decompiled-" "$readme_file"; then
echo "Progress badge not found in README file!"
exit 1
fi

sed -i "s/https:\/\/img.shields.io\/badge\/decompiled-[0-9.]\+/https:\/\/img.shields.io\/badge\/decompiled-$progress_percentage/" "$readme_file"
echo "README file progress badge updated."

if ! grep -q "Decompilation progress:" "$readme_file"; then
echo "Progress not found in README file!"
exit 1
fi

sed -i "s/Decompilation progress: [0-9.]\+%/Decompilation progress: $progress_percentage%/" "$readme_file"
echo "README file progress updated."

if ! grep -q "https://progress-bar.dev/" "$readme_file"; then
echo "Progress bar not found in README file!"
exit 1
fi

sed -i "s/https:\/\/progress-bar.dev\/[0-9]\+/https:\/\/progress-bar.dev\/$progress_percentage_int/" "$readme_file"
echo "README progress bar updated."

0 comments on commit 76701e6

Please sign in to comment.