Add some global data to have a bit mask of tiles which contain a centipede segment. This will allow the update code to figure out if centipede segments are colliding and if so, change direction. Still need to write some codegen for this global constant data rather than building it at runtime in C.

This commit is contained in:
Jeremy Rand 2020-09-20 22:22:58 -04:00
parent a9d3b12725
commit c4902f486b
4 changed files with 21 additions and 3 deletions

View File

@ -86,7 +86,7 @@
9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = "<group>"; }; 9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = "<group>"; };
9DB1505124C6875C00558B87 /* gameScorpion.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameScorpion.s; sourceTree = "<group>"; }; 9DB1505124C6875C00558B87 /* gameScorpion.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameScorpion.s; sourceTree = "<group>"; };
9DB1505224C7495400558B87 /* globals.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = globals.s; sourceTree = "<group>"; }; 9DB1505224C7495400558B87 /* globals.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = globals.s; sourceTree = "<group>"; };
9DB1505324C9E54C00558B87 /* gameSpider.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSpider.s; sourceTree = "<group>"; }; 9DB1505324C9E54C00558B87 /* gameSpider.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSpider.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
9DB1505424D3BF6C00558B87 /* gameSegments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSegments.s; sourceTree = "<group>"; }; 9DB1505424D3BF6C00558B87 /* gameSegments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSegments.s; sourceTree = "<group>"; };
9DB1505524D3BFCE00558B87 /* global.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = global.macros; sourceTree = "<group>"; }; 9DB1505524D3BFCE00558B87 /* global.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = global.macros; sourceTree = "<group>"; };
9DC4D7BD24B7652100BACF4B /* ship.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = ship.s; sourceTree = "<group>"; }; 9DC4D7BD24B7652100BACF4B /* ship.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = ship.s; sourceTree = "<group>"; };

View File

@ -7,7 +7,7 @@
<key>Binary.xcscheme_^#shared#^_</key> <key>Binary.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>3</integer>
</dict> </dict>
<key>BuGS.xcscheme_^#shared#^_</key> <key>BuGS.xcscheme_^#shared#^_</key>
<dict> <dict>
@ -22,7 +22,7 @@
<key>doNotBuild.xcscheme_^#shared#^_</key> <key>doNotBuild.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>3</integer> <integer>1</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>

View File

@ -55,6 +55,8 @@ tTileOffset tileAbove[TOTAL_NUM_TILES];
tTileOffset tileBelow[TOTAL_NUM_TILES]; tTileOffset tileBelow[TOTAL_NUM_TILES];
tTileOffset tileLeft[TOTAL_NUM_TILES]; tTileOffset tileLeft[TOTAL_NUM_TILES];
tTileOffset tileRight[TOTAL_NUM_TILES]; tTileOffset tileRight[TOTAL_NUM_TILES];
word tileBitOffset[NUM_GAME_TILES];
word tileBitMask[NUM_GAME_TILES];
tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES]; tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
word numDirtyNonGameTiles; word numDirtyNonGameTiles;
@ -70,6 +72,8 @@ void initTiles(void)
word tileY; word tileY;
word lastOffset; word lastOffset;
word tileIndex = 0; word tileIndex = 0;
word bitOffset = 0;
word bitMask = 1;
word rhsTileIndex = RHS_FIRST_TILE; word rhsTileIndex = RHS_FIRST_TILE;
word lhsTileIndex = LHS_FIRST_TILE; word lhsTileIndex = LHS_FIRST_TILE;
@ -113,6 +117,8 @@ void initTiles(void)
tileDirty[tileIndex] = 0; tileDirty[tileIndex] = 0;
tileScreenOffset[tileIndex] = lastOffset; tileScreenOffset[tileIndex] = lastOffset;
tileType[tileIndex] = TILE_EMPTY; tileType[tileIndex] = TILE_EMPTY;
tileBitOffset[tileIndex] = bitOffset;
tileBitMask[tileIndex] = bitMask;
if (tileY == 0) if (tileY == 0)
tileAbove[tileIndex] = INVALID_TILE_NUM; tileAbove[tileIndex] = INVALID_TILE_NUM;
@ -136,6 +142,16 @@ void initTiles(void)
tileIndex++; tileIndex++;
if ((tileIndex % (sizeof(word) * 2)) == 0)
{
bitOffset += sizeof(word);
bitMask = 1;
}
else
{
bitMask <<= 1;
}
lastOffset += 4; lastOffset += 4;
} }

View File

@ -112,6 +112,8 @@ extern tTileOffset tileAbove[TOTAL_NUM_TILES];
extern tTileOffset tileBelow[TOTAL_NUM_TILES]; extern tTileOffset tileBelow[TOTAL_NUM_TILES];
extern tTileOffset tileLeft[TOTAL_NUM_TILES]; extern tTileOffset tileLeft[TOTAL_NUM_TILES];
extern tTileOffset tileRight[TOTAL_NUM_TILES]; extern tTileOffset tileRight[TOTAL_NUM_TILES];
extern word tileBitOffset[NUM_GAME_TILES];
extern word tileBitMask[NUM_GAME_TILES];
extern tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES]; extern tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
extern word numDirtyNonGameTiles; extern word numDirtyNonGameTiles;