├── source ├── Build.bat ├── font │ ├── AmstradCPC.ttf │ └── ZXSpectrum.ttf ├── tst │ ├── CPUTest.cc │ ├── ComputerTest.cc │ ├── SpectrumTest.cc │ ├── CRTCTest.cc │ ├── GenericModuleTest.cc │ ├── GraphicWindowTest.cc │ ├── TZXFileTest.cc │ ├── MemoryTest.cc │ └── DSKFileTest.cc └── src │ ├── config.h.in │ ├── CommonDefs.h │ ├── Z80PrefixCB.h │ ├── Z80PrefixDD.h │ ├── Z80PrefixED.h │ ├── Z80PrefixFD.h │ ├── Z80Halt.h │ ├── SDLWindow.h │ ├── Z80JpHl.h │ ├── Z80JpIx.h │ ├── Z80JpIy.h │ ├── Z80CpReg.h │ ├── Z80Daa.h │ ├── Z80CpRegX.h │ ├── Z80CpRegY.h │ ├── Z80Di.h │ ├── Z80Ei.h │ ├── Z80OrReg.h │ ├── Z80AndReg.h │ ├── Z80OrRegX.h │ ├── Z80OrRegY.h │ ├── Z80XorReg.h │ ├── Z80AddReg.h │ ├── Z80AndRegX.h │ ├── Z80AndRegY.h │ ├── Z80SubReg.h │ ├── Z80XorRegX.h │ ├── Z80XorRegY.h │ ├── Z80AddRegX.h │ ├── Z80AddRegY.h │ ├── Z80Nop.h │ ├── Z80SubRegX.h │ ├── Z80SubRegY.h │ ├── Z80DecReg.h │ ├── Z80IncReg.h │ ├── Z80DecRegX.h │ ├── Z80DecRegY.h │ ├── Z80AdcReg.h │ ├── Z80SbcReg.h │ ├── Z80AdcRegX.h │ ├── Z80AdcRegY.h │ ├── Z80SbcRegX.h │ ├── Z80SbcRegY.h │ ├── Z80IncRegX.h │ ├── Z80IncRegY.h │ ├── Z80Scf.h │ ├── Z80Cpl.h │ ├── Z80ExAfAf.h │ ├── Z80ExDeHl.h │ ├── Z80Ccf.h │ ├── Z80Im.h │ ├── Z80Register.h │ ├── Z80LdRegReg.h │ ├── Z80SetNReg.h │ ├── Z80Exx.h │ ├── Z80ResNReg.h │ ├── Z80LdRegXRegX.h │ ├── Z80LdRegYRegY.h │ ├── Z80DecRegPX.h │ ├── Z80DecRegPY.h │ ├── Z80IncRegPX.h │ ├── Z80IncRegPY.h │ ├── Z80Rlca.h │ ├── Z80Rla.h │ ├── Z80CpByte.h │ ├── Z80CpPtrHl.h │ ├── Z80Rrca.h │ ├── Z80XXCBPrefixed.h │ ├── Z80SrlReg.h │ ├── Z80Rra.h │ ├── Z80SlaReg.h │ ├── Z80LdSpHl.h │ ├── Z80SllReg.h │ ├── Z80SubByte.h │ ├── Z80AddByte.h │ ├── Z80SubPtrHl.h │ ├── Z80AddPtrHl.h │ ├── Z80LdSpIx.h │ ├── Z80LdSpIy.h │ ├── Z80RlcReg.h │ ├── Z80LdIA.h │ ├── Z80LdRA.h │ ├── Z80OrByte.h │ ├── Z80AndByte.h │ ├── Z80OrPtrHl.h │ ├── Z80RlReg.h │ ├── Z80XorByte.h │ ├── Z80AndPtrHl.h │ ├── Z80Ret.h │ ├── Z80XorPtrHl.h │ ├── Z80JpWord.h │ ├── Z80AdcByte.h │ ├── Z80RrcReg.h │ ├── Z80SbcByte.h │ ├── Z80AdcPtrHl.h │ ├── Z80SbcPtrHl.h │ ├── Z80SraReg.h │ ├── Z80RrReg.h │ ├── Z80LdAPtrBc.h │ ├── Z80LdAPtrDe.h │ ├── Z80RetI.h │ ├── SNAFile.h │ ├── Z80DecRegP.h │ ├── Z80IncRegP.h │ ├── Z80BitNReg.h │ ├── Z80PopIx.h │ ├── Z80PopIy.h │ ├── TAPFile.h │ ├── Z80LdPtrBcA.h │ ├── Z80LdPtrDeA.h │ ├── Z80LdPtrHlByte.h │ ├── Z80CBPrefixed.h │ ├── Z80Nmi.h │ ├── Memory.cc │ ├── Console.h │ ├── Z80InAPtrByte.h │ ├── Z80LdRegByte.h │ ├── Z80LdAPtrWord.h │ ├── Z80LdRegPtrHl.h │ ├── Z80PopReg.h │ ├── Z80LdPtrHlReg.h │ ├── Z80PushIx.h │ ├── Z80PushIy.h │ ├── Z80LdRegWord.h │ ├── Z80LdRegXByte.h │ ├── Z80LdRegYByte.h │ ├── Z80OutPtrByteA.h │ ├── Z80File.h │ ├── Z80LdHlPtrWord.h │ ├── Z80DecPtrHl.h │ ├── Z80LdPtrWordA.h │ ├── Z80IncPtrHl.h │ ├── Z80LdIxPtrWord.h │ ├── Z80LdIyPtrWord.h │ ├── Z80LdPtrWordHl.h │ ├── Z80Call.h │ ├── Z80OutPtrCReg.h │ ├── Z80JrByte.h │ ├── Z80LdPtrWordIx.h │ ├── Z80LdPtrWordIy.h │ ├── Z80Neg.h │ ├── Z80Rst.h │ ├── CSWFile.h │ ├── Z80ResNPtrHl.h │ ├── Z80PushReg.h │ ├── Z80SetNPtrHl.h │ ├── PZXFile.h │ ├── Utils.h │ ├── Z80LdRegXWord.h │ ├── Z80LdRegYWord.h │ ├── SaveState.h │ ├── Z80SlaPtrHl.h │ └── Z80SrlPtrHl.h ├── .gitignore └── .github └── workflows └── build.yml /source/Build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | msbuild INSTALL.vcxproj -t:Rebuild -p:Configuration=Release 3 | -------------------------------------------------------------------------------- /source/font/AmstradCPC.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MartianGirl/SpecIde/HEAD/source/font/AmstradCPC.ttf -------------------------------------------------------------------------------- /source/font/ZXSpectrum.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MartianGirl/SpecIde/HEAD/source/font/ZXSpectrum.ttf -------------------------------------------------------------------------------- /source/tst/CPUTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE CPU test 3 | #include 4 | //#include 5 | 6 | #include "CPU.h" 7 | 8 | BOOST_AUTO_TEST_CASE(constructors_test) 9 | { 10 | CPU cpu0; 11 | } 12 | 13 | // EOF 14 | // vim: et:sw=4:ts=4 15 | -------------------------------------------------------------------------------- /source/tst/ComputerTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE Computer test 3 | #include 4 | //#include 5 | 6 | #include "Computer.h" 7 | 8 | BOOST_AUTO_TEST_CASE(constructors_test) 9 | { 10 | Computer c0; 11 | } 12 | 13 | // EOF 14 | // vim: et:sw=4:ts=4 15 | -------------------------------------------------------------------------------- /source/tst/SpectrumTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE Spectrum test 3 | #include 4 | //#include 5 | 6 | #include "Spectrum.h" 7 | 8 | BOOST_AUTO_TEST_CASE(constructors_test) 9 | { 10 | Spectrum sp0; 11 | } 12 | 13 | // EOF 14 | // vim: et:sw=4:ts=4 15 | -------------------------------------------------------------------------------- /source/tst/CRTCTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE CRTC test 3 | #include 4 | //#include 5 | 6 | #include "CRTC.h" 7 | 8 | #include 9 | 10 | BOOST_AUTO_TEST_CASE(constructors_test) { 11 | 12 | CRTC crtc; 13 | } 14 | 15 | // EOF 16 | // vim: et:sw=4:ts=4 17 | -------------------------------------------------------------------------------- /source/tst/GenericModuleTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE GenericModule test 3 | #include 4 | //#include 5 | 6 | // #include "GenericModule.h" 7 | 8 | // BOOST_AUTO_TEST_CASE(constructors_test) 9 | // { 10 | // GenericModule gm0(); 11 | // } 12 | 13 | // EOF 14 | // vim: et:sw=4:ts=4 15 | -------------------------------------------------------------------------------- /source/tst/GraphicWindowTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE GraphicWindow test 3 | #include 4 | //#include 5 | 6 | #include "GraphicWindow.h" 7 | 8 | BOOST_AUTO_TEST_CASE(constructors_test) 9 | { 10 | GraphicWindow gw0(640, 400); 11 | 12 | GraphicWindow gw1(640, 400, "SpecIde 2X"); 13 | } 14 | 15 | // EOF 16 | // vim: et:sw=4:ts=4 17 | -------------------------------------------------------------------------------- /source/src/config.h.in: -------------------------------------------------------------------------------- 1 | // SpecIde version. 2 | #define SPECIDE_BUILD_DATE "@SpecIde_BUILD_DATE@" 3 | 4 | // SpecIde time stamp. 5 | #define SPECIDE_BUILD_TIME "@SpecIde_BUILD_TIME@" 6 | 7 | // SpecIde commit SHA from git. 8 | #define SPECIDE_BUILD_COMMIT "@SpecIde_BUILD_COMMIT@" 9 | 10 | // System config. 11 | #define SPECIDE_BIG_ENDIAN @SpecIde_BIG_ENDIAN@ 12 | #define SPECIDE_HOME_ENV "@SpecIde_HOME_ENV@" 13 | #define SPECIDE_CONF_DIR "@SpecIde_CONF_DIR@" 14 | #define SPECIDE_ON_UNIX @SpecIde_ON_UNIX@ 15 | #define SPECIDE_ON_MACOS @SpecIde_ON_MACOS@ 16 | #define SPECIDE_SDL2 @SpecIde_SDL2@ 17 | 18 | // Enable BUSRQ/BUSAK support by default. 19 | // #define SPECIDE_SUPPORT_BUSRQ_BUSAK 20 | -------------------------------------------------------------------------------- /source/src/CommonDefs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class FileTypes { 6 | FILETYPE_TAP, 7 | FILETYPE_TZX, 8 | FILETYPE_CDT, 9 | FILETYPE_PZX, 10 | FILETYPE_DSK, 11 | FILETYPE_TRD, 12 | FILETYPE_Z80, 13 | FILETYPE_SNA, 14 | FILETYPE_CSW, 15 | FILETYPE_PAL, 16 | FILETYPE_ERR 17 | }; 18 | 19 | enum class RomVariant { 20 | ROM_48_EN, 21 | ROM_48_ES, 22 | ROM_128_EN, 23 | ROM_128_ES, 24 | ROM_PLUS2_EN, 25 | ROM_PLUS2_ES, 26 | ROM_PLUS3_EN, 27 | ROM_PLUS3_ES, 28 | ROM_PENTAGON, 29 | ROM_CPC464_EN, 30 | ROM_CPC464_ES, 31 | ROM_CPC464_FR, 32 | ROM_CPC664_EN, 33 | ROM_CPC6128_EN, 34 | ROM_CPC6128_ES, 35 | ROM_CPC6128_FR 36 | }; 37 | 38 | struct InputMatrixPosition { 39 | 40 | uint8_t row; 41 | uint8_t key; 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore intermediate CMake files and Makefiles. 2 | CMakeCache.txt 3 | CMakeFiles/ 4 | cmake_install.cmake 5 | Makefile 6 | .ninja_deps 7 | .ninja_log 8 | build.ninja 9 | rules.ninja 10 | 11 | # Also on windows 12 | *.vcxproj 13 | *.vcxproj.filters 14 | *.vcxproj.user 15 | *.sdf 16 | *.sln 17 | *.suo 18 | *.ipch 19 | 20 | # Install 21 | install_manifest.txt 22 | 23 | # Ignore swap files from Vim. 24 | *.swp 25 | 26 | # Ignore tag files. 27 | tags 28 | 29 | # Ignore config.h 30 | config.h 31 | 32 | # Ignore executables and compiled files. 33 | source/bin/ 34 | Debug/ 35 | Release/ 36 | Win32/ 37 | SpecIde 38 | *Test 39 | *.exe 40 | *.ilk 41 | *.pdb 42 | *.manifest 43 | 44 | # Ignore Spectrum files for testing. 45 | *.rom 46 | *.scr 47 | *.tap 48 | *.tzx 49 | *.dsk 50 | *.csw 51 | *.cdt 52 | *.z80 53 | *.sna 54 | 55 | # These files can also be ignored. 56 | *.asm 57 | *.txt 58 | *.zip 59 | -------------------------------------------------------------------------------- /source/src/Z80PrefixCB.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PrefixCB.h 19 | * 20 | * Prefix CB. 21 | * 22 | */ 23 | 24 | bool z80PrefixCB() 25 | { 26 | prefix = PREFIX_CB; 27 | return true; 28 | } 29 | 30 | // vim: et:sw=4:ts=4 31 | -------------------------------------------------------------------------------- /source/src/Z80PrefixDD.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PrefixDD.h 19 | * 20 | * Prefix DD. 21 | * 22 | */ 23 | 24 | bool z80PrefixDD() 25 | { 26 | prefix = PREFIX_DD; 27 | return true; 28 | } 29 | 30 | // vim: et:sw=4:ts=4 31 | -------------------------------------------------------------------------------- /source/src/Z80PrefixED.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PrefixED.h 19 | * 20 | * Prefix ED. 21 | * 22 | */ 23 | 24 | bool z80PrefixED() 25 | { 26 | prefix = PREFIX_ED; 27 | return true; 28 | } 29 | 30 | // vim: et:sw=4:ts=4 31 | -------------------------------------------------------------------------------- /source/src/Z80PrefixFD.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PrefixFD.h 19 | * 20 | * Prefix FD. 21 | * 22 | */ 23 | 24 | bool z80PrefixFD() 25 | { 26 | prefix = PREFIX_FD; 27 | return true; 28 | } 29 | 30 | // vim: et:sw=4:ts=4 31 | -------------------------------------------------------------------------------- /source/src/Z80Halt.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Halt.h 19 | * 20 | * Instruction: HALT 21 | * 22 | */ 23 | 24 | bool z80Halt() 25 | { 26 | iff |= HALT; 27 | flg = 0; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/SDLWindow.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2021. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** 19 | * SDLWindow 20 | * 21 | * Wrapper to SDL2 window functionality. 22 | */ 23 | class SDLWindow { 24 | 25 | SDL_Window* window; 26 | 27 | public: 28 | void create() 29 | }; 30 | // vim: et:sw=4:ts=4 31 | 32 | -------------------------------------------------------------------------------- /source/src/Z80JpHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80JpHl.h 19 | * 20 | * JP (HL) Instruction. 21 | * 22 | */ 23 | 24 | bool z80JpHl() 25 | { 26 | pc.w = hl.w; 27 | flg = 0; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80JpIx.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80JpIx.h 19 | * 20 | * JP (IX) Instruction. 21 | * 22 | */ 23 | 24 | bool z80JpIx() 25 | { 26 | pc.w = ix.w; 27 | flg = 0; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80JpIy.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80JpIy.h 19 | * 20 | * JP (IY) Instruction. 21 | * 22 | */ 23 | 24 | bool z80JpIy() 25 | { 26 | pc.w = iy.w; 27 | flg = 0; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80CpReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80CpReg.h 19 | * 20 | * Instruction: CP r 21 | * 22 | */ 23 | 24 | bool z80CpReg() 25 | { 26 | af.b.l = flg = cpFlags[af.b.h][*reg8[z]]; 27 | prefix = PREFIX_NO; 28 | return true; 29 | } 30 | 31 | // vim: et:sw=4:ts=4 32 | -------------------------------------------------------------------------------- /source/src/Z80Daa.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Daa.h 19 | * 20 | * Instruction: DAA 21 | * 22 | */ 23 | 24 | bool z80Daa() 25 | { 26 | af.w = daaTable[af.w]; 27 | flg = af.b.l; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80CpRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80CpRegX.h 19 | * 20 | * Instruction: CP rx 21 | * 22 | */ 23 | 24 | bool z80CpRegX() 25 | { 26 | af.b.l = flg = cpFlags[af.b.h][*regx8[z]]; 27 | prefix = PREFIX_NO; 28 | return true; 29 | } 30 | 31 | // vim: et:sw=4:ts=4 32 | -------------------------------------------------------------------------------- /source/src/Z80CpRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80CpRegY.h 19 | * 20 | * Instruction: CP ry 21 | * 22 | */ 23 | 24 | bool z80CpRegY() 25 | { 26 | af.b.l = flg = cpFlags[af.b.h][*regy8[z]]; 27 | prefix = PREFIX_NO; 28 | return true; 29 | } 30 | 31 | // vim: et:sw=4:ts=4 32 | -------------------------------------------------------------------------------- /source/src/Z80Di.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Di.h 19 | * 20 | * Instruction: DI 21 | * 22 | */ 23 | 24 | bool z80Di() 25 | { 26 | iff &= ~(IFF1 | IFF2); 27 | flg = 0; 28 | intNotReady = 1; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80Ei.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Ei.h 19 | * 20 | * Instruction: EI 21 | * 22 | */ 23 | 24 | bool z80Ei() 25 | { 26 | iff |= (IFF1 | IFF2); 27 | flg = 0; 28 | intNotReady = 1; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80OrReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OrReg.h 19 | * 20 | * Instruction: OR r 21 | * 22 | */ 23 | 24 | bool z80OrReg() 25 | { 26 | af.b.l = flg = orFlags[af.b.h][*reg8[z]]; 27 | af.b.h |= *reg8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80AndReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AndReg.h 19 | * 20 | * Instruction: AND r 21 | * 22 | */ 23 | 24 | bool z80AndReg() 25 | { 26 | af.b.l = flg = andFlags[af.b.h][*reg8[z]]; 27 | af.b.h &= *reg8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80OrRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OrRegX.h 19 | * 20 | * Instruction: OR rx 21 | * 22 | */ 23 | 24 | bool z80OrRegX() 25 | { 26 | af.b.l = flg = orFlags[af.b.h][*regx8[z]]; 27 | af.b.h |= *regx8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80OrRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OrRegY.h 19 | * 20 | * Instruction: OR ry 21 | * 22 | */ 23 | 24 | bool z80OrRegY() 25 | { 26 | af.b.l = flg = orFlags[af.b.h][*regy8[z]]; 27 | af.b.h |= *regy8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80XorReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80XorReg.h 19 | * 20 | * Instruction: XOR r 21 | * 22 | */ 23 | 24 | bool z80XorReg() 25 | { 26 | af.b.l = flg = xorFlags[af.b.h][*reg8[z]]; 27 | af.b.h ^= *reg8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80AddReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AddReg.h 19 | * 20 | * Instruction: ADD A, r 21 | * 22 | */ 23 | 24 | bool z80AddReg() 25 | { 26 | af.b.l = flg = addFlags[0][af.b.h][*reg8[z]]; 27 | af.b.h += *reg8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80AndRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AndRegX.h 19 | * 20 | * Instruction: AND rx 21 | * 22 | */ 23 | 24 | bool z80AndRegX() 25 | { 26 | af.b.l = flg = andFlags[af.b.h][*regx8[z]]; 27 | af.b.h &= *regx8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80AndRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AndRegY.h 19 | * 20 | * Instruction: AND ry 21 | * 22 | */ 23 | 24 | bool z80AndRegY() 25 | { 26 | af.b.l = flg = andFlags[af.b.h][*regy8[z]]; 27 | af.b.h &= *regy8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80SubReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SubReg.h 19 | * 20 | * Instruction: SUB r 21 | * 22 | */ 23 | 24 | bool z80SubReg() 25 | { 26 | af.b.l = flg = subFlags[0][af.b.h][*reg8[z]]; 27 | af.b.h -= *reg8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80XorRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80XorRegX.h 19 | * 20 | * Instruction: XOR rx 21 | * 22 | */ 23 | 24 | bool z80XorRegX() 25 | { 26 | af.b.l = flg = xorFlags[af.b.h][*regx8[z]]; 27 | af.b.h ^= *regx8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80XorRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80XorRegY.h 19 | * 20 | * Instruction: XOR ry 21 | * 22 | */ 23 | 24 | bool z80XorRegY() 25 | { 26 | af.b.l = flg = xorFlags[af.b.h][*regy8[z]]; 27 | af.b.h ^= *regy8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80AddRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AddRegX.h 19 | * 20 | * Instruction: ADD A, rx 21 | * 22 | */ 23 | 24 | bool z80AddRegX() 25 | { 26 | af.b.l = flg = addFlags[0][af.b.h][*regx8[z]]; 27 | af.b.h += *regx8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80AddRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AddRegY.h 19 | * 20 | * Instruction: ADD A, ry 21 | * 22 | */ 23 | 24 | bool z80AddRegY() 25 | { 26 | af.b.l = flg = addFlags[0][af.b.h][*regy8[z]]; 27 | af.b.h += *regy8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80Nop.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Nop.h 19 | * 20 | * Instruction: NOP 21 | * 22 | * Encoding: 00 000 000 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | */ 27 | 28 | bool z80Nop() 29 | { 30 | prefix = PREFIX_NO; 31 | flg = 0; 32 | return true; 33 | } 34 | 35 | // vim: et:sw=4:ts=4 36 | -------------------------------------------------------------------------------- /source/src/Z80SubRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SubRegX.h 19 | * 20 | * Instruction: SUB rx 21 | * 22 | */ 23 | 24 | bool z80SubRegX() 25 | { 26 | af.b.l = flg = subFlags[0][af.b.h][*regx8[z]]; 27 | af.b.h -= *regx8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80SubRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SubRegY.h 19 | * 20 | * Instruction: SUB ry 21 | * 22 | */ 23 | 24 | bool z80SubRegY() 25 | { 26 | af.b.l = flg = subFlags[0][af.b.h][*regy8[z]]; 27 | af.b.h -= *regy8[z]; 28 | prefix = PREFIX_NO; 29 | return true; 30 | } 31 | 32 | // vim: et:sw=4:ts=4 33 | -------------------------------------------------------------------------------- /source/src/Z80DecReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecReg.h 19 | * 20 | * Instruction: DEC r 21 | * 22 | */ 23 | 24 | bool z80DecReg() 25 | { 26 | flg = af.b.l & FLAG_C; 27 | flg |= decFlags[*reg8[y]]; 28 | --*reg8[y]; 29 | af.b.l = flg; 30 | prefix = PREFIX_NO; 31 | return true; 32 | } 33 | 34 | // vim: et:sw=4:ts=4 35 | -------------------------------------------------------------------------------- /source/src/Z80IncReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncReg.h 19 | * 20 | * Instruction: INC r 21 | * 22 | */ 23 | 24 | bool z80IncReg() 25 | { 26 | flg = af.b.l & FLAG_C; 27 | flg |= incFlags[*reg8[y]]; 28 | ++*reg8[y]; 29 | af.b.l = flg; 30 | prefix = PREFIX_NO; 31 | return true; 32 | } 33 | 34 | // vim: et:sw=4:ts=4 35 | -------------------------------------------------------------------------------- /source/src/Z80DecRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecRegX.h 19 | * 20 | * Instruction: DEC rx 21 | * 22 | */ 23 | 24 | bool z80DecRegX() 25 | { 26 | flg = af.b.l & FLAG_C; 27 | flg |= decFlags[*regx8[y]]; 28 | --*regx8[y]; 29 | af.b.l = flg; 30 | prefix = PREFIX_NO; 31 | return true; 32 | } 33 | 34 | // vim: et:sw=4:ts=4 35 | -------------------------------------------------------------------------------- /source/src/Z80DecRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecRegY.h 19 | * 20 | * Instruction: DEC ry 21 | * 22 | */ 23 | 24 | bool z80DecRegY() 25 | { 26 | flg = af.b.l & FLAG_C; 27 | flg |= decFlags[*regy8[y]]; 28 | --*regy8[y]; 29 | af.b.l = flg; 30 | prefix = PREFIX_NO; 31 | return true; 32 | } 33 | 34 | // vim: et:sw=4:ts=4 35 | -------------------------------------------------------------------------------- /source/src/Z80AdcReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AdcReg.h 19 | * 20 | * Instruction: ADC A, r 21 | * 22 | */ 23 | 24 | bool z80AdcReg() 25 | { 26 | acc.b.l = af.b.l & FLAG_C; 27 | af.b.l = flg = addFlags[acc.b.l][af.b.h][*reg8[z]]; 28 | af.b.h += *reg8[z] + acc.b.l; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80SbcReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SbcReg.h 19 | * 20 | * Instruction: SBC A, r 21 | * 22 | */ 23 | 24 | bool z80SbcReg() 25 | { 26 | acc.b.l = af.b.l & FLAG_C; 27 | af.b.l = flg = subFlags[acc.b.l][af.b.h][*reg8[z]]; 28 | af.b.h -= *reg8[z] + acc.b.l; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80AdcRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AdcRegX.h 19 | * 20 | * Instruction: ADC A, rx 21 | * 22 | */ 23 | 24 | bool z80AdcRegX() 25 | { 26 | acc.b.l = af.b.l & FLAG_C; 27 | af.b.l = flg = addFlags[acc.b.l][af.b.h][*regx8[z]]; 28 | af.b.h += *regx8[z] + acc.b.l; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80AdcRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AdcRegY.h 19 | * 20 | * Instruction: ADC A, ry 21 | * 22 | */ 23 | 24 | bool z80AdcRegY() 25 | { 26 | acc.b.l = af.b.l & FLAG_C; 27 | af.b.l = flg = addFlags[acc.b.l][af.b.h][*regy8[z]]; 28 | af.b.h += *regy8[z] + acc.b.l; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80SbcRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SbcRegX.h 19 | * 20 | * Instruction: SBC A, rx 21 | * 22 | */ 23 | 24 | bool z80SbcRegX() 25 | { 26 | acc.b.l = af.b.l & FLAG_C; 27 | af.b.l = flg = subFlags[acc.b.l][af.b.h][*regx8[z]]; 28 | af.b.h -= *regx8[z] + acc.b.l; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80SbcRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SbcRegY.h 19 | * 20 | * Instruction: SBC A, ry 21 | * 22 | */ 23 | 24 | bool z80SbcRegY() 25 | { 26 | acc.b.l = af.b.l & FLAG_C; 27 | af.b.l = flg = subFlags[acc.b.l][af.b.h][*regy8[z]]; 28 | af.b.h -= *regy8[z] + acc.b.l; 29 | prefix = PREFIX_NO; 30 | return true; 31 | } 32 | 33 | // vim: et:sw=4:ts=4 34 | -------------------------------------------------------------------------------- /source/src/Z80IncRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncRegX.h 19 | * 20 | * Instruction: INC rx 21 | * 22 | */ 23 | 24 | bool z80IncRegX() 25 | { 26 | // Preserve carry flag. 27 | flg = af.b.l & FLAG_C; 28 | flg |= incFlags[*regx8[y]]; 29 | ++*regx8[y]; 30 | af.b.l = flg; 31 | prefix = PREFIX_NO; 32 | return true; 33 | } 34 | 35 | // vim: et:sw=4:ts=4 36 | -------------------------------------------------------------------------------- /source/src/Z80IncRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncRegY.h 19 | * 20 | * Instruction: INC ry 21 | * 22 | */ 23 | 24 | bool z80IncRegY() 25 | { 26 | // Preserve carry flag. 27 | flg = af.b.l &= FLAG_C; 28 | flg |= incFlags[*regy8[y]]; 29 | ++*regy8[y]; 30 | af.b.l = flg; 31 | prefix = PREFIX_NO; 32 | return true; 33 | } 34 | 35 | // vim: et:sw=4:ts=4 36 | -------------------------------------------------------------------------------- /source/src/Z80Scf.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Scf.h 19 | * 20 | * Instruction: SCF 21 | * 22 | */ 23 | 24 | bool z80Scf() 25 | { 26 | flg = ((af.b.l ^ flg) | af.b.h) & (FLAG_5 | FLAG_3); 27 | flg |= af.b.l & (FLAG_S | FLAG_Z | FLAG_PV); 28 | flg |= FLAG_C; 29 | af.b.l = flg; 30 | prefix = PREFIX_NO; 31 | return true; 32 | } 33 | 34 | // vim: et:sw=4:ts=4 35 | -------------------------------------------------------------------------------- /source/src/Z80Cpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Cpl.h 19 | * 20 | * Instruction: CPL 21 | * 22 | */ 23 | 24 | bool z80Cpl() 25 | { 26 | af.b.h = ~af.b.h; 27 | flg = af.b.l & (FLAG_S | FLAG_Z | FLAG_PV | FLAG_C); 28 | flg |= af.b.h & (FLAG_5 | FLAG_3); 29 | flg |= FLAG_H | FLAG_N; 30 | af.b.l = flg; 31 | prefix = PREFIX_NO; 32 | return true; 33 | } 34 | 35 | // vim: et:sw=4:ts=4 36 | -------------------------------------------------------------------------------- /source/src/Z80ExAfAf.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80ExAfAf.h 19 | * 20 | * Instruction: EX AF, AF' 21 | * 22 | * Encoding: 00 001 000 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | */ 27 | 28 | bool z80ExAfAf() 29 | { 30 | acc.w = af.w; 31 | af.w = af_.w; 32 | af_.w = acc.w; 33 | 34 | flg = 0; 35 | prefix = PREFIX_NO; 36 | return true; 37 | } 38 | 39 | // vim: et:sw=4:ts=4 40 | -------------------------------------------------------------------------------- /source/src/Z80ExDeHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80ExDeHl.h 19 | * 20 | * Instruction: EX DE, HL 21 | * 22 | * Encoding: 11 101 011 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | */ 27 | 28 | bool z80ExDeHl() 29 | { 30 | acc.w = de.w; 31 | de.w = hl.w; 32 | hl.w = acc.w; 33 | 34 | flg = 0; 35 | prefix = PREFIX_NO; 36 | return true; 37 | } 38 | 39 | // vim: et:sw=4:ts=4 40 | -------------------------------------------------------------------------------- /source/src/Z80Ccf.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Ccf.h 19 | * 20 | * Instruction: CCF 21 | * 22 | */ 23 | 24 | bool z80Ccf() 25 | { 26 | flg = ((af.b.l ^ flg) | af.b.h) & (FLAG_5 | FLAG_3); 27 | flg |= af.b.l & (FLAG_S | FLAG_Z | FLAG_PV | FLAG_C); 28 | flg |= ((flg & FLAG_C) << 4) & FLAG_H; 29 | flg ^= FLAG_C; 30 | af.b.l = flg; 31 | prefix = PREFIX_NO; 32 | return true; 33 | } 34 | 35 | // vim: et:sw=4:ts=4 36 | -------------------------------------------------------------------------------- /source/src/Z80Im.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Im.h 19 | * 20 | * Instruction: IM 0 21 | * Instruction: IM 1 22 | * Instruction: IM 2 23 | * 24 | */ 25 | 26 | bool z80Im() 27 | { 28 | if ((y & 0x02) == 0x00) 29 | im = 0; 30 | else if ((y & 0x01) == 0x00) 31 | im = 1; 32 | else 33 | im = 2; 34 | 35 | flg = 0; 36 | prefix = PREFIX_NO; 37 | return true; 38 | } 39 | 40 | // vim: et:sw=4:ts=4 41 | -------------------------------------------------------------------------------- /source/src/Z80Register.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Register 19 | * 20 | * Each of the 16-bit groups of two 8-bit registers in the Z80. 21 | * 22 | */ 23 | 24 | #include 25 | 26 | using namespace std; 27 | 28 | struct Z80Pair 29 | { 30 | #if SPECIDE_BYTE_ORDER == 1 31 | uint8_t h; 32 | uint8_t l; 33 | #else 34 | uint8_t l; 35 | uint8_t h; 36 | #endif 37 | }; 38 | 39 | union Z80Register 40 | { 41 | uint16_t w; 42 | Z80Pair b; 43 | }; 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80LdRegReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegReg.h 19 | * 20 | * Instruction: LD r, s 21 | * 22 | * Encoding: 01 rrr sss 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegReg() 39 | { 40 | *(reg8[y]) = *(reg8[z]); 41 | flg = 0; 42 | prefix = PREFIX_NO; 43 | return true; 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80SetNReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SetNReg.h 19 | * 20 | * Instruction: SET n, r 21 | * 22 | * Encoding: 11 001 011 11 bbb rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80SetNReg() 39 | { 40 | *reg8[z] |= (1 << y); 41 | 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | } 46 | 47 | // vim: et:sw=4:ts=4 48 | -------------------------------------------------------------------------------- /source/src/Z80Exx.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Exx.h 19 | * 20 | * Instruction: EXX 21 | * 22 | * Encoding: 11 011 001 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | */ 27 | 28 | bool z80Exx() 29 | { 30 | acc.w = bc.w; 31 | bc.w = bc_.w; 32 | bc_.w = acc.w; 33 | 34 | acc.w = de.w; 35 | de.w = de_.w; 36 | de_.w = acc.w; 37 | 38 | acc.w = hl.w; 39 | hl.w = hl_.w; 40 | hl_.w = acc.w; 41 | 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | } 46 | 47 | // vim: et:sw=4:ts=4 48 | -------------------------------------------------------------------------------- /source/src/Z80ResNReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80ResNReg.h 19 | * 20 | * Instruction: RES n, r 21 | * 22 | * Encoding: 11 001 011 10 bbb rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80ResNReg() 39 | { 40 | *reg8[z] &= ~(1 << y); 41 | 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | } 46 | 47 | // vim: et:sw=4:ts=4 48 | -------------------------------------------------------------------------------- /source/src/Z80LdRegXRegX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegXRegX.h 19 | * 20 | * Instruction: LD r, s (DD-Prefixed) 21 | * 22 | * Encoding: 11 011 101 01 rrr sss 23 | * M Cycles: 2 (DD, OCF) 24 | * T States: 8 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * IXh 100 33 | * IXl 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegXRegX() 39 | { 40 | *(regx8[y]) = *(regx8[z]); 41 | flg = 0; 42 | prefix = PREFIX_NO; 43 | return true; 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80LdRegYRegY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegYRegY.h 19 | * 20 | * Instruction: LD r, s (FD-Prefixed) 21 | * 22 | * Encoding: 11 111 101 01 rrr sss 23 | * M Cycles: 2 (FD, OCF) 24 | * T States: 8 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * IYh 100 33 | * IYl 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegYRegY() 39 | { 40 | *(regy8[y]) = *(regy8[z]); 41 | flg = 0; 42 | prefix = PREFIX_NO; 43 | return true; 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80DecRegPX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecRegPX.h 19 | * 20 | * Instruction: DEC rx 21 | * 22 | */ 23 | 24 | bool z80DecRegPX() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | case 1: 30 | return false; 31 | 32 | case 2: 33 | --*regpx[p]; 34 | flg = 0; 35 | prefix = PREFIX_NO; 36 | return true; 37 | 38 | default: // Should not happen 39 | assert(false); 40 | return true; 41 | } 42 | } 43 | 44 | // vim: et:sw=4:ts=4 45 | -------------------------------------------------------------------------------- /source/src/Z80DecRegPY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecRegPY.h 19 | * 20 | * Instruction: DEC ry 21 | * 22 | */ 23 | 24 | bool z80DecRegPY() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | case 1: 30 | return false; 31 | 32 | case 2: 33 | --*regpy[p]; 34 | flg = 0; 35 | prefix = PREFIX_NO; 36 | return true; 37 | 38 | default: // Should not happen 39 | assert(false); 40 | return true; 41 | } 42 | } 43 | 44 | // vim: et:sw=4:ts=4 45 | -------------------------------------------------------------------------------- /source/src/Z80IncRegPX.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncRegPX.h 19 | * 20 | * Instruction: INC rx 21 | * 22 | */ 23 | 24 | bool z80IncRegPX() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | case 1: 30 | return false; 31 | 32 | case 2: 33 | ++*regpx[p]; 34 | flg = 0; 35 | prefix = PREFIX_NO; 36 | return true; 37 | 38 | default: // Should not happen 39 | assert(false); 40 | return true; 41 | } 42 | } 43 | 44 | // vim: et:sw=4:ts=4 45 | -------------------------------------------------------------------------------- /source/src/Z80IncRegPY.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncRegPY.h 19 | * 20 | * Instruction: INC ry 21 | * 22 | */ 23 | 24 | bool z80IncRegPY() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | case 1: 30 | return false; 31 | 32 | case 2: 33 | ++*regpy[p]; 34 | flg = 0; 35 | prefix = PREFIX_NO; 36 | return true; 37 | 38 | default: // Should not happen 39 | assert(false); 40 | return true; 41 | } 42 | } 43 | 44 | // vim: et:sw=4:ts=4 45 | -------------------------------------------------------------------------------- /source/src/Z80Rlca.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Rlca.h 19 | * 20 | * Instruction: RLCA 21 | * 22 | * Encoding: 00 000 111 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | * Flags: **5*3*0C 27 | * - MSB is copied into LSB and into CF. 28 | * 29 | */ 30 | 31 | bool z80Rlca() 32 | { 33 | acc.w = af.b.h << 1; 34 | af.b.h = acc.b.l | acc.b.h; 35 | flg = af.b.l & (FLAG_S | FLAG_Z | FLAG_PV); 36 | flg |= af.b.h & (FLAG_5 | FLAG_3 | FLAG_C); 37 | af.b.l = flg; 38 | prefix = PREFIX_NO; 39 | return true; 40 | } 41 | 42 | // vim: et:sw=4:ts=4 43 | -------------------------------------------------------------------------------- /source/tst/TZXFileTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE TZXFile test 3 | #include 4 | //#include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "TZXFile.h" 11 | 12 | using namespace std; 13 | 14 | BOOST_AUTO_TEST_CASE(constructors_test) 15 | { 16 | TZXFile tzxFile; 17 | tzxFile.load(boost::unit_test::framework::master_test_suite().argv[1]); 18 | BOOST_CHECK_EQUAL(tzxFile.fileData[0], 'Z'); 19 | BOOST_CHECK_EQUAL(tzxFile.fileData[1], 'X'); 20 | BOOST_CHECK_EQUAL(tzxFile.fileData[2], 'T'); 21 | BOOST_CHECK_EQUAL(tzxFile.fileData[3], 'a'); 22 | BOOST_CHECK_EQUAL(tzxFile.fileData[4], 'p'); 23 | BOOST_CHECK_EQUAL(tzxFile.fileData[5], 'e'); 24 | BOOST_CHECK_EQUAL(tzxFile.fileData[6], '!'); 25 | BOOST_CHECK_EQUAL(tzxFile.fileData[7], 0x1A); 26 | } 27 | 28 | BOOST_AUTO_TEST_CASE(block_parsing_test) 29 | { 30 | vector pulseData; 31 | set indexData; 32 | set stopData; 33 | set stopIf48K; 34 | 35 | TZXFile tzx; 36 | tzx.load(boost::unit_test::framework::master_test_suite().argv[1]); 37 | tzx.parse(pulseData, indexData, stopData, stopIf48K); 38 | } 39 | 40 | // EOF 41 | // vim: et:sw=4:ts=4 42 | 43 | -------------------------------------------------------------------------------- /source/src/Z80Rla.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Rla.h 19 | * 20 | * Instruction: RLA 21 | * 22 | * Encoding: 00 010 111 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | * Flags: **5*3*0C 27 | * - MSB is copied into CF. CF is copied into LSB. 28 | * 29 | */ 30 | 31 | bool z80Rla() 32 | { 33 | acc.w = af.b.h << 1; 34 | af.b.h = acc.b.l | (af.b.l & FLAG_C); 35 | flg = af.b.l & (FLAG_S | FLAG_Z | FLAG_PV); 36 | flg |= af.b.h & (FLAG_5 | FLAG_3); 37 | flg |= acc.b.h & FLAG_C; 38 | af.b.l = flg; 39 | prefix = PREFIX_NO; 40 | return true; 41 | } 42 | 43 | // vim: et:sw=4:ts=4 44 | -------------------------------------------------------------------------------- /source/src/Z80CpByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80CpByte.h 19 | * 20 | * Instruction: CP n 21 | * 22 | */ 23 | 24 | bool z80CpByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | af.b.l = flg = cpFlags[af.b.h][iReg.b.h]; 35 | prefix = PREFIX_NO; 36 | return true; 37 | 38 | default: // Should not happen 39 | assert(false); 40 | return true; 41 | } 42 | } 43 | 44 | // vim: et:sw=4:ts=4 45 | -------------------------------------------------------------------------------- /source/src/Z80CpPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80CpPtrHl.h 19 | * 20 | * Instruction: CP (HL) 21 | * 22 | */ 23 | 24 | bool z80CpPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | af.b.l = flg = cpFlags[af.b.h][iReg.b.h]; 35 | prefix = PREFIX_NO; 36 | return true; 37 | 38 | default: // Should not happen 39 | assert(false); 40 | return true; 41 | } 42 | } 43 | 44 | // vim: et:sw=4:ts=4 45 | -------------------------------------------------------------------------------- /source/src/Z80Rrca.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Rrca.h 19 | * 20 | * Instruction: RRCA 21 | * 22 | * Encoding: 00 001 111 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | * Flags: **5*3*0C 27 | * - LSB is copied into MSB and into CF. 28 | * 29 | */ 30 | 31 | bool z80Rrca() 32 | { 33 | acc.b.h = af.b.h & 0x01; 34 | acc.b.l = af.b.h; 35 | flg = af.b.l & (FLAG_S | FLAG_Z | FLAG_PV); 36 | flg |= acc.b.h & FLAG_C; 37 | acc.w >>= 1; 38 | af.b.h = acc.b.l; 39 | flg |= af.b.h & (FLAG_5 | FLAG_3); 40 | af.b.l = flg; 41 | prefix = PREFIX_NO; 42 | return true; 43 | } 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80XXCBPrefixed.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80XXCBPrefixed.h 19 | * 20 | * Z80 instruction table for DDCB and FDCB-prefixed opcodes. 21 | * The type of addressing is determined by the prefix. 22 | * 23 | */ 24 | 25 | #include "Z80Nop.h" 26 | 27 | #include "Z80RlcPtrIxIy.h" 28 | #include "Z80RrcPtrIxIy.h" 29 | #include "Z80RlPtrIxIy.h" 30 | #include "Z80RrPtrIxIy.h" 31 | #include "Z80SlaPtrIxIy.h" 32 | #include "Z80SraPtrIxIy.h" 33 | #include "Z80SllPtrIxIy.h" 34 | #include "Z80SrlPtrIxIy.h" 35 | 36 | #include "Z80BitNPtrIxIy.h" 37 | #include "Z80ResNPtrIxIy.h" 38 | #include "Z80SetNPtrIxIy.h" 39 | 40 | // vim: et:sw=4:ts=4 41 | -------------------------------------------------------------------------------- /source/src/Z80SrlReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SrlReg.h 19 | * 20 | * Instruction: SRL r 21 | * 22 | * Encoding: 11 001 011 00 111 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - 0 is shifted into MSB. 38 | * 39 | */ 40 | 41 | bool z80SrlReg() 42 | { 43 | af.b.l = flg = srlFlags[*reg8[z]]; 44 | acc.w = *reg8[z] >> 1; 45 | *reg8[z] = acc.b.l; 46 | prefix = PREFIX_NO; 47 | return true; 48 | } 49 | 50 | // vim: et:sw=4:ts=4 51 | -------------------------------------------------------------------------------- /source/src/Z80Rra.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Rra.h 19 | * 20 | * Instruction: RRA 21 | * 22 | * Encoding: 00 011 111 23 | * M Cycles: 1 (OCF) 24 | * T States: 4 25 | * 26 | * Flags: **5*3*0C 27 | * - LSB is copied into CF. CF is copied into MSB. 28 | * 29 | */ 30 | 31 | bool z80Rra() 32 | { 33 | acc.b.l = af.b.h; 34 | acc.b.h = af.b.l & FLAG_C; 35 | flg = af.b.l & (FLAG_S | FLAG_Z | FLAG_PV); 36 | flg |= af.b.h & FLAG_C; 37 | acc.w >>= 1; 38 | af.b.h = acc.b.l; 39 | flg |= af.b.h & (FLAG_5 | FLAG_3); 40 | af.b.l = flg; 41 | prefix = PREFIX_NO; 42 | return true; 43 | } 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80SlaReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SlaReg.h 19 | * 20 | * Instruction: SLA r 21 | * 22 | * Encoding: 11 001 011 00 100 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - 0 is shifted into the LSB. 38 | * 39 | */ 40 | 41 | bool z80SlaReg() 42 | { 43 | acc.w = *reg8[z] << 1; 44 | af.b.l = flg = slaFlags[*reg8[z]]; 45 | *reg8[z] = acc.b.l; 46 | prefix = PREFIX_NO; 47 | return true; 48 | } 49 | 50 | // vim: et:sw=4:ts=4 51 | -------------------------------------------------------------------------------- /source/src/Z80LdSpHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdSpHl.h 19 | * 20 | * Instruction: LD SP, HL 21 | * 22 | * Encoding: 11 111 001 23 | * M Cycles: 1 (OCF) 24 | * T States: 6 25 | * 26 | */ 27 | 28 | bool z80LdSpHl() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | case 1: 34 | return false; 35 | 36 | case 2: 37 | sp.w = hl.w; 38 | flg = 0; 39 | prefix = PREFIX_NO; 40 | return true; 41 | 42 | default: // Should not happen 43 | assert(false); 44 | return true; 45 | 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/tst/MemoryTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE Memory test 3 | #include 4 | //#include 5 | 6 | #include 7 | #include 8 | 9 | #include "Memory.h" 10 | 11 | using namespace std; 12 | 13 | BOOST_AUTO_TEST_CASE(constructors_test) 14 | { 15 | // Initialize a 8-bit 16kB RAM. 16 | Memory mem0(14, false); 17 | BOOST_CHECK_EQUAL(mem0.size, static_cast(0x4000)); 18 | 19 | // Memory should not be modified until clock happens. 20 | mem0.a = 0x1234; 21 | mem0.d = 0xAA; 22 | mem0.wr_ = true; 23 | mem0.rd_ = true; 24 | mem0.as_ = true; 25 | BOOST_CHECK_EQUAL(mem0.memory[0x1234], 0x00); 26 | 27 | // Clock edges make memory work. 28 | mem0.as_ = false; mem0.wr_ = true; mem0.rd_ = true; mem0.clock(); 29 | mem0.as_ = false; mem0.wr_ = false; mem0.rd_ = true; mem0.clock(); 30 | BOOST_CHECK_EQUAL(mem0.memory[0x1234], 0xAA); 31 | 32 | // Read test. 33 | mem0.d = 0x12; 34 | mem0.a = 0x1234; 35 | mem0.as_ = false; mem0.wr_ = true; mem0.rd_ = true; mem0.clock(); 36 | mem0.as_ = false; mem0.wr_ = true; mem0.rd_ = false; mem0.clock(); 37 | BOOST_CHECK_EQUAL(mem0.memory[0x1234], 0xAA); 38 | BOOST_CHECK_EQUAL(mem0.d, 0xAA); 39 | } 40 | 41 | // EOF 42 | // vim: et:sw=4:ts=4 43 | -------------------------------------------------------------------------------- /source/src/Z80SllReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SllReg.h 19 | * 20 | * Instruction: SLL r 21 | * 22 | * Encoding: 11 001 011 00 110 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - 1 is shifted into the LSB. 38 | * 39 | */ 40 | 41 | bool z80SllReg() 42 | { 43 | acc.w = (*reg8[z] << 1) | 0x01; 44 | af.b.l = flg = sllFlags[*reg8[z]]; 45 | *reg8[z] = acc.b.l; 46 | prefix = PREFIX_NO; 47 | return true; 48 | } 49 | 50 | // vim: et:sw=4:ts=4 51 | -------------------------------------------------------------------------------- /source/src/Z80SubByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SubByte.h 19 | * 20 | * Instruction: SUB n 21 | * 22 | */ 23 | 24 | bool z80SubByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | af.b.l = flg = subFlags[0][af.b.h][iReg.b.h]; 35 | af.b.h -= iReg.b.h; 36 | prefix = PREFIX_NO; 37 | return true; 38 | 39 | default: // Should not happen 40 | assert(false); 41 | return true; 42 | } 43 | } 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80AddByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AddByte.h 19 | * 20 | * Instruction: ADD A, n 21 | * 22 | */ 23 | 24 | bool z80AddByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | af.b.l = flg = addFlags[0][af.b.h][iReg.b.h]; 35 | af.b.h += iReg.b.h; 36 | prefix = PREFIX_NO; 37 | return true; 38 | 39 | default: // Should not happen 40 | assert(false); 41 | return true; 42 | } 43 | } 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80SubPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SubPtrHl.h 19 | * 20 | * Instruction: SUB (HL) 21 | * 22 | */ 23 | 24 | bool z80SubPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | af.b.l = flg = subFlags[0][af.b.h][iReg.b.h]; 35 | af.b.h -= iReg.b.h; 36 | prefix = PREFIX_NO; 37 | return true; 38 | 39 | default: // Should not happen 40 | assert(false); 41 | return true; 42 | } 43 | } 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80AddPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AddPtrHl.h 19 | * 20 | * Instruction: ADD A, (HL) 21 | * 22 | */ 23 | 24 | bool z80AddPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | af.b.l = flg = addFlags[0][af.b.h][iReg.b.h]; 35 | af.b.h += iReg.b.h; 36 | prefix = PREFIX_NO; 37 | return true; 38 | 39 | default: // Should not happen 40 | assert(false); 41 | return true; 42 | } 43 | } 44 | 45 | // vim: et:sw=4:ts=4 46 | -------------------------------------------------------------------------------- /source/src/Z80LdSpIx.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdSpIx.h 19 | * 20 | * Instruction: LD SP, IX 21 | * 22 | * Encoding: 11 011 101 11 111 001 23 | * M Cycles: 2 (DD, OCF) 24 | * T States: 10 25 | * 26 | */ 27 | 28 | bool z80LdSpIx() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | case 1: 34 | return false; 35 | 36 | case 2: 37 | sp.w = ix.w; 38 | flg = 0; 39 | prefix = PREFIX_NO; 40 | return true; 41 | 42 | default: // Should not happen 43 | assert(false); 44 | return true; 45 | 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/src/Z80LdSpIy.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdSpIy.h 19 | * 20 | * Instruction: LD SP, IY 21 | * 22 | * Encoding: 11 111 101 11 111 001 23 | * M Cycles: 2 (FD, OCF) 24 | * T States: 10 25 | * 26 | */ 27 | 28 | bool z80LdSpIy() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | case 1: 34 | return false; 35 | 36 | case 2: 37 | sp.w = iy.w; 38 | flg = 0; 39 | prefix = PREFIX_NO; 40 | return true; 41 | 42 | default: // Should not happen 43 | assert(false); 44 | return true; 45 | 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/src/Z80RlcReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80RlcReg.h 19 | * 20 | * Instruction: RLC r 21 | * 22 | * Encoding: 11 001 011 00 000 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - MSB is copied into LSB and into CF. 38 | * 39 | */ 40 | 41 | bool z80RlcReg() 42 | { 43 | af.b.l = flg = rlcFlags[*reg8[z]]; 44 | acc.w = *reg8[z] << 1; 45 | *reg8[z] = acc.b.l | acc.b.h; 46 | 47 | prefix = PREFIX_NO; 48 | return true; 49 | } 50 | 51 | // vim: et:sw=4:ts=4 52 | -------------------------------------------------------------------------------- /source/src/Z80LdIA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdIA.h 19 | * 20 | * Instruction: LD I, A 21 | * 22 | * Encoding: 11 101 101 01 000 111 23 | * M Cycles: 2 (ED, OCF) 24 | * T States: 9 25 | * 26 | */ 27 | 28 | bool z80LdIA() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memAddrMode = 0x00000000; 34 | return false; 35 | 36 | case 1: 37 | ir.b.h = af.b.h; 38 | flg = 0; 39 | prefix = PREFIX_NO; 40 | return true; 41 | 42 | default: // Should not happen 43 | assert(false); 44 | return true; 45 | 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/src/Z80LdRA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRA.h 19 | * 20 | * Instruction: LD R, A 21 | * 22 | * Encoding: 11 101 101 01 001 111 23 | * M Cycles: 2 (ED, OCF) 24 | * T States: 9 25 | * 26 | */ 27 | 28 | bool z80LdRA() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memAddrMode = 0x00000000; 34 | return false; 35 | 36 | case 1: 37 | ir.b.l = af.b.h; 38 | flg = 0; 39 | prefix = PREFIX_NO; 40 | return true; 41 | 42 | default: // Should not happen 43 | assert(false); 44 | return true; 45 | 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/tst/DSKFileTest.cc: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_DYN_LINK 2 | #define BOOST_TEST_MODULE DSKFile test 3 | #include 4 | //#include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "DSKFile.h" 11 | 12 | using namespace std; 13 | 14 | BOOST_AUTO_TEST_CASE(constructors_test) 15 | { 16 | DSKFile file; 17 | file.load(boost::unit_test::framework::master_test_suite().argv[1]); 18 | 19 | if (file.stdMagicOk) { 20 | cout << "Standard DSK file detected." << endl; 21 | } else if (file.extMagicOk) { 22 | cout << "Extended DSK file detected." << endl; 23 | } else { 24 | cout << "Not a valid DSK file." << endl; 25 | } 26 | 27 | for (uint32_t ii = 0; ii < file.trackSizeTable.size(); ++ii) { 28 | cout << "Track " << ii << ": " << file.trackSizeTable[ii] << " - "; 29 | for (uint32_t jj = 0; jj < file.tracks[ii].sectors.size(); ++jj) { 30 | cout << static_cast(file.tracks[ii].sectors[jj].sectorSize) << " "; 31 | } 32 | cout << " - "; 33 | for (uint32_t jj = 0; jj < file.tracks[ii].sectors.size(); ++jj) { 34 | cout << static_cast(file.tracks[ii].sectors[jj].sectorLength) << " "; 35 | } 36 | cout << endl; 37 | } 38 | } 39 | 40 | // EOF 41 | // vim: et:sw=4:ts=4 42 | 43 | -------------------------------------------------------------------------------- /source/src/Z80OrByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OrByte.h 19 | * 20 | * Instruction: OR n 21 | * 22 | */ 23 | 24 | bool z80OrByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | // Calculate the result. 35 | af.b.l = flg = orFlags[af.b.h][iReg.b.h]; 36 | af.b.h |= iReg.b.h; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80AndByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AndByte.h 19 | * 20 | * Instruction: AND n 21 | * 22 | */ 23 | 24 | bool z80AndByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | // Calculate the result. 35 | af.b.l = flg = andFlags[af.b.h][iReg.b.h]; 36 | af.b.h &= iReg.b.h; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80OrPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OrPtrHl.h 19 | * 20 | * Instruction: OR (HL) 21 | * 22 | */ 23 | 24 | bool z80OrPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | // Calculate the result. 35 | af.b.l = flg = orFlags[af.b.h][iReg.b.h]; 36 | af.b.h |= iReg.b.h; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80RlReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80RlReg.h 19 | * 20 | * Instruction: RL r 21 | * 22 | * Encoding: 11 001 011 00 010 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - MSB is copied into CF. CF is copied into LSB. 38 | * 39 | */ 40 | 41 | bool z80RlReg() 42 | { 43 | acc.w = (*reg8[z] << 1) | (af.b.l & FLAG_C); 44 | af.b.l = flg = rlFlags[af.b.l & FLAG_C][*reg8[z]]; 45 | *reg8[z] = acc.b.l; 46 | prefix = PREFIX_NO; 47 | return true; 48 | } 49 | 50 | // vim: et:sw=4:ts=4 51 | -------------------------------------------------------------------------------- /source/src/Z80XorByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80XorByte.h 19 | * 20 | * Instruction: XOR n 21 | * 22 | */ 23 | 24 | bool z80XorByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | // Calculate the result. 35 | af.b.l = flg = xorFlags[af.b.h][iReg.b.h]; 36 | af.b.h ^= iReg.b.h; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80AndPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AndPtrHl.h 19 | * 20 | * Instruction: AND (HL) 21 | * 22 | */ 23 | 24 | bool z80AndPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | // Calculate the result. 35 | af.b.l = flg = andFlags[af.b.h][iReg.b.h]; 36 | af.b.h &= iReg.b.h; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80Ret.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Ret.h 19 | * 20 | * Instruction: RET 21 | * 22 | */ 23 | 24 | bool z80Ret() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 2; 30 | memWrCycles = 0; 31 | memAddrMode = 0x000000BB; 32 | return true; 33 | 34 | case 1: 35 | return true; 36 | 37 | case 2: 38 | pc.w = wz.w = iReg.w; 39 | flg = 0; 40 | prefix = PREFIX_NO; 41 | return true; 42 | 43 | default: // Should not happen 44 | assert(false); 45 | return true; 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/src/Z80XorPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80XorPtrHl.h 19 | * 20 | * Instruction: XOR (HL) 21 | * 22 | */ 23 | 24 | bool z80XorPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | // Calculate the result. 35 | af.b.l = flg = xorFlags[af.b.h][iReg.b.h]; 36 | af.b.h ^= iReg.b.h; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80JpWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80JpWord.h 19 | * 20 | * JP nn Instruction. 21 | * 22 | */ 23 | 24 | bool z80JpWord() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 2; 30 | memWrCycles = 0; 31 | memAddrMode = 0x00000011; 32 | return true; 33 | 34 | case 1: 35 | return true; 36 | 37 | case 2: 38 | pc.w = wz.w = iReg.w; 39 | flg = 0; 40 | prefix = PREFIX_NO; 41 | return true; 42 | 43 | default: // Should not happen 44 | assert(false); 45 | return true; 46 | } 47 | } 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/src/Z80AdcByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AdcByte.h 19 | * 20 | * Instruction: ADC A, n 21 | * 22 | */ 23 | 24 | bool z80AdcByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | acc.b.l = af.b.l & FLAG_C; 35 | af.b.l = flg = addFlags[acc.b.l][af.b.h][iReg.b.h]; 36 | af.b.h += iReg.b.h + acc.b.l; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80RrcReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80RrcReg.h 19 | * 20 | * Instruction: RRC r 21 | * 22 | * Encoding: 11 001 011 00 001 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - LSB is copied into MSB and into CF. 38 | * 39 | */ 40 | 41 | bool z80RrcReg() 42 | { 43 | af.b.l = flg = rrcFlags[*reg8[z]]; 44 | 45 | acc.b.l = *reg8[z]; 46 | acc.b.h = acc.b.l & 0x01; 47 | acc.w >>= 1; 48 | 49 | *reg8[z] = acc.b.l; 50 | 51 | prefix = PREFIX_NO; 52 | return true; 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Z80SbcByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SbcByte.h 19 | * 20 | * Instruction: SBC A, n 21 | * 22 | */ 23 | 24 | bool z80SbcByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | acc.b.l = af.b.l & FLAG_C; 35 | af.b.l = flg = subFlags[acc.b.l][af.b.h][iReg.b.h]; 36 | af.b.h -= iReg.b.h + acc.b.l; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80AdcPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80AdcPtrHl.h 19 | * 20 | * Instruction: ADC A, (HL) 21 | * 22 | */ 23 | 24 | bool z80AdcPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | acc.b.l = af.b.l & FLAG_C; 35 | af.b.l = flg = addFlags[acc.b.l][af.b.h][iReg.b.h]; 36 | af.b.h += iReg.b.h + acc.b.l; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80SbcPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SbcPtrHl.h 19 | * 20 | * Instruction: SBC A, (HL) 21 | * 22 | */ 23 | 24 | bool z80SbcPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000002; 31 | return true; 32 | 33 | case 1: 34 | acc.b.l = af.b.l & FLAG_C; 35 | af.b.l = flg = subFlags[acc.b.l][af.b.h][iReg.b.h]; 36 | af.b.h -= iReg.b.h + acc.b.l; 37 | prefix = PREFIX_NO; 38 | return true; 39 | 40 | default: // Should not happen 41 | assert(false); 42 | return true; 43 | } 44 | } 45 | 46 | // vim: et:sw=4:ts=4 47 | -------------------------------------------------------------------------------- /source/src/Z80SraReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SraReg.h 19 | * 20 | * Instruction: SRA r 21 | * 22 | * Encoding: 11 001 011 00 101 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - MSB is shifted into MSB again. (Sign extension). 38 | * 39 | */ 40 | 41 | bool z80SraReg() 42 | { 43 | af.b.l = flg = sraFlags[*reg8[z]]; 44 | acc.b.l = *reg8[z]; 45 | acc.b.h = (acc.b.l & 0x80) ? 0x01 : 0x00; 46 | acc.w >>= 1; 47 | *reg8[z] = acc.b.l; 48 | prefix = PREFIX_NO; 49 | return true; 50 | } 51 | 52 | // vim: et:sw=4:ts=4 53 | -------------------------------------------------------------------------------- /source/src/Z80RrReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80RrReg.h 19 | * 20 | * Instruction: RR r 21 | * 22 | * Encoding: 11 001 011 00 011 rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * r rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | * Flags: SZ503P0C 37 | * - LSB is copied into CF. CF is copied into MSB. 38 | * 39 | */ 40 | 41 | bool z80RrReg() 42 | { 43 | acc.b.l = *reg8[z]; 44 | acc.b.h = af.b.l & FLAG_C; 45 | acc.w >>= 1; 46 | 47 | af.b.l = flg = rrFlags[af.b.l & FLAG_C][*reg8[z]]; 48 | 49 | *reg8[z] = acc.b.l; 50 | 51 | prefix = PREFIX_NO; 52 | return true; 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Z80LdAPtrBc.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdAPtrBc.h 19 | * 20 | * Instruction: LD A, (BC) 21 | * 22 | * Encoding: 00 001 010 23 | * M Cycles: 2 (OCF, MRB) 24 | * T States: 7 25 | * 26 | */ 27 | 28 | bool z80LdAPtrBc() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | memAddrMode = 0x00000003; 35 | 36 | wz.w = bc.w + 1; 37 | return true; 38 | 39 | case 1: 40 | af.b.h = iReg.b.h; 41 | flg = 0; 42 | prefix = PREFIX_NO; 43 | return true; 44 | 45 | default: // Should not happen 46 | assert(false); 47 | return true; 48 | } 49 | } 50 | 51 | // vim: et:sw=4:ts=4 52 | -------------------------------------------------------------------------------- /source/src/Z80LdAPtrDe.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdAPtrDe.h 19 | * 20 | * Instruction: LD A, (DE) 21 | * 22 | * Encoding: 00 011 010 23 | * M Cycles: 2 (OCF, MRB) 24 | * T States: 7 25 | * 26 | */ 27 | 28 | bool z80LdAPtrDe() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | memAddrMode = 0x00000004; 35 | 36 | wz.w = de.w + 1; 37 | return true; 38 | 39 | case 1: 40 | af.b.h = iReg.b.h; 41 | flg = 0; 42 | prefix = PREFIX_NO; 43 | return true; 44 | 45 | default: // Should not happen 46 | assert(false); 47 | return true; 48 | } 49 | } 50 | 51 | // vim: et:sw=4:ts=4 52 | -------------------------------------------------------------------------------- /source/src/Z80RetI.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80RetI.h 19 | * 20 | * Instruction: RETI 21 | * Instruction: RETN 22 | * 23 | */ 24 | 25 | bool z80RetI() 26 | { 27 | switch (executionStep) 28 | { 29 | case 0: 30 | memRdCycles = 2; 31 | memAddrMode = 0x000000BB; 32 | return true; 33 | 34 | case 1: 35 | return true; 36 | 37 | case 2: 38 | iff = ((iff & IFF2) >> 2) | (iff & IFF2); 39 | pc.w = wz.w = iReg.w; 40 | flg = 0; 41 | prefix = PREFIX_NO; 42 | return true; 43 | 44 | default: // Should not happen 45 | assert(false); 46 | return true; 47 | } 48 | } 49 | 50 | // vim: et:sw=4:ts=4 51 | -------------------------------------------------------------------------------- /source/src/SNAFile.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2024. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "SaveState.h" 22 | 23 | /** SNAFile.h 24 | * 25 | * SNA file format implementation. 26 | * 27 | * This class loads a SNA snapshot, validates it and applies it to the emulator. 28 | */ 29 | 30 | 31 | class SNAFile { 32 | 33 | public: 34 | SNAFile() {} 35 | 36 | std::string name; 37 | uint32_t dataIndex = 0; 38 | 39 | std::vector fileData; 40 | SaveState state; 41 | 42 | void load(std::string const& fileName); 43 | bool parse(); 44 | void apply(); 45 | void write(); 46 | 47 | bool parseHeader(); 48 | bool fillMemory(); 49 | }; 50 | 51 | // vim: et:sw=4:ts=4: 52 | -------------------------------------------------------------------------------- /source/src/Z80DecRegP.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecRegP.h 19 | * 20 | * Instruction: DEC rr 21 | * 22 | * Encoding: 00 rr1 011 23 | * M Cycles: 1 (OCF(6)) 24 | * T States: 6 25 | * 26 | * Reg rr 27 | * ---- ---- 28 | * BC 00 29 | * DE 01 30 | * HL 10 31 | * SP 11 32 | * 33 | */ 34 | 35 | bool z80DecRegP() 36 | { 37 | switch (executionStep) 38 | { 39 | case 0: 40 | case 1: 41 | return false; 42 | 43 | case 2: 44 | --*regp[p]; 45 | flg = 0; 46 | prefix = PREFIX_NO; 47 | return true; 48 | 49 | default: // Should not happen 50 | assert(false); 51 | return true; 52 | } 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Z80IncRegP.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncRegP.h 19 | * 20 | * Instruction: INC rr 21 | * 22 | * Encoding: 00 rr0 011 23 | * M Cycles: 1 (OCF(6)) 24 | * T States: 6 25 | * 26 | * Reg rr 27 | * ---- ---- 28 | * BC 00 29 | * DE 01 30 | * HL 10 31 | * SP 11 32 | * 33 | */ 34 | 35 | bool z80IncRegP() 36 | { 37 | switch (executionStep) 38 | { 39 | case 0: 40 | case 1: 41 | return false; 42 | 43 | case 2: 44 | ++*regp[p]; 45 | flg = 0; 46 | prefix = PREFIX_NO; 47 | return true; 48 | 49 | default: // Should not happen 50 | assert(false); 51 | return true; 52 | } 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Z80BitNReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80BitNReg.h 19 | * 20 | * Instruction: BIT n, r 21 | * 22 | * Encoding: 11 001 011 01 bbb rrr 23 | * M Cycles: 2 (OCF, OCF) 24 | * T States: 8 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80BitNReg() 39 | { 40 | acc.b.l = *reg8[z]; 41 | 42 | flg = af.b.l & FLAG_C; 43 | flg |= FLAG_H; 44 | flg |= acc.b.l & (FLAG_5 | FLAG_3); 45 | 46 | acc.b.l &= (1 << y); 47 | flg |= acc.b.l & FLAG_S; 48 | flg |= (acc.b.l != 0x00) ? 0x00 : (FLAG_Z | FLAG_PV); 49 | 50 | af.b.l = flg; 51 | prefix = PREFIX_NO; 52 | return true; 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Z80PopIx.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PopIx.h 19 | * 20 | * Instruction: POP IX 21 | * 22 | * Encoding: 11 011 101 11 100 001 23 | * M Cycles: 4 (DD, OCF, MRL, MRH) 24 | * T States: 15 25 | * 26 | */ 27 | 28 | bool z80PopIx() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 2; 34 | memAddrMode = 0x000000BB; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | ix.w = iReg.w; 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | 46 | default: // Should not happen 47 | assert(false); 48 | return true; 49 | } 50 | } 51 | 52 | // vim: et:sw=4:ts=4 53 | -------------------------------------------------------------------------------- /source/src/Z80PopIy.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PopIy.h 19 | * 20 | * Instruction: POP IY 21 | * 22 | * Encoding: 11 111 101 11 100 001 23 | * M Cycles: 4 (FD, OCF, MRL, MRH) 24 | * T States: 15 25 | * 26 | */ 27 | 28 | bool z80PopIy() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 2; 34 | memAddrMode = 0x000000BB; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | iy.w = iReg.w; 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | 46 | default: // Should not happen 47 | assert(false); 48 | return true; 49 | } 50 | } 51 | 52 | // vim: et:sw=4:ts=4 53 | -------------------------------------------------------------------------------- /source/src/TAPFile.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2021. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | 27 | /** TAPFile.h 28 | * 29 | * TAP file format container. 30 | * 31 | * This class generates data suitable for the Tape class. 32 | */ 33 | 34 | class TAPFile 35 | { 36 | public: 37 | vector fileData; 38 | 39 | TAPFile() {} 40 | 41 | void load(string const& fileName); 42 | void parse( 43 | vector &pulseData, 44 | set &indexData, 45 | set &stopData); 46 | 47 | size_t pointer = 0; 48 | std::string name; 49 | }; 50 | 51 | // vim: et:sw=4:ts=4: 52 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrBcA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrBcA.h 19 | * 20 | * Instruction: LD (BC), A 21 | * 22 | * Encoding: 00 000 010 23 | * M Cycles: 2 (OCF, MWB) 24 | * T States: 7 25 | * 26 | */ 27 | 28 | bool z80LdPtrBcA() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memWrCycles = 1; 34 | memAddrMode = 0x00000003; 35 | 36 | wz.w = bc.w + 1; 37 | oReg.b.l = af.b.h; 38 | return true; 39 | 40 | case 1: 41 | wz.b.h = af.b.h; 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | 46 | default: // Should not happen 47 | assert(false); 48 | return true; 49 | } 50 | } 51 | 52 | // vim: et:sw=4:ts=4 53 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrDeA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrDeA.h 19 | * 20 | * Instruction: LD (DE), A 21 | * 22 | * Encoding: 00 010 010 23 | * M Cycles: 2 (OCF, MWB) 24 | * T States: 7 25 | * 26 | */ 27 | 28 | bool z80LdPtrDeA() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memWrCycles = 1; 34 | memAddrMode = 0x00000004; 35 | 36 | wz.w = de.w + 1; 37 | oReg.b.l = af.b.h; 38 | return true; 39 | 40 | case 1: 41 | wz.b.h = af.b.h; 42 | flg = 0; 43 | prefix = PREFIX_NO; 44 | return true; 45 | 46 | default: // Should not happen 47 | assert(false); 48 | return true; 49 | } 50 | } 51 | 52 | // vim: et:sw=4:ts=4 53 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrHlByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrHlByte.h 19 | * 20 | * Instruction: LD (HL), n 21 | * 22 | * Encoding: 00 110 110 23 | * M Cycles: 3 (OCF, MRB, MWB) 24 | * T States: 10 25 | * 26 | */ 27 | 28 | bool z80LdPtrHlByte() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | memWrCycles = 1; 35 | memAddrMode = 0x00000021; 36 | return true; 37 | 38 | case 1: 39 | oReg.b.l = iReg.b.h; 40 | return true; 41 | 42 | case 2: 43 | flg = 0; 44 | prefix = PREFIX_NO; 45 | return true; 46 | 47 | default: // Should not happen 48 | assert(false); 49 | return true; 50 | } 51 | } 52 | 53 | // vim: et:sw=4:ts=4 54 | -------------------------------------------------------------------------------- /source/src/Z80CBPrefixed.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80CBPrefixed.h 19 | * 20 | * Z80 instruction table for CB-prefixed opcodes. 21 | * 22 | */ 23 | 24 | #include "Z80Nop.h" 25 | 26 | #include "Z80RlcReg.h" 27 | #include "Z80RrcReg.h" 28 | #include "Z80RlReg.h" 29 | #include "Z80RrReg.h" 30 | #include "Z80SlaReg.h" 31 | #include "Z80SraReg.h" 32 | #include "Z80SllReg.h" 33 | #include "Z80SrlReg.h" 34 | 35 | #include "Z80RlcPtrHl.h" 36 | #include "Z80RrcPtrHl.h" 37 | #include "Z80RlPtrHl.h" 38 | #include "Z80RrPtrHl.h" 39 | #include "Z80SlaPtrHl.h" 40 | #include "Z80SraPtrHl.h" 41 | #include "Z80SllPtrHl.h" 42 | #include "Z80SrlPtrHl.h" 43 | 44 | #include "Z80BitNReg.h" 45 | #include "Z80BitNPtrHl.h" 46 | #include "Z80ResNReg.h" 47 | #include "Z80ResNPtrHl.h" 48 | #include "Z80SetNReg.h" 49 | #include "Z80SetNPtrHl.h" 50 | 51 | // vim: et:sw=4:ts=4 52 | -------------------------------------------------------------------------------- /source/src/Z80Nmi.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Nmi.h 19 | * 20 | * NMI process (modelled as an instruction!) 21 | * 22 | */ 23 | 24 | bool z80Nmi() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 0; 30 | memWrCycles = 2; 31 | memAddrMode = 0x000000AA; 32 | acc.w = pc.w; 33 | return false; 34 | 35 | case 1: 36 | oReg.b.l = acc.b.h; 37 | oReg.b.h = acc.b.l; 38 | return true; 39 | 40 | case 2: 41 | return true; 42 | 43 | case 3: 44 | pc.w = 0x0066; 45 | prefix = PREFIX_NO; 46 | return true; 47 | 48 | default: // Should not happen 49 | assert(false); 50 | return true; 51 | } 52 | } 53 | 54 | // vim: et:sw=4:ts=4 55 | -------------------------------------------------------------------------------- /source/src/Memory.cc: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #include "Memory.h" 17 | 18 | Memory::Memory(size_t width, bool rom) : 19 | size(1 << width), 20 | mask(size - 1), 21 | memory(size, 0x00), 22 | rom(rom), 23 | wr_(true), 24 | rd_(true), 25 | as_(true), 26 | a(0), 27 | d(0) 28 | { 29 | } 30 | 31 | void Memory::clock() 32 | { 33 | // Latch address bus 34 | if (as_ == false) 35 | { 36 | if (rom == false && wr_ == false) 37 | memory[a & mask] = d; 38 | else if(rd_ == false) 39 | d = memory[a & mask]; 40 | } 41 | } 42 | 43 | uint_fast8_t Memory::read(uint_fast16_t addr) 44 | { 45 | d = memory[addr & mask]; 46 | return d; 47 | } 48 | 49 | void Memory::write(uint_fast16_t addr, uint_fast8_t data) 50 | { 51 | if (rom == false) 52 | memory[addr & mask] = data; 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Console.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2019. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Console 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #ifdef USE_BOOST_THREADS 26 | #include 27 | #else 28 | #include 29 | #include 30 | #endif 31 | 32 | class Console { 33 | 34 | public: 35 | #ifdef USE_BOOST_THREADS 36 | boost::mutex consoleMutex; 37 | #else 38 | std::mutex consoleMutex; 39 | #endif 40 | std::list cmdList; 41 | 42 | void operator()(); 43 | std::string get(); 44 | }; 45 | 46 | class ConsoleThread { 47 | 48 | public: 49 | Console console; 50 | #ifdef USE_BOOST_THREADS 51 | boost::thread consoleThread; 52 | #else 53 | std::thread consoleThread; 54 | #endif 55 | 56 | ConsoleThread(); 57 | ~ConsoleThread(); 58 | }; 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/Z80InAPtrByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80InAPtrByte.h 19 | * 20 | * Instruction: IN A, (n) 21 | * 22 | * Encoding: 11 011 011 23 | * M Cycles: 3 (OCF, MRB, IORD) 24 | * T States: 11 25 | * 26 | */ 27 | 28 | bool z80InAPtrByte() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | ioRdCycles = 1; 35 | memAddrMode = 0x000000D1; 36 | return true; 37 | 38 | case 1: 39 | wz.w = (af.b.h << 8) | iReg.b.h; 40 | return true; 41 | 42 | case 2: 43 | af.b.h = iReg.b.h; 44 | flg = 0; 45 | prefix = PREFIX_NO; 46 | return true; 47 | 48 | default: // Should not happen 49 | assert(false); 50 | return true; 51 | } 52 | } 53 | 54 | // vim: et:sw=4:ts=4 55 | -------------------------------------------------------------------------------- /source/src/Z80LdRegByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegByte.h 19 | * 20 | * Instruction: LD r, n 21 | * 22 | * Encoding: 00 rrr 110 23 | * M Cycles: 2 (OCF, MRB) 24 | * T States: 7 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegByte() 39 | { 40 | switch (executionStep) 41 | { 42 | case 0: 43 | memRdCycles = 1; 44 | memAddrMode = 0x00000001; 45 | return true; 46 | 47 | case 1: 48 | *(reg8[y]) = iReg.b.h; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | paths: 6 | - '.github/workflows/build.yml' 7 | - 'source/**' 8 | pull_request: 9 | paths: 10 | - '.github/workflows/build.yml' 11 | - 'source/**' 12 | 13 | env: 14 | CMAKE_BUILD_TYPE: Release 15 | 16 | jobs: 17 | build: 18 | runs-on: ${{ matrix.os }} 19 | 20 | strategy: 21 | matrix: 22 | os: [macos-latest, ubuntu-latest] 23 | 24 | steps: 25 | - uses: actions/checkout@v4 26 | 27 | - name: Install dependencies (macOS) 28 | if: startsWith(matrix.os, 'macos') 29 | run: | 30 | brew update 31 | brew install boost 32 | brew install sfml@2 33 | mkdir -p "${{ github.workspace }}/build" 34 | 35 | - name: Install dependencies (Ubuntu) 36 | if: startsWith(matrix.os, 'ubuntu') 37 | run: | 38 | sudo apt-get update 39 | sudo apt-get -y install libboost-all-dev 40 | sudo apt-get -y install libsfml-dev 41 | sudo apt-get -y install zlib1g-dev 42 | 43 | - name: Configure environment variables (macOS) 44 | if: startsWith(matrix.os, 'macos') 45 | run: echo "SFML_DIR=$(brew --prefix sfml@2)" >> $GITHUB_ENV 46 | 47 | - name: Configure CMake 48 | run: >- 49 | cmake 50 | -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} 51 | -B "${{ github.workspace }}/build" 52 | -S "${{ github.workspace }}/source" 53 | 54 | - name: Build 55 | run: cmake --build "${{ github.workspace }}/build" --config ${{ env.CMAKE_BUILD_TYPE }} --verbose 56 | -------------------------------------------------------------------------------- /source/src/Z80LdAPtrWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdAPtrWord.h 19 | * 20 | * Instruction: LD A, (nn) 21 | * 22 | * Encoding: 00 111 010 23 | * M Cycles: 4 (OCF, MRL, MRH, MRB) 24 | * T States: 13 25 | * 26 | */ 27 | 28 | bool z80LdAPtrWord() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 3; 34 | memAddrMode = 0x00000811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | wz.w = iReg.w; 42 | return true; 43 | 44 | case 3: 45 | af.b.h = iReg.b.h; 46 | flg = 0; 47 | prefix = PREFIX_NO; 48 | return true; 49 | 50 | default: // Should not happen 51 | assert(false); 52 | return true; 53 | } 54 | } 55 | 56 | // vim: et:sw=4:ts=4 57 | -------------------------------------------------------------------------------- /source/src/Z80LdRegPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegPtrHl.h 19 | * 20 | * Instruction: LD r, (HL) 21 | * 22 | * Encoding: 01 rrr 110 23 | * M Cycles: 2 (OCF, MRB) 24 | * T States: 7 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegPtrHl() 39 | { 40 | switch (executionStep) 41 | { 42 | case 0: 43 | memRdCycles = 1; 44 | memAddrMode = 0x00000002; 45 | return true; 46 | 47 | case 1: 48 | *(reg8[y]) = iReg.b.h; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80PopReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PopReg.h 19 | * 20 | * Instruction: POP rr 21 | * 22 | * Encoding: 11 rr0 001 23 | * M Cycles: 3 (OCF, MRL, MRH) 24 | * T States: 10 25 | * 26 | * Reg rr 27 | * -------- 28 | * BC 00 29 | * DE 01 30 | * HL 10 31 | * AF 11 32 | * 33 | */ 34 | 35 | bool z80PopReg() 36 | { 37 | switch (executionStep) 38 | { 39 | case 0: 40 | memRdCycles = 2; 41 | memAddrMode = 0x000000BB; 42 | return true; 43 | 44 | case 1: 45 | return true; 46 | 47 | case 2: 48 | *(regp2[p]) = iReg.w; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrHlReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrHlReg.h 19 | * 20 | * Instruction: LD (HL), r 21 | * 22 | * Encoding: 01 110 rrr 23 | * M Cycles: 2 (OCF, MWB) 24 | * T States: 7 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdPtrHlReg() 39 | { 40 | switch (executionStep) 41 | { 42 | case 0: 43 | memWrCycles = 1; 44 | memAddrMode = 0x00000002; 45 | 46 | oReg.b.l = *(reg8[z]); 47 | return true; 48 | 49 | case 1: 50 | flg = 0; 51 | prefix = PREFIX_NO; 52 | return true; 53 | 54 | default: // Should not happen 55 | assert(false); 56 | return true; 57 | } 58 | } 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/Z80PushIx.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PushIx.h 19 | * 20 | * Instruction: PUSH IX 21 | * 22 | * Encoding: 11 011 101 11 100 101 23 | * M Cycles: 4 (DD, OCF, MWL, MWH) 24 | * T States: 15 25 | * 26 | */ 27 | 28 | bool z80PushIx() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memWrCycles = 2; 34 | memAddrMode = 0x000000AA; 35 | return false; 36 | 37 | case 1: 38 | oReg.b.l = ix.b.h; 39 | oReg.b.h = ix.b.l; 40 | return true; 41 | 42 | case 2: 43 | return true; 44 | 45 | case 3: 46 | flg = 0; 47 | prefix = PREFIX_NO; 48 | return true; 49 | 50 | default: // Should not happen 51 | assert(false); 52 | return true; 53 | } 54 | } 55 | 56 | // vim: et:sw=4:ts=4 57 | -------------------------------------------------------------------------------- /source/src/Z80PushIy.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PushIy.h 19 | * 20 | * Instruction: PUSH IY 21 | * 22 | * Encoding: 11 111 101 11 100 101 23 | * M Cycles: 4 (FD, OCF, MWL, MWH) 24 | * T States: 15 25 | * 26 | */ 27 | 28 | bool z80PushIy() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memWrCycles = 2; 34 | memAddrMode = 0x000000AA; 35 | return false; 36 | 37 | case 1: 38 | oReg.b.l = iy.b.h; 39 | oReg.b.h = iy.b.l; 40 | return true; 41 | 42 | case 2: 43 | return true; 44 | 45 | case 3: 46 | flg = 0; 47 | prefix = PREFIX_NO; 48 | return true; 49 | 50 | default: // Should not happen 51 | assert(false); 52 | return true; 53 | } 54 | } 55 | 56 | // vim: et:sw=4:ts=4 57 | -------------------------------------------------------------------------------- /source/src/Z80LdRegWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegWord.h 19 | * 20 | * Instruction: LD rr, nn 21 | * 22 | * Encoding: 00 rr0 001 23 | * M Cycles: 3 (OCF, MRL, MRH) 24 | * T States: 10 25 | * 26 | * Reg rr 27 | * -------- 28 | * BC 00 29 | * DE 01 30 | * HL 10 31 | * SP 11 32 | * 33 | */ 34 | 35 | bool z80LdRegWord() 36 | { 37 | switch (executionStep) 38 | { 39 | case 0: 40 | memRdCycles = 2; 41 | memAddrMode = 0x00000011; 42 | return true; 43 | 44 | case 1: 45 | return true; 46 | 47 | case 2: 48 | *regp[p] = iReg.w; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80LdRegXByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegXByte.h 19 | * 20 | * Instruction: DD-prefixed LD r, n 21 | * 22 | * Encoding: 11 011 101 00 rrr 110 23 | * M Cycles: 3 (DD, OCF, MRB) 24 | * T States: 11 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * IXh 100 33 | * IXl 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegXByte() 39 | { 40 | switch (executionStep) 41 | { 42 | case 0: 43 | memRdCycles = 1; 44 | memAddrMode = 0x00000001; 45 | return true; 46 | 47 | case 1: 48 | *(regx8[y]) = iReg.b.h; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80LdRegYByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegYByte.h 19 | * 20 | * Instruction: FD-prefixed LD r, n 21 | * 22 | * Encoding: 11 111 101 00 rrr 110 23 | * M Cycles: 3 (FD, OCF, MRB) 24 | * T States: 11 25 | * 26 | * Reg rrr 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * IYh 100 33 | * IYl 101 34 | * A 111 35 | * 36 | */ 37 | 38 | bool z80LdRegYByte() 39 | { 40 | switch (executionStep) 41 | { 42 | case 0: 43 | memRdCycles = 1; 44 | memAddrMode = 0x00000001; 45 | return true; 46 | 47 | case 1: 48 | *(regy8[y]) = iReg.b.h; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80OutPtrByteA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OutPtrByteA.h 19 | * 20 | * Instruction: OUT (n), A 21 | * 22 | * Encoding: 11 010 011 23 | * M Cycles: 3 (OCF, MRB, IOWR) 24 | * T States: 11 25 | * 26 | */ 27 | 28 | bool z80OutPtrByteA() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | ioWrCycles = 1; 35 | memAddrMode = 0x000000D1; 36 | return true; 37 | 38 | case 1: 39 | wz.w = (af.b.h << 8) | iReg.b.h; 40 | oReg.b.l = af.b.h; 41 | return true; 42 | 43 | case 2: 44 | wz.b.h = af.b.h; 45 | flg = 0; 46 | prefix = PREFIX_NO; 47 | return true; 48 | 49 | default: // Should not happen 50 | assert(false); 51 | return true; 52 | } 53 | } 54 | 55 | // vim: et:sw=4:ts=4 56 | -------------------------------------------------------------------------------- /source/src/Z80File.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2024. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "SaveState.h" 22 | 23 | /** Z80File.h 24 | * 25 | * Z80 file format implementation. 26 | * 27 | * This class loads a Z80 snapshot, validates it and applies it to the emulator. 28 | */ 29 | 30 | 31 | class Z80File { 32 | 33 | public: 34 | Z80File() {} 35 | 36 | std::string name; 37 | uint32_t dataIndex = 0; 38 | 39 | std::vector fileData; 40 | SaveState state; 41 | 42 | void load(std::string const& fileName); 43 | bool parse(); 44 | void apply(); 45 | void write(); 46 | 47 | bool parseHeader(); 48 | bool checkVersion(); 49 | bool fillMemory(); 50 | uint8_t getPage(uint8_t numPage); 51 | void decompressBlock(size_t length, size_t start, std::vector& buffer); 52 | }; 53 | 54 | // vim: et:sw=4:ts=4: 55 | -------------------------------------------------------------------------------- /source/src/Z80LdHlPtrWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdHlPtrWord.h 19 | * 20 | * Instruction: LD HL, (nn) 21 | * 22 | * Encoding: 00 101 010 23 | * M Cycles: 5 (OCF, MRL, MRH, MRL, MRH) 24 | * T States: 16 25 | * 26 | */ 27 | 28 | bool z80LdHlPtrWord() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 4; 34 | memAddrMode = 0x00009811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | wz.w = iReg.w; 42 | return true; 43 | 44 | case 3: 45 | return true; 46 | 47 | case 4: 48 | hl.w = iReg.w; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80DecPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80DecPtrHl.h 19 | * 20 | * Instruction: DEC (HL) 21 | * 22 | */ 23 | 24 | bool z80DecPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000022; 31 | skipCycles = 1; 32 | return true; 33 | 34 | case 1: 35 | return false; 36 | 37 | case 2: 38 | // Preserve carry bit. 39 | flg = af.b.l & FLAG_C; 40 | flg |= decFlags[iReg.b.h]; 41 | 42 | oReg.b.l = iReg.b.h - 1; 43 | memWrCycles = 1; 44 | return true; 45 | 46 | case 3: 47 | af.b.l = flg; 48 | prefix = PREFIX_NO; 49 | return true; 50 | 51 | default: // Should not happen 52 | assert(false); 53 | return true; 54 | } 55 | } 56 | 57 | // vim: et:sw=4:ts=4 58 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrWordA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrWordA.h 19 | * 20 | * Instruction: LD (nn), A 21 | * 22 | * Encoding: 00 110 010 23 | * M Cycles: 2 (OCF, MRL, MRH, MWB) 24 | * T States: 13 25 | * 26 | */ 27 | 28 | bool z80LdPtrWordA() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 2; 34 | memAddrMode = 0x00000811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | wz.w = iReg.w; 42 | memWrCycles = 1; 43 | oReg.b.l = af.b.h; 44 | return true; 45 | 46 | case 3: 47 | wz.b.h = af.b.h; 48 | flg = 0; 49 | prefix = PREFIX_NO; 50 | return true; 51 | 52 | default: // Should not happen 53 | assert(false); 54 | return true; 55 | } 56 | } 57 | 58 | // vim: et:sw=4:ts=4 59 | -------------------------------------------------------------------------------- /source/src/Z80IncPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80IncPtrHl.h 19 | * 20 | * Instruction: INC (HL) 21 | * 22 | */ 23 | 24 | bool z80IncPtrHl() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000022; 31 | skipCycles = 1; 32 | return true; 33 | 34 | case 1: 35 | return false; 36 | 37 | case 2: 38 | // Preserve carry flag. 39 | flg = af.b.l & FLAG_C; 40 | flg |= incFlags[iReg.b.h]; 41 | af.b.l = flg; 42 | 43 | oReg.b.l = iReg.b.h + 1; 44 | memWrCycles = 1; 45 | return true; 46 | 47 | case 3: 48 | prefix = PREFIX_NO; 49 | return true; 50 | 51 | default: // Should not happen 52 | assert(false); 53 | return true; 54 | } 55 | } 56 | 57 | // vim: et:sw=4:ts=4 58 | -------------------------------------------------------------------------------- /source/src/Z80LdIxPtrWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdIxPtrWord.h 19 | * 20 | * Instruction: LD IX, (nn) 21 | * 22 | * Encoding: 11 011 101 00 101 010 23 | * M Cycles: 5 (DD, OCF, MRL, MRH, MRL, MRH) 24 | * T States: 20 25 | * 26 | */ 27 | 28 | bool z80LdIxPtrWord() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 4; 34 | memAddrMode = 0x00009811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | wz.w = iReg.w; 42 | return true; 43 | 44 | case 3: 45 | return true; 46 | 47 | case 4: 48 | ix.w = iReg.w; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80LdIyPtrWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdIyPtrWord.h 19 | * 20 | * Instruction: LD IY, (nn) 21 | * 22 | * Encoding: 11 111 101 00 101 010 23 | * M Cycles: 5 (FD, OCF, MRL, MRH, MRL, MRH) 24 | * T States: 20 25 | * 26 | */ 27 | 28 | bool z80LdIyPtrWord() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 4; 34 | memAddrMode = 0x00009811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | wz.w = iReg.w; 42 | return true; 43 | 44 | case 3: 45 | return true; 46 | 47 | case 4: 48 | iy.w = iReg.w; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrWordHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrWordHl.h 19 | * 20 | * Instruction: LD (nn), HL 21 | * 22 | * Encoding: 00 100 010 23 | * M Cycles: 5 (OCF, MRL, MRH, MWL, MWH) 24 | * T States: 16 25 | * 26 | */ 27 | 28 | bool z80LdPtrWordHl() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 2; 34 | memAddrMode = 0x00009811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | memWrCycles = 2; 42 | wz.w = iReg.w; 43 | oReg.w = hl.w; 44 | return true; 45 | 46 | case 3: 47 | return true; 48 | 49 | case 4: 50 | flg = 0; 51 | prefix = PREFIX_NO; 52 | return true; 53 | 54 | default: // Should not happen 55 | assert(false); 56 | return true; 57 | } 58 | } 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/Z80Call.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Call.h 19 | * 20 | * Instruction: CALL nn 21 | * 22 | */ 23 | 24 | bool z80Call() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 2; 30 | memWrCycles = 2; 31 | memAddrMode = 0x0000AA11; 32 | return true; 33 | 34 | case 1: 35 | skipCycles = 1; 36 | return true; 37 | 38 | case 2: 39 | return false; 40 | 41 | case 3: 42 | oReg.b.l = pc.b.h; 43 | oReg.b.h = pc.b.l; 44 | return true; 45 | 46 | case 4: 47 | return true; 48 | 49 | case 5: 50 | pc.w = wz.w = iReg.w; 51 | flg = 0; 52 | prefix = PREFIX_NO; 53 | return true; 54 | 55 | default: // Should not happen 56 | assert(false); 57 | return true; 58 | } 59 | } 60 | 61 | // vim: et:sw=4:ts=4 62 | -------------------------------------------------------------------------------- /source/src/Z80OutPtrCReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80OutPtrCReg.h 19 | * 20 | * Instruction: OUT (C), r 21 | * 22 | * Encoding: 11 101 101 01 rrr 001 23 | * M Cycles: 3 (ED, OCF, IOWR) 24 | * T States: 12 25 | * 26 | * Reg r 27 | * --- --- 28 | * B 000 29 | * C 001 30 | * D 010 31 | * E 011 32 | * H 100 33 | * L 101 34 | * - 110 * Outputs 00h 35 | * A 111 36 | * 37 | */ 38 | 39 | bool z80OutPtrCReg() 40 | { 41 | switch (executionStep) 42 | { 43 | case 0: 44 | ioWrCycles = 1; 45 | memAddrMode = 0x0000000E; 46 | 47 | wz.w = bc.w; 48 | oReg.b.l = (y == 6) ? zeroByte : *reg8[y]; 49 | return true; 50 | case 1: 51 | flg = 0; 52 | prefix = PREFIX_NO; 53 | return true; 54 | 55 | default: // Should not happen 56 | assert(false); 57 | return true; 58 | } 59 | } 60 | 61 | // vim: et:sw=4:ts=4 62 | -------------------------------------------------------------------------------- /source/src/Z80JrByte.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80JrByte.h 19 | * 20 | * JR n Instruction. 21 | * 22 | */ 23 | 24 | bool z80JrByte() 25 | { 26 | switch (executionStep) 27 | { 28 | case 0: 29 | memRdCycles = 1; 30 | memAddrMode = 0x00000001; 31 | return true; 32 | 33 | case 1: 34 | cpuProcCycles = 1; 35 | skipCycles = 4; 36 | return true; 37 | 38 | case 2: 39 | case 3: 40 | case 4: 41 | case 5: 42 | return false; 43 | 44 | case 6: 45 | wz.b.l = iReg.b.h; 46 | wz.b.h = ((wz.b.l & 0x80) == 0x80) ? 0xFF : 0x00; 47 | wz.w += pc.w; 48 | pc.w = wz.w; 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrWordIx.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrWordIx.h 19 | * 20 | * Instruction: LD (nn), IX 21 | * 22 | * Encoding: 11 011 101 00 100 010 23 | * M Cycles: 6 (DD, OCF, MRL, MRH, MWL, MWH) 24 | * T States: 20 25 | * 26 | */ 27 | 28 | bool z80LdPtrWordIx() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 2; 34 | memAddrMode = 0x00009811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | memWrCycles = 2; 42 | wz.w = iReg.w; 43 | oReg.w = ix.w; 44 | return true; 45 | 46 | case 3: 47 | return true; 48 | 49 | case 4: 50 | flg = 0; 51 | prefix = PREFIX_NO; 52 | return true; 53 | 54 | default: // Should not happen 55 | assert(false); 56 | return true; 57 | } 58 | } 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/Z80LdPtrWordIy.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdPtrWordIy.h 19 | * 20 | * Instruction: LD (nn), IY 21 | * 22 | * Encoding: 11 111 101 00 100 010 23 | * M Cycles: 6 (FD, OCF, MRL, MRH, MWL, MWH) 24 | * T States: 20 25 | * 26 | */ 27 | 28 | bool z80LdPtrWordIy() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 2; 34 | memAddrMode = 0x00009811; 35 | return true; 36 | 37 | case 1: 38 | return true; 39 | 40 | case 2: 41 | memWrCycles = 2; 42 | wz.w = iReg.w; 43 | oReg.w = iy.w; 44 | return true; 45 | 46 | case 3: 47 | return true; 48 | 49 | case 4: 50 | flg = 0; 51 | prefix = PREFIX_NO; 52 | return true; 53 | 54 | default: // Should not happen 55 | assert(false); 56 | return true; 57 | } 58 | } 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/Z80Neg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Neg.h 19 | * 20 | * Instruction: NEG 21 | * 22 | */ 23 | 24 | bool z80Neg() 25 | { 26 | // Calculate half-carry. This is done by doing a 4-bit 27 | // subtraction. Half-carry will be in bit 4. 28 | acc.w = -(af.b.h & 0x0F); 29 | flg = (acc.w & (FLAG_H | FLAG_3)) | FLAG_N; // ...b.H3.1. 30 | 31 | // Calculate carry in the bit 7. Overflow flag is 32 | // (carry in bit 7) XOR (carry in bit 8). 33 | acc.w = -(af.b.h & 0x7F); 34 | flg |= (acc.w >> 5) & FLAG_PV; 35 | 36 | // Calculate the result. 37 | acc.w = -af.b.h; 38 | flg |= acc.b.l & (FLAG_S | FLAG_5); // S.5H3.1. 39 | flg |= acc.b.h & FLAG_C; // S.5H3.1C 40 | flg ^= (acc.w >> 6) & FLAG_PV; // S.5H3V1C 41 | flg |= (acc.b.l) ? 0x00 : FLAG_Z; // SZ5H3V1C 42 | af.b.h = acc.b.l; 43 | af.b.l = flg; 44 | prefix = PREFIX_NO; 45 | return true; 46 | } 47 | 48 | // vim: et:sw=4:ts=4 49 | -------------------------------------------------------------------------------- /source/src/Z80Rst.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80Rst.h 19 | * 20 | * Instruction: RST 0h 21 | * Instruction: RST 8h 22 | * Instruction: RST 10h 23 | * Instruction: RST 18h 24 | * Instruction: RST 20h 25 | * Instruction: RST 28h 26 | * Instruction: RST 30h 27 | * Instruction: RST 38h 28 | * 29 | */ 30 | 31 | bool z80Rst() 32 | { 33 | switch (executionStep) 34 | { 35 | case 0: 36 | memWrCycles = 2; 37 | memAddrMode = 0x000000AA; 38 | return false; 39 | 40 | case 1: 41 | oReg.b.l = pc.b.h; 42 | oReg.b.h = pc.b.l; 43 | return true; 44 | 45 | case 2: 46 | return true; 47 | 48 | case 3: 49 | pc.w = wz.w = (y << 3); 50 | flg = 0; 51 | prefix = PREFIX_NO; 52 | return true; 53 | 54 | default: // Should not happen 55 | assert(false); 56 | return true; 57 | } 58 | } 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/CSWFile.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2024. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | class CSWFile { 24 | public: 25 | CSWFile() : 26 | magic { 27 | 'C', 'o', 'm', 'p', 'r', 'e', 's', 's', 28 | 'e', 'd', ' ', 'S', 'q', 'u', 'a', 'r', 29 | 'e', ' ', 'W', 'a', 'v', 'e', 0x1A 30 | } {} 31 | 32 | uint8_t magic[23]; 33 | bool magicIsOk = false; 34 | uint8_t majorVersion = 0; 35 | uint8_t minorVersion = 0; 36 | 37 | double rate; 38 | uint8_t compression; 39 | uint8_t flags; 40 | 41 | std::vector fileData; 42 | std::vector romData; 43 | 44 | void load(std::string const& fileName); 45 | void parse(std::vector &pulseData, 46 | std::set &indexData, 47 | std::set &stopData); 48 | }; 49 | 50 | // vim: et:sw=4:ts=4 51 | -------------------------------------------------------------------------------- /source/src/Z80ResNPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80ResNPtrHl.h 19 | * 20 | * Instruction: RES n, (HL) 21 | * 22 | * Encoding: 11 001 011 10 bbb 110 23 | * M Cycles: 4 (OCF, OCF, MRB(4), MWB) 24 | * T States: 15 25 | * 26 | */ 27 | 28 | bool z80ResNPtrHl() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | memWrCycles = 1; 35 | memAddrMode = 0x00000022; 36 | skipCycles = 1; 37 | return true; 38 | 39 | case 1: 40 | return false; 41 | 42 | case 2: 43 | acc.b.l = iReg.b.h; 44 | acc.b.l &= ~(1 << y); 45 | oReg.b.l = acc.b.l; 46 | return true; 47 | 48 | case 3: 49 | flg = 0; 50 | prefix = PREFIX_NO; 51 | return true; 52 | 53 | default: // Should not happen 54 | assert(false); 55 | return true; 56 | } 57 | } 58 | 59 | // vim: et:sw=4:ts=4 60 | -------------------------------------------------------------------------------- /source/src/Z80PushReg.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80PushReg.h 19 | * 20 | * Instruction: PUSH rr 21 | * 22 | * Encoding: 11 rr0 101 23 | * M Cycles: 3 (OCF, MWL, MWH) 24 | * T States: 11 25 | * 26 | * Reg rr 27 | * -------- 28 | * BC 00 29 | * DE 01 30 | * HL 10 31 | * AF 11 32 | * 33 | */ 34 | 35 | bool z80PushReg() 36 | { 37 | switch (executionStep) 38 | { 39 | case 0: 40 | memWrCycles = 2; 41 | memAddrMode = 0x000000AA; 42 | acc.w = *(regp2[p]); 43 | return false; 44 | 45 | case 1: 46 | oReg.b.l = acc.b.h; 47 | oReg.b.h = acc.b.l; 48 | return true; 49 | 50 | case 2: 51 | return true; 52 | 53 | case 3: 54 | flg = 0; 55 | prefix = PREFIX_NO; 56 | return true; 57 | 58 | default: // Should not happen 59 | assert(false); 60 | return true; 61 | } 62 | } 63 | 64 | // vim: et:sw=4:ts=4 65 | -------------------------------------------------------------------------------- /source/src/Z80SetNPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SetNPtrHl.h 19 | * 20 | * Instruction: SET n, (HL) 21 | * 22 | * Encoding: 11 001 011 11 bbb 110 23 | * M Cycles: 4 (OCF, OCF, MRB(4), MWB) 24 | * T States: 15 25 | * 26 | */ 27 | 28 | bool z80SetNPtrHl() 29 | { 30 | switch (executionStep) 31 | { 32 | case 0: 33 | memRdCycles = 1; 34 | memWrCycles = 1; 35 | memAddrMode = 0x00000022; 36 | skipCycles = 1; 37 | return true; 38 | 39 | case 1: 40 | return false; 41 | 42 | case 2: 43 | acc.b.l = iReg.b.h; 44 | acc.b.l |= (1 << y); 45 | 46 | oReg.b.l = acc.b.l; 47 | return true; 48 | 49 | case 3: 50 | flg = 0; 51 | prefix = PREFIX_NO; 52 | return true; 53 | 54 | default: // Should not happen 55 | assert(false); 56 | return true; 57 | } 58 | } 59 | 60 | // vim: et:sw=4:ts=4 61 | -------------------------------------------------------------------------------- /source/src/PZXFile.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2024. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | /** PZXFile.h 25 | * 26 | * PZX file format implementation. 27 | * 28 | * This class loads a PZX file and generates pulses that will be fed to the 29 | * Spectrum EAR port. 30 | */ 31 | 32 | class PZXFile { 33 | 34 | public: 35 | PZXFile() {} 36 | 37 | std::string name; 38 | 39 | uint8_t majorVersion = 0; 40 | uint8_t minorVersion = 0; 41 | 42 | std::vector fileData; 43 | std::vector romData; 44 | 45 | std::stringstream ss; // For reporting. 46 | 47 | void load(std::string const& fileName); 48 | void parse( 49 | std::vector &pulseData, 50 | std::set &indexData, 51 | std::set &stopData, 52 | std::set &stopIf48K); 53 | 54 | }; 55 | 56 | // vim: et:sw=4:ts=4: 57 | -------------------------------------------------------------------------------- /source/src/Utils.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2024. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | extern uint8_t averageTable[0x100][0x100]; 23 | 24 | void printBytes(std::string const& prefix, size_t len, uint8_t* buf); 25 | 26 | bool inflateBuffer(std::vector& in, std::vector& out); 27 | 28 | uint32_t getU32(std::vector const& v, uint_fast32_t i); 29 | 30 | uint32_t getU24(std::vector const& v, uint_fast32_t i); 31 | 32 | uint16_t getU16(std::vector const& v, uint_fast32_t i); 33 | 34 | void fillAverageTable(); 35 | 36 | uint32_t average(uint32_t *ptr); 37 | 38 | void loadPalette(std::string const& fileName, std::vector& paletteData); 39 | 40 | #if (SPECIDE_ON_UNIX == 0) 41 | /** 42 | * Query Windows timer capabilities and return the minimum timer step. 43 | * 44 | * This can be used to adjust the sleep delay to a multiple of the quantum, to avoid overshooting. 45 | */ 46 | uint32_t queryTimerStep(); 47 | #endif 48 | 49 | // vim: et:sw=4:ts=4 50 | -------------------------------------------------------------------------------- /source/src/Z80LdRegXWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegXWord.h 19 | * 20 | * DD Prefixed instructions. 21 | * Instruction: LD BC, nn 22 | * Instruction: LD DE, nn 23 | * Instruction: LD IX, nn 24 | * Instruction: LD SP, nn 25 | * 26 | * Encoding: 11 011 101 00 rr0 001 27 | * M Cycles: 4 (DD, OCF, MRL, MRH) 28 | * T States: 14 29 | * 30 | * Reg rr 31 | * -------- 32 | * BC 00 33 | * DE 01 34 | * IX 10 35 | * SP 11 36 | * 37 | */ 38 | 39 | bool z80LdRegXWord() 40 | { 41 | switch (executionStep) 42 | { 43 | case 0: 44 | memRdCycles = 2; 45 | memAddrMode = 0x00000011; 46 | return true; 47 | 48 | case 1: 49 | return true; 50 | 51 | case 2: 52 | *regpx[p] = iReg.w; 53 | flg = 0; 54 | prefix = PREFIX_NO; 55 | return true; 56 | 57 | default: // Should not happen 58 | assert(false); 59 | return true; 60 | } 61 | } 62 | 63 | // vim: et:sw=4:ts=4 64 | -------------------------------------------------------------------------------- /source/src/Z80LdRegYWord.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80LdRegYWord.h 19 | * 20 | * FD Prefixed instructions. 21 | * Instruction: LD BC, nn 22 | * Instruction: LD DE, nn 23 | * Instruction: LD IY, nn 24 | * Instruction: LD SP, nn 25 | * 26 | * Encoding: 11 111 101 00 rr0 001 27 | * M Cycles: 4 (FD, OCF, MRL, MRH) 28 | * T States: 14 29 | * 30 | * Reg rr 31 | * -------- 32 | * BC 00 33 | * DE 01 34 | * IY 10 35 | * SP 11 36 | * 37 | */ 38 | 39 | bool z80LdRegYWord() 40 | { 41 | switch (executionStep) 42 | { 43 | case 0: 44 | memRdCycles = 2; 45 | memAddrMode = 0x00000011; 46 | return true; 47 | 48 | case 1: 49 | return true; 50 | 51 | case 2: 52 | *regpy[p] = iReg.w; 53 | flg = 0; 54 | prefix = PREFIX_NO; 55 | return true; 56 | 57 | default: // Should not happen 58 | assert(false); 59 | return true; 60 | } 61 | } 62 | 63 | // vim: et:sw=4:ts=4 64 | -------------------------------------------------------------------------------- /source/src/SaveState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class JoystickType { 4 | KEMPSTON_OLD, 5 | KEMPSTON_NEW, 6 | FULLER, 7 | CURSOR, 8 | SINCLAIR 9 | }; 10 | 11 | enum class SnapshotModel { 12 | ZX_48K_ISSUE2, 13 | ZX_48K_ISSUE3, 14 | ZX_128K, 15 | ZX_PLUS2, 16 | ZX_PLUS2A, 17 | ZX_PLUS3, 18 | PENTAGON, 19 | UNSUPPORTED 20 | }; 21 | 22 | enum class SnapType { 23 | Z80_V1, 24 | Z80_V2, 25 | Z80_V3, 26 | SNA_48, 27 | SNA_128, 28 | INVALID 29 | }; 30 | 31 | struct SaveState { 32 | 33 | SnapType type = SnapType::INVALID; 34 | 35 | uint16_t af = 0x0000; 36 | uint16_t bc = 0x0000; 37 | uint16_t de = 0x0000; 38 | uint16_t hl = 0x0000; 39 | 40 | uint16_t af_ = 0x0000; 41 | uint16_t bc_ = 0x0000; 42 | uint16_t de_ = 0x0000; 43 | uint16_t hl_ = 0x0000; 44 | 45 | uint16_t pc = 0x0000; 46 | uint16_t sp = 0x0000; 47 | uint16_t ir = 0x0000; 48 | 49 | uint16_t ix = 0x0000; 50 | uint16_t iy = 0x0000; 51 | 52 | uint16_t iff = 0x0000; 53 | uint8_t im = 0x00; 54 | 55 | uint8_t border = 0x00; 56 | JoystickType joystick = JoystickType::SINCLAIR; 57 | bool issue2 = false; 58 | bool samrom = false; 59 | bool trdos = false; 60 | 61 | SnapshotModel model = SnapshotModel::UNSUPPORTED; 62 | 63 | uint8_t port_0x1ffd = 0x00; 64 | uint8_t port_0x7ffd = 0x00; 65 | uint8_t port_0xfffd = 0x00; 66 | uint8_t ayRegs[16]; 67 | 68 | bool emuAy8912 = false; 69 | bool emuFuller = false; 70 | bool emuRefresh = true; 71 | 72 | uint32_t tStates = UINT32_MAX; 73 | 74 | bool dataIsCompressed = false; 75 | std::vector memory[16]; 76 | }; 77 | 78 | // vim: et:sw=4:ts=4: 79 | -------------------------------------------------------------------------------- /source/src/Z80SlaPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SlaPtrHl.h 19 | * 20 | * Instruction: SLA (HL) 21 | * 22 | * Encoding: 11 001 011 00 100 110 23 | * M Cycles: 4 (OCF, OCF, MRB(4), MWB) 24 | * T States: 15 25 | * 26 | * Flags: SZ503P0C 27 | * - 0 is shifted into the LSB. 28 | * 29 | */ 30 | 31 | bool z80SlaPtrHl() 32 | { 33 | switch (executionStep) 34 | { 35 | case 0: 36 | memRdCycles = 1; 37 | memWrCycles = 1; 38 | memAddrMode = 0x00000022; 39 | skipCycles = 1; 40 | return true; 41 | 42 | case 1: 43 | return false; 44 | 45 | case 2: 46 | acc.w = iReg.b.h << 1; 47 | af.b.l = flg = slaFlags[iReg.b.h]; 48 | 49 | oReg.b.l = acc.b.l; 50 | return true; 51 | 52 | case 3: 53 | prefix = PREFIX_NO; 54 | return true; 55 | 56 | default: // Should not happen 57 | assert(false); 58 | return true; 59 | } 60 | } 61 | 62 | // vim: et:sw=4:ts=4 63 | -------------------------------------------------------------------------------- /source/src/Z80SrlPtrHl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of SpecIde, (c) Marta Sevillano Mancilla, 2016-2018. 2 | * 3 | * SpecIde is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * SpecIde is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with SpecIde. If not, see . 14 | */ 15 | 16 | #pragma once 17 | 18 | /** Z80SrlPtrHl.h 19 | * 20 | * Instruction: SRL (HL) 21 | * 22 | * Encoding: 11 001 011 00 111 110 23 | * M Cycles: 4 (OCF, OCF, MRB(4), MWB) 24 | * T States: 15 25 | * 26 | * Flags: SZ503P0C 27 | * - 0 is shifted into MSB. 28 | * 29 | */ 30 | 31 | bool z80SrlPtrHl() 32 | { 33 | switch (executionStep) 34 | { 35 | case 0: 36 | memRdCycles = 1; 37 | memWrCycles = 1; 38 | memAddrMode = 0x00000022; 39 | skipCycles = 1; 40 | return true; 41 | 42 | case 1: 43 | return false; 44 | 45 | case 2: 46 | af.b.l = flg = srlFlags[iReg.b.h]; 47 | acc.w = iReg.b.h >> 1; 48 | 49 | oReg.b.l = acc.b.l; 50 | return true; 51 | 52 | case 3: 53 | prefix = PREFIX_NO; 54 | return true; 55 | 56 | default: // Should not happen 57 | assert(false); 58 | return true; 59 | } 60 | } 61 | 62 | // vim: et:sw=4:ts=4 63 | --------------------------------------------------------------------------------