Clean up HVQM code a little

This commit is contained in:
CrashOveride95
2020-12-09 09:23:26 -05:00
parent 7f4cefdc36
commit a242b18d99
5 changed files with 98 additions and 35 deletions

View File

@@ -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,

View File

@@ -1,32 +1,9 @@
#include <ultra64.h>
#include <sm64.h>
#include <buffers/framebuffers.h>
#include <hvqm2dec.h>
#include <adpcmdec.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
#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() {

92
src/game/hvqm.h Normal file
View File

@@ -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

View File

@@ -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;

View File

@@ -1,4 +1,5 @@
#include <ultra64.h>
#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
*