예제 #1
0
파일: Printer.cpp 프로젝트: ctcchan/ctools
void Printer::programHeading(string program, int filling, char out, ofstream &outFile, string addString) {
    fillDisplay('*', filling);
    cout << endl << program + addString << endl;    // add " (left)" or " (right)"
    fillDisplay('*', filling);
    cout << endl;

    if (out == 'y')
        outFile << program + addString << endl << endl;
}
예제 #2
0
파일: Printer.cpp 프로젝트: ctcchan/ctools
void Printer::heading() {
    fillDisplay('=', 61);
    cout << endl << "\t\t" << getTitle() << ", " << getVersion() << ", " << getYear() << endl << endl
        << "This program lets you construct pitch sets, rows or matrixes" << endl
        << "from input, then display them to the console or outputs them" << endl
        << "to a file in your current working directory. Please choose" << endl
        << "from the options below." << endl << endl
        << "** This program can be downloaded and used freely but is" << endl
        << "provided with no warranties." << endl << endl
        << right << setfill(' ') << setw(46) << "by " << getAuthor() << endl
        << setw(60) << getEmail() << endl
        << setw(60) << getWeb() << endl;
    fillDisplay('=', 61);
}
예제 #3
0
파일: Printer.cpp 프로젝트: ctcchan/ctools
void Printer::programHeading(char out, ofstream &outFile) {
    Modules mod;

    fillDisplay('*', 14);
    cout << endl << "The Prime Set" << endl;
    fillDisplay('*', 14);
    cout << endl;

    if (out == 'y') {
        outFile << "The Prime Set" << endl;
        for (int i = 0; i < mod.getRowSize(1); i++)
            outFile << TABLE[mod.getRow(i, 5)] << " ";
        outFile << endl << endl;
    }
}
예제 #4
0
void updateCenter(AppState & state) {
  Point bottomLeft = state.convertBufferToScreen(Point(0,0));
  Point topRight = state.convertBufferToScreen(Point(MY_BG_W,MY_BG_H));

  Point newCenter = state.convertScreenToImage(Point(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
  // printf("--------------\n");
  // printf("%d %d\n", bottomLeft.x, bottomLeft.y);
  // printf("%d %d\n", topRight.x, topRight.y);
  // printf("%d %d\n", newCenter.x, newCenter.y);

  if (bottomLeft.x > 0 || bottomLeft.y > 0 || topRight.x < SCREEN_WIDTH || topRight.y < SCREEN_HEIGHT) {
    //Point newCenter = state.convertScreenToImage(Point(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
      state.scroll_x = MY_BG_W/2-SCREEN_WIDTH/2;
      state.scroll_y = MY_BG_H/2-SCREEN_HEIGHT/2;
      state.center_x = newCenter.x;
      state.center_y = newCenter.y;

      // printf("%d %d\n", state.center_x, state.center_y);
      bgHide(3);
      fillDisplay(RGB15(0,0,0) | BIT(15), state.lastPage, state);
      drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state);
  }
  bgSetScroll(3, state.scroll_x, state.scroll_y);
  bgUpdate();
  bgShow(3);
}
예제 #5
0
파일: Printer.cpp 프로젝트: ctcchan/ctools
void Printer::programHeading(int s, int r, int d, char out, ofstream &outFile, string addString) {
    Modules mod;

    if (d == 1) d = 8;   //  " (right)" has 8 characters
    else if (d == -1) d = 7; // " (left)" has 7 characters
    else d = 0;

    fillDisplay('*', (r == 0 && s == -1) ? 52 + d : (r == 1 && s == -1) ? 40 + d :
            (r == 0 && s == 1) ? 37 + d : 25 + d); // nested ? : to determine '*' length
    cout << endl;
    if (r == 0 && s == -1)
        cout << "The Multiplication Table with Inversion in Rotation" + addString;  // add " (left) or " (right)"
    else if (r == 1 && s == -1)
        cout << "The Multiplication Table with Inversion";
    else if (r == 0 && s == 1)
        cout << "The Multiplication Table in Rotation" + addString;
    else
        cout << "The Multiplication Table";
    cout << endl;
    fillDisplay('*', (r == 0 && s == -1) ? 52 + d : (r == 1 && s == -1) ? 40 + d :
            (r == 0 && s == 1) ? 37 + d : 25 + d);
    cout << endl;

    if (out == 'y') {
        if (r == 0 && s == -1)
            outFile << "The Multiplication Table with Inversion in Rotation" + addString;
        else if (r == 1 && s == -1)
            outFile << "The Multiplication Table with Inversion";
        else if (r == 0 && s == 1)
            outFile << "The Multiplication Table in Rotation" + addString;
        else
            outFile << "The Multiplication Table";
        outFile << endl;

        for (int i = 0; i < mod.getRowSize(1); i++)
            outFile << TABLE[mod.getRow(i, 1)] << " ";
        outFile << " x   ";
        for (int i = 0; i < mod.getRowSize(2); i++)
            outFile << TABLE[mod.getRow(i, 2)] << " ";
        outFile << endl << endl;
    }
}
예제 #6
0
int main(void) {

  consoleDemoInit();

  //videoSetMode(MODE_FB0);
  videoSetMode( MODE_5_2D );
  vramSetBankA(VRAM_A_MAIN_BG);
  vramSetBankB(VRAM_B_MAIN_BG);
  // vramSetBankC(VRAM_C_MAIN_BG);
  // vramSetBankD(VRAM_D_MAIN_BG_0x06040000);
  int bg = bgInit(3, BgType_Bmp8, BgSize_B8_512x512, 0,0);  //vramSetBankA(VRAM_A_LCD);

  lcdMainOnBottom();
  // lcdMainOnTop();

  printf("Video modes configured\n");
  printf("BG ID %d\n", bg);

  if (fatInitDefault())
    printf("FAT initialized\n");
  else
    printf("FAT initialization failed\n");

  AppState state;
  uiOpenNotebook(state);

  // Keyboard *kbd =  keyboardDemoInit();

  Segment * currentSegment = NULL;


  touchPosition touch;

  while (1) {
    scanKeys();
    
    if(keysHeld() & KEY_TOUCH)
      {
	// write the touchscreen coordinates in the touch variable
	touchRead(&touch);
	
	Point screenPoint = Point(touch.px, touch.py);
	Point imagePoint = state.convertScreenToImage(screenPoint);

	if (currentSegment == NULL) {
	  state.currentPage->segments.push_back(Segment());
	  currentSegment = &(state.currentPage->segments[state.currentPage->segments.size()-1]);
	  currentSegment->points.push_back(imagePoint);
	  continue;
	}

	Point lastImagePoint = currentSegment->points[currentSegment->points.size()-1];
	currentSegment->points.push_back(imagePoint);

	Point bufferPoint = state.convertScreenToBuffer(screenPoint);
	Point lastBufferPoint = state.convertImageToBuffer(lastImagePoint);
	drawLine(lastBufferPoint.x, lastBufferPoint.y,  bufferPoint.x, bufferPoint.y, RGB15(31,0,0) | BIT(15));
      }    
    else {
      currentSegment = NULL;
    }
    if (keysDown() & KEY_X) {
      int page = state.lastPage+1;
      while (state.notebook.pages.size() < page+1) {
	state.notebook.pages.push_back(Page());
	printf("New Page created\n");
      }
      state.currentPage = &(state.notebook.pages[page]);
      currentSegment = NULL;

      printf("Display page %d\n", page);

      fillDisplay(RGB15(0,0,0) | BIT(15), page, state);
      drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state);
    }
    if (keysDown() & KEY_Y) {
      int page = 0;
      if (state.lastPage > 0) {
	page = state.lastPage-1;
      }
      state.currentPage = &(state.notebook.pages[page]);
      currentSegment = NULL;

      printf("Display page %d\n", page);

      fillDisplay(RGB15(0,0,0) | BIT(15), page, state);
      drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state);
    }
    if (keysDown() & KEY_A) {
      int page = 0;
      std::string fileName = state.notebookName + "/notes.txt";
      state.notebook = loadFile(fileName.c_str());

      state.currentPage = &(state.notebook.pages[page]);
      currentSegment = NULL;

      printf("Display page %d\n", page);

      fillDisplay(RGB15(0,0,0) | BIT(15), page, state);
      drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state);
    }
    if (keysDown() & KEY_B) {
      std::string fileName = state.notebookName + "/notes.txt";
      saveFile(fileName.c_str(), state.notebook);
    }
    if (keysDown() & KEY_LEFT) {
      state.scroll_x-=50;
      updateCenter(state);
    }
    if (keysDown() & KEY_RIGHT) {
      state.scroll_x+=50;
      updateCenter(state);
    }
    if (keysDown() & KEY_UP) {
      state.scroll_y-=50;
      updateCenter(state);
    }
    if (keysDown() & KEY_DOWN) {
      state.scroll_y+=50;
      updateCenter(state);
    }
    if (keysDown() & KEY_START) {
      uiOpenNotebook(state);
    }

    swiWaitForVBlank();
  }
}
예제 #7
0
 void uiOpenNotebook(AppState & state) {
   lcdMainOnTop();

   DIR_ITER* dir = diropen (MAINPATH);
   if (dir == NULL) {
     printf("Marginalia data not found\n");
     return;
   }

   printf("\x1b[2J");
   printf("Select notebook to open\n(Press Select to create NEW)");

   struct stat st;
   char filename[MAXPATHLEN];
   int i=0;

   std::vector<std::string> notebooks;

   while (dirnext(dir, filename, &st) == 0) {
     // st.st_mode & S_IFDIR indicates a directory
     // if (!(st.st_mode & S_IFDIR))
     //   continue;
     // if (strcmp(filename, "..") == 0)
     //   continue;
     // if (strcmp(filename, ".") == 0)
     //   continue;
     printf ("\x1b[%d;3H%d)   %s\n", i+3, i, filename);
     notebooks.push_back(filename);
     i++;
   }
   dirclose (dir);
   int selected = 0;
   printf ("\x1b[%d;6H*", selected+3);
   
   while (1) {
    scanKeys();
    
    if(keysHeld() & KEY_TOUCH)
      {
      }    
    if (keysDown() & KEY_X) {
    }
    if (keysDown() & KEY_Y) {
    }
    if (keysDown() & KEY_SELECT) {
      printf ("\x1b[10;1H Insert new Directory Name");
      char newName[256];

      Keyboard *kbd =  keyboardDemoInit();

      scanf("%s", newName);
      printf ("\x1b[11;1H Creating directory %s", newName);

      state.notebookName = newName;
      if (mkdir(state.notebookName.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) {
	printf ("\x1b[12;1H directory creation failed");
	continue;
      }
      
      state.lastPage = -1;
      state.scroll_x = 0;
      state.scroll_y = 0;

      state.center_x = MY_BG_W/2;
      state.center_y = MY_BG_H/2;

      fillDisplay(RGB15(0,0,0) | BIT(15), 0, state);

      std::string fileName = state.notebookName + "/notes.txt";
      state.notebook = loadFile(fileName.c_str());
      state.currentPage = &(state.notebook.pages[0]);

      drawPage(state.currentPage, RGB15(31,31,31) | BIT(15), state);
      lcdMainOnBottom();
      return;
    }
    if (keysDown() & KEY_A) {
      printf ("\x1b[20;6H opening %s\n", notebooks[selected].c_str());
      state.lastPage = -1;
      state.scroll_x = 0;
      state.scroll_y = 0;

      state.center_x = MY_BG_W/2;
      state.center_y = MY_BG_H/2;

      state.notebookName = notebooks[selected];

      fillDisplay(RGB15(0,0,0) | BIT(15), 0, state);

      std::string fileName = state.notebookName + "/notes.txt";
      state.notebook = loadFile(fileName.c_str());
      state.currentPage = &(state.notebook.pages[0]);

      drawPage(state.currentPage, RGB15(31,31,31) | BIT(15), state);
      lcdMainOnBottom();
      return;
    }
    if (keysDown() & KEY_B) {
    }
    if (keysDown() & KEY_LEFT) {
    }
    if (keysDown() & KEY_RIGHT) {
    }
    if (keysDown() & KEY_UP) {
      printf ("\x1b[%d;6H ", selected+3);
      selected -= 1;
      printf ("\x1b[%d;6H*", selected+3);
    }
    if (keysDown() & KEY_DOWN) {
      printf ("\x1b[%d;6H ", selected+3);
      selected += 1;
      printf ("\x1b[%d;6H*", selected+3);
    }

    swiWaitForVBlank();
  }
 }