Skip to content

Commit

Permalink
Version 3.6 - see readme.md for details.
Browse files Browse the repository at this point in the history
  • Loading branch information
wavemotion-dave committed Jan 8, 2024
1 parent f79116e commit 57c7f07
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 156 deletions.
Binary file modified A5200DS.nds
Binary file not shown.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include $(DEVKITARM)/ds_rules
export TARGET := A5200DS
export TOPDIR := $(CURDIR)

VERSION=3.5c
VERSION=3.6

ICON := -b $(CURDIR)/logo.bmp "A5200DS $(VERSION);wavemotion-dave;http://https://github.com/wavemotion-dave/A5200DS"

Expand Down
Binary file modified arm9/gfx/pdev_bg0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 17 additions & 21 deletions arm9/source/a5200utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ u16* aptr __attribute__((section(".dtcm"))) = (u16*) ((u32)&sound_buffer[0] + 0x
u16* bptr __attribute__((section(".dtcm"))) = (u16*) ((u32)&sound_buffer[2] + 0xA000000);

unsigned int atari_pal16[256] = {0};
unsigned char *filebuffer;

static int last_key_code = 0x00;
static UWORD keys_dampen = 0;
Expand Down Expand Up @@ -358,19 +357,16 @@ int load_os(char *filename )
fclose(romfile);
}

return 0;
return 0;
} /* end load_os */

void dsLoadGame(char *filename)
{
// Free buffer if needed
TIMER2_CR=0; irqDisable(IRQ_TIMER2);
if (filebuffer != 0)
free(filebuffer);

// load card game if ok
if (Atari800_OpenFile(filename, true, 1, true) != AFILE_ERROR)
{
{
// Initialize the virtual console emulation
dsShowScreenEmu();

Expand All @@ -388,7 +384,7 @@ void dsLoadGame(char *filename)
}

TIMER2_DATA = TIMER_FREQ((SOUND_FREQ/2)+20); // keep this a little faster than our Pokey sound generation
TIMER2_CR = TIMER_DIV_1 | TIMER_IRQ_REQ | TIMER_ENABLE;
TIMER2_CR = TIMER_DIV_1 | TIMER_IRQ_REQ | TIMER_ENABLE;
irqSet(IRQ_TIMER2, VsoundHandler);

TIMER0_CR=0;
Expand All @@ -400,22 +396,22 @@ void dsLoadGame(char *filename)
}

unsigned int dsReadPad(void) {
unsigned short int keys_pressed, ret_keys_pressed;
unsigned short int keys_pressed, ret_keys_pressed;

do {
keys_pressed = keysCurrent();
} while ((keys_pressed & (KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP | KEY_A | KEY_B | KEY_L | KEY_R))!=0);
do {
keys_pressed = keysCurrent();
} while ((keys_pressed & (KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP | KEY_A | KEY_B | KEY_L | KEY_R))!=0);

do {
keys_pressed = keysCurrent();
} while ((keys_pressed & (KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP | KEY_A | KEY_B | KEY_L | KEY_R))==0);
ret_keys_pressed = keys_pressed;
do {
keys_pressed = keysCurrent();
} while ((keys_pressed & (KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP | KEY_A | KEY_B | KEY_L | KEY_R))==0);
ret_keys_pressed = keys_pressed;

do {
keys_pressed = keysCurrent();
} while ((keys_pressed & (KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP | KEY_A | KEY_B | KEY_L | KEY_R))!=0);
do {
keys_pressed = keysCurrent();
} while ((keys_pressed & (KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP | KEY_A | KEY_B | KEY_L | KEY_R))!=0);

return ret_keys_pressed;
return ret_keys_pressed;
}

bool dsWaitOnQuit(void) {
Expand Down Expand Up @@ -613,7 +609,7 @@ unsigned int dsWaitForRom(void)
else {
ucSHaut = 0;
}
if ( keysCurrent() & KEY_B ) {
if ( keysCurrent() & KEY_B ) {
bDone=true;
while (keysCurrent() & KEY_B);
}
Expand Down Expand Up @@ -1165,7 +1161,7 @@ void dsMainLoop(void) {

break;
}
}
}
}


Expand Down
1 change: 0 additions & 1 deletion arm9/source/emu/atari.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

void Atari800_RunEsc(UBYTE esc_code)
{
cim_encountered = 1;
Atari800_Exit(TRUE);
}

Expand Down
55 changes: 34 additions & 21 deletions arm9/source/emu/cartridge.c

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions arm9/source/emu/config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
// Define to activate sound support.
#define SOUND 1
//#define VOL_ONLY_SOUND 1

// Define to allow stereo sound.
//#define STEREO_SOUND 1

//Obsoleted file
91 changes: 6 additions & 85 deletions arm9/source/emu/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,9 @@
#include <stdlib.h> /* exit() */

#include "cpu.h"
#ifdef ASAP /* external project, see http://asap.sf.net */
#include "asap_internal.h"
#else
#include "antic.h"
#include "atari.h"
#include "memory.h"
#ifndef BASIC
#ifndef __PLUS
//#include "ui.h"
#endif
#endif /* BASIC */
#endif /* ASAP */

/* Windows headers define it */
#undef ABSOLUTE
Expand Down Expand Up @@ -121,7 +112,7 @@ UBYTE IRQ __attribute__((section(".dtcm")));
/* 6502 flags local to this module */
static UBYTE N __attribute__((section(".dtcm"))); /* bit7 set => N flag set */
#ifndef NO_V_FLAG_VARIABLE
static UBYTE V __attribute__((section(".dtcm"))); /* non-zero => V flag set */
static UBYTE V __attribute__((section(".dtcm"))); /* non-zero => V flag set */
#endif
static UBYTE Z __attribute__((section(".dtcm"))); /* zero => Z flag set */
static UBYTE C __attribute__((section(".dtcm"))); /* must be 0 or 1 */
Expand Down Expand Up @@ -149,19 +140,6 @@ inline void CPU_PutStatus(void)
/* For Atari Basic loader */
void (*rts_handler)(void) = NULL;

UBYTE cim_encountered = FALSE;

/* Execution history */
#ifdef MONITOR_BREAK
UWORD remember_PC[REMEMBER_PC_STEPS];
unsigned int remember_PC_curpos = 0;
int remember_xpos[REMEMBER_PC_STEPS];
UWORD remember_JMP[REMEMBER_JMP_STEPS];
unsigned int remember_jmp_curpos = 0;
#define INC_RET_NESTING ret_nesting++
#else /* MONITOR_BREAK */
#define INC_RET_NESTING
#endif /* MONITOR_BREAK */

/* Addressing modes */
#define zGetWord(x) dGetWord(x)
Expand Down Expand Up @@ -230,7 +208,6 @@ void NMI(void)
regPC = dGetWordAligned(0xfffa);
regS = S;
xpos += 7; /* handling an interrupt by 6502 takes 7 cycles */
INC_RET_NESTING;
}

/* Check pending IRQ, helps in (not only) Lucasfilm games */
Expand All @@ -241,22 +218,10 @@ void NMI(void)
SetI; \
SET_PC(dGetWordAligned(0xfffe)); \
xpos += 7; \
INC_RET_NESTING; \
}

/* Enter monitor */
#ifdef __PLUS
#define ENTER_MONITOR Atari800_Exit(TRUE)
#else
#define ENTER_MONITOR if (!Atari800_Exit(TRUE)) exit(0)
#endif
#define DO_BREAK \
UPDATE_GLOBAL_REGS; \
CPU_GetStatus(); \
ENTER_MONITOR; \
CPU_PutStatus(); \
UPDATE_LOCAL_REGS;


/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
static UBYTE cycles[256] __attribute__((section(".dtcm"))) =
Expand Down Expand Up @@ -412,20 +377,11 @@ ITCM_CODE void GO(int limit)
goto *opcode[insn];

OPCODE(00) /* BRK */
#ifdef MONITOR_BREAK
if (break_brk) {
DO_BREAK;
}
else
#endif
{
PC++;
PHPC;
PHPB1;
SetI;
SET_PC(dGetWordAligned(0xfffe));
INC_RET_NESTING;
}
PC++;
PHPC;
PHPB1;
SetI;
SET_PC(dGetWordAligned(0xfffe));
DONE

OPCODE(01) /* ORA (ab,x) */
Expand Down Expand Up @@ -607,11 +563,6 @@ ITCM_CODE void GO(int limit)
OPCODE(20) /* JSR abcd */
{
UWORD retaddr = GET_PC() + 1;
#ifdef MONITOR_BREAK
remember_JMP[remember_jmp_curpos] = GET_PC() - 1;
remember_jmp_curpos = (remember_jmp_curpos + 1) % REMEMBER_JMP_STEPS;
ret_nesting++;
#endif
PHW(retaddr);
}
SET_PC(OP_WORD);
Expand Down Expand Up @@ -790,10 +741,6 @@ ITCM_CODE void GO(int limit)
data = PL;
SET_PC((PL << 8) + data);
CPUCHECKIRQ;
#ifdef MONITOR_BREAK
if (break_ret && --ret_nesting <= 0)
break_step = TRUE;
#endif
DONE

OPCODE(41) /* EOR (ab,x) */
Expand Down Expand Up @@ -857,10 +804,6 @@ ITCM_CODE void GO(int limit)
DONE

OPCODE(4c) /* JMP abcd */
#ifdef MONITOR_BREAK
remember_JMP[remember_jmp_curpos] = GET_PC() - 1;
remember_jmp_curpos = (remember_jmp_curpos + 1) % REMEMBER_JMP_STEPS;
#endif
SET_PC(OP_WORD);
DONE

Expand Down Expand Up @@ -954,10 +897,6 @@ ITCM_CODE void GO(int limit)
OPCODE(60) /* RTS */
data = PL;
SET_PC((PL << 8) + data + 1);
#ifdef MONITOR_BREAK
if (break_ret && --ret_nesting <= 0)
break_step = TRUE;
#endif
DONE

OPCODE(61) /* ADC (ab,x) */
Expand Down Expand Up @@ -1058,10 +997,6 @@ ITCM_CODE void GO(int limit)
DONE

OPCODE(6c) /* JMP (abcd) */
#ifdef MONITOR_BREAK
remember_JMP[remember_jmp_curpos] = GET_PC() - 1;
remember_jmp_curpos = (remember_jmp_curpos + 1) % REMEMBER_JMP_STEPS;
#endif
ABSOLUTE;
#ifdef CPU65C02
/* XXX: if ((UBYTE) addr == 0xff) xpos++; */
Expand Down Expand Up @@ -1784,10 +1719,6 @@ ITCM_CODE void GO(int limit)
UPDATE_LOCAL_REGS;
data = PL;
SET_PC((PL << 8) + data + 1);
#ifdef MONITOR_BREAK
if (break_ret && --ret_nesting <= 0)
break_step = TRUE;
#endif
DONE

OPCODE(f2) /* ESC #ab (CIM) - on Atari is here instruction CIM [unofficial] !RS! */
Expand Down Expand Up @@ -1832,7 +1763,6 @@ ITCM_CODE void GO(int limit)
crash_code = insn;
ui();
#else
cim_encountered = TRUE;
ENTER_MONITOR;
#endif /* CRASH_MENU */

Expand Down Expand Up @@ -1948,12 +1878,3 @@ void CPU_Reset(void)
regS = 0xff;
regPC = dGetWordAligned(0xfffc);
}

void CpuStateSave(UBYTE SaveVerbose)
{
}

void CpuStateRead(UBYTE SaveVerbose)
{
}

6 changes: 3 additions & 3 deletions arm9/source/emu/gtia.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
#include <nds.h>
#include "config.h"
#include "a5200utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -76,7 +77,7 @@ UBYTE POTENA __attribute__((section(".dtcm")));

/* Internal GTIA state ----------------------------------------------------- */

int consol_index __attribute__((section(".dtcm")))= 0;
UBYTE consol_index __attribute__((section(".dtcm"))) = 0;
UBYTE consol_table[3] __attribute__((section(".dtcm")));
UBYTE consol_mask __attribute__((section(".dtcm")));
UBYTE TRIG[4] __attribute__((section(".dtcm")));
Expand Down Expand Up @@ -112,7 +113,7 @@ static UBYTE *hposm_ptr[4] __attribute__((section(".dtcm")));
static ULONG hposp_mask[4] __attribute__((section(".dtcm")));

static ULONG *grafp_ptr[4] __attribute__((section(".dtcm")));
static int global_sizem[4] __attribute__((section(".dtcm")));
static UBYTE global_sizem[4] __attribute__((section(".dtcm")));
static UBYTE PM_Width[4] __attribute__((section(".dtcm"))) = {1, 2, 1, 4};

static ULONG grafp_lookup[4][256];
Expand Down Expand Up @@ -213,7 +214,6 @@ void GTIA_Initialise(void)

/* Prepare PMG scanline ---------------------------------------------------- */


ITCM_CODE void new_pm_scanline(void)
{
/* Clear if necessary */
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/emu/gtia.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extern UBYTE collisions_mask_player_player;
extern UBYTE TRIG[4];
extern UBYTE TRIG_latch[4];

extern int consol_index;
extern UBYTE consol_index;
extern UBYTE consol_table[3];

void GTIA_Initialise(void);
Expand Down
8 changes: 0 additions & 8 deletions arm9/source/emu/pokey.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ ITCM_CODE void POKEY_Scanline(void)

ITCM_CODE void Update_Counter(int chan_mask)
{

/************************************************************/
/* As defined in the manual, the exact Div_n_cnt values are */
/* different depending on the frequency and resolution: */
Expand Down Expand Up @@ -408,10 +407,3 @@ void PokeyClearBuffer(void)
pokeyBufIdx = 0;
}

void POKEYStateSave(void)
{
}

void POKEYStateRead(void)
{
}
4 changes: 2 additions & 2 deletions arm9/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include "highscore.h"

extern int bg0, bg1;
int bg0s, bg1s, bg2s, bg3s; // sub BG pointers

extern int load_os(char *filename );

char *bios_filename = "5200.rom";

// Program entry point
int main(int argc, char **argv)
{
char *bios_filename = "5200.rom";
// Init sound
consoleDemoInit();
soundEnable();
Expand Down
Loading

0 comments on commit 57c7f07

Please sign in to comment.