1 | //============================================================================ |
2 | // |
3 | // SSSS tt lll lll |
4 | // SS SS tt ll ll |
5 | // SS tttttt eeee ll ll aaaa |
6 | // SSSS tt ee ee ll ll aa |
7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
8 | // SS SS tt ee ll ll aa aa |
9 | // SSSS ttt eeeee llll llll aaaaa |
10 | // |
11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
12 | // and the Stella Team |
13 | // |
14 | // See the file "License.txt" for information on usage and redistribution of |
15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
16 | //============================================================================ |
17 | |
18 | #include "System.hxx" |
19 | #include "Cart4K.hxx" |
20 | |
21 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
22 | Cartridge4K::Cartridge4K(const ByteBuffer& image, size_t size, |
23 | const string& md5, const Settings& settings) |
24 | : Cartridge(settings, md5) |
25 | { |
26 | // Copy the ROM image into my buffer |
27 | std::copy_n(image.get(), std::min(myImage.size(), size), myImage.begin()); |
28 | createCodeAccessBase(myImage.size()); |
29 | } |
30 | |
31 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
32 | void Cartridge4K::reset() |
33 | { |
34 | myBankChanged = true; |
35 | } |
36 | |
37 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
38 | void Cartridge4K::install(System& system) |
39 | { |
40 | mySystem = &system; |
41 | |
42 | // Map ROM image into the system |
43 | // Note that we don't need our own peek/poke methods, since the mapping |
44 | // takes care of the entire address space |
45 | System::PageAccess access(this, System::PageAccessType::READ); |
46 | for(uInt16 addr = 0x1000; addr < 0x2000; addr += System::PAGE_SIZE) |
47 | { |
48 | access.directPeekBase = &myImage[addr & 0x0FFF]; |
49 | access.codeAccessBase = &myCodeAccessBase[addr & 0x0FFF]; |
50 | mySystem->setPageAccess(addr, access); |
51 | } |
52 | } |
53 | |
54 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
55 | bool Cartridge4K::patch(uInt16 address, uInt8 value) |
56 | { |
57 | myImage[address & 0x0FFF] = value; |
58 | return myBankChanged = true; |
59 | } |
60 | |
61 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
62 | const uInt8* Cartridge4K::getImage(size_t& size) const |
63 | { |
64 | size = myImage.size(); |
65 | return myImage.data(); |
66 | } |
67 | |