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