From: Donald H. <qu...@us...> - 2018-12-27 23:00:42
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 50f96e5f4ba3d18257d6429c5f4b1e291fc1cdce (commit) via b8a44977450abb37cd7ed314f606a11374b2f69b (commit) via 1dfa5ab920e5ef7690c5abdb3cd9d37acf82a041 (commit) from 89dd38512099ba3b54c65dc846e2b04994313088 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 50f96e5f4ba3d18257d6429c5f4b1e291fc1cdce Author: Donald Haase <qu...@gm...> Date: Mon Dec 24 21:04:20 2018 -0500 Update debug message to properly print VGA usage. - Thanks Chilly Willy. commit b8a44977450abb37cd7ed314f606a11374b2f69b Author: Donald Haase <qu...@gm...> Date: Sat Dec 22 23:56:53 2018 -0500 Minor cleanup of flashrom stuff. Improved some error returns. commit 1dfa5ab920e5ef7690c5abdb3cd9d37acf82a041 Author: Donald Haase <qu...@gm...> Date: Sat Dec 22 01:00:52 2018 -0500 Minor cleanup to snd_sfxmgr. Now uses appropriate error defines. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/flashrom.c | 11 ++-- kernel/arch/dreamcast/hardware/video.c | 2 +- kernel/arch/dreamcast/include/dc/flashrom.h | 7 +-- kernel/arch/dreamcast/sound/snd_sfxmgr.c | 94 ++++++++++++++--------------- 4 files changed, 54 insertions(+), 60 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/flashrom.c b/kernel/arch/dreamcast/hardware/flashrom.c index 9ca3e07..005b662 100644 --- a/kernel/arch/dreamcast/hardware/flashrom.c +++ b/kernel/arch/dreamcast/hardware/flashrom.c @@ -215,18 +215,19 @@ typedef struct { int flashrom_get_syscfg(flashrom_syscfg_t * out) { uint8 buffer[64]; + int rv; syscfg_t *sc = (syscfg_t *)buffer; /* Get the system config block */ - if(flashrom_load_syscfg(buffer) < 0) - return -1; + rv = flashrom_load_syscfg(buffer); + if(rv < 0) return rv; /* Fill in values from it */ out->language = sc->lang; out->audio = sc->mono == 1 ? 0 : 1; out->autostart = sc->autostart == 1 ? 0 : 1; - return 0; + return FLASHROM_ERR_NONE; } int flashrom_get_region() { @@ -236,13 +237,13 @@ int flashrom_get_region() { /* Find the partition */ if(flashrom_info(FLASHROM_PT_SYSTEM, &start, &size)) { dbglog(DBG_ERROR, "flashrom_get_region: can't find partition 0\n"); - return -1; + return FLASHROM_ERR_NO_PARTITION; } /* Read the first 5 characters of that partition */ if(flashrom_read(start, region, 5) < 0) { dbglog(DBG_ERROR, "flashrom_get_region: can't read partition 0\n"); - return -1; + return FLASHROM_ERR_READ_PART; } /* Now compare against known codes */ diff --git a/kernel/arch/dreamcast/hardware/video.c b/kernel/arch/dreamcast/hardware/video.c index d7c6a4d..2e1ebaf 100644 --- a/kernel/arch/dreamcast/hardware/video.c +++ b/kernel/arch/dreamcast/hardware/video.c @@ -525,7 +525,7 @@ void vid_set_mode_ex(vid_mode_t *mode) { dbglog(DBG_INFO, "vid_set_mode: %ix%i%s %s%s\n", mode->width, mode->height, (mode->flags & VID_INTERLACE) ? "IL" : "", - (mode->flags & VID_PAL) ? "PAL" : "NTSC", + (mode->cable_type == CT_VGA) ? "VGA" : (mode->flags & VID_PAL) ? "PAL" : "NTSC", (mode->generic & DM_MULTIBUFFER) ? " multi-buffered" : ""); vid_border_color(0, 0, 0); diff --git a/kernel/arch/dreamcast/include/dc/flashrom.h b/kernel/arch/dreamcast/include/dc/flashrom.h index 16598c9..649d970 100644 --- a/kernel/arch/dreamcast/include/dc/flashrom.h +++ b/kernel/arch/dreamcast/include/dc/flashrom.h @@ -150,7 +150,7 @@ int flashrom_delete(int offset); \param partid The partition ID to look in. \param blockid The logical block ID to look for. \param buffer_out Space to store the data. Must be at least 60 bytes. - \return 0 on success, <0 on error. + \return 0 on success, <0 on error. \see fr_errs */ int flashrom_get_block(int partid, int blockid, uint8 * buffer_out); @@ -188,7 +188,7 @@ typedef struct flashrom_syscfg { /** \brief Retrieve the current system configuration settings. \param out Storage for the configuration. - \return 0 on success, <0 on error. + \return 0 on success, <0 on error. \see fr_errs */ int flashrom_get_syscfg(flashrom_syscfg_t * out); @@ -210,8 +210,7 @@ int flashrom_get_syscfg(flashrom_syscfg_t * out); This function attempts to find the region of the Dreamcast. It may or may not work on 100% of Dreamcasts, apparently. - \return A region code, or -1 on error. - \see fr_region + \return A region code (0>=) \see fr_region, or error (<0) \see fr_errs . */ int flashrom_get_region(); diff --git a/kernel/arch/dreamcast/sound/snd_sfxmgr.c b/kernel/arch/dreamcast/sound/snd_sfxmgr.c index 359e136..c48fb4f 100644 --- a/kernel/arch/dreamcast/sound/snd_sfxmgr.c +++ b/kernel/arch/dreamcast/sound/snd_sfxmgr.c @@ -29,7 +29,7 @@ typedef struct snd_effect { uint32 len; uint32 rate; uint32 used; - int stereo; + uint16 stereo; uint32 fmt; LIST_ENTRY(snd_effect) list; @@ -37,10 +37,10 @@ typedef struct snd_effect { struct selist snd_effects; -// The next channel we'll use to play sound effects. +/* The next channel we'll use to play sound effects. */ static int sfx_nextchan = 0; -// Our channel-in-use mask. +/* Our channel-in-use mask. */ static uint64 sfx_inuse = 0; /* Unload all loaded samples and free their SPU RAM */ @@ -68,7 +68,12 @@ void snd_sfx_unload_all() { /* Unload a single sample */ void snd_sfx_unload(sfxhnd_t idx) { snd_effect_t * t = (snd_effect_t *)idx; - + + if(idx == SFXHND_INVALID) { + dbglog(DBG_WARNING, "snd_sfx: can't unload an invalid SFXHND\n"); + return; + } + snd_mem_free(t->locl); if(t->stereo) @@ -91,8 +96,9 @@ void snd_sfx_unload(sfxhnd_t idx) { /* Load a sound effect from a WAV file and return a handle to it */ sfxhnd_t snd_sfx_load(const char *fn) { - uint32 fd, len, hz; - uint16 *tmp, chn, bitsize, fmt; + file_t fd; + uint32 len, hz; + uint16 *tmp, stereo, bitsize, fmt; snd_effect_t *t; int ownmem; @@ -100,26 +106,26 @@ sfxhnd_t snd_sfx_load(const char *fn) { fd = fs_open(fn, O_RDONLY); - if(fd == 0) { + if(fd <= FILEHND_INVALID) { dbglog(DBG_WARNING, "snd_sfx: can't open sfx %s\n", fn); - return 0; + return SFXHND_INVALID; } /* Check file magic */ hz = 0; - fs_seek(fd, 8, SEEK_SET); + fs_seek(fd, 0x08, SEEK_SET); fs_read(fd, &hz, 4); if(strncmp((char*)&hz, "WAVE", 4)) { dbglog(DBG_WARNING, "snd_sfx: file is not RIFF WAVE\n"); fs_close(fd); - return 0; + return SFXHND_INVALID; } /* Read WAV header info */ fs_seek(fd, 0x14, SEEK_SET); fs_read(fd, &fmt, 2); - fs_read(fd, &chn, 2); + fs_read(fd, &stereo, 2); fs_read(fd, &hz, 4); fs_seek(fd, 0x22, SEEK_SET); fs_read(fd, &bitsize, 2); @@ -129,7 +135,7 @@ sfxhnd_t snd_sfx_load(const char *fn) { fs_read(fd, &len, 4); dbglog(DBG_DEBUG, "WAVE file is %s, %luHZ, %d bits/sample, %lu bytes total," - " format %d\n", chn == 1 ? "mono" : "stereo", hz, bitsize, len, fmt); + " format %d\n", stereo == 1 ? "mono" : "stereo", hz, bitsize, len, fmt); /* Try to mmap it and if that works, no need to copy it again */ ownmem = 0; @@ -148,12 +154,15 @@ sfxhnd_t snd_sfx_load(const char *fn) { t = malloc(sizeof(snd_effect_t)); memset(t, 0, sizeof(snd_effect_t)); + + /* Common characteristics not impacted by stream type */ + t->rate = hz; + t->stereo = stereo - 1; - if(chn == 1) { + if(stereo == 1) { /* Mono PCM/ADPCM */ t->len = len / 2; /* 16-bit samples */ t->rate = hz; - t->used = 1; t->locl = snd_mem_malloc(len); if(t->locl) @@ -169,7 +178,7 @@ sfxhnd_t snd_sfx_load(const char *fn) { else t->fmt = AICA_SM_16BIT; } - else if(chn == 2 && fmt == 1) { + else if(stereo == 2 && fmt == 1) { /* Stereo PCM */ uint32 i; uint16 * sepbuf; @@ -186,7 +195,6 @@ sfxhnd_t snd_sfx_load(const char *fn) { t->len = len / 4; /* Two stereo, 16-bit samples */ t->rate = hz; - t->used = 1; t->locl = snd_mem_malloc(len / 2); t->locr = snd_mem_malloc(len / 2); @@ -201,7 +209,7 @@ sfxhnd_t snd_sfx_load(const char *fn) { free(sepbuf); } - else if(chn == 2 && fmt == 20) { + else if(stereo == 2 && fmt == 20) { /* Stereo ADPCM */ /* We have to be careful here, because the second sample might not @@ -212,7 +220,6 @@ sfxhnd_t snd_sfx_load(const char *fn) { t->len = len; /* Two stereo, 4-bit samples */ t->rate = hz; - t->used = 1; t->locl = snd_mem_malloc(len / 2); t->locr = snd_mem_malloc(len / 2); @@ -229,15 +236,14 @@ sfxhnd_t snd_sfx_load(const char *fn) { } else { free(t); - t = NULL; + t = SFXHND_INVALID; } if(ownmem) free(tmp); - if(t) { + if(t != SFXHND_INVALID) LIST_INSERT_HEAD(&snd_effects, t, list); - } return (sfxhnd_t)t; } @@ -251,37 +257,25 @@ int snd_sfx_play_chn(int chn, sfxhnd_t idx, int vol, int pan) { if(size >= 65535) size = 65534; - if(!t->stereo) { - cmd->cmd = AICA_CMD_CHAN; - cmd->timestamp = 0; - cmd->size = AICA_CMDSTR_CHANNEL_SIZE; - cmd->cmd_id = chn; - chan->cmd = AICA_CH_CMD_START; - chan->base = t->locl; - chan->type = t->fmt; - chan->length = size; - chan->loop = 0; - chan->loopstart = 0; - chan->loopend = size; - chan->freq = t->rate; - chan->vol = vol; + cmd->cmd = AICA_CMD_CHAN; + cmd->timestamp = 0; + cmd->size = AICA_CMDSTR_CHANNEL_SIZE; + cmd->cmd_id = chn; + chan->cmd = AICA_CH_CMD_START; + chan->base = t->locl; + chan->type = t->fmt; + chan->length = size; + chan->loop = 0; + chan->loopstart = 0; + chan->loopend = size; + chan->freq = t->rate; + chan->vol = vol; + + if(!t->stereo) { chan->pan = pan; snd_sh4_to_aica(tmp, cmd->size); } - else { - cmd->cmd = AICA_CMD_CHAN; - cmd->timestamp = 0; - cmd->size = AICA_CMDSTR_CHANNEL_SIZE; - cmd->cmd_id = chn; - chan->cmd = AICA_CH_CMD_START; - chan->base = t->locl; - chan->type = t->fmt; - chan->length = size; - chan->loop = 0; - chan->loopstart = 0; - chan->loopend = size; - chan->freq = t->rate; - chan->vol = vol; + else { chan->pan = 0; snd_sh4_to_aica_stop(); @@ -300,7 +294,7 @@ int snd_sfx_play_chn(int chn, sfxhnd_t idx, int vol, int pan) { int snd_sfx_play(sfxhnd_t idx, int vol, int pan) { int chn, moved, old; - // This isn't perfect.. but it should be good enough. + /* This isn't perfect.. but it should be good enough. */ old = irq_disable(); chn = sfx_nextchan; moved = 0; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |