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 "Debugger.hxx"
19#include "CartDebug.hxx"
20#include "CartCV.hxx"
21#include "CartCVWidget.hxx"
22
23// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24CartridgeCVWidget::CartridgeCVWidget(
25 GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
26 int x, int y, int w, int h, CartridgeCV& cart)
27 : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
28 myCart(cart)
29{
30 // Eventually, we should query this from the debugger/disassembler
31 uInt16 size = 2048;
32 uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4];
33 start -= start % size;
34
35 ostringstream info;
36 info << "CV 2K ROM + 1K RAM , non-bankswitched\n"
37 << "1024 bytes RAM @ $F000 - $F7FF\n"
38 << " $F000 - $F3FF (R), $F400 - $F7FF (W)\n"
39 << "ROM accessible @ $" << Common::Base::HEX4 << start << " - "
40 << "$" << (start + size - 1);
41
42 addBaseInformation(cart.mySize, "CommaVid", info.str());
43}
44
45// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46void CartridgeCVWidget::saveOldState()
47{
48 myOldState.internalram.clear();
49
50 for(uInt32 i = 0; i < internalRamSize(); ++i)
51 myOldState.internalram.push_back(myCart.myRAM[i]);
52}
53
54// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
55uInt32 CartridgeCVWidget::internalRamSize()
56{
57 return 1024;
58}
59
60// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61uInt32 CartridgeCVWidget::internalRamRPort(int start)
62{
63 return 0xF000 + start;
64}
65
66// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
67string CartridgeCVWidget::internalRamDescription()
68{
69 ostringstream desc;
70 desc << "$F000 - $F3FF used for Read Access\n"
71 << "$F400 - $F7FF used for Write Access";
72
73 return desc.str();
74}
75
76// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77const ByteArray& CartridgeCVWidget::internalRamOld(int start, int count)
78{
79 myRamOld.clear();
80 for(int i = 0; i < count; i++)
81 myRamOld.push_back(myOldState.internalram[start + i]);
82 return myRamOld;
83}
84
85// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
86const ByteArray& CartridgeCVWidget::internalRamCurrent(int start, int count)
87{
88 myRamCurrent.clear();
89 for(int i = 0; i < count; i++)
90 myRamCurrent.push_back(myCart.myRAM[start + i]);
91 return myRamCurrent;
92}
93
94// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95void CartridgeCVWidget::internalRamSetValue(int addr, uInt8 value)
96{
97 myCart.myRAM[addr] = value;
98}
99
100// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101uInt8 CartridgeCVWidget::internalRamGetValue(int addr)
102{
103 return myCart.myRAM[addr];
104}
105
106// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107string CartridgeCVWidget::internalRamLabel(int addr)
108{
109 CartDebug& dbg = instance().debugger().cartDebug();
110 return dbg.getLabel(addr + 0xF000, false);
111}
112