From: ol.sc Date: Thu, 9 Feb 2012 12:32:53 +0000 (+0000) Subject: Normalized coding style. X-Git-Tag: V2.14~547 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c3205877cd17366933b6b97bc210e903bfb5f1fd;p=cc65 Normalized coding style. git-svn-id: svn://svn.cc65.org/cc65/trunk@5516 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/samples/geos/dialog.c b/samples/geos/dialog.c index 75812d1d4..55f98bf01 100644 --- a/samples/geos/dialog.c +++ b/samples/geos/dialog.c @@ -11,24 +11,22 @@ void opvecfunc (void); void usrfunc (void); static const dlgBoxStr myDialog = { - DB_SETPOS (1, 0,150,0,319), - DB_TXTSTR (10,20,"test"), - DB_VARSTR (10,20,&r0L), - DB_GETSTR (10,20,&r0L,9), - DB_SYSOPV (sysopvfunc), - DB_GRPHSTR (&r0L), - DB_GETFILES (10,10), - DB_OPVEC (opvecfunc), - DB_USRICON (0,0,&r0L), - DB_USRROUT (usrfunc), - DB_ICON (OK, DBI_X_0, DBI_Y_0 ), - DB_ICON (CANCEL, DBI_X_1, DBI_Y_1), - DB_END - }; + DB_SETPOS (1, 0, 150, 0, 319), + DB_TXTSTR (10, 20, "test"), + DB_VARSTR (10, 20, &r0L), + DB_GETSTR (10, 20, &r0L, 9), + DB_SYSOPV (sysopvfunc), + DB_GRPHSTR (&r0L), + DB_GETFILES (10, 10), + DB_OPVEC (opvecfunc), + DB_USRICON (0, 0, &r0L), + DB_USRROUT (usrfunc), + DB_ICON (OK, DBI_X_0, DBI_Y_0 ), + DB_ICON (CANCEL, DBI_X_1, DBI_Y_1), + DB_END + }; void main (void) { - - DoDlgBox (&myDialog); - + DoDlgBox (&myDialog); } diff --git a/samples/geos/filesel.c b/samples/geos/filesel.c index 9247fc289..01aba6b92 100644 --- a/samples/geos/filesel.c +++ b/samples/geos/filesel.c @@ -1,6 +1,4 @@ - /* - GEOSLib example using DlgBoxFileSelect @@ -11,17 +9,16 @@ 26.12.1999 */ + #include -char fName[17]=""; +char fName[17] = ""; void main (void) { - r0=(int)fName; - DlgBoxOk(CBOLDON "You now will be presented","with apps list" CPLAINTEXT); - DlgBoxFileSelect("",APPLICATION,fName); + DlgBoxOk(CBOLDON "You now will be presented", "with apps list" CPLAINTEXT); + DlgBoxFileSelect("", APPLICATION, fName); DlgBoxOk("You've chosen:" CBOLDON, fName); - } diff --git a/samples/geos/geosconio.c b/samples/geos/geosconio.c index 1c728f851..963fa06a0 100644 --- a/samples/geos/geosconio.c +++ b/samples/geos/geosconio.c @@ -3,10 +3,10 @@ #include #include -void main(void) { - -struct mouse_info info; -char ch; +void main(void) +{ + struct mouse_info info; + char ch; DlgBoxOk("Now the screen will be", "cleared."); @@ -14,45 +14,45 @@ char ch; DlgBoxOk("Now a character will be", "written at 20,20"); - gotoxy(20,20); + gotoxy(20, 20); cputc('A'); DlgBoxOk("Now a string will be", "written at 0,1"); - cputsxy(0,1, CBOLDON "Just" COUTLINEON "a " CITALICON "string." CPLAINTEXT ); + cputsxy(0, 1, CBOLDON "Just" COUTLINEON "a " CITALICON "string." CPLAINTEXT ); DlgBoxOk("Write text and finish it", "with a dot."); cursor(1); do { ch = cgetc(); - cputc(ch); + cputc(ch); } while (ch!='.'); + cursor(0); DlgBoxOk("Seems that it is all for conio.", "Let's test mouse routines."); mouse_init(1); - cputsxy(0,2,CBOLDON "Now you can't see mouse (press any key)" CPLAINTEXT); + cputsxy(0, 2, CBOLDON "Now you can't see mouse (press any key)" CPLAINTEXT); mouse_hide(); while (!kbhit()) { }; cputc(cgetc()); - cputsxy(0,3,CBOLDON "Now you see the mouse (press any key)" CPLAINTEXT); + + cputsxy(0, 3, CBOLDON "Now you see the mouse (press any key)" CPLAINTEXT); mouse_show(); while (!kbhit()) { }; cputc(cgetc()); - /* Get the current mouse coordinates and button states and print them */ - mouse_info (&info); - gotoxy (0, 4); - cprintf ("X = %3d", info.pos.x); - gotoxy (0, 5); - cprintf ("Y = %3d", info.pos.y); - gotoxy (0, 6); - cprintf ("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0'); - gotoxy (0, 7); - cprintf ("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0'); - + // Get the current mouse coordinates and button states and print them + mouse_info(&info); + gotoxy(0, 4); + cprintf("X = %3d", info.pos.x); + gotoxy(0, 5); + cprintf("Y = %3d", info.pos.y); + gotoxy(0, 6); + cprintf("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0'); + gotoxy(0, 7); + cprintf("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0'); DlgBoxOk("Bye,", "Bye."); - } diff --git a/samples/geos/getid.c b/samples/geos/getid.c index efcbc7221..4331e27e8 100644 --- a/samples/geos/getid.c +++ b/samples/geos/getid.c @@ -1,4 +1,3 @@ - /* This is an example program for GEOS. It reads GEOS serial number and prints it on the screen. @@ -7,14 +6,16 @@ 05.03.2004 */ + #include #include #include const graphicStr Table = { - NEWPATTERN(0), MOVEPENTO(0,0), RECTANGLETO(320,199), GSTR_END }; + NEWPATTERN(0), MOVEPENTO(0, 0), RECTANGLETO(320, 199), GSTR_END }; -void Exit(void) { +void Exit(void) +{ exit(0); } @@ -22,16 +23,17 @@ void Menu = { (char)0, (char)14, (int)0, (int)28, (char)(HORIZONTAL|1), CBOLDON "quit", (char)MENU_ACTION, &Exit }; -int main(void) { - +int main(void) +{ dispBufferOn = ST_WR_FORE; GraphicsString(&Table); - cputsxy(0,3,CBOLDON "Your Serial Number is:"); + cputsxy(0, 3, CBOLDON "Your Serial Number is:"); cputhex16(GetSerialNumber()); DoMenu(&Menu); MainLoop(); + // will never reach this point... return 0; } diff --git a/samples/geos/grphstr.c b/samples/geos/grphstr.c index 850ce7e22..928e7a06c 100644 --- a/samples/geos/grphstr.c +++ b/samples/geos/grphstr.c @@ -7,21 +7,19 @@ #include static const graphicStr myString = { - MOVEPENTO (0,0), - LINETO(100,100), - RECTANGLETO(50,50), - NEWPATTERN(3), - FRAME_RECTO(50,50), - PEN_X_DELTA(10), - PEN_Y_DELTA(10), - PEN_XY_DELTA(10,10), - GSTR_END - }; + MOVEPENTO (0, 0), + LINETO(100, 100), + RECTANGLETO(50, 50), + NEWPATTERN(3), + FRAME_RECTO(50, 50), + PEN_X_DELTA(10), + PEN_Y_DELTA(10), + PEN_XY_DELTA(10, 10), + GSTR_END + }; int main (void) { - GraphicsString(&myString); - } diff --git a/samples/geos/hello1.c b/samples/geos/hello1.c index 749cb29f9..b4ad10605 100644 --- a/samples/geos/hello1.c +++ b/samples/geos/hello1.c @@ -1,6 +1,4 @@ - /* - GEOSLib example Hello, world example - with DBox @@ -11,25 +9,25 @@ 26.12.1999 */ + #include void main (void) { - -/* Let's show what we've got... */ + // Let's show what we've got... DlgBoxOk(CBOLDON "Hello, world" CPLAINTEXT, "This is written in C!"); -/* Normal apps exit from main into system's mainloop, and app finish - when user selects it from icons or menu, but here we want to exit - immediately. - So instead: - MainLoop(); - we can do: - (nothing as this is the end of main function) - exit(0); - return; -*/ + // Normal apps exit from main into system's mainloop, and app finish + // when user selects it from icons or menu, but here we want to exit + // immediately. + // So instead: + // MainLoop(); + // we can do: + // (nothing as this is the end of main function) + // exit(0); + // return; + return; } diff --git a/samples/geos/hello2.c b/samples/geos/hello2.c index 1692c4b5b..cb2247030 100644 --- a/samples/geos/hello2.c +++ b/samples/geos/hello2.c @@ -1,6 +1,4 @@ - /* - GEOSLib example Hello, world example - using graphic functions @@ -11,46 +9,43 @@ 26.12.1999 */ + #include -/* Let's define the window we're operating */ +// Let's define the window we're operating struct window wholeScreen = {0, 199, 0, 319}; void main (void) { + // Let's show what we've got... -/* Let's show what we've got... */ - -/* Let's clear the screen - with different pattern, because apps have cleared screen upon - start */ - + // Let's clear the screen - with different pattern, because apps have cleared screen upon + // start SetPattern(0); InitDrawWindow(&wholeScreen); Rectangle(); -/* Now some texts */ - + // Now some texts PutString(COUTLINEON "This is compiled using cc65!" CPLAINTEXT, 20, 10); PutString(CBOLDON "This is bold", 30, 10); PutString(CULINEON "and this is bold and underline!", 40, 10); PutString(CPLAINTEXT "This is plain text", 50, 10); -/* Wait for 5 secs... */ -/* Note that this is multitasking sleep, and if there are any icons/menus onscreen, - they would be usable, in this case you have only pointer usable */ - + // Wait for 5 secs... + // Note that this is multitasking sleep, and if there are any icons/menus onscreen, + // they would be usable, in this case you have only pointer usable Sleep(5*50); -/* Normal apps exit from main into system's mainloop, and app finish - when user selects it from icons or menu, but here we want to exit - immediately. - So instead: - MainLoop(); - we can do: - (nothing as this is the end of main function) - exit(0); - return; -*/ + // Normal apps exit from main into system's mainloop, and app finish + // when user selects it from icons or menu, but here we want to exit + // immediately. + // So instead: + // MainLoop(); + // we can do: + // (nothing as this is the end of main function) + // exit(0); + // return; + return; } diff --git a/samples/geos/inittab.c b/samples/geos/inittab.c index 0ea0c2526..843275e69 100644 --- a/samples/geos/inittab.c +++ b/samples/geos/inittab.c @@ -8,17 +8,15 @@ static const void myTab = { - 0xd020, (char)2, - (char)0, (char)2, - 0x4000, (char)5, - (char)0, (char)1, (char)2, (char)3, (char)4, - 0x0000 - }; + 0xd020, (char)2, + (char)0, (char)2, + 0x4000, (char)5, + (char)0, (char)1, (char)2, (char)3, (char)4, + 0x0000 + }; int main (void) { - InitRam(&myTab); - } diff --git a/samples/geos/menu.c b/samples/geos/menu.c index 78751f8b2..3b5f9da82 100644 --- a/samples/geos/menu.c +++ b/samples/geos/menu.c @@ -18,30 +18,28 @@ typedef void menuString; /* you can declare a menu using cc65 non-ANSI extensions */ static const menuString subMenu1 = { - (char)0, (char)(3*15), - (unsigned)0, (unsigned)50, - (char)(3 | VERTICAL), - "subitem1", (char)MENU_ACTION, (unsigned)smenu1, - "subitem2", (char)MENU_ACTION, (unsigned)smenu2, - "subitem3", (char)MENU_ACTION, (unsigned)smenu3 + (char)0, (char)(3*15), + (unsigned)0, (unsigned)50, + (char)(3 | VERTICAL), + "subitem1", (char)MENU_ACTION, (unsigned)smenu1, + "subitem2", (char)MENU_ACTION, (unsigned)smenu2, + "subitem3", (char)MENU_ACTION, (unsigned)smenu3 }; /* or by using initialized structures */ static struct menu subMenu2 = { - { 0, 3*15, 0, 50 }, - 3 | VERTICAL, - { - { "subitem1", MENU_ACTION, smenu1 }, - { "subitem2", MENU_ACTION, smenu2 }, - { "subitem3", MENU_ACTION, smenu3 }, - } + { 0, 3*15, 0, 50 }, + 3 | VERTICAL, + { + { "subitem1", MENU_ACTION, smenu1 }, + { "subitem2", MENU_ACTION, smenu2 }, + { "subitem3", MENU_ACTION, smenu3 }, + } }; void main (void) { - DoMenu(&subMenu1); DoMenu(&subMenu2); - } diff --git a/samples/geos/rmvprot.c b/samples/geos/rmvprot.c index 3e324da38..9f59945eb 100644 --- a/samples/geos/rmvprot.c +++ b/samples/geos/rmvprot.c @@ -1,6 +1,4 @@ - /* - GEOSLib example This small application removes GEOS disk write protection tag. @@ -12,77 +10,78 @@ 21.03.2000 */ + #include char diskName[17] = ""; static const graphicStr clearScreen = { - MOVEPENTO(0, 0), - NEWPATTERN(2), - RECTANGLETO(319, 199), - GSTR_END + MOVEPENTO(0, 0), + NEWPATTERN(2), + RECTANGLETO(319, 199), + GSTR_END }; static const dlgBoxStr mainDialog = { - DB_DEFPOS(1), - DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, - CBOLDON "Remove protection on:" CPLAINTEXT), - DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, diskName), - DB_ICON(OK, DBI_X_0, DBI_Y_2), - DB_ICON(DISK, DBI_X_1, DBI_Y_2), - DB_ICON(CANCEL, DBI_X_2, DBI_Y_2), - DB_END + DB_DEFPOS(1), + DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, + CBOLDON "Remove protection on:" CPLAINTEXT), + DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, diskName), + DB_ICON(OK, DBI_X_0, DBI_Y_2), + DB_ICON(DISK, DBI_X_1, DBI_Y_2), + DB_ICON(CANCEL, DBI_X_2, DBI_Y_2), + DB_END }; static const dlgBoxStr changeDiskDlg = { - DB_DEFPOS(1), - DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Insert new disk"), - DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "into drive." CPLAINTEXT), - DB_ICON(OK, DBI_X_0, DBI_Y_2), - DB_ICON(CANCEL, DBI_X_2, DBI_Y_2), - DB_END + DB_DEFPOS(1), + DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Insert new disk"), + DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "into drive." CPLAINTEXT), + DB_ICON(OK, DBI_X_0, DBI_Y_2), + DB_ICON(CANCEL, DBI_X_2, DBI_Y_2), + DB_END }; static const dlgBoxStr errorDialog = { - DB_DEFPOS(1), - DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Error happened..."), - DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "exiting..." CPLAINTEXT), - DB_ICON(OK, DBI_X_0, DBI_Y_2), - DB_END + DB_DEFPOS(1), + DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Error happened..."), + DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "exiting..." CPLAINTEXT), + DB_ICON(OK, DBI_X_0, DBI_Y_2), + DB_END }; void Error(void) { - DoDlgBox(&errorDialog); - EnterDeskTop(); + DoDlgBox(&errorDialog); + EnterDeskTop(); } void main(void) { + // Here we clear the screen. Not really needed anyway... + GraphicsString(&clearScreen); + + // Get the name of current disk to show it in dialog box + GetPtrCurDkNm(diskName); - /* Here we clear the screen. Not really needed anyway... */ - GraphicsString(&clearScreen); - - /* Get the name of current disk to show it in dialog box */ - GetPtrCurDkNm(diskName); + while (1) { + switch (DoDlgBox(&mainDialog)) { - while (1) { - switch (DoDlgBox(&mainDialog)) { - /* What's the result of dialog box? which icon was pressed? */ - case OK: - if (GetDirHead()) - Error(); - curDirHead[OFF_GS_DTYPE] = 0; - if (PutDirHead()) - Error(); - break; - case DISK: - DoDlgBox(&changeDiskDlg); - GetPtrCurDkNm(diskName); - break; - default: /* CANCEL is the third option */ - return; - break; - } - } + // What's the result of dialog box? which icon was pressed? + case OK: + if (GetDirHead()) + Error(); + curDirHead[OFF_GS_DTYPE] = 0; + if (PutDirHead()) + Error(); + break; + case DISK: + DoDlgBox(&changeDiskDlg); + GetPtrCurDkNm(diskName); + break; + default: // CANCEL is the third option + return; + break; + } + } } diff --git a/samples/geos/vector-demo.c b/samples/geos/vector-demo.c index cddb943d2..cdf6f5af0 100644 --- a/samples/geos/vector-demo.c +++ b/samples/geos/vector-demo.c @@ -1,4 +1,3 @@ - #include #include #include @@ -7,25 +6,30 @@ unsigned char x,y; void_func oldMouseVector, oldKeyVector; -void foo1 (void) { +void foo1 (void) +{ // do something on mouse press/release gotoxy(x,y); ++x; cputc('A'); + // call previous routine oldMouseVector(); } -void foo2 (void) { +void foo2 (void) +{ // do something on key press/release gotoxy(x,y); ++y; cputc('B'); + // call previous routine oldKeyVector(); } -void hook_into_system(void) { +void hook_into_system(void) +{ // hook into system vectors - preserve old value oldMouseVector = mouseVector; mouseVector = foo1; @@ -33,21 +37,20 @@ void hook_into_system(void) { keyVector = foo2; } -void remove_hooks(void) { +void remove_hooks(void) +{ mouseVector = oldMouseVector; keyVector = oldKeyVector; } -int main(void) { - +int main(void) +{ x = 0; y = 0; -/* - To make cc65 do something for you before exiting you might register - a function to be called using atexit call. #include then and - write: -*/ + // To make cc65 do something for you before exiting you might register + // a function to be called using atexit call. #include then and + // write: atexit(&remove_hooks); clrscr(); @@ -55,16 +58,13 @@ int main(void) { hook_into_system(); -/* This program will loop forever though */ - + // This program will loop forever though MainLoop(); -/* - If not using atexit() you have to remember about restoring system vectors - right before exiting your application. Otherwise the system will most - likely crash. + // If not using atexit() you have to remember about restoring system vectors + // right before exiting your application. Otherwise the system will most + // likely crash. + // remove_hooks(); - remove_hooks(); -*/ return 0; } diff --git a/samples/geos/yesno.c b/samples/geos/yesno.c index dadf11449..ff98d0a84 100644 --- a/samples/geos/yesno.c +++ b/samples/geos/yesno.c @@ -1,6 +1,4 @@ - /* - GEOSLib example example of using DlgBoxYesNo, DlgBoxOkCancel and DlgBoxOk functions @@ -11,16 +9,16 @@ 26.12.1999 */ + #include void main(void) { - do { - if (DlgBoxYesNo("Are you female?", "(don't lie ;-)") == YES) { - DlgBoxOk("You claim to be woman!", "You wanna dance?"); - } else { - DlgBoxOk("Ergh, another man...", "Let's go for a beer."); - }; - } while (DlgBoxOkCancel("Do you want to try again?", "") == OK); - + do { + if (DlgBoxYesNo("Are you female?", "(don't lie ;-)") == YES) { + DlgBoxOk("You claim to be woman!", "You wanna dance?"); + } else { + DlgBoxOk("Ergh, another man...", "Let's go for a beer."); + }; + } while (DlgBoxOkCancel("Do you want to try again?", "") == OK); }