diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 527297dc1..706b65cb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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'}} @@ -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: | @@ -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}} @@ -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: @@ -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 diff --git a/README.md b/README.md index 88aa96048..738e2761e 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,17 @@

Sonic Advance 2 title screen

-

+

+ + | | | + | --- | --- | + | 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) | + CI status - Decompilation Progress - Decompilation Matching Progress Contributors Discord -

+
> :warning: **This project is not completed and still under active development** diff --git a/asm/non_matching/game/shared/stage/collision__Coll_Player_Itembox.inc b/asm/non_matching/game/shared/stage/collision__Coll_Player_Itembox_sa1.inc similarity index 100% rename from asm/non_matching/game/shared/stage/collision__Coll_Player_Itembox.inc rename to asm/non_matching/game/shared/stage/collision__Coll_Player_Itembox_sa1.inc diff --git a/asm/non_matching/game/shared/stage/collision__sub_800C1E8.inc b/asm/non_matching/game/shared/stage/collision__sub_800C1E8_sa1.inc similarity index 100% rename from asm/non_matching/game/shared/stage/collision__sub_800C1E8.inc rename to asm/non_matching/game/shared/stage/collision__sub_800C1E8_sa1.inc diff --git a/asm/non_matching/game/shared/stage/evt_mgr__ReceiveRoomEvent_ReachedStageGoal.inc b/asm/non_matching/game/shared/stage/evt_mgr__ReceiveRoomEvent_ReachedStageGoal_sa1.inc similarity index 100% rename from asm/non_matching/game/shared/stage/evt_mgr__ReceiveRoomEvent_ReachedStageGoal.inc rename to asm/non_matching/game/shared/stage/evt_mgr__ReceiveRoomEvent_ReachedStageGoal_sa1.inc diff --git a/scripts/progress.py b/scripts/progress.py index 116d3bdf8..67cb427fe 100644 --- a/scripts/progress.py +++ b/scripts/progress.py @@ -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 @@ -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|...)/*/ # ^ ^ ^ @@ -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 diff --git a/src/game/shared/stage/collision_3.c b/src/game/shared/stage/collision_3.c index dd1517a17..347c6ca9b 100644 --- a/src/game/shared/stage/collision_3.c +++ b/src/game/shared/stage/collision_3.c @@ -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) }; @@ -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 diff --git a/src/game/shared/stage/mp_event_mgr.c b/src/game/shared/stage/mp_event_mgr.c index 9080b424a..eedc67f6e 100644 --- a/src/game/shared/stage/mp_event_mgr.c +++ b/src/game/shared/stage/mp_event_mgr.c @@ -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)