Skip to content

Commit

Permalink
Separated CRTC state and PALETTE state debug info.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainYS authored and CaptainYS committed Jun 19, 2020
1 parent 472efb1 commit 2675c43
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 46 deletions.
5 changes: 5 additions & 0 deletions command.md
Expand Up @@ -742,6 +742,11 @@ CRTC
```
CRTC.

```
PALETTE
```
Palette.

```
TIMER
```
Expand Down
9 changes: 9 additions & 0 deletions src/main_cui/command/townscommand.cpp
Expand Up @@ -127,6 +127,7 @@ TownsCommandInterpreter::TownsCommandInterpreter()
dumpableMap["DMAC"]=DUMP_DMAC;
dumpableMap["FDC"]=DUMP_FDC;
dumpableMap["CRTC"]=DUMP_CRTC;
dumpableMap["PALETTE"]=DUMP_PALETTE;
dumpableMap["TIMER"]=DUMP_TIMER;
dumpableMap["GDT"]=DUMP_GDT;
dumpableMap["LDT"]=DUMP_LDT;
Expand Down Expand Up @@ -338,6 +339,8 @@ void TownsCommandInterpreter::PrintHelp(void) const
std::cout << " SCSI Controller." << std::endl;
std::cout << "CRTC" << std::endl;
std::cout << " CRTC." << std::endl;
std::cout << "PALETTE" << std::endl;
std::cout << " PALETTE." << std::endl;
std::cout << "TIMER" << std::endl;
std::cout << " Interval Timer (i8253)" << std::endl;
std::cout << "MEM" << std::endl;
Expand Down Expand Up @@ -938,6 +941,12 @@ void TownsCommandInterpreter::Execute_Dump(FMTowns &towns,Command &cmd)
std::cout << str << std::endl;
}
break;
case DUMP_PALETTE:
for(auto str : towns.crtc.GetPaletteText())
{
std::cout << str << std::endl;
}
break;
case DUMP_TIMER:
towns.PrintTimer();
break;
Expand Down
1 change: 1 addition & 0 deletions src/main_cui/command/townscommand.h
Expand Up @@ -133,6 +133,7 @@ class TownsCommandInterpreter
DUMP_DMAC,
DUMP_FDC,
DUMP_CRTC,
DUMP_PALETTE,
DUMP_TIMER,
DUMP_GDT,
DUMP_LDT,
Expand Down
97 changes: 51 additions & 46 deletions src/towns/crtc/crtc.cpp
Expand Up @@ -827,15 +827,14 @@ Vec2i TownsCRTC::GetRenderSize(void) const
std::vector <std::string> TownsCRTC::GetStatusText(void) const
{
std::vector <std::string> text;
std::string empty;

text.push_back(empty);
text.push_back("");
text.back()="Registers:";
for(int i=0; i<sizeof(state.crtcReg)/sizeof(state.crtcReg[0]); ++i)
{
if(0==i%16)
{
text.push_back(empty);
text.push_back("");
text.back()+="REG";
text.back()+=cpputil::Ubtox(i);
text.back()+=":";
Expand All @@ -844,7 +843,7 @@ std::vector <std::string> TownsCRTC::GetStatusText(void) const
text.back()+=cpputil::Ustox(state.crtcReg[i]);
}

text.push_back(empty);
text.push_back("");
text.back()="Sifters (Isn't it Shifter?):";
for(int i=0; i<2; ++i)
{
Expand All @@ -861,7 +860,7 @@ std::vector <std::string> TownsCRTC::GetStatusText(void) const
text.back().push_back('0'+(state.crtcReg[REG_CR1]&3));


text.push_back(empty);
text.push_back("");
text.back()="Address Latch: ";
text.back()+=cpputil::Uitox(state.crtcAddrLatch)+"H";

Expand All @@ -871,20 +870,20 @@ std::vector <std::string> TownsCRTC::GetStatusText(void) const
(unsigned int)((state.crtcReg[REG_CR0]>>2)&3),
};

text.push_back(empty);
text.push_back("");
text.back()="CL0:"+cpputil::Itoa(CL[0])+" CL1:"+cpputil::Itoa(CL[1]);

if(true==InSinglePageMode())
{
text.push_back(empty);
text.push_back("");
text.back()="Single-Page Mode. ";

auto pageStat0=GetPageStatusText(0);
text.insert(text.end(),pageStat0.begin(),pageStat0.end());
}
else
{
text.push_back(empty);
text.push_back("");
text.back()="2-Page Mode. ";

auto pageStat0=GetPageStatusText(0);
Expand All @@ -894,37 +893,7 @@ std::vector <std::string> TownsCRTC::GetStatusText(void) const
text.insert(text.end(),pageStat1.begin(),pageStat1.end());
}

text.push_back(empty);
text.back()+="16-Color Palette";
for(int page=0; page<2; ++page)
{
text.push_back(empty);
text.back()+="Page";
text.back().push_back((char)('0'+page));
text.back().push_back(':');
for(int i=0; i<16; ++i)
{
text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][0]);
text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][1]);
text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][2]);
text.back().push_back(' ');
}
}
text.push_back(empty);
text.back()+="256-Color Palette";
for(int i=0; i<256; i+=16)
{
text.push_back(empty);
for(int j=0; j<16; ++j)
{
text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][0]);
text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][1]);
text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][2]);
text.back().push_back(' ');
}
}

text.push_back(empty);
text.push_back("");
text.back()+="VSYNC:";
text.back()+=cpputil::BoolToChar(state.VSYNC);

Expand All @@ -937,27 +906,63 @@ std::vector <std::string> TownsCRTC::GetPageStatusText(int page) const
MakePageLayerInfo(layer,page);

std::vector <std::string> text;
std::string empty;

text.push_back(empty);
text.push_back("");
text.back()="Page "+cpputil::Itoa(page);

text.push_back(empty);
text.push_back("");
text.back()+="Top-Left:("+cpputil::Itoa(layer.originOnMonitor.x())+","+cpputil::Itoa(layer.originOnMonitor.y())+") ";
text.back()+="Display Size:("+cpputil::Itoa(layer.sizeOnMonitor.x())+","+cpputil::Itoa(layer.sizeOnMonitor.y())+")";

text.push_back(empty);
text.push_back("");
text.back()+=cpputil::Itoa(layer.bitsPerPixel)+"-bit color";

text.push_back(empty);
text.push_back("");
text.back()+="VRAM Base="+cpputil::Uitox(layer.VRAMAddr);
text.back()+=" Offset="+cpputil::Uitox(layer.VRAMOffset);

text.push_back(empty);
text.push_back("");
text.back()+="BytesPerLine="+cpputil::Uitox(layer.bytesPerLine);

text.push_back(empty);
text.push_back("");
text.back()+="Zoom=("+cpputil::Uitox(layer.zoom.x())+","+cpputil::Uitox(layer.zoom.y())+")";

return text;
}

std::vector <std::string> TownsCRTC::GetPaletteText(void) const
{
std::vector <std::string> text;

text.push_back("");
text.back()+="16-Color Palette";
for(int page=0; page<2; ++page)
{
text.push_back("");
text.back()+="Page";
text.back().push_back((char)('0'+page));
text.back().push_back(':');
for(int i=0; i<16; ++i)
{
text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][0]);
text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][1]);
text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][2]);
text.back().push_back(' ');
}
}
text.push_back("");
text.back()+="256-Color Palette";
for(int i=0; i<256; i+=16)
{
text.push_back("");
for(int j=0; j<16; ++j)
{
text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][0]);
text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][1]);
text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][2]);
text.back().push_back(' ');
}
}

return text;
}
1 change: 1 addition & 0 deletions src/towns/crtc/crtc.h
Expand Up @@ -329,6 +329,7 @@ class TownsCRTC : public Device

std::vector <std::string> GetStatusText(void) const;
std::vector <std::string> GetPageStatusText(int page) const;
std::vector <std::string> GetPaletteText(void) const;
};


Expand Down

0 comments on commit 2675c43

Please sign in to comment.