Most recently, I "cleaned up" the code that deals with the enemy and area object databases. Instead of the cumbersome .db low and high byte labeling, I did a .dw of the areas, grouped by area type.

My work so far:

Code: Select all

```
EnemyDataHOffsets:
.db (E_WaterAreas-EnemyDataOffsets)>>1, (E_GroundAreas-EnemyDataOffsets)>>1
.db (E_UndergroundAreas-EnemyDataOffsets)>>1, (E_CastleAreas-EnemyDataOffsets)>>1
EnemyDataOffsets:
E_CastleAreas:
.dw E_CastleArea1, E_CastleArea2, E_CastleArea3, E_CastleArea4, E_CastleArea5, E_CastleArea6
E_GroundAreas:
.dw E_GroundArea1, E_GroundArea2, E_GroundArea3, E_GroundArea4, E_GroundArea5, E_GroundArea6
.dw E_GroundArea7, E_GroundArea8, E_GroundArea9, E_GroundArea10, E_GroundArea11, E_GroundArea12
.dw E_GroundArea13, E_GroundArea14, E_GroundArea15, E_GroundArea16, E_GroundArea17, E_GroundArea18
.dw E_GroundArea19, E_GroundArea20, E_GroundArea21, E_GroundArea22
E_UndergroundAreas:
.dw E_UndergroundArea1, E_UndergroundArea2, E_UndergroundArea3
E_WaterAreas:
.dw E_WaterArea1, E_WaterArea2, E_WaterArea3
```

Code: Select all

```
AreaDataHOffsets:
.db (L_WaterAreas-AreaDataOffsets)>>1, (L_GroundAreas-AreaDataOffsets)>>1
.db (L_UndergroundAreas-AreaDataOffsets)>>1, (L_CastleAreas-AreaDataOffsets)>>1
AreaDataOffsets:
L_WaterAreas:
.dw L_WaterArea1, L_WaterArea2, L_WaterArea3
L_GroundAreas:
.dw L_GroundArea1, L_GroundArea2, L_GroundArea3, L_GroundArea4, L_GroundArea5, L_GroundArea6
.dw L_GroundArea7, L_GroundArea8, L_GroundArea9, L_GroundArea10, L_GroundArea11, L_GroundArea12
.dw L_GroundArea13, L_GroundArea14, L_GroundArea15, L_GroundArea16, L_GroundArea17, L_GroundArea18
.dw L_GroundArea19, L_GroundArea20, L_GroundArea21, L_GroundArea22
L_UndergroundAreas:
.dw L_UndergroundArea1, L_UndergroundArea2, L_UndergroundArea3
L_CastleAreas:
.dw L_CastleArea1, L_CastleArea2, L_CastleArea3, L_CastleArea4, L_CastleArea5, L_CastleArea6
```

Code: Select all

```
GetAreaDataAddrs:
lda AreaPointer ; use 2 MSB for Y
jsr GetAreaType
tay
lda AreaPointer ; mask out all but 5 LSB
and #%00011111
sta AreaAddrsOffset ; save as low offset
lda EnemyAddrHOffsets,y ; load base value with 2 altered MSB,
clc ; then add base value to 5 MSB, result
adc AreaAddrsOffset ; becomes offset for level data
tay
lda EnemyDataOffsets,y ; use offset to load pointer
sta EnemyDataLow
lda EnemyDataOffsets+1,y
sta EnemyDataHigh
ldy AreaType ; use area type as offset
lda AreaAddrHOffsets,y ; do the same thing but with different base value
clc
adc AreaAddrsOffset
tay
lda AreaDataOffsets,y
sta AreaDataLow
lda AreaDataOffsets+1,y
sta AreaDataHigh
[...]
```

Thank you,

Ben (SMB2J-2Q)