Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 31 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
run: |
make check_format

build-gba:
build-sa2-gba:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork || github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork}}
runs-on: ubuntu-24.04
name: Build GBA (USA)
name: Build SA2 GBA (USA)
steps:
- name: Checkout PR
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target'}}
Expand Down Expand Up @@ -78,13 +78,13 @@ jobs:
- name: Generate reports
run: |
mkdir -p gh-pages/reports
mkdir -p gh-pages/maps
mkdir -p gh-pages/maps/sa2
python3 scripts/progress.py csv > gh-pages/reports/progress-sa2-nonmatching-latest.csv
python3 scripts/progress.py csv -m > gh-pages/reports/progress-sa2-matching-latest.csv
python3 scripts/progress.py shield-json > gh-pages/reports/progress-sa2-shield.json
python3 scripts/progress.py shield-json -m > gh-pages/reports/progress-sa2-shield-matching.json
echo "REPORTS_COMMIT_MSG=$( git log --format=%s ${GITHUB_SHA} )" >> $GITHUB_ENV
cp sa2.map gh-pages/maps/${GITHUB_SHA}.map
cp sa2.map gh-pages/maps/sa2/${GITHUB_SHA}.map

- name: Generate reports (Collect Rings)
run: |
Expand All @@ -108,6 +108,7 @@ jobs:
with:
path: |
gh-pages
name: sa2

build-sa1-gba:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork || github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork}}
Expand Down Expand Up @@ -150,32 +151,33 @@ jobs:
- name: Compare
run: make sa1 -j${nproc}

# - name: Progress
# run: |
# python3 scripts/progress.py text

# - name: Generate reports
# run: |
# mkdir -p gh-pages/reports
# mkdir -p gh-pages/maps
# python3 sa1/scripts/progress.py csv >> gh-pages/reports/progress-sa1-nonmatching.csv
# python3 sa1/scripts/progress.py csv -m >> gh-pages/reports/progress-sa1-matching.csv
# python3 sa1/scripts/progress.py shield-json > gh-pages/reports/progress-sa1-shield.json
# python3 sa1/scripts/progress.py shield-json -m > gh-pages/reports/progress-sa1-shield-matching.json
# echo "REPORTS_COMMIT_MSG=$( git log --format=%s ${GITHUB_SHA} )" >> $GITHUB_ENV
# cp sa1.map gh-pages/maps/${GITHUB_SHA}.map

# - name: Upload progress
# if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
# uses: actions/upload-artifact@v7
# with:
# path: |
# gh-pages
- name: Progress
run: |
python3 scripts/progress.py -f sa1.map text

- name: Generate reports
run: |
mkdir -p gh-pages/reports
mkdir -p gh-pages/maps/sa1
python3 scripts/progress.py -f sa1.map csv >> gh-pages/reports/progress-sa1-nonmatching-latest.csv
python3 scripts/progress.py -f sa1.map csv -m >> gh-pages/reports/progress-sa1-matching-latest.csv
python3 scripts/progress.py -f sa1.map shield-json > gh-pages/reports/progress-sa1-shield.json
python3 scripts/progress.py -f sa1.map shield-json -m > gh-pages/reports/progress-sa1-shield-matching.json
echo "REPORTS_COMMIT_MSG=$( git log --format=%s ${GITHUB_SHA} )" >> $GITHUB_ENV
cp sa1.map gh-pages/maps/sa1/${GITHUB_SHA}.map

- name: Upload progress
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v7
with:
path: |
gh-pages
name: sa1

publish-progress:
name: Publish progress
runs-on: ubuntu-24.04
needs: [build-gba]
needs: [build-sa2-gba, build-sa1-gba]
# Only able to run from repo pull requests (by maintainers, or on the main branch via push)
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
permissions:
Expand All @@ -191,7 +193,10 @@ jobs:
with:
path: |
gh-pages
merge-multiple: true
- run: |
cat gh-pages/reports/progress-sa1-nonmatching-latest.csv >> gh-pages/reports/progress-sa1-nonmatching.csv
cat gh-pages/reports/progress-sa1-matching-latest.csv >> gh-pages/reports/progress-sa1-matching.csv
cat gh-pages/reports/progress-sa2-nonmatching-latest.csv >> gh-pages/reports/progress-sa2-nonmatching.csv
cat gh-pages/reports/progress-sa2-matching-latest.csv >> gh-pages/reports/progress-sa2-matching.csv
cat gh-pages/reports/progress-collect_rings-nonmatching-latest.csv >> gh-pages/reports/progress-collect_rings-nonmatching.csv
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
<p align="center">
<img height="240" src=".github/media/titlescreen.png" alt="Sonic Advance 2 title screen">
</p>
<p align="center">
<div align="center">

| | |
| --- | --- |
| SA1 | ![Decompilation Progress](https://img.shields.io/endpoint?url=https://sat-r.github.io/sa2/reports/progress-sa1-shield.json) ![Decompilation Matching Progress](https://img.shields.io/endpoint?url=https://sat-r.github.io/sa2/reports/progress-sa1-shield-matching.json) |
| SA2 | ![Decompilation Progress](https://img.shields.io/endpoint?url=https://sat-r.github.io/sa2/reports/progress-sa2-shield.json) ![Decompilation Matching Progress](https://img.shields.io/endpoint?url=https://sat-r.github.io/sa2/reports/progress-sa2-shield-matching.json) |

<a href="https://github.com/SAT-R/sa2/actions/workflows/build.yml"><img src="https://github.com/SAT-R/sa2/actions/workflows/build.yml/badge.svg" alt="CI status"></a>
<a href="https://github.com/SAT-R/sa2"><img src="https://img.shields.io/endpoint?url=https://sat-r.github.io/sa2/reports/progress-sa2-shield.json" alt="Decompilation Progress"></a>
<a href="https://github.com/SAT-R/sa2"><img src="https://img.shields.io/endpoint?url=https://sat-r.github.io/sa2/reports/progress-sa2-shield-matching.json" alt="Decompilation Matching Progress"></a>
<a href="https://github.com/SAT-R/sa2/graphs/contributors"><img src="https://img.shields.io/github/contributors/SAT-R/sa2" alt="Contributors"></a>
<a href="https://discord.gg/vZTvVH3gA9"><img src="https://img.shields.io/discord/1052347299457671200" alt="Discord"></a>
</p>
</div>

> :warning: **This project is not completed and still under active development**

Expand Down
77 changes: 36 additions & 41 deletions scripts/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,45 @@
import os
import re

def collect_non_matching_funcs():
def read_non_matching_funcs(filepath, game):
result = []
for root, dirs, files in os.walk('src'):
if "/sa1/" in root:
continue
for file in files:
if file.endswith('.c'):
with open(os.path.join(root, file), 'r') as f:
data = f.read()
lines = data.split("\n")
for i in range(len(lines)):
line = lines[i]
if "sa1" in line:
continue
if "NONMATCH" in line:
# if "unused_" in line.lower():
# continue
matcher = r'(NONMATCH|ASM_FUNC)\(".*",\W*\w*\W*(\w*).*\)'
match = re.findall(matcher, line)
if match:
result.append(match[0])
else:
if i < len(lines) - 1:
line = lines[i + 1]
match = re.findall(r'\W*\w*\W*(\w*).*\)', line)
if match:
result.append(('NONMATCH', match[0]))
with open(filepath, 'r') as f:
data = f.read()
lines = data.split("\n")
for i in range(len(lines)):
line = lines[i]
if "NONMATCH" in line:
if game == "sa1" and "sa2." in line:
continue

if game == "sa2" and "sa1." in line:
continue

# if "unused_" in line.lower():
# continue
matcher = r'(NONMATCH|ASM_FUNC)\(".*?",\s*\w+\s+(?:SA2_LABEL\()?(\w+).*\)'
match = re.findall(matcher, line)
if match:
result.append(match[0][1])
else:
if i < len(lines) - 1:
line = lines[i + 1]
match = re.findall(r'\W*\w*\W*(\w*).*\)', line)
if match:
result.append(match[0])
if result:
print(filepath, result)
return result


def parse_map(non_matching_funcs, map_file):
def parse_map(matching, map_file):
src = 0
asm = 0
src_data = 0
data = 0
game = map_file.replace(".map", "")
non_matching = 0
non_matching_funcs = []

with open(map_file, 'r') as map:
# Skip to the linker script section
Expand All @@ -61,6 +64,11 @@ def parse_map(non_matching_funcs, map_file):
section = arr[0]
size = int(arr[2], 16)
filepath = arr[3]
if (filepath.startswith('src')):
if matching:
c_path = filepath.replace(".o", ".c")
if os.path.exists(c_path):
non_matching_funcs += read_non_matching_funcs(c_path, game)
if filepath.startswith('build'):
# build/*/(asm|data|sound|src|...)/*/
# ^ ^ ^
Expand Down Expand Up @@ -123,20 +131,7 @@ def main():
parser.add_argument("-f", "--file", dest='map_file', default="sa2.map")
args = parser.parse_args()

matching = args.matching

non_matching_funcs = []
funcs = collect_non_matching_funcs()
if matching:
# Remove all non matching funcs from count
non_matching_funcs = [x[1] for x in funcs]
else:
# Only remove ASM_FUNC functions from count
for func in funcs:
if func[0] == 'ASM_FUNC':
non_matching_funcs.append(func[1])

(src, asm, src_data, data) = parse_map(non_matching_funcs, args.map_file)
(src, asm, src_data, data) = parse_map(args.matching, args.map_file)

total = src + asm
data_total = src_data + data
Expand Down
4 changes: 2 additions & 2 deletions src/game/shared/stage/collision_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ u32 Coll_Player_Spring_Sideways(Sprite *s, CamCoord worldX, CamCoord worldY, Pla
}

// (99.92%) https://decomp.me/scratch/GFpFd
NONMATCH("asm/non_matching/game/shared/stage/collision__Coll_Player_Itembox.inc",
NONMATCH("asm/non_matching/game/shared/stage/collision__Coll_Player_Itembox_sa1.inc",
u32 Coll_Player_Itembox(Sprite *s, CamCoord worldX, CamCoord worldY, Player *p))
{
s8 rectDataPlayerA[4] = { -(p->spriteOffsetX + 5), (1 - p->spriteOffsetY), (p->spriteOffsetX + 5), (p->spriteOffsetY - 1) };
Expand Down Expand Up @@ -861,7 +861,7 @@ EHit sub_800C0E0(Sprite *s, CamCoord screenX, CamCoord screenY, Player *p)
}

// (97.67%) https://decomp.me/scratch/e4jLp
NONMATCH("asm/non_matching/game/shared/stage/collision__sub_800C1E8.inc",
NONMATCH("asm/non_matching/game/shared/stage/collision__sub_800C1E8_sa1.inc",
u32 sub_800C1E8(Sprite *inSprite, Rect8 rectB, s16 sx, s16 sy, Player *p))
{
#ifndef NON_MATCHING
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/stage/mp_event_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void ReceiveRoomEvent_ItemEffect(union MultiSioData *recv, u8 i)
#ifndef COLLECT_RINGS_ROM
#if (GAME == GAME_SA1)
// (96.15%) https://decomp.me/scratch/LMpNt
NONMATCH("asm/non_matching/game/shared/stage/evt_mgr__ReceiveRoomEvent_ReachedStageGoal.inc",
NONMATCH("asm/non_matching/game/shared/stage/evt_mgr__ReceiveRoomEvent_ReachedStageGoal_sa1.inc",
void ReceiveRoomEvent_ReachedStageGoal(union MultiSioData *recv, u8 i))
#else
void ReceiveRoomEvent_ReachedStageGoal(union MultiSioData *recv, u8 i)
Expand Down
Loading