Browse Source

Version 2.20

tags/2.20
Carsten Larsen 2 years ago
parent
commit
d8238b8649
59 changed files with 5898 additions and 2 deletions
  1. 191
    0
      Abacus.cpp
  2. 51
    0
      Abacus.hpp
  3. 145
    0
      About.cpp
  4. 57
    0
      About.hpp
  5. 534
    0
      Board.cpp
  6. 126
    0
      Board.hpp
  7. 867
    0
      BoardClass.cpp
  8. 80
    0
      BoardClass.hpp
  9. 263
    0
      BoardWindow.cpp
  10. 51
    0
      BoardWindow.hpp
  11. 96
    0
      Board_testmain.cpp
  12. 53
    0
      Images.hpp
  13. 371
    0
      LocStrings.h
  14. 59
    0
      MCC.hpp
  15. 141
    0
      Main.cpp
  16. 108
    0
      MsgWin.cpp
  17. 52
    0
      MsgWin.hpp
  18. 11
    2
      README.md
  19. 118
    0
      Rules.cpp
  20. 57
    0
      Rules.hpp
  21. 253
    0
      Settings.cpp
  22. 62
    0
      Settings.hpp
  23. 90
    0
      Status.hpp
  24. 186
    0
      StatusWin.cpp
  25. 85
    0
      StatusWin.hpp
  26. 42
    0
      System.hpp
  27. 352
    0
      Tools.cpp
  28. 113
    0
      Tools.hpp
  29. 63
    0
      images/IMG_Abacus.c
  30. BIN
      images/IMG_Abacus.iff
  31. 73
    0
      images/IMG_About.c
  32. 87
    0
      images/IMG_Kreis_A.c
  33. BIN
      images/IMG_Kreis_A.iff
  34. 87
    0
      images/IMG_Kreis_B.c
  35. BIN
      images/IMG_Kreis_B.iff
  36. 60
    0
      images/IMG_Load.c
  37. BIN
      images/IMG_Load.iff
  38. 80
    0
      images/IMG_Logo.c
  39. BIN
      images/IMG_Logo.iff
  40. 242
    0
      images/IMG_Moves.c
  41. BIN
      images/IMG_Moves.iff
  42. 111
    0
      images/IMG_Prefs.c
  43. BIN
      images/IMG_Prefs.iff
  44. 60
    0
      images/IMG_Quit.c
  45. BIN
      images/IMG_Quit.iff
  46. 60
    0
      images/IMG_Rules.c
  47. BIN
      images/IMG_Rules.iff
  48. 52
    0
      images/IMG_Save.c
  49. BIN
      images/IMG_Save.iff
  50. 60
    0
      images/IMG_Settings.c
  51. BIN
      images/IMG_Settings.iff
  52. 60
    0
      images/IMG_Start.c
  53. BIN
      images/IMG_Start.iff
  54. 60
    0
      images/IMG_Stop.c
  55. BIN
      images/IMG_Stop.iff
  56. 69
    0
      images/IMG_Time.c
  57. BIN
      images/IMG_Time.iff
  58. 60
    0
      images/IMG_Undo.c
  59. BIN
      images/IMG_Undo.iff

+ 191
- 0
Abacus.cpp View File

@@ -0,0 +1,191 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+/****************************************************************************************
20
+	Abacus.cpp
21
+-----------------------------------------------------------------------------------------
22
+
23
+  CL_Abacus (Application)
24
+
25
+-----------------------------------------------------------------------------------------
26
+	01.01.1997
27
+****************************************************************************************/
28
+
29
+#include "Abacus.hpp"
30
+#include "BoardWindow.hpp"
31
+#include "Settings.hpp"
32
+#include "About.hpp"
33
+#include "Rules.hpp"
34
+#include "Tools.hpp"
35
+
36
+
37
+MUI_CustomClass *CL_Abacus;
38
+
39
+
40
+
41
+/****************************************************************************************
42
+	About
43
+****************************************************************************************/
44
+
45
+ULONG Abacus_About(struct IClass* cl, Object* obj, Msg msg)
46
+{
47
+	struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
48
+	setatt(data->WI_About, MUIA_Window_RefWindow, data->WI_Main);
49
+	setatt(data->WI_About, MUIA_Window_Open			, TRUE);
50
+	return 0;
51
+}
52
+
53
+
54
+/****************************************************************************************
55
+	Rules
56
+****************************************************************************************/
57
+
58
+ULONG Abacus_Rules(struct IClass* cl, Object* obj, Msg msg)
59
+{
60
+	struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
61
+	setatt(data->WI_Rules, MUIA_Window_Open, TRUE);
62
+	return 0;
63
+}
64
+
65
+
66
+/****************************************************************************************
67
+	OpenSettings
68
+****************************************************************************************/
69
+
70
+ULONG Abacus_OpenSettings(struct IClass* cl, Object* obj, Msg msg)
71
+{
72
+	struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
73
+	setatt(data->WI_Settings, MUIA_Window_Open, TRUE);
74
+	return 0;
75
+}
76
+
77
+
78
+/****************************************************************************************
79
+	New
80
+****************************************************************************************/
81
+
82
+ULONG Abacus_New(struct IClass* cl, Object* obj, struct opSet* msg)
83
+{
84
+	Abacus_Data tmp;
85
+	obj = (Object*)DoSuperNew(cl, obj,
86
+		MUIA_Application_Title      , "Abacus",
87
+		MUIA_Application_Version    , version_string,
88
+		MUIA_Application_Copyright  , "(c)1995-97, Kai Nickel",
89
+		MUIA_Application_Author     , "Kai Nickel",
90
+		MUIA_Application_Description, GetStr(MSG_APPDESCRIPTION),
91
+		MUIA_Application_Base       , "ABACUS",
92
+		MUIA_Application_HelpFile   , "Abacus.guide",
93
+
94
+		MUIA_Application_Window, 
95
+			tmp.WI_Main     = (Object*)NewObject(CL_BoardWindow->mcc_Class, NULL, TAG_DONE),
96
+
97
+  	MUIA_Application_Window, 
98
+			tmp.WI_Settings = (Object*)NewObject(CL_Settings->mcc_Class   , NULL, TAG_DONE),
99
+
100
+  	MUIA_Application_Window, 
101
+  	  tmp.WI_About    = (Object*)NewObject(CL_About->mcc_Class      , NULL, 
102
+  	  																		 TAG_DONE),
103
+
104
+  	MUIA_Application_Window, 
105
+  	  tmp.WI_Rules    = (Object*)NewObject(CL_Rules->mcc_Class      , NULL, TAG_DONE),
106
+
107
+ 		TAG_MORE, msg->ops_AttrList);
108
+
109
+	if (obj) 
110
+	{
111
+		struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
112
+		*data = tmp;
113
+
114
+	  DoMethod(obj, MUIM_Application_Load, MUIV_Application_Load_ENVARC);
115
+	  DoMethod(obj, MUIM_Application_Save, MUIV_Application_Save_ENV);
116
+		setatt(obj, MUIA_Abacus_Settings, xget(data->WI_Settings, MUIA_Settings_Settings)); 
117
+		// erste Settings installieren
118
+
119
+		setatt(tmp.WI_Main, MUIA_Window_Open, TRUE);
120
+
121
+		return((ULONG)obj);
122
+	}
123
+	ShowError(NULL, NULL, MSG_NOAPP);
124
+	return(0);
125
+}
126
+
127
+
128
+/****************************************************************************************
129
+	Dispose
130
+****************************************************************************************/
131
+
132
+ULONG Abacus_Dispose(struct IClass* cl, Object* obj, Msg msg)
133
+{
134
+	struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
135
+	return(DoSuperMethodA(cl, obj, msg));
136
+}
137
+
138
+
139
+/****************************************************************************************
140
+	Get / Set
141
+****************************************************************************************/
142
+
143
+ULONG Abacus_Get(struct IClass* cl, Object* obj, struct opGet* msg)
144
+{
145
+	struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
146
+	switch (msg->opg_AttrID)
147
+	{
148
+		case MUIA_Abacus_Settings:
149
+		{
150
+			Settings* s = (Settings*)xget(data->WI_Settings, MUIA_Settings_Settings);
151
+			*(msg->opg_Storage) = (ULONG)s;
152
+			return(TRUE);
153
+		}
154
+	}
155
+  return(DoSuperMethodA(cl, obj, (Msg)msg));
156
+}
157
+
158
+ULONG Abacus_Set(struct IClass* cl, Object* obj, struct opSet* msg)
159
+{
160
+	struct Abacus_Data* data = (Abacus_Data*)INST_DATA(cl, obj);
161
+	struct TagItem *tag;
162
+  tag = FindTagItem(MUIA_Abacus_Settings, msg->ops_AttrList);
163
+	if (tag)
164
+	{
165
+  	DoMethod(data->WI_Main, MUIM_BoardWindow_NewSettings);
166
+	}
167
+  return(DoSuperMethodA(cl, obj, (Msg)msg));
168
+}
169
+
170
+        
171
+/****************************************************************************************
172
+	Dispatcher
173
+****************************************************************************************/
174
+
175
+SAVEDS ASM ULONG Abacus_Dispatcher(REG(a0) struct IClass* cl, 
176
+                                   REG(a2) Object* 				obj, 
177
+                                   REG(a1) Msg 						msg)
178
+{
179
+	switch(msg->MethodID)
180
+	{
181
+		case OM_NEW                  : return(Abacus_New          (cl, obj, (opSet*)msg));
182
+  	case OM_DISPOSE              : return(Abacus_Dispose	    (cl, obj, msg));
183
+		case OM_GET                  : return(Abacus_Get          (cl, obj, (opGet*)msg));
184
+		case OM_SET                  : return(Abacus_Set          (cl, obj, (opSet*)msg));
185
+		case MUIM_Abacus_EditSettings: return(Abacus_OpenSettings (cl, obj, msg));
186
+		case MUIM_Abacus_About       : return(Abacus_About        (cl, obj, msg));
187
+		case MUIM_Abacus_Rules       : return(Abacus_Rules        (cl, obj, msg));
188
+	}
189
+	return(DoSuperMethodA(cl, obj, msg));
190
+}
191
+

+ 51
- 0
Abacus.hpp View File

@@ -0,0 +1,51 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef INCLUDE_ABACUS_HPP
20
+#define INCLUDE_ABACUS_HPP
21
+/****************************************************************************************
22
+	Abacus.hpp
23
+-----------------------------------------------------------------------------------------
24
+
25
+
26
+
27
+-----------------------------------------------------------------------------------------
28
+	29.12.1996
29
+****************************************************************************************/
30
+
31
+#include "MCC.hpp"
32
+
33
+
34
+#define MUIA_Abacus_Settings	   			(TAGBASE_KAI | 0x1001)
35
+#define MUIM_Abacus_EditSettings    	(TAGBASE_KAI | 0x1003)
36
+#define MUIM_Abacus_About			    		(TAGBASE_KAI | 0x1004)
37
+#define MUIM_Abacus_Rules  		    		(TAGBASE_KAI | 0x1005)
38
+
39
+extern MUI_CustomClass *CL_Abacus;
40
+
41
+
42
+struct Abacus_Data
43
+{
44
+	Object *WI_Main, *WI_Settings, *WI_About, *WI_Rules;
45
+};
46
+
47
+
48
+SAVEDS ASM ULONG Abacus_Dispatcher(REG(a0) struct IClass* cl, 
49
+                                   REG(a2) Object* 				obj, 
50
+                                   REG(a1) Msg 						msg);
51
+#endif

+ 145
- 0
About.cpp View File

@@ -0,0 +1,145 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+/****************************************************************************************
20
+	About.cpp
21
+-----------------------------------------------------------------------------------------
22
+
23
+  CL_About (Window)
24
+
25
+-----------------------------------------------------------------------------------------
26
+	01.01.1996
27
+****************************************************************************************/
28
+
29
+#include "About.hpp"
30
+#include "Tools.hpp"
31
+#include "Images.hpp"
32
+#include <stdio.h>    // für sprintf
33
+
34
+MUI_CustomClass *CL_About;
35
+
36
+
37
+/****************************************************************************************
38
+	AboutMUI
39
+****************************************************************************************/
40
+
41
+ULONG About_AboutMUI(struct IClass* cl, Object* obj, Msg msg)
42
+{
43
+	struct About_Data* data = (About_Data*)INST_DATA(cl, obj);
44
+	Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
45
+	Object* aboutwin = AboutmuiObject,
46
+                       MUIA_Window_RefWindow    , obj,
47
+                       MUIA_Aboutmui_Application, app,
48
+                       End;
49
+	if (aboutwin) setatt(aboutwin, MUIA_Window_Open, TRUE);
50
+	return 0;
51
+}
52
+
53
+
54
+/****************************************************************************************
55
+	New
56
+****************************************************************************************/
57
+
58
+ULONG About_New(struct IClass* cl, Object* obj, struct opSet* msg)
59
+{
60
+	Object *BT_Ok, *BT_MUI;
61
+	About_Data tmp;
62
+
63
+	static char version_text[50];
64
+	sprintf(version_text, GetStr(MSG_ABOUT_VERSION), version_number, version_date);
65
+
66
+	obj = (Object*)DoSuperNew(cl, obj,
67
+		MUIA_HelpNode        	 , "COPYRIGHT",
68
+		MUIA_Window_LeftEdge   , MUIV_Window_LeftEdge_Centered,
69
+		MUIA_Window_TopEdge    , MUIV_Window_TopEdge_Centered,
70
+		MUIA_Window_CloseGadget, FALSE,
71
+		MUIA_Window_DepthGadget, FALSE,
72
+		MUIA_Window_SizeGadget , FALSE,
73
+		MUIA_Window_DragBar    , FALSE,
74
+		MUIA_Window_Borderless , TRUE,
75
+
76
+		WindowContents, VGroup, ButtonFrame,
77
+
78
+			Child, HGroup,
79
+				Child, HVSpace,
80
+	      Child, MakeImage(IMG_Logo_body, IMG_LOGO_WIDTH, IMG_LOGO_HEIGHT, 
81
+	      								 IMG_LOGO_DEPTH, IMG_LOGO_COMPRESSION, IMG_LOGO_MASKING, 
82
+	      								 IMG_Abacus_colors),
83
+				Child, VGroup,
84
+		      Child, MakeImage(IMG_Abacus_body, IMG_ABACUS_WIDTH, IMG_ABACUS_HEIGHT, 
85
+		      								 IMG_ABACUS_DEPTH, IMG_ABACUS_COMPRESSION, 
86
+		      								 IMG_ABACUS_MASKING, IMG_Abacus_colors),
87
+					Child, TextObject,
88
+						MUIA_Text_Contents, version_text,
89
+						MUIA_Font   		  , MUIV_Font_Tiny,
90
+						End,
91
+					End,
92
+				Child, HVSpace,
93
+				End,
94
+
95
+			Child, HBar(),
96
+
97
+			Child, HGroup,
98
+				Child, HVSpace,
99
+				Child, TextObject,
100
+					MUIA_Text_Contents, GetStr(MSG_ABOUT_TEXT),
101
+					End,
102
+				Child, HVSpace,
103
+				End,
104
+
105
+			Child, HBar(),
106
+			Child, HGroup,
107
+				Child, BT_Ok     = MakeButton(MSG_ABOUT_OK , MSG_ABOUT_OK_HELP ),
108
+				Child, BT_MUI    = MakeButton(MSG_ABOUT_MUI, MSG_ABOUT_MUI_HELP),
109
+				End,
110
+
111
+			End,
112
+
113
+		TAG_MORE, msg->ops_AttrList);
114
+
115
+	if (obj)
116
+	{
117
+		DoMethod(obj   , MUIM_Notify, MUIA_Window_CloseRequest, TRUE , obj, 3, MUIM_Set, MUIA_Window_Open, FALSE);
118
+		DoMethod(BT_Ok , MUIM_Notify, MUIA_Pressed            , FALSE, obj, 3, MUIM_Set, MUIA_Window_Open, FALSE);
119
+		DoMethod(BT_MUI, MUIM_Notify, MUIA_Pressed            , FALSE, obj, 1, MUIM_About_AboutMUI);
120
+
121
+
122
+
123
+		struct About_Data* data = (About_Data*)INST_DATA(cl, obj);
124
+		*data = tmp;
125
+		return (ULONG)obj;
126
+	}
127
+	return 0;
128
+}
129
+
130
+
131
+/****************************************************************************************
132
+	Dispatcher
133
+****************************************************************************************/
134
+
135
+SAVEDS ASM ULONG About_Dispatcher(REG(a0) struct IClass* cl, 
136
+											 					  REG(a2) Object* 				obj, 
137
+												  			  REG(a1) Msg 						msg)
138
+{
139
+	switch(msg->MethodID)
140
+	{
141
+		case OM_NEW							: return(About_New     (cl, obj, (opSet*)msg));
142
+		case MUIM_About_AboutMUI: return(About_AboutMUI(cl, obj, msg));
143
+	}
144
+	return DoSuperMethodA(cl, obj, msg);
145
+}

+ 57
- 0
About.hpp View File

@@ -0,0 +1,57 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef INCLUDE_ABOUT_HPP
20
+#define INCLUDE_ABOUT_HPP
21
+/****************************************************************************************
22
+	About.hpp
23
+-----------------------------------------------------------------------------------------
24
+
25
+  Interface des About-Fenster
26
+
27
+-----------------------------------------------------------------------------------------
28
+	02.12.1996
29
+****************************************************************************************/
30
+
31
+#include "MCC.hpp"
32
+
33
+extern MUI_CustomClass *CL_About;
34
+
35
+#define MUIM_About_AboutMUI   	   		(TAGBASE_KAI | 0x1402)
36
+
37
+
38
+
39
+/******************************************************************************
40
+	About_Data
41
+******************************************************************************/
42
+
43
+struct About_Data
44
+{
45
+	Object *dummy;
46
+};
47
+
48
+
49
+/******************************************************************************
50
+	Dispatcher
51
+******************************************************************************/
52
+
53
+SAVEDS ASM ULONG About_Dispatcher(REG(a0) struct IClass* cl, 
54
+											 					  REG(a2) Object* 				obj, 
55
+												  			  REG(a1) Msg 						msg);
56
+
57
+#endif

+ 534
- 0
Board.cpp View File

@@ -0,0 +1,534 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+/*****************************************************************************************
20
+  Board.cpp
21
+------------------------------------------------------------------------------------------
22
+
23
+
24
+
25
+------------------------------------------------------------------------------------------
26
+  03.01.1997
27
+*****************************************************************************************/
28
+
29
+#include "Board.hpp"
30
+#include <stdio.h>
31
+#include <stdlib.h>
32
+#include <string.h>
33
+
34
+
35
+/*****************************************************************************************
36
+  statische Elemente
37
+*****************************************************************************************/
38
+
39
+const char Board::black = 'O';
40
+const char Board::white = 'X';
41
+const char Board::empty = '.';
42
+
43
+const int  Board::next[61][6] =
44
+{
45
+  {-1, -1,  1,  6,  5, -1}, {-1, -1,  2,  7,  6,  0}, {-1, -1,  3,  8,  7,  1}, // 00
46
+  {-1, -1,  4,  9,  8,  2}, {-1, -1, -1, 10,  9,  3}, {-1,  0,  6, 12, 11, -1}, // 03
47
+  { 0,  1,  7, 13, 12,  5}, { 1,  2,  8, 14, 13,  6}, { 2,  3,  9, 15, 14,  7}, // 06
48
+  { 3,  4, 10, 16, 15,  8}, { 4, -1, -1, 17, 16,  9}, {-1,  5, 12, 19, 18, -1}, // 09
49
+  { 5,  6, 13, 20, 19, 11}, { 6,  7, 14, 21, 20, 12}, { 7,  8, 15, 22, 21, 13}, // 12
50
+  { 8,  9, 16, 23, 22, 14}, { 9, 10, 17, 24, 23, 15}, {10, -1, -1, 25, 24, 16}, // 15
51
+  {-1, 11, 19, 27, 26, -1}, {11, 12, 20, 28, 27, 18}, {12, 13, 21, 29, 28, 19}, // 18
52
+  {13, 14, 22, 30, 29, 20}, {14, 15, 23, 31, 30, 21}, {15, 16, 24, 32, 31, 22}, // 21
53
+  {16, 17, 25, 33, 32, 23}, {17, -1, -1, 34, 33, 24}, {-1, 18, 27, 35, -1, -1}, // 24
54
+  {18, 19, 28, 36, 35, 26}, {19, 20, 29, 37, 36, 27}, {20, 21, 30, 38, 37, 28}, // 27
55
+  {21, 22, 31, 39, 38, 29}, {22, 23, 32, 40, 39, 30}, {23, 24, 33, 41, 40, 31}, // 30
56
+  {24, 25, 34, 42, 41, 32}, {25, -1, -1, -1, 42, 33}, {26, 27, 36, 43, -1, -1}, // 33
57
+  {27, 28, 37, 44, 43, 35}, {28, 29, 38, 45, 44, 36}, {29, 30, 39, 46, 45, 37}, // 36
58
+  {30, 31, 40, 47, 46, 38}, {31, 32, 41, 48, 47, 39}, {32, 33, 42, 49, 48, 40}, // 39
59
+  {33, 34, -1, -1, 49, 41}, {35, 36, 44, 50, -1, -1}, {36, 37, 45, 51, 50, 43}, // 42
60
+  {37, 38, 46, 52, 51, 44}, {38, 39, 47, 53, 52, 45}, {39, 40, 48, 54, 53, 46}, // 45
61
+  {40, 41, 49, 55, 54, 47}, {41, 42, -1, -1, 55, 48}, {43, 44, 51, 56, -1, -1}, // 48
62
+  {44, 45, 52, 57, 56, 50}, {45, 46, 53, 58, 57, 51}, {46, 47, 54, 59, 58, 52}, // 51
63
+  {47, 48, 55, 60, 59, 53}, {48, 49, -1, -1, 60, 54}, {50, 51, 57, -1, -1, -1}, // 54
64
+  {51, 52, 58, -1, -1, 56}, {52, 53, 59, -1, -1, 57}, {53, 54, 60, -1, -1, 58}, // 57
65
+  {54, 55, -1, -1, -1, 59}                                                      // 60
66
+};
67
+
68
+/*
69
+Spielfeld:
70
+                 00  01  02  03  04
71
+
72
+               05  06  07  08  09  10
73
+
74
+             11  12  13  14  15  16  17
75
+
76
+           18  19  20  21  22  23  24  25
77
+
78
+         26  27  28  29  30  31  32  33  34
79
+
80
+           35  36  37  38  39  40  41  42
81
+
82
+             43  44  45  46  47  48  49
83
+
84
+               50  51  52  53  54  55
85
+
86
+                 56  57  58  59  60
87
+
88
+Richtungen:
89
+
90
+       0   1
91
+
92
+    5    X    2
93
+
94
+       4   3
95
+*/
96
+
97
+
98
+/*****************************************************************************************
99
+  Kon- /Destruktor
100
+*****************************************************************************************/
101
+
102
+Board::Board()
103
+{
104
+	Clear();
105
+}
106
+
107
+
108
+/*****************************************************************************************
109
+  Dir
110
+*****************************************************************************************/
111
+
112
+int Board::Dir(int a, int b)
113
+{
114
+  for (int i = 0; i < 6; i++)
115
+    if (next[a][i] == b) return i;
116
+  return -1;
117
+}
118
+
119
+
120
+/*****************************************************************************************
121
+  outBalls()
122
+*****************************************************************************************/
123
+
124
+int Board::outBalls(char player) const
125
+{
126
+	return (player == white) ? outwhite : outblack;
127
+}
128
+
129
+
130
+/*****************************************************************************************
131
+  Clear
132
+*****************************************************************************************/
133
+
134
+void Board::Clear()
135
+{
136
+  strcpy(field, "XXXXXXXXXXX..XXX.............................OOO..OOOOOOOOOOO");
137
+  me  		 = white;
138
+  you 		 = black;
139
+	outwhite = 0;
140
+	outblack = 0;
141
+	value    = 0;
142
+}
143
+
144
+
145
+/*****************************************************************************************
146
+  Show
147
+*****************************************************************************************/
148
+
149
+/*
150
+#include <iostream.h>
151
+
152
+void Board::Show() const
153
+{
154
+  int o = 0, i, j;
155
+  for (i = 5; i < 10; i++)
156
+  {
157
+    for (j = 0; j < 10 - i; j++) cout << " ";
158
+    for (j = 0; j < i; j++) cout << field[o + j] << " ";
159
+    o += i;
160
+    cout << "\n";
161
+  }
162
+  for (i = 8; i >= 5; i--)
163
+  {
164
+    for (j = 0; j < 10 - i; j++) cout << " ";
165
+    for (j = 0; j < i; j++) cout << field[o + j] << " ";
166
+    o += i;
167
+    cout << "\n";
168
+  }
169
+};
170
+*/
171
+
172
+
173
+/*****************************************************************************************
174
+  Save / Load
175
+*****************************************************************************************/
176
+
177
+BOOL Board::Save(char* filename)
178
+{
179
+  BOOL ok = FALSE;
180
+  FILE* f = fopen(filename, "w");
181
+  if (f) 
182
+  {
183
+    ok = (fwrite(this, 1, sizeof(Board), f) == sizeof(Board));
184
+    fclose(f);
185
+  }
186
+  return ok;
187
+}
188
+
189
+BOOL Board::Load(char* filename)
190
+{
191
+  BOOL ok = FALSE;
192
+  FILE* f = fopen(filename, "r");
193
+  if (f)
194
+  {
195
+    ok = (fread(this, 1, sizeof(Board), f) == sizeof(Board));
196
+    fclose(f);
197
+  }
198
+  return ok;
199
+}
200
+
201
+
202
+/*****************************************************************************************
203
+	Test
204
+*****************************************************************************************/
205
+
206
+int Board::Test1(int ball1, int dir) const
207
+{
208
+  int pos = next[ball1][dir];
209
+  if (pos == -1) return -1;               // O-
210
+  if (field[pos] == you  ) return -2;     // OX
211
+  if (field[pos] == empty) return 0;      // O.
212
+                                          // OO
213
+  pos = next[pos][dir];
214
+  if (pos == -1) return -1;               // OO-
215
+  if (field[pos] == empty) return 0;      // OO.
216
+  if (field[pos] == you  )                // OOX
217
+  {
218
+    pos = next[pos][dir];
219
+    if (pos == -1) return 1;              // OOX-
220
+    if (field[pos] == empty) return 0;    // OOX.
221
+    return -2;                            // OOXO oder OOXX
222
+  }                                       // OOO
223
+
224
+  pos = next[pos][dir];
225
+  if (pos == -1) return -1;               // OOO-
226
+  if (field[pos] == empty) return 0;      // OOO.
227
+  if (field[pos] == me   ) return -5;     // OOOO
228
+                                          // OOOX
229
+  pos = next[pos][dir];
230
+  if (pos == -1) return 1;                // OOOX-
231
+  if (field[pos] == empty) return 0;      // OOOX.
232
+  if (field[pos] == me   ) return -5;     // OOOXO
233
+                                          // OOOXX
234
+  pos = next[pos][dir];
235
+  if (pos == -1) return 1;                // OOOXX-
236
+  if (field[pos] == empty) return 0;      // OOOXX.
237
+  return -5;                              // OOOXXX oder OOOXXO
238
+};
239
+
240
+int Board::Test(int ball1, int dir, int ball2, int ball3) const
241
+{
242
+  if (ball2 != -1)
243
+  {
244
+    if (next[ball2][dir] == -1) return -1;
245
+    if (field[next[ball2][dir]] != empty) return -3;
246
+    if (ball3 != -1)
247
+    {
248
+      if (next[ball3][dir] == -1) return -1;
249
+      if (field[next[ball3][dir]] != empty) return -3;
250
+    }
251
+    if (next[ball1][dir] == -1) return -1;
252
+    if (field[next[ball1][dir]] != empty) return -3;
253
+    return 0;
254
+  }
255
+  else
256
+  {
257
+    return Test1(ball1, dir);
258
+  }
259
+};
260
+
261
+
262
+/*****************************************************************************************
263
+	Move
264
+*****************************************************************************************/
265
+
266
+#include <iostream.h>
267
+
268
+char Board::ChangePosTo(int pos, char neu)
269
+{
270
+	char alt = field[pos];
271
+	if (alt == neu) return alt;
272
+	field[pos] = neu;
273
+
274
+	int r = 0, a = 0, n = 0;
275
+	for (int dir = 0; dir < 6; dir++)
276
+	{
277
+		int x = next[pos][dir];
278
+		if      (x == -1) 	      r += 4;
279
+		else if (field[x] == alt) a += 2;
280
+		else if (field[x] == neu) n += 2;
281
+	}
282
+
283
+	if 			(alt == white) value += r - a;
284
+	else if (alt == black) value += a - r;
285
+
286
+	if      (neu == white) value += n - r;
287
+	else if (neu == black) value += r - n;
288
+
289
+	return alt;
290
+}
291
+
292
+
293
+void Board::Move1(int ball1, int dir)
294
+{
295
+	/*
296
+	**	Toggle player
297
+	*/
298
+
299
+	char tmp = me;
300
+	me  = you;
301
+	you = tmp;
302
+
303
+	/*
304
+	**	Reihe pushen
305
+	*/
306
+
307
+	tmp = empty;
308
+
309
+  do
310
+  {
311
+		tmp = ChangePosTo(ball1, tmp);
312
+		if (tmp == empty) return;	// Ende der Reihe
313
+
314
+		ball1 = next[ball1][dir];
315
+		if (ball1 == -1)					// Ende des Brettes
316
+		{
317
+			if (me == black)
318
+			{
319
+				value += 1000;
320
+				outblack++;
321
+			}
322
+			else
323
+			{
324
+				value -= 1000;
325
+				outwhite++;
326
+			}
327
+			return;
328
+		}
329
+  }
330
+  while (TRUE);
331
+}
332
+
333
+void Board::Move(int ball1, int dir, int ball2, int ball3)
334
+{
335
+  if (ball2 != -1)
336
+  {
337
+		ChangePosTo(next[ball1][dir], me	 );
338
+		ChangePosTo(ball1						, empty);
339
+		ChangePosTo(next[ball2][dir], me	 );
340
+		ChangePosTo(ball2						, empty);
341
+    if (ball3 != -1)
342
+    {
343
+			ChangePosTo(next[ball3][dir], me	 );
344
+			ChangePosTo(ball3						, empty);
345
+    }
346
+
347
+		char tmp = me;
348
+		me  = you;
349
+		you = tmp;
350
+  }
351
+  else
352
+  {
353
+    Move1(ball1, dir);
354
+  }
355
+}
356
+
357
+
358
+/*****************************************************************************************
359
+  Evaluate
360
+*****************************************************************************************/
361
+
362
+inline int Board::Evaluate() const
363
+{
364
+	return (me == white) ? value : - value;
365
+}
366
+
367
+
368
+/*****************************************************************************************
369
+  AlphaBeta
370
+*****************************************************************************************/
371
+
372
+const int INFINITY = 20000;
373
+
374
+int Board::AlphaBeta(int depth, int alpha, int beta) const
375
+{
376
+	depth--;
377
+	int best = - INFINITY;
378
+	Board b;
379
+
380
+  for (int pos = 60; pos >= 0; pos--)
381
+  {
382
+    if (field[pos] == me)
383
+    {
384
+      for (int dir = 5; dir >= 0; dir--)
385
+      {
386
+        if (Test1(pos, dir) >= 0)
387
+				{
388
+					b = *this;
389
+					b.Move1(pos, dir);
390
+
391
+					int v;
392
+					if (depth)
393
+						v = - b.AlphaBeta(depth, -beta, -alpha);
394
+					else
395
+						v = - b.Evaluate();
396
+
397
+					if (v > best) 
398
+					{
399
+						best = v;
400
+						if (best >= beta) return best;
401
+						if (best > alpha) alpha = best;
402
+					}
403
+
404
+				}
405
+			}
406
+		}
407
+	}
408
+
409
+	return best;
410
+}
411
+
412
+
413
+/*****************************************************************************************
414
+  PrincipalVariation
415
+*****************************************************************************************/
416
+
417
+int Board::PrincipalVariation(int depth, int alpha, int beta)
418
+{
419
+	if (!depth) return Evaluate();
420
+	depth--;
421
+	int dir = 5, pos = -1;
422
+
423
+	Board b = *this;
424
+	b.NextMove(pos, dir);
425
+	int best = - b.PrincipalVariation(depth, -beta, -alpha);
426
+
427
+	while (b.NextMove(pos, dir) && best < beta)
428
+	{
429
+		if (best > alpha) alpha = best;
430
+		int value = - b.PrincipalVariation(depth, -alpha - 1, -alpha);
431
+		if (value > alpha && value < beta) 
432
+			best = - b.PrincipalVariation(depth, -beta, -value);
433
+		else if (value > best)
434
+			best = value;
435
+
436
+		b = *this;
437
+	}
438
+
439
+	return best;
440
+}
441
+
442
+
443
+/*****************************************************************************************
444
+  ComputerMove
445
+*****************************************************************************************/
446
+
447
+void Board::Computer_Move(Status& status, int tiefe)
448
+{
449
+  status.Update(0, (14 - outBalls(me))*6);
450
+  int nr = 1;
451
+
452
+  /*
453
+	**	Zufallsfeld erzeugen
454
+	*/
455
+
456
+	int rpos[61], p, dest;
457
+  for (p = 0; p < 61; p++) rpos[p] = -1;
458
+  for (p = 0; p < 61; p++)
459
+  {
460
+		do {dest = Random(61);}
461
+		while (rpos[dest] != -1);
462
+		rpos[dest] = p;
463
+  }
464
+
465
+	int rdir[6];
466
+  for (p = 0; p < 6; p++) rdir[p] = -1;
467
+  for (p = 0; p < 6; p++)
468
+  {
469
+		do {dest = Random(6);}
470
+		while (rdir[dest] != -1);
471
+		rdir[dest] = p;
472
+  }
473
+
474
+
475
+  /*
476
+	**	Alle Möglichkeiten testen
477
+	*/
478
+
479
+	int 	best = - INFINITY;
480
+	Board bestboard;
481
+	tiefe--;
482
+
483
+  for (p = 0; p < 61 && !status.Break(); p++)
484
+  {
485
+    int pos = rpos[p];
486
+    if (field[pos] == me)
487
+    {
488
+      for (int d = 0; d < 6 && !status.Break(); d++)
489
+      {
490
+				status.Update(nr++);
491
+				int dir = rdir[d];
492
+        if (Test1(pos, dir) >= 0)
493
+				{
494
+					Board b = *this;
495
+					b.Move1(pos, dir);
496
+					int test;
497
+					if (tiefe)
498
+						test = - b.AlphaBeta(tiefe, -INFINITY, +INFINITY);
499
+					else
500
+						test = - b.Evaluate();
501
+					if (test > best) 
502
+					{
503
+						best = test;
504
+						bestboard = b;
505
+					}
506
+				}	// if Test1 >= 0
507
+			} // for dir
508
+		}	// if me
509
+	}	// for pos
510
+
511
+  *this = bestboard;
512
+};
513
+
514
+
515
+/*****************************************************************************************
516
+  Sucessors
517
+*****************************************************************************************/
518
+
519
+BOOL Board::NextMove(int &pos, int &dir)
520
+{
521
+	do
522
+	{
523
+		dir++;
524
+		if (dir == 6)
525
+		{
526
+			dir = 0;
527
+			pos++;
528
+			if (pos == 61) return FALSE;
529
+		}
530
+	}
531
+	while (field[pos] != me || Test1(pos, dir) < 0);
532
+	Move1(pos, dir);
533
+	return TRUE;
534
+}

+ 126
- 0
Board.hpp View File

@@ -0,0 +1,126 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef INCLUDE_BOARD_HPP
20
+#define INCLUDE_BOARD_HPP
21
+/*****************************************************************************************
22
+  Board.hpp
23
+------------------------------------------------------------------------------------------
24
+
25
+
26
+
27
+------------------------------------------------------------------------------------------
28
+  03.01.1997
29
+*****************************************************************************************/
30
+
31
+#include "Status.hpp"
32
+
33
+
34
+class Board
35
+{
36
+  public:
37
+
38
+    char  field[62];                //  Spielfeld
39
+    char  me, you;                  //  Aktiver Spieler und Gegenspieler
40
+
41
+    static const char black;
42
+    static const char white;
43
+    static const char empty;
44
+    static const int  next[61][6];
45
+
46
+					Board();
47
+
48
+		int 	outBalls(char player) const;
49
+
50
+    /*
51
+    **  Initialisierung mit Startboard
52
+    */
53
+
54
+    void 	Clear();
55
+
56
+    /*
57
+    **  Brett als ASCII-Kunstwerk nach cout schicken
58
+    */
59
+
60
+    //void Show() const;
61
+
62
+    /*
63
+    **  Testet, ob Zug legal ist.
64
+    **  Es wird vorausgesetzt, dass alle drei Kugeln von der
65
+    **  selben Farbe sind und in einer Reihe liegen. Sonst aber nichts.
66
+    **
67
+    **  Rueckgabewert:   1  eine Kugel des Gegeners flog raus
68
+    **                   0  keine Kugel folg raus
69
+    **                  -1  Fehler: eigene Kugel(n) rausgeschmissen
70
+    **                  -2  Fehler: keine Uebermacht
71
+    **                  -3  Fehler: seitlich nicht leer
72
+    **                  -5  Fehler: sonstiges
73
+    */
74
+
75
+    int 	Test(int, int dir, int, int) const;
76
+
77
+    /*
78
+    **  Fuehrt Zug ungeprueft aus
79
+    */
80
+
81
+    void 	Move(int, int dir, int, int);
82
+
83
+    /*
84
+    **  Fuehrt Zug fuer 'me' aus
85
+    */
86
+
87
+    void 	Computer_Move(Status& status, int depth);
88
+
89
+    /*
90
+    **  Speichern und Laden
91
+    */
92
+
93
+    BOOL 	Save(char* filename);
94
+    BOOL 	Load(char* filename);
95
+
96
+    /*
97
+    **  Retourniert Richtung, in der sich b von a befindet (oder -1)
98
+    */
99
+
100
+    static int Dir(int a, int b);
101
+
102
+	private:
103
+
104
+		int 	outwhite, outblack;							// Anz. der verlorenen Kugeln
105
+		int		value;													// Bewertungsindex für white
106
+
107
+		char  ChangePosTo(int pos, char neu);	// Ändert Position in neue Farbe und
108
+																					// retourniert alte. Führt randwhite/black
109
+																					// mit.
110
+
111
+
112
+    int 	Test1			(int, int dir) const;
113
+    void 	Move1		 (int, int dir);
114
+
115
+		int 	Evaluate() const;
116
+
117
+		int 	AlphaBeta(int depth, int alpha, int beta) const;
118
+
119
+		int 	PrincipalVariation(int depth, int alpha, int beta);
120
+
121
+
122
+
123
+		BOOL	NextMove(int &pos, int &dir);
124
+
125
+};
126
+#endif

+ 867
- 0
BoardClass.cpp View File

@@ -0,0 +1,867 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+/****************************************************************************************
20
+  BoardClass.cpp
21
+-----------------------------------------------------------------------------------------
22
+
23
+  CL_Board (Area)
24
+
25
+-----------------------------------------------------------------------------------------
26
+  01.01.1997
27
+****************************************************************************************/
28
+
29
+#include <graphics/gfxmacros.h>
30
+#include <pragma/graphics_lib.h>
31
+#include <pragma/exec_lib.h> 			// Wait
32
+#include <stdio.h>
33
+
34
+#include "BoardClass.hpp"
35
+#include "BoardWindow.hpp"
36
+#include "Abacus.hpp"
37
+#include "Tools.hpp"
38
+#include "Settings.hpp"
39
+#include "StatusWin.hpp"
40
+#include "MsgWin.hpp"
41
+
42
+MUI_CustomClass *CL_Board;
43
+
44
+
45
+
46
+/****************************************************************************************
47
+  Board_Data
48
+****************************************************************************************/
49
+
50
+const int ALLDRAW   = 1;    //  Kugeln und Auskugeln zeichnen
51
+const int SELSDRAW  = 3;    //  Selektionen zeichnen
52
+
53
+void Board_Data::GetCenterOf(int nr, int &cx, int &cy)
54
+{
55
+  float x = nr, y;
56
+  if      (nr <  5) {y = 0.1;          x += 2.1;};
57
+  else if (nr < 11) {y = 1.1; x -=  5; x += 1.6;};
58
+  else if (nr < 18) {y = 2.1; x -= 11; x += 1.1;};
59
+  else if (nr < 26) {y = 3.1; x -= 18; x += 0.6;};
60
+  else if (nr < 35) {y = 4.1; x -= 26; x += 0.1;};
61
+  else if (nr < 43) {y = 5.1; x -= 35; x += 0.6;};
62
+  else if (nr < 50) {y = 6.1; x -= 43; x += 1.1;};
63
+  else if (nr < 56) {y = 7.1; x -= 50; x += 1.6;};
64
+  else              {y = 8.1; x -= 56; x += 2.1;};
65
+  cx = left + rx + int(x * dx),
66
+  cy = top  + ry + int(y * dy);
67
+}
68
+
69
+int Board_Data::GetNrOf(int x, int y)
70
+{
71
+  float my = float(y - top ) / float(dy);
72
+  if (my < 0 || my >= 9) return -1;
73
+  int ball, maxx;
74
+  switch(my)
75
+  {
76
+    case 0: ball =  0; maxx = 4; break;
77
+    case 1: ball =  5; maxx = 5; break;
78
+    case 2: ball = 11; maxx = 6; break;
79
+    case 3: ball = 18; maxx = 7; break;
80
+    case 4: ball = 26; maxx = 8; break;
81
+    case 5: ball = 35; maxx = 7; break;
82
+    case 6: ball = 43; maxx = 6; break;
83
+    case 7: ball = 50; maxx = 5; break;
84
+    case 8: ball = 56; maxx = 4; break;
85
+  }
86
+  float mx = float(x - left - (8-maxx) * dx / 2) / float(dx);
87
+  if (mx < 0 || mx >= maxx + 1) return -1;
88
+  ball += mx;
89
+  return ball;
90
+}
91
+
92
+ULONG Board_Data::ActivePlayerNr()
93
+{
94
+	if (board.me == Board::white)
95
+		return 1;
96
+	else
97
+		return 2;
98
+}
99
+
100
+
101
+/****************************************************************************************
102
+  NewSettings
103
+****************************************************************************************/
104
+
105
+ULONG Board_NewSettings(struct IClass* cl, Object* obj, Msg msg)
106
+{
107
+  struct Board_Data *data = (Board_Data*)INST_DATA(cl,obj);
108
+  data->newsettings = TRUE;
109
+  data->diff        = FALSE;
110
+  data->update_mode = ALLDRAW;
111
+  MUI_Redraw(obj, MADF_DRAWUPDATE);
112
+  data->setsels     = TRUE;
113
+  data->update_mode = SELSDRAW;
114
+  MUI_Redraw(obj, MADF_DRAWUPDATE);
115
+  return 0;
116
+}
117
+
118
+/****************************************************************************************
119
+	NewGame
120
+****************************************************************************************/
121
+
122
+ULONG Board_NewGame(struct IClass* cl, Object* obj, Msg msg)
123
+{
124
+  struct Board_Data *data = (Board_Data*)INST_DATA(cl,obj);
125
+	Board b;
126
+	setatt(obj, MUIA_Board_Board, &b);
127
+	return 0;
128
+}
129
+
130
+
131
+/****************************************************************************************
132
+	Load / Save
133
+****************************************************************************************/
134
+
135
+ULONG Board_Load(struct IClass* cl, Object* obj, Msg msg)
136
+{
137
+	struct Board_Data* data = (Board_Data*)INST_DATA(cl, obj);
138
+	Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
139
+	char* fname = GetFilename(_win(obj), FALSE, MSG_LOAD_TITLE, "", "Games/");
140
+	if (fname)
141
+	{
142
+		Board b;
143
+		if (b.Load(fname))
144
+			setatt(obj, MUIA_Board_Board, &b);
145
+		else
146
+ 			ShowError(app, obj, MSG_LOAD_ERROR);
147
+	}
148
+
149
+	return 0;
150
+}
151
+
152
+ULONG Board_Save(struct IClass* cl, Object* obj, Msg msg)
153
+{
154
+	struct Board_Data* data = (Board_Data*)INST_DATA(cl, obj);
155
+	Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
156
+
157
+	char* fname = GetFilename(_win(obj), TRUE, MSG_SAVE_TITLE, "", "Games/");
158
+	if (fname)
159
+	{
160
+		if (!data->board.Save(fname)) 
161
+			ShowError(app, obj, MSG_SAVE_ERROR);
162
+	}
163
+	return 0;
164
+}
165
+
166
+
167
+/****************************************************************************************
168
+  Undo
169
+****************************************************************************************/
170
+
171
+ULONG Board_Undo(struct IClass* cl, Object* obj, Msg msg)
172
+{
173
+  struct Board_Data *data = (Board_Data*)INST_DATA(cl,obj);
174
+  Board n = data->last_board;
175
+  setatt(obj, MUIA_Board_Board, &n);
176
+  return 0;
177
+}
178
+
179
+
180
+/****************************************************************************************
181
+  TogglePlayer
182
+****************************************************************************************/
183
+
184
+ULONG Board_Winner(struct IClass* cl, Object* obj, Msg msg)
185
+{
186
+  struct Board_Data* data = (Board_Data*)INST_DATA(cl, obj);
187
+  Object* win = (Object*)xget(obj, MUIA_WindowObject);
188
+  Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
189
+  Settings* s = (Settings*)xget(app, MUIA_Abacus_Settings);
190
+
191
+	setatt(win, MUIA_Window_Sleep, TRUE);
192
+
193
+  char buffer[100];
194
+  if (data->board.outBalls(Board::black) == 6)
195
+    sprintf(buffer, GetStr(MSG_WINNER_TEXT), s->name1); 
196
+  else
197
+    sprintf(buffer, GetStr(MSG_WINNER_TEXT), s->name2); 
198
+
199
+	Object* mwin = (Object*)NewObject(CL_MsgWin->mcc_Class, NULL,
200
+			MUIA_Window_RefWindow	, win,
201
+			MUIA_MsgWin_MsgBig  	, GetStr(MSG_WINNER_TITLE),
202
+			MUIA_MsgWin_MsgSmall	, buffer,
203
+			TAG_DONE);
204
+	if (!mwin) return 0;
205
+
206
+	DoMethod(app, OM_ADDMEMBER, mwin);
207
+	setatt(mwin, MUIA_Window_Open, TRUE);
208
+
209
+	ULONG sigs = 0;
210
+	while (DoMethod(app, MUIM_Application_NewInput, &sigs) != MUIV_MsgWin_Close)
211
+	{
212
+		if (sigs)	sigs = Wait(sigs);
213
+	}
214
+
215
+	setatt(mwin, MUIA_Window_Open, FALSE);
216
+	DoMethod(app, OM_REMMEMBER, mwin);
217
+	DisposeObject(mwin);
218
+
219
+	DoMethod(obj, MUIM_Board_NewGame);
220
+
221
+	setatt(win, MUIA_Window_Sleep, FALSE);
222
+  return 0;
223
+}
224
+
225
+
226
+/****************************************************************************************
227
+  ComputerMove
228
+****************************************************************************************/
229
+
230
+ULONG Board_ComputerMove(struct IClass* cl, Object* obj, Msg msg)
231
+{
232
+  struct Board_Data* data = (Board_Data*)INST_DATA(cl, obj);
233
+  Object* win = (Object*)xget(obj, MUIA_WindowObject);
234
+  Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
235
+  Settings* s = (Settings*)xget(app, MUIA_Abacus_Settings);
236
+
237
+	setatt(app, MUIA_Application_Sleep, TRUE);
238
+
239
+  Board undo = data->last_board;
240
+  data->last_board  = data->board;		//wg. Diffsdraw
241
+
242
+	if (s->depth2 > 2)
243
+	{
244
+    StatusWin_Status status(app, win);
245
+		status.Init();
246
+	  data->board.Computer_Move(status, s->depth2);
247
+		status.Exit();
248
+	}
249
+	else
250
+	{
251
+	  Status status;
252
+	  data->board.Computer_Move(status, s->depth2);
253
+	}
254
+
255
+  data->diff        = TRUE;
256
+  data->update_mode = ALLDRAW;
257
+  MUI_Redraw(obj, MADF_DRAWUPDATE);
258
+
259
+  if (data->board.outBalls(data->board.me) == 6)
260
+	{
261
+    DoMethod(obj, MUIM_Board_Winner);
262
+	}
263
+	else
264
+	{
265
+  	setatt(win, MUIA_BoardWindow_ActivePlayer, data->ActivePlayerNr());
266
+
267
+		if (s->auto2)
268
+		{
269
+	    if (data->ActivePlayerNr() == 2)
270
+  	  {
271
+				DoMethod(app, MUIM_Application_PushMethod,
272
+								 obj, 1, MUIM_Board_ComputerMove);
273
+	    }
274
+			else
275
+			  data->last_board  = undo;
276
+		}
277
+	}
278
+
279
+	setatt(app, MUIA_Application_Sleep, FALSE);
280
+	return 0;
281
+}
282
+
283
+
284
+/****************************************************************************************
285
+  AskMinMax
286
+****************************************************************************************/
287
+
288
+SAVEDS ULONG Board_AskMinMax(struct IClass*         cl, 
289
+                             Object*                obj, 
290
+                             struct MUIP_AskMinMax* msg)
291
+{
292
+  DoSuperMethodA(cl, obj, (Msg)msg);
293
+  msg->MinMaxInfo->MinWidth  += 200;
294
+  msg->MinMaxInfo->DefWidth  += 300;
295
+  msg->MinMaxInfo->MaxWidth  += MUI_MAXMAX;
296
+  msg->MinMaxInfo->MinHeight += 100;
297
+  msg->MinMaxInfo->DefHeight += 200;
298
+  msg->MinMaxInfo->MaxHeight += MUI_MAXMAX;
299
+  return 0;
300
+}
301
+
302
+
303
+/****************************************************************************************
304
+  Setup / Cleanup
305
+****************************************************************************************/
306
+
307
+SAVEDS ULONG Board_Setup(struct IClass* cl, Object* obj, Msg msg)
308
+{
309
+  if (!DoSuperMethodA(cl, obj, msg)) return(FALSE);
310
+  struct Board_Data *data = (Board_Data*)INST_DATA(cl,obj);
311
+
312
+  MUI_RequestIDCMP(obj, IDCMP_MOUSEBUTTONS);
313
+  return TRUE;
314
+}
315
+
316
+SAVEDS ULONG Board_Cleanup(struct IClass* cl, Object* obj, Msg msg)
317
+{
318
+  struct Board_Data *data = (Board_Data*)INST_DATA(cl,obj);
319
+  MUI_ReleasePen(muiRenderInfo(obj), data->pen1); data->pen1 = -1;
320
+  MUI_ReleasePen(muiRenderInfo(obj), data->pen2); data->pen2 = -1;
321
+  MUI_ReleasePen(muiRenderInfo(obj), data->pen3); data->pen3 = -1;
322
+  MUI_ReleasePen(muiRenderInfo(obj), data->pen4); data->pen4 = -1;
323
+  data->newsettings = TRUE; // damit die Pens nachher wieder allokiert werden
324
+
325
+  MUI_RejectIDCMP(obj,IDCMP_MOUSEBUTTONS);
326
+  return(DoSuperMethodA(cl, obj, msg));
327
+}
328
+
329
+
330
+/****************************************************************************************
331
+  Handle_Input
332
+****************************************************************************************/
333
+
334
+SAVEDS ULONG Board_HandleInput(struct IClass*           cl,
335
+                               Object*                  obj, 
336
+                               struct MUIP_HandleInput* msg)
337
+{
338
+  Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
339
+  Object* win = (Object*)xget(obj, MUIA_WindowObject);
340
+  struct Board_Data *data = (Board_Data*)INST_DATA(cl,obj);
341
+
342
+  if (  !msg->imsg ||
343
+       (!(msg->imsg->Class == IDCMP_MOUSEBUTTONS) && 
344
+        !(msg->imsg->Class == IDCMP_MOUSEMOVE   ))
345
+     )  return(DoSuperMethodA(cl, obj, (Msg)msg));
346
+
347
+  int ball = data->GetNrOf(msg->imsg->MouseX, msg->imsg->MouseY);
348
+  if (ball == -1) return(DoSuperMethodA(cl, obj, (Msg)msg));
349
+
350
+  switch (msg->imsg->Class)
351
+  {
352
+    /*
353
+    **
354
+    **  IDCMP_MOUSEBUTTONS
355
+    **
356
+    */
357
+
358
+    case IDCMP_MOUSEBUTTONS:
359
+    {     
360
+      switch (msg->imsg->Code)
361
+      {
362
+        /*
363
+        **  SELECTDOWN
364
+        */
365
+
366
+        case SELECTDOWN:
367
+        {
368
+          /*
369
+          **  Erste Selektion
370
+          */
371
+
372
+          if (data->ball[0] == -1)
373
+          {
374
+            if (data->board.field[ball] == data->board.me)
375
+            {
376
+              data->ball[0]  			 = ball;
377
+              data->update_mode    = SELSDRAW;
378
+              data->setsels        = TRUE;
379
+              MUI_Redraw(obj, MADF_DRAWUPDATE);
380
+              MUI_RequestIDCMP(obj, IDCMP_MOUSEMOVE);
381
+            }
382
+          }
383
+
384
+          /*
385
+          **  Selektion canceln
386
+          */
387
+                    
388
+          else if (data->ball[0] == ball || 
389
+                   data->ball[1] == ball || 
390
+                   data->ball[2] == ball)
391
+          {
392
+            data->setsels       = FALSE;
393
+            data->update_mode   = SELSDRAW;
394
+            MUI_Redraw(obj, MADF_DRAWUPDATE);
395
+            data->ball[0] = -1;
396
+            data->ball[1] = -1;
397
+            data->ball[2] = -1;
398
+          }
399
+          
400
+          /*
401
+          **  Zweite Selektion (Richtung)
402
+          */
403
+          
404
+          else
405
+          {
406
+            int dir = Board::Dir(data->ball[0], ball);
407
+            if (dir != -1 && 
408
+            		data->board.Test(data->ball[0], dir, data->ball[1], data->ball[2]) >= 0)
409
+            {             
410
+              //  Selektionen löschen
411
+
412
+              data->setsels     = FALSE;
413
+              data->update_mode = SELSDRAW;
414
+              MUI_Redraw(obj, MADF_DRAWUPDATE);
415
+
416
+              //  Zug ausführen
417
+
418
+              data->last_board = data->board;
419
+              data->board.Move(data->ball[0], dir, data->ball[1], data->ball[2]);
420
+              data->ball[0] = -1;
421
+              data->ball[1] = -1;
422
+              data->ball[2] = -1;
423
+              data->diff          = TRUE;
424
+              data->update_mode   = ALLDRAW;
425
+              MUI_Redraw(obj, MADF_DRAWUPDATE);
426
+
427
+					    if (data->board.outBalls(data->board.me) == 6)
428
+							{
429
+	              DoMethod(obj, MUIM_Board_Winner);
430
+							}
431
+							else
432
+							{
433
+					      setatt(win, MUIA_BoardWindow_ActivePlayer, data->ActivePlayerNr());
434
+
435
+  	            Settings* s = (Settings*)xget(app, MUIA_Abacus_Settings);
436
+    	          if (s->auto2)
437
+      	        {
438
+									DoMethod(app, MUIM_Application_PushMethod,
439
+													 obj, 1, MUIM_Board_ComputerMove);
440
+              	}
441
+							}
442
+
443
+            }
444
+          }
445
+          
446
+          break;
447
+        } // End SELECTDOWN
448
+
449
+        /*
450
+        **  SELECTUP
451
+        */
452
+
453
+        case SELECTUP:
454
+        {
455
+          MUI_RejectIDCMP(obj, IDCMP_MOUSEMOVE);
456
+          break;
457
+        } // End SELECTUP
458
+
459
+      } // End UP/DOWN case
460
+      break;
461
+    } //  End IDCMP_MOUSEBUTTONS
462
+
463
+
464
+    /*
465
+    **
466
+    **  IDCMP_MOUSEMOVE
467
+    **
468
+    */
469
+
470
+    case IDCMP_MOUSEMOVE:
471
+    {
472
+      char me = data->board.me;
473
+      int b1 = -1, b2 = -1;
474
+      for (int i = 0; i < 6; i++)
475
+      {
476
+        int n = Board::next[data->ball[0]][i];
477
+        if (n == ball) 
478
+        {
479
+          b1 = ball;
480
+          if (data->board.field[b1] != me) b1 = -1;             //  nur eigene
481
+        }
482
+        else if (n != -1 && Board::next[n][i] == ball)
483
+        {
484
+          b1 = n;
485
+          b2 = ball;
486
+          if (data->board.field[b1] != me) {b1 = -1; b2 = -1;}  //  nicht über
487
+          if (data->board.field[b2] != me) b2 = -1;             //  Lücken
488
+        }
489
+      }
490
+
491
+      if (data->ball[1] != b1 || data->ball[2] != b2)
492
+      {
493
+        //  Selektionen löschen
494
+
495
+        data->setsels       = FALSE;
496
+        data->update_mode   = SELSDRAW;
497
+        MUI_Redraw(obj, MADF_DRAWUPDATE);
498
+
499
+        //  Neue setzen
500
+
501
+        data->ball[1] = b1;
502
+        data->ball[2] = b2;
503
+        data->setsels       = TRUE;
504
+        data->update_mode   = SELSDRAW;
505
+        MUI_Redraw(obj, MADF_DRAWUPDATE);
506
+      }
507
+
508
+      break;
509
+    } // End IDCMP_MOUSEMOVE
510
+
511
+  } // End switch Class
512
+  return(DoSuperMethodA(cl, obj, (Msg)msg));
513
+}
514
+
515
+
516
+/****************************************************************************************
517
+  Draw
518
+****************************************************************************************/
519
+
520
+SAVEDS ULONG Board_Draw(struct IClass* cl, Object* obj, struct MUIP_Draw* msg)
521
+{
522
+  DoSuperMethodA(cl, obj, (Msg)msg);
523
+  if (!(msg->flags & (MADF_DRAWUPDATE + MADF_DRAWOBJECT))) return 0; // Überflüssig?
524
+
525
+  struct Board_Data* data = (Board_Data*)INST_DATA(cl,obj);
526
+  RastPort* rp  = _rp(obj);
527
+  struct AreaInfo areainfo;
528
+  struct TmpRas   tmp;
529
+
530
+  //APTR      cliphandle  = MUI_AddClipping(muiRenderInfo(obj), _mleft (obj), _mtop(obj), 
531
+  //                                                            _mwidth(obj), _mheight(obj)); // Überflüssig?
532
+  int       w           = rp->BitMap->BytesPerRow * 8,
533
+            h           = rp->BitMap->Rows;
534
+  PLANEPTR  mem         = AllocRaster(w, h);
535
+
536
+  InitArea(&areainfo, &data->areabuffer, 400);
537
+  rp->TmpRas   = (struct TmpRas*)InitTmpRas(&tmp, mem, RASSIZE(w, h));
538
+  rp->AreaInfo = &areainfo;
539
+
540
+  /*
541
+  **
542
+  **  DRAWOBJECT
543
+  **
544
+  */
545
+
546
+  if (msg->flags & MADF_DRAWOBJECT)
547
+  {
548
+    data->left   = _mleft  (obj) + 5;
549
+    data->right  = _mright (obj) - 5;
550
+    data->top    = _mtop   (obj) + 5;
551
+    data->bottom = _mbottom(obj) - 5;
552
+    data->width  = data->right  - data->left + 1;
553
+    data->height = data->bottom - data->top  + 1;
554
+    data->mdx    = _mwidth (obj) / 21;          // Abstand zwischen Minikugelmittelpunkten
555
+    data->mdy    = _mheight(obj) / 21;          //
556
+    data->mrx    = int((0.8 * data->mdx) / 2);  // Minikugelradius
557
+    data->mry    = int((0.8 * data->mdy) / 2);  //
558
+    data->dx     = data->width  / 9;            // Abstand zwischen Kugelmittelpunkten
559
+    data->dy     = data->height / 9;            //
560
+    data->rx     = int((0.8 * data->dx) / 2);   // Kugelradius
561
+    data->ry     = int((0.8 * data->dy) / 2);   //
562
+
563
+    data->diff        = FALSE;
564
+    data->setsels     = TRUE;
565
+  }
566
+
567
+
568
+  /*
569
+  **
570
+  **  ALLDRAW
571
+  **
572
+  */
573
+
574
+  if (data->update_mode == ALLDRAW || msg->flags & MADF_DRAWOBJECT)
575
+  {
576
+    /*
577
+    **  New settings?
578
+    */
579
+
580
+    if (data->newsettings)
581
+    {
582
+      Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
583
+      Settings* s = (Settings*)xget(app, MUIA_Abacus_Settings);
584
+
585
+      if (data->pen1 != -1) MUI_ReleasePen(muiRenderInfo(obj), data->pen1);
586
+      if (data->pen2 != -1) MUI_ReleasePen(muiRenderInfo(obj), data->pen2);
587
+      if (data->pen3 != -1) MUI_ReleasePen(muiRenderInfo(obj), data->pen3);
588
+      if (data->pen4 != -1) MUI_ReleasePen(muiRenderInfo(obj), data->pen4);
589
+      data->pen1 = MUI_ObtainPen(muiRenderInfo(obj), &s->color1, 0);
590
+      data->pen2 = MUI_ObtainPen(muiRenderInfo(obj), &s->color2, 0);
591
+      data->pen3 = MUI_ObtainPen(muiRenderInfo(obj), &s->color3, 0);
592
+      data->pen4 = MUI_ObtainPen(muiRenderInfo(obj), &s->color4, 0);
593
+
594
+      data->dirs        = s->dirs;
595
+      data->newsettings = FALSE;
596
+    }
597
+
598
+    /*
599
+    **  Spielfeld
600
+    */
601
+
602
+    for (int color = 0; color < 3; color++)
603
+    {
604
+      BOOL draw = FALSE;
605
+      for (int f = 0; f < 61; f++)
606
+      {
607
+        if (data->board.field[f] != data->last_board.field[f] || !data->diff)
608
+        {
609
+          if (color == 1 && data->board.field[f] == Board::white  ||
610
+              color == 2 && data->board.field[f] == Board::black  ||
611
+              color == 0 && data->board.field[f] == Board::empty   ) 
612
+          {
613
+            int cx, cy;
614
+            data->GetCenterOf(f, cx, cy);
615
+            AreaEllipse(rp, cx, cy, data->rx, data->ry);
616
+            draw = TRUE;
617
+          }
618
+        }
619
+      }
620
+      if (draw) 
621
+      {
622
+        switch(color)
623
+        {
624
+          case 0: SetAPen (rp, MUIPEN(data->pen3)); break;
625
+          case 1: SetAPen (rp, MUIPEN(data->pen1)); break;
626
+          case 2: SetAPen (rp, MUIPEN(data->pen2)); break;
627
+        }
628
+        AreaEnd(rp);
629
+      }
630
+    }
631
+
632
+    /*
633
+    **  Minikugeln
634
+    */
635
+
636
+    BYTE o = rp->AOlPen;
637
+    int mx = data->right - data->mrx, my ,i;
638
+
639
+    if (data->board.outBalls(Board::white) != data->last_board.outBalls(Board::white) || !data->diff)
640
+    {
641
+      SetAPen(rp, MUIPEN(data->pen1));
642
+      SetOPen(rp, MUIPEN(data->pen1));
643
+      my = data->top   + data->mry;
644
+      for (i = 0; i < 6; i++)
645
+      {
646
+        if (i == data->board.outBalls(Board::white)) SetAPen(rp, 0);
647
+        AreaEllipse(rp, mx, my + data->mdy * i, data->mrx, data->mry);
648
+        AreaEnd(rp);
649
+      }
650
+    }
651
+
652
+    if (data->board.outBalls(Board::black) != data->last_board.outBalls(Board::black) || !data->diff)
653
+    {
654
+      SetAPen(rp, MUIPEN(data->pen2));
655
+      SetOPen(rp, MUIPEN(data->pen2));
656
+      my = data->bottom - data->mry;
657
+      for (i = 0; i < 6; i++)
658
+      {
659
+        if (i == data->board.outBalls(Board::black)) SetAPen(rp, 0);
660
+        AreaEllipse(rp, mx, my - data->mdy * i, data->mrx, data->mry);
661
+        AreaEnd(rp);
662
+      }
663
+    }
664
+
665
+    SetOPen(rp, o);
666
+
667
+  }
668
+
669
+  /*
670
+  **
671
+  **  SELSDRAW
672
+  **
673
+  */
674
+
675
+  if (data->update_mode == SELSDRAW || msg->flags & MADF_DRAWOBJECT)
676
+  {
677
+    /*
678
+    **  Selektiere (de-)markieren
679
+    */
680
+
681
+    for (int i = 0; i < 3; i++)
682
+    {
683
+      if (data->ball[i] != -1)
684
+      {
685
+        int cx, cy;
686
+        data->GetCenterOf(data->ball[i], cx, cy);
687
+        if (data->setsels)
688
+        {
689
+          SetAPen(rp, MUIPEN(data->pen4));
690
+          AreaEllipse(rp, cx, cy, int(data->rx / 2.5), int(data->ry / 2.5));
691
+        }
692
+        else
693
+        {
694
+					char c = data->board.field[data->ball[i]];
695
+
696
+          if 			(c == Board::white)	SetAPen(rp, MUIPEN(data->pen1));
697
+					else if (c == Board::black) SetAPen(rp, MUIPEN(data->pen2));
698
+					else											 	SetAPen(rp, MUIPEN(data->pen3));
699
+ 
700
+          AreaEllipse(rp, cx, cy, data->rx, data->ry);
701
+        }
702
+        AreaEnd(rp);
703
+      }
704
+    }
705
+
706
+    /*
707
+    **  Zugmöglichkeiten anzeigen/löschen
708
+    */
709
+
710
+    if (data->dirs && data->ball[0] != -1)
711
+    {
712
+      for (int dir = 0; dir < 6; dir++)
713
+      {
714
+        if (data->board.Test(data->ball[0], dir, data->ball[1], data->ball[2]) >= 0)
715
+        {
716
+          int n = Board::next[data->ball[0]][dir];
717
+          if (n != -1)
718
+          {
719
+            int cx, cy;
720
+            data->GetCenterOf(n, cx, cy);
721
+
722
+            if (data->setsels)
723
+            {
724
+              SetAPen(rp, MUIPEN(data->pen4));
725
+              AreaEllipse(rp, cx, cy, data->rx, data->ry);
726
+              AreaEnd(rp);
727
+            }
728
+
729
+						char c = data->board.field[n];
730
+    	      if 			(c == Board::white)	SetAPen(rp, MUIPEN(data->pen1));
731
+						else if (c == Board::black) SetAPen(rp, MUIPEN(data->pen2));
732
+						else											 	SetAPen(rp, MUIPEN(data->pen3));
733
+
734
+            if (data->setsels)
735
+              AreaEllipse(rp, cx, cy, data->rx - 2, data->ry - 2);
736
+            else
737
+              AreaEllipse(rp, cx, cy, data->rx, data->ry);
738
+            AreaEnd(rp);
739
+
740
+          }
741
+        }
742
+      }
743
+    }
744
+
745
+  }
746
+
747
+  
748
+  rp->TmpRas = NULL;
749
+  rp->AreaInfo = NULL;
750
+  FreeRaster(mem, w, h);
751
+  rp->Flags &= ~AREAOUTLINE;
752
+  //MUI_RemoveClipping(muiRenderInfo(obj), cliphandle);
753
+
754
+  return(0);
755
+}
756
+
757
+
758
+/****************************************************************************************
759
+  New / Dispose
760
+****************************************************************************************/
761
+
762
+ULONG Board_New(struct IClass* cl, Object* obj, struct opSet* msg)
763
+{
764
+  Board_Data tmp;
765
+
766
+  obj = (Object*)DoSuperNew(cl, obj, TAG_MORE, msg->ops_AttrList);
767
+  if (obj)
768
+  {
769
+    tmp.last_board = tmp.board;
770
+    tmp.pen1       = -1;
771
+    tmp.pen2       = -1;
772
+    tmp.pen3       = -1;
773
+    tmp.pen4       = -1;
774
+		tmp.ball[0]    = -1;
775
+		tmp.ball[1]    = -1;
776
+		tmp.ball[2]    = -1;
777
+    struct Board_Data* data = (Board_Data*)INST_DATA(cl, obj);
778
+    *data = tmp;
779
+  }
780
+  return (ULONG)obj;
781
+}
782
+
783
+
784
+/****************************************************************************************
785
+  Set
786
+****************************************************************************************/
787
+
788
+ULONG Board_Set(struct IClass* cl, Object* obj, struct opSet* msg)
789
+{
790
+  struct Board_Data* data = (Board_Data*)INST_DATA(cl, obj);
791
+  struct TagItem *tag;
792
+  tag = FindTagItem(MUIA_Board_Board, msg->ops_AttrList);
793
+  if (tag)
794
+  {
795
+    /*
796
+    **  Selektionen löschen
797
+    */
798
+
799
+    data->setsels     = FALSE;
800
+    data->update_mode = SELSDRAW;
801
+    MUI_Redraw(obj, MADF_DRAWUPDATE);
802
+
803
+    /*
804
+    **  Board zeichnen
805
+    */
806
+
807
+    data->last_board  = data->board;
808
+    data->board       = *(Board*)tag->ti_Data;
809
+    data->diff        = TRUE;
810
+    data->update_mode = ALLDRAW;
811
+		data->ball[0]    	= -1;
812
+		data->ball[1]    	= -1;
813
+		data->ball[2]    	= -1;
814
+    MUI_Redraw(obj, MADF_DRAWUPDATE);
815
+
816
+    /*
817
+    **  Selektionen setzen
818
+    */
819
+
820
+    data->setsels     = TRUE;
821
+    data->update_mode = SELSDRAW;
822
+    MUI_Redraw(obj, MADF_DRAWUPDATE);
823
+
824
+    /*
825
+    **  Richtigen Spieler setzen
826
+    */
827
+
828
+    Object* win = (Object*)xget(obj, MUIA_WindowObject);
829
+    if (data->board.me == Board::white)
830
+      setatt(win, MUIA_BoardWindow_ActivePlayer, 1);
831
+    else
832
+      setatt(win, MUIA_BoardWindow_ActivePlayer, 2);
833
+
834
+    return TRUE;
835
+  }
836
+  return DoSuperMethodA(cl, obj, (Msg)msg);
837
+}
838
+
839
+
840
+/****************************************************************************************
841
+  Dispatcher
842
+****************************************************************************************/
843
+
844
+SAVEDS ASM ULONG Board_Dispatcher(REG(a0) struct IClass* cl, 
845
+                                  REG(a2) Object*        obj, 
846
+                                  REG(a1) Msg            msg)
847
+{
848
+  switch(msg->MethodID)
849
+  {
850
+    case OM_NEW                 : return(Board_New         (cl, obj, (opSet*)msg));
851
+    case OM_SET                 : return(Board_Set         (cl, obj, (opSet*)msg));
852
+    case MUIM_Cleanup           : return(Board_Cleanup     (cl, obj, msg));
853
+    case MUIM_Setup             : return(Board_Setup       (cl, obj, msg));
854
+    case MUIM_HandleInput       : return(Board_HandleInput (cl, obj, (MUIP_HandleInput*)msg));
855
+    case MUIM_AskMinMax         : return(Board_AskMinMax   (cl, obj, (MUIP_AskMinMax*)msg));
856
+    case MUIM_Draw              : return(Board_Draw        (cl, obj, (MUIP_Draw*)msg));
857
+
858
+    case MUIM_Board_NewSettings : return(Board_NewSettings (cl, obj, msg));
859
+    case MUIM_Board_Undo        : return(Board_Undo        (cl, obj, msg));
860
+    case MUIM_Board_Load        : return(Board_Load        (cl, obj, msg));
861
+    case MUIM_Board_Save        : return(Board_Save        (cl, obj, msg));
862
+    case MUIM_Board_NewGame     : return(Board_NewGame     (cl, obj, msg));
863
+    case MUIM_Board_Winner			: return(Board_Winner			 (cl, obj, msg));
864
+    case MUIM_Board_ComputerMove: return(Board_ComputerMove(cl, obj, msg));
865
+  }
866
+  return(DoSuperMethodA(cl, obj, msg));
867
+}

+ 80
- 0
BoardClass.hpp View File

@@ -0,0 +1,80 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef INCLUDE_BOARDCLASS_HPP
20
+#define INCLUDE_BOARDCLASS_HPP
21
+/****************************************************************************************
22
+  BoardClass.hpp
23
+-----------------------------------------------------------------------------------------
24
+
25
+  CL_BoardClass (Area)
26
+
27
+-----------------------------------------------------------------------------------------
28
+  02.01.1997
29
+****************************************************************************************/
30
+
31
+#include "System.hpp"
32
+
33
+#include "MCC.hpp"
34
+#include "Board.hpp"
35
+#include "Tools.hpp"
36
+
37
+
38
+extern MUI_CustomClass *CL_Board;
39
+
40
+#define MUIA_Board_Board			   	   	(TAGBASE_KAI | 0x1201)	//  [.S.]
41
+#define MUIM_Board_NewSettings 				(TAGBASE_KAI | 0x1202)
42
+#define MUIM_Board_Undo		 	   				(TAGBASE_KAI | 0x1204)
43
+#define MUIM_Board_Winner			  	   	(TAGBASE_KAI | 0x1205)
44
+#define MUIM_Board_Load		 	   				(TAGBASE_KAI | 0x1206)
45
+#define MUIM_Board_Save		 	   				(TAGBASE_KAI | 0x1207)
46
+#define MUIM_Board_NewGame 	   				(TAGBASE_KAI | 0x1208)
47
+#define MUIM_Board_ComputerMove				(TAGBASE_KAI | 0x1209)
48
+
49
+
50
+struct Board_Data
51
+{
52
+  Board board, last_board;            //  Spielfeld und letztes
53
+  int   update_mode;                  //  
54
+  BOOL  setsels;                      //  Selections setzen od. löschen
55
+	int		ball[3];											//  Selektierte Bälle
56
+  BOOL  diff;                         //  Zeichnen im Vgl. zum last_board;
57
+
58
+  BOOL  newsettings;
59
+
60
+  void  GetCenterOf(int, int&, int&); //  Kreismittelpunkt von feld[nr] berechnen
61
+  int   GetNrOf    (int, int);        //  Feldindex der Mausposition berechnen
62
+	ULONG ActivePlayerNr();							//  Akt. Spieler als Nummer
63
+
64
+  /*
65
+  **  Graphik Context
66
+  */
67
+
68
+  LONG  pen1, pen2, pen3, pen4;
69
+  int   dx, dy, rx, ry, mdx, mdy, mrx, mry,
70
+        left, right, top, bottom, 
71
+        width, height;
72
+  WORD  areabuffer[1000];
73
+  BOOL  dirs;                         //  Mögl. Züge anzeigen
74
+};
75
+
76
+
77
+SAVEDS ASM ULONG Board_Dispatcher(REG(a0) struct IClass* cl, 
78
+                                  REG(a2) Object*        obj, 
79
+                                  REG(a1) Msg            msg);
80
+#endif

+ 263
- 0
BoardWindow.cpp View File

@@ -0,0 +1,263 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+/****************************************************************************************
20
+	BoardWindow.cpp
21
+-----------------------------------------------------------------------------------------
22
+
23
+  CL_BoardWindow (Window)
24
+
25
+-----------------------------------------------------------------------------------------
26
+	03.01.1997
27
+****************************************************************************************/
28
+
29
+#include <pragma/gadtools_lib.h>
30
+
31
+#include "BoardWindow.hpp"
32
+#include "BoardClass.hpp"
33
+#include "Abacus.hpp"
34
+#include "Tools.hpp"
35
+#include "Settings.hpp"
36
+#include "Images.hpp"
37
+
38
+#include "images/IMG_Start.c"
39
+#include "images/IMG_Undo.c"
40
+#include "images/IMG_Settings.c"
41
+#include "images/IMG_Quit.c"
42
+#include "images/IMG_Rules.c"
43
+
44
+MUI_CustomClass *CL_BoardWindow;
45
+
46
+
47
+/****************************************************************************************
48
+	Quit
49
+****************************************************************************************/
50
+
51
+ULONG BoardWindow_Quit(struct IClass* cl, Object* obj, Msg msg)
52
+{
53
+	struct BoardWindow_Data* data = (BoardWindow_Data*)INST_DATA(cl, obj);
54
+	Object* app = (Object*)xget(obj, MUIA_ApplicationObject);
55
+	if (MUI_RequestA(app, obj, 0, GetStr(MSG_QUIT_TITLE),
56
+              		 GetStr(MSG_QUIT_GADGETS), GetStr(MSG_QUIT_TEXT), NULL) == 1)
57
+		DoMethod(app, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
58
+	return 0;
59
+}
60
+
61
+
62
+/****************************************************************************************
63
+	NewSettings
64
+****************************************************************************************/
65
+
66
+ULONG BoardWindow_NewSettings(struct IClass* cl, Object* obj, Msg msg)
67
+{
68
+	struct BoardWindow_Data* data = (BoardWindow_Data*)INST_DATA(cl, obj);
69
+	Object*   app = (Object*	)xget(obj, MUIA_ApplicationObject);
70
+	Settings* s 	= (Settings*)xget(app, MUIA_Abacus_Settings);
71
+	DoMethod(data->Board, MUIM_Board_NewSettings);
72
+
73
+	setatt(data->TX_Player1, MUIA_Text_Contents	 , s->name1	 );
74
+	setatt(data->TX_Player2, MUIA_Text_Contents	 , s->name2	 );
75
+	setatt(data->PD_Player1, MUIA_Pendisplay_Spec, &s->color1);
76
+	setatt(data->PD_Player2, MUIA_Pendisplay_Spec, &s->color2);
77
+
78
+	return 0;
79
+}
80
+
81
+
82
+/****************************************************************************************
83
+	New
84
+****************************************************************************************/
85
+
86
+
87
+ULONG BoardWindow_New(struct IClass* cl, Object* obj, struct opSet* msg)
88
+{
89
+	Object *BT_New,   *BT_Quit, *BT_Settings, *strip, *BT_About, 
90
+				 *BT_Rules, *BT_Undo;
91
+	BoardWindow_Data tmp;
92
+
93
+	enum 
94
+	{
95
+		MEN_NEW = 1, MEN_ICONIFY, MEN_HELP, MEN_RULES, MEN_QUIT, MEN_COMPUTER,
96
+		MEN_SAVE, MEN_LOAD,	MEN_UNDO, MEN_SETABACUS, MEN_SETMUI, MEN_ABOUT,
97
+	};
98
+
99
+	struct NewMenu Menu[] =
100
+	{
101
+		{ NM_TITLE, GetStr(MSG_MENU_PROJECT) 		 		, 0, 0, 0, (APTR)0          	},
102
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_NEW) 		, 0, 0, 0, (APTR)MEN_NEW    	},
103
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_SAVE)		, 0, 0, 0, (APTR)MEN_SAVE  		},
104
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_LOAD)		, 0, 0, 0, (APTR)MEN_LOAD  		},
105
+		{ NM_ITEM,  NM_BARLABEL          		 				, 0, 0, 0, (APTR)0          	},
106
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_ABOUT)	, 0, 0, 0, (APTR)MEN_ABOUT		},
107
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_RULES)	, 0, 0, 0, (APTR)MEN_RULES		},
108
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_HELP) 	, 0, 0, 0, (APTR)MEN_HELP			},
109
+		{ NM_ITEM,  NM_BARLABEL          		 				, 0, 0, 0, (APTR)0          	},
110
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_ICONIFY), 0, 0, 0, (APTR)MEN_ICONIFY	},
111
+		{ NM_ITEM,  GetStr(MSG_MENU_PROJECT_QUIT)   , 0, 0, 0, (APTR)MEN_QUIT   	},
112
+
113
+		{ NM_TITLE, GetStr(MSG_MENU_MOVE) 		 			, 0, 0, 0, (APTR)0           	},
114
+		{ NM_ITEM,  GetStr(MSG_MENU_MOVE_UNDO)      , 0, 0, 0, (APTR)MEN_UNDO		 	},
115
+		{ NM_ITEM,  GetStr(MSG_MENU_MOVE_COMPUTER)  , 0, 0, 0, (APTR)MEN_COMPUTER	},
116
+
117
+		{ NM_TITLE, GetStr(MSG_MENU_SETTINGS) 			, 0, 0, 0, (APTR)0           	},
118
+		{ NM_ITEM,  GetStr(MSG_MENU_SETTINGS_ABACUS), 0, 0, 0, (APTR)MEN_SETABACUS},
119
+		{ NM_ITEM,  GetStr(MSG_MENU_SETTINGS_MUI)		, 0, 0, 0, (APTR)MEN_SETMUI 	},
120
+
121
+		{ NM_END ,  NULL                 		 		, 0, 0, 0, (APTR)0          	},
122
+	};
123
+
124
+	obj = (Object*)DoSuperNew(cl, obj,
125
+		MUIA_Window_Title		 , GetStr(MSG_BOARD_TITLE),
126
+		MUIA_Window_ID   		 , MAKE_ID('B','W','I','N'),
127
+		MUIA_HelpNode        , "MAINWINDOW",
128
+		MUIA_Window_Menustrip, 
129
+			strip = MUI_MakeObject(MUIO_MenustripNM, Menu, MUIO_MenustripNM_CommandKeyCheck),
130
+		WindowContents, HGroup,
131
+
132
+			Child, tmp.Board = (Object*)NewObject(CL_Board->mcc_Class , NULL,	TAG_DONE),
133
+
134
+      Child, VBar(),
135
+
136
+			Child, VGroup, MUIA_Weight, 1,
137
+
138
+				Child, BT_About = VGroup,
139
+					MUIA_InputMode  	, MUIV_InputMode_RelVerify,
140
+					MUIA_ShowSelState , FALSE,
141
+			      Child, MakeImage(IMG_Logo_body, IMG_LOGO_WIDTH, IMG_LOGO_HEIGHT, IMG_LOGO_DEPTH, 
142
+														 IMG_LOGO_COMPRESSION, IMG_LOGO_MASKING, IMG_Save_colors),
143
+			      Child, MakeImage(IMG_Abacus_body, IMG_ABACUS_WIDTH, IMG_ABACUS_HEIGHT, IMG_ABACUS_DEPTH,
144
+														 IMG_ABACUS_COMPRESSION, IMG_ABACUS_MASKING, IMG_Save_colors),
145
+					End,
146
+
147
+				Child, HVSpace,
148
+				Child, ColGroup(2),
149
+					Child, tmp.TX_Player1 = TextObject, End,
150
+					Child, tmp.PD_Player1 = MUI_NewObject(MUIC_Pendisplay, TAG_DONE),
151
+					Child, tmp.TX_Player2 = TextObject, End,
152
+					Child, tmp.PD_Player2 = MUI_NewObject(MUIC_Pendisplay, TAG_DONE),
153
+					End,
154
+				Child, HVSpace,
155
+
156
+
157
+				Child, BT_New 			= MakeImageTextButton(MSG_BOARD_NEW, MSG_BOARD_NEW_HELP,
158
+                       		                        MSG_BOARD_NEW_CHAR, IMG_Start_body),
159
+		    Child, BT_Undo  		= MakeImageTextButton(MSG_BOARD_UNDO, MSG_BOARD_UNDO_HELP,
160
+       			                                      MSG_BOARD_UNDO_CHAR, IMG_Undo_body),
161
+				Child, BT_Settings  = MakeImageTextButton(MSG_BOARD_SETTINGS, MSG_BOARD_SETTINGS_HELP, 
162
+                                                  MSG_BOARD_SETTINGS_CHAR, IMG_Settings_body),
163
+				Child, BT_Rules     = MakeImageTextButton(MSG_BOARD_RULES, MSG_BOARD_RULES_HELP, 
164
+                                                  MSG_BOARD_RULES_CHAR, IMG_Rules_body),
165
+				Child, BT_Quit      = MakeImageTextButton(MSG_BOARD_QUIT, MSG_BOARD_QUIT_HELP, 
166
+                                                  MSG_BOARD_QUIT_CHAR, IMG_Quit_body),
167
+
168
+				Child, HVSpace,
169
+
170
+
171
+				End,
172
+
173
+			End,
174
+		TAG_MORE, msg->ops_AttrList);
175
+
176
+	if (obj)
177
+	{
178
+		DoMethod(obj        , MUIM_Notify, MUIA_Window_CloseRequest, TRUE , obj                    	, 1, MUIM_BoardWindow_Quit);
179
+		DoMethod(BT_Quit    , MUIM_Notify, MUIA_Pressed            , FALSE, obj											, 1, MUIM_BoardWindow_Quit);
180
+		DoMethod(BT_New			, MUIM_Notify, MUIA_Pressed            , FALSE, tmp.Board								, 1, MUIM_Board_NewGame);
181
+		DoMethod(BT_Undo		, MUIM_Notify, MUIA_Pressed            , FALSE, tmp.Board  							, 1, MUIM_Board_Undo);
182
+		DoMethod(BT_Settings, MUIM_Notify, MUIA_Pressed            , FALSE, MUIV_Notify_Application	, 1, MUIM_Abacus_EditSettings);
183
+		DoMethod(BT_About  	, MUIM_Notify, MUIA_Pressed            , FALSE, MUIV_Notify_Application	, 1, MUIM_Abacus_About);
184
+		DoMethod(BT_Rules  	, MUIM_Notify, MUIA_Pressed            , FALSE, MUIV_Notify_Application	, 1, MUIM_Abacus_Rules);
185
+
186
+  	DoMethod(MenuObj(strip, MEN_HELP       ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, MUIV_Notify_Application, 5, MUIM_Application_ShowHelp, NULL, "Abacus.guide", "MAIN", 0);
187
+		DoMethod(MenuObj(strip, MEN_ICONIFY    ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, MUIV_Notify_Application, 3, MUIM_Set, MUIA_Application_Iconified, TRUE);
188
+		DoMethod(MenuObj(strip, MEN_QUIT    	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj										 , 1, MUIM_BoardWindow_Quit);
189
+		DoMethod(MenuObj(strip, MEN_NEW	   	 	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, tmp.Board							 , 1, MUIM_Board_NewGame);
190
+		DoMethod(MenuObj(strip, MEN_UNDO    	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, tmp.Board  						 , 1, MUIM_Board_Undo);
191
+		DoMethod(MenuObj(strip, MEN_COMPUTER 	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, tmp.Board							 , 1, MUIM_Board_ComputerMove);
192
+		DoMethod(MenuObj(strip, MEN_LOAD    	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, tmp.Board	 						 , 1, MUIM_Board_Load);
193
+		DoMethod(MenuObj(strip, MEN_SAVE    	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, tmp.Board	 						 , 1, MUIM_Board_Save);
194
+		DoMethod(MenuObj(strip, MEN_SETABACUS	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, MUIV_Notify_Application, 1, MUIM_Abacus_EditSettings);
195
+		DoMethod(MenuObj(strip, MEN_SETMUI  	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, MUIV_Notify_Application, 2, MUIM_Application_OpenConfigWindow, 0);
196
+		DoMethod(MenuObj(strip, MEN_ABOUT   	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, MUIV_Notify_Application, 1, MUIM_Abacus_About);
197
+		DoMethod(MenuObj(strip, MEN_RULES   	 ), MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, MUIV_Notify_Application, 1, MUIM_Abacus_Rules);
198
+
199
+		struct BoardWindow_Data* data = (BoardWindow_Data*)INST_DATA(cl, obj);
200
+		*data = tmp;
201
+
202
+		setatt(obj, MUIA_BoardWindow_ActivePlayer, 1);
203
+
204
+		return (ULONG)obj;
205
+	}
206
+	return 0;
207
+}
208
+
209
+
210
+/****************************************************************************************
211
+	Set
212
+****************************************************************************************/
213
+
214
+ULONG BoardWindow_Set(struct IClass* cl, Object* obj, struct opSet* msg)
215
+{
216
+	struct BoardWindow_Data* data = (BoardWindow_Data*)INST_DATA(cl, obj);
217
+	struct TagItem *tag;
218
+
219
+  tag = FindTagItem(MUIA_BoardWindow_ActivePlayer, msg->ops_AttrList);
220
+	if (tag)
221
+	{
222
+		ULONG player = tag->ti_Data;
223
+		Object* app = (Object*	)xget(obj, MUIA_ApplicationObject);
224
+		Settings* s = (Settings*)xget(app, MUIA_Abacus_Settings);
225
+		switch (player)
226
+		{
227
+			case 0: 
228
+				setatt(data->TX_Player1, MUIA_Background, MUII_BACKGROUND);
229
+				setatt(data->TX_Player2, MUIA_Background, MUII_BACKGROUND);
230
+				break;
231
+			case 1: 
232
+				setatt(data->TX_Player1, MUIA_Background, MUII_FILL);
233
+				setatt(data->TX_Player2, MUIA_Background, MUII_BACKGROUND);
234
+				break;
235
+			case 2:
236
+				setatt(data->TX_Player1, MUIA_Background, MUII_BACKGROUND);
237
+				setatt(data->TX_Player2, MUIA_Background, MUII_FILL);
238
+				break;
239
+		}
240
+		return TRUE;
241
+	}
242
+
243
+  return DoSuperMethodA(cl, obj, (Msg)msg);
244
+}
245
+
246
+
247
+/****************************************************************************************
248
+	Dispatcher
249
+****************************************************************************************/
250
+
251
+SAVEDS ASM ULONG BoardWindow_Dispatcher(REG(a0) struct IClass* cl, 
252
+																				REG(a2) Object* 			 obj, 
253
+																				REG(a1) Msg 					 msg)
254
+{
255
+	switch(msg->MethodID)
256
+	{
257
+		case OM_NEW                     	: return(BoardWindow_New         (cl, obj, (opSet*)msg));
258
+		case OM_SET      			            : return(BoardWindow_Set         (cl, obj, (opSet*)msg));
259
+		case MUIM_BoardWindow_Quit      	: return(BoardWindow_Quit        (cl, obj, msg));
260
+		case MUIM_BoardWindow_NewSettings	: return(BoardWindow_NewSettings (cl, obj, msg));
261
+	}
262
+	return DoSuperMethodA(cl, obj, msg);
263
+}

+ 51
- 0
BoardWindow.hpp View File

@@ -0,0 +1,51 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef INCLUDE_BOARDWIN_HPP
20
+#define INCLUDE_BOARDWIN_HPP
21
+/****************************************************************************************
22
+	BoardWindow.hpp
23
+-----------------------------------------------------------------------------------------
24
+
25
+
26
+
27
+-----------------------------------------------------------------------------------------
28
+	03.01.1997
29
+****************************************************************************************/
30
+
31
+#include "MCC.hpp"
32
+
33
+extern MUI_CustomClass *CL_BoardWindow;
34
+
35
+#define MUIA_BoardWindow_ActivePlayer	(TAGBASE_KAI | 0x1100) // [.S.]
36
+#define MUIM_BoardWindow_Quit   	   	(TAGBASE_KAI | 0x1101)
37
+#define MUIM_BoardWindow_NewSettings 	(TAGBASE_KAI | 0x1102)
38
+
39
+
40
+struct BoardWindow_Data
41
+{
42
+	Object *Board, 
43
+				 *TX_Player1, *TX_Player2, 
44
+				 *PD_Player1, *PD_Player2;
45
+};
46
+
47
+
48
+SAVEDS ASM ULONG BoardWindow_Dispatcher(REG(a0) struct IClass* cl, 
49
+																				REG(a2) Object* 			 obj, 
50
+																				REG(a1) Msg 					 msg);
51
+#endif

+ 96
- 0
Board_testmain.cpp View File

@@ -0,0 +1,96 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+/*******************************************************************************
20
+	Board_main.cpp
21
+--------------------------------------------------------------------------------
22
+
23
+
24
+--------------------------------------------------------------------------------
25
+	Last Change: 27.09.1996
26
+*******************************************************************************/
27
+
28
+#include <iostream.h>
29
+#include <string.h>
30
+
31
+/*******************************************************************************
32
+	BOOL
33
+*******************************************************************************/
34
+
35
+#ifndef TRUE
36
+	typedef int BOOL;
37
+	const TRUE  = 1;
38
+	const FALSE = 0;
39
+#endif
40
+
41
+
42
+#include "Board.cpp"
43
+
44
+
45
+/*******************************************************************************
46
+	main
47
+*******************************************************************************/
48
+
49
+int main()
50
+{
51
+	Board b;
52
+	b.Clear();
53
+
54
+	BOOL running = TRUE;
55
+	char player = b.white;
56
+	while (running)
57
+	{
58
+		b.Show();
59
+		cout << "\n\n          00 01 02 03 04                     \n"
60
+				 << "         05 06 07 08 09 10                   \n"
61
+				 << "       11 12 13 14 15 16 17           0 1   \n"
62
+				 << "      18 19 20 21 22 23 24 25        5 X 2  \n"
63
+				 << "     26 27 28 29 30 31 32 33 34       4 3   \n"
64
+				 << "      35 36 37 38 39 40 41 42               \n"
65
+				 << "       43 44 45 46 47 48 49                 \n"
66
+				 << "        50 51 52 53 54 55                   \n"
67
+				 << "         56 57 58 59 60                     \n\n"
68
+				 << "Player " << player << " : ball#";
69
+		int ball1, ball2, ball3, dir;
70
+		cin >> ball1;
71
+		cout << "           direction#";
72
+		cin >> dir;
73
+		cout << "           2nd ball#";
74
+		cin >> ball2;
75
+		if (ball2 != -1)
76
+		{
77
+			cout << "           3rd ball#";
78
+			cin >> ball3;
79
+		}
80
+		cout << "\n";
81
+		int res = b.Test(ball1, dir, ball2, ball3);
82
+		if (res >= 0)
83
+		{
84
+			b.Move(ball1, dir, ball2, ball3);
85
+			cout << "Kugeldifferenz: " << res;
86
+			if (player == b.white) player = b.black; else player = b.white;
87
+		}
88
+		else
89
+		{
90
+			cout << "Fehlercode: " << res;
91
+		}
92
+		cout << "\n\n";
93
+	};
94
+
95
+	return 0;
96
+};

+ 53
- 0
Images.hpp View File

@@ -0,0 +1,53 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef INCLUDE_IMAGES_HPP
20
+#define INCLUDE_IMAGES_HPP
21
+
22
+#define IMG_SAVE_WIDTH        17
23
+#define IMG_SAVE_HEIGHT       16
24
+#define IMG_SAVE_DEPTH         3
25
+#define IMG_SAVE_COMPRESSION   0
26
+#define IMG_SAVE_MASKING       2
27
+
28
+extern const ULONG IMG_Save_colors[24];
29
+extern const UBYTE IMG_Save_body[192];
30
+
31
+
32
+
33
+#define IMG_LOGO_WIDTH        58
34
+#define IMG_LOGO_HEIGHT       42
35
+#define IMG_LOGO_DEPTH         3
36
+#define IMG_LOGO_COMPRESSION   1
37
+#define IMG_LOGO_MASKING       2
38
+
39
+extern const UBYTE IMG_Logo_body[801];
40
+
41
+
42
+
43
+#define IMG_ABACUS_WIDTH        77
44
+#define IMG_ABACUS_HEIGHT       18
45
+#define IMG_ABACUS_DEPTH         3
46
+#define IMG_ABACUS_COMPRESSION   1
47
+#define IMG_ABACUS_MASKING       2
48
+
49
+extern const ULONG IMG_Abacus_colors[24];
50
+extern const UBYTE IMG_Abacus_body[362];
51
+
52
+
53
+#endif

+ 371
- 0
LocStrings.h View File

@@ -0,0 +1,371 @@
1
+/*
2
+* This file is part of Abacus.
3
+* Copyright (C) 1997 Kai Nickel
4
+* 
5
+* Abacus is free software: you can redistribute it and/or modify
6
+* it under the terms of the GNU General Public License as published by
7
+* the Free Software Foundation, either version 3 of the License, or
8
+* (at your option) any later version.
9
+*
10
+* Abacus is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with Abacus.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+#ifndef LOCSTRINGS_H
20
+#define LOCSTRINGS_H
21
+
22
+
23
+/****************************************************************************/
24
+
25
+
26
+/* This file was created automatically by CatComp.
27
+ * Do NOT edit by hand!
28
+ */
29
+
30
+
31
+#ifndef EXEC_TYPES_H
32
+#include <exec/types.h>
33
+#endif
34
+
35
+#ifdef CATCOMP_ARRAY
36
+#undef CATCOMP_NUMBERS
37
+#undef CATCOMP_STRINGS
38
+#define CATCOMP_NUMBERS
39
+#define CATCOMP_STRINGS
40
+#endif
41
+
42
+#ifdef CATCOMP_BLOCK
43
+#undef CATCOMP_STRINGS
44
+#define CATCOMP_STRINGS
45
+#endif
46
+
47
+
48
+/****************************************************************************/
49
+
50
+
51
+#ifdef CATCOMP_NUMBERS
52
+
53
+#define MSG_APPDESCRIPTION 100
54
+#define MSG_ERRREQTITLE 101
55
+#define MSG_ERRREQGADGET 102
56
+#define MSG_ERRREQGADGETSYS 103
57
+#define MSG_NOCLASSES 104
58
+#define MSG_NOAPP 105
59
+#define MSG_ABOUT_TITLE 200
60
+#define MSG_ABOUT_VERSION 201
61
+#define MSG_ABOUT_TEXT 202
62
+#define MSG_ABOUT_OK 203
63
+#define MSG_ABOUT_OK_HELP 204
64
+#define MSG_ABOUT_MUI 205
65
+#define MSG_ABOUT_MUI_HELP 206
66
+#define MSG_BOARD_TITLE 300
67
+#define MSG_BOARD_QUIT 301
68
+#define MSG_BOARD_QUIT_HELP 302
69
+#define MSG_BOARD_QUIT_CHAR 303
70 </