BDCFF - "add" object help needed

Everything about the various Boulder Dash tools, and other stuff created by the fans.

Moderator: Admin

Post Reply
User avatar
Piter
Member
Posts: 41
Joined: Mon May 26, 2008 8:53 pm
Location: Poland

BDCFF - "add" object help needed

Post by Piter »

Hi!

Currently I'm working over BDCFF support for my BD clone and I'm stuck with one thing. According to Tim Stridmann's documentation, BD2 used "add" function in objects section. Syntax looks like:

Add=IncX IncY element1 element2

I have no idea how does it work... and Tim doesn't explain it any further in his doc. I wonder if someone of You could help me to understand how should I interpret it. I'd be very grateful.

Best, Peter
subotai
Member
Posts: 251
Joined: Sun Jan 25, 2009 4:19 pm

Post by subotai »

Hello piter,

I don't have much experience with the BDCFF, but it should work as follows:

Add=IncX IncY element1 element2:
Search for element1. Starting from the position of this element, move IncX fields to the right and IncY fields to the down and set the element2

Example:
Add (0,5, BOULDER, DIAMOND). The Boulder is at position X,Y (5,5),
the Diamond will be set at position(5+0,5+5).

Code: Select all

//Untested!
For i:=879 downto 0 do //or For i:=0 to 879 do; I'm not sure about that
     BEGIN
     IF map[i]=element1 then
        BEGIN
         X:=i MOD 40;
         Y:=i DIV 40; 
         j:=(Y+IncY)*40+X+IncX;
         IF (j>=0) AND (j<880) then
           map[j]:=element2
        END;
     END;
The C64 uses a one dimensional array for the map, the BDCFF uses a two dimensional array. That' one point that I don't like about the BDCFF. The C64 implementation is much easier.

BTW: Gdash is a very good reference for BDCFF-support.
User avatar
Piter
Member
Posts: 41
Joined: Mon May 26, 2008 8:53 pm
Location: Poland

Post by Piter »

Yepp, that's it! Thanks alot Subotai!

I am wondering what should've happen if position of extra element exceeds cave boundaries.

For example - we have classic cave 40x22 with boulder at 39,5.

Add=3 1 boulder diamond

x + incx = 42
y + incy = 6

What should the program do?

In my implementation I've made protection and whenever such situation occurs, my program just ignores it.

Code: Select all

// int CaveMap[40][22]

for (int y = 1; y < 21; y++) {
	for (int x = 1; x < 39; x++) {
		if (CaveData.CaveMap[x][y] == GetObjectCode(element1)
			if ((x+incx < 39) && (y+sy < 21))
				PutObject(x+incx, y+incy, element2, CaveData);
	}
}
But I don't know if it's how does original game work. I'll try to check this situation against GDash.
subotai
Member
Posts: 251
Joined: Sun Jan 25, 2009 4:19 pm

Post by subotai »

piter wrote:I am wondering what should've happen if position of extra element exceeds cave boundaries.
I don't know how it's meant to be in the BDCFF. But in the original C64 game, the scan position (value from 0 to 879) is used for the calculation, not the coordinates x,y.

In the C64 games, the Add routine for example looks like this: (scan position = Y*40+X)

Code: Select all

add 43 boulder diamond //1*40+3

scan position of the boulder at 39,5 => 5*40+39 = 239
scan position of the diamond: 239 + 43 = 282

The diamond is only drawn, if the position is between 0 and 879!

X:=282 MOD 40 = 2 //I don't know the command in C (divide and take the rest as the result)
Y:=282 DIV 40 = 7

coordinates of the diamond = 2,7
This implementation is closer to the original. It's better to use a one dimensional array for the cavemap as this is how the original works (CaveData.CaveMap[scanposition])
Post Reply