From: cuz Date: Sat, 15 Jul 2000 09:12:11 +0000 (+0000) Subject: Added tutorial files from Maciek X-Git-Tag: V2.12.0~3365 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e2de9f58732e548e5b2205af230f2f1b24294100;p=cc65 Added tutorial files from Maciek git-svn-id: svn://svn.cc65.org/cc65/trunk@149 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/samples/geos/.cvsignore b/samples/geos/.cvsignore new file mode 100644 index 000000000..21ec6770b --- /dev/null +++ b/samples/geos/.cvsignore @@ -0,0 +1,8 @@ +filesel +hello1 +hello2 +rmvprot +yesno +*.map +*.s +*.lbl diff --git a/samples/geos/appfile.grc b/samples/geos/appfile.grc new file mode 100644 index 000000000..bc1e113c1 --- /dev/null +++ b/samples/geos/appfile.grc @@ -0,0 +1,8 @@ + +; this is resource file for filesel.c, a GEOS application example + +HEADER APPLICATION "filesel" "FileSel" "V1.0" { +dostype USR +author "Maciej Witkowiak" +info "This is C prog compiled with cc65 and GEOSLib." +} diff --git a/samples/geos/apphello1.grc b/samples/geos/apphello1.grc new file mode 100644 index 000000000..7c2137d04 --- /dev/null +++ b/samples/geos/apphello1.grc @@ -0,0 +1,8 @@ + +; this is resource file for hello1.c, a GEOS application example + +HEADER APPLICATION "hello1" "Hello 1" "V1.0" { +dostype USR +author "Maciej Witkowiak" +info "This is C prog compiled with cc65 and GEOSLib." +} diff --git a/samples/geos/apphello2.grc b/samples/geos/apphello2.grc new file mode 100644 index 000000000..fb1e3bb0e --- /dev/null +++ b/samples/geos/apphello2.grc @@ -0,0 +1,8 @@ + +; this is resource file for hello2.c, a GEOS application example + +HEADER APPLICATION "hello2" "Hello 2" "V1.0" { +dostype USR +author "Maciej Witkowiak" +info "This is C prog compiled with cc65 and GEOSLib." +} diff --git a/samples/geos/apprmvprot.grc b/samples/geos/apprmvprot.grc new file mode 100644 index 000000000..c63abbc05 --- /dev/null +++ b/samples/geos/apprmvprot.grc @@ -0,0 +1,9 @@ + +; this is resource file for rmvprot.c, a GEOS application example + +HEADER APPLICATION "rmvprot" "RmvProt" "V1.0" { +dostype USR +author "Maciej Witkowiak" +;info "This is C prog compiled with cc65 and GEOSLib." +info "This will remove write protection from your bootdisk." +} diff --git a/samples/geos/appyesno.grc b/samples/geos/appyesno.grc new file mode 100644 index 000000000..23171a604 --- /dev/null +++ b/samples/geos/appyesno.grc @@ -0,0 +1,8 @@ + +; this is resource file for yesno.c, a GEOS application example + +HEADER APPLICATION "yesno" "YesNo" "V1.0" { +dostype USR +author "Maciej Witkowiak" +info "This is C prog compiled with cc65 and GEOSLib." +} diff --git a/samples/geos/filesel.c b/samples/geos/filesel.c new file mode 100644 index 000000000..a25aa3e1e --- /dev/null +++ b/samples/geos/filesel.c @@ -0,0 +1,28 @@ + +/* + + GEOSLib example + + using DlgBoxFileSelect + + Maciej 'YTM/Alliance' Witkowiak + + + 26.12.1999 +*/ + +#include + +char fName[17]=""; + +void main (void) +{ + + r0=(int)fName; + + DlgBoxOk(CBOLDON "You now will be presented","with apps list" CPLAINTEXT); + DlgBoxFileSelect("",APPLICATION,fName); + DlgBoxOk("You've chosen:" CBOLDON, fName); + + EnterDeskTop(); +} diff --git a/samples/geos/hello1.c b/samples/geos/hello1.c new file mode 100644 index 000000000..f4b5e626a --- /dev/null +++ b/samples/geos/hello1.c @@ -0,0 +1,29 @@ + +/* + + GEOSLib example + + Hello, world example - with DBox + + Maciej 'YTM/Alliance' Witkowiak + + + 26.12.1999 +*/ + +#include + +void main (void) +{ + +/* 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. +*/ + EnterDeskTop(); +} diff --git a/samples/geos/hello2.c b/samples/geos/hello2.c new file mode 100644 index 000000000..8bc28ab3d --- /dev/null +++ b/samples/geos/hello2.c @@ -0,0 +1,50 @@ + +/* + + GEOSLib example + + Hello, world example - using graphic functions + + Maciej 'YTM/Alliance' Witkowiak + + + 26.12.1999 +*/ + +#include + +/* 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 clear the screen - with different pattern, because apps have cleared screen upon + start */ + + SetPattern(0); + InitDrawWindow(&wholeScreen); + Rectangle(); + +/* 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 */ + + 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. +*/ + EnterDeskTop(); +} diff --git a/samples/geos/rmvprot.c b/samples/geos/rmvprot.c new file mode 100644 index 000000000..a249290ef --- /dev/null +++ b/samples/geos/rmvprot.c @@ -0,0 +1,88 @@ + +/* + + GEOSLib example + + This small application removes GEOS disk write protection tag. + e.g. boot disk is always protected after boot-up + + Maciej 'YTM/Alliance' Witkowiak + + + 21.03.2000 +*/ + +#include + +char diskName[17] = ""; + +static const graphicStr clearScreen = { + 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 +}; + +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 +}; + +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 +}; + +void Error(void) +{ + 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); + + 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 */ + EnterDeskTop(); + break; + } + } +} diff --git a/samples/geos/yesno.c b/samples/geos/yesno.c new file mode 100644 index 000000000..b085db91a --- /dev/null +++ b/samples/geos/yesno.c @@ -0,0 +1,27 @@ + +/* + + GEOSLib example + + example of using DlgBoxYesNo, DlgBoxOkCancel and DlgBoxOk functions + + Maciej 'YTM/Alliance' Witkowiak + + + 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); + + EnterDeskTop(); +}