Skip to content

Restore Special Wave from AddMusicM#38

Open
KungFuFurby wants to merge 52 commits intomasterfrom
0031-special-wave-restoration
Open

Restore Special Wave from AddMusicM#38
KungFuFurby wants to merge 52 commits intomasterfrom
0031-special-wave-restoration

Conversation

@KungFuFurby
Copy link
Owner

@KungFuFurby KungFuFurby commented Feb 2, 2021

This merge request closes #31.

  • Implement SPC-side
  • Implement C++-side

These pull requests, once merged, will require this pull request be updated:

Special Wave from AddMusicM has been restored! However, the SRCN ID must be
initialized first, and a C++-side modification is pending to perform this task
automatically.
These are here to avoid BRR overwriting chaose caused by the special wave being
more dependent on the SRCN ID, and I accidentally left a security hole in this
VCMD in the process of doing so, hence this patch.
The BRR file was copied from AddMusicM incorrectly, accidentally omitting the
opening BRR block. This affected how the PWM played, and thus did not make it
authentic to AddMusicM.
Due to the presence of a gate at the beginning, there was no need for this
opcode at the end of the routine, since it was already there at the beginning.
Turns out there was a misunderstanding about the #AMM sample group: its only
purpose is to provide padding so that sample IDs $20 and up are allocated to the
custom samples used in an AddMusicM song. Two new sample groups were going to be
created via overwriting sample ID $09, but there is a conflict with the bonus
end song, a default global song at that, meaning that it would not be feasible
to have this done by default.

Thus, SPECIALWAVE.brr has been reallocated from sample ID $1D to sample ID $14,
with $1D being the starting expected sample ID plus $09, which was the source of
the original misinterpretation... as a zero was used.
Due to an optimization made in the master branch to auto-reload $46 to X upon
execution of a VCMD ($DA and up), this opcode is redundant, which in turn will
save bytes down the road.
@KungFuFurby KungFuFurby added spc-side Involves the SPC700 code. documentation Improvements or additions to documentation labels Apr 1, 2021
@KungFuFurby KungFuFurby mentioned this pull request Apr 2, 2021
15 tasks
@KungFuFurby KungFuFurby added the addmusicm Involves an adaptation that originates from AddMusicM. label Apr 2, 2021
The last piece of the puzzle to fully implement the Special Pulse Wave feature
is complete.

This commit closes #31.
@KungFuFurby KungFuFurby marked this pull request as ready for review June 1, 2021 02:29
@KungFuFurby KungFuFurby added the c++-side Involves the AddMusicK program itself in some way. label Jun 1, 2021
@KungFuFurby
Copy link
Owner Author

The last thing I have to do is to update the AddmusicM porting notes, because the default sample set used with AddMusicM is not compatible with the Bonus End song with the Special Pulse Wave in its default ID, and thus some updating has to be done. Plus, in hindsight, I have to program the conversions from the AMM special wave commands.

Sometimes things get way tricker than they're supposed to be when it comes to
analyzing what memory locations are supposed to be used where, simply because
the way it is specified in the assembly is a bit non-intuitive. Although the
final compiled result can't be helped in this fashion, the raw assembly code to
compile, on the other hand, can, so that the user can more easily search for
what memory locations are used where.

This commit is specific to the changes done to the special pulse wave
restoration, which used a setp/clrp section.
@KungFuFurby KungFuFurby added the new-vcmd Involves adding at least one VCMD to the collection. label Jun 25, 2021
@KungFuFurby KungFuFurby mentioned this pull request Jun 25, 2021
3 tasks
…file

Because of an incompatibility in the sample ID, this is required. This is also
the last piece of the puzzle for a full restoration.

This commit closes #31.
In addition to saving a few bytes, this allows less opcodes to be executed per
loop. It does require that the initial pointer not be offset by a byte, since it
is instead done by the dbnz opcode, which omits the zero offset.
Looks like this code had some room for optimization. I got to take advantage of
some of the SPC700's specialties in the opcode department in order to shrink
this down. Plus, no more need to use an array.
…ation

The sources themselves were added in during the merge commit to avoid HTML table
misalignments.
GetCommandData is no longer needed since it is pre-fetched by cmdFA, so we get
rid of them.
An oversight in the code meant that SRCN IDs above $3F were reading the
incorrect pointers in the sample directory, causing corruption of the samples.
We only need one jmp within a certain radius of code if it goes to the same
place.
Now that we're clearing a strip of 16 bytes, we can use a later loop to save
some memory.
This is one byte cheaper than using shifting opcodes with regards to setting up
the offset to the sample directory.
Courtesy of the relocation of the code for VCMD $FA $10.
…g $016B

This does the same thing as checking for a zero in $016B since we already stored
there. The accumulator is overwritten, but we're not really using it afterwards,
so we save two bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addmusicm Involves an adaptation that originates from AddMusicM. c++-side Involves the AddMusicK program itself in some way. documentation Improvements or additions to documentation new-vcmd Involves adding at least one VCMD to the collection. spc-side Involves the SPC700 code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore the Special Wave from AddMusicM

1 participant