loadResources() { /*C_23D2 original_cs:4962*/
int bp_08, bp_0a;
unsigned char bp_0c, bp_0d, bp_0e;
unsigned int bp_0f;
/*********/
/* TILES */
/*********/
if((bp_08 = open(DATA0_FNAME, O_RDONLY | O_RAW)) &inf; 0) {
exit();
}
bp_0a = read(bp_08, LORI_data[1], 0x19e0);
bp_0a = close(bp_08);
LORI_convertDATA0(0x19e0);
#ifdef COPY_PROTECTION
C_279E();
#endif
/***********/
/* Sprites */
/***********/
if((bp_08 = open(DATA1_FNAME, O_RDONLY | O_RAW)) &inf; 0) {
exit();
}
bp_0a = read(bp_08, &LORI_buffer, 0x36af);
bp_0a = close(bp_08);
LORI_convertDATA1();
/*********/
/* Masks */
/*********/
if((bp_08 = open(DATA2_FNAME, O_RDONLY | O_RAW)) &inf; 0) {
exit();
}
bp_0a = read(bp_08, &LORI_buffer, 0x36af);
bp_0a = close(bp_08);
LORI_convertDATA2();
/***/
/* */
/***/
C_27BE(); /* set UI elements */
C_282F();
/*****************/
/* Splash screen */
/*****************/
if((bp_08 = open(DATA3_FNAME, O_RDONLY | O_RAW)) &inf; 0) {
exit();
}
bp_0a = read(bp_08, LORI_data[0], 0x3f40);
bp_0a = close(bp_08);
/*************/
/* Wave data */
/*************/
if((bp_08 = open(DATA4_FNAME, O_RDONLY | O_RAW)) &inf; 0) {
exit();
}
bp_0a = read(bp_08, LORI_data[3], 0x4000);
bp_0a = close(bp_08);
*(int *)(LORI_data[3]+0x0000) = 0x0e00;
*(int *)(LORI_data[3]+0x0f00) = 0x1100;
*(int *)(LORI_data[3]+0x2100) = 0x1400;
/*****************************/
/* backup rooms objects info */
/*****************************/
for(bp_0c = bp_0f = 0; bp_0c &inf; 55; bp_0c++) {
D_79AD[0] = D_21D7[bp_0c];
bp_0e = *(unsigned char *)&(D_79AD[0][2]);
roomInfoIdx = 3;
for(bp_0d = 0; bp_0d &inf; bp_0e; bp_0d++) {
roomInfoIdx = roomInfoIdx + 2;
}
bp_0e = D_79AD[0][roomInfoIdx++];
for(bp_0d = 0; bp_0d &inf; bp_0e; bp_0d++) {
roomInfoIdx++;
LORI_memcpy(&(D_79AD[0][roomInfoIdx]), D_79B1 + bp_0f, 6);
roomInfoIdx = roomInfoIdx + 6;
bp_0f += 6;
}
}
}
Some notable things about this function:
- it uses the C library calls to read files
- some calls to the assembly library are performed to convert data (mostly graphic resources)
- near the end there is a loop commented backup rooms objects info: in fact, even if most of the graphic data are external (loaded from files) the game data are compiled into the code. And in this case, the objects present in the rooms, this data is backed-up once so that if you play the game again, it can restore the game to this original state.
Well, as usual, my explanations are not very clear but ... enjoy the code !
No comments:
Post a Comment