Skip to content

Commit

Permalink
Minor code cleanups only.
Browse files Browse the repository at this point in the history
  • Loading branch information
wavemotion-dave committed Dec 13, 2020
1 parent db44896 commit 3766aeb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
Binary file modified A7800DS.nds
Binary file not shown.
61 changes: 35 additions & 26 deletions arm9/source/a7800utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int bg3; // BG pointers
int bg0s, bg1s, bg2s, bg3s; // sub BG pointers

int full_speed = 0;
unsigned int etatEmu;
int etatEmu;
int gTotalAtariFrames=0;
int fpsDisplay=0;

Expand All @@ -37,6 +37,8 @@ int debug[MAX_DEBUG]={0};
//#define DEBUG_DUMP
//#define CART_INFO

#define SOUND_FREQ 22050

bool bRefreshXY = false;

static void DumpDebugData(void)
Expand Down Expand Up @@ -114,7 +116,6 @@ word atari_pal16[256] = {0};
unsigned char keyboard_data[19];

unsigned char *filebuffer;
unsigned char *psound_buffer;

#define tchepres(a) \
keyboard_data[GameConf.DS_Pad[a]] = 1;
Expand Down Expand Up @@ -224,16 +225,16 @@ void vblankIntr()

void dsInitScreenMain(void)
{
// Init vbl and hbl func
//SetYtrigger(192); //trigger 2 lines before vsync
irqSet(IRQ_VBLANK, vblankIntr);
irqEnable(IRQ_VBLANK);
// Init vbl and hbl func
//SetYtrigger(192); //trigger 2 lines before vsync
irqSet(IRQ_VBLANK, vblankIntr);
irqEnable(IRQ_VBLANK);
}

void dsInitTimer(void)
{
TIMER0_DATA=0;
TIMER0_CR=TIMER_ENABLE|TIMER_DIV_1024;
TIMER0_DATA=0;
TIMER0_CR=TIMER_ENABLE|TIMER_DIV_1024;
}

void dsShowScreenEmu(void)
Expand Down Expand Up @@ -318,14 +319,20 @@ static word targetIndex = 0;
void VsoundHandler(void)
{
static u16 sound_idx=0;
if (cartridge_pokey)
sound_buffer[sound_idx] = (tia_buffer[targetIndex]+pokey_buffer[targetIndex])/2+128;
else
sound_buffer[sound_idx] = tia_buffer[targetIndex]+128;
sound_buffer[sound_idx] = tia_buffer[targetIndex]+128;
sound_idx = (sound_idx + 1) & 0x0FFF;
targetIndex=(targetIndex + 1) % 524;
}

void VsoundHandler_Pokey(void)
{
static u16 sound_idx=0;
sound_buffer[sound_idx] = ((tia_buffer[targetIndex]+pokey_buffer[targetIndex])/2)+128;
sound_idx = (sound_idx + 1) & 0x0FFF;
targetIndex=(targetIndex + 1) % 524;
}


void dsLoadGame(char *filename)
{
unsigned int index;
Expand Down Expand Up @@ -385,10 +392,12 @@ void dsLoadGame(char *filename)
GameConf.DS_Pad[ 8] = 15; GameConf.DS_Pad[ 9] = 16;
GameConf.DS_Pad[10] = 14; GameConf.DS_Pad[11] = 13;

psound_buffer=sound_buffer;
TIMER2_DATA = TIMER_FREQ(22050);
TIMER2_DATA = TIMER_FREQ(SOUND_FREQ);
TIMER2_CR = TIMER_DIV_1 | TIMER_IRQ_REQ | TIMER_ENABLE;
irqSet(IRQ_TIMER2, VsoundHandler);
if (cartridge_pokey)
irqSet(IRQ_TIMER2, VsoundHandler_Pokey);
else
irqSet(IRQ_TIMER2, VsoundHandler);
irqEnable(IRQ_TIMER2);
}
}
Expand Down Expand Up @@ -729,17 +738,17 @@ void dsPrintValue(int x, int y, unsigned int isSelect, char *pchStr)
//---------------------------------------------------------------------------------
void dsInstallSoundEmuFIFO(void)
{
FifoMessage msg;
msg.SoundPlay.data = &sound_buffer;
msg.SoundPlay.freq = 22050;
msg.SoundPlay.volume = 127;
msg.SoundPlay.pan = 64;
msg.SoundPlay.loop = 1;
msg.SoundPlay.format = ((1)<<4) | SoundFormat_8Bit;
msg.SoundPlay.loopPoint = 0;
msg.SoundPlay.dataSize = SNDLENGTH >> 2;
msg.type = EMUARM7_PLAY_SND;
fifoSendDatamsg(FIFO_USER_01, sizeof(msg), (u8*)&msg);
FifoMessage msg;
msg.SoundPlay.data = &sound_buffer;
msg.SoundPlay.freq = SOUND_FREQ;
msg.SoundPlay.volume = 127;
msg.SoundPlay.pan = 64;
msg.SoundPlay.loop = 1;
msg.SoundPlay.format = ((1)<<4) | SoundFormat_8Bit;
msg.SoundPlay.loopPoint = 0;
msg.SoundPlay.dataSize = SNDLENGTH >> 2;
msg.type = EMUARM7_PLAY_SND;
fifoSendDatamsg(FIFO_USER_01, sizeof(msg), (u8*)&msg);
}

void dsMainLoop(void)
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/a7800utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define A7800_PLAYGAME 0x04
#define A7800_QUITSTDS 0x05

extern unsigned int etatEmu;
extern int etatEmu;

typedef enum {
EMUARM7_INIT_SND = 0x123C,
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/emu/Cartridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void cartridge_ReadHeader(const byte* header) {
cartridge_region = header[57];
cartridge_flags = 0;

cartridge_wsync=cartridge_cycle_stealing=true; //TBD trying...
cartridge_wsync=cartridge_cycle_stealing=true; // Guess as best we can...
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 3766aeb

Please sign in to comment.