Skip to content

Commit

Permalink
Test FUN_8c010bae
Browse files Browse the repository at this point in the history
  • Loading branch information
lhsazevedo committed Apr 30, 2024
1 parent 49c617f commit 8762a95
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
3 changes: 3 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ $sh4objtest "tests/0100bc_sound/010972_setAdxVol.php" "build/output/_000188_8c01
$sh4objtest "tests/0100bc_sound/010a40_FUN_adxVol.php" "build/output/0100bc_sound_src.obj"
$sh4objtest "tests/0100bc_sound/010a40_FUN_adxVol.php" "build/output/_000188_8c0100bc_sound_c.obj"

$sh4objtest "tests/0100bc_sound/010bae_FUN.php" "build/output/0100bc_sound_src.obj"
$sh4objtest "tests/0100bc_sound/010bae_FUN.php" "build/output/_000188_8c0100bc_sound_c.obj"

# 015ab8_title
assemble src/asm/decompiled/015ab8_title.src
$sh4objtest "tests/015ab8_title.php" "build/output/015ab8_title_src.obj"
Expand Down
3 changes: 3 additions & 0 deletions src/non_matching/_000188_8c0100bc_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ void setMidiVolAndInitStruct_8c0109f4(int param1) {
initUknVol_8c0100bc();
}

/* Tested */
void FUN_adxVol_8c010a40() {
/* 8c010a56 */
if ((var_uknAdxVol_8c157a34.flags_0x00 & 0xf) != 0)
Expand Down Expand Up @@ -652,11 +653,13 @@ void FUN_8c010bae(int param1) {
if ((var_uknAdxVol_8c157a34.flags_0x00 & 0xf0) == 0) {
/* 8c010bba */
if (param1 == 0 && (var_uknAdxVol_8c157a34.flags_0x00 & 0xf) != 1) {
/* A */
var_uknAdxVol_8c157a34.flags_0x00 |= 1;
var_uknAdxVol_8c157a34.field_0x04 = (init_uknAdxVol_8c03bd88.field_0x00 - 300) / 90;
var_uknAdxVol_8c157a34.field_0x0c = init_uknAdxVol_8c03bd88.field_0x00 - 990;
}
if (param1 == 1 && (var_uknAdxVol_8c157a34.flags_0x00 & 0xf) != 2) {
/* B */
var_uknAdxVol_8c157a34.flags_0x00 |= 2;
var_uknAdxVol_8c157a34.field_0x08 = (init_uknAdxVol_8c03bd88.field_0x04 - 300) / 90;
var_uknAdxVol_8c157a34.field_0x10 = init_uknAdxVol_8c03bd88.field_0x04 - 990;
Expand Down
2 changes: 0 additions & 2 deletions tests/0100bc_sound/010a40_FUN_adxVol.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ public function test_pathH()
0b1100_0000
);

//$this->shouldWrite($this->addressOf('_init_8c03bd80'), 0b11011111);

$this->call('_FUN_adxVol_8c010a40')->run();
}

Expand Down
68 changes: 68 additions & 0 deletions tests/0100bc_sound/010bae_FUN.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

use Lhsazevedo\Sh4ObjTest\TestCase;

return new class extends TestCase {
public function test_pathNone()
{
$this->resolveSymbols();

$this->initUint32($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 1);

$this->call('_FUN_8c010bae')->with(0)->run();
}

public function test_pathNone2()
{
$this->resolveSymbols();

$this->initUint32($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 0xf0);

$this->call('_FUN_8c010bae')->with(0)->run();
}

public function test_pathNone3()
{
$this->resolveSymbols();

$this->initUint32($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 0xf0);

$this->call('_FUN_8c010bae')->with(3)->run();
}

public function test_pathA()
{
$this->resolveSymbols();

$this->initUint32($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 0b100);
$this->initUint32($this->addressOf('_init_uknAdxVol_8c03bd88') + 0x00, 660);

$this->shouldWrite($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 0b101);
$this->shouldWrite($this->addressOf('_var_uknAdxVol_8c157a34') + 0x04, 4);
$this->shouldWrite($this->addressOf('_var_uknAdxVol_8c157a34') + 0x0c, -330);

$this->call('_FUN_8c010bae')->with(0)->run();
}

public function test_pathB()
{
$this->resolveSymbols();

$this->initUint32($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 0b100);
$this->initUint32($this->addressOf('_init_uknAdxVol_8c03bd88') + 0x04, 660);

$this->shouldWrite($this->addressOf('_var_uknAdxVol_8c157a34') + 0x00, 0b110);
$this->shouldWrite($this->addressOf('_var_uknAdxVol_8c157a34') + 0x08, 4);
$this->shouldWrite($this->addressOf('_var_uknAdxVol_8c157a34') + 0x10, -330);

$this->call('_FUN_8c010bae')->with(1)->run();
}

private function resolveSymbols(): void
{
// Functions
$this->setSize('__divls', 4);
}
};

0 comments on commit 8762a95

Please sign in to comment.