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); }
int main(void) { long r, lstlzz, error_code; int stkl, year; printf("\n/*************************"); printf("\n * This is the C-program *"); printf("\n *************************/\n"); printf("\nLohnsteuer (german wage tax) (all amounts in Euro):\n"); /* * Error-checking by return values is provided for every function. * Make sure, you always check them! The library will not crash if * you set illegal values, you will get results but they will be wrong. * This is a feature not a bug. Doing it this way, you can choose, * how to continue and what to do next. */ for (year = get_first_year(); year <= get_last_year(); ++year) { printf("\nYear: %d\n", year); printf (" RE4 I II III IV V VI\n"); printf ("--------------------------------------------------------\n"); for (r = 2; r <= 24; ++r) { printf("%8ld", r * 2500); for (stkl = 1; stkl <= 6; ++stkl) { error_code = reset_all(); if (error_code == no_error_code) error_code = set_year(year); if (error_code == no_error_code) error_code = set_lzz(1); /* * The library expects all amounts in Euro-Cent. * So we multiply by 100. */ if (error_code == no_error_code) error_code = set_re4(r * 250000); if (error_code == no_error_code) error_code = set_stkl(stkl); /* * After all parameters are set we call the function * which calculates the wage tax (Lohnsteuer) */ if (error_code == no_error_code) error_code = calc_lst(); /* * As above: the library returns Euro-Cents: */ if (error_code == no_error_code) lstlzz = get_lstlzz() / 100; if (error_code == no_error_code) printf("%8ld", lstlzz); else printf(" %s", "error"); } printf("\n"); }; if (error_code != no_error_code) { if (error_code == program_error_code) printf("Error: Program error.\n"); else if (error_code == tasking_error_code) printf("Error: Tasking error.\n"); else if (error_code == storage_error_code) printf("Error: Storage error.\n"); else if (error_code == constraint_error_code) printf ("Error: Constraint Error (probably value out of range).\n"); else if (error_code == parameter_not_defined_error_code) printf("Error: Parameter not defined.\n"); else if (error_code == general_error_code) printf("Error: General error.\n"); else /* * Should not be reached, all unknown errors should be caught * by general_error. If you get the following message, send * me a bug-report. */ printf("Unknown error.\n"); error_code = no_error_code; } } /* * Now an example for the income tax. Like above, you should always * check the return values. I spare it here to keep the example short. */ printf ("\nEinkommensteuer (german income tax) (all amounts in Euro):\n"); for (year = get_first_year(); year <= get_last_year(); ++year) { printf("\nYear: %d\n", year); printf(" ZVE Grundtabelle Splittingtabelle\n"); printf("------------------------------------------------\n"); for (r = 1; r <= 10; ++r) { printf("%8ld", r * 10000); reset_all(); set_year(year); set_lzz(1); set_zve(r * 1000000); calc_est(); printf("%20ld", get_grundtab() / 100); printf("%20ld\n", get_splittab() / 100); }; } return 0; }
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; } }
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(); } }