📄 calendarpatch.lst
字号:
C51 COMPILER V8.01 CALENDARPATCH 11/28/2006 08:08:06 PAGE 1
C51 COMPILER V8.01, COMPILATION OF MODULE CALENDARPATCH
OBJECT MODULE PLACED IN ..\..\1out\CalendarPatch.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\..\msFunc\CalendarPatch.c BROWSE INCDIR(..\..\inc;..\..\mslib;..\..\Devi
-ce;..\..\kernal;..\..\msFunc;..\..\pc;..\..\tv) DEBUG OBJECTEXTEND PRINT(..\..\1out\CalendarPatch.lst) OBJECT(..\..\1out
-\CalendarPatch.obj)
line level source
1 #define _CALENDAR_C_
2
3 #include "types.h"
4 #include "board.h"
5 #include "global.h"
6 #include "debug.h"
7 #include "msOSD.h"
8 #include "Menudef.h"
9 #include "menufunc.h"
10 #include "CalendarPatch.h"
11 #if CALENDAR_ENABLE
#define START_YEAR 1600
#define MAX_YEAR 899
#define MIN_YEAR 0
#define INIT_YEAR 405
#define INIT_MONTH 1
//===============================================
BYTE code tMonthDayNormal[] =
{// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12
0,31,28,31,30,31,30,31,31,30,31,30,31
};
void InitializeCalendarVariable(void)
{
if(gc_solar_calendar_year<MIN_YEAR||gc_solar_calendar_year>MAX_YEAR)gc_solar_calendar_year=INIT_YEAR;
if(gc_solar_calendar_month<1||gc_solar_calendar_month>12)gc_solar_calendar_month=INIT_MONTH;
temp_total_day = 0;
gc_solar_calendar_date= 1;
gc_lunar_calendar_year= 0;
gc_lunar_calendar_month= 0;
gc_lunar_calendar_date= 0;
start_day_of_week= 0;
gc_lunar_leap_month= 0;
}
BYTE get_solar_day_date(void)//Faster and less code
{
WORD ucTmp,ucLeapYear,uc100Year,uc400year;
BYTE ucValue;
start_day_of_week = 6;//1600
temp_total_day = 0;
if (gc_solar_calendar_year)
{
ucLeapYear = gc_solar_calendar_year-1;
ucLeapYear >>= 2;
ucLeapYear++;//1600 is 366 days
uc100Year= gc_solar_calendar_year-1;
uc100Year=uc100Year/100;
ucLeapYear-=uc100Year;
C51 COMPILER V8.01 CALENDARPATCH 11/28/2006 08:08:06 PAGE 2
uc400year= gc_solar_calendar_year-1;
uc400year=uc400year/400;
ucLeapYear+=uc400year;
ucTmp = gc_solar_calendar_year-ucLeapYear;
temp_total_day = (DWORD)ucLeapYear*366+(DWORD)ucTmp*365;
if (!(gc_solar_calendar_year%100)&&((gc_solar_calendar_year+START_YEAR)%400))
ucLeapYear = 1;
else
ucLeapYear = gc_solar_calendar_year&0x03;
}
else
{
ucLeapYear = 0;//1600
}
temp_total_day += start_day_of_week;
for(ucTmp=0;ucTmp<gc_solar_calendar_month;ucTmp++)
temp_total_day += tMonthDayNormal[ucTmp];
ucValue = tMonthDayNormal[ucTmp];
if (!ucLeapYear)
{
if (gc_solar_calendar_month == 2)
ucValue++;
if (gc_solar_calendar_month >2)
temp_total_day++;
}
start_day_of_week = temp_total_day%7;
return ucValue;
}
void DrawCalendarYear(void)
{
Osd_SetTextColor(CP_RedColor, CP_YellowColor);
DrawNum(6,1,4,(gc_solar_calendar_year + START_YEAR));
}
void DirectDrawCalendar(void)
{
XDATA BYTE strNumToStr[3];//for internal use only
BYTE ucX,ucY;
BYTE ucTmp;
BYTE ucEndValue;
BYTE ucShowValue;
strNumToStr[2] = '\0';
DrawCalendarYear();
ucEndValue = get_solar_day_date();
ucEndValue += start_day_of_week;
ucShowValue = 0;
ucY = 5;
C51 COMPILER V8.01 CALENDARPATCH 11/28/2006 08:08:06 PAGE 3
for(ucTmp = 0;ucTmp <= 36;ucTmp++)
{
//-------------------------------------------------
if (ucTmp < start_day_of_week)
ucShowValue = 0;
else if(ucTmp < ucEndValue)
ucShowValue ++;
else
ucShowValue = 0;
//-------------------------------------------------
if((ucTmp%7) == 0)
{
ucY += 1;
ucX = 0;
}
//-------------------------------------------------
if (ucShowValue==0)
{
strNumToStr[1] = ' ';
strNumToStr[0] = ' ';
}
else if (ucShowValue <10)
{
strNumToStr[1] = ucShowValue + OSD_0_INDEX;
strNumToStr[0] = ' ';
}
else
{
strNumToStr[1] = ucShowValue % 10 + OSD_0_INDEX;
strNumToStr[0] = ucShowValue/10 + OSD_0_INDEX;
}
if((ucX==0)||(ucX==18))
Osd_SetTextColor(CP_RedColor, CP_BlueColor);
else
Osd_SetTextColor(CP_GreenColor, CP_BlueColor);
Osd_DrawStr(ucX, ucY, strNumToStr);
//-------------------------------------------------
ucX += 3;
}
}
BOOL EnterCalendarMenuExec(void)
{
Osd_SetTextColor(CP_RedColor, CP_BlueColor);
Osd_DrawStr(0, 4, "SU SA");
Osd_SetTextColor(CP_YellowColor, CP_BlueColor);
Osd_DrawStr(3, 4, "MO TU WE TH FR");
DirectDrawCalendar();
return TRUE;
}
BOOL AdjustCalendarYearORMonth(MenuItemActionType action)
{
if(action==MIA_CalendarmonthIncValue)
{
if(gc_solar_calendar_month==12)
{
C51 COMPILER V8.01 CALENDARPATCH 11/28/2006 08:08:06 PAGE 4
gc_solar_calendar_month=1;
gc_solar_calendar_year++;
if(gc_solar_calendar_year==MAX_YEAR)
gc_solar_calendar_year=MIN_YEAR;
}
else
gc_solar_calendar_month= DecIncValue(MIA_IncValue, gc_solar_calendar_month, 1, 12, 1);
}
else if(action==MIA_CalendarmonthDecValue)
{
if(gc_solar_calendar_month==1)
{
gc_solar_calendar_month=12;
gc_solar_calendar_year--;
if(gc_solar_calendar_year==MIN_YEAR)
gc_solar_calendar_year=MAX_YEAR;
}
else
gc_solar_calendar_month= DecIncValue(MIA_DecValue, gc_solar_calendar_month, 1, 12, 1);
}
else
{
if(gc_solar_calendar_year==MIN_YEAR&&action==MIA_DecValue)
gc_solar_calendar_year=MAX_YEAR;
else if(gc_solar_calendar_year==MAX_YEAR&&action==MIA_IncValue)
gc_solar_calendar_year=MIN_YEAR;
else
gc_solar_calendar_year = DecIncValue(action, gc_solar_calendar_year, MIN_YEAR, MAX_YEAR, 1);
}
DirectDrawCalendar();
return TRUE;
}
#endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = ---- ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -