]> git.sur5r.net Git - cc65/blob - samples/geos/rmvprot.c
Added GEOS Kernal call showing what the struct is for - like the other fragment-type...
[cc65] / samples / geos / rmvprot.c
1
2 /*
3
4     GEOSLib example
5     
6     This small application removes GEOS disk write protection tag.
7     e.g. boot disk is always protected after boot-up
8     
9     Maciej 'YTM/Elysium' Witkowiak
10     <ytm@elysium.pl>
11     
12     21.03.2000
13 */
14
15 #include <geos.h>
16
17 char diskName[17] = "";
18
19 static const graphicStr clearScreen = {
20         MOVEPENTO(0, 0),
21         NEWPATTERN(2),
22         RECTANGLETO(319, 199),
23         GSTR_END
24 };
25
26 static const dlgBoxStr mainDialog = {
27         DB_DEFPOS(1),
28         DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y,
29                   CBOLDON "Remove protection on:" CPLAINTEXT),
30         DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, diskName),
31         DB_ICON(OK, DBI_X_0, DBI_Y_2),
32         DB_ICON(DISK, DBI_X_1, DBI_Y_2),
33         DB_ICON(CANCEL, DBI_X_2, DBI_Y_2),
34         DB_END
35 };
36
37 static const dlgBoxStr changeDiskDlg = {
38         DB_DEFPOS(1),
39         DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Insert new disk"),
40         DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "into drive." CPLAINTEXT),
41         DB_ICON(OK, DBI_X_0, DBI_Y_2),
42         DB_ICON(CANCEL, DBI_X_2, DBI_Y_2),
43         DB_END
44 };
45
46 static const dlgBoxStr errorDialog = {
47         DB_DEFPOS(1),
48         DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Error happened..."),
49         DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "exiting..." CPLAINTEXT),
50         DB_ICON(OK, DBI_X_0, DBI_Y_2),
51         DB_END
52 };
53
54 void Error(void)
55 {
56         DoDlgBox(&errorDialog);
57         EnterDeskTop();
58 }
59
60 void main(void)
61 {
62
63         /* Here we clear the screen. Not really needed anyway... */
64         GraphicsString(&clearScreen);
65         
66         /* Get the name of current disk to show it in dialog box */
67         GetPtrCurDkNm(diskName);
68
69         while (1) {
70                 switch (DoDlgBox(&mainDialog)) {
71                 /* What's the result of dialog box? which icon was pressed? */
72                 case OK:
73                         if (GetDirHead())
74                                 Error();
75                         curDirHead[OFF_GS_DTYPE] = 0;
76                         if (PutDirHead())
77                                 Error();
78                         break;
79                 case DISK:
80                         DoDlgBox(&changeDiskDlg);
81                         GetPtrCurDkNm(diskName);
82                         break;
83                 default:        /* CANCEL is the third option */
84                         return;
85                         break;
86                 }
87         }
88 }