Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase bios_size to 1MB #630

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/mips/modplayer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ timewarped.o \

include ../common.mk

timewarped.o: timewarped.hit
$(PREFIX)-objcopy -I binary --set-section-alignment .data=4 --rename-section .data=.rodata,alloc,load,readonly,data,contents -O $(FORMAT) -B mips timewarped.hit timewarped.o
# convert HIT files to bin
%.o: %.hit
$(PREFIX)-objcopy -I binary --set-section-alignment .data=4 --rename-section .data=.rodata,alloc,load,readonly,data,contents -O $(FORMAT) -B mips $< $@
6 changes: 5 additions & 1 deletion src/mips/modplayer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ This code is a reverse engineering of the file MODPLAY.BIN, located in the zip f

The current API behaves roughly the same the original one. The code should provide information about the alterations made to it.

The demo song, "timewarped", written by [Jesster](https://modarchive.org/index.php?request=view_profile&query=69138), comes from [the modarchive](https://modarchive.org/index.php?request=view_by_moduleid&query=106481) with a [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/) license, allowing non-commercial adaptations. The file has been converted from MOD to HIT using the MODCONV.EXE software provided by Hitmen.
The demo song, "timewarped", written by [Jester](https://modarchive.org/index.php?request=view_profile&query=69138), comes from [the modarchive](https://modarchive.org/index.php?request=view_by_moduleid&query=106481) with a [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/) license, allowing non-commercial adaptations. The file has been converted from MOD to HIT using the MODCONV.EXE software provided by Hitmen.

# Creating MOD files

You can use the opensource [openMPT](https://openmpt.org/) to create MOD (OpenTracker) files. Keep in mind that Hitmen's `MODCONV.EXE` utility only allows 16 channels MODs.
23 changes: 20 additions & 3 deletions src/mips/modplayer/modplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ static void SPUUploadInstruments(uint32_t SpuAddr, const uint8_t* data, uint32_t

static void SPUUnMute() { SPU_CTRL = 0xc000; }

static void SPUSetVoiceVolume(int voiceID, uint16_t left, uint16_t right) {
SPU_VOICES[voiceID].volumeLeft = left >> 2;
SPU_VOICES[voiceID].volumeRight = right >> 2;
static uint32_t s_masterVolume = 16384;

static void SPUSetVoiceVolume(int voiceID, uint32_t left, uint32_t right) {
SPU_VOICES[voiceID].volumeLeft = (left * s_masterVolume) >> 16;
SPU_VOICES[voiceID].volumeRight = (right * s_masterVolume) >> 16;
}

static void SPUSetStartAddress(int voiceID, uint32_t spuAddr) { SPU_VOICES[voiceID].sampleStartAddr = spuAddr >> 3; }
Expand Down Expand Up @@ -804,3 +806,18 @@ void MOD_PlayNote(unsigned channel, unsigned sampleID, unsigned note, int16_t vo
int32_t newPeriod = channelData->period = MOD_PeriodTable[note];
SETVOICESAMPLERATE(channel, newPeriod);
}

void MOD_PlaySoundEffect(unsigned channel, unsigned sampleID, unsigned note, int16_t volume) {
uint32_t s_prevVolume = s_masterVolume;
s_masterVolume = 16384;
MOD_PlayNote( channel, sampleID, note, volume);
s_masterVolume = s_prevVolume;
}

void MOD_SetMusicVolume(uint32_t musicVolume) {
s_masterVolume = musicVolume;
const unsigned channels = MOD_Channels;
for (unsigned channel = 0; channel < MOD_Channels; channel++) {
SETVOICEVOLUME(channel, s_channelData[channel].volume);
}
}
7 changes: 7 additions & 0 deletions src/mips/modplayer/modplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,12 @@ void MOD_Relocate(uint8_t* buffer);
// setting the volume of the voice to 0.
void MOD_PlayNote(unsigned voiceID, unsigned sampleID, unsigned note, int16_t volume);

// Plays a sound effect
// As opposed to MOD_PlayNote(), MOD_PlaySoundEffect()'s volume is absolute. 0 == mute, 63 == max SPU voice volume
void MOD_PlaySoundEffect(unsigned channel, unsigned sampleID, unsigned note, int16_t volume);

// Added API to reset the SPU and silence everything.
void MOD_Silence();

// Set MOD Volume to musicVolume, where musicVolume is between 0 and 65535.
void MOD_SetMusicVolume(uint32_t musicVolume);