From 9ef6f855f9423d90032043de41e2f3f58ae8cfa0 Mon Sep 17 00:00:00 2001 From: dwsJason Date: Sat, 24 Nov 2018 16:48:15 -0500 Subject: [PATCH] ntp: test code in-place, NTP is actually playing the samerica song --- asm/ntp.s | 44 +++++++++--- include/config.h | 4 +- include/game.h | 24 ++++++- include/system.h | 48 ++++++++++++-- src/dat_snd.c | 16 +++++ src/game.c | 44 +++++++++--- src/syssnd.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 322 insertions(+), 27 deletions(-) diff --git a/asm/ntp.s b/asm/ntp.s index 22fccb2..955dded 100644 --- a/asm/ntp.s +++ b/asm/ntp.s @@ -22,8 +22,6 @@ DummyNTP start ASM_CODE * NTPprepare start ASM_CODE -aNTPprepare EQU ntpplayer - lda 4,s tax lda 6,s @@ -38,7 +36,8 @@ aNTPprepare EQU ntpplayer lda #0 sta 1,s - jsl aNTPprepare +ntpb0 entry + jsl >$000000 ; NTPprepare bcc okgo @@ -59,8 +58,6 @@ okgo pla * NTPplay start ASM_CODE -aNTPplay EQU ntpplayer+3 - lda 4,s tax lda 2,s @@ -69,7 +66,8 @@ aNTPplay EQU ntpplayer+3 sta 3,s pla txa - jmp >aNTPplay +ntpb1 entry + jml >$000003 ; NTPplay *------------------------------------------------------------------------------- end @@ -82,9 +80,8 @@ aNTPplay EQU ntpplayer+3 * NTPstop start ASM_CODE -aNTPstop EQU ntpplayer+6 - - jmp >aNTPstop +ntpb2 entry + jml >$000006 ; NTPstop *------------------------------------------------------------------------------- end @@ -129,6 +126,35 @@ NTPforcesongpos start ASM_CODE rtl *------------------------------------------------------------------------------- end + +* +* void SetAudioBank(u8 bankNo); +* +SetAudioBank start ASM_CODE + +iBank equ 4 + + sep #$30 + + lda iBank,s + + sta >ntpb0+3 + sta >ntpb1+3 + sta >ntpb2+3 + + rep #$30 + + lda 2,s + sta iBank,s + lda 1,s + sta iBank-1,s + + pla + + rtl +*------------------------------------------------------------------------------- + end + diff --git a/include/config.h b/include/config.h index ee48015..529a3bd 100644 --- a/include/config.h +++ b/include/config.h @@ -29,8 +29,8 @@ #undef ENABLE_JOYSTICK /* sound support */ -//#define ENABLE_SOUND -#undef ENABLE_SOUND +#define ENABLE_SOUND +//#undef ENABLE_SOUND /* cheats support */ #define ENABLE_CHEATS diff --git a/include/game.h b/include/game.h index dc20675..a0b45cf 100644 --- a/include/game.h +++ b/include/game.h @@ -74,6 +74,26 @@ extern void game_toggleCheat(U8); #endif #ifdef ENABLE_SOUND +#ifdef IIGS + +extern sound_t WAV_GAMEOVER; +extern sound_t WAV_SBONUS2; +extern sound_t WAV_BULLET; +extern sound_t WAV_BOMBSHHT; +extern sound_t WAV_EXPLODE; +extern sound_t WAV_STICK; +extern sound_t WAV_WALK; +extern sound_t WAV_CRAWL; +extern sound_t WAV_JUMP; +extern sound_t WAV_PAD; +extern sound_t WAV_BOX; +extern sound_t WAV_BONUS; +extern sound_t WAV_SBONUS1; +extern sound_t WAV_DIE; +extern sound_t WAV_ENTITY[]; + +#else + extern sound_t *WAV_GAMEOVER; extern sound_t *WAV_SBONUS2; extern sound_t *WAV_BULLET; @@ -89,7 +109,9 @@ extern sound_t *WAV_BONUS; extern sound_t *WAV_SBONUS1; extern sound_t *WAV_DIE; extern sound_t *WAV_ENTITY[]; -#endif + +#endif /* IIGS */ +#endif /* ENABLE_SOUND */ #endif diff --git a/include/system.h b/include/system.h index 38de33a..68a3bef 100644 --- a/include/system.h +++ b/include/system.h @@ -129,6 +129,38 @@ extern U8 syskbd_fire; * sound section */ #ifdef ENABLE_SOUND + +#ifdef IIGS +typedef int sound_t; + +/* + * Output from the Mr.Audio Bank packer + */ +enum { + SND_BOMBSHHT, + SND_BONUS, + SND_BOX, + SND_BULLET, + SND_CRAWL, + SND_DIE, + SND_ENT0, + SND_ENT1, + SND_ENT2, + SND_ENT3, + SND_ENT4, + SND_ENT6, + SND_ENT8, + SND_EXPLODE, + SND_JUMP, + SND_PAD, + SND_SBONUS1, + SND_SBONUS2, + SND_STICK, + SND_WALK, +}; + + +#else typedef struct { #ifdef DEBUG char *name; @@ -137,19 +169,27 @@ typedef struct { U32 len; U8 dispose; } sound_t; +#endif extern void syssnd_init(void); extern void syssnd_shutdown(void); extern void syssnd_vol(S8); extern void syssnd_toggleMute(void); +#ifdef IIGS +extern S8 syssnd_play(sound_t, S8); +extern void syssnd_stopsound(sound_t); +extern int syssnd_isplaying(sound_t); +extern void syssnd_free(sound_t); +#else extern S8 syssnd_play(sound_t *, S8); +extern void syssnd_stopsound(sound_t *); +extern int syssnd_isplaying(sound_t *); +extern void syssnd_free(sound_t *); +extern sound_t *syssnd_load(char *name); +#endif extern void syssnd_pause(U8, U8); extern void syssnd_stopchan(S8); -extern void syssnd_stopsound(sound_t *); extern void syssnd_stopall(); -extern int syssnd_isplaying(sound_t *); -extern sound_t *syssnd_load(char *name); -extern void syssnd_free(sound_t *); #endif /* diff --git a/src/dat_snd.c b/src/dat_snd.c index 7220f0a..b3eefdb 100644 --- a/src/dat_snd.c +++ b/src/dat_snd.c @@ -22,6 +22,21 @@ #include "system.h" +#ifdef IIGS + +sound_t WAV_WAA; +sound_t WAV_BOMB; +sound_t WAV_BULLET; +sound_t WAV_WALK; +sound_t WAV_JUMP; +sound_t WAV_TING; +sound_t WAV_BOMBSHHT; +sound_t WAV_BONUS; +sound_t WAV_SHHT; +sound_t WAV_BOX; +sound_t WAV_DDDING; + +#else sound_t *WAV_WAA; sound_t *WAV_BOMB; sound_t *WAV_BULLET; @@ -33,6 +48,7 @@ sound_t *WAV_BONUS; sound_t *WAV_SHHT; sound_t *WAV_BOX; sound_t *WAV_DDDING; +#endif /* IIGS */ #endif /* ENABLE_SOUND */ diff --git a/src/game.c b/src/game.c index 7e69305..f0d6a8e 100644 --- a/src/game.c +++ b/src/game.c @@ -102,23 +102,42 @@ hscore_t game_hscores[8] = { { 1000, "ANDYSPLEEN" } }; #endif + #ifdef ENABLE_SOUND +#ifdef IIGS +sound_t WAV_GAMEOVER; +sound_t WAV_SBONUS2; +//sound_t WAV_BULLET; +//sound_t WAV_BOMBSHHT; +sound_t WAV_EXPLODE; +sound_t WAV_STICK; +//sound_t WAV_WALK; +sound_t WAV_CRAWL; +//sound_t WAV_JUMP; +sound_t WAV_PAD; +//sound_t WAV_BOX; +//sound_t WAV_BONUS; +sound_t WAV_SBONUS1; +sound_t WAV_DIE; +sound_t WAV_ENTITY[10]; +#else sound_t *WAV_GAMEOVER; sound_t *WAV_SBONUS2; -sound_t *WAV_BULLET; -sound_t *WAV_BOMBSHHT; +//sound_t *WAV_BULLET; +//sound_t *WAV_BOMBSHHT; sound_t *WAV_EXPLODE; sound_t *WAV_STICK; -sound_t *WAV_WALK; +//sound_t *WAV_WALK; sound_t *WAV_CRAWL; -sound_t *WAV_JUMP; +//sound_t *WAV_JUMP; sound_t *WAV_PAD; -sound_t *WAV_BOX; -sound_t *WAV_BONUS; +//sound_t *WAV_BOX; +//sound_t *WAV_BONUS; sound_t *WAV_SBONUS1; sound_t *WAV_DIE; sound_t *WAV_ENTITY[10]; -#endif +#endif /*IIGS*/ +#endif /*ENABLE_SOUND*/ /* @@ -187,6 +206,7 @@ game_toggleCheat(U8 nbr) void game_setmusic(char *name, U8 loop) { +#ifndef IIGS U8 channel; if (music_snd) @@ -197,13 +217,16 @@ game_setmusic(char *name, U8 loop) music_snd->dispose = TRUE; /* music is always "fire and forget" */ channel = syssnd_play(music_snd, loop); } +#endif } void game_stopmusic(void) { +#ifndef IIGS syssnd_stopsound(music_snd); music_snd = NULL; +#endif } #endif @@ -387,15 +410,11 @@ frame(void) game_state = PLAY0; return; - - case PAUSE_PRESSED1: screen_pause(TRUE); game_state = PAUSE_PRESSED1B; break; - - case PAUSE_PRESSED1B: if (control_status & CONTROL_PAUSE) return; @@ -766,6 +785,7 @@ loaddata() * * tune[0-5].wav not cached */ + #ifndef IIGS WAV_GAMEOVER = syssnd_load("sounds/gameover.wav"); WAV_SBONUS2 = syssnd_load("sounds/sbonus2.wav"); WAV_BULLET = syssnd_load("sounds/bullet.wav"); @@ -789,6 +809,8 @@ loaddata() WAV_ENTITY[6] = syssnd_load("sounds/ent6.wav"); WAV_ENTITY[7] = syssnd_load("sounds/ent7.wav"); WAV_ENTITY[8] = syssnd_load("sounds/ent8.wav"); + #endif + #endif } diff --git a/src/syssnd.c b/src/syssnd.c index 6d4f675..1420dff 100644 --- a/src/syssnd.c +++ b/src/syssnd.c @@ -33,6 +33,174 @@ segment "system"; + +#ifdef IIGS + +char* pNtpDriver = NULL; +char* pNtpSong = NULL; + +extern char ntpplayer_lz4; +extern char samerica_lz4; + +void SetAudioBank(char bankNo); +void NTPstop(void); +void NTPplay(int bPlayOnce); +int NTPprepare(void* pNTPData); + +void +syssnd_init(void) +{ + U32* handle = NULL; + printf("syssnd_init\n"); + // Allocate a buffer for the NTPAudio Driver + // and to place the various NTP songs that will play + printf("Alloc NTPDriver\n"); + handle = (U32*)NewHandle(0x10000, userid(), 0xC014, 0); + if (toolerror()) + { + printf("Unable to allocate Audio Driver Mem\n"); + printf("Game can't run\n"); + sys_sleep(5000); // Wait 5 seconds + exit(1); + } + printf("SUCCESS\n"); + + pNtpDriver = (char*)*handle; + pNtpSong = pNtpDriver + 0x8000; + + //printf("%p\n", pNtpDriver ); + //printf("%p\n", pNtpSong ); + + printf("Decompress NTP Driver\n"); + LZ4_Unpack(pNtpDriver, &ntpplayer_lz4); + printf("Decompress samerica\n"); + LZ4_Unpack(pNtpSong, &samerica_lz4); + + printf("SetAudioBank\n"); + SetAudioBank( (*handle)>>16 ); + + printf("NTPprepare\n"); + + if (NTPprepare(pNtpSong)) + { + printf("NTPprepare failed\n"); + } + else + { + printf("NTPplay\n"); + NTPplay(0); + } + +} + +/* + * Shutdown + */ +void +syssnd_shutdown(void) +{ + printf("syssnd_shutdown\n"); + //if (!isAudioActive) return; + //isAudioActive = FALSE; +} + +/* + * Toggle mute + * + * When muted, sounds are still managed but not sent to the dsp, hence + * it is possible to un-mute at any time. + */ +void +syssnd_toggleMute(void) +{ + printf("syssnd_toggleMute\n"); +} + +void +syssnd_vol(S8 d) +{ + printf("syssnd_vol: %d\n", d); +} + +/* + * Play a sound + * + * loop: number of times the sound should be played, -1 to loop forever + * returns: channel number, or -1 if none was available + * + * NOTE if sound is already playing, simply reset it (i.e. can not have + * twice the same sound playing -- tends to become noisy when too many + * bad guys die at the same time). + */ +S8 +syssnd_play(sound_t sound, S8 loop) +{ + printf("syssnd_play\n"); + return 0; +} + +/* + * Pause + * + * pause: TRUE or FALSE + * clear: TRUE to cleanup all sounds and make sure we start from scratch + */ +void +syssnd_pause(U8 pause, U8 clear) +{ + printf("syssnd_pause\n"); +} + +/* + * Stop a channel + */ +void +syssnd_stopchan(S8 chan) +{ + printf("syssnd_stopchan\n"); +} + +/* + * Stop a sound + */ +void +syssnd_stopsound(sound_t sound) +{ + printf("syssnd_stopsound\n"); +} + +/* + * See if a sound is playing + */ +int +syssnd_isplaying(sound_t sound) +{ + printf("syssnd_isplaying\n"); + return 0; +} + + +/* + * Stops all channels. + */ +void +syssnd_stopall(void) +{ + printf("syssnd_stopall\n"); +} + +/* + * + */ +void +syssnd_free(sound_t s) +{ + printf("syssnd_free\n"); +} + + +#else + #define ADJVOL(S) (((S)*sndVol)/SDL_MIX_MAXVOLUME) static U8 isAudioActive = FALSE; @@ -435,6 +603,7 @@ sdlRWops_close(SDL_RWops *context) return 0; } +#endif /* IIGS */ #endif /* ENABLE_SOUND */ /* eof */