├── .github └── FUNDING.yml ├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── README.md ├── chip8 ├── README.md ├── roms │ ├── brix.rom │ └── pong.rom └── src │ ├── MainChip8.java │ ├── emulator │ ├── Chip8.java │ ├── Emulator.java │ ├── instructions │ │ ├── InstructionCommand.java │ │ ├── Instructions.java │ │ └── map │ │ │ ├── Font.java │ │ │ ├── KeyBoardOp.java │ │ │ ├── LoadOp.java │ │ │ ├── Operators.java │ │ │ ├── OthersOp.java │ │ │ └── ZeroOp.java │ ├── specification │ │ ├── SpecificationChip8Impl.java │ │ ├── SpecificationsChip8.java │ │ ├── font │ │ │ └── Font.java │ │ ├── graphics │ │ │ ├── BufferPoolImage.java │ │ │ ├── Display.java │ │ │ ├── Render.java │ │ │ ├── Screen.java │ │ │ └── Video.java │ │ ├── input │ │ │ ├── KeyBoard.java │ │ │ ├── KeyBoardListener.java │ │ │ └── KeyBoardStatus.java │ │ ├── memory │ │ │ └── Memory.java │ │ ├── register │ │ │ └── Register.java │ │ ├── sound │ │ │ └── Sound.java │ │ └── timer │ │ │ └── Timer.java │ └── utils │ │ ├── Loader.java │ │ └── Utils.java │ └── framework │ ├── core │ ├── AsyncTask.java │ ├── Executable.java │ ├── Processor.java │ └── Updateable.java │ ├── dispose │ └── Disposable.java │ └── windows │ ├── ActionCommand.java │ ├── Windows.java │ ├── WindowsActionListenerImpl.java │ ├── WindowsItemListenerImpl.java │ └── WindowsListenerImpl.java ├── emulators.iml ├── gameboyclassic ├── LoadRomMBC1 ├── LoadRomMBC3 ├── README.md ├── semanticVersioning.md ├── src │ └── emulator │ │ ├── cartridge │ │ ├── CartridgeAsync.java │ │ ├── CartridgeAsyncImpl.java │ │ ├── battery │ │ │ ├── Battery.java │ │ │ └── BatteryImpl.java │ │ ├── game │ │ │ ├── Game.java │ │ │ └── GameImpl.java │ │ ├── memory │ │ │ ├── Memory.java │ │ │ ├── MemoryImpl.java │ │ │ ├── bankController │ │ │ │ ├── MBC1.java │ │ │ │ ├── MBC1Impl.java │ │ │ │ ├── MBC3.java │ │ │ │ ├── MBC3Impl.java │ │ │ │ └── ReadMBC3Clock.java │ │ │ └── fisic │ │ │ │ ├── FisicMemory.java │ │ │ │ ├── FisicMemoryImpl.java │ │ │ │ ├── Ram.java │ │ │ │ └── Rom.java │ │ └── utils │ │ │ └── MemoryControllersGameBoy.java │ │ ├── configuration │ │ ├── EmulatorConfigurator.java │ │ ├── action │ │ │ ├── MainWindowConfigure.java │ │ │ └── ProcessorConfigure.java │ │ └── extension │ │ │ └── MainLoopCoreConfigure.java │ │ ├── cpu │ │ ├── bios │ │ │ └── NintendoLogo.java │ │ └── processor │ │ │ ├── command │ │ │ ├── Commands.java │ │ │ ├── CommandsImpl.java │ │ │ ├── bits16 │ │ │ │ ├── add │ │ │ │ │ └── ADD_HL_BC.java │ │ │ │ └── dec │ │ │ │ │ └── DEC_BC.java │ │ │ ├── bits8 │ │ │ │ ├── LDD_HL_A.java │ │ │ │ ├── LDI_A_HL.java │ │ │ │ ├── LDI_HL_A.java │ │ │ │ ├── LD_A_A.java │ │ │ │ ├── LD_A_B.java │ │ │ │ ├── LD_A_BC.java │ │ │ │ ├── LD_A_C.java │ │ │ │ ├── LD_A_D.java │ │ │ │ ├── LD_A_DE.java │ │ │ │ ├── LD_A_E.java │ │ │ │ ├── LD_A_FF00_C.java │ │ │ │ ├── LD_A_FF00_NN.java │ │ │ │ ├── LD_A_H.java │ │ │ │ ├── LD_A_HL.java │ │ │ │ ├── LD_A_HLL.java │ │ │ │ ├── LD_A_L.java │ │ │ │ ├── LD_A_N.java │ │ │ │ ├── LD_A_NNN.java │ │ │ │ ├── LD_BC_A.java │ │ │ │ ├── LD_B_A.java │ │ │ │ ├── LD_B_B.java │ │ │ │ ├── LD_B_C.java │ │ │ │ ├── LD_B_D.java │ │ │ │ ├── LD_B_E.java │ │ │ │ ├── LD_B_H.java │ │ │ │ ├── LD_B_HL.java │ │ │ │ ├── LD_B_L.java │ │ │ │ ├── LD_B_N.java │ │ │ │ ├── LD_C_A.java │ │ │ │ ├── LD_C_B.java │ │ │ │ ├── LD_C_C.java │ │ │ │ ├── LD_C_D.java │ │ │ │ ├── LD_C_E.java │ │ │ │ ├── LD_C_FF00_A.java │ │ │ │ ├── LD_C_H.java │ │ │ │ ├── LD_C_HL.java │ │ │ │ ├── LD_C_L.java │ │ │ │ ├── LD_C_N.java │ │ │ │ ├── LD_DE_A.java │ │ │ │ ├── LD_D_A.java │ │ │ │ ├── LD_D_B.java │ │ │ │ ├── LD_D_C.java │ │ │ │ ├── LD_D_D.java │ │ │ │ ├── LD_D_E.java │ │ │ │ ├── LD_D_H.java │ │ │ │ ├── LD_D_HL.java │ │ │ │ ├── LD_D_L.java │ │ │ │ ├── LD_D_N.java │ │ │ │ ├── LD_E_A.java │ │ │ │ ├── LD_E_B.java │ │ │ │ ├── LD_E_C.java │ │ │ │ ├── LD_E_D.java │ │ │ │ ├── LD_E_E.java │ │ │ │ ├── LD_E_H.java │ │ │ │ ├── LD_E_HL.java │ │ │ │ ├── LD_E_L.java │ │ │ │ ├── LD_E_N.java │ │ │ │ ├── LD_FF00_NN_A.java │ │ │ │ ├── LD_HL_A.java │ │ │ │ ├── LD_HL_B.java │ │ │ │ ├── LD_HL_C.java │ │ │ │ ├── LD_HL_D.java │ │ │ │ ├── LD_HL_E.java │ │ │ │ ├── LD_HL_H.java │ │ │ │ ├── LD_HL_L.java │ │ │ │ ├── LD_HL_N.java │ │ │ │ ├── LD_H_A.java │ │ │ │ ├── LD_H_B.java │ │ │ │ ├── LD_H_C.java │ │ │ │ ├── LD_H_D.java │ │ │ │ ├── LD_H_E.java │ │ │ │ ├── LD_H_H.java │ │ │ │ ├── LD_H_HL.java │ │ │ │ ├── LD_H_L.java │ │ │ │ ├── LD_H_N.java │ │ │ │ ├── LD_L_A.java │ │ │ │ ├── LD_L_B.java │ │ │ │ ├── LD_L_C.java │ │ │ │ ├── LD_L_D.java │ │ │ │ ├── LD_L_E.java │ │ │ │ ├── LD_L_H.java │ │ │ │ ├── LD_L_HL.java │ │ │ │ ├── LD_L_L.java │ │ │ │ ├── LD_L_N.java │ │ │ │ └── LD_NNN_A.java │ │ │ └── noOperation │ │ │ │ └── NoOperation.java │ │ │ ├── mainRam │ │ │ └── MainRam.java │ │ │ ├── memory │ │ │ ├── MemoryZ80.java │ │ │ ├── MemoryZ80Impl.java │ │ │ ├── read │ │ │ │ └── MemoryMapReadInternal.java │ │ │ ├── registerIoAux │ │ │ │ ├── ControlSio.java │ │ │ │ ├── Div.java │ │ │ │ ├── Dma.java │ │ │ │ ├── If.java │ │ │ │ ├── PaletteIoRegister.java │ │ │ │ ├── QuadrangularWaveIoRegister.java │ │ │ │ ├── SerialT.java │ │ │ │ ├── SoundMixerIoRegister.java │ │ │ │ ├── UnMappedRegister.java │ │ │ │ ├── VoluntaryWaveIoRegister.java │ │ │ │ ├── WavePatternRamIoRegister.java │ │ │ │ ├── WhiteNoiseIoRegister.java │ │ │ │ └── parent │ │ │ │ │ ├── RegisterMemoryMap.java │ │ │ │ │ └── RegisterMemoryMapImpl.java │ │ │ └── write │ │ │ │ └── MemoryMapWriteInternal.java │ │ │ ├── spriteAttribMemory │ │ │ └── OAM.java │ │ │ └── z80 │ │ │ ├── disassembler │ │ │ └── Disassembler.java │ │ │ └── ticks │ │ │ ├── Z80CbCycles.java │ │ │ └── Z80Cycles.java │ │ ├── framework │ │ ├── configuration │ │ │ ├── config │ │ │ │ └── FrameworkConfigurable.java │ │ │ └── extension │ │ │ │ └── FrameworkExtensionable.java │ │ ├── container │ │ │ ├── ClassToMapContainer.java │ │ │ └── ClassToMapKey.java │ │ ├── context │ │ │ ├── annotation │ │ │ │ └── FrameworkInstall.java │ │ │ ├── api │ │ │ │ ├── FrameworkConfig.java │ │ │ │ ├── FrameworkContext.java │ │ │ │ └── FrameworkExtension.java │ │ │ └── src │ │ │ │ └── FrameworkContextImpl.java │ │ ├── factory │ │ │ ├── buffer │ │ │ │ ├── FactoryBuffer.java │ │ │ │ └── FactoryBufferImpl.java │ │ │ └── collection │ │ │ │ ├── FactoryCollection.java │ │ │ │ └── FactoryCollectionImpl.java │ │ ├── injector │ │ │ └── api │ │ │ │ ├── Injector.java │ │ │ │ ├── annotation │ │ │ │ ├── Inject.java │ │ │ │ ├── instance │ │ │ │ │ ├── Prototype.java │ │ │ │ │ ├── Singleton.java │ │ │ │ │ └── Value.java │ │ │ │ └── method │ │ │ │ │ ├── PostConstruct.java │ │ │ │ │ └── PreDestroy.java │ │ │ │ └── type │ │ │ │ ├── InjectorFactory.java │ │ │ │ └── Instance.java │ │ ├── logger │ │ │ ├── api │ │ │ │ └── Logger.java │ │ │ └── src │ │ │ │ └── LoggerImpl.java │ │ └── pattern │ │ │ └── action │ │ │ ├── ActionFrameworkContext.java │ │ │ └── ActionInjector.java │ │ ├── graphic │ │ ├── GameboyPalette.java │ │ ├── fps │ │ │ ├── FPS.java │ │ │ └── FPSImpl.java │ │ ├── palette │ │ │ ├── DMGPalette.java │ │ │ ├── DMGPaletteImpl.java │ │ │ └── shader │ │ │ │ ├── PaletteVideo.java │ │ │ │ ├── PaletteVideoImpl.java │ │ │ │ └── PaletteVideoMultiton.java │ │ └── stat │ │ │ ├── StatVideo.java │ │ │ └── StatVideoImpl.java │ │ ├── main │ │ ├── GameBoy.java │ │ ├── configuration │ │ │ ├── EmulatorConfigurator.java │ │ │ ├── action │ │ │ │ ├── MainWindowConfigure.java │ │ │ │ └── ProcessorConfigure.java │ │ │ └── extension │ │ │ │ └── MainLoopCoreConfigure.java │ │ └── loop │ │ │ ├── ExecuteOption.java │ │ │ ├── LoopCore.java │ │ │ └── MainLoopCore.java │ │ ├── pattern │ │ ├── diposable │ │ │ └── Disposable.java │ │ ├── reseteable │ │ │ └── Reseteable.java │ │ └── updateble │ │ │ └── Updatable.java │ │ ├── specification │ │ └── sound │ │ │ ├── Channel.java │ │ │ ├── SoundControl.java │ │ │ ├── ch1_2 │ │ │ └── QuadrangularWaveForm.java │ │ │ ├── ch3 │ │ │ └── ArbitraryWaveForm.java │ │ │ └── ch4 │ │ │ └── WhiteNoise.java │ │ ├── toolBar │ │ ├── file │ │ │ ├── ToolBarFile.java │ │ │ ├── ToolBarFileImpl.java │ │ │ ├── action │ │ │ │ ├── ToolBarFileAction.java │ │ │ │ ├── ToolBarFileItemAction.java │ │ │ │ └── ToolBarFileItemActionImpl.java │ │ │ └── item │ │ │ │ ├── ToolBarFileItemMenu.java │ │ │ │ └── ToolBarFileItemMenuImpl.java │ │ └── others │ │ │ ├── ToolBarOthers.java │ │ │ ├── ToolBarOthersImpl.java │ │ │ ├── action │ │ │ ├── ToolBarOthersItemAction.java │ │ │ └── ToolBarOthersItemActionImpl.java │ │ │ └── item │ │ │ ├── ToolBarOthersItemMenu.java │ │ │ └── ToolBarOthersItemMenuImpl.java │ │ └── utils │ │ ├── CheckSum.java │ │ ├── FileAsync.java │ │ ├── Operation.java │ │ ├── executor │ │ ├── ExecutorPoolException.java │ │ ├── ThreadPoolPriorityQueueAsync.java │ │ ├── ThreadPoolPriorityQueueAsyncImpl.java │ │ ├── deferred │ │ │ ├── DeferredAsync.java │ │ │ └── DeferredAsyncImpl.java │ │ └── execute │ │ │ ├── CoreExecute.java │ │ │ └── CoreExecuteImpl.java │ │ ├── mainLoop │ │ ├── MainLoopUtils.java │ │ └── MainLoopUtilsImpl.java │ │ ├── shell │ │ ├── Console.java │ │ ├── ConsoleWindowsListener.java │ │ ├── Logger.java │ │ └── pool │ │ │ ├── LoggerPoolMessage.java │ │ │ ├── message │ │ │ ├── LoggerMessage.java │ │ │ └── LoggerMessageImpl.java │ │ │ └── utils │ │ │ └── WorkerThreadFactory.java │ │ └── toolBar │ │ ├── ToolBarUtils.java │ │ └── ToolBarUtilsImpl.java └── test │ └── emulator │ ├── cartridge │ ├── CartridgeAsyncImplTest.java │ ├── battery │ │ └── BatteryImplTest.java │ ├── game │ │ └── GameImplTest.java │ ├── memory │ │ ├── bankController │ │ │ ├── MBC1ImplTest.java │ │ │ └── MBC3ImplTest.java │ │ └── fisic │ │ │ ├── RamTest.java │ │ │ └── RomTest.java │ └── utils │ │ └── MemoryControllersGameBoyTest.java │ ├── cpu │ └── processor │ │ └── command │ │ ├── _return │ │ ├── RETTest.java │ │ ├── RET_NZTest.java │ │ ├── RET_ZTest.java │ │ └── RET_n_NZTest.java │ │ ├── bits16 │ │ ├── add │ │ │ ├── ADD_HL_BCTest.java │ │ │ ├── ADD_HL_DETest.java │ │ │ ├── ADD_HL_HLTest.java │ │ │ └── ADD_SP_nnTestas.java │ │ ├── dec │ │ │ ├── DEC_BCTest.java │ │ │ ├── DEC_DETest.java │ │ │ ├── DEC_HL_nnTest.java │ │ │ ├── DEC_SPTest.java │ │ │ └── DEC_nnTest.java │ │ ├── inc │ │ │ ├── INC_BCTest.java │ │ │ └── INC_DETest.java │ │ └── ld │ │ │ ├── LD_BC_NNTest.java │ │ │ ├── LD_DE_NNTest.java │ │ │ └── LD_NN_SPTest.java │ │ ├── bits8 │ │ ├── dec │ │ │ ├── DEC_ATest.java │ │ │ ├── DEC_BTest.java │ │ │ ├── DEC_CTest.java │ │ │ ├── DEC_DTest.java │ │ │ ├── DEC_ETest.java │ │ │ ├── DEC_HTest.java │ │ │ ├── DEC_nTest.java │ │ │ ├── DEC_n_BTest.java │ │ │ └── DEC_n_CTest.java │ │ ├── inc │ │ │ ├── INC_BTest.java │ │ │ ├── INC_CTest.java │ │ │ └── INC_DTest.java │ │ └── ld │ │ │ ├── LD_A_BCTest.java │ │ │ ├── LD_B_NNTest.java │ │ │ ├── LD_C_NTest.java │ │ │ ├── LD_DE_ATest.java │ │ │ └── LD_H_NTest.java │ │ ├── jump │ │ ├── JRTest.java │ │ ├── JR_NZ_nnTest.java │ │ └── JR_Z_nnTest.java │ │ └── others │ │ └── DAATest.java │ └── framework │ ├── container │ ├── ClassToMapContainerTest.java │ └── ClassToMapKeyTest.java │ ├── executor │ ├── deferred │ │ ├── DeferredAsyncImplTest.java │ │ └── resultAsync │ │ │ └── ResultAsyncImplTest.java │ ├── execute │ │ └── CoreExecuteImplTest.java │ └── threadPool │ │ └── ThreadPoolPriorityQueueAsyncImplTest.java │ └── factory │ └── FactoryCollectionImplTest.java └── schip8 ├── README.md └── src └── emulator └── specification ├── Memory.java └── sfont └── SFont.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: vicboma1 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.xml 3 | /Users/vicboma/Desktop/Informatica/emulators/gameboyclassic/src/emulator/cpu/processor/processor 4 | /Users/vicboma/Desktop/Informatica/emulators/gameboyclassic/src/emulator/cpu/processor/command/bits8/load_nn_n 5 | /Users/vicboma/Desktop/Informatica/emulators/gameboyclassic/src/emulator/cpu/processor/command/bits8/load 6 | /Users/vicboma/Desktop/Informatica/emulators/gameboyclassic/src/emulator/cpu/processor/command/bits8/load_r1_r2 -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | emulators -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Emulators with Java 8/9/11 | Kotlin | C/C++ 2 | ========= 3 | [![Analytics](https://ga-beacon.appspot.com/UA-68658653-1/emulators/readme)](https://github.com/igrigorik/ga-beacon) 4 | 5 | Development Methodology Software Emulators 6 | 7 | * [Chip8](https://github.com/vicboma1/emulators/tree/master/chip8) 8 | * [S-Chip8](https://github.com/vicboma1/emulators/tree/master/schip8) 9 | * [Game Boy Classic ](https://github.com/vicboma1/emulators/tree/master/gameboyclassic) 10 | * [GameBoy Emulator Environment - GBEE](https://github.com/vicboma1/GameBoyEmulatorEnvironment) 11 | * [Loader Dumps Arcade Emulator](https://github.com/vicboma1/loaderDumpsArcade) 12 | 13 | 14 | 15 | @Author: Victor Bolinches Marin 16 | -------------------------------------------------------------------------------- /chip8/roms/brix.rom: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/emulators/2c709a3b0d03159b3c5d74289c7329c957215e5a/chip8/roms/brix.rom -------------------------------------------------------------------------------- /chip8/roms/pong.rom: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/emulators/2c709a3b0d03159b3c5d74289c7329c957215e5a/chip8/roms/pong.rom -------------------------------------------------------------------------------- /chip8/src/MainChip8.java: -------------------------------------------------------------------------------- 1 | import emulator.Chip8; 2 | import emulator.utils.Utils; 3 | 4 | import javax.swing.*; 5 | 6 | /** 7 | * Created by vicboma on 08/07/14. 8 | */ 9 | public class MainChip8 { 10 | 11 | private static final String SYSTEM_LOOK_AND_FEEL_CLASS_NAME = UIManager.getSystemLookAndFeelClassName(); 12 | private static final String EMULATOR_LOADED = "Emulator loaded "; 13 | private static final String EMULATOR_LOADED_KO = EMULATOR_LOADED + "KO!"; 14 | private static final String EMULATOR_LOADED_OK = EMULATOR_LOADED + "OK!"; 15 | 16 | public static void main(String[] args) { 17 | final Chip8 chip8 = new Chip8(); 18 | try { 19 | Utils.setLookAndFeel(SYSTEM_LOOK_AND_FEEL_CLASS_NAME, chip8.windows()); 20 | } catch (Exception e) { 21 | System.out.println(EMULATOR_LOADED_KO); 22 | e.printStackTrace(); 23 | } finally { 24 | System.out.println(EMULATOR_LOADED_OK); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chip8/src/emulator/Chip8.java: -------------------------------------------------------------------------------- 1 | package emulator; 2 | 3 | import emulator.specification.SpecificationChip8Impl; 4 | import emulator.specification.input.KeyBoard; 5 | import framework.windows.Windows; 6 | 7 | import javax.swing.*; 8 | 9 | 10 | /** 11 | * Created by vicboma on 02/07/14. 12 | */ 13 | public class Chip8 { 14 | private KeyBoard keyBoard; 15 | private SpecificationChip8Impl specificationChip8Impl; 16 | private Windows windows; 17 | 18 | public Chip8() { 19 | keyBoard = new KeyBoard(); 20 | specificationChip8Impl = new SpecificationChip8Impl(keyBoard); 21 | windows = Windows.create(specificationChip8Impl, keyBoard); 22 | } 23 | 24 | public JFrame windows() { 25 | return windows.component(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chip8/src/emulator/Emulator.java: -------------------------------------------------------------------------------- 1 | package emulator; 2 | 3 | import framework.dispose.Disposable; 4 | 5 | /** 6 | * Created by vicboma on 03/07/14. 7 | */ 8 | public abstract class Emulator implements Disposable { 9 | 10 | public Emulator() { 11 | } 12 | 13 | public abstract void initialize(); 14 | 15 | public abstract void loadContent(); 16 | } 17 | -------------------------------------------------------------------------------- /chip8/src/emulator/instructions/InstructionCommand.java: -------------------------------------------------------------------------------- 1 | package emulator.instructions; 2 | 3 | /** 4 | * Created by vicboma on 03/07/14. 5 | */ 6 | public interface InstructionCommand { 7 | void execute(); 8 | } 9 | -------------------------------------------------------------------------------- /chip8/src/emulator/instructions/map/Font.java: -------------------------------------------------------------------------------- 1 | package emulator.instructions.map; 2 | 3 | /** 4 | * Created by vicboma on 09/07/14. 5 | */ 6 | public class Font { 7 | 8 | public static final short[] chip8 = { 9 | 0xf9, 0x99, 0xf2, 0x62, 0x27, 10 | 0xf1, 0xf8, 0xff, 0x1f, 0x1f, 11 | 0x99, 0xf1, 0x1f, 0x8f, 0x1f, 12 | 0xf8, 0xf9, 0xff, 0x12, 0x44, 13 | 0xf9, 0xf9, 0xff, 0x9f, 0x1f, 14 | 0xf9, 0xf9, 0x9e, 0x9e, 0x9e, 15 | 0xf8, 0x88, 0xfe, 0x99, 0x9e, 16 | 0xf8, 0xf8, 0xff, 0x8f, 0x88}; 17 | 18 | public Font() { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /chip8/src/emulator/instructions/map/KeyBoardOp.java: -------------------------------------------------------------------------------- 1 | package emulator.instructions.map; 2 | 3 | import emulator.instructions.InstructionCommand; 4 | import emulator.specification.SpecificationsChip8; 5 | import emulator.specification.input.KeyBoard; 6 | import emulator.specification.input.KeyBoardStatus; 7 | import emulator.specification.register.Register; 8 | 9 | import java.util.Hashtable; 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by vicboma on 11/07/14. 14 | */ 15 | public class KeyBoardOp { 16 | 17 | private static final int Ex9E_SKP_Vx = 0x9E; 18 | private static final int ExA1_SKNP_Vx = 0xA1; 19 | 20 | public static Map load(SpecificationsChip8 specificationsChip8) { 21 | 22 | final Register register = specificationsChip8.register(); 23 | final KeyBoard keyBoard = specificationsChip8.keyBoard(); 24 | return new Hashtable() { 25 | { 26 | put(Ex9E_SKP_Vx, () -> { 27 | if (keyBoard.get(KeyBoardStatus.unMap[register.V(register.getOpCode(2))])) 28 | incremetIP(); 29 | }); 30 | put(ExA1_SKNP_Vx, () -> { 31 | if (!keyBoard.get(KeyBoardStatus.unMap[register.V(register.getOpCode(2))])) 32 | incremetIP(); 33 | }); 34 | } 35 | 36 | private void incremetIP() { 37 | register.IP(register.IP() + 2); 38 | } 39 | }; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/SpecificationsChip8.java: -------------------------------------------------------------------------------- 1 | package emulator.specification; 2 | 3 | import emulator.specification.graphics.Video; 4 | import emulator.specification.input.KeyBoard; 5 | import emulator.specification.memory.Memory; 6 | import emulator.specification.register.Register; 7 | import emulator.specification.timer.Timer; 8 | 9 | /** 10 | * Created by vicboma on 10/07/14. 11 | */ 12 | public interface SpecificationsChip8 { 13 | Memory memory(); 14 | 15 | Register register(); 16 | 17 | Video video(); 18 | 19 | KeyBoard keyBoard(); 20 | 21 | Timer timer(); 22 | } 23 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/font/Font.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.font; 2 | 3 | /** 4 | * Created by vicboma on 09/07/14. 5 | */ 6 | public class Font { 7 | 8 | public static final short[] chip8 = { 9 | 0xf9, 0x99, 0xf2, 0x62, 0x27, 10 | 0xf1, 0xf8, 0xff, 0x1f, 0x1f, 11 | 0x99, 0xf1, 0x1f, 0x8f, 0x1f, 12 | 0xf8, 0xf9, 0xff, 0x12, 0x44, 13 | 0xf9, 0xf9, 0xff, 0x9f, 0x1f, 14 | 0xf9, 0xf9, 0x9e, 0x9e, 0x9e, 15 | 0xf8, 0x88, 0xfe, 0x99, 0x9e, 16 | 0xf8, 0xf8, 0xff, 0x8f, 0x88}; 17 | 18 | public Font() { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/graphics/BufferPoolImage.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.graphics; 2 | 3 | import emulator.utils.Utils; 4 | 5 | import java.awt.*; 6 | import java.awt.image.BufferedImage; 7 | 8 | /** 9 | * Created by vicboma on 08/07/14. 10 | */ 11 | public class BufferPoolImage { 12 | private BufferedImage bufferedImage; 13 | private Screen screen; 14 | 15 | public BufferPoolImage(Screen screen) { 16 | this.screen = screen; 17 | } 18 | 19 | public void begin() { 20 | this.bufferedImage = new BufferedImage(Video.WIDTH, Video.HEIGHT, BufferedImage.TYPE_INT_RGB); 21 | } 22 | 23 | public void draw() { 24 | screen.flush(); 25 | //internamente llama al consumidor de imagenes cuando hacemos esta llamada 26 | this.bufferedImage.getGraphics().drawImage(screen.image(), Utils.ZERO, Utils.ZERO, null); 27 | } 28 | 29 | public void end(Graphics graphics) { 30 | graphics.drawImage(bufferedImage, Video.X_OFFSET, Video.Y_OFFSET, screen.width(), screen.height(), Color.black, null); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/graphics/Screen.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.graphics; 2 | 3 | import java.awt.*; 4 | 5 | /** 6 | * Created by vicboma on 08/07/14. 7 | */ 8 | public class Screen { 9 | 10 | private Image image; 11 | private int width; 12 | private int height; 13 | 14 | public Screen() { 15 | } 16 | 17 | public Screen set(Image image) { 18 | this.image = image; 19 | return this; 20 | } 21 | 22 | public void flush() { 23 | this.image.flush(); 24 | } 25 | 26 | public void setSize(Integer width, Integer height) { 27 | this.width = width; 28 | this.height = height; 29 | } 30 | 31 | public Integer width() { 32 | return this.width; 33 | } 34 | 35 | public Integer height() { 36 | return this.height; 37 | } 38 | 39 | public Image image() { 40 | return this.image; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/graphics/Video.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.graphics; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | /** 7 | * Created by vicboma on 07/07/14. 8 | */ 9 | public class Video { 10 | public static final int WIDTH = 128; 11 | public static final int HEIGHT = 64; 12 | 13 | public static final int X_OFFSET = 65; 14 | public static final int Y_OFFSET = 20; 15 | 16 | private Graphics graphics; 17 | private Display display; 18 | private Screen screen; 19 | private BufferPoolImage bufferPoolImage; 20 | 21 | // Nos permite hacer lo mismo que el JPanel pero sin pintar pixeles. 22 | // No extendemos la clase, sino que la componemos. 23 | private JComponent jComponent; 24 | 25 | public Video(Display display, Screen screen, BufferPoolImage bufferPoolImage, JComponent component) { 26 | this.bufferPoolImage = bufferPoolImage; 27 | this.jComponent = component; 28 | this.display = display; 29 | final Image image = this.jComponent.createImage(display); 30 | this.screen = screen.set(image); 31 | this.graphics = this.jComponent.getGraphics(); 32 | } 33 | 34 | public void refresh() { 35 | if (graphics == null) 36 | graphics = this.jComponent.getGraphics(); 37 | 38 | this.bufferPoolImage.begin(); 39 | this.bufferPoolImage.draw(); 40 | this.bufferPoolImage.end(graphics); 41 | } 42 | 43 | public void scale(Integer factor) { 44 | this.screen.setSize(WIDTH * factor, HEIGHT * factor); 45 | } 46 | 47 | public Display display() { 48 | return display; 49 | } 50 | 51 | public JComponent component() { 52 | return jComponent; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/input/KeyBoard.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.input; 2 | 3 | import framework.dispose.Disposable; 4 | 5 | import java.awt.event.KeyListener; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.stream.IntStream; 9 | 10 | /** 11 | * Created by vicboma on 08/07/14. 12 | */ 13 | public class KeyBoard implements Disposable { 14 | 15 | private KeyBoardStatus keyBoardStatus; 16 | private KeyBoardListener keyBoardListener; 17 | private List keyPressed; 18 | 19 | public KeyBoard() { 20 | initializeKeyPressed(); 21 | keyBoardStatus = new KeyBoardStatus(); 22 | keyBoardListener = new KeyBoardListener(this); 23 | } 24 | 25 | private void initializeKeyPressed() { 26 | keyPressed = null; 27 | keyPressed = new ArrayList(); 28 | IntStream stream = IntStream.range(0, 16); 29 | stream.sequential().forEach(x -> this.keyPressed.add(x, false)); 30 | } 31 | 32 | @Override 33 | public void dispose() { 34 | initializeKeyPressed(); 35 | this.keyBoardListener.initializeMapEvent(); 36 | } 37 | 38 | public KeyListener listener() { 39 | return this.keyBoardListener.listener(); 40 | } 41 | 42 | public Boolean get(final int index) { 43 | return this.keyPressed.get(index); 44 | } 45 | 46 | public Boolean set(final int index, Boolean value) { 47 | return this.keyPressed.set(index, value); 48 | } 49 | 50 | public KeyBoardStatus status() { 51 | return this.keyBoardStatus; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/input/KeyBoardStatus.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.input; 2 | 3 | import emulator.utils.Utils; 4 | 5 | /** 6 | * Created by vicboma on 08/07/14. 7 | */ 8 | public class KeyBoardStatus { 9 | 10 | public static final short[] map = {0x01, 0x02, 0x03, 0x0C, 0x04, 0x05, 0x06, 0x0D, 0x07, 0x08, 0x09, 0x0E, 0x0A, 0x00, 0x0B, 0x0F}; 11 | public static final short[] unMap = {0x0D, 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x08, 0x09, 0x0A, 0x0C, 0x0E, 0x03, 0x07, 0x0B, 0x0F}; 12 | 13 | private static final int RESET = 255; //0xff 14 | 15 | public short previousKeyPressed; 16 | public short actualKeyPressed; 17 | public boolean isKeyPressed; 18 | public boolean isOtherKeyPressed; 19 | 20 | public KeyBoardStatus() { 21 | previousKeyPressed = Utils.ZERO; 22 | actualKeyPressed = Utils.ZERO; 23 | isKeyPressed = Utils.FALSE; 24 | isOtherKeyPressed = Utils.FALSE; 25 | } 26 | 27 | public void refresh() { 28 | actualKeyPressed = RESET; 29 | 30 | if (isKeyPressed && previousKeyPressed != actualKeyPressed) { 31 | actualKeyPressed = previousKeyPressed; 32 | isOtherKeyPressed = true; 33 | } 34 | } 35 | 36 | public void reset() { 37 | isKeyPressed = Utils.FALSE; 38 | isOtherKeyPressed = Utils.FALSE; 39 | } 40 | 41 | public void process(KeyBoard keyBoard) { 42 | for (int i = 0; i < map.length; i++) { 43 | if (keyBoard.get(i)) { 44 | actualKeyPressed = map[i]; 45 | isKeyPressed = true; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/memory/Memory.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.memory; 2 | 3 | import emulator.specification.font.Font; 4 | 5 | /** 6 | * Created by vicboma on 03/07/14. 7 | */ 8 | public class Memory { 9 | 10 | public static final int INITIALIZE = 0x0000; 11 | public static final int START_CHIP8_PROGRAMS = 0x0200; 12 | public static final int START_ETI_660_CHIP8_PROGRAMS = 0x0600; 13 | public static final int SIZE = 0x1000; 14 | private short men[]; 15 | 16 | public Memory() { 17 | men = new short[SIZE]; 18 | } 19 | 20 | public void set(Integer index, short value) { 21 | this.men[index] = value; 22 | } 23 | 24 | public int ShiftL(Integer index, int value) { 25 | return men[index] << value; 26 | } 27 | 28 | public int ShiftR(Integer index, int value) { 29 | return this.men[index] >> value; 30 | } 31 | 32 | public short get(Integer index) { 33 | return this.men[index]; 34 | } 35 | 36 | public void loadFont(Font font) { 37 | for (int i = 0; i < 40; i++) { 38 | final int index = i << 1; 39 | final int mask = 0xf0; 40 | set(index, (short) (font.chip8[i] & mask)); 41 | set(index + 1, (short) ((font.chip8[i] << 4) & mask)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /chip8/src/emulator/specification/timer/Timer.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.timer; 2 | 3 | import emulator.utils.Utils; 4 | import framework.dispose.Disposable; 5 | 6 | /** 7 | * Created by vicboma on 08/07/14. 8 | */ 9 | public class Timer implements Disposable { 10 | 11 | public static final int SIZE = 0x02; 12 | public static final int DELAY = Utils.ZERO; 13 | public static final int SOUND = 0x01; 14 | 15 | private short[] T; 16 | 17 | public Timer() { 18 | T = new short[SIZE]; 19 | } 20 | 21 | public short get(Integer index) { 22 | return this.T[index]; 23 | } 24 | 25 | public void set(Integer index, short value) { 26 | this.T[index] = value; 27 | } 28 | 29 | public void delay(short value) { 30 | this.T[DELAY] = value; 31 | } 32 | 33 | public void sound(short value) { 34 | this.T[SOUND] = value; 35 | } 36 | 37 | public short delay() { 38 | return this.T[DELAY]; 39 | } 40 | 41 | public short sound() { 42 | return this.T[SOUND]; 43 | } 44 | 45 | @Override 46 | public void dispose() { 47 | this.T = new short[SIZE]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /chip8/src/emulator/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package emulator.utils; 2 | 3 | import emulator.specification.graphics.Display; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | /** 9 | * Created by vicboma on 08/07/14. 10 | */ 11 | public class Utils { 12 | public static final boolean FALSE = false; 13 | public static final int ZERO = 0x0; 14 | private static final int HALF = 0x02; 15 | 16 | private static DisplayMode displayMode() { 17 | return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); 18 | } 19 | 20 | public static Integer DisplayModeCenterX() { 21 | final int width = displayMode().getWidth(); 22 | final int centerX = (width / HALF) - (Display.WIDTH / HALF); 23 | return centerX; 24 | } 25 | 26 | public static Integer DisplayModeCenterY() { 27 | final int height = displayMode().getHeight(); 28 | final int centerY = (height / HALF) - (Display.HEIGHT / HALF); 29 | return centerY; 30 | } 31 | 32 | public static void setLookAndFeel(String lookAndFeel, Component component) { 33 | try { 34 | UIManager.setLookAndFeel(lookAndFeel); 35 | } catch (InstantiationException | 36 | ClassNotFoundException | 37 | UnsupportedLookAndFeelException | 38 | IllegalAccessException ex) { 39 | ex.printStackTrace(); 40 | } finally { 41 | SwingUtilities.updateComponentTreeUI(component); 42 | } 43 | } 44 | 45 | public static int mergeTo16bits(short big, short little) { 46 | return ((big << 8) | little); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /chip8/src/framework/core/AsyncTask.java: -------------------------------------------------------------------------------- 1 | package framework.core; 2 | 3 | import framework.dispose.Disposable; 4 | 5 | /** 6 | * Created by vicboma on 11/07/14. 7 | * Create a task asynchronously executable. 8 | */ 9 | public class AsyncTask implements Disposable { 10 | private static final String PROCESSOR_THREAD = "processor-thread"; 11 | private Thread thread; 12 | private T executable; 13 | 14 | public AsyncTask(final T executable) { 15 | this.executable = executable; 16 | thread = new Thread(executable, PROCESSOR_THREAD + executable.toString()); 17 | thread.setPriority(Thread.NORM_PRIORITY); 18 | } 19 | 20 | public void start() { 21 | thread.start(); 22 | } 23 | 24 | public void stop() { 25 | executable.stop(); 26 | thread.stop(); 27 | dispose(); 28 | } 29 | 30 | @Override 31 | public void dispose() { 32 | executable = null; 33 | thread = null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /chip8/src/framework/core/Executable.java: -------------------------------------------------------------------------------- 1 | package framework.core; 2 | 3 | /** 4 | * Created by vicboma on 11/07/14. 5 | * Interface based on sequential pattern 6 | */ 7 | public interface Executable extends Runnable { 8 | void stop(); 9 | } 10 | -------------------------------------------------------------------------------- /chip8/src/framework/core/Updateable.java: -------------------------------------------------------------------------------- 1 | package framework.core; 2 | 3 | /** 4 | * Created by vicboma on 14/07/14. 5 | * Interface based on sequential pattern 6 | */ 7 | public interface Updateable { 8 | void update(Double deltaTime); 9 | } 10 | -------------------------------------------------------------------------------- /chip8/src/framework/dispose/Disposable.java: -------------------------------------------------------------------------------- 1 | package framework.dispose; 2 | 3 | /** 4 | * Created by vicboma on 08/07/14. 5 | */ 6 | public interface Disposable { 7 | abstract void dispose(); 8 | } 9 | -------------------------------------------------------------------------------- /chip8/src/framework/windows/ActionCommand.java: -------------------------------------------------------------------------------- 1 | package framework.windows; 2 | 3 | /** 4 | * Created by vicboma on 09/07/14. 5 | */ 6 | public interface ActionCommand { 7 | void execute(); 8 | } 9 | -------------------------------------------------------------------------------- /chip8/src/framework/windows/WindowsItemListenerImpl.java: -------------------------------------------------------------------------------- 1 | package framework.windows; 2 | 3 | import emulator.specification.SpecificationChip8Impl; 4 | 5 | import javax.swing.*; 6 | import java.awt.event.ItemEvent; 7 | import java.awt.event.ItemListener; 8 | 9 | /** 10 | * Created by vicboma on 09/07/14. 11 | */ 12 | public class WindowsItemListenerImpl implements ItemListener { 13 | 14 | private SpecificationChip8Impl specificationChip8Impl; 15 | private JCheckBoxMenuItem sound; 16 | 17 | WindowsItemListenerImpl(final SpecificationChip8Impl specificationChip8Impl, final JCheckBoxMenuItem sound) { 18 | this.specificationChip8Impl = specificationChip8Impl; 19 | this.sound = sound; 20 | this.sound.addItemListener(this); 21 | } 22 | 23 | public static ItemListener create(final SpecificationChip8Impl specificationChip8Impl, final JCheckBoxMenuItem sound) { 24 | return new WindowsItemListenerImpl(specificationChip8Impl, sound); 25 | } 26 | 27 | @Override 28 | public void itemStateChanged(ItemEvent event) { 29 | final Object itemSelected = event.getItem(); 30 | 31 | if (itemSelected == this.sound) { 32 | //this.cpu.soundOff = sound.getState(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /chip8/src/framework/windows/WindowsListenerImpl.java: -------------------------------------------------------------------------------- 1 | package framework.windows; 2 | 3 | import java.awt.event.WindowEvent; 4 | import java.awt.event.WindowListener; 5 | 6 | /** 7 | * Created by vicboma on 09/07/14. 8 | */ 9 | public class WindowsListenerImpl implements WindowListener { 10 | 11 | WindowsListenerImpl() { 12 | } 13 | 14 | public static WindowListener create() { 15 | return new WindowsListenerImpl(); 16 | } 17 | 18 | public void windowOpened(WindowEvent e) { 19 | } 20 | 21 | public void windowClosing(WindowEvent e) { 22 | e.getWindow().dispose(); 23 | System.exit(0); 24 | } 25 | 26 | public void windowClosed(WindowEvent e) { 27 | } 28 | 29 | public void windowIconified(WindowEvent e) { 30 | } 31 | 32 | public void windowDeiconified(WindowEvent e) { 33 | } 34 | 35 | public void windowActivated(WindowEvent e) { 36 | } 37 | 38 | public void windowDeactivated(WindowEvent e) { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /emulators.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /gameboyclassic/LoadRomMBC3: -------------------------------------------------------------------------------- 1 | Vicboma - Game Boy Emulator v0.2.2 Debug (c) 2014 Victor Manuel Bolinches Marin 2 | Debug: Read SRAM from '/Users/vicboma/Downloads/Pokemon Rojo ingles.sav' 3 | Debug: 4 | Rom name : /Users/vicboma/Downloads/Pokemon Rojo ingles.gb 5 | Rom original title : POKEMON RED 6 | Rom version : 0 7 | License code : 817 8 | Old license : Nintendo 48 49 - Code : 51 9 | Game boy game : Classic - Code : 0 10 | Destination Region : Non-Japanese - Code : 1 11 | Game boy indicator : Super GameBoy functions - Code : 3 12 | Checksum = 37350 13 | Actual checksum = 37350 14 | Header checksum = 32 15 | Actual header checksum = 33 16 | Cartridge type = ROM+MBC3+NO_RTC+RAM+BATT 17 | Rom banks = 64 - Rom size = 1024 Kb. 18 | Ram banks = 4 - Ram size = 32768 19 | Is vertical blank interrupt handler ? true 20 | Is lcd status interrupt handler ? true 21 | Is timer overflow interrupt handler ? true 22 | Is serial transfer completion interrupt handler ? true 23 | Is high to lower of P10-P13 interrupt handler ? true 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/CartridgeAsync.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge; 2 | 3 | import utils.Diposable.Disposable; 4 | import utils.Reseteable.Reseteable; 5 | 6 | import java.awt.*; 7 | import java.util.concurrent.CompletableFuture; 8 | 9 | /** 10 | * Created by vicboma on 15/08/15. 11 | */ 12 | public interface CartridgeAsync extends Disposable, Reseteable { 13 | 14 | CompletableFuture load(String romFileName, Component a); 15 | 16 | CompletableFuture write(int addr, int data); 17 | 18 | CompletableFuture read(int addr); 19 | 20 | int gBIndicator(); 21 | 22 | boolean isGbColor(); 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/battery/Battery.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.battery; 2 | 3 | import cartridge.game.Game; 4 | import cartridge.memory.fisic.FisicMemory; 5 | 6 | import java.nio.ByteBuffer; 7 | import java.util.concurrent.CompletableFuture; 8 | 9 | /** 10 | * Created by vicboma on 18/08/15. 11 | */ 12 | public interface Battery { 13 | CompletableFuture saveRam(Game game, FisicMemory ram); 14 | CompletableFuture loadRam(Game game); 15 | } 16 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/game/Game.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.game; 2 | 3 | import cartridge.memory.fisic.FisicMemory; 4 | 5 | /** 6 | * Created by vicboma on 18/08/15. 7 | */ 8 | public interface Game { 9 | void normalizeRom(FisicMemory rom); 10 | 11 | Boolean checkSum(boolean isCheck); 12 | 13 | int romBanks(); 14 | 15 | int ramBanks(); 16 | 17 | String getName(); 18 | 19 | int indicator(); 20 | 21 | boolean isGbColor(); 22 | 23 | String toString(); 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/Memory.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory; 2 | 3 | import cartridge.memory.fisic.FisicMemory; 4 | 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** 8 | * Created by vicboma on 18/08/15. 9 | */ 10 | public interface Memory { 11 | 12 | CompletableFuture read(final int address, final FisicMemory rom, final FisicMemory ram); 13 | 14 | CompletableFuture write(final int address, final int data, final FisicMemory rom, final FisicMemory ram); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/bankController/MBC1.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.bankController; 2 | 3 | import framework.pattern.diposable.Disposable; 4 | import framework.pattern.reseteable.Reseteable; 5 | 6 | /** 7 | * Created by vicboma on 18/08/15. 8 | */ 9 | public interface MBC1 extends Disposable, Reseteable { 10 | boolean isModeEnabled(); 11 | 12 | void setModeEnabled(boolean isMode); 13 | 14 | boolean isRamEnabled(); 15 | 16 | void setRamEnabled(boolean isRamEnabled); 17 | } 18 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/bankController/MBC1Impl.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.bankController; 2 | 3 | import framework.injector.api.annotation.Inject; 4 | import framework.injector.api.annotation.method.PostConstruct; 5 | import framework.logger.api.Logger; 6 | 7 | /** 8 | * Created by vicboma on 15/08/15. 9 | */ 10 | public class MBC1Impl implements MBC1 { 11 | 12 | private boolean isModeEnabled; 13 | private boolean isRamEnabled; 14 | 15 | @Inject 16 | public Logger logger; 17 | 18 | /** 19 | * Memory bank controller 20 | */ 21 | public MBC1Impl() { 22 | isModeEnabled = true; 23 | isRamEnabled = false; 24 | } 25 | 26 | @PostConstruct 27 | public void initialize(){ 28 | logger.info(this); 29 | } 30 | 31 | @Override 32 | public boolean isModeEnabled() { 33 | return isModeEnabled; 34 | } 35 | 36 | @Override 37 | public void setModeEnabled(boolean isMode) { 38 | this.isModeEnabled = isMode; 39 | } 40 | 41 | @Override 42 | public boolean isRamEnabled() { 43 | return isRamEnabled; 44 | } 45 | 46 | @Override 47 | public void setRamEnabled(boolean isRamEnabled) { 48 | this.isRamEnabled = isRamEnabled; 49 | } 50 | 51 | @Override 52 | public void dispose() { 53 | isModeEnabled = false; 54 | isRamEnabled = false; 55 | } 56 | 57 | @Override 58 | public void reset() { 59 | isModeEnabled = true; 60 | isRamEnabled = false; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/bankController/MBC3.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.bankController; 2 | 3 | import framework.pattern.diposable.Disposable; 4 | import framework.pattern.reseteable.Reseteable; 5 | 6 | /** 7 | * Created by vicboma on 18/08/15. 8 | */ 9 | public interface MBC3 extends Disposable, Reseteable { 10 | boolean isClockenabled(); 11 | 12 | void setClockenabled(boolean clockenabled); 13 | 14 | long getTime(); 15 | 16 | void setTime(long time); 17 | 18 | int getReg(); 19 | 20 | void setReg(int reg); 21 | } 22 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/bankController/MBC3Impl.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.bankController; 2 | 3 | import framework.injector.api.annotation.Inject; 4 | import framework.injector.api.annotation.method.PostConstruct; 5 | import framework.logger.api.Logger; 6 | 7 | /** 8 | * Created by vicboma on 15/08/15. 9 | */ 10 | public class MBC3Impl implements MBC3 { 11 | 12 | private boolean clockenabled; 13 | private long time; 14 | private int reg; 15 | 16 | @Inject 17 | public Logger logger; 18 | 19 | /** 20 | * Memory bank controller 21 | */ 22 | public MBC3Impl() { 23 | this.clockenabled = false; 24 | this.time = 0; 25 | this.reg = 0; 26 | } 27 | 28 | @PostConstruct 29 | public void initialize(){ 30 | logger.info(this); 31 | } 32 | 33 | @Override 34 | public boolean isClockenabled() { 35 | return clockenabled; 36 | } 37 | 38 | @Override 39 | public void setClockenabled(boolean clockenabled) { 40 | this.clockenabled = clockenabled; 41 | } 42 | 43 | @Override 44 | public long getTime() { 45 | return time; 46 | } 47 | 48 | @Override 49 | public void setTime(long time) { 50 | this.time = time; 51 | } 52 | 53 | @Override 54 | public int getReg() { 55 | return reg; 56 | } 57 | 58 | @Override 59 | public void setReg(int reg) { 60 | this.reg = reg; 61 | } 62 | 63 | @Override 64 | public void reset() { 65 | clockenabled = false; 66 | } 67 | 68 | @Override 69 | public void dispose() { 70 | clockenabled = false; 71 | this.reg = 0; 72 | this.time = 0; 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/bankController/ReadMBC3Clock.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.bankController; 2 | 3 | import java.util.Calendar; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Created by vicboma on 20/08/15. 8 | */ 9 | public interface ReadMBC3Clock { 10 | CompletableFuture runAsync(final Calendar cal); 11 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/fisic/FisicMemory.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.fisic; 2 | 3 | /** 4 | * Created by vicboma on 15/08/15. 5 | */ 6 | public interface FisicMemory { 7 | 8 | byte getValue(int address); 9 | 10 | void setValue(int address, byte value); 11 | 12 | byte[] getObject(); 13 | 14 | void setObject(byte[] memory); 15 | 16 | int getOffset(); 17 | 18 | void setOffset(int offset); 19 | 20 | void bank(int bank); 21 | 22 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/fisic/FisicMemoryImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.fisic; 2 | 3 | /** 4 | * Created by vicboma on 13/09/15. 5 | */ 6 | public class FisicMemoryImpl implements FisicMemory { 7 | protected byte[] mem; 8 | 9 | protected int offset; 10 | 11 | public static FisicMemoryImpl Create() { 12 | return new FisicMemoryImpl(); 13 | } 14 | 15 | public static FisicMemoryImpl Create(byte[] mem) { 16 | return new FisicMemoryImpl(mem); 17 | } 18 | 19 | public FisicMemoryImpl() { 20 | } 21 | 22 | public FisicMemoryImpl(byte[] mem) { 23 | this.mem = mem; 24 | } 25 | 26 | public byte getData(int addres) { 27 | return mem[addres]; 28 | } 29 | 30 | public void setData(int addres, byte value) { 31 | mem[addres] = value; 32 | } 33 | 34 | public byte[] getObject() { 35 | return mem; 36 | } 37 | 38 | public void setObject(byte[] mem) { 39 | this.mem = mem; 40 | } 41 | 42 | public int getOffset() { 43 | return offset; 44 | } 45 | 46 | public void setOffset(int offset) { 47 | this.offset = offset; 48 | } 49 | 50 | public void bank(int bank) { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/fisic/Ram.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.fisic; 2 | 3 | import utils.shell.Logger; 4 | 5 | /** 6 | * Created by vicboma on 15/08/15. 7 | */ 8 | public class Ram extends FisicMemoryImpl { 9 | 10 | public static Ram Create() { 11 | return new Ram(); 12 | } 13 | 14 | public static Ram Create(byte[] ram) { 15 | return new Ram(ram); 16 | } 17 | 18 | public Ram() { 19 | } 20 | 21 | public Ram(byte[] ram) { 22 | super(ram); 23 | } 24 | 25 | @Override 26 | public void setData(int addres, byte value) { 27 | if (addres >= 197198) 28 | Logger.Debug("address: " + addres + " value: " + value); 29 | else 30 | mem[addres] = value; 31 | } 32 | 33 | public void bank(int bank) { 34 | setOffset(-0xA000 + bank * 0x2000); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cartridge/memory/fisic/Rom.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.fisic; 2 | 3 | /** 4 | * Created by vicboma on 15/08/15. 5 | */ 6 | public class Rom extends FisicMemoryImpl { 7 | 8 | public static Rom Create() { 9 | return new Rom(); 10 | } 11 | 12 | public static Rom Create(byte[] rom) { 13 | return new Rom(rom); 14 | } 15 | 16 | public Rom() { 17 | } 18 | 19 | public Rom(byte[] rom) { 20 | super(rom); 21 | } 22 | 23 | public void bank(int bank) { 24 | setOffset((bank - 1) * 0x4000); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/configuration/EmulatorConfigurator.java: -------------------------------------------------------------------------------- 1 | package emulator.configuration; 2 | 3 | import configuration.config.*; 4 | import configuration.extension.CartridgeExtension; 5 | import configuration.extension.GameBoyDMGExtension; 6 | import framework.context.api.FrameworkContext; 7 | import framework.context.src.FrameworkContextImpl; 8 | 9 | /** 10 | * Created by vicboma on 28/09/15. 11 | */ 12 | public class EmulatorConfigurator { 13 | 14 | private static FrameworkContext context; 15 | 16 | public static EmulatorConfigurator configure() throws Exception { 17 | return new EmulatorConfigurator(); 18 | } 19 | 20 | public EmulatorConfigurator() throws Exception { 21 | 22 | context = FrameworkContextImpl.create(); 23 | 24 | context 25 | .immediatelyInstallExtension(GameBoyDMGExtension.create()) 26 | .immediatelyInstallExtension(CartridgeExtension.create()) 27 | .installExtensionAsync(MainLoopCoreConfigure.create()) 28 | .immediatelyConfigure(GraphicsConfigure.create()) 29 | .immediatelyConfigure(MainWindowConfigure.create()) 30 | .immediatelyConfigure(ConsoleConfigure.create()) 31 | .immediatelyConfigure(ToolBarWindowConfigure.create()) 32 | .executeCompletableAsync(() -> { 33 | return configuration(); 34 | }); 35 | 36 | context.persistenConfiguration(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/Commands.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command; 2 | 3 | /** 4 | * Created by vicboma on 12/08/15. 5 | */ 6 | public interface Commands { 7 | void runAsync(int opCode1, int opCode2, int opCode3, int opCode4); 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/CommandsImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command; 2 | 3 | import cpu.processor.Z80; 4 | import utils.Operation; 5 | 6 | /** 7 | * Created by vicboma on 13/08/15. 8 | */ 9 | public class CommandsImpl implements Commands { 10 | 11 | protected Z80 z80; 12 | 13 | public CommandsImpl(Z80 z80) { 14 | this.z80 = z80; 15 | } 16 | 17 | @Override 18 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 19 | 20 | } 21 | 22 | protected void NoOp() { 23 | this.z80.pc++; 24 | this.z80.cycles += 4; 25 | } 26 | 27 | protected int loadImmediateF(final int reg) { 28 | this.z80.pc += 2; 29 | this.z80.cycles += 16; 30 | return reg; 31 | } 32 | 33 | protected int loadImmediate(final int reg) { 34 | this.z80.pc += 2; 35 | this.z80.cycles += 8; 36 | return reg; 37 | } 38 | 39 | protected int load(final int reg) { 40 | this.z80.pc++; 41 | this.z80.cycles += 4; 42 | return reg; 43 | } 44 | 45 | public void addressWrite(final int address, final int data, final int opc, final int cycles) { 46 | z80.pc += opc; 47 | z80.addressWrite(address, data); 48 | this.z80.cycles += cycles; 49 | } 50 | 51 | public short addressRead(final int address, final int pc, final int cycles) { 52 | z80.pc = pc; 53 | this.z80.cycles += cycles; 54 | return Operation.unsign(z80.addressRead(address)); 55 | } 56 | 57 | public void decreaseRegisterHL() { 58 | this.z80.hl = (z80.hl - 1) & 0xFFFF; 59 | } 60 | 61 | public void incremetRegisterHL() { 62 | this.z80.hl = (z80.hl + 1) & 0xFFFF; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits16/add/ADD_HL_BC.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.add; 2 | 3 | import cpu.processor.command.CommandsImpl; 4 | import cpu.processor.register.flag.Flags; 5 | import cpu.processor.z80.Z80Impl; 6 | 7 | /** 8 | * Created by vicboma on 14/09/14. 9 | * Mnemonic Time Size CNPHZS OP-Code 10 | * ADD HL,BC 11 1 +0- -- 09 11 | * HL <- HL + BC 12 | */ 13 | public class ADD_HL_BC extends CommandsImpl { 14 | 15 | public static final int OP_CODE_0X09 = 0x09; 16 | 17 | public ADD_HL_BC(Z80Impl z80Impl) { 18 | super(z80Impl); 19 | } 20 | 21 | /** 22 | * 4 ld c,a 23 | * 4 ld b,0 24 | * 11 add hl,bc 25 | * @param opCode1 26 | * @param opCode2 27 | * @param opCode3 28 | * @param opCode4 29 | */ 30 | @Override 31 | public void execute(int opCode1, int opCode2, int opCode3, int opCode4) { 32 | z80Impl.pc++; 33 | final int b = z80Impl.b << 8; 34 | final int c = z80Impl.c; 35 | final int bc = b + c; 36 | z80Impl.hl = ( z80Impl.hl + bc); 37 | 38 | final int fAndFlags = z80Impl.f & (Flags.SUBTRACT + Flags.ZERO + Flags.HALFCARRY); 39 | final int regH = z80Impl.hl & 0xFFFF0000; 40 | 41 | z80Impl.f = (short) fAndFlags; 42 | 43 | if (regH != 0) { 44 | z80Impl.f = (short) (fAndFlags | (Flags.CARRY)); 45 | z80Impl.hl &= 0xFFFF; 46 | } 47 | 48 | this.z80Impl.cycles+= 8; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits16/dec/DEC_BC.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.dec; 2 | 3 | import cpu.processor.command.CommandsImpl; 4 | import cpu.processor.z80.Z80Impl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class DEC_BC extends CommandsImpl { 10 | 11 | public static final int OP_CODE_0X0B = 0x0B; 12 | 13 | /** 14 | * Increment register nn. 15 | */ 16 | public DEC_BC(Z80Impl z80Impl) { 17 | super(z80Impl); 18 | } 19 | 20 | @Override 21 | public void execute(int opCode1, int opCode2, int opCode3, int opCode4) { 22 | this.z80Impl.pc++; 23 | decrementC(); 24 | final int offsetC = this.z80Impl.c & 0xFF00; 25 | if (offsetC != 0) { 26 | this.z80Impl.c = 0xFF; 27 | decrementB(); 28 | final int offsetB = this.z80Impl.b & 0xFF00; 29 | if (offsetB != 0) { 30 | this.z80Impl.b = 0xFF; 31 | } 32 | } 33 | this.z80Impl.cycles+=8; 34 | } 35 | 36 | private void decrementB() { 37 | this.z80Impl.b--; 38 | } 39 | 40 | private void decrementC() { 41 | this.z80Impl.c--; 42 | } 43 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LDD_HL_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LDD_HL_A extends CommandsImpl { 10 | 11 | /** 12 | * Put A into memory address HL. Decrement HL. Same as: LD (HL),A - DEC HL - 0x32 13 | */ 14 | public LDD_HL_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | super.addressWrite(z80.hl, z80.a, 1, 8); 21 | super.decreaseRegisterHL(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LDI_A_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LDI_A_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value at address HL into A. Increment HL. Same as: LD A,(HL) - INC HL - 2A 13 | */ 14 | public LDI_A_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.addressRead(z80.hl, 1, 8); 21 | super.incremetRegisterHL(); 22 | } 23 | } 24 | ; -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LDI_HL_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LDI_HL_A extends CommandsImpl { 10 | 11 | /** 12 | * Put A into memory address HL. Increment HL. Same as: LD (HL),A - INC HL - 22 13 | */ 14 | public LDI_HL_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | super.addressWrite(z80.hl, z80.a, 1, 8); 21 | super.incremetRegisterHL(); 22 | } 23 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.a = super.load(z80.a); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.a = super.load(z80.b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_BC.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_BC extends CommandsImpl { 10 | 11 | /** 12 | * Put value A into n. 13 | */ 14 | public LD_A_BC(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.addressRead((z80.b & 0x00FF) << 8 | z80.c & 0x00FF, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.load(z80.c); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.load(z80.d); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_DE.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_DE extends CommandsImpl { 10 | 11 | /** 12 | * Put value A into n. 13 | */ 14 | public LD_A_DE(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.addressRead((z80.d & 0x00FF) << 8 | z80.e & 0x00FF, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.load(z80.e); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_FF00_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | import utils.Operation; 6 | 7 | /** 8 | * Created by vicboma on 14/08/15. 9 | */ 10 | public class LD_A_FF00_C extends CommandsImpl { 11 | 12 | /** 13 | * Put value at address $FF00 + register C into A. 14 | * Same as: LD A,($FF00+C) 0xF2 15 | * 16 | * @param z80 17 | */ 18 | public LD_A_FF00_C(Z80 z80) { 19 | super(z80); 20 | } 21 | 22 | @Override 23 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 24 | this.z80.a = Operation.unsign(super.addressRead(0xFF00 + z80.c, 1, 8)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_FF00_NN.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | import utils.Operation; 6 | 7 | /** 8 | * Created by vicboma on 14/08/15. 9 | */ 10 | public class LD_A_FF00_NN extends CommandsImpl { 11 | 12 | /** 13 | * Put memory address $FF00+n into A. - F0 14 | * 15 | * @param z80 16 | */ 17 | public LD_A_FF00_NN(Z80 z80) { 18 | super(z80); 19 | } 20 | 21 | @Override 22 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 23 | this.z80.a = Operation.unsign(super.addressRead(0xFF00 + opCode2, 2, 16)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.load((z80.hl & 0xFF00)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.addressRead(z80.hl, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_HLL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LD_A_HLL extends CommandsImpl { 10 | 11 | /** 12 | * Put value at address HL into A. Decrement HL. Same as: LD A,(HL) - DEC HL 0x3A 13 | */ 14 | public LD_A_HLL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | super.addressRead(z80.hl, 1, 8); 21 | super.decreaseRegisterHL(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_A_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.load((z80.hl & 0x00FF)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value n into A. 0x3E 13 | */ 14 | public LD_A_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.loadImmediate((opCode2 & 0x00FF)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_A_NNN.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_A_NNN extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 0xFA 13 | */ 14 | public LD_A_NNN(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.a = super.addressRead((opCode3 << 8) | opCode2, 3, 16); 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_BC_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_BC_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value A into n. 13 | */ 14 | public LD_BC_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | super.addressWrite(((z80.b & 0x00FF << 8) | z80.c & 0x00FF), z80.a, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load(z80.a); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load(z80.b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load(z80.c); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load(z80.d); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load(z80.e); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load((z80.hl & 0xFF00)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.addressRead(z80.hl, 1, 8); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_B_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.b = super.load(z80.hl & 0x00FF); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_B_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_B_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value nn into n 13 | */ 14 | public LD_B_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.b = super.loadImmediate(opCode2); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load(z80.a); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load(z80.b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load(z80.c); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load(z80.d); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load(z80.e); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_FF00_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LD_C_FF00_A extends CommandsImpl { 10 | 11 | /** 12 | * Put A into address $FF00 + register C. 0xE2 13 | * 14 | * @param z80 15 | */ 16 | public LD_C_FF00_A(Z80 z80) { 17 | super(z80); 18 | } 19 | 20 | @Override 21 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 22 | super.addressWrite(0xFF00 + this.z80.a, this.z80.c, 1, 8); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load((z80.hl & 0xFF00)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.c = super.addressRead(z80.hl, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_C_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.c = super.load(z80.hl & 0x00FF); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_C_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_C_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value nn into n 13 | */ 14 | public LD_C_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.c = super.loadImmediate(opCode2); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_DE_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_DE_A extends CommandsImpl { 10 | 11 | /** 12 | * ut value A into n. 13 | */ 14 | public LD_DE_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | super.addressWrite(((z80.d & 0x00FF << 8) | z80.e & 0x00FF), z80.a, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load(z80.a); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load(z80.b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load(z80.c); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load(z80.d); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load(z80.e); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load((z80.hl & 0xFF00)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.d = super.addressRead(z80.hl, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_D_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.d = super.load(z80.hl & 0x00FF); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_D_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_D_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value nn into n 13 | */ 14 | public LD_D_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.d = super.loadImmediate(opCode2); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load(z80.a); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load(z80.b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load(z80.c); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load(z80.d); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load(z80.e); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load((z80.hl & 0xFF00)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.e = super.addressRead(z80.hl, 1, 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_E_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.e = super.load(z80.hl & 0x00FF); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_E_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_E_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value nn into n 13 | */ 14 | public LD_E_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.e = super.loadImmediate(opCode2); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_FF00_NN_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LD_FF00_NN_A extends CommandsImpl { 10 | 11 | /** 12 | * Put A into memory address $FF00+n - 0xE 13 | * 14 | * @param z80 15 | */ 16 | public LD_FF00_NN_A(Z80 z80) { 17 | super(z80); 18 | } 19 | 20 | @Override 21 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 22 | super.addressWrite(0xFF00 + opCode2, z80.a, 2, 12); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.a, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.b, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.c, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.d, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.e, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.hl & 0xFF00, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, z80.hl & 0x00FF, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_HL_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_HL_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_HL_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.addressWrite(z80.hl, opCode2, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.a & 0x00FF) << 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.b & 0x00FF) << 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.c & 0x00FF) << 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.d & 0x00FF) << 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.e & 0x00FF) << 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.hl & 0xFF00)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.addressRead((z80.hl & 0x00FF) | z80.hl, 1, 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_H_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0x00FF) | (z80.hl & 0x00FF) << 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_H_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_H_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value nn into n 13 | */ 14 | public LD_H_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.hl = super.loadImmediate((z80.hl & 0x00FF) | (opCode2 << 8)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_A(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.a & 0x00FF)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_B.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_B extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_B(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.b & 0x00FF)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_C.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_C extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_C(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.c & 0x00FF)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_D.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_D extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_D(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.d & 0x00FF)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_E.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_E extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_E(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.e & 0x00FF)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_H.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_H extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_H(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.hl & 0xFF00) >> 8); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_HL.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_HL extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_HL(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | z80.hl); 22 | this.z80.cycles += 4; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_L.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_L extends CommandsImpl { 10 | 11 | /** 12 | * Put value r2 into r1. 13 | */ 14 | public LD_L_L(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | z80.hl = super.load((z80.hl & 0xFF00) | (z80.hl & 0x00FF)); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_L_N.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 12/08/15. 8 | */ 9 | public class LD_L_N extends CommandsImpl { 10 | 11 | /** 12 | * Put value nn into n 13 | */ 14 | public LD_L_N(Z80 z80) { 15 | super(z80); 16 | } 17 | 18 | @Override 19 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 20 | z80.hl = super.loadImmediate((z80.hl & 0xFF00) | opCode2); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/bits8/LD_NNN_A.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 14/08/15. 8 | */ 9 | public class LD_NNN_A extends CommandsImpl { 10 | 11 | /** 12 | * Put value A into n. 0xEA 13 | * 14 | * @param z80 15 | */ 16 | public LD_NNN_A(Z80 z80) { 17 | super(z80); 18 | } 19 | 20 | @Override 21 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 22 | super.addressWrite((opCode3 << 8) | opCode2, z80.a, 3, 16); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/command/noOperation/NoOperation.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.noOperation; 2 | 3 | import cpu.processor.Z80; 4 | import cpu.processor.command.CommandsImpl; 5 | 6 | /** 7 | * Created by vicboma on 13/08/15. 8 | */ 9 | public class NoOperation extends CommandsImpl { 10 | 11 | /** 12 | * No operation 13 | * @param z80 14 | */ 15 | public NoOperation(Z80 z80) { 16 | super(z80); 17 | } 18 | 19 | @Override 20 | public void runAsync(int opCode1, int opCode2, int opCode3, int opCode4) { 21 | super.NoOp(); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/mainRam/MainRam.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.mainRam; 2 | 3 | import framework.factory.FactoryCollectionImpl; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by vicboma on 09/09/15. 9 | * Represented a Main Ram Processor 10 | */ 11 | public class MainRam extends FactoryCollectionImpl { 12 | 13 | // 32Kb for GBC ( 32768 ) 14 | public static final int mainRamGBC = 0x32768; 15 | // 8Kb main system RAM 16 | public static final int mainRamDMG = 0x8000; 17 | 18 | public static MainRam Create(final int size, final H _default) { 19 | List list = FactoryCollectionImpl.initialize(size, _default); 20 | return new MainRam(list); 21 | } 22 | 23 | public MainRam(final List mainRam) { 24 | super(mainRam); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/MemoryZ80.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory; 2 | 3 | import cpu.processor.memory.read.MemoryMapReadInternal; 4 | import cpu.processor.memory.write.MemoryMapWriteInternal; 5 | 6 | /** 7 | * Created by vicboma on 10/09/15. 8 | */ 9 | public interface MemoryZ80 extends MemoryMapReadInternal, MemoryMapWriteInternal { 10 | } 11 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/read/MemoryMapReadInternal.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.read; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** 6 | * Created by vicboma on 20/08/15. 7 | */ 8 | public interface MemoryMapReadInternal { 9 | CompletableFuture read(final int address); 10 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/ControlSio.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import emulator.cpu.processor.memory.registerIoAux.parent.RegisterMemoryMapImpl; 4 | 5 | /** 6 | * Created by vicboma on 08/09/15. 7 | */ 8 | public class ControlSio extends RegisterMemoryMapImpl { 9 | public ControlSio() { 10 | super(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/Div.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import emulator.cpu.processor.memory.registerIoAux.parent.RegisterMemoryMapImpl; 4 | 5 | /** 6 | * Created by vicboma on 08/09/15. 7 | */ 8 | public class Div extends RegisterMemoryMapImpl { 9 | public Div() { 10 | super(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/Dma.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import emulator.cpu.processor.memory.registerIoAux.parent.RegisterMemoryMapImpl; 4 | 5 | /** 6 | * Created by vicboma on 08/09/15. 7 | */ 8 | public class Dma extends RegisterMemoryMapImpl { 9 | public Dma() { 10 | super(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/If.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import emulator.cpu.processor.memory.registerIoAux.parent.RegisterMemoryMapImpl; 4 | 5 | /** 6 | * Created by vicboma on 08/09/15. 7 | */ 8 | public class If extends RegisterMemoryMapImpl { 9 | public If() { 10 | super(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/PaletteIoRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public class PaletteIoRegister { 7 | private byte OBJ0; 8 | private byte OBJ1; 9 | private byte BGP; 10 | 11 | public PaletteIoRegister() { 12 | } 13 | 14 | public byte OBJ0() { 15 | return this.OBJ0; 16 | } 17 | 18 | public void OBJ0(byte OBJ0) { 19 | this.OBJ0 = OBJ0; 20 | } 21 | 22 | public byte OBJ1() { 23 | return this.OBJ1; 24 | } 25 | 26 | public void OBJ1(byte OBJ1) { 27 | this.OBJ1 = OBJ1; 28 | } 29 | 30 | public byte BGP() { 31 | return this.BGP; 32 | } 33 | 34 | public void BGP(byte BGP) { 35 | this.BGP = BGP; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/QuadrangularWaveIoRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public class QuadrangularWaveIoRegister { 7 | private byte sweepRegister; 8 | private byte lengthWaveRegister; 9 | private byte envelopeRegister; 10 | private byte frequencyRegisterLO; 11 | private byte frequencyRegisterHI; 12 | 13 | public QuadrangularWaveIoRegister() { 14 | } 15 | 16 | public byte sweepRegister() { 17 | return this.sweepRegister; 18 | } 19 | 20 | public void sweepRegister(byte sweepRegister) { 21 | this.sweepRegister = sweepRegister; 22 | } 23 | 24 | public byte lengthWaveRegister() { 25 | return this.lengthWaveRegister; 26 | } 27 | 28 | public void lengthWaveRegister(byte lengthWaveRegister) { 29 | this.lengthWaveRegister = lengthWaveRegister; 30 | } 31 | 32 | public byte envelopeRegister() { 33 | return this.envelopeRegister; 34 | } 35 | 36 | public void envelopeRegister(byte envelopeRegister) { 37 | this.envelopeRegister = envelopeRegister; 38 | } 39 | 40 | public byte frequencyRegisterLO() { 41 | return this.frequencyRegisterLO; 42 | } 43 | 44 | public void frequencyRegisterLO(byte frequencyRegisterLO) { 45 | this.frequencyRegisterLO = frequencyRegisterLO; 46 | } 47 | 48 | public byte frequencyRegisterHI() { 49 | return this.frequencyRegisterHI; 50 | } 51 | 52 | public void frequencyRegisterHI(byte frequencyRegisterHI) { 53 | this.frequencyRegisterHI = frequencyRegisterHI; 54 | } 55 | 56 | 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/SerialT.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import emulator.cpu.processor.memory.registerIoAux.parent.RegisterMemoryMapImpl; 4 | 5 | /** 6 | * Created by vicboma on 08/09/15. 7 | */ 8 | public class SerialT extends RegisterMemoryMapImpl { 9 | public SerialT() { 10 | super(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/SoundMixerIoRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public class SoundMixerIoRegister { 7 | private WavePatternRamIoRegister wavePatternRamIoRegister; 8 | private byte channelControl; 9 | private byte channelOutput; 10 | private byte soundOnOff; 11 | 12 | public SoundMixerIoRegister() { 13 | wavePatternRamIoRegister = new WavePatternRamIoRegister(); 14 | } 15 | 16 | public byte channelControl() { 17 | return this.channelControl; 18 | } 19 | public void channelControl(byte channelControl) { 20 | this.channelControl = channelControl; 21 | } 22 | 23 | public byte channelOutput() { 24 | return this.channelOutput; 25 | } 26 | public void channelOutput(byte register) { 27 | this.channelOutput = register; 28 | } 29 | 30 | public byte soundOnOff() { 31 | return this.soundOnOff; 32 | } 33 | public void soundOnOff(byte soundOnOff) { 34 | this.soundOnOff = soundOnOff; 35 | } 36 | 37 | public WavePatternRamIoRegister wavePatternRamIoRegister(){ return this.wavePatternRamIoRegister; } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/UnMappedRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.IntStream; 6 | 7 | /** 8 | * Created by vicboma on 11/09/15. 9 | */ 10 | public class UnMappedRegister { 11 | private static final int SIZE = 0x100; 12 | private List list; 13 | 14 | public static UnMappedRegister Create(){ 15 | List initialize = initialize(); 16 | return new UnMappedRegister(initialize); 17 | } 18 | 19 | public static List initialize(){ 20 | final List list = new ArrayList(); 21 | IntStream.range(0,SIZE).boxed().forEach(x -> list.add((byte) 0)); 22 | return list; 23 | } 24 | 25 | 26 | public UnMappedRegister(List list){ 27 | this.list = list; 28 | } 29 | 30 | 31 | public Byte read(int address) { 32 | final byte read = list.get(address); 33 | return read; 34 | } 35 | 36 | public void write(int address, byte data) { 37 | final byte set = list.set(address, data); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/VoluntaryWaveIoRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public class VoluntaryWaveIoRegister { 7 | private byte volumeRegister; 8 | private byte setLengthData; 9 | private byte outputLevel; 10 | private byte frequencyRegisterLO; 11 | private byte frequencyRegisterHI; 12 | 13 | public VoluntaryWaveIoRegister() { 14 | } 15 | 16 | public byte volumeRegister() { 17 | return this.volumeRegister; 18 | } 19 | 20 | public void volumeRegister(byte volumeRegister) { 21 | this.volumeRegister = volumeRegister; 22 | } 23 | 24 | public byte setLengthData() { 25 | return this.setLengthData; 26 | } 27 | 28 | public void setLengthData(byte setLengthData) { 29 | this.setLengthData = setLengthData; 30 | } 31 | 32 | public byte outputLevel() { 33 | return this.outputLevel; 34 | } 35 | 36 | public void outputLevel(byte outputLevel) { 37 | this.outputLevel = outputLevel; 38 | } 39 | 40 | public byte frequencyRegisterLO() { 41 | return this.frequencyRegisterLO; 42 | } 43 | 44 | public void frequencyRegisterLO(byte frequencyRegisterLO) { 45 | this.frequencyRegisterLO = frequencyRegisterLO; 46 | } 47 | 48 | public byte frequencyRegisterHI() { 49 | return this.frequencyRegisterHI; 50 | } 51 | 52 | public void frequencyRegisterHI(byte frequencyRegisterHI) { 53 | this.frequencyRegisterHI = frequencyRegisterHI; 54 | } 55 | 56 | 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/WavePatternRamIoRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | import java.util.Hashtable; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by vicboma on 08/09/15. 8 | */ 9 | public class WavePatternRamIoRegister { 10 | 11 | Map map; 12 | 13 | public WavePatternRamIoRegister() { 14 | map = new Hashtable(); 15 | } 16 | 17 | 18 | public Byte get(Integer index){ 19 | final Byte value = this.map.get(index); 20 | return value; 21 | } 22 | 23 | public Byte put(Integer key, byte value){ 24 | return this.map.put(key,value); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/WhiteNoiseIoRegister.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public class WhiteNoiseIoRegister { 7 | private byte envelopeRegister; 8 | private byte setLengthData; 9 | private byte polynomialCycleRegister; 10 | private byte counter; 11 | 12 | public WhiteNoiseIoRegister() { 13 | } 14 | 15 | public byte envelopeRegister() { 16 | return this.envelopeRegister; 17 | } 18 | 19 | public void envelopeRegister(byte envelopeRegister) { 20 | this.envelopeRegister = envelopeRegister; 21 | } 22 | 23 | public byte setLengthData() { 24 | return this.setLengthData; 25 | } 26 | 27 | public void setLengthData(byte setLengthData) { 28 | this.setLengthData = setLengthData; 29 | } 30 | 31 | public byte polynomialCycleRegister() { 32 | return this.polynomialCycleRegister; 33 | } 34 | 35 | public void polynomialCycleRegister(byte polynomialCycleRegister) { 36 | this.polynomialCycleRegister = polynomialCycleRegister; 37 | } 38 | 39 | public byte counter() { 40 | return this.counter; 41 | } 42 | 43 | public void counter(byte counter) { 44 | this.counter = counter; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/parent/RegisterMemoryMap.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux.parent; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public interface RegisterMemoryMap { 7 | byte register(); 8 | void register(byte register); 9 | } 10 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/registerIoAux/parent/RegisterMemoryMapImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.registerIoAux.parent; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public class RegisterMemoryMapImpl implements RegisterMemoryMap { 7 | private byte register; 8 | 9 | public RegisterMemoryMapImpl() { 10 | this.register = 0; 11 | } 12 | 13 | @Override 14 | public byte register() { 15 | return register; 16 | } 17 | 18 | @Override 19 | public void register(byte register) { 20 | this.register = register; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/memory/write/MemoryMapWriteInternal.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.memory.write; 2 | 3 | import java.util.concurrent.ExecutionException; 4 | 5 | /** 6 | * Created by vicboma on 20/08/15. 7 | */ 8 | public interface MemoryMapWriteInternal { 9 | void write(final int address, final int data) throws ExecutionException, InterruptedException; 10 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/spriteAttribMemory/OAM.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.spriteAttribMemory; 2 | 3 | import framework.factory.FactoryCollectionImpl; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by vicboma on 09/09/15. 9 | * Represented a Sprite Attribute Memory 10 | */ 11 | public class OAM extends FactoryCollectionImpl { 12 | 13 | public static final int size = 0xA0; // $FE00-FE9F 1registro lo recorre 4 veces, 40 * 4 = 160 = 0xA0 14 | 15 | public static OAM Create(final int size, H _default){ 16 | List list = FactoryCollectionImpl.initialize(size, _default); 17 | return new OAM(list); 18 | } 19 | 20 | public OAM(final List mainRam) { 21 | super(mainRam); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/z80/disassembler/Disassembler.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.z80.disassembler; 2 | 3 | /** 4 | * Created by vicboma on 05/10/15. 5 | */ 6 | public interface Disassembler { 7 | void execute(StringBuilder instruction, Short hi, Short lo, boolean isDecimal, boolean isHexadecimal); 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/z80/ticks/Z80CbCycles.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.z80.ticks; 2 | 3 | /** 4 | * Created by vicboma on 04/06/15. 5 | */ 6 | public class Z80CbCycles { 7 | 8 | public static Integer[] ticks = new Integer[]{ 9 | 10 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 11 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 12 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 13 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 14 | 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 15 | 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 16 | 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 17 | 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 18 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 19 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 20 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 21 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 22 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 23 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 24 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8, 25 | 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 16, 8 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/cpu/processor/z80/ticks/Z80Cycles.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.z80.ticks; 2 | 3 | /** 4 | * Created by vicboma on 04/06/15. 5 | */ 6 | public class Z80Cycles { 7 | 8 | public static Integer[] ticks = new Integer[]{ 9 | 10 | 4, 12, 8, 8, 4, 4, 8, 4, 20, 8, 8, 8, 4, 4, 8, 4, 11 | 4, 12, 8, 8, 4, 4, 8, 4, 12, 8, 8, 8, 4, 4, 8, 4, 12 | 8, 12, 8, 8, 4, 4, 8, 4, 8, 8, 8, 8, 4, 4, 8, 4, 13 | 8, 12, 8, 8, 12 , 12, 12, 4, 8, 8, 8, 8, 4, 4, 8, 4, 14 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 15 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 16 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 17 | 8, 8, 8, 8, 8, 8, 4, 8, 4, 4, 4, 4, 4, 4, 8, 4, 18 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 19 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 20 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 21 | 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4, 22 | 8, 12, 12, 16, 12, 16, 8, 16, 8, 16, 12, 0, 12, 24, 8, 16, 23 | 8, 12, 12, 4, 12, 16, 8, 16, 8, 16, 12, 4, 12, 4, 8, 16, 24 | 12, 12, 8, 4, 4, 16, 8, 16, 16, 4, 16, 4, 4, 4, 8, 16, 25 | 12, 12, 8, 4, 4, 16, 8, 16, 12, 8, 16, 4, 0, 4, 8, 16 26 | 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/configuration/config/FrameworkConfigurable.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.configuration.config; 2 | 3 | import framework.context.api.FrameworkConfig; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by vicboma on 12/02/15. 9 | */ 10 | public class FrameworkConfigurable implements FrameworkConfig { 11 | 12 | protected Map map; 13 | 14 | public FrameworkConfigurable(Map map) { 15 | this.map = map; 16 | } 17 | 18 | @Override 19 | public void configure() throws Exception { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/configuration/extension/FrameworkExtensionable.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.configuration.extension; 2 | 3 | import framework.context.api.FrameworkExtension; 4 | 5 | import java.util.Map; 6 | import java.util.concurrent.CompletableFuture; 7 | 8 | /** 9 | * Created by vicboma on 12/02/15. 10 | */ 11 | public class FrameworkExtensionable implements FrameworkExtension { 12 | 13 | protected CompletableFuture completableFuture; 14 | protected Map map; 15 | 16 | public FrameworkExtensionable(Map map) { 17 | this.map = map; 18 | } 19 | 20 | @Override 21 | public CompletableFuture installExtensionAsync() throws Exception { 22 | return null; 23 | } 24 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/container/ClassToMapContainer.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.container; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by vicboma on 10/09/15. 8 | */ 9 | public class ClassToMapContainer { 10 | 11 | private Map, Object> map; 12 | 13 | public ClassToMapContainer() { 14 | map = new HashMap(); 15 | } 16 | 17 | public Object put(ClassToMapKey key, T value ) { 18 | return map.put( key, value ); 19 | } 20 | 21 | public T get(ClassToMapKey key ) { 22 | return key._class.cast(map.get(key)); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/container/ClassToMapKey.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.container; 2 | 3 | /** 4 | * Created by vicboma on 10/09/15. 5 | */ 6 | public class ClassToMapKey { 7 | 8 | final String id; 9 | final Class _class; 10 | 11 | public static ClassToMapKey Create(String id, Class _class){ 12 | return new ClassToMapKey(id, _class); 13 | } 14 | 15 | ClassToMapKey(String id, Class _class) { 16 | this.id = id; 17 | this._class = _class; 18 | } 19 | 20 | public String id() { 21 | return id; 22 | } 23 | 24 | public Class _class() { 25 | return _class; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/context/annotation/FrameworkInstall.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.context.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: vicboma 11 | * Date: 14/02/14 12 | * Time: 18:38 13 | */ 14 | @Target(ElementType.METHOD) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface FrameworkInstall { 17 | } 18 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/context/api/FrameworkConfig.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.context.api; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: vicboma 6 | * Date: 26/02/14 7 | * Time: 23:44 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public interface FrameworkConfig 11 | { 12 | void configure() throws Exception; 13 | } 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/context/api/FrameworkContext.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.context.api; 2 | 3 | import framework.injector.api.Injector; 4 | 5 | import java.util.concurrent.Callable; 6 | import java.util.concurrent.CompletableFuture; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: vicboma 11 | * Date: 26/02/14 12 | * Time: 23:33 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public interface FrameworkContext 16 | { 17 | //Methods channeables 18 | FrameworkContext immediatelyConfigure(FrameworkConfig frameworkConfig) throws Exception; 19 | FrameworkContext queueConfigure(FrameworkConfig frameworkConfig) throws Exception; 20 | FrameworkContext installExtensionAsync(FrameworkExtension frameworkExtension) throws Exception; 21 | FrameworkContext immediatelyInstallExtension(FrameworkExtension frameworkExtension) throws Exception; 22 | 23 | CompletableFuture executeCompletableAsync(Callable callable) throws Exception; //then(....) 24 | FrameworkContext executeQueueAsync(Callable callable) throws Exception; 25 | 26 | CompletableFuture executeCompletableAsync(Runnable runnable) throws Exception; //then(....) 27 | FrameworkContext executeQueueAsync(Runnable runnable) throws Exception; 28 | 29 | Injector injector(); 30 | FrameworkContext persistenConfiguration(); 31 | FrameworkContext endConfiguration(Boolean state); 32 | } 33 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/context/api/FrameworkExtension.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.context.api; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: vicboma 8 | * Date: 26/02/14 9 | * Time: 23:44 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public interface FrameworkExtension 13 | { 14 | CompletableFuture installExtensionAsync() throws Exception; 15 | } 16 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/factory/buffer/FactoryBuffer.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.factory.buffer; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /** 6 | * Created by vicboma on 15/09/15. 7 | */ 8 | public interface FactoryBuffer { 9 | Byte read(int addres); 10 | ByteBuffer write(int addres, byte data); 11 | } 12 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/factory/buffer/FactoryBufferImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.factory.buffer; 2 | 3 | import framework.factory.collection.FactoryCollection; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | /** 8 | * Created by vicboma on 10/07/15. 9 | */ 10 | public class FactoryBufferImpl implements FactoryBuffer { 11 | private ByteBuffer data; 12 | 13 | public static FactoryCollection Create(ByteBuffer byteBuffer){ 14 | return (FactoryCollection) new FactoryBufferImpl(byteBuffer); 15 | } 16 | 17 | public static ByteBuffer initialize(final int size){ 18 | final ByteBuffer byteBuffer = ByteBuffer.allocate(size); 19 | return byteBuffer; 20 | } 21 | 22 | public FactoryBufferImpl(ByteBuffer _data) { 23 | this.data = _data; 24 | } 25 | 26 | @Override 27 | public Byte read(int addres){ 28 | return this.data.get(addres); 29 | } 30 | 31 | @Override 32 | public ByteBuffer write(int addres, byte data) { 33 | final ByteBuffer put = this.data.put(addres, data); 34 | return put; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/factory/collection/FactoryCollection.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.factory.collection; 2 | 3 | /** 4 | * Created by vicboma on 10/09/15. 5 | */ 6 | public interface FactoryCollection { 7 | T read(int addres); 8 | 9 | T write(int addres, T data); 10 | } 11 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/factory/collection/FactoryCollectionImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.factory.collection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.IntStream; 6 | 7 | /** 8 | * Created by vicboma on 10/09/15. 9 | */ 10 | public class FactoryCollectionImpl implements FactoryCollection { 11 | private List data; 12 | 13 | public static FactoryCollection Create(List list){ 14 | return (FactoryCollection) new FactoryCollectionImpl(list); 15 | } 16 | 17 | public static List initialize(final int size, final T defautl){ 18 | final List list = new ArrayList(size); 19 | IntStream.range(0,size).boxed().forEach(x -> list.add(x, defautl)); 20 | return list; 21 | } 22 | 23 | public FactoryCollectionImpl() { 24 | } 25 | 26 | public FactoryCollectionImpl(List _data) { 27 | this.data = _data; 28 | } 29 | 30 | @Override 31 | public T read(int addres){ 32 | return this.data.get(addres); 33 | } 34 | 35 | @Override 36 | public T write(int addres, T data) { 37 | return this.data.set(addres,data); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/Injector.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: vicboma 6 | * Date: 14/05/14 7 | * Time: 20:03 8 | */ 9 | public interface Injector 10 | { 11 | String POST_CONSTRUCTOR = "PostConstruct"; 12 | String PRE_DESTROY = "PreDestroy"; 13 | 14 | T getInstance(Class _class); 15 | 16 | void destroy() throws Exception; 17 | 18 | void injectInto(Object instance) throws Exception ; 19 | 20 | void mapValue(Class _class, T instance); 21 | 22 | void mapSingleton(Class _classFrom, Class _classTo); 23 | 24 | void mapLocal(Class _classFrom, Class _classTo); 25 | 26 | Injector unmap(Class _class) ; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/annotation/Inject.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: vicboma 11 | * Date: 14/05/14 12 | * Time: 14:38 13 | */ 14 | @Target(ElementType.FIELD) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface Inject { 17 | } 18 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/annotation/instance/Prototype.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.annotation.instance; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: vicboma 12 | * Date: 14/02/14 13 | * Time: 18:36 14 | */ 15 | @Target(TYPE) 16 | @Retention(RUNTIME) 17 | public @interface Prototype { 18 | String name(); 19 | } 20 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/annotation/instance/Singleton.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.annotation.instance; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: vicboma 12 | * Date: 14/02/14 13 | * Time: 18:38 14 | */ 15 | @Target(TYPE) 16 | @Retention(RUNTIME) 17 | public @interface Singleton { 18 | String name(); 19 | } 20 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/annotation/instance/Value.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.annotation.instance; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: vicboma 12 | * Date: 14/02/14 13 | * Time: 18:35 14 | */ 15 | @Target(TYPE) 16 | @Retention(RUNTIME) 17 | public @interface Value { 18 | String name(); 19 | } 20 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/annotation/method/PostConstruct.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.annotation.method; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: vicboma 11 | * Date: 14/05/14 12 | * Time: 14:33 13 | */ 14 | @Target(ElementType.METHOD) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface PostConstruct { 17 | } 18 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/annotation/method/PreDestroy.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.annotation.method; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: vicboma 11 | * Date: 14/05/14 12 | * Time: 14:33 13 | */ 14 | @Target(ElementType.METHOD) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface PreDestroy { 17 | } 18 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/type/InjectorFactory.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.type; 2 | 3 | /** 4 | * Created by vicboma on 28/09/15. 5 | */ 6 | public interface InjectorFactory { 7 | Object createInstance(Class _class) throws Exception; 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/injector/api/type/Instance.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.injector.api.type; 2 | 3 | import framework.injector.src.state.StoreLocation; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: vicboma 8 | * Date: 14/05/14 9 | * Time: 19:43 10 | */ 11 | public interface Instance { 12 | Object getInstance(InjectorFactory factory) throws Exception; 13 | StoreLocation getStoreLocation(); 14 | } 15 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/logger/api/Logger.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.logger.api; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: vicboma 6 | * Date: 11/03/14 7 | * Time: 22:28 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public interface Logger { 11 | void info(E clazz, String log); 12 | void info(E clazz); 13 | void info(E clazz, String log, Throwable throwable); 14 | void debug(E clazz, String log); 15 | void debug(E clazz, String log, Throwable throwable); 16 | void error(E clazz, String log); 17 | void error(E clazz, String log, Throwable throwable); 18 | } 19 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/logger/src/LoggerImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.logger.src; 2 | 3 | import framework.injector.api.type.Injector; 4 | import framework.logger.api.Logger; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: vicboma 9 | * Date: 11/03/14 10 | * Time: 22:24 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class LoggerImpl implements Logger 14 | { 15 | public static Logger create() 16 | { 17 | return new LoggerImpl(); 18 | } 19 | 20 | LoggerImpl() { info(this);} 21 | 22 | public void info(E clazz, String log) 23 | { 24 | org.apache.log4j.Logger.getLogger(clazz.getClass()).info(log); 25 | } 26 | 27 | public void info(E clazz) 28 | { 29 | final Class aClass = clazz.getClass(); 30 | org.apache.log4j.Logger.getLogger(aClass).info(Injector.POST_CONSTRUCTOR+" "+aClass.getName()); 31 | } 32 | 33 | public void info(E clazz, String log, Throwable throwable) 34 | { 35 | org.apache.log4j.Logger.getLogger(clazz.getClass()).info(log, throwable); 36 | } 37 | 38 | public void debug(E clazz, String log) 39 | { 40 | org.apache.log4j.Logger.getLogger(clazz.getClass()).debug(log); 41 | } 42 | 43 | public void debug(E clazz, String log, Throwable throwable) 44 | { 45 | org.apache.log4j.Logger.getLogger(clazz.getClass()).debug(log, throwable); 46 | } 47 | 48 | public void error(E clazz, String log) 49 | { 50 | org.apache.log4j.Logger.getLogger(clazz.getClass()).error(log); 51 | } 52 | 53 | public void error(E clazz, String log, Throwable throwable) 54 | { 55 | org.apache.log4j.Logger.getLogger(clazz.getClass()).error(log, throwable); 56 | } 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/pattern/action/ActionFrameworkContext.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.pattern.action; 2 | 3 | import framework.context.api.FrameworkContext; 4 | 5 | /** 6 | * Created by vicboma on 05/10/15. 7 | */ 8 | public interface ActionFrameworkContext { 9 | void execute(FrameworkContext frameworkContext); 10 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/framework/pattern/action/ActionInjector.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.pattern.action; 2 | 3 | import framework.injector.api.type.Injector; 4 | 5 | /** 6 | * Created by vicboma on 05/10/15. 7 | */ 8 | public interface ActionInjector { 9 | void execute(Injector injector); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/graphic/GameboyPalette.java: -------------------------------------------------------------------------------- 1 | package emulator.graphic; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by vicboma on 30/08/15. 7 | */ 8 | public interface GameboyPalette { 9 | 10 | void setARGBColours(List listARGBColor); 11 | int getARGBColour(int valueRGB); 12 | void createPalette(int keyARGB); 13 | } 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/graphic/fps/FPS.java: -------------------------------------------------------------------------------- 1 | package emulator.graphic.fps; 2 | 3 | /** 4 | * Created by vicboma on 02/09/15. 5 | */ 6 | public interface FPS { 7 | FPS calculate(); 8 | void start(); 9 | Boolean count(); 10 | Boolean validate(); 11 | 12 | Integer get(); 13 | Integer waitTime() ; 14 | void setDone(boolean done); 15 | Boolean done(); 16 | int skip(); 17 | void setSkip(int skip); 18 | } 19 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/graphic/palette/DMGPalette.java: -------------------------------------------------------------------------------- 1 | package emulator.graphic.palette; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by vicboma on 30/08/15. 7 | */ 8 | public interface DMGPalette { 9 | 10 | void setARGBColours(List listARGBColor); 11 | int getARGBColour(int valueRGB); 12 | void create(int keyARGB); 13 | } 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/graphic/palette/shader/PaletteVideo.java: -------------------------------------------------------------------------------- 1 | package emulator.graphic.palette.shader; 2 | 3 | import java.awt.*; 4 | 5 | /** 6 | * Created by vicboma on 22/08/15. 7 | */ 8 | public interface PaletteVideo { 9 | int palette1Rgb(); 10 | int palette2Rgb(); 11 | int palette3Rgb(); 12 | int palette4Rgb(); 13 | 14 | Color bezel(); 15 | } 16 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/graphic/palette/shader/PaletteVideoImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.graphic.palette.shader; 2 | 3 | import java.awt.*; 4 | 5 | /** 6 | * Created by vicboma on 22/08/15. 7 | */ 8 | public class PaletteVideoImpl implements PaletteVideo { 9 | 10 | protected Color p1; 11 | protected Color p2; 12 | protected Color p3; 13 | protected Color p4; 14 | protected Color bezel; 15 | 16 | public PaletteVideoImpl(Color p1, Color p2, Color p3, Color p4, Color bezel) { 17 | this.p1 = p1; 18 | this.p2 = p2; 19 | this.p3 = p3; 20 | this.p4 = p4; 21 | this.bezel = bezel; 22 | } 23 | 24 | @Override 25 | public int palette1Rgb() { return this.p1.getRGB();} 26 | @Override 27 | public int palette2Rgb() { return this.p2.getRGB();} 28 | @Override 29 | public int palette3Rgb() { return this.p3.getRGB();} 30 | @Override 31 | public int palette4Rgb() { return this.p4.getRGB();} 32 | @Override 33 | public Color bezel() { return this.bezel; } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/graphic/stat/StatVideo.java: -------------------------------------------------------------------------------- 1 | package emulator.graphic.stat; 2 | 3 | /** 4 | * Created by vicboma on 06/09/15. 5 | */ 6 | public interface StatVideo { 7 | boolean isStatLyc(); 8 | 9 | void setStatLyc(boolean statLyc); 10 | 11 | boolean isStatOam(); 12 | 13 | void setStatOam(boolean statOam); 14 | 15 | boolean isStatHblank(); 16 | 17 | void setStatHblank(boolean statHblank); 18 | 19 | boolean isStatVblank(); 20 | 21 | void setStatVblank(boolean statVblank); 22 | 23 | byte getStatMode(); 24 | 25 | void setStatMode(byte statMode); 26 | } 27 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/main/GameBoy.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import main.configuration.*; 4 | import org.apache.log4j.BasicConfigurator; 5 | 6 | /** 7 | * Created by vicboma on 03/06/14. 8 | */ 9 | public class GameBoy { 10 | 11 | public static final String VICBOMA_GAME_BOY_EMULATOR_V1 = "Vicboma - Game Boy Emulator v"; 12 | public static String VERSION = "0.32.0 Debug"; 13 | public static final String C_2014_VICTOR_MANUEL_BOLINCHES_MARIN = " (c) 2014 Victor Manuel Bolinches Marin"; 14 | public static Boolean DEBUG = true; 15 | 16 | /** 17 | * Main 18 | * @param args 19 | * @throws Exception 20 | */ 21 | public static void main(String args[]) throws Exception { 22 | //Logger 4 java 23 | BasicConfigurator.configure(); 24 | //Emulator Gameboy 25 | EmulatorConfigurator.configure(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/main/loop/ExecuteOption.java: -------------------------------------------------------------------------------- 1 | package emulator.main.loop; 2 | 3 | import framework.injector.api.Injector; 4 | 5 | import java.util.concurrent.ExecutionException; 6 | 7 | /** 8 | * Created by vicboma on 29/09/15. 9 | */ 10 | public interface ExecuteOption { 11 | void execute(Injector injector) throws ExecutionException, InterruptedException; 12 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/main/loop/LoopCore.java: -------------------------------------------------------------------------------- 1 | package emulator.main.loop; 2 | 3 | /** 4 | * Created by vicboma on 29/09/15. 5 | */ 6 | public interface LoopCore { 7 | void executeAsync(); 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/main/loop/MainLoopCore.java: -------------------------------------------------------------------------------- 1 | package emulator.main.loop; 2 | 3 | /** 4 | * Created by vicboma on 29/09/15. 5 | */ 6 | public interface MainLoopCore { 7 | MainLoopCore queue(String option); 8 | void selectableOption(); 9 | } 10 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/pattern/diposable/Disposable.java: -------------------------------------------------------------------------------- 1 | package emulator.pattern.diposable; 2 | 3 | /** 4 | * Created by vicboma on 15/08/15. 5 | */ 6 | public interface Disposable { 7 | void dispose(); 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/pattern/reseteable/Reseteable.java: -------------------------------------------------------------------------------- 1 | package emulator.pattern.reseteable; 2 | 3 | /** 4 | * Created by vicboma on 08/09/15. 5 | */ 6 | public interface Reseteable { 7 | void reset(); 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/pattern/updateble/Updatable.java: -------------------------------------------------------------------------------- 1 | package emulator.pattern.updateble; 2 | 3 | import java.awt.*; 4 | import java.util.concurrent.ExecutionException; 5 | 6 | /** 7 | * Created by vicboma on 06/09/15. 8 | */ 9 | public interface Updatable { 10 | boolean update(Graphics g, int startX, int startY) throws ExecutionException, InterruptedException; 11 | } 12 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/specification/sound/Channel.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.sound; 2 | 3 | /** 4 | * Created by vicboma on 07/05/14. 5 | */ 6 | public interface Channel { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/specification/sound/ch1_2/QuadrangularWaveForm.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.sound.ch1_2; 2 | 3 | 4 | import emulator.specification.sound.Channel; 5 | 6 | /** 7 | * Created by vicboma on 07/05/14. 8 | */ 9 | public class QuadrangularWaveForm implements Channel { 10 | 11 | public static final int sound1 = 0; 12 | public static final int sound2 = 1; 13 | 14 | 15 | ... 16 | } 17 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/specification/sound/ch3/ArbitraryWaveForm.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.sound.ch3; 2 | 3 | import emulator.specification.sound.Channel; 4 | 5 | 6 | /** 7 | * Created by vicboma on 07/05/14. 8 | */ 9 | public class ArbitraryWaveForm implements Channel { 10 | 11 | public static final int sound3 = 2; 12 | 13 | ... 14 | } 15 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/specification/sound/ch4/WhiteNoise.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.sound.ch4; 2 | 3 | import emulator.specification.sound.Channel; 4 | 5 | /** 6 | * Created by vicboma on 07/05/14.. 7 | */ 8 | public class WhiteNoise implements Channel { 9 | 10 | public static final int sound4 = 3; 11 | 12 | 13 | ... 14 | 15 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/file/ToolBarFile.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.file; 2 | 3 | import toolBar.ToolBarMenu; 4 | 5 | import java.awt.*; 6 | import java.awt.event.ActionListener; 7 | import java.awt.event.ItemListener; 8 | 9 | /** 10 | * Created by vicboma on 23/08/15. 11 | */ 12 | public interface ToolBarFile extends ActionListener, ItemListener, ToolBarMenu { 13 | MenuItem getFileEmulate(); 14 | MenuItem getFileReset(); 15 | MenuItem getFilePause(); 16 | } 17 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/file/action/ToolBarFileAction.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.file.action; 2 | 3 | import framework.injector.api.type.Injector; 4 | 5 | /** 6 | * Created by vicboma on 30/09/15. 7 | */ 8 | public interface ToolBarFileAction { 9 | void execute(Injector injector); 10 | } 11 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/file/action/ToolBarFileItemAction.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.file.action; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by vicboma on 30/09/15. 7 | */ 8 | public interface ToolBarFileItemAction { 9 | Map load(); 10 | } 11 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/file/item/ToolBarFileItemMenu.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.file.item; 2 | 3 | import toolBar.file.ToolBarFile; 4 | 5 | import java.awt.*; 6 | 7 | /** 8 | * Created by vicboma on 30/09/15. 9 | */ 10 | public interface ToolBarFileItemMenu { 11 | java.util.List load(ToolBarFile toolBarFile); 12 | } 13 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/others/ToolBarOthers.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.others; 2 | 3 | import toolBar.ToolBarMenu; 4 | 5 | import java.awt.*; 6 | import java.awt.event.ActionListener; 7 | import java.awt.event.ItemListener; 8 | 9 | /** 10 | * Created by vicboma on 31/08/15. 11 | */ 12 | public interface ToolBarOthers extends ItemListener, ToolBarMenu, ActionListener { 13 | CheckboxMenuItem getOthersConsole(); 14 | CheckboxMenuItem getItemDisassembler(int index); 15 | } 16 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/others/action/ToolBarOthersItemAction.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.others.action; 2 | 3 | import framework.pattern.action.ActionInjector; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by vicboma on 05/10/15. 9 | */ 10 | public interface ToolBarOthersItemAction { 11 | Map load(); 12 | } 13 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/toolBar/others/item/ToolBarOthersItemMenu.java: -------------------------------------------------------------------------------- 1 | package emulator.toolBar.others.item; 2 | 3 | import toolBar.others.ToolBarOthers; 4 | 5 | import java.awt.*; 6 | 7 | /** 8 | * Created by vicboma on 05/10/15. 9 | */ 10 | public interface ToolBarOthersItemMenu { 11 | java.util.List loadMenu(ToolBarOthers toolBarOthers); 12 | java.util.List loadDisassembler(ToolBarOthers toolBarOthers); 13 | } 14 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/CheckSum.java: -------------------------------------------------------------------------------- 1 | package emulator.utils; 2 | 3 | /** 4 | * Created by vicboma on 08/08/14. 5 | */ 6 | public class CheckSum { 7 | 8 | public final static int HI = 0x14E; 9 | public final static int LO = 0x14F; 10 | public static final int DESP = 8; 11 | public static final int MASK = 0x0000FFFF; 12 | 13 | public static boolean validate(byte [] rom ){ 14 | 15 | int checkSum = (Operation.unsign(rom[HI]) << DESP) + Operation.unsign(rom[LO]); 16 | 17 | int sumTotal = 0; 18 | final int length = rom.length; 19 | for (int r = 0; r < length; r++) { 20 | if ((r != HI) && (r != LO)) { 21 | sumTotal = (sumTotal + Operation.unsign(rom[r])) & MASK; 22 | } 23 | } 24 | 25 | return (checkSum == sumTotal); 26 | 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/Operation.java: -------------------------------------------------------------------------------- 1 | package emulator.utils; 2 | 3 | /** 4 | * Created by vicboma on 10/09/14. 5 | */ 6 | public class Operation { 7 | 8 | /** 9 | * 16-bits to signed 8-bit 10 | */ 11 | public static Short unsign(Short b) { 12 | return _unsign(b); 13 | } 14 | 15 | /** 16 | * signed 8-bit 17 | */ 18 | public static Short unsign(Byte b) { 19 | return _unsign(b); 20 | } 21 | 22 | private static Short _unsign(short b) { 23 | final short result = (b >= 0) ? b : (short) (0x100 + b); 24 | return result; 25 | 26 | } 27 | 28 | public static final String hexChars = "0123456789ABCDEF"; 29 | 30 | /** 31 | * string of an 8-bits in hx for Debug 32 | */ 33 | public static String hexByte(int value) { 34 | final char shiftL = hexChars.charAt(value >> 4); 35 | final char mask = hexChars.charAt(value & 0x0F); 36 | String s = new Character(shiftL).toString(); 37 | s += new Character(mask).toString(); 38 | 39 | return s; 40 | } 41 | 42 | /** 43 | * string of an 16-bit in hx for Debug 44 | */ 45 | public static String hexShort(Integer value) { 46 | String high = hexByte((value & 0x0000FF00) >> 8); 47 | String low = hexByte(value & 0x000000FF); 48 | return new String(high + low); 49 | } 50 | 51 | public static int mergeTo16bits(short big, short little) { 52 | return ((big << 8) | little); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/executor/ExecutorPoolException.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.executor; 2 | 3 | /** 4 | * Created by vicboma on 02/09/15. 5 | */ 6 | public class ExecutorPoolException extends Exception { 7 | public ExecutorPoolException() { super(); } 8 | public ExecutorPoolException(String message) { super(message); } 9 | public ExecutorPoolException(String message, Throwable cause) { super(message, cause); } 10 | public ExecutorPoolException(Throwable cause) { super(cause); } 11 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/executor/ThreadPoolPriorityQueueAsync.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.executor; 2 | 3 | import java.util.concurrent.Callable; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.concurrent.Executor; 6 | import java.util.function.Supplier; 7 | 8 | /** 9 | * Created by vicboma on 03/09/15. 10 | */ 11 | public interface ThreadPoolPriorityQueueAsync { 12 | CompletableFuture addCallableAsync(Callable callable); 13 | 14 | CompletableFuture addRunnableAsync(Runnable runnableFuture); 15 | 16 | CompletableFuture addSupplier(Supplier supplier); 17 | 18 | Executor executor(); 19 | 20 | Integer size(); 21 | } 22 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/executor/deferred/DeferredAsync.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.executor.deferred; 2 | 3 | import java.util.concurrent.Callable; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Created by vicboma on 03/09/15. 8 | */ 9 | public interface DeferredAsync { 10 | 11 | CompletableFuture getCompletableFuture(); 12 | Callable getCallable(); 13 | Runnable getRunnable(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/executor/deferred/DeferredAsyncImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.executor.deferred; 2 | 3 | import java.util.concurrent.Callable; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Created by vicboma on 03/09/15. 8 | */ 9 | public class DeferredAsyncImpl implements DeferredAsync { 10 | 11 | private CompletableFuture completableFuture; 12 | private Callable callable; 13 | private Runnable runnableFuture; 14 | 15 | public DeferredAsyncImpl(Callable callable) { 16 | this.completableFuture = new CompletableFuture(); 17 | this.callable = callable; 18 | } 19 | 20 | public DeferredAsyncImpl(Runnable runnableFuture) { 21 | this.completableFuture = new CompletableFuture(); 22 | this.runnableFuture = runnableFuture; 23 | } 24 | 25 | public CompletableFuture getCompletableFuture() { 26 | return completableFuture; 27 | } 28 | 29 | public Callable getCallable() { 30 | return callable; 31 | } 32 | public Runnable getRunnable() { 33 | return runnableFuture; } 34 | } 35 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/executor/execute/CoreExecute.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.executor.execute; 2 | 3 | import java.util.concurrent.Callable; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.function.Supplier; 6 | 7 | /** 8 | * Created by vicboma on 03/09/15. 9 | */ 10 | public interface CoreExecute { 11 | CompletableFuture addCallableAsync(Callable Callable); 12 | 13 | CompletableFuture addRunnableAsync(Runnable addRunnableAsync); 14 | 15 | CompletableFuture addSupplier(Supplier supplier); 16 | 17 | Integer size(); 18 | } 19 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/mainLoop/MainLoopUtils.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.mainLoop; 2 | 3 | import framework.injector.api.type.Injector; 4 | 5 | /** 6 | * Created by vicboma on 30/09/15. 7 | */ 8 | public interface MainLoopUtils { 9 | void addOptionAsync(Injector injector, String opc); 10 | } 11 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/mainLoop/MainLoopUtilsImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.mainLoop; 2 | 3 | import framework.injector.api.annotation.Inject; 4 | import framework.injector.api.annotation.method.PostConstruct; 5 | import framework.injector.api.type.Injector; 6 | import framework.logger.api.Logger; 7 | import main.loop.MainLoopCore; 8 | 9 | /** 10 | * Created by vicboma on 30/09/15. 11 | */ 12 | public class MainLoopUtilsImpl implements MainLoopUtils { 13 | 14 | @Inject 15 | public Logger logger; 16 | 17 | public MainLoopUtilsImpl() { 18 | } 19 | 20 | @PostConstruct 21 | public void initialize(){ 22 | logger.info(this); 23 | } 24 | 25 | @Override 26 | public void addOptionAsync(Injector injector, String opc){ 27 | synchronized (this){ 28 | optionAsync(injector,opc); 29 | } 30 | 31 | } 32 | private void optionAsync(Injector injector, String openRom) { 33 | final MainLoopCore mainLoopCoreImpl = getInstanceMainLoopCore(injector); 34 | mainLoopCoreImpl.queue(openRom); 35 | } 36 | 37 | private MainLoopCore getInstanceMainLoopCore(Injector injector) { 38 | return injector.getInstance(MainLoopCore.class); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/shell/ConsoleWindowsListener.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.shell; 2 | 3 | import java.awt.*; 4 | import java.awt.event.WindowEvent; 5 | import java.awt.event.WindowListener; 6 | 7 | /** 8 | * Created by vicboma on 31/08/15. 9 | */ 10 | public class ConsoleWindowsListener implements WindowListener { 11 | 12 | private Dialog dialog; 13 | public static ConsoleWindowsListener Create(Dialog dialog){ 14 | return new ConsoleWindowsListener(dialog); 15 | } 16 | 17 | ConsoleWindowsListener(Dialog dialog) { 18 | this.dialog = dialog; 19 | this.dialog.addWindowListener(this); 20 | } 21 | 22 | @Override 23 | public void windowOpened(WindowEvent e) { 24 | 25 | } 26 | 27 | @Override 28 | public void windowClosing(WindowEvent e) { 29 | dialog.setVisible(false); 30 | } 31 | 32 | @Override 33 | public void windowClosed(WindowEvent e) { 34 | 35 | } 36 | 37 | @Override 38 | public void windowIconified(WindowEvent e) { 39 | 40 | } 41 | 42 | @Override 43 | public void windowDeiconified(WindowEvent e) { 44 | 45 | } 46 | 47 | @Override 48 | public void windowActivated(WindowEvent e) { 49 | 50 | } 51 | 52 | @Override 53 | public void windowDeactivated(WindowEvent e) { 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/shell/Logger.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.shell; 2 | 3 | import utils.shell.pool.LoggerPoolAsyncImpl; 4 | 5 | import java.awt.*; 6 | 7 | /** 8 | * Created by vicboma on 02/01/15. 9 | */ 10 | public class Logger { 11 | 12 | private static Console console; 13 | public static final String LUCIDA_CONSOLE = "Lucida Console"; 14 | public static final String QUEUE_TASK = " Queue task : "; 15 | 16 | public static void Console(Dialog dialog, LoggerPoolAsyncImpl loggerPoolAsync){ 17 | console = new Console(dialog,loggerPoolAsync); 18 | } 19 | 20 | // basic println 21 | static public void Debug(String s) { 22 | console.println("Debug: " + s); 23 | } 24 | 25 | static public void DebugValidate(String s) { 26 | console.printValidateln("Debug: " + s); 27 | } 28 | 29 | static public void DebugToolBar(String s) { 30 | console.printToolBarln("Debug: " + s); 31 | } 32 | 33 | 34 | //uncontrollable 35 | static public void Error(String s) { 36 | console.printErrorln("Error: " + s); 37 | } 38 | 39 | // error controllable 40 | static public void Warning(String s) { 41 | console.printWarningln("Warning: " + s); 42 | } 43 | 44 | static public void WarningInLine(String s) { 45 | console.printWarning(s); 46 | } 47 | 48 | 49 | static public void DebugInLine(String s) { 50 | console.println(s); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/shell/pool/LoggerPoolMessage.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.shell.pool; 2 | 3 | import utils.shell.pool.message.LoggerMessage; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | /** 9 | * Created by vicboma on 31/08/15. 10 | */ 11 | public interface LoggerPoolMessage { 12 | void runAsync(JTextPane println, String msn, Color color, Label label); 13 | LoggerPoolMessage add(LoggerMessage loggerMessage); 14 | int size(); 15 | } 16 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/shell/pool/message/LoggerMessage.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.shell.pool.message; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | /** 7 | * Created by vicboma on 31/08/15. 8 | */ 9 | public interface LoggerMessage { 10 | Label getLabel(); 11 | JTextPane getPrintln(); 12 | String getMsn(); 13 | Color getColor(); 14 | } 15 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/shell/pool/message/LoggerMessageImpl.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.shell.pool.message; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | /** 7 | * Created by vicboma on 31/08/15. 8 | */ 9 | public class LoggerMessageImpl implements LoggerMessage { 10 | private JTextPane println; 11 | private String msn; 12 | private Color color; 13 | private Label l; 14 | 15 | public LoggerMessageImpl(JTextPane println, String msn, Color color, Label l) { 16 | this.println = println; 17 | this.msn = msn; 18 | this.color = color; 19 | this.l = l; 20 | 21 | } 22 | 23 | @Override 24 | public Label getLabel() { 25 | return l; 26 | } 27 | 28 | @Override 29 | public JTextPane getPrintln() { 30 | return println; 31 | } 32 | 33 | @Override 34 | public String getMsn() { 35 | return msn; 36 | } 37 | 38 | @Override 39 | public Color getColor() { 40 | return color; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/shell/pool/utils/WorkerThreadFactory.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.shell.pool.utils; 2 | 3 | import java.util.concurrent.ThreadFactory; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | /** 7 | * Created by vicboma on 31/08/15. 8 | * Pattern Thread Factory 9 | */ 10 | public class WorkerThreadFactory implements ThreadFactory { 11 | 12 | public static final String SEPARATOR = " - "; 13 | private AtomicInteger counter; 14 | private String prefix = ""; 15 | 16 | public static WorkerThreadFactory Create(String prefix){ 17 | return new WorkerThreadFactory(prefix); 18 | } 19 | 20 | WorkerThreadFactory(String prefix) { 21 | this.prefix = prefix; 22 | this.counter = new AtomicInteger(0); 23 | } 24 | 25 | public Thread newThread(Runnable runnable) { 26 | final int counter = this.counter.incrementAndGet(); 27 | return new Thread(runnable, prefix + SEPARATOR + counter); 28 | } 29 | 30 | public String toString() { 31 | final StringBuilder sb = new StringBuilder() 32 | .append(prefix) 33 | .append(SEPARATOR) 34 | .append(counter.intValue()); 35 | 36 | return sb.toString(); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /gameboyclassic/src/emulator/utils/toolBar/ToolBarUtils.java: -------------------------------------------------------------------------------- 1 | package emulator.utils.toolBar; 2 | 3 | import framework.injector.api.type.Injector; 4 | import framework.pattern.action.ActionInjector; 5 | import toolBar.others.action.ToolBarOthersItemActionImpl; 6 | 7 | import java.awt.*; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * Created by vicboma on 30/09/15. 13 | */ 14 | public interface ToolBarUtils { 15 | Menu createMenu(String menuName, List menuItemList); 16 | Menu addSubMenu(Menu menu, List menuItemList); 17 | void logError(String command, String message); 18 | Boolean commander(String command, Map map, String message); 19 | void addOptionAsync(Injector injector, String openRom); 20 | ToolBarOthersItemActionImpl getToolBarOthersItemActionImpl(Injector injector); 21 | } 22 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cartridge/memory/bankController/MBC1ImplTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cartridge.memory.bankController; 2 | 3 | import junit.framework.TestCase; 4 | 5 | import static org.mockito.Mockito.*; 6 | 7 | public class MBC1ImplTest extends TestCase { 8 | 9 | private MBC1 mbc1; 10 | 11 | public void setUp() throws Exception { 12 | super.setUp(); 13 | mbc1 = MBC1Impl.Create(); 14 | } 15 | 16 | public void tearDown() throws Exception { 17 | mbc1 = null; 18 | } 19 | 20 | public void testIsModeEnabled() throws Exception { 21 | final boolean modeEnabled = mbc1.isModeEnabled(); 22 | assertTrue("Not same testIsModeEnabled", modeEnabled); 23 | } 24 | 25 | public void testSetModeEnabled() throws Exception { 26 | final MBC1 mbc1Mock = mock(MBC1.class); 27 | mbc1Mock.setModeEnabled(false); 28 | verify(mbc1Mock).setModeEnabled(false); 29 | } 30 | 31 | public void testIsRamEnabled() throws Exception { 32 | final boolean ramEnabled = mbc1.isRamEnabled(); 33 | assertFalse("Not same testIsModeEnabled", ramEnabled); 34 | 35 | } 36 | 37 | public void testSetRamEnabled() throws Exception { 38 | final MBC1 mbc1Spy = spy(mbc1); 39 | mbc1Spy.setRamEnabled(true); 40 | verify(mbc1Spy).setRamEnabled(true); 41 | } 42 | 43 | public void testDispose() throws Exception { 44 | final MBC1 mbc1Spy = spy(mbc1); 45 | mbc1Spy.dispose(); 46 | verify(mbc1Spy).dispose(); 47 | } 48 | 49 | public void testReset() throws Exception { 50 | final MBC1 mbc1Spy = spy(mbc1); 51 | mbc1Spy.reset(); 52 | verify(mbc1Spy).reset(); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/add/ADD_HL_BCTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.add; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | public class ADD_HL_BCTest extends TestCase { 9 | 10 | private ADD_HL_BC add_hl_bc; 11 | private Z80Impl z80; 12 | 13 | public void setUp() throws Exception { 14 | super.setUp(); 15 | z80 = mock(Z80Impl.class); 16 | add_hl_bc = new ADD_HL_BC(z80); 17 | } 18 | 19 | public void tearDown() throws Exception { 20 | add_hl_bc = null; 21 | } 22 | 23 | public void testRunAsync() throws Exception { 24 | z80.pc = 35440; 25 | z80.b = 51; 26 | z80.c = 30; 27 | 28 | z80.hl = 210; 29 | z80.f = 15; 30 | 31 | z80.cycles = 0; 32 | 33 | add_hl_bc.execute(0,0,0,0); 34 | 35 | assertTrue("Not same b", z80.b == 51); 36 | assertTrue("Not same c",z80.c == 30 ); 37 | assertTrue("Not same pc",z80.pc == 35441); 38 | assertTrue("Not same hl", z80.hl == 13296); 39 | assertTrue("Not same f", z80.f == 0); 40 | assertTrue("Not same cycles",z80.cycles == 8); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/add/ADD_HL_DETest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.add; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 21/09/15. 10 | */ 11 | public class ADD_HL_DETest extends TestCase { 12 | private ADD_HL_DE add_hl_de; 13 | private Z80Impl z80; 14 | 15 | public void setUp() throws Exception { 16 | super.setUp(); 17 | z80 = mock(Z80Impl.class); 18 | 19 | add_hl_de = new ADD_HL_DE(new ADD_HL_nn(z80)); 20 | } 21 | 22 | public void tearDown() throws Exception { 23 | add_hl_de = null; 24 | } 25 | 26 | public void testRunAsync() throws Exception { 27 | z80.d = 16; 28 | z80.e = 44; 29 | z80.hl = 210; 30 | z80.f = 15; 31 | 32 | add_hl_de.execute(0,0,0,0); 33 | 34 | assertTrue("Not same d", z80.d == 16); 35 | assertTrue("Not same e",z80.e == 44 ); 36 | assertTrue("Not same pc",z80.pc == 1); 37 | assertTrue("Not same hl", z80.hl == 4350); 38 | assertTrue("Not same f", z80.f == 0); 39 | assertTrue("Not same cycles",z80.cycles == 8); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/add/ADD_HL_HLTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.add; 2 | 3 | import cpu.processor.register.flag.Flags; 4 | import cpu.processor.z80.Z80Impl; 5 | import junit.framework.TestCase; 6 | 7 | import static org.mockito.Mockito.mock; 8 | 9 | /** 10 | * Created by vicboma on 20/09/15. 11 | */ 12 | public class ADD_HL_HLTest extends TestCase { 13 | 14 | private Z80Impl z80; 15 | private ADD_HL_HL add_hl_hl; 16 | private ADD_HL_nn add_hl_nn; 17 | 18 | @Override 19 | public void setUp() throws Exception { 20 | super.setUp(); 21 | z80 = mock(Z80Impl.class); 22 | add_hl_nn = new ADD_HL_nn(z80); 23 | add_hl_hl = new ADD_HL_HL(add_hl_nn); 24 | } 25 | 26 | @Override 27 | public void tearDown() throws Exception { 28 | super.tearDown(); 29 | z80= null; 30 | add_hl_hl = null; 31 | add_hl_nn = null; 32 | } 33 | 34 | public void testName() throws Exception { 35 | final int expectedHL = 57374; 36 | z80.hl = 0xf00f; 37 | 38 | add_hl_hl.execute(0,0,0,0); 39 | 40 | assertTrue("not same f", z80.f == Flags.CARRY); 41 | assertTrue("not same hl", z80.hl == expectedHL); 42 | assertTrue("not same pc", z80.pc == 1); 43 | assertTrue("not same cycles", z80.cycles == 8); 44 | 45 | } 46 | 47 | public void testName2() throws Exception { 48 | final int expectedHL = 0; 49 | z80.hl = 0; 50 | 51 | add_hl_hl.execute(0,0,0,0); 52 | 53 | assertTrue("not same f", z80.f == (z80.f & (Flags.SUBTRACT + Flags.ZERO + Flags.HALFCARRY))); 54 | assertTrue("not same hl", z80.hl == expectedHL); 55 | assertTrue("not same pc", z80.pc == 1); 56 | assertTrue("not same cycles", z80.cycles == 8); 57 | 58 | } 59 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/add/ADD_SP_nnTestas.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.add; 2 | 3 | import cpu.processor.register.flag.Flags; 4 | import cpu.processor.z80.Z80Impl; 5 | import junit.framework.TestCase; 6 | 7 | import static org.mockito.Mockito.mock; 8 | 9 | /** 10 | * Created by vicboma on 18/09/15. 11 | */ 12 | public class ADD_SP_nnTestas extends TestCase { 13 | 14 | private Z80Impl z80; 15 | private ADD_SP_nn add_sp_nn; 16 | 17 | @Override 18 | public void setUp() throws Exception { 19 | super.setUp(); 20 | z80 = mock(Z80Impl.class); 21 | add_sp_nn = new ADD_SP_nn(z80); 22 | } 23 | 24 | @Override 25 | public void tearDown() throws Exception { 26 | super.tearDown(); 27 | z80= null; 28 | add_sp_nn = null; 29 | } 30 | 31 | public void testName() throws Exception { 32 | 33 | z80.sp = 0xFFFF; 34 | add_sp_nn.execute(0,0,0,4); 35 | 36 | assertTrue("not same f", z80.f == Flags.CARRY); 37 | assertTrue("not same sp", z80.sp == 0x0003); 38 | assertTrue("not same pc", z80.pc == 2); 39 | assertTrue("not same cycles", z80.cycles == 16); 40 | } 41 | 42 | public void testName2() throws Exception { 43 | 44 | z80.sp = 0x0065; 45 | add_sp_nn.execute(0,0,0,4); 46 | 47 | assertTrue("not same f", z80.f == (z80.f & (Flags.SUBTRACT + Flags.ZERO + Flags.HALFCARRY))); 48 | assertTrue("not same sp", z80.sp == 0x0069); 49 | assertTrue("not same pc", z80.pc == 2); 50 | assertTrue("not same cycles", z80.cycles == 16); 51 | } 52 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/dec/DEC_HL_nnTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.dec; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 17/09/15. 10 | */ 11 | public class DEC_HL_nnTest extends TestCase { 12 | 13 | 14 | private DEC_HL_nn dec_hlNn; 15 | private Z80Impl z80; 16 | 17 | @Override 18 | public void setUp() throws Exception { 19 | super.setUp(); 20 | 21 | z80 = mock(Z80Impl.class); 22 | dec_hlNn = new DEC_HL_nn(z80); 23 | } 24 | 25 | @Override 26 | public void tearDown() throws Exception { 27 | super.tearDown(); 28 | dec_hlNn = null; 29 | z80 = null; 30 | } 31 | 32 | public void testExecute() throws Exception { 33 | 34 | z80.hl = 0x0001; 35 | dec_hlNn.execute(0,0,0,0); 36 | 37 | assertTrue("Not same pc", z80.pc == 1); 38 | assertTrue("Not same hl", z80.hl == 0); 39 | assertTrue("Not same cycles", z80.cycles == 8); 40 | 41 | } 42 | 43 | public void testExecute0() throws Exception { 44 | 45 | z80.hl = 0x0000; 46 | dec_hlNn.execute(0,0,0,0); 47 | 48 | assertTrue("Not same pc", z80.pc == 1); 49 | assertTrue("Not same hl", z80.hl == 0xFFFF); 50 | assertTrue("Not same cycles", z80.cycles == 8); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/dec/DEC_SPTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.dec; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 17/09/15. 10 | */ 11 | public class DEC_SPTest extends TestCase { 12 | 13 | private DEC_SP dec_sp; 14 | private Z80Impl z80; 15 | 16 | @Override 17 | public void setUp() throws Exception { 18 | super.setUp(); 19 | 20 | z80 = mock(Z80Impl.class); 21 | final DEC_nn dec_nn = new DEC_nn(); 22 | dec_sp = new DEC_SP(z80, dec_nn); 23 | } 24 | @Override 25 | public void tearDown() throws Exception { 26 | super.tearDown(); 27 | dec_sp = null; 28 | z80 = null; 29 | } 30 | 31 | public void testExecute() throws Exception { 32 | 33 | z80.sp = 0x0001; 34 | 35 | dec_sp.execute(0,0,0,0); 36 | 37 | assertTrue("Not same pc", z80.pc == 1); 38 | assertTrue("Not same d", z80.sp == 0); 39 | assertTrue("Not same cycles", z80.cycles == 8); 40 | 41 | } 42 | 43 | public void testExecute0() throws Exception { 44 | 45 | z80.sp = 0x0000; 46 | 47 | dec_sp.execute(0,0,0,0); 48 | 49 | assertTrue("Not same pc", z80.pc == 1); 50 | assertTrue("Not same d", z80.sp == 0xFFFF); 51 | assertTrue("Not same cycles", z80.cycles == 8); 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/dec/DEC_nnTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.dec; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 18/09/15. 10 | */ 11 | public class DEC_nnTest extends TestCase { 12 | 13 | private DEC_nn dec_nn; 14 | private Z80Impl z80; 15 | 16 | @Override 17 | public void setUp() throws Exception { 18 | super.setUp(); 19 | 20 | z80 = mock(Z80Impl.class); 21 | dec_nn = new DEC_nn(); 22 | } 23 | 24 | @Override 25 | public void tearDown() throws Exception { 26 | super.tearDown(); 27 | dec_nn = null; 28 | z80 = null; 29 | } 30 | 31 | public void testExecute() throws Exception { 32 | 33 | z80.sp = 0x0001; 34 | 35 | dec_nn.execute(z80, z80.sp); 36 | 37 | assertTrue("Not same pc", z80.pc == 1); 38 | assertTrue("Not same d", z80.sp == 0); 39 | assertTrue("Not same cycles", z80.cycles == 8); 40 | 41 | } 42 | 43 | public void testExecute0() throws Exception { 44 | 45 | z80.sp = 0x0000; 46 | dec_nn.execute(z80, z80.sp); 47 | 48 | assertTrue("Not same pc", z80.pc == 1); 49 | assertTrue("Not same d", z80.sp == 0xFFFF); 50 | assertTrue("Not same cycles", z80.cycles == 8); 51 | 52 | } 53 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/inc/INC_BCTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.inc; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | public class INC_BCTest extends TestCase { 9 | 10 | private Z80Impl z80; 11 | private INC_BC iNC_BC; 12 | 13 | public void setUp() throws Exception { 14 | super.setUp(); 15 | z80 = mock(Z80Impl.class); 16 | iNC_BC = new INC_BC(z80); 17 | } 18 | 19 | public void tearDown() throws Exception { 20 | z80 = null; 21 | } 22 | 23 | public void testInc_BC() throws Exception { 24 | z80.b = 0; 25 | z80.pc = 0; 26 | z80.c = 0; 27 | 28 | iNC_BC.execute(0, 0, 0, 0); 29 | 30 | assertTrue("Not same b",z80.b == 0); 31 | assertTrue("Not same c",z80.c == 1 ); 32 | assertTrue("Not same pc",z80.pc == 1); 33 | assertTrue("Not same cycles",z80.cycles == 8); 34 | } 35 | 36 | public void testInc_BC_OFFSET_C() throws Exception { 37 | z80.b = 0; 38 | z80.pc = 0; 39 | z80.c = INC_BC.OFFSET; 40 | 41 | iNC_BC.execute(0, 0, 0, 0); 42 | 43 | assertTrue("Not same b",z80.b == 1); 44 | assertTrue("Not same c",z80.c == 0 ); 45 | assertTrue("Not same pc",z80.pc == 1); 46 | assertTrue("Not same cycles",z80.cycles == 8); 47 | } 48 | 49 | 50 | public void testInc_BC_OFFSET_B() throws Exception { 51 | z80.b = INC_BC.OFFSET-1; 52 | z80.pc = 0; 53 | z80.c = INC_BC.OFFSET; 54 | 55 | iNC_BC.execute(0, 0, 0, 0); 56 | 57 | assertTrue("Not same b",z80.b == 0); 58 | assertTrue("Not same c",z80.c == 0 ); 59 | assertTrue("Not same pc",z80.pc == 1); 60 | assertTrue("Not same cycles",z80.cycles == 8); 61 | } 62 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/inc/INC_DETest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.inc; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 17/09/15. 10 | */ 11 | public class INC_DETest extends TestCase { 12 | private Z80Impl z80; 13 | private INC_DE iNC_DE; 14 | 15 | public void setUp() throws Exception { 16 | super.setUp(); 17 | z80 = mock(Z80Impl.class); 18 | iNC_DE = new INC_DE(z80); 19 | } 20 | 21 | public void tearDown() throws Exception { 22 | z80 = null; 23 | } 24 | 25 | public void testInc_DE() throws Exception { 26 | z80.d = 0; 27 | z80.pc = 0; 28 | z80.e = 0; 29 | 30 | iNC_DE.execute(0, 0, 0, 0); 31 | 32 | assertTrue("Not same b", z80.d == 0); 33 | assertTrue("Not same c", z80.e == 1); 34 | assertTrue("Not same pc", z80.pc == 1); 35 | assertTrue("Not same cycles", z80.cycles == 8); 36 | } 37 | 38 | public void testInc_DE_OFFSET_E() throws Exception { 39 | z80.d = 0; 40 | z80.pc = 0; 41 | z80.e = INC_BC.OFFSET; 42 | 43 | iNC_DE.execute(0, 0, 0, 0); 44 | 45 | assertTrue("Not same b", z80.d == 1); 46 | assertTrue("Not same c", z80.e == 0); 47 | assertTrue("Not same pc", z80.pc == 1); 48 | assertTrue("Not same cycles", z80.cycles == 8); 49 | } 50 | 51 | 52 | public void testInc_DE_OFFSET_D() throws Exception { 53 | z80.d = INC_BC.OFFSET - 1; 54 | z80.pc = 0; 55 | z80.e = INC_BC.OFFSET; 56 | 57 | iNC_DE.execute(0, 0, 0, 0); 58 | 59 | assertTrue("Not same b", z80.d == 0); 60 | assertTrue("Not same c", z80.e == 0); 61 | assertTrue("Not same pc", z80.pc == 1); 62 | assertTrue("Not same cycles", z80.cycles == 8); 63 | } 64 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/ld/LD_BC_NNTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.ld; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | public class LD_BC_NNTest extends TestCase { 9 | 10 | private Z80Impl z80; 11 | private LD_BC_NN ld_bc_NN; 12 | 13 | public void setUp() throws Exception { 14 | super.setUp(); 15 | z80 = mock(Z80Impl.class); 16 | ld_bc_NN = new LD_BC_NN(z80); 17 | } 18 | 19 | public void tearDown() throws Exception { 20 | z80 = null; 21 | } 22 | 23 | public void testLD_BC_nn() throws Exception { 24 | ld_bc_NN.execute(0, 1, 2, 3); 25 | assertTrue("Not same b",z80.b == 2); 26 | assertTrue("Not same c",z80.c == 1 ); 27 | assertTrue("Not same pc",z80.pc == 3); 28 | assertTrue("Not same cycles",z80.cycles == 12); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/ld/LD_DE_NNTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.ld; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 17/09/15. 10 | */ 11 | public class LD_DE_NNTest extends TestCase { 12 | private Z80Impl z80; 13 | private LD_DE_NN ld_de_NN; 14 | 15 | public void setUp() throws Exception { 16 | super.setUp(); 17 | z80 = mock(Z80Impl.class); 18 | ld_de_NN = new LD_DE_NN(z80); 19 | } 20 | 21 | public void tearDown() throws Exception { 22 | z80 = null; 23 | } 24 | 25 | public void testLD_DE_nn() throws Exception { 26 | ld_de_NN.execute(0, 1, 2, 3); 27 | assertTrue("Not same b", z80.d == 2); 28 | assertTrue("Not same e", z80.e == 1); 29 | assertTrue("Not same pc", z80.pc == 3); 30 | assertTrue("Not same cycles", z80.cycles == 12); 31 | } 32 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits16/ld/LD_NN_SPTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits16.ld; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | import static org.mockito.Mockito.verify; 8 | 9 | public class LD_NN_SPTest extends TestCase { 10 | 11 | private Z80Impl z80; 12 | private LD_NN_SP ld_nn_sp; 13 | 14 | public void setUp() throws Exception { 15 | super.setUp(); 16 | z80 = mock(Z80Impl.class); 17 | ld_nn_sp = mock(LD_NN_SP.class); 18 | } 19 | 20 | public void tearDown() throws Exception { 21 | z80 = null; 22 | } 23 | 24 | public void test() throws Exception { 25 | z80.pc = 3; 26 | z80.cycles = 20; 27 | 28 | ld_nn_sp.execute(0, 0, 0, 0); 29 | verify(ld_nn_sp).execute(0, 0, 0, 0); 30 | 31 | assertTrue("Not same pc",z80.pc == 3); 32 | assertTrue("Not same cycles",z80.cycles == 20F); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/inc/INC_BTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.inc; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | public class INC_BTest extends TestCase { 9 | private Z80Impl z80; 10 | private INC_B iNC_B; 11 | 12 | public void setUp() throws Exception { 13 | super.setUp(); 14 | z80 = mock(Z80Impl.class); 15 | iNC_B = new INC_B(z80); 16 | } 17 | 18 | public void tearDown() throws Exception { 19 | z80 = null; 20 | } 21 | 22 | public void testInc_B() throws Exception { 23 | z80.b = 0; 24 | z80.pc = 0; 25 | z80.f = 0x1110; 26 | 27 | iNC_B.execute(0, 0, 0, 0); 28 | 29 | assertTrue("Not same b",z80.b == 1); 30 | assertTrue("Not same f",z80.f == 0x10); 31 | assertTrue("Not same pc",z80.pc == 1); 32 | assertTrue("Not same cycles",z80.cycles == 4); 33 | } 34 | 35 | public void testInc_B_0xFF() throws Exception { 36 | z80.b = 0xFF; 37 | z80.pc = 0; 38 | z80.f = 0xAA; 39 | 40 | iNC_B.execute(0, 0, 0, 0); 41 | 42 | assertTrue("Not same b",z80.b == 0); 43 | assertTrue("Not same f",z80.f == 0xA0); 44 | assertTrue("Not same pc",z80.pc == 1); 45 | assertTrue("Not same cycles",z80.cycles == 4); 46 | } 47 | 48 | public void testInc_B_0x0F() throws Exception { 49 | z80.b = 0x0F; 50 | z80.pc = 0; 51 | z80.f = 0xAA; 52 | 53 | iNC_B.execute(0, 0, 0, 0); 54 | 55 | assertTrue("Not same b",z80.b == 0x10); 56 | assertTrue("Not same f",z80.f == 0x20); 57 | assertTrue("Not same pc",z80.pc == 1); 58 | assertTrue("Not same cycles",z80.cycles == 4); 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/inc/INC_CTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.inc; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Created by vicboma on 15/09/15. 7 | */ 8 | public class INC_CTest extends TestCase { 9 | 10 | public void setUp() throws Exception { 11 | super.setUp(); 12 | 13 | } 14 | 15 | public void tearDown() throws Exception { 16 | 17 | } 18 | 19 | public void testRunAsync() throws Exception { 20 | assertTrue(false); 21 | } 22 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/ld/LD_A_BCTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.ld; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Created by vicboma on 15/09/15. 7 | */ 8 | public class LD_A_BCTest extends TestCase { 9 | 10 | public void setUp() throws Exception { 11 | super.setUp(); 12 | 13 | } 14 | 15 | public void tearDown() throws Exception { 16 | 17 | } 18 | 19 | public void testRunAsync() throws Exception { 20 | assertTrue(false); 21 | } 22 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/ld/LD_B_NNTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.ld; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | public class LD_B_NNTest extends TestCase { 9 | 10 | private Z80Impl z80; 11 | private LD_B_NN ld_b_NN; 12 | 13 | public void setUp() throws Exception { 14 | super.setUp(); 15 | z80 = mock(Z80Impl.class); 16 | ld_b_NN = new LD_B_NN(z80); 17 | } 18 | 19 | public void tearDown() throws Exception { 20 | z80 = null; 21 | } 22 | 23 | public void testld_b_n_2() throws Exception { 24 | ld_b_NN.execute(1, 2, 2, 2); 25 | 26 | assertTrue("Not same b", z80.b == 2); 27 | assertTrue("Not same pc", z80.pc == 2); 28 | assertTrue("Not same cycles", z80.cycles == 8); 29 | } 30 | 31 | public void testld_b_3() throws Exception { 32 | ld_b_NN.execute(3, 1, 3, 0); 33 | 34 | assertTrue("Not same b", z80.b == 1); 35 | assertTrue("Not same pc", z80.pc == 2); 36 | assertTrue("Not same cycles", z80.cycles == 8); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/ld/LD_C_NTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.ld; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Created by vicboma on 15/09/15. 7 | */ 8 | public class LD_C_NTest extends TestCase { 9 | 10 | public void setUp() throws Exception { 11 | super.setUp(); 12 | 13 | } 14 | 15 | public void tearDown() throws Exception { 16 | 17 | } 18 | 19 | public void testRunAsync() throws Exception { 20 | assertTrue(false); 21 | } 22 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/ld/LD_DE_ATest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.ld; 2 | 3 | import cpu.processor.command.bits8.ld.LD_DE_A;import cpu.processor.memory.MemoryZ80Impl; 4 | import cpu.processor.register.bits8.Registers8bits; 5 | import cpu.processor.z80.Z80Impl; 6 | import junit.framework.TestCase; 7 | 8 | import java.lang.Exception;import static org.mockito.Mockito.mock; 9 | import static org.mockito.Mockito.when; 10 | 11 | /** 12 | * Created by vicboma on 17/09/15. 13 | */ 14 | public class LD_DE_ATest extends TestCase { 15 | 16 | private LD_DE_A ld_de_a; 17 | private Z80Impl z80; 18 | private Registers8bits registers8bits; 19 | private MemoryZ80Impl memoryZ80; 20 | 21 | public void setUp() throws Exception { 22 | super.setUp(); 23 | 24 | z80 = mock(Z80Impl.class); 25 | memoryZ80 = mock(MemoryZ80Impl.class); 26 | registers8bits = mock(Registers8bits.class); 27 | z80.registers8bits = registers8bits; 28 | z80.memoryZ80 = memoryZ80; 29 | ld_de_a = new LD_DE_A(z80); 30 | } 31 | 32 | public void tearDown() throws Exception { 33 | ld_de_a = null; 34 | } 35 | 36 | public void testExecute() throws Exception { 37 | final int expected = 8209; 38 | when(z80.registers8bits.a()).thenReturn((short) expected); 39 | final int value = 0x000F; 40 | this.z80.d = value; 41 | this.z80.e = 0x1111; 42 | final int result = (value << 8) + this.z80.e; 43 | 44 | ld_de_a.execute(0,0,0,0); 45 | assertTrue("not same a", result == this.registers8bits.a()); 46 | assertTrue("not same pc", this.z80.pc == 1); 47 | assertTrue("not same cycles", this.z80.cycles == 8); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/bits8/ld/LD_H_NTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.bits8.ld; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 20/09/15. 10 | */ 11 | public class LD_H_NTest extends TestCase { 12 | 13 | private LD_N ld_n; 14 | 15 | private LD_H_N ld_h_n; 16 | private Z80Impl z80; 17 | 18 | public void setUp() throws Exception { 19 | super.setUp(); 20 | 21 | z80 = mock(Z80Impl.class); 22 | ld_n = new LD_N(z80); 23 | ld_h_n = new LD_H_N(ld_n); 24 | } 25 | 26 | public void tearDown() throws Exception { 27 | ld_h_n = null; 28 | ld_n = null; 29 | } 30 | 31 | public void testName() throws Exception { 32 | final int expected = 0x4455; 33 | 34 | z80.hl = 0xFF55; 35 | ld_h_n.execute(0x22, 0x44, 0x11, 0x99); 36 | 37 | assertTrue("Not same l", z80.hl == expected); 38 | assertTrue("Not same pc",z80.pc == 2); 39 | assertTrue("Not same cycles",z80.cycles == 8); 40 | } 41 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/jump/JRTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.jump; 2 | 3 | import cpu.processor.z80.Z80Impl; 4 | import junit.framework.TestCase; 5 | 6 | import static org.mockito.Mockito.mock; 7 | 8 | /** 9 | * Created by vicboma on 19/09/15. 10 | */ 11 | public class JRTest extends TestCase 12 | { 13 | private JR jr; 14 | private Z80Impl z80; 15 | 16 | public void setUp() throws Exception { 17 | super.setUp(); 18 | z80 = mock(Z80Impl.class); 19 | jr = new JR(z80); 20 | } 21 | 22 | public void tearDown() throws Exception { 23 | jr = null; 24 | z80 = null; 25 | } 26 | public void testName() throws Exception { 27 | 28 | jr.execute(0,0,0,2); 29 | 30 | assertTrue("Not same pc", z80.pc == 4); 31 | assertTrue("Not same cycles", z80.cycles == 8); 32 | } 33 | 34 | public void testName1() throws Exception { 35 | 36 | jr.execute(0,0,0,4); 37 | 38 | assertTrue("Not same pc", z80.pc == 6); 39 | assertTrue("Not same cycles", z80.cycles == 8); 40 | } 41 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/jump/JR_NZ_nnTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.jump; 2 | 3 | import cpu.processor.register.flag.Flags; 4 | import cpu.processor.z80.Z80Impl; 5 | import junit.framework.TestCase; 6 | 7 | import static org.mockito.Mockito.mock; 8 | 9 | /** 10 | * Created by vicboma on 21/09/15. 11 | */ 12 | public class JR_NZ_nnTest extends TestCase { 13 | 14 | private JR_NZ_nn jr_NZ_nn; 15 | private Z80Impl z80; 16 | 17 | public void setUp() throws Exception { 18 | super.setUp(); 19 | z80 = mock(Z80Impl.class); 20 | jr_NZ_nn = new JR_NZ_nn(z80); 21 | } 22 | 23 | public void tearDown() throws Exception { 24 | jr_NZ_nn = null; 25 | z80 = null; 26 | } 27 | 28 | public void testjrNzNull() throws Exception { 29 | 30 | z80.f = Flags.NULL; 31 | 32 | jr_NZ_nn.execute(0,0,0,4); 33 | 34 | assertTrue("not same f", z80.f == Flags.NULL); 35 | assertTrue("not same pc", z80.pc == 6 ); 36 | assertTrue("not same cycles", z80.cycles == 8 ); 37 | 38 | } 39 | 40 | public void testjrNz() throws Exception { 41 | 42 | z80.f = Flags.ZERO; 43 | 44 | jr_NZ_nn.execute(0,0,0,8); 45 | 46 | assertTrue("not same f", z80.f == Flags.ZERO); 47 | assertTrue("not same pc", z80.pc == 2 ); 48 | assertTrue("not same cycles", z80.cycles == 8 ); 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/cpu/processor/command/jump/JR_Z_nnTest.java: -------------------------------------------------------------------------------- 1 | package emulator.cpu.processor.command.jump; 2 | 3 | import cpu.processor.register.flag.Flags; 4 | import cpu.processor.z80.Z80Impl; 5 | import junit.framework.TestCase; 6 | 7 | import static org.mockito.Mockito.mock; 8 | 9 | /** 10 | * Created by vicboma on 20/09/15. 11 | */ 12 | public class JR_Z_nnTest extends TestCase { 13 | 14 | private JR_Z_nn jr_Z_nn; 15 | private Z80Impl z80; 16 | 17 | public void setUp() throws Exception { 18 | super.setUp(); 19 | z80 = mock(Z80Impl.class); 20 | jr_Z_nn = new JR_Z_nn(z80); 21 | } 22 | 23 | public void tearDown() throws Exception { 24 | jr_Z_nn = null; 25 | z80 = null; 26 | } 27 | 28 | public void testjrNzNull() throws Exception { 29 | 30 | z80.f = Flags.NULL; 31 | 32 | jr_Z_nn.execute(0, 0, 0, 23); 33 | 34 | assertTrue("not same f", z80.f == Flags.NULL); 35 | assertTrue("not same pc", z80.pc == 2); 36 | assertTrue("not same cycles", z80.cycles == 8); 37 | 38 | } 39 | 40 | public void testjrNz() throws Exception { 41 | 42 | z80.f = Flags.ZERO; 43 | 44 | jr_Z_nn.execute(0, 0, 0, 8); 45 | 46 | assertTrue("not same f", z80.f == Flags.ZERO); 47 | assertTrue("not same pc", z80.pc == 10); 48 | assertTrue("not same cycles", z80.cycles == 8); 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/framework/container/ClassToMapContainerTest.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.container; 2 | 3 | import junit.framework.TestCase; 4 | 5 | import java.util.stream.IntStream; 6 | 7 | import static org.mockito.Mockito.mock; 8 | 9 | 10 | public class ClassToMapContainerTest extends TestCase { 11 | 12 | private ClassToMapContainer classToMapContainer; 13 | 14 | public void setUp() throws Exception { 15 | super.setUp(); 16 | classToMapContainer = new ClassToMapContainer(); 17 | } 18 | 19 | public void tearDown() throws Exception { 20 | classToMapContainer = null; 21 | } 22 | 23 | public void testPut() throws Exception { 24 | ClassToMapKey mockClassToMapKey = mock(ClassToMapKey.class); 25 | String mockObject = ""; 26 | final Object put = classToMapContainer.put(mockClassToMapKey, mockObject); 27 | assertNull("Not same Object", put); 28 | } 29 | 30 | public void testPutAndGet() throws Exception { 31 | ClassToMapKey classToMapKey = ClassToMapKey.Create("class",String.class); 32 | String obj = ""; 33 | classToMapContainer.put(classToMapKey, obj); 34 | final String result = classToMapContainer.get(classToMapKey); 35 | assertSame("Not same result",obj,result); 36 | } 37 | 38 | public void testGet() throws Exception { 39 | IntStream.range(0, 100).forEach( 40 | x -> 41 | { 42 | ClassToMapKey classToMapKey = ClassToMapKey.Create("" + x, String.class); 43 | final String value = "object number " + x; 44 | classToMapContainer.put(classToMapKey, value); 45 | final String get = classToMapContainer.get(classToMapKey); 46 | 47 | assertSame("Not same Object", value, get); 48 | }); 49 | } 50 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/framework/container/ClassToMapKeyTest.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.container; 2 | 3 | import junit.framework.TestCase; 4 | 5 | import static org.mockito.Mockito.spy; 6 | import static org.mockito.Mockito.when; 7 | 8 | public class ClassToMapKeyTest extends TestCase { 9 | 10 | private String id = "id"; 11 | private Class classString; 12 | 13 | private ClassToMapKey classToMapKey; 14 | 15 | public void setUp() throws Exception { 16 | super.setUp(); 17 | classToMapKey = ClassToMapKey.Create(id,classString); 18 | } 19 | 20 | public void tearDown() throws Exception { 21 | classToMapKey = null; 22 | } 23 | 24 | public void testCreate() throws Exception { 25 | final ClassToMapKey _classToMapKey = ClassToMapKey.Create(id, classString); 26 | assertNotSame("Not same testCreate",_classToMapKey, classToMapKey); 27 | } 28 | 29 | public void testId() throws Exception { 30 | final ClassToMapKey _classToMapKey = ClassToMapKey.Create(id, classString); 31 | final ClassToMapKey classToMapKeySpy = spy(_classToMapKey); 32 | when(classToMapKeySpy.id()).thenReturn(id); 33 | assertEquals("Not same id",classToMapKeySpy.id(), id); 34 | } 35 | 36 | public void testType() throws Exception { 37 | final ClassToMapKey _classToMapKey = ClassToMapKey.Create(id, classString); 38 | assertEquals("Not same id",_classToMapKey.type(), classString); 39 | } 40 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/framework/executor/deferred/DeferredAsyncImplTest.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.executor.deferred; 2 | 3 | import junit.framework.TestCase; 4 | 5 | import static org.mockito.Mockito.spy; 6 | import static org.mockito.Mockito.verify; 7 | 8 | public class DeferredAsyncImplTest extends TestCase { 9 | 10 | 11 | public void testGetCompletableFuture() throws Exception { 12 | final DeferredAsyncImpl deferredAsync = new DeferredAsyncImpl(()->{} ); 13 | DeferredAsyncImpl spy = spy(deferredAsync); 14 | spy.getCompletableFuture(); 15 | verify(spy).getCompletableFuture(); 16 | } 17 | 18 | public void testGetCallable() throws Exception { 19 | final DeferredAsyncImpl deferredAsync = new DeferredAsyncImpl(() -> true); 20 | DeferredAsyncImpl spy = spy(deferredAsync); 21 | spy.getCallable(); 22 | verify(spy).getCallable(); 23 | } 24 | 25 | public void testGetRunnable() throws Exception { 26 | final DeferredAsyncImpl deferredAsync = new DeferredAsyncImpl(()->{} ); 27 | DeferredAsyncImpl spy = spy(deferredAsync); 28 | spy.getRunnable(); 29 | verify(spy).getRunnable(); 30 | } 31 | } -------------------------------------------------------------------------------- /gameboyclassic/test/emulator/framework/executor/deferred/resultAsync/ResultAsyncImplTest.java: -------------------------------------------------------------------------------- 1 | package emulator.framework.executor.deferred.resultAsync; 2 | 3 | import junit.framework.TestCase; 4 | 5 | import java.util.concurrent.Callable; 6 | import java.util.concurrent.ExecutorService; 7 | import java.util.concurrent.Executors; 8 | 9 | public class ResultAsyncImplTest extends TestCase { 10 | 11 | 12 | public static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor(); 13 | private ResultAsyncImpl,ExecutorService> resultAsync; 14 | 15 | public void setUp() throws Exception { 16 | super.setUp(); 17 | this.resultAsync = new ResultAsyncImpl(EXECUTOR_SERVICE,new Callable(){ 18 | public Boolean call() throws Exception{ 19 | return true; 20 | } 21 | }); 22 | } 23 | 24 | public void tearDown() throws Exception { 25 | this.resultAsync = null; 26 | } 27 | 28 | public void testGetExecutor() throws Exception { 29 | final ExecutorService executor = this.resultAsync.getExecutor(); 30 | assertSame("Not same getExecutor", executor, EXECUTOR_SERVICE); 31 | } 32 | 33 | public void testGetResult() throws Exception { 34 | Callable result = this.resultAsync.getResult(); 35 | Boolean call = result.call(); 36 | assertTrue("Not same result",call); 37 | } 38 | } -------------------------------------------------------------------------------- /schip8/README.md: -------------------------------------------------------------------------------- 1 | S-Chip8 Java Emulator 2 | ========= 3 | 4 | 5 | Super Chip-48: New Instructions 6 | ``` 7 | 00Cn - SCD nibble 8 | 00FB - SCR 9 | 00FC - SCL 10 | 00FD - EXIT 11 | 00FE - LOW 12 | 00FF - HIGH 13 | Dxy0 - DRW Vx, Vy, 0 14 | Fx30 - LD HF, Vx 15 | Fx75 - LD R, Vx 16 | Fx85 - LD Vx, R 17 | ``` 18 | 19 | 20 | ##References : 21 | 22 | * [Chip8 Java Emulator](https://github.com/vicboma1/emulators/blob/master/chip8/README.md#references-) 23 | * My own know. 24 | @Author: Victor Bolinches Marin 25 | -------------------------------------------------------------------------------- /schip8/src/emulator/specification/Memory.java: -------------------------------------------------------------------------------- 1 | package emulator.specification; 2 | 3 | import emulator.specification.font.Font; 4 | import emulator.specification.sfont.SFont; 5 | 6 | /** 7 | * Created by vicboma on 03/07/14. 8 | */ 9 | public class Memory { 10 | 11 | public static final int INITIALIZE = 0x0000; 12 | public static final int START_CHIP8_PROGRAMS = 0x0200; 13 | public static final int START_ETI_660_CHIP8_PROGRAMS = 0x0600; 14 | public static final int SIZE = 0x1000; 15 | private short men[]; 16 | 17 | public Memory() { 18 | men = new short[SIZE]; 19 | } 20 | 21 | public void set(Integer index, short value) { 22 | this.men[index] = value; 23 | } 24 | 25 | public int ShiftL(Integer index, int value) { 26 | return men[index] << value; 27 | } 28 | 29 | public int ShiftR(Integer index, int value) { 30 | return this.men[index] >> value; 31 | } 32 | 33 | public short get(Integer index) { 34 | return this.men[index]; 35 | } 36 | 37 | public void loadFont(Font font) { 38 | for (int i = 0; i < 40; i++) { 39 | final int index = i << 1; 40 | final int mask = 0xf0; 41 | set(index, (short) (font.chip8[i] & mask)); 42 | set(index + 1, (short) ((font.chip8[i] << 4) & mask)); 43 | } 44 | } 45 | 46 | public void loadSFont(Font font) { 47 | for (int i = 0; i < 100; i++) { 48 | this.men[0x50 + i] = SFont.SChip8[i]; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /schip8/src/emulator/specification/sfont/SFont.java: -------------------------------------------------------------------------------- 1 | package emulator.specification.sfont; 2 | 3 | /** 4 | * Created by vicboma on 12/08/14. 5 | */ 6 | public class SFont { 7 | public static final short[] SChip8 = { 8 | 0x3C, 0x7E, 0xE7, 0xC3, 0xC3, 0xC3, 0xC3, 0xE7, 0x7E, 0x3C, 9 | 0x18, 0x38, 0x58, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 10 | 0x3E, 0x7F, 0xC3, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xFF, 0xFF, 11 | 0x3C, 0x7E, 0xC3, 0x03, 0x0E, 0x0E, 0x03, 0xC3, 0x7E, 0x3C, 12 | 0x06, 0x0E, 0x1E, 0x36, 0x66, 0xC6, 0xFF, 0xFF, 0x06, 0x06, 13 | 0xFF, 0xFF, 0xC0, 0xC0, 0xFC, 0xFE, 0x03, 0xC3, 0x7E, 0x3C, 14 | 0x3E, 0x7C, 0xC0, 0xC0, 0xFC, 0xFE, 0xC3, 0xC3, 0x7E, 0x3C, 15 | 0xFF, 0xFF, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x60, 0x60, 16 | 0x3C, 0x7E, 0xC3, 0xC3, 0x7E, 0x7E, 0xC3, 0xC3, 0x7E, 0x3C, 17 | 0x3C, 0x7E, 0xC3, 0xC3, 0x7F, 0x3F, 0x03, 0x03, 0x3E, 0x7C}; 18 | 19 | public SFont() { 20 | } 21 | } 22 | --------------------------------------------------------------------------------