Skip to content

Commit

Permalink
Add mgba's suite to the accuracy checker.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arignir committed Feb 14, 2024
1 parent 03d2d70 commit 1685837
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 15 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/accuracy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
shred -u ags.zip
mv AGB_*.gba ags.gba
# Download mGBA Suite
wget -q https://s3.amazonaws.com/mgba/suite-latest.zip -O suite.zip
unzip suite.zip
mv suite*.gba mgba-suite.gba
# Download the remaining testing ROMs
wget -q https://raw.githubusercontent.com/jsmolka/gba-tests/master/arm/arm.gba -O jsmolka-arm.gba
wget -q https://raw.githubusercontent.com/jsmolka/gba-tests/master/bios/bios.gba -O jsmolka-bios.gba
Expand All @@ -48,7 +53,7 @@ jobs:
wget -q https://raw.githubusercontent.com/Arignir/Hades-Tests/master/roms/timer-basic.gba -O hades-timer-basic.gba
# Clear-out all secrets to not leak them to the later steps
unset BIOS_DATA BIOS_KEY AGS_URL AGS_KEY
unset BIOS_DATA BIOS_KEY AGS_URL AGS_KEY ags_url
env:
BIOS_DATA: ${{ secrets.BIOS_DATA }}
BIOS_KEY: ${{ secrets.BIOS_KEY }}
Expand Down
64 changes: 50 additions & 14 deletions accuracy/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ def main():
help="Path to Hades' binary",
)

parser.add_argument(
'--bios',
nargs='?',
default='./bios.bin',
help="Path to the BIOS",
)

parser.add_argument(
'--roms',
nargs='?',
Expand All @@ -83,29 +90,58 @@ def main():

args = parser.parse_args()

hades_binary = Path(os.getcwd()) / args.binary
rom_directory = Path(os.getcwd()) / args.roms
hades_binary: Path = Path(os.getcwd()) / args.binary
bios: Path = Path(os.getcwd()) / args.bios
rom_directory: Path = Path(os.getcwd()) / args.roms

if not hades_binary.exists():
print(f"Error: {hades_binary}: no such file or directory.")
exit(1)

if not bios.exists():
print(f"Error: {bios}: no such file or directory.")
exit(1)

for test in TESTS_SUITE:
if not test.skip and not (rom_directory / test.rom).exists():
print(f"Error: ROM {test.rom} is missing from the ROM directory.")
exit(1)

# Ensure Hades is built with the debugger
try:
subprocess.run(
[hades_binary, '--without-gui', '--help'],
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text=True,
encoding='utf-8',
check=True,
)
except subprocess.CalledProcessError:
print("Error: Hades wasn't build with its debugger.")
exit(1)

config = tempfile.NamedTemporaryFile()
config.write(textwrap.dedent('''
{
"file": {
"bios": "./bios.bin"
},
"emulation": {
config.write(textwrap.dedent(f'''
{{
"file": {{
"bios": "{bios}"
}},
"emulation": {{
"skip_bios": true,
"speed": 0,
"unbounded": false,
"backup_storage": {
"backup_storage": {{
"autodetect": true,
"type": 0
},
"rtc": {
}},
"rtc": {{
"autodetect": true,
"enabled": true
}
}
}
}}
}}
}}
''').encode('utf-8'))
config.flush()

Expand Down
Binary file added accuracy/expected/mgba_suite_bios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_carry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_dma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_io.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_memory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_multiply_long.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_shifter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_timer_count_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_timer_irq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added accuracy/expected/mgba_suite_timing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 155 additions & 0 deletions accuracy/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,161 @@
skip=True,
),

# mGBA suite
# https://github.com/mgba-emu/suite
Test(
name="mGBA Suite - Memory",
rom='mgba-suite.gba',
code='''
key a true
frame 20
key a false
frame 100
screenshot ./.tests_screenshots/mgba_suite_memory.png
''',
screenshot='mgba_suite_memory.png',
),
Test(
name="mGBA Suite - IO",
rom='mgba-suite.gba',
code='''
key down true
frame 20
key down false
key a true
frame 20
key a false
frame 100
screenshot ./.tests_screenshots/mgba_suite_io.png
''',
screenshot='mgba_suite_io.png',
),
Test(
name="mGBA Suite - Timing", # NOTE: Only passing 1918/2020 tests for now.
rom='mgba-suite.gba',
code='''
key down true
frame 40
key down false
key a true
frame 20
key a false
frame 200
screenshot ./.tests_screenshots/mgba_suite_timing.png
''',
screenshot='mgba_suite_timing.png',
),
Test(
name="mGBA Suite - Timer Count-Up", # NOTE: Only passing 211/936 tests for now.
rom='mgba-suite.gba',
code='''
key down true
frame 50
key down false
key a true
frame 20
key a false
frame 150
screenshot ./.tests_screenshots/mgba_suite_timer_count_up.png
''',
screenshot='mgba_suite_timer_count_up.png',
),
Test(
name="mGBA Suite - Timer IRQ", # NOTE: Only passing 28/90 tests for now.
rom='mgba-suite.gba',
code='''
key down true
frame 60
key down false
key a true
frame 20
key a false
screenshot ./.tests_screenshots/mgba_suite_timer_irq.png
''',
screenshot='mgba_suite_timer_irq.png',
),
Test(
name="mGBA Suite - Shifter",
rom='mgba-suite.gba',
code='''
key down true
frame 70
key down false
key a true
frame 20
key a false
screenshot ./.tests_screenshots/mgba_suite_shifter.png
''',
screenshot='mgba_suite_shifter.png',
),
Test(
name="mGBA Suite - Carry",
rom='mgba-suite.gba',
code='''
key down true
frame 80
key down false
key a true
frame 20
key a false
screenshot ./.tests_screenshots/mgba_suite_carry.png
''',
screenshot='mgba_suite_carry.png',
),
Test(
name="mGBA Suite - Multiply Long", # NOTE: Only passing 52/72 tests for now.
rom='mgba-suite.gba',
code='''
key down true
frame 85
key down false
key a true
frame 20
key a false
screenshot ./.tests_screenshots/mgba_suite_multiply_long.png
''',
screenshot='mgba_suite_multiply_long.png',
),
Test(
name="mGBA Suite - BIOS",
rom='mgba-suite.gba',
code='''
key down true
frame 90
key down false
key a true
frame 20
key a false
screenshot ./.tests_screenshots/mgba_suite_bios.png
''',
screenshot='mgba_suite_bios.png',
),
Test(
name="mGBA Suite - DMA", # NOTE: Only passing 1156/1256 tests for now.
rom='mgba-suite.gba',
code='''
key down true
frame 100
key down false
key a true
frame 20
key a false
frame 130
screenshot ./.tests_screenshots/mgba_suite_dma.png
''',
screenshot='mgba_suite_dma.png',
),

# Hades Tests
# https://github.com/Arignir/Hades-Tests
Test(
Expand Down

0 comments on commit 1685837

Please sign in to comment.