forked from chennin/adom-sage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarsign.cc
130 lines (117 loc) · 2.97 KB
/
starsign.cc
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
#include "jaakkos.h"
void starsign_select() {
int month;
uint32_t BIRTHSIGN_ADDR = 0;
uint32_t JUMP_TO = 0;
// Get ADOM version number, set by Sage
int adom_version = get_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.
*/
if (adom_version == 111) {
BIRTHSIGN_ADDR = 0x82b61f0;
JUMP_TO = 0x813ee80;
}
else if (adom_version == 100) {
BIRTHSIGN_ADDR = 0x82a66e4;
JUMP_TO = 0x0813ace0;
}
else if (adom_version == 1203) {
BIRTHSIGN_ADDR = 0x8283d40;
JUMP_TO = 0x081386d0;
}
else if (adom_version == 1204) {
BIRTHSIGN_ADDR = 0x8285d40;
JUMP_TO = 0x8139fb0;
}
else if (adom_version == 1205) {
BIRTHSIGN_ADDR = 0x8286948;
JUMP_TO = 0x813a860;
}
else if (adom_version == 1206) {
BIRTHSIGN_ADDR = 0x828acbc;
JUMP_TO = 0x813bf70;
}
else if (adom_version == 1207) {
BIRTHSIGN_ADDR = 0x82921fc;
JUMP_TO = 0x81405a0;
}
else if (adom_version == 1208) {
BIRTHSIGN_ADDR = 0x8295a60;
JUMP_TO = 0x81418f0;
}
else if (adom_version == 1209) {
BIRTHSIGN_ADDR = 0x82a7d40;
JUMP_TO = 0x81458a0;
}
else if (adom_version == 12010) {
BIRTHSIGN_ADDR = 0x82a7e40;
JUMP_TO = 0x8145780;
}
else if (adom_version == 12011) {
BIRTHSIGN_ADDR = 0x82a6d20;
JUMP_TO = 0x8144910;
}
else if (adom_version == 12012) {
BIRTHSIGN_ADDR = 0x82b8c30;
JUMP_TO = 0x8144620;
}
else if (adom_version == 12013) {
BIRTHSIGN_ADDR = 0x82b8c90;
JUMP_TO = 0x8144690;
}
else if (adom_version == 12014) {
BIRTHSIGN_ADDR = 0x82bbf34;
JUMP_TO = 0x8145870;
}
else if (adom_version == 12016) {
BIRTHSIGN_ADDR = 0x82be774;
JUMP_TO = 0x8149090;
}
else if (adom_version == 12017) {
BIRTHSIGN_ADDR = 0x82e15b8;
JUMP_TO = 0x814a7c0;
}
else if (adom_version == 12018) {
BIRTHSIGN_ADDR = 0x82e1c58;
JUMP_TO = 0x814a040;
}
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)();
}