/************************************************************************* * uLoad * "Parse" a uCode source program (using flex to scan it). *************************************************************************/ int uLoad(uINSTRUCTION code[], int label[]) { uINSTRUCTION *currInstr; int codeLine = 0; int i, lab; do { currInstr = &(code[codeLine]); clearInstruction(currInstr); codeFlag = valid; loadOpcode(currInstr); if (codeFlag == valid) { switch (yytok) { case tHLT: break; case tRD: case tRDF: case tRDS: loadTarget(currInstr, 0); break; case tWRT: case tWRTLN: loadSource(currInstr, 0); break; case tWRTS: case tWRTLNS: break; case tMOV : case tNEG : case tNEGF : case tCASTI: case tCASTF: loadSource(currInstr, 0); loadTarget(currInstr, 1); break; case tADD : case tSUB : case tMUL : case tDIV : case tMOD : case tADDF : case tSUBF : case tMULF : case tDIVF : loadSource(currInstr, 0); loadSource(currInstr, 1); loadTarget(currInstr, 2); break; case tPUSH: loadSource(currInstr, 0); break; case tPOP : loadTarget(currInstr, 0); break; case tNEGS: case tADDS: case tSUBS: case tMULS: case tDIVS: case tMODS: case tNEGSF: case tADDSF: case tSUBSF: case tMULSF: case tDIVSF: case tCASTSI: case tCASTSF: break; /* Label instruction must be handled at load time */ case tLAB : { sscanf(yytext, "%*[Ll]%d:", &lab); currInstr->Operand[0].Mode = mLabel; setOperandValue(&(currInstr->Operand[0]), lab); validateLabel(lab); if (codeFlag == valid) { if (label[lab] != undefinedLabel) { sprintf(loadMessage, "L%d REDEFINED", lab); codeFlag = badLabel; } else { label[lab] = codeLine; } } break; } case tANDS: case tORS: case tNOTS: break; case tCMPEQS: case tCMPGES: case tCMPGTS: case tCMPLES: case tCMPLTS: case tCMPNES: case tCMPEQSF: case tCMPGESF: case tCMPGTSF: case tCMPLESF: case tCMPLTSF: case tCMPNESF: break; case tBRTS: case tBRFS: loadLabel(currInstr, 0); break; case tBR : loadLabel(currInstr, 0); break; case tBEQ : case tBGE : case tBGT : case tBLE : case tBLT : case tBNE : case tBEQF : case tBGEF : case tBGTF : case tBLEF : case tBLTF : case tBNEF : loadSource(currInstr, 0); loadSource(currInstr, 1); loadLabel (currInstr, 2); break; case tCALL: loadLabel(currInstr, 0); break; case tRET : break; case tEOF : break; case tPRTS: case tPRTR: break; default: perror(">>> INTERNAL ERROR IN LOAD_uCODE <<<"); exit(1); } loadEnd(); } /* Print an error message if an error occured */ if (codeFlag != valid) { loadError(loadText, loadLine, loadMessage); switch (codeFlag) { case invalidOpcode: break; case invalidForm: printCorrectForm(currInstr->Opcode); break; case invalidRegister: fprintf(stderr, "\n VALID RegisterS RANGE FROM 0 to "); fprintf(stderr, "%d", registerCount); fprintf(stderr, "\n"); break; case invalidLabel: fprintf(stderr, "\n VALID LABELS RANGE FROM 0 to "); fprintf(stderr, "%d", labelCount); fprintf(stderr, "\n"); break; case badLabel: case invalidString: break; default: perror(">>> INTERNAL ERROR IN uLOAD <<<"); exit(1); } } /* Process debugging information and update counters */ fillInformation(currInstr, loadText, loadLine); loadText[0] = '\0'; loadLine++; codeLine++; if (codeLine >= codeSize) { fprintf(stderr, ">>> CODE MEMORY OVERFLOW <<<\n"); exit(1); } } while (yytok != tEOF); /* Resolve labels if source was loaded successfully */ if (loadFlag == valid) { for (i = 0; i < labelCount; i++) { lab = label[i]; while ((lab < 0) && (lab != undefinedLabel)) { label[i] = label[-label[i]]; lab = label[i]; } } } return (loadFlag == valid) ?1 :0; }
DidYouKnowDialog::DidYouKnowDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Le saviez-vous ?")); //setMinimumWidth(400); list << tr("<center><b>Bienvenue sur TuxFisher</b></center><br/>" "TuxFisher est un jeu de réflexion ou vous devez manger les fishs<br/>" "sans se faire écraser par les avalanches et sans se retrouver bloqué.<br/>" "Utilisez les touches directionnelles (up, down, gauche, droite) pour vous déplacer.<br/>" "La touche [Ret. Arrière] (au dessus de [Entrer]) permet d'annuler un déplacement.<br/>" "Amusez-vous bien."); list << tr("Si vous avez fait un mouvement que vous souhaitez annuler,\n" "appuyez sur la touche [Ret. Arrière] (au dessus de [Entrer])\n" "et vous reviendrez à votre ancienne position.\n" "Vous pouvez annuler jusqu'à 20 déplacements."); list << tr("TuxFisher est un clone libre et gratuit du jeu Mr Matt, \n" "développé par J. Andrzej Wrotniak en 1996.\n" "Mr Matt et TuxFisher sont des dérivés de Boulder Dash"); list << tr("Vous pouvez activer et désactiver la music du jeu par le menu Options.\n" "Le titre de la music du jeu est Acclimate de General Fuzz.\n"); list << tr("Vous aussi vous pouvez créer des jeux pour TuxFisher \n" "grâce à l'éditeur de jeu de TuxFisher.\n" "Une fois terminé, vous pouvez mettre en ligne vos créations\n" "et les partager avec la communauté."); list << tr("Vous pouvez choisir les graphismes par le menu Options->Graphisms.\n" "Vous pouvez créer vos propres graphismes en créant un répertoire\n" "avec le nom désiré dans le répertoire \"graphismes\" du jeu.\n" "Ce répertoire doit contenir les images pour chaque case."); list << tr("Vous pouvez choisir les bruitages par le menu Options->Sons\n" "Pour désactiver les bruitages: Options->Sons->Aucun Son\n" "Vous pouvez créer vos bruitages en créant un new répertoire\n" "dans le répertoire \"sons\" du jeu."); button_close = new QPushButton(tr("Fermer"), this); button_next = new QPushButton(tr("Suivant"), this); button_previous = new QPushButton(tr("Précédent"), this); checkbox_afficher = new QCheckBox(tr("Ne plus afficher"), this); label_image = new QLabel(this); label_image->setPixmap(QPixmap(":/ressources/mainwindow/saviezvous.png")); label_text = new QLabel(this); //label_text->setWordWrap(true); qsrand(QDateTime::currentDateTime().toTime_t()); index=(qrand()%(list.count()-1))+1; loadLabel(); //label->setAlignment(Qt::AlignCenter); QHBoxLayout *layout_labels = new QHBoxLayout; layout_labels->addWidget(label_text); layout_labels->addStretch(); layout_labels->addWidget(label_image); QHBoxLayout *layout_buttons = new QHBoxLayout; layout_buttons->addWidget(checkbox_afficher); layout_buttons->addStretch(); layout_buttons->addWidget(button_close); layout_buttons->addWidget(button_previous); layout_buttons->addWidget(button_next); QVBoxLayout *layout = new QVBoxLayout; layout->addLayout(layout_labels); layout->addLayout(layout_buttons); setLayout(layout); connect( button_close, SIGNAL(clicked()), this, SLOT(accept()) ); connect( button_next, SIGNAL(clicked()), this, SLOT(next()) ); connect( button_previous, SIGNAL(clicked()), this, SLOT(previous()) ); }
void DidYouKnowDialog::previous() { if (index>0) index--; loadLabel(); }
void DidYouKnowDialog::next() { if (index<list.count()-1) index++; loadLabel(); }
void DidYouKnowDialog::displayWelcome() { index=0; loadLabel(); }