diff --git a/src/game/game_init.c b/src/game/game_init.c index c2cf82b2..b8e3f512 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -59,10 +59,6 @@ struct DemoInput *gCurrDemoInput = NULL; // demo input sequence u16 gDemoInputListID = 0; struct DemoInput gRecordedDemoInput = { 0 }; // possibly removed in EU. TODO: Check - -#include "include/timekeeper.inc.c" -#include "include/hvqm.inc.c" - /** * Initializes the Reality Display Processor (RDP). * This function initializes settings such as texture filtering mode, diff --git a/include/hvqm.inc.c b/src/game/hvqm.c similarity index 95% rename from include/hvqm.inc.c rename to src/game/hvqm.c index af6edfa1..2c1ff463 100644 --- a/include/hvqm.inc.c +++ b/src/game/hvqm.c @@ -1,32 +1,9 @@ #include +#include +#include #include #include -/* - * Size of the data area for the HVQ microcode - */ -#define HVQ_SPFIFO_SIZE 30000 - -/* - * Size of buffer for video records - */ -#define HVQ_DATASIZE_MAX 40000 - -/* - * Size of buffer for audio records - */ -#define AUDIO_RECORD_SIZE_MAX 5000 - -/* - * Size of data area for HVQM2 microcode - */ -#define HVQ_SPFIFO_SIZE 30000 - -#define SCREEN_WD 320 /* Screen width [pixel] */ -#define SCREEN_HT 240 /* Screen height [pixel] */ - -#define APP_GFX_UCODE_HVQ 6 /* HVQ2 microcode */ - -#define AUDIO_DMA_MSG_SIZE 1 +#include "hvqm.h" u8 hvqbuf[HVQ_DATASIZE_MAX]; @@ -192,7 +169,7 @@ HVQM2Header *hvqm_header; static OSMesgQueue hvqmMesgQ; static OSMesg hvqmMesgBuf; -static OSThread hvqmThread; +OSThread hvqmThread; static u64 hvqmStack[STACKSIZE/sizeof(u64)]; void hvqm_main_proc() { diff --git a/src/game/hvqm.h b/src/game/hvqm.h new file mode 100644 index 00000000..2c621b87 --- /dev/null +++ b/src/game/hvqm.h @@ -0,0 +1,92 @@ +#ifndef HVQM_H +#define HVQM_H + + +/* + * Size of the data area for the HVQ microcode + */ +#define HVQ_SPFIFO_SIZE 30000 + +/* + * Size of buffer for video records + */ +#define HVQ_DATASIZE_MAX 40000 + +/* + * Size of buffer for audio records + */ +#define AUDIO_RECORD_SIZE_MAX 5000 + +/* + * Size of data area for HVQM2 microcode + */ +#define HVQ_SPFIFO_SIZE 30000 + +#define SCREEN_WD 320 /* Screen width [pixel] */ +#define SCREEN_HT 240 /* Screen height [pixel] */ + +#define APP_GFX_UCODE_HVQ 6 /* HVQ2 microcode */ + +#define AUDIO_DMA_MSG_SIZE 1 + + +#define CFB_FREE 0 /* Available */ +#define CFB_PRECIOUS (1<<0) /* Constrained for decoding of next frame */ +#define CFB_SHOWING (1<<1) /* Waiting to display or displaying */ + + +typedef u32 (*tkAudioProc)(void *pcmbuf); +typedef tkAudioProc (*tkRewindProc)(void); + +void createTimekeeper(); +void tkStart(tkRewindProc rewind, u32 samples_per_sec); +void tkPushVideoframe(void *vaddr, u32 *statP, u64 disptime); +u64 tkGetTime(void); +void tkStop(void); + + + +#define NUM_CFBs 3 +#define STACKSIZE 0x2000 +#define PCM_CHANNELS 2 /* Number of channels */ +#define PCM_CHANNELS_SHIFT 1 /* log2(PCM_CHANNELS) */ +#define PCM_ALIGN 2 /* Alignment of number of samples to send */ +#define PCM_BYTES_PER_SAMPLE (2 * PCM_CHANNELS) /* Number of bytes in one sample */ +#define PCM_BYTES_PER_SAMPLE_SHIFT 2 /* log2(PCM_BYTES_PER_SAMPLE) */ + +/* + * Audio record definitions + */ +#define AUDIO_SAMPLE_BITS 4 +#define AUDIO_SAMPLES_MAX (((AUDIO_RECORD_SIZE_MAX-sizeof(HVQM2Audio))*8/AUDIO_SAMPLE_BITS)+1) /* Maximum number of records per sample */ + +/* + * PCM buffer specifications + */ +#define NUM_PCMBUFs 3 /* Number of PCM buffers (2 or more, at least 3 recommended) */ +#define PCMBUF_SPREAD ((PCM_ALIGN-1)+AUDIO_SAMPLES_MAX) /* Minimum required capacity for PCM buffer = Number of samples carried forward from last time + number of samples newly decoded */ +#define PCMBUF_ALIGNED ((PCMBUF_SPREAD+(PCM_ALIGN-1))&(~(PCM_ALIGN-1))) /* pcmbuf[i] address is aligned */ +#define PCMBUF_SIZE 0xA00 + +/* + * Thread ID and priority + */ +#define IDLE_THREAD_ID 1 +#define MAIN_THREAD_ID 3 +#define HVQM_THREAD_ID 7 +#define TIMEKEEPER_THREAD_ID 8 +#define DA_COUNTER_THREAD_ID 9 + +#define IDLE_PRIORITY 10 +#define MAIN_PRIORITY 10 +#define HVQM_PRIORITY 11 +#define TIMEKEEPER_PRIORITY 12 +#define DA_COUNTER_PRIORITY 13 + +#define PI_COMMAND_QUEUE_SIZE 4 + +typedef u32 (*tkAudioProc)(void *pcmbuf); +typedef tkAudioProc (*tkRewindProc)(void); + + +#endif // HVQM_H \ No newline at end of file diff --git a/src/game/main.h b/src/game/main.h index bdc88e07..b50aeb51 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -26,6 +26,7 @@ extern OSThread gIdleThread; extern OSThread gMainThread; extern OSThread gGameLoopThread; extern OSThread gSoundThread; +extern OSThread hvqmThread; #if ENABLE_RUMBLE extern OSThread gRumblePakThread; diff --git a/include/timekeeper.inc.c b/src/game/timekeeper.c similarity index 98% rename from include/timekeeper.inc.c rename to src/game/timekeeper.c index 96d67a85..99621f83 100644 --- a/include/timekeeper.inc.c +++ b/src/game/timekeeper.c @@ -1,4 +1,5 @@ #include +#include "hvqm.h" #include "audio/data.h" #include "buffers/framebuffers.h" @@ -147,10 +148,6 @@ static int clock_alive; ***********************************************************************/ static u32 samples_per_sec; -#define CFB_FREE 0 /* Available */ -#define CFB_PRECIOUS (1<<0) /* Constrained for decoding of next frame */ -#define CFB_SHOWING (1<<1) /* Waiting to display or displaying */ - /*********************************************************************** * Number of PCM samples that have finished playing *