diff --git a/Assets/gamedb/gamedb_vectrex.txt b/Assets/gamedb/gamedb_vectrex.txt index 4ba83c75a7..a5fafea41f 100644 --- a/Assets/gamedb/gamedb_vectrex.txt +++ b/Assets/gamedb/gamedb_vectrex.txt @@ -23,4 +23,9 @@ ;;; Actually TRANSLATED -;;; Games NOT present in TOSEC \ No newline at end of file +;;; Games NOT present in TOSEC + +;;; Homebrew +SHA1:D2FB28CECC38202E17BEE2FAEBC93B3BC8B76AFD Where Have All The Pixels Gone? VEC +SHA1:CF5DF39705107732CAF81C7FE742A5AEE598E9BC EigenVectrex VEC + diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs index 26f57ba2f0..96b32e2745 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs @@ -157,7 +157,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex if (dir_ctrl.Bit(3)) { bc1 = value.Bit(3); } if (dir_ctrl.Bit(4)) { bdir = value.Bit(4); } if (dir_ctrl.Bit(5)) { /*compare = value.Bit(5);*/ } - if (dir_ctrl.Bit(6)) { /* cart bank switch */ } + if (dir_ctrl.Bit(6)) { /*writing here seems to change the bank for only a single cycle, and only in output mode, not implemented*/ } if (dir_ctrl.Bit(7)) { //Console.WriteLine(PB7_undriven + " " + !wrt_val.Bit(7)); @@ -326,6 +326,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex break; case 0x2: dir_ctrl = value; + // the direction of bit 6 here controls the bank + mapper.bank = dir_ctrl.Bit(6) ? 1 : 0; + break; case 0x3: dir_dac = value; diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs index acf5d26a51..3ed8219683 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs @@ -7,6 +7,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex { public VectrexHawk Core { get; set; } + public int bank; + public virtual byte ReadMemory(ushort addr) { return 0; @@ -27,6 +29,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public virtual void SyncState(Serializer ser) { + ser.Sync(nameof(bank), ref bank); } public virtual void Dispose() diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_64K.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_64K.cs new file mode 100644 index 0000000000..9ecc5efcbe --- /dev/null +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_64K.cs @@ -0,0 +1,32 @@ +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + // Default mapper with no bank switching + // make sure peekmemory and poke memory don't effect the rest of the system! + public class Mapper_64K : MapperBase + { + public override void Initialize() + { + bank = 0; + } + + public override byte ReadMemory(ushort addr) + { + return Core._rom[addr + bank * 0x8000]; + } + + public override byte PeekMemory(ushort addr) + { + return ReadMemory(addr); + } + + public override void WriteMemory(ushort addr, byte value) + { + + } + + public override void PokeMemory(ushort addr, byte value) + { + WriteMemory(addr, value); + } + } +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs index afd74ecb4c..4351765001 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs @@ -62,7 +62,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex _rom = rom; - // If the game is minstorm, then no cartridge is inserted, retun 0xFF + // If the game is minestorm, then no cartridge is inserted, retun 0xFF if (romHashSHA1 == RomChecksums.Minestorm) { _rom = new byte[0x8000]; @@ -159,8 +159,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex private void Setup_Mapper() { - mapper = new MapperDefault(); + if (_rom.Length == 0x10000) + { + mapper = new Mapper_64K(); + } + else + { + mapper = new MapperDefault(); + } + mapper.Core = this; + mapper.Initialize(); } } }