📄 nachtm.c
字号:
0x8004,0x3B04,0x8004,0x3804,0x8004,0x3904,0x8004,0x3704,0x8004,0x3604, 0x8004,0x3204,0x8004,0x3404,0x8004,0x3004,0x8004,0x3204,0x8004,0x3204, 0x8004,0x2708,0x8018,0x3208,0x8018,0x2708,0x8018,0x3208,0x8018,0x3B08, 0x8008,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4908,0x8008,0x4901, 0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901, 0x4901,0x4901,0x4901,0x4901,0x4901,0x4704,0x4B04,0x5004,0x5204,0x5001, 0x5001,0x5001,0x5001,0x5201,0x5201,0x5401,0x5401,0x5204,0x5004,0x5001, 0x5001,0x5001,0x5001,0x4B04,0x4704,0x4B04,0x4B01,0x4B01,0x4B01,0x4B01, 0x4904,0x4704,0x4604,0x4704,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04, 0x3B04,0x3904,0x3904,0x3B04,0x3B04,0x4004,0x4004,0x3904,0x3904,0x3B04, 0x4B04,0x5004,0x5004,0x5204,0x5204,0x4B04,0x4B04,0x4904,0x4904,0x4B04, 0x4B04,0x5004,0x5004,0x4904,0x4904,0x8004,0x3704,0x3B04,0x3904,0x3804, 0x3404,0x3604,0x3804,0x3904,0x4004,0x3904,0x3704,0x3604,0x3204,0x3404, 0x3604,0x3704,0x3704,0x3904,0x3B04,0x4004,0x4004,0x4004,0x4004,0x4204, 0x4204,0x4204,0x4204,0x3204,0x3204,0x3204,0x3204,0x3704,0x3204,0x3404, 0x3604,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3604,0x3704,0x3904,0x3B04, 0x3B04,0x4004,0x4004,0x4204,0x4204,0x4304,0x4304,0x4408,0x8008,0x3001, 0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001, 0x3001,0x3001,0x3001,0x3001,0x3001,0x3210,0x2708,0x8018,0x3001,0x3001, 0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001, 0x3001,0x3001,0x3001,0x3001,0x3210,0x2708,0x8018,0x3008,0x8008,0x3208, 0x8008,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, 0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, 0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, 0x2704,0x2704,0x2704,0x2704,0x2B04,0x3204,0x3704,0x3B04,0x3704,0x4204, 0x3B04,0x3708,0x2706,0x2702,0x2708,0x8008, 0x0000};#if defined(__C64__) || defined(__CBM510__)static unsigned long FreqTab [12] = {#ifndef NTSC /* PAL */ 0x008B38, 0x009381, 0x009C45, 0x00A590, 0x00AF68, 0x00B9D6, 0x00C4E4, 0x00D099, 0x00DCFF, 0x00EA24, 0x00F810, 0x0106D1,#else /* NTSC */ 0x00861E, 0x008E19, 0x00968B, 0x009F7F, 0x00A8FA, 0x00B307, 0x00BDAD, 0x00C8F4, 0x00D4E6, 0x00E18F, 0x00EEF9, 0x00FD2F,#endif};#elif defined(__C128__)static unsigned long FreqTab [12] = { 0x00892B, 0x009153, 0x0099F7, 0x00A31E, 0x00ACD2, 0x00B718, 0x00C1FD, 0x00CD85, 0x00D9BD, 0x00E6B0, 0x00F467, 0x0102F0,};#elif defined(__CBM610__)static unsigned long FreqTab [12] = { 0x004495, 0x0048AA, 0x004CFB, 0x00518F, 0x005669, 0x005B8C, 0x0060FE, 0x0066C3, 0x006CDE, 0x007358, 0x007A34, 0x008178,};#endiftypedef struct { unsigned char DoneMask; /* Set this if we're done */ unsigned char Trigger; /* Trigger value */ unsigned char Ticks; /* Ticks for this tone */ unsigned Freq; /* Actual frequency value */ unsigned* Data; /* Pointer to data */ struct __sid_voice* Voice; /* Pointer to sid registers */} VoiceCtrl;/* Control structs for all three voices */static VoiceCtrl V1 = { 0x01, 0x11, 0, 0, Voice1, &SID.v1};static VoiceCtrl V2 = { 0x02, 0x41, 0, 0, Voice2, &SID.v2};static VoiceCtrl V3 = { 0x04, 0x11, 0, 0, Voice3, &SID.v3};/* Pointers to the structs for easy reference */static VoiceCtrl* V [3] = { &V1, &V2, &V3};/* Screen dimensions */static unsigned char XSize, YSize;/* Variable that contains the time of the next clock tick to play a note */static unsigned char NextClock;/* Start- and runtime */static clock_t StartTime;/* Number of ticks for each tone */#define TICKS_PER_TONE 4/* Done flag. Contains one bit for each voice. Will contain 0x07 if all * voices have finished playing. */static unsigned char Done;/*****************************************************************************//* Code *//*****************************************************************************/static void MakeTeeLine (unsigned char Y)/* Make a divider line */{ cputcxy (0, Y, CH_LTEE); chline (XSize - 2); cputc (CH_RTEE);}static void MakeNiceScreen (void)/* Make a nice screen */{ typedef struct { unsigned char Y; char* Msg; } TextDesc; static TextDesc Text [] = { { 2, "Wolfgang Amadeus Mozart" }, { 4, "\"Eine kleine Nachtmusik\"" }, { 5, "(KV 525)" }, { 9, "Ported to the SID in 1987 by" }, { 11, "Joachim von Bassewitz" }, { 12, "(joachim@von-bassewitz.de)" }, { 13, "and" }, { 14, "Ullrich von Bassewitz" }, { 15, "(ullrich@von-bassewitz.de)" }, { 18, "C Implementation by" }, { 19, "Ullrich von Bassewitz" }, { 23, "Press any key to quit..." }, }; register const TextDesc* T; unsigned char I; unsigned char X; /* Clear the screen hide the cursor, set colors */#ifdef __CBM610__ textcolor (COLOR_WHITE);#else textcolor (COLOR_GRAY3);#endif bordercolor (COLOR_BLACK); bgcolor (COLOR_BLACK); clrscr (); cursor (0); /* Top line */ cputcxy (0, 0, CH_ULCORNER); chline (XSize - 2); cputc (CH_URCORNER); /* Left line */ cvlinexy (0, 1, 23); /* Bottom line */ cputc (CH_LLCORNER); chline (XSize - 2); cputc (CH_LRCORNER); /* Right line */ cvlinexy (XSize - 1, 1, 23); /* Several divider lines */ MakeTeeLine (7); MakeTeeLine (22); /* Write something into the frame */ for (I = 0, T = Text; I < sizeof (Text) / sizeof (Text [0]); ++I) { X = (XSize - strlen (T->Msg)) / 2; cputsxy (X, T->Y, T->Msg); ++T; }}static void TimeSync (void)/* Sync the time for the next tone */{ static unsigned char Clock; do { Clock = clock (); } while (Clock != NextClock); NextClock = Clock + TICKS_PER_TONE;}static void DisplayTime (void)/* Display the running time */{ clock_t Time = (clock () - StartTime) / CLOCKS_PER_SEC; unsigned Sec = Time % 60; unsigned Min = Time / 60; gotoxy
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -