diff --git a/joeylib/src/jIIgs.c b/joeylib/src/jIIgs.c index e392eb4..d33ce78 100644 --- a/joeylib/src/jIIgs.c +++ b/joeylib/src/jIIgs.c @@ -28,6 +28,7 @@ #include #include #include +#include #undef false #undef true @@ -86,10 +87,6 @@ static byte *BORDER = (byte *)0xE0C034L; static byte _jlBorderSaved; -static jint16 _jlMyID; -static jint16 _jlMemID; -static jint16 _jlMusicMemID; -static Handle _jlSHRShadowHandle; static jint16 _jlHertz; @@ -97,7 +94,7 @@ static jint16 _jlHertz; #define JOEY_CHECK_TOOL_ERROR(w) if (_toolErr) _jlDieWithToolError(w, _toolErr); void _jlDieWithToolError(const char *what, int err) { char message[256]; - sprintf(message, "Tool Error %04X %s", err, what); + sprintf(message, "Tool Error $%04X %s", err, what); jlUtilDie(message); } @@ -265,29 +262,54 @@ bool _jlSoundLoad(jlSoundT **sound, char *filename) { } -void jlSoundMusicContinue(void) { +void jlSoundMidiContinue(void) { + //***TODO*** +} + + +bool jlSoundMidiIsPlaying(void) { + //***TODO*** + return false; +} + + +void jlSoundMidiPause(void) { + //***TODO*** +} + + +void jlSoundMidiPlay(char *name) { + (void)name; + //***TODO*** +} + + +void jlSoundMidiStop(void) { + //***TODO*** +} + + +void jlSoundModContinue(void) { NTPContinueMusic(); } -bool jlSoundMusicIsPlaying(void) { +bool jlSoundModIsPlaying(void) { return (NTPGetPlayingMusic() != 0xFFFF); } -void jlSoundMusicPause(void) { +void jlSoundModPause(void) { NTPPauseMusic(); } -void jlSoundMusicPlay(char *name) { +void jlSoundModPlay(char *name) { char *temp = jlUtilMakePathname(name, "ntp"); _jlPascalStringT file; _jlSetPascalString(file, temp); - //strcpy(file.text, temp); - //file.length = strlen(temp); - NTPStartUp(_jlMusicMemID); + NTPStartUp(userid()); JOEY_CHECK_TOOL_ERROR("NTPStartup") NTPLoadOneMusic((Pointer)&file); JOEY_CHECK_TOOL_ERROR("NTPLoadOneMusic") @@ -296,7 +318,7 @@ void jlSoundMusicPlay(char *name) { } -void jlSoundMusicStop(void) { +void jlSoundModStop(void) { NTPShutDown(); JOEY_CHECK_TOOL_ERROR("NTPShutDown") } @@ -332,15 +354,15 @@ void jlUtilShutdown(void) { asmStop(); // Shutdown tools - /* - MSShutDown(); // MIDI Synth - SoundShutDown(); // Sound Tool Set - */ - UnloadOneTool(0xDD); // NinjaTracker - MTShutDown(); // Misc Tools - DisposeAll(_jlMemID); - MMShutDown(_jlMyID); // Memory Manager - TLShutDown(); // Tool Locator + NTPShutDown(); // NinjaTracker + UnloadOneTool(222); + MSShutDown(); // MIDI Synth + UnloadOneTool(35); + SoundShutDown(); // Sound Tool Set + MTShutDown(); // Misc Tools + DisposeAll(userid()); + MMShutDown(userid()); // Memory Manager + TLShutDown(); // Tool Locator jlUtilDie("Clean Exit."); } @@ -348,7 +370,7 @@ void jlUtilShutdown(void) { void jlUtilStartup(char *appTitle) { - handle ZeroPageHandle; + handle tempHandle; ptr ZeroPagePtr; InitialLoadOutputRec initialLoad; char *temp; @@ -356,44 +378,59 @@ void jlUtilStartup(char *appTitle) { (void)appTitle; // Unused on IIgs - // Start up neded tools TLStartUp(); // Tool Locator - _jlMyID = MMStartUp(); // Memory Manager - _jlMemID = _jlMyID | 0x0100; // Set aux ID to 1. - _jlMusicMemID = _jlMyID | 0x0200; // Set music ID. + JOEY_CHECK_TOOL_ERROR("TLStartUp") + MMStartUp(); // Memory Manager + JOEY_CHECK_TOOL_ERROR("MMStartUp") MTStartUp(); // Misc Tools + JOEY_CHECK_TOOL_ERROR("MTStartUp") - /* - ZeroPageHandle = NewHandle((Long)DPTotal, (Word)_jlMyMemID, (Word)attrBank | attrPage | attrFixed | attrLocked, (Long)0); - ZeroPagePtr = *ZeroPageHandle; - SoundStartUp((word)ZeroPagePtr + DPForSound); // Sound Tool Set + // Reserve shadow area for SHR + tempHandle = NewHandle((LongWord)0x8000, userid(), (Word)(attrLocked | attrFixed | attrAddr | attrBank), (Pointer)0x012000); + JOEY_CHECK_TOOL_ERROR("NewHandle SHR") + + // Sound Tool Set + tempHandle = NewHandle((Long)DPTotal, userid(), (Word)(attrLocked | attrFixed | attrPage | attrBank), (Long)0); + JOEY_CHECK_TOOL_ERROR("NewHandle Sound") + ZeroPagePtr = *tempHandle; + SoundStartUp((word)ZeroPagePtr + DPForSound); + + // Try to load MidiSynth from SYSTEM:TOOLS + LoadOneTool(35, 0); + if (_toolErr) { + // Not there. Try to manually load it from our disk. + temp = jlUtilMakePathname("Tool035", NULL); + _jlSetPascalString(toolFile, temp); + initialLoad = InitialLoad(userid(), (Pointer)&toolFile, 0); + JOEY_CHECK_TOOL_ERROR("Tool035") + SetTSPtr(0, 35, initialLoad.startAddr); + MSBootInit(); + JOEY_CHECK_TOOL_ERROR("MSBootInit") + } MSStartUp(); // MIDI Synth - */ + JOEY_CHECK_TOOL_ERROR("MSStartUp") // Try to load NinjaTrackerPlus from SYSTEM:TOOLS - LoadOneTool(0xDE, 0); + LoadOneTool(222, 0); if (_toolErr) { // Not there. Try to manually load it from our disk. temp = jlUtilMakePathname("Tool222", NULL); _jlSetPascalString(toolFile, temp); - initialLoad = InitialLoad(_jlMyID, (Pointer)&toolFile, 0); + initialLoad = InitialLoad(userid(), (Pointer)&toolFile, 0); JOEY_CHECK_TOOL_ERROR("Tool222") SetTSPtr(0, 222, initialLoad.startAddr); NTPBootInit(); + JOEY_CHECK_TOOL_ERROR("NTPBootInit") } - // Reserve shadow area for SHR - _jlSHRShadowHandle = NewHandle((LongWord)0x8000, (Word)_jlMemID, (Word)(attrLocked + attrFixed + attrBank + attrAddr), (Pointer)0x012000); - JOEY_CHECK_TOOL_ERROR("NewHandle") - // Start assembly module _jlHertz = (int)ReadBParam((Word)0x1D) == 0 ? 60 : 50; // Is this a PAL or NTSC machine? - asmStart(_jlMyID, _jlHertz / 10); + asmStart(userid(), _jlHertz / 10); // SHR on asmGrOn(); - // If you work out the Screen Conrol Bytes, everything we want is zero. + // If you work out the Screen Conrol Bytes, everything we want is zero. // So we just memset all 200 of them. memset(SHRSCB, 0, 200); diff --git a/joeylib/src/jSDL2.c b/joeylib/src/jSDL2.c index bd81f20..aa8d74d 100644 --- a/joeylib/src/jSDL2.c +++ b/joeylib/src/jSDL2.c @@ -501,25 +501,53 @@ bool _jlSoundLoad(jlSoundT **sound, char *filename) { } -void jlSoundMusicContinue(void) { +void jlSoundMidiContinue(void) { + //***TODO*** +} + + +bool jlSoundMidiIsPlaying(void) { + //***TODO*** + return false; +} + + + +void jlSoundMidiPause(void) { + //***TODO*** +} + + +void jlSoundMidiPlay(char *name) { + (void)name; + //***TODO*** +} + + +void jlSoundMidiStop(void) { + //***TODO*** +} + + +void jlSoundModContinue(void) { Mix_ResumeMusic(); } -bool jlSoundMusicIsPlaying(void) { +bool jlSoundModIsPlaying(void) { return (bool)Mix_PlayingMusic(); } -void jlSoundMusicPause(void) { +void jlSoundModPause(void) { Mix_PauseMusic(); } -void jlSoundMusicPlay(char *name) { +void jlSoundModPlay(char *name) { if (_jlMusicHandle != NULL) { - jlSoundMusicStop(); + jlSoundModStop(); } _jlMusicHandle = Mix_LoadMUS(jlUtilMakePathname(name, "mod")); if (_jlMusicHandle != NULL) { @@ -530,8 +558,8 @@ void jlSoundMusicPlay(char *name) { } -void jlSoundMusicStop(void) { - if (jlSoundMusicIsPlaying()) { +void jlSoundModStop(void) { + if (jlSoundModIsPlaying()) { Mix_HaltMusic(); } if (_jlMusicHandle != NULL) { diff --git a/joeylib/src/joey.h b/joeylib/src/joey.h index 9823d5a..116f534 100644 --- a/joeylib/src/joey.h +++ b/joeylib/src/joey.h @@ -275,7 +275,7 @@ char jlKeyRead(void); void jlKeyWaitForAny(void); void jlPaletteDefault(void); //***TODO*** Treat palettes like we do "surfaces" - allow changing STAs or display -void jlPaletteSet(byte index, byte r, byte g, byte b); +void jlPaletteSet(byte index, byte r, byte g, byte b); //***TODO*** Really need a matching "get" void jlPaletteSetFromImg(jlImgT *img); void jlSoundFree(jlSoundT *sound); @@ -283,11 +283,16 @@ bool jlSoundIsPlaying(jlSoundT *sound); #define jlSoundLoad(sound, filename) _jlSoundLoad((jlSoundT **)&(sound), filename) // Syntatic Sugar bool _jlSoundLoad(jlSoundT **sound, char *filename); -void jlSoundMusicContinue(void); -bool jlSoundMusicIsPlaying(void); -void jlSoundMusicPause(void); -void jlSoundMusicPlay(char *name); -void jlSoundMusicStop(void); +void jlSoundMidiContinue(void); +bool jlSoundMidiIsPlaying(void); +void jlSoundMidiPause(void); +void jlSoundMidiPlay(char *name); +void jlSoundMidiStop(void); +void jlSoundModContinue(void); +bool jlSoundModIsPlaying(void); +void jlSoundModPause(void); +void jlSoundModPlay(char *name); +void jlSoundModStop(void); void jlSoundPlay(jlSoundT *sound); void jlStnFree(jlStnT *stn); diff --git a/joeylib/src/test.c b/joeylib/src/test.c index d9b2e3a..ece70c6 100644 --- a/joeylib/src/test.c +++ b/joeylib/src/test.c @@ -282,17 +282,26 @@ void lineTest(void) { void musicTest(void) { jlImgT *kanga = NULL; + jlImgT *font = NULL; if (!jlImgLoad(kanga, "kanga")) jlUtilDie("Unable to load kanga.img!"); + if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!"); jlImgDisplay(kanga); jlDisplayPresent(); - jlSoundMusicPlay("music"); + jlSoundModPlay("music"); - jlKeyWaitForAny(); + while (!jlKeyPressed()) { + printAt(font, NULL, 1, 1, "%dx%d %d %d ", jlGameGetAxis(0), jlGameGetAxis(1), jlGameGetButton(0), jlGameGetButton(1)); + jlDisplayPresent(); + } + jlKeyRead(); - jlSoundMusicStop(); + jlSoundModStop(); + + jlImgFree(font); + jlImgFree(kanga); }