void mc146818_device::set_base_datetime() { system_time systime; system_time::full_time current_time; machine().base_datetime(systime); current_time = (m_use_utc) ? systime.utc_time: systime.local_time; // logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n", // current_time.year % 100, current_time.month + 1, current_time.mday, // current_time.hour,current_time.minute, current_time.second); set_seconds(current_time.second); set_minutes(current_time.minute); set_hours(current_time.hour); set_dayofweek(current_time.weekday + 1); set_dayofmonth(current_time.mday); set_month(current_time.month + 1); if(m_binyear) set_year((current_time.year - m_epoch) % (m_data[REG_B] & REG_B_DM ? 0x100 : 100)); // pcd actually depends on this else set_year((current_time.year - m_epoch) % 100); if (m_century_index >= 0) m_data[m_century_index] = to_ram(current_time.year / 100); }
void mc146818_device::set_base_datetime() { system_time systime; system_time::full_time current_time; machine().base_datetime(systime); current_time = (m_use_utc) ? systime.utc_time: systime.local_time; // logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n", // current_time.year % 100, current_time.month + 1, current_time.mday, // current_time.hour,current_time.minute, current_time.second); set_seconds(current_time.second); set_minutes(current_time.minute); set_hours(current_time.hour); set_dayofweek(current_time.weekday + 1); set_dayofmonth(current_time.mday); set_month(current_time.month + 1); set_year(current_time.year % 100); if (m_century_index >= 0) m_data[m_century_index] = to_ram(current_time.year / 100); }
void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_PERIODIC: m_data[REG_C] |= REG_C_PF; update_irq(); break; case TIMER_CLOCK: if (!(m_data[REG_B] & REG_B_SET)) { /// TODO: find out how the real chip deals with updates when binary/bcd values are already outside the normal range int seconds = get_seconds() + 1; if (seconds < 60) { set_seconds(seconds); } else { set_seconds(0); int minutes = get_minutes() + 1; if (minutes < 60) { set_minutes(minutes); } else { set_minutes(0); int hours = get_hours() + 1; if (hours < 24) { set_hours(hours); } else { set_hours(0); int dayofweek = get_dayofweek() + 1; if (dayofweek <= 7) { set_dayofweek(dayofweek); } else { set_dayofweek(1); } int dayofmonth = get_dayofmonth() + 1; if (dayofmonth <= gregorian_days_in_month(get_month(), get_year() + 2000)) { set_dayofmonth(dayofmonth); } else { set_dayofmonth(1); int month = get_month() + 1; if (month <= 12) { set_month(month); } else { set_month(1); set_year((get_year() + 1) % 100); } } } } } if ((m_data[REG_ALARM_SECONDS] == m_data[REG_SECONDS] || (m_data[REG_ALARM_SECONDS] & ALARM_DONTCARE) == ALARM_DONTCARE) && (m_data[REG_ALARM_MINUTES] == m_data[REG_MINUTES] || (m_data[REG_ALARM_MINUTES] & ALARM_DONTCARE) == ALARM_DONTCARE) && (m_data[REG_ALARM_HOURS] == m_data[REG_HOURS] || (m_data[REG_ALARM_HOURS] & ALARM_DONTCARE) == ALARM_DONTCARE)) { // set the alarm interrupt flag AF m_data[REG_C] |= REG_C_AF; } // set the update-ended interrupt Flag UF m_data[REG_C] |= REG_C_UF; update_irq(); m_last_refresh = machine().time(); } break; } }
int main(int argc, char *argv[]) { // Set the tiltle of the window system("title "); // Pdcurses initiation functions initscr(); scrollok(stdscr, TRUE); raw(); noecho(); clear(); keypad(stdscr, TRUE); // Get max height and width of the console. getmaxyx(stdscr, max_y, max_x); // Color functions/declarations start_color(); init_color(COLOR_RED, 1000, 500, 500); init_pair(1, 15, 9); init_pair(2, 0, 7); init_pair(3, 15, 0); init_pair(4, 15, 1); init_pair(5, 12, 0); init_pair(6, 10, 0); init_pair(7, 13, 0); init_pair(8, 11, 0); // Title of the app (with blue background) titlebar(); attron(COLOR_PAIR(3)); // Function to enable coloured text based on color pair (init_pair) declared before. mvprintw(2, 1, "Welcome to rF3.Calendar!"); mvprintw(3, 1, "------------------------"); mvprintw(5, 1, "Please select the month / year..."); mvprintw(6, 1, "Press key LEFT or RIGHT to change and ENTER to select."); mvprintw(7, 1, "To quit this program, press Q."); refresh(); // Adding example events to the vector event_saved = true; data.save_name("Example Event"); data.save_loc("Engineering Faculty"); data.min = 20; data.hour = 11; srand(time_t(NULL)); for (int o = 1; o < 31; o++) { data.day = rand() % (10 - 1 + 1) + 1; data.nmon = rand() % (12 - 1 + 1) + 1; data.year = rand() % (2014 - 1990 + 1) + 1990; myVector.push_back(data); } // Old code // Show the calendar and user must select one //show_calendar(true,14,10); set_month(); menu(); return 0; }
void set_date(){ clear_pixelMatrix(); print_date(POS_DATE_SET); print_year(); print_symbol(16,17, hakenSymb,108,46); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); update_LCD(); int old_selectedItem = 0; int item = 0; while (item != 3){ cli(); btn_drehenc_pushed = false; sei(); while(!btn_drehenc_pushed){ if(rotary != 0){ item += rotary; cli(); rotary = 0; sei(); item = item % 4; if(item<0){ item += 4; } switch (old_selectedItem){ case 0: for(int x = 0; x<128; x++){ for(int y = 0; y<10; y++) reset_pixel(x,y); } break; case 1: for(int x = 0; x<128; x++){ for(int y = 0; y<10; y++) reset_pixel(x,y); }break; case 2: for(int x = 0; x<128; x++){ for(int y = 30; y<40; y++) reset_pixel(x,y); }break; case 3: for(int x = 94; x<104; x++){ for(int y = 2+3*15+5; y<2+3*15+5+8; y++) reset_pixel(x,y); }break; } switch (item) { case 0: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); break; //-4 = halbe Länge Herz case 1: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); break; case 2: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10);break; case 3: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, 94, 2+3*15+5);break; } old_selectedItem = item; update_LCD(); } goodNight(); check_light(); } cli(); btn_drehenc_pushed = false; sei(); switch (item) { case 0: { print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); update_LCD(); set_day(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); break; } case 1:{ print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); update_LCD(); set_month(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); break; } case 2: { print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10); update_LCD(); set_year(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10); break; } default: break; } update_LCD(); } }