mirror of
https://github.com/jeremysrand/BuGS.git
synced 2025-01-04 23:30:06 +00:00
This is the first step to getting rid of the tile.c file and replace it with generated assembly instead. And then I can add the extra data required to handle the player correctly.
This commit is contained in:
parent
7c0dc8ebb1
commit
c45c3503d6
@ -208,6 +208,7 @@ nextWord anop
|
||||
startGame entry
|
||||
stz gameRunning
|
||||
stz numSegments
|
||||
jsl addRandomMushrooms
|
||||
jsl initPlayer
|
||||
jsl spiderInitGame
|
||||
jsl levelInit
|
||||
|
@ -13,6 +13,35 @@
|
||||
gameMushroom start
|
||||
using globalData
|
||||
|
||||
|
||||
STARTING_NUM_MUSHROOMS equ 30
|
||||
|
||||
|
||||
addRandomMushrooms entry
|
||||
stz numInfieldMushrooms
|
||||
ldy #STARTING_NUM_MUSHROOMS
|
||||
|
||||
addRandomMushrooms_loop anop
|
||||
phy
|
||||
addRandomMushrooms_tryAgain anop
|
||||
jsl randomMushroomOffset
|
||||
tax
|
||||
lda tileType,x
|
||||
bne addRandomMushrooms_tryAgain
|
||||
lda #TILE_MUSHROOM4
|
||||
sta tileType,x
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tileDirty,x
|
||||
cpx #SPIDER_STARTING_TOP_ROW_OFFSET
|
||||
blt addRandomMushrooms_notInfield
|
||||
inc numInfieldMushrooms
|
||||
addRandomMushrooms_notInfield anop
|
||||
ply
|
||||
dey
|
||||
bne addRandomMushrooms_loop
|
||||
rtl
|
||||
|
||||
|
||||
; Call this with the tile offset of the mushroom being shot in the X register
|
||||
shootMushroom entry
|
||||
ldy tileType,x
|
||||
@ -52,11 +81,7 @@ shootRandomMushroom entry
|
||||
bra shootRandomMushroom_testTile
|
||||
|
||||
shootRandomMushroom_doRandom anop
|
||||
jsl rand0_to_65534
|
||||
and #1023
|
||||
cmp #24*25
|
||||
bge shootRandomMushroom_doRandom
|
||||
asl a
|
||||
jsl randomMushroomOffset
|
||||
tax
|
||||
shootRandomMushroom_testTile anop
|
||||
lda tileType,x
|
||||
|
@ -159,7 +159,7 @@ scoreWithin20000 dc i2'0'
|
||||
scoreNum20000 dc i2'0'
|
||||
centipedeLevelNum dc i2'0'
|
||||
colourLevelNum dc i2'0'
|
||||
; numInfieldMushrooms
|
||||
numInfieldMushrooms dc i2'0'
|
||||
; tileType
|
||||
|
||||
|
||||
|
@ -34,6 +34,14 @@ unsigned int randomSeed;
|
||||
/* Implementation */
|
||||
|
||||
|
||||
tTileOffset randomMushroomOffset(void)
|
||||
{
|
||||
/* We do not put mushrooms in the bottom tile so we subtract the width here to find
|
||||
a tile number above that last line */
|
||||
return (rand() % (NUM_GAME_TILES - GAME_NUM_TILES_WIDE)) * sizeof(word);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int event;
|
||||
@ -65,7 +73,6 @@ int main(void)
|
||||
|
||||
initTiles();
|
||||
initNonGameTiles();
|
||||
addStartingMushrooms();
|
||||
|
||||
game();
|
||||
|
||||
|
36
BuGS/tiles.c
36
BuGS/tiles.c
@ -34,11 +34,8 @@
|
||||
#define SCREEN_ADDRESS_FOR_TILE_AT_X_Y(X, Y) \
|
||||
(0x2000 + (0xa0 * (Y)) + ((X) / 2) + 3)
|
||||
|
||||
#define STARTING_NUM_MUSHROOMS 30
|
||||
#define STARTING_NUM_PLAYERS 3
|
||||
|
||||
#define ADD_DIRTY_GAME_TILE(tileNum) tileDirty[tileNum] = 1;
|
||||
|
||||
#define ADD_DIRTY_NON_GAME_TILE(tileNum) \
|
||||
if (!tileDirty[tileNum]) { \
|
||||
tileDirty[tileNum] = 1; \
|
||||
@ -61,10 +58,6 @@ word tileBitMask[NUM_GAME_TILES];
|
||||
tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
|
||||
word numDirtyNonGameTiles;
|
||||
|
||||
word numPlayers;
|
||||
|
||||
word numInfieldMushrooms;
|
||||
|
||||
|
||||
/* Implementation */
|
||||
|
||||
@ -295,9 +288,8 @@ void initNonGameTiles(void)
|
||||
tileType[tileNum] = TILE_SYMBOL_COLON;
|
||||
ADD_DIRTY_NON_GAME_TILE(tileNum);
|
||||
|
||||
numPlayers = STARTING_NUM_PLAYERS;
|
||||
tileNum = LHS_FIRST_TILE + (10 * LHS_NUM_TILES_WIDE) - 2;
|
||||
for (i = 0; i < numPlayers; i++)
|
||||
for (i = 0; i < STARTING_NUM_PLAYERS; i++)
|
||||
{
|
||||
tileType[tileNum] = TILE_PLAYER;
|
||||
ADD_DIRTY_NON_GAME_TILE(tileNum);
|
||||
@ -430,35 +422,11 @@ void initNonGameTiles(void)
|
||||
tileType[tileNum] = TILE_SYMBOL_COLON;
|
||||
ADD_DIRTY_NON_GAME_TILE(tileNum);
|
||||
|
||||
numPlayers = STARTING_NUM_PLAYERS;
|
||||
tileNum = LHS_FIRST_TILE + (23 * LHS_NUM_TILES_WIDE) - 2;
|
||||
for (i = 0; i < numPlayers; i++)
|
||||
for (i = 0; i < STARTING_NUM_PLAYERS; i++)
|
||||
{
|
||||
tileType[tileNum] = TILE_PLAYER;
|
||||
ADD_DIRTY_NON_GAME_TILE(tileNum);
|
||||
tileNum--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void addStartingMushrooms(void)
|
||||
{
|
||||
tTileNum tileNum;
|
||||
unsigned int numMushrooms = 0;
|
||||
numInfieldMushrooms = 0;
|
||||
|
||||
while (numMushrooms < STARTING_NUM_MUSHROOMS)
|
||||
{
|
||||
/* We do not put mushrooms in the bottom tile so we subtract the width here to find
|
||||
a tile number above that last line */
|
||||
tileNum = rand() % (NUM_GAME_TILES - GAME_NUM_TILES_WIDE);
|
||||
if (tileType[tileNum] != TILE_EMPTY)
|
||||
continue;
|
||||
|
||||
tileType[tileNum] = TILE_MUSHROOM4;
|
||||
ADD_DIRTY_GAME_TILE(tileNum);
|
||||
numMushrooms++;
|
||||
if ((tileNum / GAME_NUM_TILES_WIDE) >= GAME_NUM_TILES_TALL - 10)
|
||||
numInfieldMushrooms++;
|
||||
}
|
||||
}
|
||||
|
@ -120,13 +120,11 @@ extern word tileBitMask[NUM_GAME_TILES];
|
||||
|
||||
extern tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
|
||||
extern word numDirtyNonGameTiles;
|
||||
extern word numInfieldMushrooms;
|
||||
|
||||
|
||||
/* API */
|
||||
|
||||
extern void initTiles(void);
|
||||
extern void addStartingMushrooms(void);
|
||||
|
||||
|
||||
#endif /* define _GUARD_PROJECTBuGS_FILEtiles_ */
|
||||
|
Loading…
Reference in New Issue
Block a user