ReC98/th02/res_init.cpp

71 lines
1.7 KiB
C++
Raw Normal View History

#ifndef ERROR_NOT_RESIDENT
# define ERROR_NOT_RESIDENT "<22><EFBFBD><ED82BD><EFBFBD>A<EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>悧"
#endif
#ifndef REMOVED
# define REMOVED "<22><><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>A<EFBFBD>܂<EFBFBD><DC82><EFBFBD><EF82A6><EFBFBD><EFBFBD><E782A2><EFBFBD><EFBFBD>"
#endif
#ifndef INITIALIZED
# define INITIALIZED "<22><><EFBFBD><EFBFBD><EFBFBD>ł́A<CD81><41><EFBFBD><EFBFBD><EB82B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E882A2><EFBFBD>܂<EFBFBD>"
#endif
#define arg_is(arg, capital, small) \
((arg[0] == '-' ) || (arg[0] == '/' )) && \
((arg[1] == capital) || (arg[1] == small))
int main(int argc, const unsigned char **argv)
{
resident_t __seg *sgm;
#if (GAME == 5)
int i;
resident_t far *resident;
uint8_t far *resident_bytes;
const char *res_id = RES_ID;
#else
const char *res_id = RES_ID;
int i;
uint8_t far *resident_bytes;
#endif
sgm = ResData<resident_t>::exist_with_id_from_pointer(res_id);
dos_puts2("\n\n" LOGO "\n");
graph_clear();
#ifdef RES_INIT_TOP
RES_INIT_TOP;
#endif
if(argc == 2) {
if(arg_is(argv[1], 'R', 'r')) {
if(!sgm) {
dos_puts2(ERROR_NOT_RESIDENT "\n\n");
return 1;
}
dos_free(sgm);
dos_puts2(REMOVED "\n\n");
return 0;
} else if(arg_is(argv[1], 'D', 'd')) {
debug = 1;
} else {
dos_puts2("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȃI<EFBFBD>v<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n\n");
sgm = sgm; /* optimization barrier #1 */
return 1;
}
}
if(sgm) {
dos_puts2("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>łɂ<EFBFBD><EFBFBD>܂<EFBFBD><EFBFBD>\n\n");
argv = argv; /* optimization barrier #2 */
return 1;
}
sgm = ResData<resident_t>::create_with_id_from_pointer(res_id);
if(!sgm) {
dos_puts2("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̋<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>́I\n\n");
optimization_barrier_3();
return 1;
}
resident_bytes = reinterpret_cast<uint8_t far *>(sgm);
dos_puts2(INITIALIZED "\n\n");
for(i = (ResData<resident_t>::id_len() + 1); i < sizeof(resident_t); i++) {
resident_bytes[i] = 0;
}
RES_INIT_BOTTOM;
return 0;
}