/* Copyright (c) Günter Woigk 2002 - 2009 mailto:kio@little-bat.de This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the copyright holder not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The copyright holder makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define LOG 1 #define SAFE 3 #include #include "AyInsp.h" #include "Ay.h" INIT_MSG QFont* ff = NULL; static QLineEdit* newled( cstr s ) { QLineEdit* e = new QLineEdit(s); e->setAlignment(Qt::AlignHCenter); e->setFrame(0); e->setReadOnly(1); if(!ff) { ff = new QFont(e->font()); ff->setFamily("Monaco"/*"Andale Mono"*/); ff->setPixelSize(12); } e->setFont(*ff); return e; } AyInsp::AyInsp( QWidget* w, ZxItem* i ) : Inspector(w,i,"/Backgrounds/light-150-s.jpg") { XXASSERT( i->IsA(isa_Ay) ); memset(&value,0,sizeof(value)); value.clock=0.0; QGridLayout* g = new QGridLayout(this); g->setContentsMargins(10,10,10,10); g->setVerticalSpacing(4); g->setRowStretch(13,100); g->setColumnStretch(0,33); g->setColumnStretch(1,66); clock=newled("0.0 MHz"); g->addWidget(new QLabel("Clock"), 0,0,Qt::AlignRight); g->addWidget(clock,0,1); pitch_a = newled("0000"); g->addWidget(new QLabel("A pitch"), 1,0,Qt::AlignRight); g->addWidget(pitch_a,1,1); pitch_b = newled("0000"); g->addWidget(new QLabel("B pitch"), 2,0,Qt::AlignRight); g->addWidget(pitch_b,2,1); pitch_c = newled("0000"); g->addWidget(new QLabel("C pitch"), 3,0,Qt::AlignRight); g->addWidget(pitch_c,3,1); pitch_n = newled("0000"); g->addWidget(new QLabel("Noise pi."), 4,0,Qt::AlignRight); g->addWidget(pitch_n,4,1); mixer = newled("--------"); g->addWidget(new QLabel("Mixer"), 5,0,Qt::AlignRight); g->addWidget(mixer,5,1); vol_a = newled("00"); g->addWidget(new QLabel("A volume"), 6,0,Qt::AlignRight); g->addWidget(vol_a,6,1); vol_b = newled("00"); g->addWidget(new QLabel("B volume"), 7,0,Qt::AlignRight); g->addWidget(vol_b,7,1); vol_c = newled("00"); g->addWidget(new QLabel("C volume"), 8,0,Qt::AlignRight); g->addWidget(vol_c,8,1); pitch_e = newled("0000"); g->addWidget(new QLabel("Env pitch"), 9,0,Qt::AlignRight); g->addWidget(pitch_e,9,1); shape_e = newled("----"); g->addWidget(new QLabel("Env shape"), 10,0,Qt::AlignRight); g->addWidget(shape_e,10,1); port_a = newled("$00"); g->addWidget(new QLabel("Port A"), 11,0,Qt::AlignRight); g->addWidget(port_a,11,1); port_b = newled("$00"); g->addWidget(new QLabel("Port B"), 12,0,Qt::AlignRight); g->addWidget(port_b,12,1); stereo = new QComboBox(this); stereo->addItem("Mono"); stereo->addItem("ABC Stereo"); stereo->addItem("ACB Stereo"); value.stereo=ay()->GetStereoMix(); stereo->setCurrentIndex(value.stereo); g->addWidget(stereo,13,1); timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(update())); timer->start(1000/10); } void AyInsp::setReadOnly(bool f) { for( uint i=0; isetReadOnly(f); } static cstr MHzStr( Frequency f ) { str s = TempStr(16); if( f>=1000000 ) sprintf(s,"%.5g MHz",f/1000000.0); else if( f>=1000 ) sprintf(s,"%.5g kHz",f/1000.0); else sprintf(s,"%.5g Hz", f); return s; } static cstr es[]= { "\\___", "\\___","\\___", "\\___", "/___", "/___", "/___", "/___", "\\\\\\\\\\\\","\\___","\\/\\/\\/", "\\ ̄ ̄ ̄", "//////", "/ ̄ ̄ ̄", "/\\/\\/\\", "/___" }; void AyInsp::update() { XXXLogIn("AyInsp::update"); if(!ay()) { timer->stop(); return; } uint8 const* regs = ay()->GetRegisters(); if( value.clock != ay()->GetClock() ) { value.clock = ay()->GetClock(); clock->setText(MHzStr(value.clock)); } if( value.stereo!= ay()->GetStereoMix() ) { value.stereo = ay()->GetStereoMix(); stereo->setCurrentIndex(value.stereo); } for(int i=0;i<16;i++) { if(value.regs[i]==regs[i]) continue; value.regs[i] = regs[i]; switch(i) { case 0: value.regs[1] = regs[1]; i++; case 1: pitch_a->setText(NumStr(value.regs[0]+256*value.regs[1])); break; case 2: value.regs[3] = regs[3]; i++; case 3: pitch_b->setText(NumStr(value.regs[2]+256*value.regs[3])); break; case 4: value.regs[5] = regs[5]; i++; case 5: pitch_c->setText(NumStr(value.regs[4]+256*value.regs[5])); break; case 6: pitch_n->setText(NumStr(value.regs[6])); break; case 7: mixer->setText(BinStr(value.regs[7],"iicbaCBA","oo------")); break; case 8: vol_a->setText(value.regs[8]&0x10?"Envelope":NumStr(value.regs[8])); break; case 9: vol_b->setText(value.regs[9]&0x10?"Envelope":NumStr(value.regs[9])); break; case 10:vol_c->setText(value.regs[10]&0x10?"Envelope":NumStr(value.regs[10])); break; case 11:value.regs[12] = regs[12]; i++; case 12:pitch_e->setText(NumStr(value.regs[11]+256u*value.regs[12])); break; case 13:shape_e->setText(es[value.regs[13]&0x0f]); break; case 14:port_a->setText(CatStr("$",HexStr(value.regs[14],2))); break; // value written. TODO: read? case 15:port_b->setText(CatStr("$",HexStr(value.regs[15],2))); break; // value written. TODO: read? } } }