├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── StellaDS.nds ├── arm7 ├── Makefile └── source │ ├── emusoundfifo.c │ └── main.c ├── arm9 ├── Makefile ├── data │ ├── clickNoQuit.wav │ ├── clickQuit.wav │ └── mus_intro.wav ├── ds_arm9_hi.mem ├── ds_arm9_hi.specs ├── gfx │ ├── bgBottom.png │ ├── bgDualKeypad.png │ ├── bgFileSel.png │ ├── bgHighScore.png │ ├── bgInstructions.png │ ├── bgKeypad.png │ ├── bgPaddles.png │ ├── bgStarRaiders.png │ ├── bgTop.png │ ├── pdev_bg0.png │ └── pdev_tbg0.png └── source │ ├── StellaDS.cpp │ ├── StellaDS.h │ ├── config.cpp │ ├── config.h │ ├── emucore │ ├── Booster.cpp │ ├── Booster.hxx │ ├── Cart.cpp │ ├── Cart.hxx │ ├── Cart03E0.cpp │ ├── Cart03E0.hxx │ ├── Cart0840.cpp │ ├── Cart0840.hxx │ ├── Cart0FA0.cpp │ ├── Cart0FA0.hxx │ ├── Cart2K.cpp │ ├── Cart2K.hxx │ ├── Cart3E.cpp │ ├── Cart3E.hxx │ ├── Cart3EPlus.cpp │ ├── Cart3EPlus.hxx │ ├── Cart3F.cpp │ ├── Cart3F.hxx │ ├── Cart4K.cpp │ ├── Cart4K.hxx │ ├── CartAR.cpp │ ├── CartAR.hxx │ ├── CartBF.cpp │ ├── CartBF.hxx │ ├── CartBFSC.cpp │ ├── CartBFSC.hxx │ ├── CartCDF.cpp │ ├── CartCDF.hxx │ ├── CartCTY.cpp │ ├── CartCTY.hxx │ ├── CartCV.cpp │ ├── CartCV.hxx │ ├── CartDF.cpp │ ├── CartDF.hxx │ ├── CartDFSC.cpp │ ├── CartDFSC.hxx │ ├── CartDPC.cpp │ ├── CartDPC.hxx │ ├── CartDPCPlus.cpp │ ├── CartDPCPlus.hxx │ ├── CartE0.cpp │ ├── CartE0.hxx │ ├── CartE7.cpp │ ├── CartE7.hxx │ ├── CartEF.cpp │ ├── CartEF.hxx │ ├── CartEFSC.cpp │ ├── CartEFSC.hxx │ ├── CartF4.cpp │ ├── CartF4.hxx │ ├── CartF4SC.cpp │ ├── CartF4SC.hxx │ ├── CartF6.cpp │ ├── CartF6.hxx │ ├── CartF6SC.cpp │ ├── CartF6SC.hxx │ ├── CartF8.cpp │ ├── CartF8.hxx │ ├── CartF8SC.cpp │ ├── CartF8SC.hxx │ ├── CartFA2.cpp │ ├── CartFA2.hxx │ ├── CartFASC.cpp │ ├── CartFASC.hxx │ ├── CartFE.cpp │ ├── CartFE.hxx │ ├── CartJANE.cpp │ ├── CartJANE.hxx │ ├── CartMB.cpp │ ├── CartMB.hxx │ ├── CartSB.cpp │ ├── CartSB.hxx │ ├── CartTV.cpp │ ├── CartTV.hxx │ ├── CartUA.cpp │ ├── CartUA.hxx │ ├── CartWD.cpp │ ├── CartWD.hxx │ ├── CartWF8.cpp │ ├── CartWF8.hxx │ ├── CartX07.cpp │ ├── CartX07.hxx │ ├── Console.cpp │ ├── Console.hxx │ ├── Control.cpp │ ├── Control.hxx │ ├── Device.cpp │ ├── Device.hxx │ ├── Driving.cpp │ ├── Driving.hxx │ ├── Event.cpp │ ├── Event.hxx │ ├── EventHandler.cpp │ ├── EventHandler.hxx │ ├── Genesis.cpp │ ├── Genesis.hxx │ ├── Joystick.cpp │ ├── Joystick.hxx │ ├── Keyboard.cpp │ ├── Keyboard.hxx │ ├── M6502.cpp │ ├── M6502.hxx │ ├── M6502Low.cpp │ ├── M6502Low.hxx │ ├── M6502Low.ins │ ├── M6532.cpp │ ├── M6532.hxx │ ├── MD5.cpp │ ├── MD5.hxx │ ├── MT24LC256.cpp │ ├── MT24LC256.hxx │ ├── NullDev.cpp │ ├── NullDev.hxx │ ├── Paddles.cpp │ ├── Paddles.hxx │ ├── QuadTari.cpp │ ├── QuadTari.hxx │ ├── Random.cpp │ ├── Random.hxx │ ├── SaveKey.cpp │ ├── SaveKey.hxx │ ├── StellaEvent.hxx │ ├── Switches.cpp │ ├── Switches.hxx │ ├── System.cpp │ ├── System.hxx │ ├── TIA.cpp │ ├── TIA.hxx │ ├── TIA.inc │ ├── TIASound.cpp │ ├── TIASound.hxx │ ├── Thumbulator.cpp │ ├── Thumbulator.hxx │ └── bspf.hxx │ ├── highscore.cpp │ ├── highscore.h │ ├── instructions.cpp │ ├── instructions.h │ ├── intro.cpp │ ├── intro.h │ ├── main.cpp │ ├── printf.c │ ├── printf.h │ ├── savestate.cpp │ ├── savestate.h │ ├── screenshot.cpp │ └── screenshot.h ├── logo.bmp └── png ├── champ.png ├── gorf-shift.bmp └── gorf.bmp /.gitignore: -------------------------------------------------------------------------------- 1 | /*.nds 2 | /arm7/*.elf 3 | /arm9/*.elf 4 | /arm9/build 5 | /arm7/build 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | See the readme.md file for details... 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #export DEVKITPRO=/opt/devkitpro 2 | #export DEVKITARM=/opt/devkitpro/devkitARM 3 | # 4 | #--------------------------------------------------------------------------------- 5 | .SUFFIXES: 6 | #--------------------------------------------------------------------------------- 7 | .SECONDARY: 8 | 9 | ifeq ($(strip $(DEVKITARM)),) 10 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 11 | endif 12 | 13 | include $(DEVKITARM)/ds_rules 14 | 15 | export TARGET := StellaDS 16 | export TOPDIR := $(CURDIR) 17 | export VERSION := 8.0 18 | 19 | 20 | ICON := -b $(CURDIR)/logo.bmp "StellaDS $(VERSION);wavemotion-dave;https://github.com/wavemotion-dave/StellaDS" 21 | 22 | .PHONY: arm7/$(TARGET).elf arm9/$(TARGET).elf 23 | 24 | #--------------------------------------------------------------------------------- 25 | # main targets 26 | #--------------------------------------------------------------------------------- 27 | all: $(TARGET).nds 28 | 29 | #--------------------------------------------------------------------------------- 30 | $(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf 31 | ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf $(ICON) 32 | 33 | #--------------------------------------------------------------------------------- 34 | arm7/$(TARGET).elf: 35 | $(MAKE) -C arm7 36 | 37 | #--------------------------------------------------------------------------------- 38 | arm9/$(TARGET).elf: 39 | $(MAKE) -C arm9 40 | 41 | #--------------------------------------------------------------------------------- 42 | clean: 43 | $(MAKE) -C arm9 clean 44 | $(MAKE) -C arm7 clean 45 | rm -f $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9 46 | -------------------------------------------------------------------------------- /StellaDS.nds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/StellaDS.nds -------------------------------------------------------------------------------- /arm7/source/emusoundfifo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef enum { 6 | EMUARM7_INIT_SND = 0x123C, 7 | EMUARM7_STOP_SND = 0x123D, 8 | EMUARM7_PLAY_SND = 0x123E, 9 | } FifoMesType; 10 | 11 | //--------------------------------------------------------------------------------- 12 | void soundEmuDataHandler(int bytes, void *user_data) 13 | { 14 | int channel = -1; 15 | 16 | FifoMessage msg; 17 | 18 | fifoGetDatamsg(FIFO_USER_01, bytes, (u8*)&msg); 19 | 20 | switch (msg.type) { 21 | case EMUARM7_PLAY_SND: 22 | channel = (msg.SoundPlay.format & 0xF0)>>4; 23 | SCHANNEL_SOURCE(channel) = (u32)msg.SoundPlay.data; 24 | SCHANNEL_REPEAT_POINT(channel) = msg.SoundPlay.loopPoint; 25 | SCHANNEL_LENGTH(channel) = msg.SoundPlay.dataSize; 26 | SCHANNEL_TIMER(channel) = SOUND_FREQ(msg.SoundPlay.freq); 27 | SCHANNEL_CR(channel) = SCHANNEL_ENABLE | SOUND_VOL(msg.SoundPlay.volume) | SOUND_PAN(msg.SoundPlay.pan) | ((msg.SoundPlay.format & 0xF) << 29) | (msg.SoundPlay.loop ? SOUND_REPEAT : SOUND_ONE_SHOT); 28 | break; 29 | 30 | case EMUARM7_INIT_SND: 31 | break; 32 | 33 | case EMUARM7_STOP_SND: 34 | break; 35 | } 36 | } 37 | 38 | //--------------------------------------------------------------------------------- 39 | void soundEmuCommandHandler(u32 command, void* userdata) { 40 | int cmd = (command ) & 0x00F00000; 41 | int data = command & 0xFFFF; 42 | int channel = (command >> 16) & 0xF; 43 | 44 | switch(cmd) 45 | { 46 | 47 | case SOUND_SET_VOLUME: 48 | SCHANNEL_CR(channel) &= ~0xFF; 49 | SCHANNEL_CR(channel) |= data; 50 | break; 51 | 52 | case SOUND_SET_PAN: 53 | SCHANNEL_CR(channel) &= ~SOUND_PAN(0xFF); 54 | SCHANNEL_CR(channel) |= SOUND_PAN(data); 55 | break; 56 | 57 | case SOUND_SET_FREQ: 58 | SCHANNEL_TIMER(channel) = SOUND_FREQ(data); 59 | break; 60 | 61 | case SOUND_SET_WAVEDUTY: 62 | SCHANNEL_CR(channel) &= ~(7 << 24); 63 | SCHANNEL_CR(channel) |= (data) << 24; 64 | break; 65 | 66 | case SOUND_KILL: 67 | case SOUND_PAUSE: 68 | SCHANNEL_CR(channel) &= ~SCHANNEL_ENABLE; 69 | break; 70 | 71 | case SOUND_RESUME: 72 | SCHANNEL_CR(channel) |= SCHANNEL_ENABLE; 73 | break; 74 | 75 | default: break; 76 | } 77 | } 78 | 79 | //--------------------------------------------------------------------------------- 80 | void installSoundEmuFIFO(void) { 81 | fifoSetDatamsgHandler(FIFO_USER_01, soundEmuDataHandler, 0); 82 | fifoSetValue32Handler(FIFO_USER_01, soundEmuCommandHandler, 0); 83 | } 84 | -------------------------------------------------------------------------------- /arm7/source/main.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | default ARM7 core 4 | 5 | Copyright (C) 2005 - 2010 6 | Michael Noland (joat) 7 | Jason Rogers (dovoto) 8 | Dave Murphy (WinterMute) 9 | 10 | This software is provided 'as-is', without any express or implied 11 | warranty. In no event will the authors be held liable for any 12 | damages arising from the use of this software. 13 | 14 | Permission is granted to anyone to use this software for any 15 | purpose, including commercial applications, and to alter it and 16 | redistribute it freely, subject to the following restrictions: 17 | 18 | 1. The origin of this software must not be misrepresented; you 19 | must not claim that you wrote the original software. If you use 20 | this software in a product, an acknowledgment in the product 21 | documentation would be appreciated but is not required. 22 | 23 | 2. Altered source versions must be plainly marked as such, and 24 | must not be misrepresented as being the original software. 25 | 26 | 3. This notice may not be removed or altered from any source 27 | distribution. 28 | 29 | ---------------------------------------------------------------------------------*/ 30 | #include 31 | #include 32 | #include 33 | 34 | extern void installSoundEmuFIFO(void); 35 | 36 | //--------------------------------------------------------------------------------- 37 | void VblankHandler(void) { 38 | //--------------------------------------------------------------------------------- 39 | Wifi_Update(); 40 | } 41 | 42 | 43 | //--------------------------------------------------------------------------------- 44 | void VcountHandler() { 45 | //--------------------------------------------------------------------------------- 46 | inputGetAndSend(); 47 | } 48 | 49 | volatile bool exitflag = false; 50 | 51 | //--------------------------------------------------------------------------------- 52 | void powerButtonCB() { 53 | //--------------------------------------------------------------------------------- 54 | exitflag = true; 55 | } 56 | 57 | //--------------------------------------------------------------------------------- 58 | int main() { 59 | //--------------------------------------------------------------------------------- 60 | readUserSettings(); 61 | 62 | irqInit(); 63 | // Start the RTC tracking IRQ 64 | initClockIRQ(); 65 | touchInit(); 66 | fifoInit(); 67 | 68 | //mmInstall(FIFO_MAXMOD); 69 | 70 | SetYtrigger(80); 71 | 72 | installWifiFIFO(); 73 | installSoundFIFO(); 74 | 75 | installSystemFIFO(); 76 | 77 | installSoundEmuFIFO(); 78 | 79 | irqSet(IRQ_VCOUNT, VcountHandler); 80 | irqSet(IRQ_VBLANK, VblankHandler); 81 | 82 | irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK); 83 | 84 | setPowerButtonCB(powerButtonCB); 85 | 86 | // Keep the ARM7 mostly idle 87 | while (!exitflag) { 88 | if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) { 89 | exitflag = true; 90 | } 91 | 92 | swiWaitForVBlank(); 93 | } 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /arm9/data/clickNoQuit.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/data/clickNoQuit.wav -------------------------------------------------------------------------------- /arm9/data/clickQuit.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/data/clickQuit.wav -------------------------------------------------------------------------------- /arm9/data/mus_intro.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/data/mus_intro.wav -------------------------------------------------------------------------------- /arm9/ds_arm9_hi.mem: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------- 2 | This Source Code Form is subject to the terms of the Mozilla Public License, 3 | v. 2.0. If a copy of the MPL was not distributed with this file, You can 4 | obtain one at https://mozilla.org/MPL/2.0/. 5 | --------------------------------------------------------------------------------*/ 6 | MEMORY { 7 | ewram : ORIGIN = 0x02004000, LENGTH = 3M + 512K - 0x4000 8 | dtcm : ORIGIN = 0x0b000000, LENGTH = 16K 9 | vectors : ORIGIN = 0x01000000, LENGTH = 256 10 | itcm : ORIGIN = 0x01000100, LENGTH = 32K - 256 11 | } 12 | -------------------------------------------------------------------------------- /arm9/ds_arm9_hi.specs: -------------------------------------------------------------------------------- 1 | %rename link old_link 2 | 3 | *link: 4 | %(old_link) -T ../ds_arm9_hi.mem%s -T ds_arm9.ld%s --gc-sections 5 | 6 | *startfile: 7 | ds_arm9_crt0%O%s crti%O%s crtbegin%O%s 8 | 9 | -------------------------------------------------------------------------------- /arm9/gfx/bgBottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgBottom.png -------------------------------------------------------------------------------- /arm9/gfx/bgDualKeypad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgDualKeypad.png -------------------------------------------------------------------------------- /arm9/gfx/bgFileSel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgFileSel.png -------------------------------------------------------------------------------- /arm9/gfx/bgHighScore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgHighScore.png -------------------------------------------------------------------------------- /arm9/gfx/bgInstructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgInstructions.png -------------------------------------------------------------------------------- /arm9/gfx/bgKeypad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgKeypad.png -------------------------------------------------------------------------------- /arm9/gfx/bgPaddles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgPaddles.png -------------------------------------------------------------------------------- /arm9/gfx/bgStarRaiders.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgStarRaiders.png -------------------------------------------------------------------------------- /arm9/gfx/bgTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/bgTop.png -------------------------------------------------------------------------------- /arm9/gfx/pdev_bg0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/pdev_bg0.png -------------------------------------------------------------------------------- /arm9/gfx/pdev_tbg0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/arm9/gfx/pdev_tbg0.png -------------------------------------------------------------------------------- /arm9/source/StellaDS.h: -------------------------------------------------------------------------------- 1 | #ifndef __DS_TOOLS_H 2 | #define __DS_TOOLS_H 3 | 4 | #include 5 | 6 | #include "Console.hxx" 7 | 8 | #define WAITVBL swiWaitForVBlank(); swiWaitForVBlank(); swiWaitForVBlank(); swiWaitForVBlank(); swiWaitForVBlank(); 9 | 10 | #define STELLADS_MENUINIT 0x01 11 | #define STELLADS_MENUSHOW 0x02 12 | #define STELLADS_PLAYINIT 0x03 13 | #define STELLADS_PLAYGAME 0x04 14 | #define STELLADS_QUITSTDS 0x05 15 | 16 | typedef enum { 17 | EMUARM7_INIT_SND = 0x123C, 18 | EMUARM7_STOP_SND = 0x123D, 19 | EMUARM7_PLAY_SND = 0x123E, 20 | } FifoMesType; 21 | 22 | #define MAX_ROMS_PER_DIRECTORY 1500 23 | #define MAX_FILE_NAME_LEN 199 24 | 25 | typedef struct FICtoLoad { 26 | char filename[MAX_FILE_NAME_LEN]; 27 | uInt8 directory; 28 | } FICA2600; 29 | 30 | extern Console* theConsole; 31 | extern Sound* theSound; 32 | 33 | extern FICA2600 vcsromlist[]; 34 | 35 | extern uInt16 atari_frames; 36 | extern uInt8 bInitialDiffSet; 37 | extern uInt8 tv_type_requested; 38 | extern uInt8 gSaveKeyEEWritten; 39 | extern uInt8 gSaveKeyIsDirty; 40 | extern uInt16 mySoundFreq; 41 | extern uInt16 emuState; 42 | extern uint8 sound_buffer[SOUND_SIZE]; 43 | extern uint8 bHaltEmulation; 44 | extern uint8 bScreenRefresh; 45 | extern uInt32 gAtariFrames; 46 | extern uInt32 gTotalAtariFrames; 47 | extern uInt16 console_color; 48 | 49 | #define ds_GetTicks() (TIMER0_DATA) 50 | 51 | extern void FadeToColor(unsigned char ucSens, unsigned short ucBG, unsigned char ucScr, unsigned char valEnd, unsigned char uWait); 52 | 53 | extern void dsInitScreenMain(void); 54 | extern void dsInitTimer(void); 55 | extern void dsInitPalette(void); 56 | 57 | extern void dsShowScreenEmu(void); 58 | extern void dsShowScreenMain(bool bFull); 59 | extern void dsFreeEmu(void); 60 | extern bool dsLoadGame(char *filename); 61 | 62 | extern bool dsWaitOnQuit(void); 63 | extern unsigned int dsWaitForRom(void); 64 | extern unsigned int dsWaitOnMenu(unsigned int actState); 65 | 66 | extern void dsPrintValue(int x, int y, unsigned int isSelect, char *pchStr); 67 | 68 | extern void dsMainLoop(void); 69 | 70 | extern void dsInstallSoundEmuFIFO(void); 71 | 72 | extern void vcsFindFiles(void); 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arm9/source/config.h: -------------------------------------------------------------------------------- 1 | // ===================================================================================================== 2 | // Stella DSi - Improved Version by Dave Bernazzani (wavemotion) 3 | // 4 | // See readme.txt for a list of everything that has changed in the baseline 1.0 code. 5 | // ===================================================================================================== 6 | #ifndef __CONFIG_H 7 | #define __CONFIG_H 8 | 9 | #include 10 | #include "Cart.hxx" 11 | 12 | // --------------------------- 13 | // Config handling... 14 | // --------------------------- 15 | #define CONFIG_VER 0x000C 16 | 17 | #define MAX_CONFIGS 1300 18 | 19 | struct AllConfig_t 20 | { 21 | uInt16 config_ver; 22 | struct CartInfo cart[MAX_CONFIGS]; 23 | struct GlobalCartInfo global; 24 | uInt32 crc32; 25 | }; 26 | 27 | extern struct AllConfig_t allConfigs; 28 | 29 | void LoadConfig(void); 30 | void ShowConfig(void); 31 | void SaveConfig(bool bShow); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /arm9/source/emucore/Booster.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include "Event.hxx" 23 | #include "Booster.hxx" 24 | 25 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | BoosterGrip::BoosterGrip(Jack jack, const Event& event) 27 | : Controller(jack, event) 28 | { 29 | } 30 | 31 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 32 | BoosterGrip::~BoosterGrip() 33 | { 34 | } 35 | 36 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 37 | bool BoosterGrip::read(DigitalPin pin) 38 | { 39 | switch(pin) 40 | { 41 | case One: 42 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroUp) == 0) : 43 | (myEvent.get(Event::JoystickOneUp) == 0); 44 | 45 | case Two: 46 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroDown) == 0) : 47 | (myEvent.get(Event::JoystickOneDown) == 0); 48 | 49 | case Three: 50 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroLeft) == 0) : 51 | (myEvent.get(Event::JoystickOneLeft) == 0); 52 | 53 | case Four: 54 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroRight) == 0) : 55 | (myEvent.get(Event::JoystickOneRight) == 0); 56 | 57 | case Six: 58 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroFire) == 0) : 59 | (myEvent.get(Event::JoystickOneFire) == 0); 60 | 61 | default: 62 | return true; 63 | } 64 | } 65 | 66 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 67 | Int32 BoosterGrip::read(AnalogPin pin) 68 | { 69 | // The CBS Booster-grip has two more buttons on it. These buttons are 70 | // connected to the inputs usually used by paddles. 71 | 72 | switch(pin) 73 | { 74 | case Five: 75 | if(myJack == Left) 76 | { 77 | return (myEvent.get(Event::BoosterGripZeroBooster) != 0) ? 78 | minimumResistance : maximumResistance; 79 | } 80 | else 81 | { 82 | return (myEvent.get(Event::BoosterGripOneBooster) != 0) ? 83 | minimumResistance : maximumResistance; 84 | } 85 | 86 | case Nine: 87 | if(myJack == Left) 88 | { 89 | return (myEvent.get(Event::BoosterGripZeroTrigger) != 0) ? 90 | minimumResistance : maximumResistance; 91 | } 92 | else 93 | { 94 | return (myEvent.get(Event::BoosterGripOneTrigger) != 0) ? 95 | minimumResistance : maximumResistance; 96 | } 97 | 98 | default: 99 | return maximumResistance; 100 | } 101 | } 102 | 103 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 104 | void BoosterGrip::write(DigitalPin, bool) 105 | { 106 | // Writing doesn't do anything to the booster grip... 107 | } 108 | 109 | -------------------------------------------------------------------------------- /arm9/source/emucore/Booster.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef BOOSTERGRIP_HXX 23 | #define BOOSTERGRIP_HXX 24 | 25 | #include "bspf.hxx" 26 | #include "Control.hxx" 27 | 28 | /** 29 | The standard Atari 2600 joystick controller fitted with the 30 | CBS Booster grip. The Booster grip has two more fire buttons 31 | on it (a booster and a trigger). 32 | 33 | @author Bradford W. Mott 34 | @version $Id: Booster.hxx,v 1.2 2005/02/13 19:17:02 stephena Exp $ 35 | */ 36 | class BoosterGrip : public Controller 37 | { 38 | public: 39 | /** 40 | Create a new booster grip joystick plugged into the specified jack 41 | 42 | @param jack The jack the controller is plugged into 43 | @param event The event object to use for events 44 | */ 45 | BoosterGrip(Jack jack, const Event& event); 46 | 47 | /** 48 | Destructor 49 | */ 50 | virtual ~BoosterGrip(); 51 | 52 | public: 53 | /** 54 | Read the value of the specified digital pin for this controller. 55 | 56 | @param pin The pin of the controller jack to read 57 | @return The state of the pin 58 | */ 59 | virtual bool read(DigitalPin pin); 60 | 61 | /** 62 | Read the resistance at the specified analog pin for this controller. 63 | The returned value is the resistance measured in ohms. 64 | 65 | @param pin The pin of the controller jack to read 66 | @return The resistance at the specified pin 67 | */ 68 | virtual Int32 read(AnalogPin pin); 69 | 70 | /** 71 | Write the given value to the specified digital pin for this 72 | controller. Writing is only allowed to the pins associated 73 | with the PIA. Therefore you cannot write to pin six. 74 | 75 | @param pin The pin of the controller jack to write to 76 | @param value The value to write to the pin 77 | */ 78 | virtual void write(DigitalPin pin, bool value); 79 | }; 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart0840.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGE0840_HXX 23 | #define CARTRIDGE0840_HXX 24 | 25 | class Cartridge0840; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for the 0840 Econobanking scheme with rwo 4K banks. 32 | */ 33 | class Cartridge0840 : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | Cartridge0840(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~Cartridge0840(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | 93 | private: 94 | // Previous Device's page access 95 | PageAccess myHotSpotPageAccess[16]; 96 | 97 | // The 8K ROM image of the cartridge 98 | uInt8 *myImage; 99 | }; 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart0FA0.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGE0FA0_HXX 23 | #define CARTRIDGE0FA0_HXX 24 | 25 | class Cartridge0FA0; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for some brazilian 8K bankswitched games. There 32 | are two 4K banks, which are switched by accessing 33 | (address & $16A0) = $06a0 (bank 0) and = $06c0 (bank 1). 34 | Actual addresses used by these carts are e.g. $0FA0, $0FC0 and $EFC0. 35 | The code accepts further potential hotspot addresses. 36 | 37 | @author Thomas Jentzsch 38 | */ 39 | 40 | class Cartridge0FA0 : public Cartridge 41 | { 42 | public: 43 | /** 44 | Create a new cartridge using the specified image 45 | 46 | @param image Pointer to the ROM image 47 | */ 48 | Cartridge0FA0(const uInt8* image); 49 | 50 | /** 51 | Destructor 52 | */ 53 | virtual ~Cartridge0FA0(); 54 | 55 | public: 56 | /** 57 | Get a null terminated string which is the device's name (i.e. "M6532") 58 | 59 | @return The name of the device 60 | */ 61 | virtual const char* name() const; 62 | 63 | /** 64 | Reset device to its power-on state 65 | */ 66 | virtual void reset(); 67 | 68 | /** 69 | Install cartridge in the specified system. Invoked by the system 70 | when the cartridge is attached to it. 71 | 72 | @param system The system the device should install itself in 73 | */ 74 | virtual void install(System& system); 75 | 76 | public: 77 | /** 78 | Get the byte at the specified address. 79 | 80 | @return The byte at the specified address 81 | */ 82 | virtual uInt8 peek(uInt16 address); 83 | 84 | /** 85 | Change the byte at the specified address to the given value 86 | 87 | @param address The address where the value should be stored 88 | @param value The value to be stored at the address 89 | */ 90 | virtual void poke(uInt16 address, uInt8 value); 91 | 92 | private: 93 | /** 94 | Install pages for the specified bank in the system 95 | 96 | @param bank The bank that should be installed in the system 97 | */ 98 | void bank(uInt16 bank); 99 | 100 | // Check if we should switch banks on this address access 101 | void checkSwitchBank(uInt16 address); 102 | 103 | private: 104 | // Previous Device's page access 105 | PageAccess myHotSpotPageAccess; 106 | 107 | // The 8K ROM image of the cartridge 108 | uInt8 *myImage; 109 | }; 110 | #endif 111 | 112 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart2K.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include 23 | #include "Cart2K.hxx" 24 | #include "System.hxx" 25 | #include 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | Cartridge2K::Cartridge2K(const uInt8* image) 29 | { 30 | myImage = fast_cart_buffer; 31 | // Copy the ROM image into my buffer 32 | for(uInt32 addr = 0; addr < 4096; ++addr) 33 | { 34 | myImage[addr] = image[addr % 2048]; 35 | } 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | Cartridge2K::~Cartridge2K() 40 | { 41 | } 42 | 43 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 44 | const char* Cartridge2K::name() const 45 | { 46 | return "2K"; 47 | } 48 | 49 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 50 | void Cartridge2K::reset() 51 | { 52 | } 53 | 54 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 55 | void Cartridge2K::install(System& system) 56 | { 57 | mySystem = &system; 58 | uInt16 shift = mySystem->pageShift(); 59 | uInt16 mask = mySystem->pageMask(); 60 | 61 | // Make sure the system we're being installed in has a page size that'll work 62 | assert((0x1000 & mask) == 0); 63 | 64 | page_access.directPokeBase = 0; 65 | page_access.device = this; 66 | 67 | // Map ROM image into the system 68 | for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) 69 | { 70 | page_access.directPeekBase = &myImage[address & 0x07FF]; 71 | mySystem->setPageAccess(address >> mySystem->pageShift(), page_access); 72 | } 73 | } 74 | 75 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 76 | uInt8 Cartridge2K::peek(uInt16 address) 77 | { 78 | return myImage[address & 0x07FF]; 79 | } 80 | 81 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 82 | void Cartridge2K::poke(uInt16, uInt8) 83 | { 84 | // This is ROM so poking has no effect :-) 85 | } 86 | 87 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart2K.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGE2K_HXX 23 | #define CARTRIDGE2K_HXX 24 | 25 | class Cartridge2K; 26 | class System; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | This is the standard Atari 2K cartridge. These cartridges 33 | are not bankswitched, however, the data repeats twice in the 34 | 2600's 4K cartridge addressing space. 35 | 36 | @author Bradford W. Mott 37 | @version $Id: Cart2K.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 38 | */ 39 | class Cartridge2K : public Cartridge 40 | { 41 | public: 42 | /** 43 | Create a new cartridge using the specified image 44 | 45 | @param image Pointer to the ROM image 46 | */ 47 | Cartridge2K(const uInt8* image); 48 | 49 | /** 50 | Destructor 51 | */ 52 | virtual ~Cartridge2K(); 53 | 54 | public: 55 | /** 56 | Get a null terminated string which is the device's name (i.e. "M6532") 57 | 58 | @return The name of the device 59 | */ 60 | virtual const char* name() const; 61 | 62 | /** 63 | Reset cartridge to its power-on state 64 | */ 65 | virtual void reset(); 66 | 67 | /** 68 | Install cartridge in the specified system. Invoked by the system 69 | when the cartridge is attached to it. 70 | 71 | @param system The system the device should install itself in 72 | */ 73 | virtual void install(System& system); 74 | 75 | public: 76 | /** 77 | Get the byte at the specified address 78 | 79 | @return The byte at the specified address 80 | */ 81 | virtual uInt8 peek(uInt16 address); 82 | 83 | /** 84 | Change the byte at the specified address to the given value 85 | 86 | @param address The address where the value should be stored 87 | @param value The value to be stored at the address 88 | */ 89 | virtual void poke(uInt16 address, uInt8 value); 90 | 91 | private: 92 | // The 2k ROM image for the cartridge 93 | uInt8 *myImage; 94 | }; 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart3F.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGE3F_HXX 23 | #define CARTRIDGE3F_HXX 24 | 25 | class Cartridge3F; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | This is the cartridge class for Tigervision's bankswitched 32 | games. In this bankswitching scheme the 2600's 4K cartridge 33 | address space is broken into two 2K segments. The last 2K 34 | segment always points to the last 2K of the ROM image. The 35 | desired bank number of the first 2K segment is selected by 36 | storing its value into $3F. Actually, any write to location 37 | $00 to $3F will change banks. Although, the Tigervision games 38 | only used 8K this bankswitching scheme supports up to 512K. 39 | 40 | @author Bradford W. Mott 41 | @version $Id: Cart3F.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 42 | */ 43 | class Cartridge3F : public Cartridge 44 | { 45 | public: 46 | /** 47 | Create a new cartridge using the specified image and size 48 | 49 | @param image Pointer to the ROM image 50 | @param size The size of the ROM image 51 | */ 52 | Cartridge3F(const uInt8* image, uInt32 size); 53 | 54 | /** 55 | Destructor 56 | */ 57 | virtual ~Cartridge3F(); 58 | 59 | public: 60 | /** 61 | Get a null terminated string which is the device's name (i.e. "M6532") 62 | 63 | @return The name of the device 64 | */ 65 | virtual const char* name() const; 66 | 67 | /** 68 | Reset device to its power-on state 69 | */ 70 | virtual void reset(); 71 | 72 | /** 73 | Install cartridge in the specified system. Invoked by the system 74 | when the cartridge is attached to it. 75 | 76 | @param system The system the device should install itself in 77 | */ 78 | virtual void install(System& system); 79 | 80 | public: 81 | /** 82 | Get the byte at the specified address 83 | 84 | @return The byte at the specified address 85 | */ 86 | virtual uInt8 peek(uInt16 address); 87 | 88 | /** 89 | Change the byte at the specified address to the given value 90 | 91 | @param address The address where the value should be stored 92 | @param value The value to be stored at the address 93 | */ 94 | virtual void poke(uInt16 address, uInt8 value); 95 | 96 | private: 97 | /** 98 | Map the specified bank into the first segment 99 | 100 | @param bank The bank that should be mapped 101 | */ 102 | void bank(uInt16 bank); 103 | 104 | private: 105 | // Pointer to a ROM image of the cartridge 106 | uInt8* myImage; 107 | 108 | // Size of the ROM image 109 | uInt32 mySize; 110 | 111 | uInt32 myBankMod; 112 | }; 113 | #endif 114 | 115 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart4K.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include 23 | #include "Cart4K.hxx" 24 | #include "System.hxx" 25 | #include 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | Cartridge4K::Cartridge4K(const uInt8* image) 29 | { 30 | myImage = fast_cart_buffer; 31 | // Copy the ROM image into my buffer 32 | for(uInt32 addr = 0; addr < 4096; ++addr) 33 | { 34 | myImage[addr] = image[addr]; 35 | } 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | Cartridge4K::~Cartridge4K() 40 | { 41 | } 42 | 43 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 44 | const char* Cartridge4K::name() const 45 | { 46 | return "4K"; 47 | } 48 | 49 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 50 | void Cartridge4K::reset() 51 | { 52 | } 53 | 54 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 55 | void Cartridge4K::install(System& system) 56 | { 57 | mySystem = &system; 58 | uInt16 shift = mySystem->pageShift(); 59 | uInt16 mask = mySystem->pageMask(); 60 | 61 | // Make sure the system we're being installed in has a page size that'll work 62 | assert((0x1000 & mask) == 0); 63 | 64 | page_access.directPokeBase = 0; 65 | page_access.device = this; 66 | 67 | // Map ROM image into the system 68 | for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) 69 | { 70 | page_access.directPeekBase = &myImage[address & 0x0FFF]; 71 | mySystem->setPageAccess(address >> mySystem->pageShift(), page_access); 72 | } 73 | } 74 | 75 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 76 | uInt8 Cartridge4K::peek(uInt16 address) 77 | { 78 | return myImage[address & 0x0FFF]; 79 | } 80 | 81 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 82 | void Cartridge4K::poke(uInt16, uInt8) 83 | { 84 | // This is ROM so poking has no effect :-) 85 | } 86 | -------------------------------------------------------------------------------- /arm9/source/emucore/Cart4K.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGE4K_HXX 23 | #define CARTRIDGE4K_HXX 24 | 25 | class Cartridge4K; 26 | class System; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | This is the standard Atari 4K cartridge. These cartridges are 33 | not bankswitched. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: Cart4K.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 37 | */ 38 | class Cartridge4K : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | Cartridge4K(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~Cartridge4K(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset cartridge to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | // The 4K ROM image for the cartridge 92 | uInt8 *myImage; 93 | }; 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartBF.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CartridgeBF_HXX 23 | #define CartridgeBF_HXX 24 | 25 | class CartridgeBF; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for 256K banked BF games. 32 | */ 33 | class CartridgeBF : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | CartridgeBF(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~CartridgeBF(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | 93 | private: 94 | // The 256K ROM image of the cartridge 95 | uInt8 *myImage; 96 | }; 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartBFSC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CartridgeBFSC_HXX 23 | #define CartridgeBFSC_HXX 24 | 25 | class CartridgeBFSC; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for 256K banked BF games. 32 | */ 33 | class CartridgeBFSC : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | CartridgeBFSC(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~CartridgeBFSC(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | 93 | private: 94 | // The 256K ROM image of the cartridge 95 | uInt8 *myImage; 96 | }; 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartCDF.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // See the file "License.txt" for information on usage and redistribution of 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 16 | // 17 | // $Id$ 18 | //============================================================================ 19 | 20 | #ifndef CARTRIDGE_CDF_HXX 21 | #define CARTRIDGE_CDF_HXX 22 | 23 | class System; 24 | #ifdef THUMB_SUPPORT 25 | class Thumbulator; 26 | #endif 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | #define COMMSTREAM 0x20 32 | #define JUMPSTREAM_BASE 0x21 33 | 34 | #define DSRAM 0x800 35 | 36 | extern bool isCDFJPlus; 37 | extern uInt16 myAmplitudeStream; 38 | extern uInt8 myDataStreamFetch; 39 | extern uInt8 peekvalue; 40 | extern Int32 myDPCPCycles; 41 | extern uInt8 myMode; 42 | extern u8 myLDXenabled; 43 | extern u8 myLDYenabled; 44 | extern uInt16 myFastFetcherOffset; 45 | extern uInt16 myMusicWaveformSize[3]; 46 | 47 | /** 48 | Cartridge class used for CDF/CDFJ. 49 | */ 50 | class CartridgeCDF : public Cartridge 51 | { 52 | public: 53 | /** 54 | Create a new cartridge using the specified image 55 | 56 | @param image Pointer to the ROM image 57 | @param size The size of the ROM image 58 | */ 59 | CartridgeCDF(const uInt8* image, uInt32 size); 60 | 61 | /** 62 | Destructor 63 | */ 64 | virtual ~CartridgeCDF(); 65 | 66 | public: 67 | /** 68 | Reset device to its power-on state 69 | */ 70 | void reset(); 71 | 72 | /** 73 | Notification method invoked by the system right before the 74 | system resets its cycle counter to zero. It may be necessary 75 | to override this method for devices that remember cycle counts. 76 | */ 77 | void systemCyclesReset(); 78 | 79 | /** 80 | Install cartridge in the specified system. Invoked by the system 81 | when the cartridge is attached to it. 82 | 83 | @param system The system the device should install itself in 84 | */ 85 | void install(System& system); 86 | 87 | /** 88 | Install pages for the specified bank in the system. 89 | 90 | @param bank The bank that should be installed in the system 91 | */ 92 | void bank(uInt16 bank); 93 | 94 | 95 | /** 96 | Get a descriptor for the device name (used in error checking). 97 | 98 | @return The name of the object 99 | */ 100 | virtual const char* name() const; 101 | 102 | public: 103 | /** 104 | Get the byte at the specified address. 105 | 106 | @return The byte at the specified address 107 | */ 108 | virtual uInt8 peek(uInt16 address); 109 | 110 | /** 111 | Change the byte at the specified address to the given value 112 | 113 | @param address The address where the value should be stored 114 | @param value The value to be stored at the address 115 | */ 116 | virtual void poke(uInt16 address, uInt8 value); 117 | 118 | uInt8 peekMusic(void); 119 | 120 | private: 121 | /** 122 | Call Special Functions 123 | */ 124 | void callFunction(uInt8 value); 125 | uInt32 scanCDFDriver(uInt32 searchValue); 126 | 127 | uInt32 getWaveform(uInt8 index) const; 128 | 129 | private: 130 | }; 131 | 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartCTY.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CartridgeCTY_HXX 24 | #define CartridgeCTY_HXX 25 | 26 | class CartridgeCTY; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | extern uInt16 myTunePosition; 32 | extern uInt32 myAudioCycles; 33 | extern uInt32 deltaCyclesX10; 34 | extern uInt8 myOperationType; 35 | 36 | extern uInt8 CTY_updateMusicModeDataFetchers(void); 37 | 38 | /** 39 | Cartridge class used for Chetiry - has extra RAM and an EE Chip 40 | */ 41 | class CartridgeCTY : public Cartridge 42 | { 43 | public: 44 | /** 45 | Create a new cartridge using the specified image 46 | 47 | @param image Pointer to the ROM image 48 | */ 49 | CartridgeCTY(const uInt8* image, uInt32 size); 50 | 51 | /** 52 | Destructor 53 | */ 54 | virtual ~CartridgeCTY(); 55 | 56 | public: 57 | /** 58 | Get a null terminated string which is the device's name (i.e. "M6532") 59 | 60 | @return The name of the device 61 | */ 62 | virtual const char* name() const; 63 | 64 | /** 65 | Reset device to its power-on state 66 | */ 67 | virtual void reset(); 68 | 69 | /** 70 | Install cartridge in the specified system. Invoked by the system 71 | when the cartridge is attached to it. 72 | 73 | @param system The system the device should install itself in 74 | */ 75 | virtual void install(System& system); 76 | 77 | virtual void systemCyclesReset(); 78 | 79 | public: 80 | /** 81 | Get the byte at the specified address. 82 | 83 | @return The byte at the specified address 84 | */ 85 | virtual uInt8 peek(uInt16 address); 86 | 87 | /** 88 | Change the byte at the specified address to the given value 89 | 90 | @param address The address where the value should be stored 91 | @param value The value to be stored at the address 92 | */ 93 | virtual void poke(uInt16 address, uInt8 value); 94 | 95 | private: 96 | /** 97 | Install pages for the specified bank in the system 98 | 99 | @param bank The bank that should be installed in the system 100 | */ 101 | void bank(uInt16 bank); 102 | void handle_cty_flash_backing(void); 103 | void updateTune(void); 104 | uInt8 ramReadWrite(void); 105 | 106 | private: 107 | 108 | // The ROM image of the cartridge 109 | uInt8 *myImage; 110 | 111 | // The 256 bytes of RAM on the cartridge 112 | uInt8 *ctyRAM; 113 | 114 | // The 256 bytes of EEPROM on the cartridge 115 | uInt8 *ctyEE; 116 | }; 117 | #endif 118 | 119 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartCV.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGECV_HXX 23 | #define CARTRIDGECV_HXX 24 | 25 | class CartridgeCV; 26 | class System; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Commavid's extra-RAM games. 33 | 34 | $F000-$F3FF read from RAM 35 | $F400-$F7FF write to RAM 36 | $F800-$FFFF ROM 37 | 38 | @author Eckhard Stolberg 39 | @version $Id: CartCV.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 40 | */ 41 | class CartridgeCV : public Cartridge 42 | { 43 | public: 44 | /** 45 | Create a new cartridge using the specified image 46 | 47 | @param image Pointer to the ROM image 48 | */ 49 | CartridgeCV(const uInt8* image, uInt32 size); 50 | 51 | /** 52 | Destructor 53 | */ 54 | virtual ~CartridgeCV(); 55 | 56 | public: 57 | /** 58 | Get a null terminated string which is the device's name (i.e. "M6532") 59 | 60 | @return The name of the device 61 | */ 62 | virtual const char* name() const; 63 | 64 | /** 65 | Reset cartridge to its power-on state 66 | */ 67 | virtual void reset(); 68 | 69 | /** 70 | Install cartridge in the specified system. Invoked by the system 71 | when the cartridge is attached to it. 72 | 73 | @param system The system the device should install itself in 74 | */ 75 | virtual void install(System& system); 76 | 77 | public: 78 | /** 79 | Get the byte at the specified address 80 | 81 | @return The byte at the specified address 82 | */ 83 | virtual uInt8 peek(uInt16 address); 84 | 85 | /** 86 | Change the byte at the specified address to the given value 87 | 88 | @param address The address where the value should be stored 89 | @param value The value to be stored at the address 90 | */ 91 | virtual void poke(uInt16 address, uInt8 value); 92 | }; 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartDF.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CartridgeDF_HXX 23 | #define CartridgeDF_HXX 24 | 25 | class CartridgeDF; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for 128K banked DF games with 128 bytes of extra SUPER RAM 32 | */ 33 | class CartridgeDF : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | CartridgeDF(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~CartridgeDF(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | 93 | private: 94 | // The 128K ROM image of the cartridge 95 | uInt8 *myImage; 96 | }; 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartDFSC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CartridgeDFSCSC_HXX 23 | #define CartridgeDFSCSC_HXX 24 | 25 | class CartridgeDFSC; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for 128K banked DF games with 128 bytes of extra SUPER RAM 32 | */ 33 | class CartridgeDFSC : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | CartridgeDFSC(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~CartridgeDFSC(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | 93 | private: 94 | // The 128K ROM image of the cartridge 95 | uInt8 *myImage; 96 | }; 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartDPC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGEDCP_HXX 23 | #define CARTRIDGEDCP_HXX 24 | 25 | class CartridgeDPC; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for Pitfall II. There are two 4K program banks, a 32 | 2K display bank, and the DPC chip. For complete details on the DPC chip 33 | see David P. Crane's United States Patent Number 4,644,495. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartDPC.hxx,v 1.4 2005/02/13 19:17:02 stephena Exp $ 37 | */ 38 | class CartridgeDPC : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeDPC(const uInt8* image, uInt32 size); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeDPC(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Notification method invoked by the system right before the 68 | system resets its cycle counter to zero. It may be necessary 69 | to override this method for devices that remember cycle counts. 70 | */ 71 | virtual void systemCyclesReset(); 72 | 73 | /** 74 | Install cartridge in the specified system. Invoked by the system 75 | when the cartridge is attached to it. 76 | 77 | @param system The system the device should install itself in 78 | */ 79 | virtual void install(System& system); 80 | 81 | public: 82 | /** 83 | Get the byte at the specified address. 84 | 85 | @return The byte at the specified address 86 | */ 87 | virtual uInt8 peek(uInt16 address); 88 | 89 | uInt8 peek_fetch(uInt16 address); // Fast DPC fetcher 90 | 91 | /** 92 | Change the byte at the specified address to the given value 93 | 94 | @param address The address where the value should be stored 95 | @param value The value to be stored at the address 96 | */ 97 | virtual void poke(uInt16 address, uInt8 value); 98 | 99 | private: 100 | /** 101 | Install pages for the specified bank in the system 102 | 103 | @param bank The bank that should be installed in the system 104 | */ 105 | inline void bank(uInt16 bank); 106 | 107 | void updateMusicModeDataFetchers(uInt32 delta); 108 | }; 109 | #endif 110 | 111 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartE0.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGEE0_HXX 23 | #define CARTRIDGEE0_HXX 24 | 25 | class CartridgeF8; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | This is the cartridge class for Parker Brothers' 8K games. In 32 | this bankswitching scheme the 2600's 4K cartridge address space 33 | is broken into four 1K segments. The desired 1K slice of the 34 | ROM is selected by accessing 1FE0 to 1FE7 for the first 1K. 35 | 1FE8 to 1FEF selects the slice for the second 1K, and 1FF0 to 36 | 1FF8 selects the slice for the third 1K. The last 1K segment 37 | always points to the last 1K of the ROM image. 38 | 39 | @author Bradford W. Mott 40 | @version $Id: CartE0.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 41 | */ 42 | class CartridgeE0 : public Cartridge 43 | { 44 | public: 45 | /** 46 | Create a new cartridge using the specified image 47 | 48 | @param image Pointer to the ROM image 49 | */ 50 | CartridgeE0(const uInt8* image); 51 | 52 | /** 53 | Destructor 54 | */ 55 | virtual ~CartridgeE0(); 56 | 57 | public: 58 | /** 59 | Get a null terminated string which is the device's name (i.e. "M6532") 60 | 61 | @return The name of the device 62 | */ 63 | virtual const char* name() const; 64 | 65 | /** 66 | Reset device to its power-on state 67 | */ 68 | virtual void reset(); 69 | 70 | /** 71 | Install cartridge in the specified system. Invoked by the system 72 | when the cartridge is attached to it. 73 | 74 | @param system The system the device should install itself in 75 | */ 76 | virtual void install(System& system); 77 | 78 | public: 79 | /** 80 | Get the byte at the specified address. 81 | 82 | @return The byte at the specified address 83 | */ 84 | virtual uInt8 peek(uInt16 address); 85 | 86 | /** 87 | Change the byte at the specified address to the given value 88 | 89 | @param address The address where the value should be stored 90 | @param value The value to be stored at the address 91 | */ 92 | virtual void poke(uInt16 address, uInt8 value); 93 | 94 | private: 95 | /** 96 | Install the specified slice for segment zero 97 | 98 | @param slice The slice to map into the segment 99 | */ 100 | void segmentZero(uInt16 slice); 101 | 102 | /** 103 | Install the specified slice for segment one 104 | 105 | @param slice The slice to map into the segment 106 | */ 107 | void segmentOne(uInt16 slice); 108 | 109 | /** 110 | Install the specified slice for segment two 111 | 112 | @param slice The slice to map into the segment 113 | */ 114 | void segmentTwo(uInt16 slice); 115 | 116 | private: 117 | // The 8K ROM image of the cartridge 118 | uInt8 *myImage; 119 | }; 120 | #endif 121 | 122 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartEF.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGEEF_HXX 23 | #define CARTRIDGEEF_HXX 24 | 25 | class CartridgeEF; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for 64K banked EF games. 32 | */ 33 | class CartridgeEF : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | CartridgeEF(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~CartridgeEF(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | 93 | private: 94 | }; 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartEFSC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CartridgeEFSCSC_HXX 23 | #define CartridgeEFSCSC_HXX 24 | 25 | class CartridgeEFSC; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for 64K banked EF games with 128 bytes of extra SUPER RAM 32 | */ 33 | class CartridgeEFSC : public Cartridge 34 | { 35 | public: 36 | /** 37 | Create a new cartridge using the specified image 38 | 39 | @param image Pointer to the ROM image 40 | */ 41 | CartridgeEFSC(const uInt8* image); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~CartridgeEFSC(); 47 | 48 | public: 49 | /** 50 | Get a null terminated string which is the device's name (i.e. "M6532") 51 | 52 | @return The name of the device 53 | */ 54 | virtual const char* name() const; 55 | 56 | /** 57 | Reset device to its power-on state 58 | */ 59 | virtual void reset(); 60 | 61 | /** 62 | Install cartridge in the specified system. Invoked by the system 63 | when the cartridge is attached to it. 64 | 65 | @param system The system the device should install itself in 66 | */ 67 | virtual void install(System& system); 68 | 69 | public: 70 | /** 71 | Get the byte at the specified address. 72 | 73 | @return The byte at the specified address 74 | */ 75 | virtual uInt8 peek(uInt16 address); 76 | 77 | /** 78 | Change the byte at the specified address to the given value 79 | 80 | @param address The address where the value should be stored 81 | @param value The value to be stored at the address 82 | */ 83 | virtual void poke(uInt16 address, uInt8 value); 84 | 85 | private: 86 | /** 87 | Install pages for the specified bank in the system 88 | 89 | @param bank The bank that should be installed in the system 90 | */ 91 | void bank(uInt16 bank); 92 | }; 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartF4.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef CARTRIDGEF4_HXX 23 | #define CARTRIDGEF4_HXX 24 | 25 | class CartridgeF4; 26 | 27 | #include "bspf.hxx" 28 | #include "Cart.hxx" 29 | 30 | /** 31 | Cartridge class used for Atari's 32K bankswitched games. There 32 | are eight 4K banks. 33 | 34 | @author Bradford W. Mott 35 | @version $Id: CartF4.hxx,v 1.2 2005/02/13 19:17:02 stephena Exp $ 36 | */ 37 | class CartridgeF4 : public Cartridge 38 | { 39 | public: 40 | /** 41 | Create a new cartridge using the specified image 42 | 43 | @param image Pointer to the ROM image 44 | */ 45 | CartridgeF4(const uInt8* image); 46 | 47 | /** 48 | Destructor 49 | */ 50 | virtual ~CartridgeF4(); 51 | 52 | public: 53 | /** 54 | Get a null terminated string which is the device's name (i.e. "M6532") 55 | 56 | @return The name of the device 57 | */ 58 | virtual const char* name() const; 59 | 60 | /** 61 | Reset device to its power-on state 62 | */ 63 | virtual void reset(); 64 | 65 | /** 66 | Install cartridge in the specified system. Invoked by the system 67 | when the cartridge is attached to it. 68 | 69 | @param system The system the device should install itself in 70 | */ 71 | virtual void install(System& system); 72 | 73 | public: 74 | /** 75 | Get the byte at the specified address. 76 | 77 | @return The byte at the specified address 78 | */ 79 | virtual uInt8 peek(uInt16 address); 80 | 81 | /** 82 | Change the byte at the specified address to the given value 83 | 84 | @param address The address where the value should be stored 85 | @param value The value to be stored at the address 86 | */ 87 | virtual void poke(uInt16 address, uInt8 value); 88 | 89 | private: 90 | /** 91 | Install pages for the specified bank in the system 92 | 93 | @param bank The bank that should be installed in the system 94 | */ 95 | void bank(uInt16 bank); 96 | 97 | private: 98 | // The 32K ROM image of the cartridge 99 | uInt8 *myImage; 100 | }; 101 | #endif 102 | 103 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartF4SC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEF4SC_HXX 24 | #define CARTRIDGEF4SC_HXX 25 | 26 | class CartridgeF4SC; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Atari's 32K bankswitched games with 33 | 128 bytes of RAM. There are eight 4K banks. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartF4SC.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 37 | */ 38 | class CartridgeF4SC : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeF4SC(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeF4SC(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | // Indicates which bank is currently active 100 | uInt16 myCurrentOffset; 101 | 102 | // The 32K ROM image of the cartridge 103 | uInt8 *myImage; 104 | 105 | // The 128 bytes of RAM will use fast_cart_buffer[] 106 | }; 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartF6.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEF6_HXX 24 | #define CARTRIDGEF6_HXX 25 | 26 | class CartridgeF6; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Atari's 16K bankswitched games. There 33 | are four 4K banks. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartF6.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 37 | */ 38 | class CartridgeF6 : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeF6(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeF6(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | // The 16K ROM image of the cartridge 100 | uInt8 *myImage; 101 | }; 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartF6SC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEF6SC_HXX 24 | #define CARTRIDGEF6SC_HXX 25 | 26 | class CartridgeF6SC; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Atari's 16K bankswitched games with 33 | 128 bytes of RAM. There are four 4K banks. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartF6SC.hxx,v 1.3 2005/02/13 19:17:02 stephena Exp $ 37 | */ 38 | class CartridgeF6SC : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeF6SC(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeF6SC(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | // The 16K ROM image of the cartridge 100 | uInt8 *myImage; 101 | 102 | // The 128 bytes of RAM will use fast_cart_buffer[] 103 | }; 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartF8.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEF8_HXX 24 | #define CARTRIDGEF8_HXX 25 | 26 | class CartridgeF8; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Atari's 8K bankswitched games. There 33 | are two 4K banks. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartF8.hxx,v 1.2 2002/05/13 19:17:32 stephena Exp $ 37 | */ 38 | class CartridgeF8 : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeF8(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeF8(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | 100 | // The 8K ROM image of the cartridge 101 | uInt8 *myImage; 102 | }; 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartF8SC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEF8SC_HXX 24 | #define CARTRIDGEF8SC_HXX 25 | 26 | class CartridgeF8SC; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Atari's 8K bankswitched games with 33 | 128 bytes of RAM. There are two 4K banks. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartF8SC.hxx,v 1.2 2002/05/13 19:17:32 stephena Exp $ 37 | */ 38 | class CartridgeF8SC : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeF8SC(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeF8SC(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | 100 | // The 8K ROM image of the cartridge 101 | uInt8 *myImage; 102 | }; 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartFA2.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CartridgeFA2_HXX 24 | #define CartridgeFA2_HXX 25 | 26 | class CartridgeFA2; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for CBS' RAM Plus cartridges extended format. 33 | There are seven 4K banks and 256 bytes of RAM. 34 | */ 35 | class CartridgeFA2 : public Cartridge 36 | { 37 | public: 38 | /** 39 | Create a new cartridge using the specified image 40 | 41 | @param image Pointer to the ROM image 42 | */ 43 | CartridgeFA2(const uInt8* image, uInt32 size); 44 | 45 | /** 46 | Destructor 47 | */ 48 | virtual ~CartridgeFA2(); 49 | 50 | public: 51 | /** 52 | Get a null terminated string which is the device's name (i.e. "M6532") 53 | 54 | @return The name of the device 55 | */ 56 | virtual const char* name() const; 57 | 58 | /** 59 | Reset device to its power-on state 60 | */ 61 | virtual void reset(); 62 | 63 | /** 64 | Install cartridge in the specified system. Invoked by the system 65 | when the cartridge is attached to it. 66 | 67 | @param system The system the device should install itself in 68 | */ 69 | virtual void install(System& system); 70 | 71 | public: 72 | /** 73 | Get the byte at the specified address. 74 | 75 | @return The byte at the specified address 76 | */ 77 | virtual uInt8 peek(uInt16 address); 78 | 79 | /** 80 | Change the byte at the specified address to the given value 81 | 82 | @param address The address where the value should be stored 83 | @param value The value to be stored at the address 84 | */ 85 | virtual void poke(uInt16 address, uInt8 value); 86 | 87 | private: 88 | /** 89 | Install pages for the specified bank in the system 90 | 91 | @param bank The bank that should be installed in the system 92 | */ 93 | void bank(uInt16 bank); 94 | void handle_fa2_flash_backing(void); 95 | 96 | private: 97 | 98 | // The ROM image of the cartridge 99 | uInt8 *myImage; 100 | }; 101 | #endif 102 | 103 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartFASC.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEFASC_HXX 24 | #define CARTRIDGEFASC_HXX 25 | 26 | class CartridgeFASC; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for CBS' RAM Plus cartridges. There are 33 | three 4K banks and 256 bytes of RAM. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartFASC.hxx,v 1.2 2002/05/13 19:17:32 stephena Exp $ 37 | */ 38 | class CartridgeFASC : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeFASC(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeFASC(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | // The 12K ROM image of the cartridge 100 | uInt8 *myImage; 101 | }; 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartFE.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include 24 | #include "CartFE.hxx" 25 | #include "System.hxx" 26 | #include 27 | 28 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 29 | CartridgeFE::CartridgeFE(const uInt8* image) 30 | { 31 | myImage = fast_cart_buffer; 32 | 33 | // Copy the ROM image into my buffer 34 | for(uInt32 addr = 0; addr < 8192; ++addr) 35 | { 36 | myImage[addr] = image[addr]; 37 | } 38 | } 39 | 40 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 41 | CartridgeFE::~CartridgeFE() 42 | { 43 | } 44 | 45 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 46 | const char* CartridgeFE::name() const 47 | { 48 | return "FE"; 49 | } 50 | 51 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 52 | void CartridgeFE::reset() 53 | { 54 | } 55 | 56 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 57 | void CartridgeFE::install(System& system) 58 | { 59 | mySystem = &system; 60 | uInt16 shift = mySystem->pageShift(); 61 | uInt16 mask = mySystem->pageMask(); 62 | 63 | // Make sure the system we're being installed in has a page size that'll work 64 | assert((0x1000 & mask) == 0); 65 | 66 | // Map all of the accesses to call peek and poke 67 | for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) 68 | { 69 | page_access.directPeekBase = 0; 70 | page_access.directPokeBase = 0; 71 | page_access.device = this; 72 | mySystem->setPageAccess(i >> shift, page_access); 73 | } 74 | } 75 | 76 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 77 | uInt8 CartridgeFE::peek(uInt16 address) 78 | { 79 | // The bank is determined by A13 of the processor 80 | if (address & 0x2000) 81 | return fast_cart_buffer[(address & 0x0FFF)]; 82 | else 83 | return fast_cart_buffer[(address & 0x1FFF)]; 84 | } 85 | 86 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 87 | void CartridgeFE::poke(uInt16, uInt8) 88 | { 89 | } 90 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartFE.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEFE_HXX 24 | #define CARTRIDGEFE_HXX 25 | 26 | class CartridgeFE; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Bankswitching method used by Activison's Robot Tank and Decathlon. 33 | 34 | Kevin Horton describes FE as follows: 35 | 36 | Used only on two carts (Robot Tank and Decathlon). These 37 | carts are very weird. It does not use accesses to the stack 38 | like was previously thought. Instead, if you watch the called 39 | addresses very carefully, you can see that they are either Dxxx 40 | or Fxxx. This determines the bank to use. Just monitor A13 of 41 | the processor and use it to determine your bank! :-) Of course 42 | the 6507 in the 2600 does not have an A13, so the cart must have 43 | an extra bit in the ROM matrix to tell when to switch banks. 44 | There is *no* way to determine which bank you want to be in from 45 | monitoring the bus. 46 | 47 | @author Bradford W. Mott 48 | @version $Id: CartFE.hxx,v 1.2 2002/05/13 19:17:32 stephena Exp $ 49 | */ 50 | class CartridgeFE : public Cartridge 51 | { 52 | public: 53 | /** 54 | Create a new cartridge using the specified image 55 | 56 | @param image Pointer to the ROM image 57 | */ 58 | CartridgeFE(const uInt8* image); 59 | 60 | /** 61 | Destructor 62 | */ 63 | virtual ~CartridgeFE(); 64 | 65 | public: 66 | /** 67 | Get a null terminated string which is the device's name (i.e. "M6532") 68 | 69 | @return The name of the device 70 | */ 71 | virtual const char* name() const; 72 | 73 | /** 74 | Reset device to its power-on state 75 | */ 76 | virtual void reset(); 77 | 78 | /** 79 | Install cartridge in the specified system. Invoked by the system 80 | when the cartridge is attached to it. 81 | 82 | @param system The system the device should install itself in 83 | */ 84 | virtual void install(System& system); 85 | 86 | public: 87 | /** 88 | Get the byte at the specified address. 89 | 90 | @return The byte at the specified address 91 | */ 92 | virtual uInt8 peek(uInt16 address); 93 | 94 | /** 95 | Change the byte at the specified address to the given value 96 | 97 | @param address The address where the value should be stored 98 | @param value The value to be stored at the address 99 | */ 100 | virtual void poke(uInt16 address, uInt8 value); 101 | 102 | private: 103 | // The 8K ROM image of the cartridge 104 | uInt8 *myImage; 105 | }; 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartJANE.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEJANE_HXX 24 | #define CARTRIDGEJANE_HXX 25 | 26 | class CartridgeJANE; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for the Tarzan Prototype - four banks with 33 | hotspots at FFF0 (bank 0), FFF1 (bank 1), FFF8 (bank2), FFF9 (bank3) 34 | */ 35 | class CartridgeJANE : public Cartridge 36 | { 37 | public: 38 | /** 39 | Create a new cartridge using the specified image 40 | 41 | @param image Pointer to the ROM image 42 | */ 43 | CartridgeJANE(const uInt8* image); 44 | 45 | /** 46 | Destructor 47 | */ 48 | virtual ~CartridgeJANE(); 49 | 50 | public: 51 | /** 52 | Get a null terminated string which is the device's name (i.e. "M6532") 53 | 54 | @return The name of the device 55 | */ 56 | virtual const char* name() const; 57 | 58 | /** 59 | Reset device to its power-on state 60 | */ 61 | virtual void reset(); 62 | 63 | /** 64 | Install cartridge in the specified system. Invoked by the system 65 | when the cartridge is attached to it. 66 | 67 | @param system The system the device should install itself in 68 | */ 69 | virtual void install(System& system); 70 | 71 | public: 72 | /** 73 | Get the byte at the specified address. 74 | 75 | @return The byte at the specified address 76 | */ 77 | virtual uInt8 peek(uInt16 address); 78 | 79 | /** 80 | Change the byte at the specified address to the given value 81 | 82 | @param address The address where the value should be stored 83 | @param value The value to be stored at the address 84 | */ 85 | virtual void poke(uInt16 address, uInt8 value); 86 | 87 | private: 88 | /** 89 | Install pages for the specified bank in the system 90 | 91 | @param bank The bank that should be installed in the system 92 | */ 93 | void bank(uInt16 bank); 94 | 95 | private: 96 | // The 16K ROM image of the cartridge 97 | uInt8 *myImage; 98 | }; 99 | #endif 100 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartMB.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEMB_HXX 24 | #define CARTRIDGEMB_HXX 25 | 26 | class CartridgeMB; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for Dynacom Megaboy 33 | There are 16 4K banks. 34 | Accessing $1FF0 switches to next bank. 35 | 36 | @author Eckhard Stolberg 37 | @version $Id: CartMB.hxx,v 1.2 2002/05/13 19:17:32 stephena Exp $ 38 | */ 39 | class CartridgeMB : public Cartridge 40 | { 41 | public: 42 | /** 43 | Create a new cartridge using the specified image 44 | 45 | @param image Pointer to the ROM image 46 | */ 47 | CartridgeMB(const uInt8* image); 48 | 49 | /** 50 | Destructor 51 | */ 52 | virtual ~CartridgeMB(); 53 | 54 | public: 55 | /** 56 | Get a null terminated string which is the device's name (i.e. "M6532") 57 | 58 | @return The name of the device 59 | */ 60 | virtual const char* name() const; 61 | 62 | /** 63 | Reset device to its power-on state 64 | */ 65 | virtual void reset(); 66 | 67 | /** 68 | Install cartridge in the specified system. Invoked by the system 69 | when the cartridge is attached to it. 70 | 71 | @param system The system the device should install itself in 72 | */ 73 | virtual void install(System& system); 74 | 75 | public: 76 | /** 77 | Get the byte at the specified address. 78 | 79 | @return The byte at the specified address 80 | */ 81 | virtual uInt8 peek(uInt16 address); 82 | 83 | /** 84 | Change the byte at the specified address to the given value 85 | 86 | @param address The address where the value should be stored 87 | @param value The value to be stored at the address 88 | */ 89 | virtual void poke(uInt16 address, uInt8 value); 90 | 91 | private: 92 | /** 93 | Install pages for the next bank in the system 94 | */ 95 | void incbank(); 96 | }; 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartSB.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CartridgeSB_HXX 24 | #define CartridgeSB_HXX 25 | 26 | class CartridgeSB; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for 128K or 256K Super Cart ROMs 33 | */ 34 | class CartridgeSB : public Cartridge 35 | { 36 | public: 37 | /** 38 | Create a new cartridge using the specified image 39 | 40 | @param image Pointer to the ROM image 41 | */ 42 | CartridgeSB(const uInt8* image, uInt32 size); 43 | 44 | /** 45 | Destructor 46 | */ 47 | virtual ~CartridgeSB(); 48 | 49 | public: 50 | /** 51 | Get a null terminated string which is the device's name (i.e. "M6532") 52 | 53 | @return The name of the device 54 | */ 55 | virtual const char* name() const; 56 | 57 | /** 58 | Reset device to its power-on state 59 | */ 60 | virtual void reset(); 61 | 62 | /** 63 | Install cartridge in the specified system. Invoked by the system 64 | when the cartridge is attached to it. 65 | 66 | @param system The system the device should install itself in 67 | */ 68 | virtual void install(System& system); 69 | 70 | public: 71 | /** 72 | Get the byte at the specified address. 73 | 74 | @return The byte at the specified address 75 | */ 76 | virtual uInt8 peek(uInt16 address); 77 | 78 | /** 79 | Change the byte at the specified address to the given value 80 | 81 | @param address The address where the value should be stored 82 | @param value The value to be stored at the address 83 | */ 84 | virtual void poke(uInt16 address, uInt8 value); 85 | 86 | private: 87 | /** 88 | Install pages for the specified bank in the system 89 | 90 | @param bank The bank that should be installed in the system 91 | */ 92 | void bank(uInt16 bank); 93 | 94 | bool checkSwitchBank(uInt16 address); 95 | 96 | private: 97 | uInt8 myRomBankCount; 98 | 99 | uInt16 sbLastBank; 100 | 101 | // The 128K or 256K ROM image of the cartridge 102 | uInt8 *myImage; 103 | 104 | // Previous Device's page access 105 | PageAccess myHotSpotPageAccess; 106 | }; 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartTV.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CartridgeTV_HXX 24 | #define CartridgeTV_HXX 25 | 26 | class CartridgeTV; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for 256K banked BF games. 33 | */ 34 | class CartridgeTV : public Cartridge 35 | { 36 | public: 37 | /** 38 | Create a new cartridge using the specified image 39 | 40 | @param image Pointer to the ROM image 41 | */ 42 | CartridgeTV(const uInt8* image); 43 | 44 | /** 45 | Destructor 46 | */ 47 | virtual ~CartridgeTV(); 48 | 49 | public: 50 | /** 51 | Get a null terminated string which is the device's name (i.e. "M6532") 52 | 53 | @return The name of the device 54 | */ 55 | virtual const char* name() const; 56 | 57 | /** 58 | Reset device to its power-on state 59 | */ 60 | virtual void reset(); 61 | 62 | /** 63 | Install cartridge in the specified system. Invoked by the system 64 | when the cartridge is attached to it. 65 | 66 | @param system The system the device should install itself in 67 | */ 68 | virtual void install(System& system); 69 | 70 | public: 71 | /** 72 | Get the byte at the specified address. 73 | 74 | @return The byte at the specified address 75 | */ 76 | virtual uInt8 peek(uInt16 address); 77 | 78 | /** 79 | Change the byte at the specified address to the given value 80 | 81 | @param address The address where the value should be stored 82 | @param value The value to be stored at the address 83 | */ 84 | virtual void poke(uInt16 address, uInt8 value); 85 | 86 | private: 87 | /** 88 | Install pages for the specified bank in the system 89 | 90 | @param bank The bank that should be installed in the system 91 | */ 92 | void bank(uInt16 bank); 93 | 94 | private: 95 | uInt8 *myImage; 96 | }; 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartUA.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEUA_HXX 24 | #define CARTRIDGEUA_HXX 25 | 26 | class CartridgeUA; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | #include "System.hxx" 31 | 32 | /** 33 | Cartridge class used for UA Limited's 8K bankswitched games. There 34 | are two 4K banks. 35 | 36 | @author Bradford W. Mott 37 | @version $Id: CartUA.hxx,v 1.1 2004/06/25 03:44:12 bwmott Exp $ 38 | */ 39 | class CartridgeUA : public Cartridge 40 | { 41 | public: 42 | /** 43 | Create a new cartridge using the specified image 44 | 45 | @param image Pointer to the ROM image 46 | */ 47 | CartridgeUA(const uInt8* image, uInt8 bSwap); 48 | 49 | /** 50 | Destructor 51 | */ 52 | virtual ~CartridgeUA(); 53 | 54 | public: 55 | /** 56 | Get a null terminated string which is the device's name (i.e. "M6532") 57 | 58 | @return The name of the device 59 | */ 60 | virtual const char* name() const; 61 | 62 | /** 63 | Reset device to its power-on state 64 | */ 65 | virtual void reset(); 66 | 67 | /** 68 | Install cartridge in the specified system. Invoked by the system 69 | when the cartridge is attached to it. 70 | 71 | @param system The system the device should install itself in 72 | */ 73 | virtual void install(System& system); 74 | 75 | public: 76 | /** 77 | Get the byte at the specified address. 78 | 79 | @return The byte at the specified address 80 | */ 81 | virtual uInt8 peek(uInt16 address); 82 | 83 | /** 84 | Change the byte at the specified address to the given value 85 | 86 | @param address The address where the value should be stored 87 | @param value The value to be stored at the address 88 | */ 89 | virtual void poke(uInt16 address, uInt8 value); 90 | 91 | private: 92 | /** 93 | Install pages for the specified bank in the system 94 | 95 | @param bank The bank that should be installed in the system 96 | */ 97 | void bank(uInt16 bank); 98 | 99 | private: 100 | // Some UA carts swap the bank hotspots 101 | uInt8 bUAswapped; 102 | 103 | // The 8K ROM image of the cartridge 104 | uInt8 *myImage; 105 | 106 | // Previous Device's page access 107 | PageAccess myHotSpotPageAccess; 108 | PageAccess myHotSpotPageAccess2; 109 | }; 110 | #endif 111 | 112 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartWF8.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEWF8_HXX 24 | #define CARTRIDGEWF8_HXX 25 | 26 | class CartridgeWF8; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | 31 | /** 32 | Cartridge class used for some later Coleco games 33 | like Smurf Rescue and Zaxxon which utilize a write to 0xFFF8 34 | to bank-switch. 35 | */ 36 | class CartridgeWF8 : public Cartridge 37 | { 38 | public: 39 | /** 40 | Create a new cartridge using the specified image 41 | 42 | @param image Pointer to the ROM image 43 | */ 44 | CartridgeWF8(const uInt8* image); 45 | 46 | /** 47 | Destructor 48 | */ 49 | virtual ~CartridgeWF8(); 50 | 51 | public: 52 | /** 53 | Get a null terminated string which is the device's name (i.e. "M6532") 54 | 55 | @return The name of the device 56 | */ 57 | virtual const char* name() const; 58 | 59 | /** 60 | Reset device to its power-on state 61 | */ 62 | virtual void reset(); 63 | 64 | /** 65 | Install cartridge in the specified system. Invoked by the system 66 | when the cartridge is attached to it. 67 | 68 | @param system The system the device should install itself in 69 | */ 70 | virtual void install(System& system); 71 | 72 | public: 73 | /** 74 | Get the byte at the specified address. 75 | 76 | @return The byte at the specified address 77 | */ 78 | virtual uInt8 peek(uInt16 address); 79 | 80 | /** 81 | Change the byte at the specified address to the given value 82 | 83 | @param address The address where the value should be stored 84 | @param value The value to be stored at the address 85 | */ 86 | virtual void poke(uInt16 address, uInt8 value); 87 | 88 | private: 89 | /** 90 | Install pages for the specified bank in the system 91 | 92 | @param bank The bank that should be installed in the system 93 | */ 94 | void bank(uInt16 bank); 95 | 96 | private: 97 | 98 | // The 8K ROM image of the cartridge 99 | uInt8 *myImage; 100 | }; 101 | #endif 102 | -------------------------------------------------------------------------------- /arm9/source/emucore/CartX07.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef CARTRIDGEX07_HXX 24 | #define CARTRIDGEX07_HXX 25 | 26 | class CartridgeX07; 27 | 28 | #include "bspf.hxx" 29 | #include "Cart.hxx" 30 | #include "System.hxx" 31 | 32 | /** 33 | Cartridge class used for X07 (mainly Stella's Stocking from Atariage). 64K max. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: CartX07.hxx,v 1.1 2004/06/25 03:44:12 bwmott Exp $ 37 | */ 38 | class CartridgeX07 : public Cartridge 39 | { 40 | public: 41 | /** 42 | Create a new cartridge using the specified image 43 | 44 | @param image Pointer to the ROM image 45 | */ 46 | CartridgeX07(const uInt8* image); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~CartridgeX07(); 52 | 53 | public: 54 | /** 55 | Get a null terminated string which is the device's name (i.e. "M6532") 56 | 57 | @return The name of the device 58 | */ 59 | virtual const char* name() const; 60 | 61 | /** 62 | Reset device to its power-on state 63 | */ 64 | virtual void reset(); 65 | 66 | /** 67 | Install cartridge in the specified system. Invoked by the system 68 | when the cartridge is attached to it. 69 | 70 | @param system The system the device should install itself in 71 | */ 72 | virtual void install(System& system); 73 | 74 | public: 75 | /** 76 | Get the byte at the specified address. 77 | 78 | @return The byte at the specified address 79 | */ 80 | virtual uInt8 peek(uInt16 address); 81 | 82 | /** 83 | Change the byte at the specified address to the given value 84 | 85 | @param address The address where the value should be stored 86 | @param value The value to be stored at the address 87 | */ 88 | virtual void poke(uInt16 address, uInt8 value); 89 | 90 | private: 91 | /** 92 | Install pages for the specified bank in the system 93 | 94 | @param bank The bank that should be installed in the system 95 | */ 96 | void bank(uInt16 bank); 97 | 98 | private: 99 | // The 64K ROM image of the cartridge 100 | uInt8 *myImage; 101 | }; 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /arm9/source/emucore/Control.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include 24 | #include "Control.hxx" 25 | 26 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 27 | Controller::Controller(Jack jack, const Event& event) 28 | : myJack(jack), 29 | myEvent(event) 30 | { 31 | } 32 | 33 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | Controller::~Controller() 35 | { 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | const Int32 Controller::maximumResistance = 0x7FFFFFFF; 40 | 41 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | const Int32 Controller::minimumResistance = 0x00000000; 43 | 44 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 45 | Controller::Controller(const Controller& c) 46 | : myJack(c.myJack), 47 | myEvent(c.myEvent) 48 | { 49 | assert(false); 50 | } 51 | 52 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 53 | Controller& Controller::operator = (const Controller&) 54 | { 55 | assert(false); 56 | return *this; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /arm9/source/emucore/Device.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include "Device.hxx" 24 | 25 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | Device::Device() 27 | : mySystem(0) 28 | { 29 | } 30 | 31 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 32 | Device::~Device() 33 | { 34 | } 35 | 36 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 37 | void Device::systemCyclesReset() 38 | { 39 | // By default I do nothing when my system resets its cycle counter 40 | } 41 | 42 | -------------------------------------------------------------------------------- /arm9/source/emucore/Device.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef DEVICE_HXX 24 | #define DEVICE_HXX 25 | 26 | class System; 27 | 28 | #include "bspf.hxx" 29 | 30 | /** 31 | Abstract base class for devices which can be attached to a 6502 32 | based system. 33 | 34 | @author Bradford W. Mott 35 | @version $Id: Device.hxx,v 1.2 2002/05/13 19:10:25 stephena Exp $ 36 | */ 37 | class Device 38 | { 39 | public: 40 | /** 41 | Create a new device 42 | */ 43 | Device(); 44 | 45 | /** 46 | Destructor 47 | */ 48 | virtual ~Device(); 49 | 50 | public: 51 | /** 52 | Get a null terminated string which is the device's name (i.e. "M6532") 53 | 54 | @return The name of the device 55 | */ 56 | virtual const char* name() const = 0; 57 | 58 | /** 59 | Reset device to its power-on state 60 | */ 61 | virtual void reset() = 0; 62 | 63 | /** 64 | Notification method invoked by the system right before the 65 | system resets its cycle counter to zero. It may be necessary 66 | to override this method for devices that remember cycle counts. 67 | */ 68 | virtual void systemCyclesReset(); 69 | 70 | /** 71 | Install device in the specified system. Invoked by the system 72 | when the device is attached to it. 73 | 74 | @param system The system the device should install itself in 75 | */ 76 | virtual void install(System& system) = 0; 77 | 78 | public: 79 | /** 80 | Get the byte at the specified address 81 | 82 | @return The byte at the specified address 83 | */ 84 | virtual uInt8 peek(uInt16 address) = 0; 85 | 86 | /** 87 | Change the byte at the specified address to the given value 88 | 89 | @param address The address where the value should be stored 90 | @param value The value to be stored at the address 91 | */ 92 | virtual void poke(uInt16 address, uInt8 value) = 0; 93 | 94 | protected: 95 | /// Pointer to the system the device is installed in or the null pointer 96 | System* mySystem; 97 | }; 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /arm9/source/emucore/Driving.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef DRIVING_HXX 24 | #define DRIVING_HXX 25 | 26 | class Driving; 27 | class System; 28 | 29 | #include "bspf.hxx" 30 | #include "Control.hxx" 31 | 32 | /** 33 | The standard Atari 2600 Indy 500 driving controller. 34 | 35 | @author Bradford W. Mott 36 | @version $Id: Driving.hxx,v 1.1.1.1 2001/12/27 19:54:21 bwmott Exp $ 37 | */ 38 | class Driving : public Controller 39 | { 40 | public: 41 | /** 42 | Create a new Indy 500 driving controller plugged into 43 | the specified jack 44 | 45 | @param jack The jack the controller is plugged into 46 | @param event The event object to use for events 47 | */ 48 | Driving(Jack jack, const Event& event); 49 | 50 | /** 51 | Destructor 52 | */ 53 | virtual ~Driving(); 54 | 55 | public: 56 | /** 57 | Read the value of the specified digital pin for this controller. 58 | 59 | @param pin The pin of the controller jack to read 60 | @return The state of the pin 61 | */ 62 | virtual bool read(DigitalPin pin); 63 | 64 | /** 65 | Read the resistance at the specified analog pin for this controller. 66 | The returned value is the resistance measured in ohms. 67 | 68 | @param pin The pin of the controller jack to read 69 | @return The resistance at the specified pin 70 | */ 71 | virtual Int32 read(AnalogPin pin); 72 | 73 | /** 74 | Write the given value to the specified digital pin for this 75 | controller. Writing is only allowed to the pins associated 76 | with the PIA. Therefore you cannot write to pin six. 77 | 78 | @param pin The pin of the controller jack to write to 79 | @param value The value to write to the pin 80 | */ 81 | virtual void write(DigitalPin pin, bool value); 82 | 83 | private: 84 | // Counter to iterate through the gray codes 85 | uInt32 myCounter; 86 | }; 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /arm9/source/emucore/Event.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include 24 | #include "Event.hxx" 25 | 26 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 27 | Event::Event() 28 | { 29 | // Set all of the events to 0 / false to start with 30 | for(int i = 0; i < (int)Event::LastType; ++i) 31 | { 32 | myValues[i] = 0; 33 | } 34 | } 35 | 36 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 37 | Event::~Event() 38 | { 39 | } 40 | 41 | -------------------------------------------------------------------------------- /arm9/source/emucore/EventHandler.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include "Console.hxx" 29 | #include "Event.hxx" 30 | #include "EventHandler.hxx" 31 | #include "StellaEvent.hxx" 32 | #include "System.hxx" 33 | #include "bspf.hxx" 34 | 35 | // Create the event object which will be used for this handler 36 | Event myStellaEvent; 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | EventHandler::EventHandler(Console* console) 40 | { 41 | } 42 | 43 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 44 | EventHandler::~EventHandler() 45 | { 46 | } 47 | 48 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 49 | Event* EventHandler::event() 50 | { 51 | return &myStellaEvent; 52 | } 53 | -------------------------------------------------------------------------------- /arm9/source/emucore/EventHandler.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef EVENTHANDLER_HXX 24 | #define EVENTHANDLER_HXX 25 | 26 | #include "bspf.hxx" 27 | #include "Event.hxx" 28 | #include "StellaEvent.hxx" 29 | 30 | class Console; 31 | 32 | 33 | /** 34 | This class takes care of event remapping and dispatching for the 35 | Stella core, as well as keeping track of the current 'mode'. 36 | 37 | The frontends will send translated events here, and the handler will 38 | check to see what the current 'mode' is. For now, the modes can be 39 | normal and menu mode. 40 | 41 | If in normal mode, events received from the frontends are remapped and 42 | sent to the emulation core. If in menu mode, the events are sent 43 | unchanged to the user interface, where (among other things) changing key 44 | mapping can take place. 45 | 46 | @author Stephen Anthony 47 | @version $Id: EventHandler.hxx,v 1.14 2004/06/20 23:30:48 stephena Exp $ 48 | */ 49 | class EventHandler 50 | { 51 | public: 52 | /** 53 | Create a new event handler object 54 | */ 55 | EventHandler(Console* console); 56 | 57 | /** 58 | Destructor 59 | */ 60 | virtual ~EventHandler(); 61 | 62 | /** 63 | Returns the event object associated with this handler class. 64 | 65 | @return The event object 66 | */ 67 | Event* event(); 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /arm9/source/emucore/Genesis.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include 23 | 24 | #include "Event.hxx" 25 | #include "Genesis.hxx" 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | Genesis::Genesis(Jack jack, const Event& event) 29 | : Controller(jack, event) 30 | { 31 | } 32 | 33 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | Genesis::~Genesis() 35 | { 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | ITCM_CODE bool Genesis::read(DigitalPin pin) 40 | { 41 | switch(pin) 42 | { 43 | case One: 44 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroUp) == 0) : 45 | (myEvent.get(Event::JoystickOneUp) == 0); 46 | 47 | case Two: 48 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroDown) == 0) : 49 | (myEvent.get(Event::JoystickOneDown) == 0); 50 | 51 | case Three: 52 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroLeft) == 0) : 53 | (myEvent.get(Event::JoystickOneLeft) == 0); 54 | 55 | case Four: 56 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroRight) == 0) : 57 | (myEvent.get(Event::JoystickOneRight) == 0); 58 | 59 | case Six: 60 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroFire) == 0) : 61 | (myEvent.get(Event::JoystickOneFire) == 0); 62 | 63 | default: 64 | return true; 65 | } 66 | } 67 | 68 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 69 | ITCM_CODE Int32 Genesis::read(AnalogPin pin) 70 | { 71 | // The Genesis has one more button (C) that can be read by the 2600 72 | // However, it seems to work opposite to the BoosterGrip controller, 73 | // in that the logic is inverted. We still use the BoosterGrip events. 74 | 75 | switch(pin) 76 | { 77 | case Five: 78 | if(myJack == Left) 79 | { 80 | return (myEvent.get(Event::BoosterGripZeroBooster) == 0) ? 81 | minimumResistance : maximumResistance; 82 | } 83 | else 84 | { 85 | return (myEvent.get(Event::BoosterGripOneBooster) == 0) ? 86 | minimumResistance : maximumResistance; 87 | } 88 | 89 | case Nine: 90 | return minimumResistance; // This is actually how games can tell if we've got this controller plugged in! 91 | 92 | default: 93 | return maximumResistance; 94 | } 95 | } 96 | 97 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 98 | void Genesis::write(DigitalPin, bool) 99 | { 100 | // Writing doesn't do anything to the Genesis Controller... 101 | } 102 | 103 | -------------------------------------------------------------------------------- /arm9/source/emucore/Genesis.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef GENESIS_HXX 24 | #define GENESIS_HXX 25 | 26 | #include "bspf.hxx" 27 | #include "Control.hxx" 28 | 29 | /** 30 | The Genesis Controller has a 2nd button that can be read by the Atari 2600 31 | and is read via Analog on INPT5. 32 | */ 33 | 34 | class Genesis : public Controller 35 | { 36 | public: 37 | /** 38 | Create a new Genesis controller plugged into the specified jack 39 | 40 | @param jack The jack the controller is plugged into 41 | @param event The event object to use for events 42 | */ 43 | Genesis(Jack jack, const Event& event); 44 | 45 | /** 46 | Destructor 47 | */ 48 | virtual ~Genesis(); 49 | 50 | public: 51 | /** 52 | Read the value of the specified digital pin for this controller. 53 | 54 | @param pin The pin of the controller jack to read 55 | @return The state of the pin 56 | */ 57 | virtual bool read(DigitalPin pin); 58 | 59 | /** 60 | Read the resistance at the specified analog pin for this controller. 61 | The returned value is the resistance measured in ohms. 62 | 63 | @param pin The pin of the controller jack to read 64 | @return The resistance at the specified pin 65 | */ 66 | virtual Int32 read(AnalogPin pin); 67 | 68 | /** 69 | Write the given value to the specified digital pin for this 70 | controller. Writing is only allowed to the pins associated 71 | with the PIA. Therefore you cannot write to pin six. 72 | 73 | @param pin The pin of the controller jack to write to 74 | @param value The value to write to the pin 75 | */ 76 | virtual void write(DigitalPin pin, bool value); 77 | }; 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /arm9/source/emucore/Joystick.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include 23 | #include 24 | #include "Event.hxx" 25 | #include "Joystick.hxx" 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | Joystick::Joystick(Jack jack, const Event& event) 29 | : Controller(jack, event) 30 | { 31 | } 32 | 33 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | Joystick::~Joystick() 35 | { 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | ITCM_CODE bool Joystick::read(DigitalPin pin) 40 | { 41 | switch(pin) 42 | { 43 | case One: 44 | return (myJack == Left) ? (myStellaEvent.get(Event::JoystickZeroUp) == 0) : 45 | (myStellaEvent.get(Event::JoystickOneUp) == 0); 46 | 47 | case Two: 48 | return (myJack == Left) ? (myStellaEvent.get(Event::JoystickZeroDown) == 0) : 49 | (myStellaEvent.get(Event::JoystickOneDown) == 0); 50 | 51 | case Three: 52 | return (myJack == Left) ? (myStellaEvent.get(Event::JoystickZeroLeft) == 0) : 53 | (myStellaEvent.get(Event::JoystickOneLeft) == 0); 54 | 55 | case Four: 56 | return (myJack == Left) ? (myStellaEvent.get(Event::JoystickZeroRight) == 0) : 57 | (myStellaEvent.get(Event::JoystickOneRight) == 0); 58 | 59 | case Six: 60 | return (myJack == Left) ? (myStellaEvent.get(Event::JoystickZeroFire) == 0) : 61 | (myStellaEvent.get(Event::JoystickOneFire) == 0); 62 | 63 | default: 64 | return true; 65 | } 66 | } 67 | 68 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 69 | Int32 Joystick::read(AnalogPin) 70 | { 71 | // Analog pins are not connect in joystick so we have infinite resistance 72 | return maximumResistance; 73 | } 74 | 75 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 76 | void Joystick::write(DigitalPin, bool) 77 | { 78 | // Writing doesn't do anything to the joystick... 79 | } 80 | 81 | -------------------------------------------------------------------------------- /arm9/source/emucore/Joystick.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef JOYSTICK_HXX 24 | #define JOYSTICK_HXX 25 | 26 | #include "bspf.hxx" 27 | #include "Control.hxx" 28 | 29 | /** 30 | The standard Atari 2600 joystick controller. 31 | 32 | @author Bradford W. Mott 33 | @version $Id: Joystick.hxx,v 1.1.1.1 2001/12/27 19:54:22 bwmott Exp $ 34 | */ 35 | class Joystick : public Controller 36 | { 37 | public: 38 | /** 39 | Create a new joystick controller plugged into the specified jack 40 | 41 | @param jack The jack the controller is plugged into 42 | @param event The event object to use for events 43 | */ 44 | Joystick(Jack jack, const Event& event); 45 | 46 | /** 47 | Destructor 48 | */ 49 | virtual ~Joystick(); 50 | 51 | public: 52 | /** 53 | Read the value of the specified digital pin for this controller. 54 | 55 | @param pin The pin of the controller jack to read 56 | @return The state of the pin 57 | */ 58 | virtual bool read(DigitalPin pin); 59 | 60 | /** 61 | Read the resistance at the specified analog pin for this controller. 62 | The returned value is the resistance measured in ohms. 63 | 64 | @param pin The pin of the controller jack to read 65 | @return The resistance at the specified pin 66 | */ 67 | virtual Int32 read(AnalogPin pin); 68 | 69 | /** 70 | Write the given value to the specified digital pin for this 71 | controller. Writing is only allowed to the pins associated 72 | with the PIA. Therefore you cannot write to pin six. 73 | 74 | @param pin The pin of the controller jack to write to 75 | @param value The value to write to the pin 76 | */ 77 | virtual void write(DigitalPin pin, bool value); 78 | }; 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /arm9/source/emucore/Keyboard.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef KEYBOARD_HXX 24 | #define KEYBOARD_HXX 25 | 26 | #include "bspf.hxx" 27 | #include "Control.hxx" 28 | 29 | /** 30 | The standard Atari 2600 keyboard controller 31 | 32 | @author Bradford W. Mott 33 | @version $Id: Keyboard.hxx,v 1.1.1.1 2001/12/27 19:54:22 bwmott Exp $ 34 | */ 35 | class Keyboard : public Controller 36 | { 37 | public: 38 | /** 39 | Create a new keyboard controller plugged into the specified jack 40 | 41 | @param jack The jack the controller is plugged into 42 | @param event The event object to use for events 43 | */ 44 | Keyboard(Jack jack, const Event& event); 45 | 46 | /** 47 | Destructor 48 | */ 49 | virtual ~Keyboard(); 50 | 51 | public: 52 | /** 53 | Read the value of the specified digital pin for this controller. 54 | 55 | @param pin The pin of the controller jack to read 56 | @return The state of the pin 57 | */ 58 | virtual bool read(DigitalPin pin); 59 | 60 | /** 61 | Read the resistance at the specified analog pin for this controller. 62 | The returned value is the resistance measured in ohms. 63 | 64 | @param pin The pin of the controller jack to read 65 | @return The resistance at the specified pin 66 | */ 67 | virtual Int32 read(AnalogPin pin); 68 | 69 | /** 70 | Write the given value to the specified digital pin for this 71 | controller. Writing is only allowed to the pins associated 72 | with the PIA. Therefore you cannot write to pin six. 73 | 74 | @param pin The pin of the controller jack to write to 75 | @param value The value to write to the pin 76 | */ 77 | virtual void write(DigitalPin pin, bool value); 78 | 79 | private: 80 | // State of the output pins 81 | uInt8 myPinState; 82 | }; 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /arm9/source/emucore/M6502.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include 23 | 24 | #include "M6502.hxx" 25 | #include "Random.hxx" 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | M6502::M6502(uInt32 systemCyclesPerProcessorCycle) 29 | : mySystem(0) 30 | { 31 | uInt16 t; 32 | 33 | // Compute the BCD lookup table 34 | for(t = 0; t < 256; ++t) 35 | { 36 | ourBCDTable[0][t] = ((t >> 4) * 10) + (t & 0x0f); 37 | ourBCDTable[1][t] = (((t % 100) / 10) << 4) | (t % 10); 38 | } 39 | } 40 | 41 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | M6502::~M6502() 43 | { 44 | } 45 | 46 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 47 | void M6502::install(System& system) 48 | { 49 | // Remember which system I'm installed in 50 | mySystem = &system; 51 | } 52 | 53 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 54 | void M6502::reset() 55 | { 56 | Random random; 57 | // Clear the execution status flags 58 | myExecutionStatus = 0; 59 | 60 | // Set registers to default values 61 | A = random.next() & 0xFF; 62 | X = random.next() & 0xFF; 63 | Y = random.next() & 0xFF; 64 | 65 | SP = 0xff; 66 | PS(0x20); 67 | 68 | // Load PC from the reset vector 69 | gPC = (uInt16)mySystem->peek(0xfffc) | ((uInt16)mySystem->peek(0xfffd) << 8); 70 | gPC &= MY_ADDR_MASK; 71 | 72 | // Set the data bus back to zero 73 | myDataBusState = 0x02; 74 | } 75 | 76 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 77 | void M6502::stop() 78 | { 79 | myExecutionStatus |= StopExecutionBit; 80 | } 81 | 82 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 83 | ITCM_CODE uInt8 M6502::PS() const 84 | { 85 | uInt8 ps = 0x20; 86 | 87 | if(N & 0x80) ps |= 0x80; 88 | if(V) ps |= 0x40; 89 | if(B) ps |= 0x10; 90 | if(D) ps |= 0x08; 91 | if(I) ps |= 0x04; 92 | if(!notZ) ps |= 0x02; 93 | if(C) ps |= 0x01; 94 | 95 | return ps; 96 | } 97 | 98 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 | ITCM_CODE void M6502::PS(uInt8 ps) 100 | { 101 | N = ps & 0x80; 102 | V = ps & 0x40; 103 | B = ps & 0x10; 104 | D = ps & 0x08; 105 | I = ps & 0x04; 106 | notZ = !(ps & 0x02); 107 | C = ps & 0x01; 108 | } 109 | 110 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 111 | uInt8 M6502::ourBCDTable[2][256]; 112 | 113 | -------------------------------------------------------------------------------- /arm9/source/emucore/MD5.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef MD5_HXX 24 | #define MD5_HXX 25 | 26 | #include "bspf.hxx" 27 | 28 | /** 29 | Get the MD5 Message-Digest of the specified message with the 30 | given length. The digest consists of 32 hexadecimal digits. 31 | 32 | @param buffer The message to compute the digest of 33 | @param length The length of the message 34 | @return The message-digest 35 | */ 36 | string MD5(const uInt8* buffer, uInt32 length); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /arm9/source/emucore/NullDev.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include "NullDev.hxx" 24 | 25 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | NullDevice::NullDevice() 27 | { 28 | } 29 | 30 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 31 | NullDevice::~NullDevice() 32 | { 33 | } 34 | 35 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 36 | const char* NullDevice::name() const 37 | { 38 | return "NULL"; 39 | } 40 | 41 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | void NullDevice::reset() 43 | { 44 | } 45 | 46 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 47 | void NullDevice::install(System& system) 48 | { 49 | mySystem = &system; 50 | } 51 | 52 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 53 | uInt8 NullDevice::peek(uInt16 address) 54 | { 55 | return 0; 56 | } 57 | 58 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 59 | void NullDevice::poke(uInt16 address, uInt8 value) 60 | { 61 | // Do nothing 62 | return; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /arm9/source/emucore/NullDev.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef NULLDEVICE_HXX 24 | #define NULLDEVICE_HXX 25 | 26 | class System; 27 | 28 | #include "bspf.hxx" 29 | #include "Device.hxx" 30 | 31 | /** 32 | Class that represents a "null" device. The basic idea is that a 33 | null device is installed in a 6502 based system anywhere there are 34 | holes in the address space (i.e. no real device attached). 35 | 36 | @author Bradford W. Mott 37 | @version $Id: NullDev.hxx,v 1.2 2002/05/13 19:10:25 stephena Exp $ 38 | */ 39 | class NullDevice : public Device 40 | { 41 | public: 42 | /** 43 | Create a new null device 44 | */ 45 | NullDevice(); 46 | 47 | /** 48 | Destructor 49 | */ 50 | virtual ~NullDevice(); 51 | 52 | public: 53 | /** 54 | Get a null terminated string which is the device's name (i.e. "M6532") 55 | 56 | @return The name of the device 57 | */ 58 | virtual const char* name() const; 59 | 60 | /** 61 | Reset device to its power-on state 62 | */ 63 | virtual void reset(); 64 | 65 | /** 66 | Install device in the specified system. Invoked by the system 67 | when the device is attached to it. 68 | 69 | @param system The system the device should install itself in 70 | */ 71 | virtual void install(System& system); 72 | 73 | public: 74 | /** 75 | Get the byte at the specified address 76 | 77 | @return The byte at the specified address 78 | */ 79 | virtual uInt8 peek(uInt16 address); 80 | 81 | /** 82 | Change the byte at the specified address to the given value 83 | 84 | @param address The address where the value should be stored 85 | @param value The value to be stored at the address 86 | */ 87 | virtual void poke(uInt16 address, uInt8 value); 88 | }; 89 | #endif 90 | 91 | -------------------------------------------------------------------------------- /arm9/source/emucore/Paddles.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include 24 | #include "Event.hxx" 25 | #include "Paddles.hxx" 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | Paddles::Paddles(Jack jack, const Event& event) 29 | : Controller(jack, event) 30 | { 31 | } 32 | 33 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | Paddles::~Paddles() 35 | { 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | bool Paddles::read(DigitalPin pin) 40 | { 41 | switch(pin) 42 | { 43 | case Three: 44 | return (myJack == Left) ? (myEvent.get(Event::PaddleOneFire) == 0) : 45 | (myEvent.get(Event::PaddleThreeFire) == 0); 46 | 47 | case Four: 48 | return (myJack == Left) ? (myEvent.get(Event::PaddleZeroFire) == 0) : 49 | (myEvent.get(Event::PaddleTwoFire) == 0); 50 | 51 | default: 52 | // Other pins are not connected (floating high) 53 | return true; 54 | } 55 | } 56 | 57 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 58 | Int32 Paddles::read(AnalogPin pin) 59 | { 60 | switch(pin) 61 | { 62 | case Five: 63 | return (myJack == Left) ? myEvent.get(Event::PaddleOneResistance) : 64 | myEvent.get(Event::PaddleThreeResistance); 65 | 66 | case Nine: 67 | return (myJack == Left) ? myEvent.get(Event::PaddleZeroResistance) : 68 | myEvent.get(Event::PaddleTwoResistance); 69 | 70 | default: 71 | return maximumResistance; 72 | } 73 | } 74 | 75 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 76 | void Paddles::write(DigitalPin, bool) 77 | { 78 | // Writing doesn't do anything to the paddles... 79 | } 80 | 81 | -------------------------------------------------------------------------------- /arm9/source/emucore/Paddles.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef PADDLES_HXX 24 | #define PADDLES_HXX 25 | 26 | #include "bspf.hxx" 27 | #include "Control.hxx" 28 | 29 | /** 30 | The standard Atari 2600 pair of paddle controllers. 31 | 32 | @author Bradford W. Mott 33 | @version $Id: Paddles.hxx,v 1.1.1.1 2001/12/27 19:54:23 bwmott Exp $ 34 | */ 35 | class Paddles : public Controller 36 | { 37 | public: 38 | /** 39 | Create a new pair of paddle controllers plugged into the specified jack 40 | 41 | @param jack The jack the controller is plugged into 42 | @param event The event object to use for events 43 | */ 44 | Paddles(Jack jack, const Event& event); 45 | 46 | /** 47 | Destructor 48 | */ 49 | virtual ~Paddles(); 50 | 51 | public: 52 | /** 53 | Read the value of the specified digital pin for this controller. 54 | 55 | @param pin The pin of the controller jack to read 56 | @return The state of the pin 57 | */ 58 | virtual bool read(DigitalPin pin); 59 | 60 | /** 61 | Read the resistance at the specified analog pin for this controller. 62 | The returned value is the resistance measured in ohms. 63 | 64 | @param pin The pin of the controller jack to read 65 | @return The resistance at the specified pin 66 | */ 67 | virtual Int32 read(AnalogPin pin); 68 | 69 | /** 70 | Write the given value to the specified digital pin for this 71 | controller. Writing is only allowed to the pins associated 72 | with the PIA. Therefore you cannot write to pin six. 73 | 74 | @param pin The pin of the controller jack to write to 75 | @param value The value to write to the pin 76 | */ 77 | virtual void write(DigitalPin pin, bool value); 78 | }; 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /arm9/source/emucore/QuadTari.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include "Event.hxx" 24 | #include "QuadTari.hxx" 25 | #include "TIA.hxx" 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | QuadTari::QuadTari(Jack jack, const Event& event) 29 | : Controller(jack, event) 30 | { 31 | } 32 | 33 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | QuadTari::~QuadTari() 35 | { 36 | } 37 | 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | bool QuadTari::read(DigitalPin pin) 40 | { 41 | if (myVBLANK & 0x80) 42 | { 43 | switch(pin) 44 | { 45 | case One: 46 | return (myEvent.get(Event::JoystickOneUp) == 0); 47 | 48 | case Two: 49 | return (myEvent.get(Event::JoystickOneDown) == 0); 50 | 51 | case Three: 52 | return (myEvent.get(Event::JoystickOneLeft) == 0); 53 | 54 | case Four: 55 | return (myEvent.get(Event::JoystickOneRight) == 0); 56 | 57 | case Six: 58 | return (myEvent.get(Event::JoystickOneFire) == 0); 59 | 60 | default: 61 | return true; 62 | } 63 | } 64 | else 65 | { 66 | switch(pin) 67 | { 68 | case One: 69 | return (myEvent.get(Event::JoystickZeroUp) == 0); 70 | 71 | case Two: 72 | return (myEvent.get(Event::JoystickZeroDown) == 0); 73 | 74 | case Three: 75 | return (myEvent.get(Event::JoystickZeroLeft) == 0); 76 | 77 | case Four: 78 | return (myEvent.get(Event::JoystickZeroRight) == 0); 79 | 80 | case Six: 81 | return (myEvent.get(Event::JoystickZeroFire) == 0); 82 | 83 | default: 84 | return true; 85 | } 86 | } 87 | } 88 | 89 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 90 | Int32 QuadTari::read(AnalogPin pin) 91 | { 92 | switch(pin) 93 | { 94 | case Five: 95 | return minimumResistance; // This is actually how games can tell if we've got this controller plugged in! 96 | case Nine: 97 | return maximumResistance; // This is actually how games can tell if we've got this controller plugged in! 98 | 99 | default: 100 | return maximumResistance; 101 | } 102 | } 103 | 104 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 105 | void QuadTari::write(DigitalPin, bool) 106 | { 107 | // Writing doesn't do anything to our limited QuadTari implementation 108 | } 109 | 110 | -------------------------------------------------------------------------------- /arm9/source/emucore/QuadTari.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef QUADTARI_HXX 24 | #define QUADTARI_HXX 25 | 26 | #include "bspf.hxx" 27 | #include "Control.hxx" 28 | 29 | /** 30 | The QuadTari Controller is limited in this implementation to just 2 joysticks per port. 31 | This is enough for Dual-Stick and SaveKey. 32 | */ 33 | 34 | class QuadTari : public Controller 35 | { 36 | public: 37 | /** 38 | Create a new Genesis controller plugged into the specified jack 39 | 40 | @param jack The jack the controller is plugged into 41 | @param event The event object to use for events 42 | */ 43 | QuadTari(Jack jack, const Event& event); 44 | 45 | /** 46 | Destructor 47 | */ 48 | virtual ~QuadTari(); 49 | 50 | public: 51 | /** 52 | Read the value of the specified digital pin for this controller. 53 | 54 | @param pin The pin of the controller jack to read 55 | @return The state of the pin 56 | */ 57 | virtual bool read(DigitalPin pin); 58 | 59 | /** 60 | Read the resistance at the specified analog pin for this controller. 61 | The returned value is the resistance measured in ohms. 62 | 63 | @param pin The pin of the controller jack to read 64 | @return The resistance at the specified pin 65 | */ 66 | virtual Int32 read(AnalogPin pin); 67 | 68 | /** 69 | Write the given value to the specified digital pin for this 70 | controller. Writing is only allowed to the pins associated 71 | with the PIA. Therefore you cannot write to pin six. 72 | 73 | @param pin The pin of the controller jack to write to 74 | @param value The value to write to the pin 75 | */ 76 | virtual void write(DigitalPin pin, bool value); 77 | }; 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /arm9/source/emucore/Random.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include "Random.hxx" 24 | 25 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | Random::Random() 27 | { 28 | srand((unsigned) time(NULL)); 29 | } 30 | 31 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 32 | uInt32 Random::next() 33 | { 34 | return (uInt32)rand(); 35 | } 36 | -------------------------------------------------------------------------------- /arm9/source/emucore/Random.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef RANDOM_HXX 24 | #define RANDOM_HXX 25 | 26 | #include "bspf.hxx" 27 | 28 | /** 29 | This is a quick-and-dirty random number generator. It is based on 30 | information in Chapter 7 of "Numerical Recipes in C". It's a simple 31 | linear congruential generator. 32 | 33 | @author Bradford W. Mott 34 | @version $Id: Random.hxx,v 1.1.1.1 2001/12/27 19:54:23 bwmott Exp $ 35 | */ 36 | class Random 37 | { 38 | public: 39 | /** 40 | Create a new random number generator 41 | */ 42 | Random(); 43 | 44 | public: 45 | /** 46 | Answer the next random number from the random number generator 47 | 48 | @return A random number 49 | */ 50 | uInt32 next(); 51 | }; 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /arm9/source/emucore/SaveKey.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #include 24 | #include 25 | #include "MT24LC256.hxx" 26 | #include "System.hxx" 27 | #include "SaveKey.hxx" 28 | 29 | MT24LC256 *gSaveKeyEEprom = NULL; 30 | 31 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 32 | SaveKey::SaveKey(Jack jack, const Event& event) : Controller(jack, event), 33 | myEEPROM(NULL) 34 | { 35 | DIR* dir = opendir("/data"); 36 | if (dir) 37 | { 38 | closedir(dir); /* Directory exists. */ 39 | } 40 | else 41 | { 42 | mkdir("/data", 0777); 43 | } 44 | myEEPROM = new MT24LC256("/data/StellaDS.EE"); 45 | 46 | gSaveKeyEEprom = myEEPROM; 47 | 48 | bUseSaveKey = false; 49 | } 50 | 51 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 52 | SaveKey::~SaveKey() 53 | { 54 | gSaveKeyEEprom = NULL; 55 | delete myEEPROM; 56 | } 57 | 58 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 59 | bool SaveKey::read(DigitalPin pin) 60 | { 61 | // We need to override the Controller::read() method, since the timing 62 | // of the actual read is important for the EEPROM (we can't just read 63 | // 60 times per second in the ::update() method) 64 | switch(pin) 65 | { 66 | // Pin 3: EEPROM SDA 67 | // input data from the 24LC256 EEPROM using the I2C protocol 68 | case Three: 69 | return (bUseSaveKey ? (myEEPROM->readSDA()) : 1); 70 | 71 | default: 72 | return 1; 73 | } 74 | } 75 | 76 | Int32 SaveKey::read(AnalogPin pin) 77 | { 78 | return maximumResistance; 79 | } 80 | 81 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 82 | void SaveKey::write(DigitalPin pin, bool value) 83 | { 84 | // Change the pin state based on value 85 | switch(pin) 86 | { 87 | // Pin 3: EEPROM SDA 88 | // output data to the 24LC256 EEPROM using the I2C protocol 89 | case Three: 90 | myEEPROM->writeSDA(value); 91 | break; 92 | 93 | // Pin 4: EEPROM SCL 94 | // output clock data to the 24LC256 EEPROM using the I2C protocol 95 | case Four: 96 | bUseSaveKey = true; 97 | myEEPROM->writeSCL(value); 98 | break; 99 | 100 | default: 101 | break; 102 | } 103 | } 104 | 105 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 106 | void SaveKey::systemCyclesReset() 107 | { 108 | // The EEPROM keeps track of cycle counts, and needs to know when the 109 | // cycles are reset 110 | myEEPROM->systemCyclesReset(); 111 | } 112 | -------------------------------------------------------------------------------- /arm9/source/emucore/SaveKey.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef SAVEKEY_HXX 24 | #define SAVEKEY_HXX 25 | 26 | class MT24LC256; 27 | 28 | #include "Control.hxx" 29 | #include "MT24LC256.hxx" 30 | 31 | extern MT24LC256 *gSaveKeyEEprom; 32 | 33 | /** 34 | Richard Hutchinson's SaveKey "controller", consisting of a 32KB EEPROM 35 | accessible using the I2C protocol. 36 | 37 | This code owes a great debt to Alex Herbert's AtariVox documentation and 38 | driver code. 39 | 40 | @author Stephen Anthony 41 | @version $Id$ 42 | */ 43 | class SaveKey : public Controller 44 | { 45 | public: 46 | /** 47 | Create a new SaveKey controller plugged into the specified jack 48 | 49 | @param jack The jack the controller is plugged into 50 | @param event The event object to use for events 51 | */ 52 | SaveKey(Jack jack, const Event& event); 53 | 54 | /** 55 | Destructor 56 | */ 57 | virtual ~SaveKey(); 58 | 59 | public: 60 | /** 61 | Read the value of the specified digital pin for this controller. 62 | 63 | @param pin The pin of the controller jack to read 64 | @return The state of the pin 65 | */ 66 | virtual bool read(DigitalPin pin); 67 | 68 | /** 69 | Write the given value to the specified digital pin for this 70 | controller. Writing is only allowed to the pins associated 71 | with the PIA. Therefore you cannot write to pin six. 72 | 73 | @param pin The pin of the controller jack to write to 74 | @param value The value to write to the pin 75 | */ 76 | virtual void write(DigitalPin pin, bool value); 77 | 78 | virtual Int32 read(AnalogPin pin); 79 | 80 | /** 81 | Update the entire digital and analog pin state according to the 82 | events currently set. 83 | */ 84 | virtual void update() { } 85 | 86 | /** 87 | Notification method invoked by the system right before the 88 | system resets its cycle counter to zero. It may be necessary 89 | to override this method for devices that remember cycle counts. 90 | */ 91 | virtual void systemCyclesReset(); 92 | 93 | private: 94 | // The EEPROM used in the SaveKey 95 | MT24LC256* myEEPROM; 96 | 97 | bool bUseSaveKey; 98 | }; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /arm9/source/emucore/StellaEvent.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef STELLAEVENT_HXX 24 | #define STELLAEVENT_HXX 25 | 26 | /** 27 | This file defines the global STELLA events that the frontends 28 | will use to communicate with the Event Handler. 29 | 30 | Only the standard keys are defined here. Function and 31 | navigation (HOME, END, etc) keys are special and must be handled 32 | by the frontends directly. 33 | 34 | @author Stephen Anthony 35 | @version $Id: StellaEvent.hxx,v 1.9 2004/05/06 00:06:19 stephena Exp $ 36 | */ 37 | class StellaEvent 38 | { 39 | public: 40 | /** 41 | Enumeration of keyboard keycodes 42 | */ 43 | enum KeyCode 44 | { 45 | KCODE_a, KCODE_b, KCODE_c, KCODE_d, KCODE_e, KCODE_f, KCODE_g, KCODE_h, 46 | KCODE_i, KCODE_j, KCODE_k, KCODE_l, KCODE_m, KCODE_n, KCODE_o, KCODE_p, 47 | KCODE_q, KCODE_r, KCODE_s, KCODE_t, KCODE_u, KCODE_v, KCODE_w, KCODE_x, 48 | KCODE_y, KCODE_z, 49 | 50 | KCODE_0, KCODE_1, KCODE_2, KCODE_3, KCODE_4, KCODE_5, KCODE_6, KCODE_7, 51 | KCODE_8, KCODE_9, 52 | 53 | KCODE_BACKSPACE, KCODE_TAB, KCODE_CLEAR, KCODE_RETURN, 54 | KCODE_ESCAPE, KCODE_SPACE, KCODE_COMMA, KCODE_MINUS, KCODE_PERIOD, 55 | KCODE_SLASH, KCODE_BACKSLASH, KCODE_SEMICOLON, KCODE_EQUALS, 56 | 57 | KCODE_INSERT, KCODE_HOME, KCODE_PAGEUP, 58 | KCODE_DELETE, KCODE_END, KCODE_PAGEDOWN, 59 | 60 | KCODE_UP, KCODE_DOWN, KCODE_LEFT, KCODE_RIGHT, 61 | 62 | KCODE_F1, KCODE_F2, KCODE_F3, KCODE_F4, KCODE_F5, KCODE_F6, KCODE_F7, 63 | KCODE_F8, KCODE_F9, KCODE_F10, KCODE_F11, KCODE_F12, KCODE_F13, 64 | KCODE_F14, KCODE_F15, 65 | 66 | LastKCODE 67 | }; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /arm9/source/emucore/Switches.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #include 23 | #include "Event.hxx" 24 | #include "Switches.hxx" 25 | 26 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 27 | Switches::Switches(const Event& event) 28 | : myEvent(event), 29 | mySwitches(0x0F) 30 | { 31 | mySwitches |= 0x08; // Color Mode 32 | } 33 | 34 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | Switches::~Switches() 36 | { 37 | } 38 | extern uInt32 debug[]; 39 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 40 | ITCM_CODE uInt8 Switches::read() 41 | { 42 | if(myEvent.get(Event::ConsoleColor) != 0) 43 | { 44 | mySwitches |= 0x08; 45 | } 46 | else if(myEvent.get(Event::ConsoleBlackWhite) != 0) 47 | { 48 | mySwitches &= ~0x08; 49 | } 50 | 51 | if(myEvent.get(Event::ConsoleRightDifficultyA) != 0) 52 | { 53 | mySwitches |= 0x80; 54 | } 55 | else if(myEvent.get(Event::ConsoleRightDifficultyB) != 0) 56 | { 57 | mySwitches &= ~0x80; 58 | } 59 | 60 | if(myEvent.get(Event::ConsoleLeftDifficultyA) != 0) 61 | { 62 | mySwitches |= 0x40; 63 | } 64 | else if(myEvent.get(Event::ConsoleLeftDifficultyB) != 0) 65 | { 66 | mySwitches &= ~0x40; 67 | } 68 | 69 | if(myEvent.get(Event::ConsoleSelect) != 0) 70 | mySwitches &= ~0x02; 71 | else 72 | mySwitches |= 0x02; 73 | 74 | if(myEvent.get(Event::ConsoleReset) != 0) 75 | mySwitches &= ~0x01; 76 | else 77 | mySwitches |= 0x01; 78 | 79 | return mySwitches; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /arm9/source/emucore/Switches.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | 23 | #ifndef SWITCHES_HXX 24 | #define SWITCHES_HXX 25 | 26 | class Event; 27 | class Switches; 28 | 29 | #include "bspf.hxx" 30 | 31 | /** 32 | This class represents the console switches of the game console. 33 | 34 | @author Bradford W. Mott 35 | @version $Id: Switches.hxx,v 1.1.1.1 2001/12/27 19:54:23 bwmott Exp $ 36 | */ 37 | class Switches 38 | { 39 | public: 40 | /** 41 | Create a new set of switches using the specified events and 42 | properties 43 | 44 | @param event The event object to use for events 45 | */ 46 | Switches(const Event& event); 47 | 48 | /** 49 | Destructor 50 | */ 51 | virtual ~Switches(); 52 | 53 | public: 54 | /** 55 | Get the value of the console switches 56 | 57 | @return The 8 bits which represent the state of the console switches 58 | */ 59 | uInt8 read(); 60 | 61 | private: 62 | // Reference to the event object to use 63 | const Event& myEvent; 64 | 65 | // State of the console switches 66 | uInt8 mySwitches; 67 | }; 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /arm9/source/emucore/TIASound.hxx: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* Module: TIA Chip Sound Simulator Includes, V1.1 */ 4 | /* Purpose: Define global function prototypes and structures for the TIA */ 5 | /* Chip Sound Simulator. */ 6 | /* Author: Ron Fries */ 7 | /* */ 8 | /* Revision History: */ 9 | /* 10-Sep-96 - V1.0 - Initial Release */ 10 | /* 14-Jan-97 - V1.1 - Added compiler directives to facilitate compilation */ 11 | /* on a C++ compiler. */ 12 | /* */ 13 | /*****************************************************************************/ 14 | /* */ 15 | /* License Information and Copyright Notice */ 16 | /* ======================================== */ 17 | /* */ 18 | /* TiaSound is Copyright(c) 1997 by Ron Fries */ 19 | /* */ 20 | /* This library is free software; you can redistribute it and/or modify it */ 21 | /* under the terms of version 2 of the GNU Library General Public License */ 22 | /* as published by the Free Software Foundation. */ 23 | /* */ 24 | /* This library is distributed in the hope that it will be useful, but */ 25 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 26 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library */ 27 | /* General Public License for more details. */ 28 | /* To obtain a copy of the GNU Library General Public License, write to the */ 29 | /* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 30 | /* */ 31 | /* Any permitted reproduction of these routines, in whole or in part, must */ 32 | /* bear this legend. */ 33 | /* */ 34 | /*****************************************************************************/ 35 | 36 | #ifndef _TIASOUND_H 37 | #define _TIASOUND_H 38 | 39 | /* the size (in entries) of the 4 polynomial tables */ 40 | #define POLY4_SIZE 0x000f 41 | #define POLY5_SIZE 0x001f 42 | #define POLY9_SIZE 0x01ff 43 | 44 | 45 | void Tia_sound_init (unsigned short sample_freq, unsigned short playback_freq); 46 | void Update_tia_sound_0(void); 47 | void Update_tia_sound_1(void); 48 | void Update_tia_sound (uInt8 chan); 49 | void Tia_process (void); 50 | void Tia_process_wave(void); 51 | 52 | extern unsigned char AUDC[2]; 53 | extern unsigned char AUDF[2]; 54 | extern unsigned char AUDV[2]; 55 | extern uInt8 bProcessingSample; 56 | extern uInt32 Outvol[2]; 57 | extern uInt16 tia_buf_idx; 58 | extern uInt16 tia_out_idx; 59 | 60 | extern uInt8 Bit9[POLY9_SIZE]; 61 | extern uInt8 P4[2]; 62 | extern uInt8 P5[2]; 63 | extern uInt16 P9[2]; 64 | extern uInt32 Div_n_cnt[2]; 65 | extern uInt32 Div_n_max[2]; 66 | extern uInt32 Samp_n_max; 67 | extern uInt32 Samp_n_cnt; 68 | 69 | extern uInt16 *tia_buf; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /arm9/source/emucore/bspf.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony 12 | // and the Stella Team 13 | // 14 | // This file has been modified by Dave Bernazzani (wavemotion-dave) 15 | // for optimized execution on the DS/DSi platform. Please seek the 16 | // official Stella source distribution which is far cleaner, newer, 17 | // and better maintained. 18 | // 19 | // See the file "License.txt" for information on usage and redistribution of 20 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 21 | //============================================================================ 22 | #ifndef BSPF_HXX 23 | #define BSPF_HXX 24 | 25 | /** 26 | This file defines various basic data types and preprocessor variables 27 | that need to be defined for different operating systems. 28 | 29 | @author Bradford W. Mott 30 | @version $Id: bspf.hxx,v 1.4 2004/05/28 22:07:57 stephena Exp $ 31 | */ 32 | 33 | // Types for 8-bit signed and unsigned integers 34 | typedef signed char Int8; 35 | typedef unsigned char uInt8; 36 | 37 | // Types for 16-bit signed and unsigned integers 38 | typedef signed short Int16; 39 | typedef unsigned short uInt16; 40 | 41 | // Types for 32-bit signed and unsigned integers 42 | typedef signed int Int32; 43 | typedef unsigned int uInt32; 44 | 45 | // The following code should provide access to the standard C++ objects and 46 | // types: cout, cerr, string, ostream, istream, etc. 47 | #include 48 | #include 49 | #include 50 | using namespace std; 51 | 52 | #define likely(x) __builtin_expect(!!(x), 1) 53 | #define unlikely(x) __builtin_expect(!!(x), 0) 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /arm9/source/highscore.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIGHSCORE_H 2 | #define __HIGHSCORE_H 3 | 4 | #include 5 | 6 | #include "Console.hxx" 7 | 8 | extern void highscore_init(void); 9 | extern void highscore_save(void); 10 | extern void highscore_display(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /arm9/source/instructions.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSTRUCTIONS_H 2 | #define __INSTRUCTIONS_H 3 | 4 | #include 5 | 6 | #include "Console.hxx" 7 | 8 | extern void dsShowScreenInstructions(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /arm9/source/intro.cpp: -------------------------------------------------------------------------------- 1 | // ===================================================================================================== 2 | // Stella DS/DSi Pheonix Edition - Improved Version by Dave Bernazzani (wavemotion) 3 | // 4 | // Copyright (c) 2020-2024 by Dave Bernazzani 5 | // 6 | // Copying and distribution of this emulator, it's source code and associated 7 | // readme files, with or without modification, are permitted in any medium without 8 | // royalty provided this copyright notice is used and wavemotion-dave (Phoenix-Edition), 9 | // Alekmaul (original port) are thanked profusely along with the entire Stella Team. 10 | // 11 | // The StellaDS emulator is offered as-is, without any warranty. 12 | // ===================================================================================================== 13 | #include 14 | #include 15 | 16 | #include "StellaDS.h" 17 | 18 | #include "mus_intro_wav.h" 19 | #include "pdev_tbg0.h" 20 | #include "pdev_bg0.h" 21 | 22 | volatile u16 vusCptVBL; 23 | 24 | void vblankIntro() { 25 | vusCptVBL++; 26 | } 27 | 28 | // Intro with portabledev logo 29 | void intro_logo(void) { 30 | short int soundId=-1; 31 | u8 bOK; 32 | 33 | // Init graphics 34 | videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE ); 35 | videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE ); 36 | vramSetBankA(VRAM_A_MAIN_BG); vramSetBankC(VRAM_C_SUB_BG); 37 | irqSet(IRQ_VBLANK, vblankIntro); 38 | irqEnable(IRQ_VBLANK); 39 | 40 | // Init BG 41 | int bg1 = bgInit(0, BgType_Text8bpp, BgSize_T_256x256, 31,0); 42 | 43 | // Init sub BG 44 | int bg1s = bgInitSub(0, BgType_Text8bpp, BgSize_T_256x256, 31,0); 45 | 46 | REG_BLDCNT = BLEND_FADE_BLACK | BLEND_SRC_BG0 | BLEND_DST_BG0; REG_BLDY = 16; 47 | REG_BLDCNT_SUB = BLEND_FADE_BLACK | BLEND_SRC_BG0 | BLEND_DST_BG0; REG_BLDY_SUB = 16; 48 | 49 | // Show portabledev 50 | decompress(pdev_tbg0Tiles, bgGetGfxPtr(bg1), LZ77Vram); 51 | decompress(pdev_tbg0Map, (void*) bgGetMapPtr(bg1), LZ77Vram); 52 | dmaCopy((void *) pdev_tbg0Pal,(u16*) BG_PALETTE,256*2); 53 | 54 | decompress(pdev_bg0Tiles, bgGetGfxPtr(bg1s), LZ77Vram); 55 | decompress(pdev_bg0Map, (void*) bgGetMapPtr(bg1s), LZ77Vram); 56 | dmaCopy((void *) pdev_bg0Pal,(u16*) BG_PALETTE_SUB,256*2); 57 | 58 | FadeToColor(0,BLEND_FADE_BLACK | BLEND_SRC_BG0 | BLEND_DST_BG0,3,0,3); 59 | 60 | soundId = soundPlaySample((const void *) mus_intro_wav, SoundFormat_ADPCM, mus_intro_wav_size, 22050, 127, 64, false, 0); 61 | 62 | bOK=false; 63 | while (!bOK) { if ( !(keysCurrent() & 0x1FFF) ) bOK=true; } // 0x1FFF = key or pen 64 | vusCptVBL=0;bOK=false; 65 | while (!bOK && (vusCptVBL<3*60)) { if (keysCurrent() & 0x1FFF ) bOK=true; } 66 | bOK=false; 67 | while (!bOK) { if ( !(keysCurrent() & 0x1FFF) ) bOK=true; } 68 | 69 | FadeToColor(1,BLEND_FADE_WHITE | BLEND_SRC_BG0 | BLEND_DST_BG0,3,16,3); 70 | if (soundId!=-1) soundKill(soundId); 71 | } 72 | -------------------------------------------------------------------------------- /arm9/source/intro.h: -------------------------------------------------------------------------------- 1 | #ifndef _INTRO_H 2 | #define _INTRO_H 3 | 4 | extern void intro_logo(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /arm9/source/main.cpp: -------------------------------------------------------------------------------- 1 | // ===================================================================================================== 2 | // Stella DS/DSi Pheonix Edition - Improved Version by Dave Bernazzani (wavemotion) 3 | // 4 | // Copyright (c) 2020-2024 by Dave Bernazzani 5 | // 6 | // Copying and distribution of this emulator, it's source code and associated 7 | // readme files, with or without modification, are permitted in any medium without 8 | // royalty provided this copyright notice is used and wavemotion-dave (Phoenix-Edition), 9 | // Alekmaul (original port) are thanked profusely along with the entire Stella Team. 10 | // 11 | // The StellaDS emulator is offered as-is, without any warranty. 12 | // ===================================================================================================== 13 | #include 14 | #include 15 | #include 16 | 17 | #include "intro.h" 18 | #include "StellaDS.h" 19 | #include "highscore.h" 20 | #include "config.h" 21 | 22 | #include "clickNoQuit_wav.h" 23 | #include "clickQuit_wav.h" 24 | 25 | int main(int argc, char **argv) 26 | { 27 | // Init sound 28 | consoleDemoInit(); 29 | soundEnable(); 30 | lcdMainOnTop(); 31 | 32 | // Init Fat 33 | if (!fatInitDefault()) { 34 | iprintf("Unable to initialize libfat!\n"); 35 | return -1; 36 | } 37 | 38 | // Load the configuration database (or create it) 39 | LoadConfig(); 40 | 41 | // Init Timer 42 | dsInitTimer(); 43 | 44 | // Init sound emulation 45 | dsInstallSoundEmuFIFO(); 46 | 47 | // Intro and main screen 48 | intro_logo(); 49 | 50 | // Init high score (must be done after FAT init) 51 | highscore_init(); 52 | 53 | dsInitScreenMain(); 54 | if (argc > 1) 55 | { 56 | dsShowScreenMain(true); 57 | emuState = STELLADS_PLAYINIT; 58 | dsLoadGame(argv[1]); 59 | } 60 | else 61 | { 62 | chdir("/roms"); // Try to start in roms area... doesn't matter if it fails 63 | chdir("a2600"); // And try to start in the subdir /a2600... doesn't matter if it fails. 64 | emuState = STELLADS_MENUINIT; 65 | } 66 | 67 | // Main loop of emulation 68 | dsMainLoop(); 69 | 70 | // Free memory to be correct 71 | dsFreeEmu(); 72 | 73 | return 0; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /arm9/source/savestate.h: -------------------------------------------------------------------------------- 1 | #ifndef __SAVESTATE_H 2 | #define __SAVESTATE_H 3 | 4 | #include 5 | 6 | #include "Console.hxx" 7 | 8 | extern void dsSaveStateHandler(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /arm9/source/screenshot.cpp: -------------------------------------------------------------------------------- 1 | // Borrowed from Godemode9i from Rocket Robz 2 | // Used with permission April 2023 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "screenshot.h" 11 | #include "printf.h" 12 | 13 | 14 | void write16(void *address, u16 value) { 15 | 16 | u8* first = (u8*)address; 17 | u8* second = first + 1; 18 | 19 | *first = value & 0xff; 20 | *second = value >> 8; 21 | } 22 | 23 | void write32(void *address, u32 value) { 24 | 25 | u8* first = (u8*)address; 26 | u8* second = first + 1; 27 | u8* third = first + 2; 28 | u8* fourth = first + 3; 29 | 30 | *first = value & 0xff; 31 | *second = (value >> 8) & 0xff; 32 | *third = (value >> 16) & 0xff; 33 | *fourth = (value >> 24) & 0xff; 34 | } 35 | 36 | bool screenshotbmp(const char* filename) { 37 | FILE *file = fopen(filename, "wb"); 38 | 39 | if(!file) 40 | return false; 41 | 42 | REG_DISPCAPCNT = DCAP_BANK(DCAP_BANK_VRAM_D) | DCAP_SIZE(DCAP_SIZE_256x192) | DCAP_ENABLE; 43 | while(REG_DISPCAPCNT & DCAP_ENABLE); 44 | 45 | u8 *temp; 46 | // On the DSi there is ample memory to just allocate the buffer and free it below... 47 | temp = (u8*) malloc(256 * 192 * 2 + sizeof(INFOHEADER) + sizeof(HEADER)); 48 | 49 | if(!temp) { 50 | fclose(file); 51 | return false; 52 | } 53 | 54 | HEADER *header= (HEADER*)temp; 55 | INFOHEADER *infoheader = (INFOHEADER*)(temp + sizeof(HEADER)); 56 | 57 | write16(&header->type, 0x4D42); 58 | write32(&header->size, 256 * 192 * 2 + sizeof(INFOHEADER) + sizeof(HEADER)); 59 | write32(&header->reserved1, 0); 60 | write32(&header->reserved2, 0); 61 | write32(&header->offset, sizeof(INFOHEADER) + sizeof(HEADER)); 62 | 63 | write32(&infoheader->size, sizeof(INFOHEADER)); 64 | write32(&infoheader->width, 256); 65 | write32(&infoheader->height, 192); 66 | write16(&infoheader->planes, 1); 67 | write16(&infoheader->bits, 16); 68 | write32(&infoheader->compression, 3); 69 | write32(&infoheader->imagesize, 256 * 192 * 2); 70 | write32(&infoheader->xresolution, 2835); 71 | write32(&infoheader->yresolution, 2835); 72 | write32(&infoheader->ncolours, 0); 73 | write32(&infoheader->importantcolours, 0); 74 | write32(&infoheader->redBitmask, 0xF800); 75 | write32(&infoheader->greenBitmask, 0x07E0); 76 | write32(&infoheader->blueBitmask, 0x001F); 77 | write32(&infoheader->reserved, 0); 78 | 79 | u16 *ptr = (u16*)(temp + sizeof(HEADER) + sizeof(INFOHEADER)); 80 | for(int y = 0; y < 192; y++) { 81 | for(int x = 0; x < 256; x++) { 82 | u16 color = VRAM_D[256 * 191 - y * 256 + x]; 83 | *(ptr++) = ((color >> 10) & 0x1F) | (color & (0x1F << 5)) << 1 | ((color & 0x1F) << 11); 84 | } 85 | } 86 | 87 | DC_FlushAll(); 88 | fwrite(temp, 1, 256 * 192 * 2 + sizeof(INFOHEADER) + sizeof(HEADER), file); 89 | fclose(file); 90 | free(temp); 91 | return true; 92 | } 93 | 94 | 95 | char snapPath[64]; 96 | bool screenshot(void) 97 | { 98 | time_t unixTime = time(NULL); 99 | struct tm* timeStruct = gmtime((const time_t *)&unixTime); 100 | 101 | sprintf(snapPath, "SNAP-%02d-%02d-%04d-%02d-%02d-%02d.bmp", timeStruct->tm_mday, timeStruct->tm_mon+1, timeStruct->tm_year+1900, timeStruct->tm_hour, timeStruct->tm_min, timeStruct->tm_sec); 102 | 103 | // Take top screenshot 104 | if(!screenshotbmp(snapPath)) 105 | return false; 106 | 107 | return true; 108 | } 109 | 110 | // End of file 111 | -------------------------------------------------------------------------------- /arm9/source/screenshot.h: -------------------------------------------------------------------------------- 1 | // Borrowed from GodMode9i from Rocket Robz 2 | #ifndef SCREENSHOT_H 3 | #define SCREENSHOT_H 4 | #include 5 | 6 | extern bool screenshot(void); 7 | 8 | typedef struct { 9 | u16 type; /* Magic identifier */ 10 | u32 size; /* File size in bytes */ 11 | u16 reserved1, reserved2; 12 | u32 offset; /* Offset to image data, bytes */ 13 | } PACKED HEADER; 14 | 15 | typedef struct { 16 | u32 size; /* Header size in bytes */ 17 | u32 width, height; /* Width and height of image */ 18 | u16 planes; /* Number of colour planes */ 19 | u16 bits; /* Bits per pixel */ 20 | u32 compression; /* Compression type */ 21 | u32 imagesize; /* Image size in bytes */ 22 | u32 xresolution, yresolution; /* Pixels per meter */ 23 | u32 ncolours; /* Number of colours */ 24 | u32 importantcolours; /* Important colours */ 25 | u32 redBitmask; /* Red bitmask */ 26 | u32 greenBitmask; /* Green bitmask */ 27 | u32 blueBitmask; /* Blue bitmask */ 28 | u32 reserved; 29 | } PACKED INFOHEADER; 30 | 31 | #endif // SCREENSHOT_H 32 | -------------------------------------------------------------------------------- /logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/logo.bmp -------------------------------------------------------------------------------- /png/champ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/png/champ.png -------------------------------------------------------------------------------- /png/gorf-shift.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/png/gorf-shift.bmp -------------------------------------------------------------------------------- /png/gorf.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wavemotion-dave/StellaDS/a90b9873097055a004ac15bc6ecd12590dc4b96f/png/gorf.bmp --------------------------------------------------------------------------------