Back to the source: ReDMCSB

Use this forum to discuss dungeon editors and other tools, like DMute (by George Gilbert, also working for RTC dungeons), DM Builder (by Sphenx), and ADGE by `rain. Includes DM editing tips and tricks.
Forum rules
Please read the Forum rules and policies before posting.
zosodk69
Novice
Posts: 13
Joined: Wed May 11, 2005 8:50 pm
Location: Michigan, US

Re: Back to the source: ReDMCSB

Post by zosodk69 »

I certainly wasn't disputing the platform used to compile the binaries. :wink: You've spent so much time with this code that these types of revelations probably don't carry the same weight. For me, the fact that DM/CSB version 3 was developed and compiled in Think C on the Apple platform is a piece of Dungeon Master history that I'm just learning.

Sometimes I have to remind myself that, especially in those days, development was often done outside of the target platform. Doom is the most predominate example I can think of but why wouldn't Dungeon Master be as well? I wouldn't be surprised if this was much more common. The Amiga (and the ST) is a pretty great platform to develop for, but a pretty lousy platform to develop on.
-=[dave]=-
zosodk69
Novice
Posts: 13
Joined: Wed May 11, 2005 8:50 pm
Location: Michigan, US

Re: Back to the source: ReDMCSB

Post by zosodk69 »

ChristopheF, is it possible to run the build process with the NOCOPYPROTECTION set? Your compile process works really slick so I thought I'd ask if there is an intended way to build like this (before I start cracking open batch files).
-=[dave]=-
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

I have only tested compilation with the NOCOPYPROTECTION flag set for Atari ST and Amiga executables. Check files MKSS.BAT and MKAA.BAT where you'll find commented lines to build executables without the copy protection.
For other versions you'll have to perform your own experiments.
zosodk69
Novice
Posts: 13
Joined: Wed May 11, 2005 8:50 pm
Location: Michigan, US

Re: Back to the source: ReDMCSB

Post by zosodk69 »

Hi ChristopheF,

Have you continued your work on ReDMCSB? It's been a about 3 years since your last WIP release. Would you be willing to post any progress you've made?
-=[dave]=-
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

I can't say I did nothing since then, but not enough to justify a new release yet. Are you expecting some specific features/progress ?
zosodk69
Novice
Posts: 13
Joined: Wed May 11, 2005 8:50 pm
Location: Michigan, US

Re: Back to the source: ReDMCSB

Post by zosodk69 »

Nothing needed, just interested. I've spent quite a bit of time with this code and I noticed that it's been a couple years since your last release. I personally find the changes between the 2.x vs 3.x code-bases fascinating. Maybe support NOCOPYPROTECTION in version 3?

Seriously though, nothing needed.
-=[dave]=-
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Comparing the code between versions was one of my goals, happy to see someone else also interested :)
The switch from the 1.x/2.x (Atari ST/Amiga/Apple IIGS) to 3.x (all other versions) codebase corresponds to the time FTL Games moved all their development efforts to the Macintosh platform. Most notably, they implemented and used their own ".FTL" executable file format for all 68000 CPU based platforms, and generally worked on making it easier to reuse their code for other projects, and port the game engine to other platforms, starting with the Japanese computers.

Fully implementing NOCOPYPROTECTION for all versions is definitely in my todolist (along with lots of code cleanup).
I think the job is already 99% done in the source code itself as sections about the copy protection are already isolated with NOCOPYPROTECTION directives. However I never tried compiling these versions without the copy protection so this would require lots of testing, and automating the whole process would also probably take some time. I need to find both time and motivation. Don't hold your breath!

Anyway, based on the really low amount of feedback I got about ReDMCSB over the years, you're probably one of the very few people who had a peek in the source code of the game. Feel free if you have any questions!
User avatar
megar
Journeyman
Posts: 65
Joined: Thu Dec 29, 2005 10:15 am
Location: France

Re: Back to the source: ReDMCSB

Post by megar »

Awesome work ! I would never have dreamed of it to turn true ! Thank you for all that incredible work !
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Thanks ;)
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

Hi Christophe,
i had a look at the Encyclopedia for : LAY1 items (Dungeon Master Engine 3.x). And i cant find anything about the scaling of the wall ornates for D2, D3. Isnt this in the LAY1? You know where i can find this information? Since Engine 3.x the FOV has been changed. The coordinates in excel works real good.
The coords given in ADGE dont work on the gfx of 3.x.

Cheers
C.
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

You can use this script to extract LAY1 data to text: http://dmweb.free.fr/?q=node/707
You'll find all LAY1 management code in the source file named COORD.C (in http://dmweb.free.fr/Stuff/ReDMCSB_WIP20210206.7z)
The last function in COORD.C loads LAY1 item #696 from graphics.dat, in versions where it is present. Note that in Japanese versions of DM (FM-Towns, PC-9801, X68000) there is no LAY1 item in graphics.dat; the corresponding data is compiled as part of the executable and is declared in COORD.C.
I have not labeled each and every LAY1 entry in the source code (which are identified as "ZONE" in the source code), however in DEFS.H you may find "ZONE" indices like C1004_ZONE_WALL_ORNAMENT (and many others grouped before/after this particular one).
Search for C1004_ZONE_WALL_ORNAMENT in DUNVIEW.C to find the code used to draw wall ornaments.
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

Thanks. Yes it seems its hardcoded. i went through the code upto: F0791_DUNGEONVIEW_DrawBitmapXX() where ZoneIndex is a parameter.
but then i ran into lots of strange var names ;-)

From a comment in another file, i found something interessting, what i will try out:
/* Versions 3.x: 64 bitmaps: 4 bitmaps (two bitmaps per wall ornament, scaled 14/32 for D3 and 21/32 for D2) for each of the 16 possible wall ornaments per map (including inscription) in G0101_as_CurrentMapWallOrnamentsInfo. */

seems a fixed value now. Thanks again :)
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

Hey @ChristopheF,

in Dunview:
AL0089_i_ZoneIndex = C1004_ZONE_WALL_ORNAMENT + (G0101_as_CurrentMapWallOrnamentsInfo[AP0116_i_WallOrnamentIndex].CoordinateSet * C15_UNKNOWN) + P0117_i_ViewWallIndex;

the C15_UNKNOWN = C15_NUMBER_OF_COORDS_FOR_ONE_SET

when its set 1 it takes the 1 multiplies it with the C15 to get to the correct coords in the Zonefield. Set0/Set1/Set2/... are all 15 values away.
Coordinates to display wall decorations - Set 0 :
FgD1
FdD1
CgD3
CdD3
FgD3
FD3
FdD3
CgD2
CdD2
FgD2
FD2
FdD2
CgD1
CdD1
FD1
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Thanks, I've updated my code. This also applies to C13_UNKNOWN which is the equivalent for some Japanese versions.
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

No problem, as you see im deep into layer1 8) Just converting it now to a dict structure/file..:
{'General':
{'start': 1, 'end': 17, 'entity': [
{'self': 1, 'align': 9, 'parent': 0, 'x': 320, 'y': 200},
{'self': 2, 'align': 1, 'parent': 1, 'x': 0, 'y': 0},....
'Screens':
{'start': 400, 'end': 438, 'entity': [
{'self': 400, 'align': 9, 'parent': 2, 'x': 320, 'y': 33},

Oh and i found something.. but this flag is set and cleared everywhere, but no code checks it:
Zeile 12: BOOLEAN G0435_B_CommandQueueLocked = C1_TRUE;
Zeile 398: G0435_B_CommandQueueLocked = C1_TRUE;
Zeile 436: G0435_B_CommandQueueLocked = C0_FALSE;
Zeile 553: G0435_B_CommandQueueLocked = C0_FALSE;
Zeile 591: G0435_B_CommandQueueLocked = C1_TRUE;
Zeile 643: G0435_B_CommandQueueLocked = C0_FALSE;
Zeile 775: G0435_B_CommandQueueLocked = C1_TRUE;
Zeile 790: G0435_B_CommandQueueLocked = C0_FALSE;
Zeile 803: G0435_B_CommandQueueLocked = C0_FALSE;

Not sure if its relevant, i can see it is done in MEDIA607_X30J_X31J, MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E (Atari ST Version?) but Amiga/PC they just set the flag/clear the flag..
Maybe a comment in line 12 of command.c ?
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

Oh and while we are at it:
#define C2500_ZONE_ITEMS_ON_FLOOR =2500
#define C2548_ZONE_ITEMS_IN_ALCOVES =2548
#define C2900_ZONE_ITEMS_ON_FLOOR_SET_2 =2900
#define C3000_ZONE_DISPLAY_LIGHTNING_BOLTS =3000
#define C3007_ZONE_DISPLAY_CLOUDS =3007
#define C3014_ZONE_DISPLAY_SPECIAL_CLOUDS =3014
#define C3031_ZONE_DISPLAY_SPECIAL_CLOUDS_2 =3031
#define C3200_ZONE_CREATURE_GRAPHICS =3200

this is strange i need to look further into it:
#define C3029_ZONE_ =3029
its in the end of special clouds.. i thing its abug.. on : MEDIA508_F20E_F20J_X30J_P20JA_P20JB
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

Here another cleanup for function F0635_ i call it now: CalcAlignment
i changed the var names to proper reflect their values.

Code: Select all

int16_t* F0635_CalcAlignment(
unsigned char*    P2129_puc_Bitmap  ,
REGISTER BOX_WORD* P2130_pi_XYZ      ,
int16_t           P2131_i_ZoneIndex ,
int16_t*          P2132_pi_X        ,
int16_t*          P2133_pi_Y        )
{
        REGISTER LAYOUT_RECORD* parent_layoutrecord;
        REGISTER LAYOUT_RECORD* current_layoutrecord;
        REGISTER int16_t current_x;
        REGISTER int16_t current_y;
        REGISTER int16_t parent_x;
        REGISTER int16_t parent_y;
        REGISTER int16_t parent_record_type;
        BOOLEAN adjust_coords;
        int16_t current_type;
        BOX_WORD tmp_box;


        if (P2131_i_ZoneIndex == CM1_UNKNOWN) {
                return NULL;
        }
        if ((current_x = M007_GET(P2131_i_ZoneIndex, MASK0x8000_SHIFT_OBJECTS_AND_CREATURES)) != 0) {
                M009_CLEAR(P2131_i_ZoneIndex, MASK0x8000_SHIFT_OBJECTS_AND_CREATURES);
        }
        if ((parent_layoutrecord = F0634_GetLayoutRecord(G2174_ps_LayoutData, P2131_i_ZoneIndex)) == NULL) {
                return NULL;
        }
                F0625_GetZoneInitializedFromDimensions(tmp_box, 20000, 20000);
                if ((parent_record_type = parent_layoutrecord->RecordType) <= 8) {
                        parent_x = parent_layoutrecord->Data1;
                        parent_y = parent_layoutrecord->Data2;
                } else {
                        if (parent_record_type == 9) {
                                return NULL;
                        }
                        parent_record_type -= 10;
                        parent_x = 0;
                        parent_y = 0;
                }
                if (current_x) {
                        parent_x += *P2132_pi_X;
                        parent_y += *P2133_pi_Y;
                        *P2132_pi_X = 0;
                        *P2133_pi_Y = 0;
                }
                adjust_coords = C0_FALSE;
                while (parent_layoutrecord->ParentRecordIndex) {
                        if ((parent_layoutrecord->RecordType >= 10) && (parent_layoutrecord->RecordType <= 18)) {
                                if ((current_layoutrecord = F0634_GetLayoutRecord(G2174_ps_LayoutData, parent_layoutrecord->ParentRecordIndex)) == NULL) {
                                        break;
                                }
                                current_x = current_layoutrecord->Data1;
                                current_y = current_layoutrecord->Data2;
                                current_type = current_layoutrecord->RecordType;
                                if ((current_layoutrecord = F0634_GetLayoutRecord(G2174_ps_LayoutData, current_layoutrecord->ParentRecordIndex)) == NULL) {
                                        break;
                                }
                                switch (current_type) {
                                        default:
                                                return NULL;
                                        case 0:
                                                current_y -= ((current_layoutrecord->Data2 + 1) >> 1);
                                        case 5:
                                                current_x -= ((current_layoutrecord->Data1 + 1) >> 1);
                                                break;
                                        case 3:
                                                current_y -= current_layoutrecord->Data2 - 1;
                                        case 2:
                                                current_x -= current_layoutrecord->Data1 - 1;
                                                break;
                                        case 6:
                                                current_x -= current_layoutrecord->Data1 - 1;
                                        case 8:
                                                current_y -= (current_layoutrecord->Data2 + 1) >> 1;
                                                break;
                                        case 7:
                                                current_x -= (current_layoutrecord->Data1 + 1) >> 1;
                                        case 4:
                                                current_y -= current_layoutrecord->Data2 - 1;
                                        case 1:
                                                break;
                                }
                                if ((M704_ZONE_LEFT(tmp_box) += current_x) < current_x) {
                                        M704_ZONE_LEFT(tmp_box) = current_x;
                                }
                                if (M705_ZONE_RIGHT(tmp_box) >= current_layoutrecord->Data1 + current_x) {
                                        M708_ZONE_WIDTH(tmp_box) = current_layoutrecord->Data1 - M704_ZONE_LEFT(tmp_box) + current_x;
                                }
                                if ((M706_ZONE_TOP(tmp_box) += current_y) < current_y) {
                                        M706_ZONE_TOP(tmp_box) = current_y;
                                }
                                if (M707_ZONE_BOTTOM(tmp_box) >= current_layoutrecord->Data2 + current_y) {
                                        M709_ZONE_HEIGHT(tmp_box) = current_layoutrecord->Data2 - M706_ZONE_TOP(tmp_box) + current_y;
                                }
                                switch (parent_layoutrecord->RecordType) {
                                        default:
                                                return NULL;
                                        case 10:
                                                current_y += (current_layoutrecord->Data2 + 1) >> 1;
                                        case 15:
                                                current_x += (current_layoutrecord->Data1 + 1) >> 1;
                                                break;
                                        case 13:
                                                current_y += current_layoutrecord->Data2 - 1;
                                        case 12:
                                                current_x += current_layoutrecord->Data1 - 1;
                                                break;
                                        case 16:
                                                current_x += current_layoutrecord->Data1 - 1;
                                        case 18:
                                                current_y += (current_layoutrecord->Data2 + 1) >> 1;
                                                break;
                                        case 17:
                                                current_x += (current_layoutrecord->Data1 + 1) >> 1;
                                        case 14:
                                                current_y += current_layoutrecord->Data2 - 1;
                                        case 11:
                                                break;
                                }
                                parent_x += current_x + parent_layoutrecord->Data1;
                                parent_y += current_y + parent_layoutrecord->Data2;
                                parent_layoutrecord = current_layoutrecord;
                        } else {
                                if ((current_layoutrecord = F0634_GetLayoutRecord(G2174_ps_LayoutData, parent_layoutrecord->ParentRecordIndex)) == NULL) {
                                        break;
                                }
                                current_x = current_layoutrecord->Data1;
                                current_y = current_layoutrecord->Data2;
                                if (current_layoutrecord->RecordType == 1) {
                                        parent_x += current_x;
                                        parent_y += current_y;
                                        M704_ZONE_LEFT(tmp_box) += current_x;
                                        M706_ZONE_TOP(tmp_box) += current_y;
                                } else {
                                        if (current_layoutrecord->RecordType == 9) {
                                                switch (parent_layoutrecord->RecordType) {
                                                        case 0:
                                                                current_x = parent_layoutrecord->Data1 - ((current_x + 1) >> 1);
                                                                current_y = parent_layoutrecord->Data2 - ((current_y + 1) >> 1);
                                                                break;
                                                        case 1:
                                                                current_x = parent_layoutrecord->Data1;
                                                                current_y = parent_layoutrecord->Data2;
                                                                break;
                                                        case 2:
                                                                current_x = parent_layoutrecord->Data1 - (current_x - 1);
                                                                current_y = parent_layoutrecord->Data2;
                                                                break;
                                                        case 3:
                                                                current_x = parent_layoutrecord->Data1 - (current_x - 1);
                                                                current_y = parent_layoutrecord->Data2 - (current_y - 1);
                                                                break;
                                                        case 4:
                                                                current_x = parent_layoutrecord->Data1;
                                                                current_y = parent_layoutrecord->Data2 - (current_y - 1);
                                                                break;
                                                        case 5:
                                                                current_x = parent_layoutrecord->Data1 - ((current_x + 1) >> 1);
                                                                current_y = parent_layoutrecord->Data2;
                                                                break;
                                                        case 6:
                                                                current_x = parent_layoutrecord->Data1 - (current_x - 1);
                                                                current_y = parent_layoutrecord->Data2 - ((current_y + 1) >> 1);
                                                                break;
                                                        case 7:
                                                                current_x = parent_layoutrecord->Data1 - ((current_x + 1) >> 1);
                                                                current_y = parent_layoutrecord->Data2 - (current_y - 1);
                                                                break;
                                                        case 8:
                                                                current_x = parent_layoutrecord->Data1;
                                                                current_y = parent_layoutrecord->Data2 - ((current_y + 1) >> 1);

                                                }
                                                if (adjust_coords) {
                                                        adjust_coords = C0_FALSE;
                                                        parent_x += current_x;
                                                        parent_y += current_y;
                                                        M704_ZONE_LEFT(tmp_box) += current_x;
                                                        M706_ZONE_TOP(tmp_box) += current_y;
                                                }
                                                if (M704_ZONE_LEFT(tmp_box) < current_x) {
                                                        M704_ZONE_LEFT(tmp_box) = current_x;
                                                }
                                                if (M705_ZONE_RIGHT(tmp_box) >= current_layoutrecord->Data1 + current_x) {
                                                        M708_ZONE_WIDTH(tmp_box) = current_layoutrecord->Data1 - M704_ZONE_LEFT(tmp_box) + current_x;
                                                }
                                                if (M706_ZONE_TOP(tmp_box) < current_y) {
                                                        M706_ZONE_TOP(tmp_box) = current_y;
                                                }
                                                if (M707_ZONE_BOTTOM(tmp_box) >= current_layoutrecord->Data2 + current_y) {
                                                        M709_ZONE_HEIGHT(tmp_box) = current_layoutrecord->Data2 - M706_ZONE_TOP(tmp_box) + current_y;
                                                }
                                        } else {
                                                if (current_layoutrecord->RecordType <= 8) {
                                                        adjust_coords = C1_TRUE;
                                                }
                                        }
                                }
                                parent_layoutrecord = current_layoutrecord;
                        }
                }
                if ((current_x = *P2132_pi_X) == 0) {
                        current_x = M100_PIXEL_WIDTH(P2129_puc_Bitmap);
                }
                if ((current_y = *P2133_pi_Y) == 0) {
                        current_y = M101_PIXEL_HEIGHT(P2129_puc_Bitmap);
                }
                switch (parent_record_type) {
                        default:
                                return NULL;
                        case 0:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x - ((current_x + 1) >> 1);
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y - ((current_y + 1) >> 1);
                                break;
                        case 1:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x;
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y;
                                break;
                        case 2:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x - (current_x - 1);
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y;
                                break;
                        case 3:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x - (current_x - 1);
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y - (current_y - 1);
                                break;
                        case 4:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x;
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y - (current_y - 1);
                                break;
                        case 5:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x - ((current_x + 1) >> 1);
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y;
                                break;
                        case 6:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x - (current_x - 1);
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y - ((current_y + 1) >> 1);
                                break;
                        case 7:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x - ((current_x + 1) >> 1);
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y - (current_y - 1);
                                break;
                        case 8:
                                M704_ZONE_LEFT(P2130_pi_XYZ) = parent_x;
                                M706_ZONE_TOP(P2130_pi_XYZ) = parent_y - ((current_y + 1) >> 1);
                }
        parent_x = M704_ZONE_LEFT(tmp_box) - M704_ZONE_LEFT(P2130_pi_XYZ);
        parent_y = M706_ZONE_TOP(tmp_box) - M706_ZONE_TOP(P2130_pi_XYZ);
        if (parent_x <= 0) {
                *P2132_pi_X = 0;
                M708_ZONE_WIDTH(P2130_pi_XYZ) = F0024_MAIN_GetMinimumValue(current_x, M708_ZONE_WIDTH(tmp_box) + parent_x);
        } else {
                *P2132_pi_X = parent_x;
                M704_ZONE_LEFT(P2130_pi_XYZ) = M704_ZONE_LEFT(tmp_box);
                M708_ZONE_WIDTH(P2130_pi_XYZ) = F0024_MAIN_GetMinimumValue(current_x - parent_x, M708_ZONE_WIDTH(tmp_box));
        }
        if (parent_y <= 0) {
                *P2133_pi_Y = 0;
                M709_ZONE_HEIGHT(P2130_pi_XYZ) = F0024_MAIN_GetMinimumValue(current_y, M709_ZONE_HEIGHT(tmp_box) + parent_y);
        } else {
                *P2133_pi_Y = parent_y;
                M706_ZONE_TOP(P2130_pi_XYZ) = M706_ZONE_TOP(tmp_box);
                M709_ZONE_HEIGHT(P2130_pi_XYZ) = F0024_MAIN_GetMinimumValue(current_y - parent_y, M709_ZONE_HEIGHT(tmp_box));
        }
        if ((M708_ZONE_WIDTH(P2130_pi_XYZ) <= 0) || (M709_ZONE_HEIGHT(P2130_pi_XYZ) <= 0)) {
                return NULL;
        }
        return P2130_pi_XYZ;
}
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

@Christophef Here another Bunch of ZONE #Defines for you:

#define C427_ZONE_ENTRANCE_ANIM_VIEWPORT = 427
#define C429_ZONE_ENTRANCE_ANIM_FRAME = 429
#define C430_ZONE_ENTRANCE_DOOR_LEFT = 430
#define C431_ZONE_ENTRANCE_DOOR_RIGHT = 431
#define C432_ZONE_ENTRANCE_MICRODUNGEON = 432
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Thanks, I have updated some ZONE names. Here some the names I have used (I think you made a few mistakes):

Code: Select all

#define C2500_ZONE_FLOOR_OBJECT                                2500
#define C2900_ZONE_PROJECTILE                                  2900
#define C3000_ZONE_EXPLOSION_REBIRTH_STEP1                     3000
#define C3007_ZONE_EXPLOSION_REBIRTH_STEP2                     3007
#define C3014_ZONE_EXPLOSION_CENTERED                          3014
#define C3200_ZONE_CREATURE                                    3200

#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
#define M790_ZONE_ALCOVE_OBJECT                                2540
#define M791_ZONE_EXPLOSION                                    3029
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
#define M790_ZONE_ALCOVE_OBJECT                                2548
#define M791_ZONE_EXPLOSION                                    3031
#endif
About F0635_, can you describe what the function does in a few words? (I'll have a look into it later, as well as your question about G0435_B_CommandQueueLocked - I don't have enough time now)
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

ChristopheF wrote: Fri Mar 08, 2024 12:59 am Thanks, I have updated some ZONE names. Here some the names I have used (I think you made a few mistakes):
i will recheck.
ChristopheF wrote: Fri Mar 08, 2024 12:59 am About F0635_, can you describe what the function does in a few words? (I'll have a look into it later, as well as your question about G0435_B_CommandQueueLocked - I don't have enough time now)
F0635_ is a function which iterates through the given Zone (LAY1) Item and processing the following Commands:

Code: Select all

    CENTER = 0             # Center X, Y (Shift from Center)
    TOP_LEFT = 1           # Top left X1, Y1
    TOP_RIGHT = 2          # Top right X2, Y1
    BOTTOM_RIGHT = 3       # Bottom right X2, Y2
    BOTTOM_LEFT = 4        # Bottom left X1, Y2
    CENTER_TOP = 5         # X center horizontally, top margin Y
    RIGHT_CENTER = 6       # Right margin X, Y center vertically
    CENTER_BOTTOM = 7      # X center horizontally, bottom margin Y
    LEFT_CENTER = 8        # Left margin X, Y center vertically
    DIMENSIONS = 9         # Dimensions width X, height Y
    
    MARGIN_CENTER = 10     # Margins from Center X, Y
    MARGIN_TOP_LEFT = 11   # Margins from Top left X1, Y1
    MARGIN_TOP_RIGHT = 12  # Margins from Top right X2, Y1
    MARGIN_BOTTOM_RIGHT = 13 # Margins from Bottom right X2, Y2
    MARGIN_BOTTOM_LEFT = 14  # Margins from Bottom left X1, Y2
    MARGIN_CENTER_TOP = 15   # Margins from X center horizontally, top margin Y
    MARGIN_RIGHT_CENTER = 16 # Margins from Right margin X, Y center vertically
    MARGIN_CENTER_BOTTOM = 17 # Margins from X center horizontally, bottom margin Y
    MARGIN_LEFT_CENTER = 18  # Margins from Left margin X, Y center vertically
It stops when no Parent is found anymore (the "parent" field is 0) (big while() with lots of switch()-case)
Thus i called this Function: F0635_CalculateAlignment

Overall from Code perspective:
Data comes directly to the function or through an helper function, depending on the expected data.

GetZone() [Helper Function]-> Gets the "Master" Layout -> This is when the parent has Alignment set to 9 the F0635_ () is called and the whole zone is fetched (example: Screensize, Viewportsize, Action_Area etc, you can say most of the lower Zone (1-17).
Mostly called from Code, which needs to allocate a buffer in memory (the whole screen, the bltbuffer, ..), calls internally F0635_ if the explained match is given, otherwise NULL

F0635_ () -> Gets calls mostly from Blit() functions to get the Box for the blitting. Its usally a child of a Zone. When you call this Box with GetZone() -> you get NULL


Not sure if its clearer, here my implementation of one of the switches, as you can see its a mathematical calcualtions for x and y to get into position, it reminds me of Font-Handling and Sprite-Handling of Game Engines:

Code: Select all

                    align_functions = {
                        Alignment.CENTER:       lambda lx, ly: (pl_x - ((lx + 1) >> 1), pl_y - ((ly + 1) >> 1)),
                        Alignment.TOP_LEFT:     lambda lx, ly: (pl_x, pl_y),
                        Alignment.TOP_RIGHT:    lambda lx, ly: (pl_x - lx - 1, pl_y),
                        Alignment.BOTTOM_RIGHT: lambda lx, ly: (pl_x - lx - 1, pl_y - ly - 1),
                        Alignment.BOTTOM_LEFT:  lambda lx, ly: (pl_x, pl_y - ly - 1),
                        Alignment.CENTER_TOP:   lambda lx, ly: (pl_x - ((lx + 1) >> 1), pl_y),
                        Alignment.RIGHT_CENTER: lambda lx, ly: (pl_x - (lx - 1), pl_y - ((ly + 1) >> 1)),
                        Alignment.CENTER_BOTTOM:lambda lx, ly: (pl_x - ((lx + 1) >> 1), pl_y - (ly - 1)),
                        Alignment.LEFT_CENTER:  lambda lx, ly: (pl_x, pl_y - ((ly + 1) >> 1))
                    }
                    if current_layoutrecord['align'] == Alignment.DIMENSIONS:
                        parent_align = parent_layoutrecord['align']
                        current_x, current_y = align_functions[Alignment(parent_align)](current_x, current_y)
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

You are right about variable G0435_B_CommandQueueLocked.
This variable is set/reset in all versions.
This variable is used in Atari ST and X68000 versions, but in a buggy and non-effective way (BUG0_73).
This variable is not used in other versions.
As you suggested, I added a comment on the line where this variable is defined.
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

@Christophe
One suggestion for the WiKi:

It says:
Next object ID

Maybe enter a paragraph about the Next Object ID. Its not the Id itself (like an Index) but a 16bit value with:
Bits 15-14: Cell, Bits 13-10: Type, Bits 9-0: Index

so to get to the next item, you need to decrypt this, go to the apropiate list (Type) and then you get the item through the index
User avatar
ChristopheF
Encyclopedist
Posts: 1538
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

The definition of an Object ID is found here: http://dmweb.free.fr/?q=node/217#toc23
Cycl0ne
Craftsman
Posts: 103
Joined: Mon Apr 19, 2010 11:33 am

Re: Back to the source: ReDMCSB

Post by Cycl0ne »

You are right. since the text itself is so big, when one at the itemlist[16] one forgets that there is this chapter + i allways interpreted it only for this chapter alone. it was not clear reading: Next Object ID, that this is a complex id and not an index.

after extracting more data, i know now why this is needed:
010Ch (268) 818 bytes - Index of tiles with objects on them (per column)
was also not so clear from the description.. :D

i circumvented it by filling out the "Item on Tile"-bit to an index value into the table:

{
"Level": 0,
"X": 1,
"Y": 4,
"Content": 5,
"TileType": 1,
"Flags": 16
},
{
"Level": 0,
"X": 1,
"Y": 5,
"Content": 65535,
"TileType": 1,
"Flags": 0
},
Post Reply

Return to “Editors and Tools (DMute, DM Builder, ADGE, etc.)”