Boulder Dash Forum Forum Index Boulder Dash Forum
The only Boulder Dash discussion board in English language!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BDCFF - "add" object help needed

 
Post new topic   Reply to topic    Boulder Dash Forum Forum Index -> Tools, Fanstuff
View previous topic :: View next topic  
Author Message
Piter
Member


Joined: 26 May 2008
Posts: 41
Location: Poland

PostPosted: Thu Jun 07, 2012 9:54 pm    Post subject: BDCFF - "add" object help needed Reply with quote

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
Back to top
View user's profile Send private message
subotai
Member


Joined: 25 Jan 2009
Posts: 251

PostPosted: Thu Jun 07, 2012 11:32 pm    Post subject: Reply with quote

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:
//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.
Back to top
View user's profile Send private message
Piter
Member


Joined: 26 May 2008
Posts: 41
Location: Poland

PostPosted: Fri Jun 08, 2012 9:04 am    Post subject: Reply with quote

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:

// 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.
Back to top
View user's profile Send private message
subotai
Member


Joined: 25 Jan 2009
Posts: 251

PostPosted: Fri Jun 08, 2012 4:49 pm    Post subject: Reply with quote

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:
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])
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Boulder Dash Forum Forum Index -> Tools, Fanstuff All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group