This repository has been archived by the owner on Nov 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstarsign.c
170 lines (135 loc) · 3.45 KB
/
starsign.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "jaakkos.h"
/*
This is the starsign selector hook callback.
Ask the user for a month and randomize the day in that month.
Alternatively, completely randomize the day ('?').
*/
void starsign_select() {
int month;
uint32_t BIRTHSIGN_ADDR = 0;
uint32_t JUMP_TO = 0;
// Get ADOM version number
char *version = getenv("ADOM_VERSION");
int adom_version = 0;
if (version != NULL)
{
sscanf(version, "%i", &adom_version);
}
/*
BIRTHSIGN_ADDR is the place in memory where the day of birth is stored.
Its value in memory will be the in-game displayed value minus one.
JUMP_TO is where to resume execution in the ADOM executable.
See http://www.adom.de/forums/showthread.php/1134-Choosing-star-sign?p=72882#post72882
for information on finding these offsets.
*/
switch (adom_version) {
case 111:
BIRTHSIGN_ADDR = 0x82b61f0;
JUMP_TO = 0x813ee80;
break;
case 100:
BIRTHSIGN_ADDR = 0x82a66e4;
JUMP_TO = 0x0813ace0;
break;
case 1203:
BIRTHSIGN_ADDR = 0x8283d40;
JUMP_TO = 0x081386d0;
break;
case 1204:
BIRTHSIGN_ADDR = 0x8285d40;
JUMP_TO = 0x08139fb0;
break;
case 1205:
BIRTHSIGN_ADDR = 0x8286948;
JUMP_TO = 0x0813a860;
break;
case 1206:
BIRTHSIGN_ADDR = 0x828acbc;
JUMP_TO = 0x0813bf70;
break;
case 1207:
BIRTHSIGN_ADDR = 0x82921fc;
JUMP_TO = 0x81405a0;
break;
case 1208:
BIRTHSIGN_ADDR = 0x8295a60;
JUMP_TO = 0x81418f0;
break;
case 1209:
BIRTHSIGN_ADDR = 0x82a7d40;
JUMP_TO = 0x81458a0;
break;
case 12010:
BIRTHSIGN_ADDR = 0x82a7e40;
JUMP_TO = 0x8145780;
break;
case 12011:
BIRTHSIGN_ADDR = 0x82a6d20;
JUMP_TO = 0x8144910;
break;
case 12013:
BIRTHSIGN_ADDR = 0x82b8c90;
JUMP_TO = 0x8144690;
break;
case 12014:
BIRTHSIGN_ADDR = 0x82bbf34;
JUMP_TO = 0x8145870;
break;
case 12016:
BIRTHSIGN_ADDR = 0x82be774;
JUMP_TO = 0x8149090;
break;
case 12017:
BIRTHSIGN_ADDR = 0x82e15b8;
JUMP_TO = 0x814a7c0;
break;
case 12018:
BIRTHSIGN_ADDR = 0x82e1c58;
JUMP_TO = 0x814a040;
break;
case 12019:
BIRTHSIGN_ADDR = 0x82e27fc;
JUMP_TO = 0x814a3b0;
break;
case 12020:
BIRTHSIGN_ADDR = 0x82E277C;
JUMP_TO = 0x814a3b0;
break;
default:
break;
}
if ((BIRTHSIGN_ADDR == 0) || (JUMP_TO == 0)) {
printf("Don't know where to put the birth date or jump to. Unknown ADOM version %i ?\n", adom_version);
return;
}
do {
printf("\033[2J\033[1;1H");
printf("Select the month of your birth:\r\n"
"\r\n"
" ? - random\r\n"
"\r\n"
" A - Raven\r\n"
" B - Book\r\n"
" C - Wand\r\n"
" D - Unicorn\r\n"
" E - Salamander\r\n"
" F - Dragon\r\n"
" G - Sword\r\n"
" H - Falcon\r\n"
" I - Cup\r\n"
" J - Candle\r\n"
" K - Wolf\r\n"
" L - Tree\r\n"
"\r\n"
"> ");
fflush(stdout);
month = toupper(fgetc(stdin));
} while(month != '?' && (month < 'A' || month > 'L'));
printf("\033[2J");
fflush(stdout);
month = month == '?' ? 0 : month-'A'+1;
if(!month) month = rand() % 12;
else month--;
*((uint16_t*)BIRTHSIGN_ADDR) = (unsigned int)(30*month + (rand()%30));
((void(*)())JUMP_TO)();
}