Added initial implementation of ARM emulation to the DPC+ bankswitching

scheme.  However, it doesn't seem to be working yet ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2204 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2011-01-16 21:23:03 +00:00
parent f2427a6cbc
commit 935fd4df3f
5 changed files with 2026 additions and 5 deletions

View File

@ -21,6 +21,7 @@
#include <cstring>
#include "System.hxx"
#include "Thumbulator.hxx"
#include "CartDPCPlus.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -37,17 +38,19 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size,
uInt32 minsize = 4096 * 6 + 4096 + 1024 + 255;
mySize = BSPF_max(minsize, size);
myImage = new uInt8[mySize];
myDPCRAM = new uInt8[8192];
memcpy(myImage, image, size);
createCodeAccessBase(4096 * 6);
// Pointer to the program ROM (24K @ 0 byte offset)
myProgramImage = myImage;
// Pointer to the display ROM (4K @ 24K offset)
myDisplayImage = myProgramImage + 4096 * 6;
// Pointer to the display RAM
myDisplayImage = myDPCRAM + 0xC00;
memset(myDPCRAM, 0, 8192);
// Pointer to the Frequency ROM (1K @ 28K offset)
myFrequencyImage = myDisplayImage + 4096;
myFrequencyImage = myProgramImage + 0x7000;
// If the image is larger than 29K, we assume any excess at the
// beginning is ARM code, and skip over it
@ -55,10 +58,17 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size,
{
int offset = size - 29 * 1024;
myProgramImage += offset;
myDisplayImage += offset;
// myDisplayImage += offset;
myFrequencyImage += offset;
}
// Create Thumbulator ARM emulator
myThumbEmulator = new Thumbulator((uInt16*)(myProgramImage-0xC00),
(uInt16*)myDPCRAM);
// Copy DPC display data to Harmony RAM
memcpy(myDisplayImage, myProgramImage + 0x6000, 0x1000);
// Initialize the DPC data fetcher registers
for(uInt16 i = 0; i < 8; ++i)
myTops[i] = myBottoms[i] = myCounters[i] = myFractionalIncrements[i] = 0;
@ -77,6 +87,9 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size,
CartridgeDPCPlus::~CartridgeDPCPlus()
{
delete[] myImage;
delete[] myDPCRAM;
delete myThumbEmulator;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -181,8 +194,11 @@ inline void CartridgeDPCPlus::callFunction(uInt8 value)
myDisplayImage[myCounters[myParameter[2]]+i] = myParameter[0];
myParameterPointer = 0;
break;
case 254:
case 255: // Call user writen ARM code (most likely be C compiled for ARM).
// ARM code not supported by Stella at this time.
myThumbEmulator->run();
break;
// reserved
}

View File

@ -21,6 +21,7 @@
#define CARTRIDGE_DPC_PLUS_HXX
class System;
class Thumbulator;
#include "bspf.hxx"
#include "Cart.hxx"
@ -178,6 +179,12 @@ class CartridgeDPCPlus : public Cartridge
// Pointer to the 4K display ROM image of the cartridge
uInt8* myDisplayImage;
// Pointer to the DPC 8k RAM image
uInt8* myDPCRAM;
// Pointer to the Thumb ARM emulator object
Thumbulator* myThumbEmulator;
// Pointer to the 1K frequency table
uInt8* myFrequencyImage;

1885
src/emucore/Thumbulator.cxx Normal file

File diff suppressed because it is too large Load Diff

112
src/emucore/Thumbulator.hxx Normal file
View File

@ -0,0 +1,112 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2011 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
//============================================================================
// This class provides Thumb emulation code ("Thumbulator")
// by David Welch (dwelch@dwelch.com)
// Modified by Fred Quimby
// Code is public domain and used with the author's consent
//============================================================================
#include "bspf.hxx"
#define ROMADDMASK 0x7FFF
#define RAMADDMASK 0x1FFF
#define ROMSIZE (ROMADDMASK+1)
#define RAMSIZE (RAMADDMASK+1)
//0b10000 User PC, R14 to R0, CPSR
//0b10001 FIQ PC, R14_fiq to R8_fiq, R7 to R0, CPSR, SPSR_fiq
//0b10010 IRQ PC, R14_irq, R13_irq, R12 to R0, CPSR, SPSR_irq
//0b10011 Supervisor PC, R14_svc, R13_svc, R12 to R0, CPSR, SPSR_svc
//0b10111 Abort PC, R14_abt, R13_abt, R12 to R0, CPSR, SPSR_abt
//0b11011 Undefined PC, R14_und, R13_und, R12 to R0, CPSR, SPSR_und
//0b11111 System
#define MODE_USR 0x10
#define MODE_FIQ 0x11
#define MODE_IRQ 0x12
#define MODE_SVC 0x13
#define MODE_ABT 0x17
#define MODE_UND 0x1B
#define MODE_SYS 0x1F
#define CPSR_T (1<<5)
#define CPSR_F (1<<6)
#define CPSR_I (1<<7)
#define CPSR_N (1<<31)
#define CPSR_Z (1<<30)
#define CPSR_C (1<<29)
#define CPSR_V (1<<28)
#define CPSR_Q (1<<27)
class Thumbulator
{
public:
Thumbulator(uInt16* rom, uInt16* ram);
~Thumbulator();
int run();
private:
uInt32 read_register ( uInt32 reg );
uInt32 write_register ( uInt32 reg, uInt32 data );
uInt32 fetch16 ( uInt32 addr );
uInt32 fetch32 ( uInt32 addr );
uInt32 read16 ( uInt32 addr );
uInt32 read32 ( uInt32 );
void write16 ( uInt32 addr, uInt32 data );
void write32 ( uInt32 addr, uInt32 data );
void do_zflag ( uInt32 x );
void do_nflag ( uInt32 x );
void do_cflag ( uInt32 a, uInt32 b, uInt32 c );
void do_sub_vflag ( uInt32 a, uInt32 b, uInt32 c );
void do_add_vflag ( uInt32 a, uInt32 b, uInt32 c );
void do_cflag_bit ( uInt32 x );
void do_vflag_bit ( uInt32 x );
void dump_counters ( void );
int execute ( void );
int reset ( void );
private:
uInt16* rom;
uInt16* ram;
Int32 copydata;
uInt32 halfadd;
uInt32 cpsr;
uInt32 reg_usr[16]; //User mode
uInt32 reg_sys[16]; //System mode
uInt32 reg_svc[16]; //Supervisor mode
//uInt32 reg_abt[16]; //Abort mode
//uInt32 reg_und[16]; //Undefined mode
uInt32 reg_irq[16]; //Interrupt mode
//uInt32 reg_fiq[16]; //Fast Interrupt mode
uInt64 instructions;
uInt64 fetches;
uInt64 reads;
uInt64 writes;
Int32 DBUG; // dump detailed execution trace
Int32 DISS; // dump Thumb instruction trace
};

View File

@ -64,7 +64,8 @@ MODULE_OBJS := \
src/emucore/TIATables.o \
src/emucore/TrackBall.o \
src/emucore/unzip.o \
src/emucore/MediaFactory.o
src/emucore/MediaFactory.o \
src/emucore/Thumbulator.o
MODULE_DIRS += \
src/emucore