Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing 'main.asm' file, and fixing 'xor' compilation errors for #90 #91

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
788 changes: 0 additions & 788 deletions galactic-armada/main.asm

This file was deleted.

6 changes: 6 additions & 0 deletions galactic-armada/src/main/states/gameplay/objects/bullets.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ wActiveBulletCounter:: db
; how many bullet's we've updated
wUpdateBulletsCounter: db

; ANCHOR: w-bullets

; Bytes: active, x , y (low), y (high)
wBullets:: ds MAX_BULLET_COUNT*PER_BULLET_BYTES_COUNT

; ANCHOR_END: w-bullets

SECTION "Bullets", ROM0

bulletMetasprite::
.metasprite1 db 0,0,8,0
.metaspriteEnd db 128

; ANCHOR: bullets-tile-data
bulletTileData:: INCBIN "src/generated/sprites/bullet.2bpp"
bulletTileDataEnd::
; ANCHOR_END: bullets-tile-data


; ANCHOR_END: bullets-top
Expand Down
18 changes: 15 additions & 3 deletions galactic-armada/src/main/states/gameplay/objects/enemies.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,28 @@ wActiveEnemyCounter::db
wUpdateEnemiesCounter:db
wUpdateEnemiesCurrentEnemyAddress::dw

; ANCHOR: w-enemies
; Bytes: active, x , y (low), y (high), speed, health
wEnemies:: ds MAX_ENEMY_COUNT*PER_ENEMY_BYTES_COUNT

; ANCHOR_END: w-enemies

; ANCHOR_END: enemies-start
; ANCHOR: enemies-tile-metasprite
; ANCHOR: enemies-section-header
SECTION "Enemies", ROM0
; ANCHOR_END: enemies-section-header

; ANCHOR: enemies-tile-data
enemyShipTileData:: INCBIN "src/generated/sprites/enemy-ship.2bpp"
enemyShipTileDataEnd::
; ANCHOR_END: enemies-tile-data

; ANCHOR: enemy-metasprites
enemyShipMetasprite::
.metasprite1 db 0,0,4,0
.metasprite2 db 0,8,6,0
.metaspriteEnd db 128
; ANCHOR_END: enemies-tile-metasprite
; ANCHOR_END: enemy-metasprites

; ANCHOR: enemies-initialize
InitializeEnemies::
Expand Down Expand Up @@ -243,7 +250,7 @@ UpdateEnemies_PerEnemy_CheckPlayerCollision:
UpdateEnemies_DeActivateEnemy:

; Set as inactive
xor
xor a
ld [hl], a

; Decrease counter
Expand All @@ -265,6 +272,9 @@ UpdateEnemies_NoCollisionWithPlayer::

push hl


; ANCHOR: draw-enemy-metasprites

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; call the 'DrawMetasprites function. setup variables and call
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -287,6 +297,8 @@ UpdateEnemies_NoCollisionWithPlayer::
; Actually call the 'DrawMetasprites function
call DrawMetasprites

; ANCHOR_END: draw-enemy-metasprites

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
2 changes: 2 additions & 0 deletions galactic-armada/src/main/states/gameplay/objects/player.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ mPlayerFlash: dw
; ANCHOR: player-data
SECTION "Player", ROM0

; ANCHOR: player-tile-data
playerShipTileData: INCBIN "src/generated/sprites/player-ship.2bpp"
playerShipTileDataEnd:
; ANCHOR_END: player-tile-data

playerTestMetaSprite::
.metasprite1 db 0,0,0,0
Expand Down
2 changes: 2 additions & 0 deletions galactic-armada/src/main/utils/constants.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ DEF enemy_speedByte RB 1
DEF enemy_healthByte RB 1
DEF PER_ENEMY_BYTES_COUNT RB 0

; ANCHOR: bullet-offset-constants
; from https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.5#EXPRESSIONS
; The RS group of commands is a handy way of defining structure offsets:
RSRESET
Expand All @@ -33,6 +34,7 @@ DEF bullet_xByte RB 1
DEF bullet_yLowByte RB 1
DEF bullet_yHighByte RB 1
DEF PER_BULLET_BYTES_COUNT RB 0
; ANCHOR_END: bullet-offset-constants

; ANCHOR: sprite-vram-constants
RSRESET
Expand Down
4 changes: 4 additions & 0 deletions galactic-armada/src/main/utils/text-utils.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ SECTION "Text", ROM0

textFontTileData: INCBIN "src/generated/backgrounds/text-font.2bpp"
textFontTileDataEnd:
; ANCHOR: load-text-font

LoadTextFontIntoVRAM::
; Copy the tile data
ld de, textFontTileData ; de contains the address where data will be copied from;
ld hl, $9000 ; hl contains the address where data will be copied to;
ld bc, textFontTileDataEnd - textFontTileData ; bc contains how many bytes we have to copy.
jp CopyDEintoMemoryAtHL

; ANCHOR_END: load-text-font


; ANCHOR: draw-text-tiles
DrawTextTilesLoop::
Expand Down
6 changes: 3 additions & 3 deletions src/part3/collision.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ For this, we've created a basic function called "CheckObjectPositionDifference".

Here's an example of how to call this function:

> We have the player's x & y position in registers d & e respectively. We have the enemy's x & y position in registers b & c respectively. If there is no overlap on the x or y axis, the program jumps to the "NoCollisionWithPlayer" label.
> We have the player's Y position in the `d` register. We'll check it's value against the y value of the current enemy, which we have in a variable named `wCurrentEnemyY`.

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:player-collision-label}}
{{#include ../../galactic-armada/main.asm:player-collision-label}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/collision/enemy-player-collision.asm:check-y-overlap}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/collision/enemy-player-collision.asm:check-y-overlap}}
```

When checking for collision, we'll use that function twice. Once for the x-axis, and again for the y-axis.
Expand Down
8 changes: 6 additions & 2 deletions src/part3/enemies.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ Here are the RAM variables we'll use for our enemies:

Just like with bullets, we'll setup ROM data for our enemies tile data and metasprites.

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemies-tile-metasprite}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemies-tile-metasprite}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemies-section-header}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemies-section-header}}

{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemies-tile-data}}

{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemy-metasprites}}
```

## Initializing Enemies
Expand Down
35 changes: 0 additions & 35 deletions src/part3/game-states.md

This file was deleted.

12 changes: 6 additions & 6 deletions src/part3/object-pools.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Galactic Armada will use "object pools" for bullets and enemies. A fixed amount

Constants are also created for the size of each object, and what each byte is. These constants are in the “src/main/utils/constants.inc” file and utilize RGBDS offset constants (a really cool feature)

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:bullet-offset-constants}}
{{#include ../../galactic-armada/main.asm:bullet-offset-constants}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/utils/constants.inc:bullet-offset-constants}}
{{#include ../../galactic-armada/src/main/utils/constants.inc:bullet-offset-constants}}
```

The two object types that we need to loop through are Enemies and Bullets.
Expand All @@ -19,8 +19,8 @@ The two object types that we need to loop through are Enemies and Bullets.
5. Speed - How fast they move
6. Health - How many bullets they can take

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:w-enemies}}
{{#include ../../galactic-armada/main.asm:w-enemies}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:w-enemies}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:w-enemies}}
```

![EnemyBytesVisualized.png](../assets/part3/img/EnemyBytesVisualized.png)
Expand All @@ -32,8 +32,8 @@ The two object types that we need to loop through are Enemies and Bullets.
3. Y (low) - The lower byte of their 16-bit (scaled) y position
4. Y (high) - The higher byte of their 16-bit (scaled) y position

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:w-bullets}}
{{#include ../../galactic-armada/main.asm:w-bullets}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/bullets.asm:w-bullets}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/bullets.asm:w-bullets}}
```

![BulletBytesVisualized.png](../assets/part3/img/BulletBytesVisualized.png)
Expand Down
11 changes: 9 additions & 2 deletions src/part3/project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ We'll use it to convert all of our graphics to .2bpp, and .tilemap formats (bina

From there, INCBIN commands are used to store reference the binary tile data.

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:sprite-tile-data}}
{{#include ../../galactic-armada/main.asm:sprite-tile-data}}
```rgbasm
; in src/main/states/gameplay/objects/player.asm
{{#include ../../galactic-armada/src/main/states/gameplay/objects/player.asm:player-tile-data}}

; in src/main/states/gameplay/objects/enemies.asm
{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemies-tile-data}}

; in src/main/states/gameplay/objects/bullets.asm
{{#include ../../galactic-armada/src/main/states/gameplay/objects/bullets.asm:bullets-tile-data}}
```

:::tip Including binary files
Expand Down
8 changes: 4 additions & 4 deletions src/part3/sprites-metasprites.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ The logic stops drawing when it reads 128.
An example of metasprite is the enemy ship:


```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:enemy-metasprites}}
{{#include ../../galactic-armada/main.asm:enemy-metasprites}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemy-metasprites}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:enemy-metasprites}}
```

![MetaspriteDIagram.png](../assets/part3/img/MetaspriteDIagram.png)
Expand All @@ -30,8 +30,8 @@ The Previous snippet draws two sprites. One that the object’s actual position,

I can later draw such metasprite by calling the "DrawMetasprite" function that

```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/main.asm:draw-enemy-metasprites}}
{{#include ../../galactic-armada/main.asm:draw-enemy-metasprites}}
```rgbasm,linenos,start={{#line_no_of "" ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:draw-enemy-metasprites}}
{{#include ../../galactic-armada/src/main/states/gameplay/objects/enemies.asm:draw-enemy-metasprites}}
```

We previously mentioned a variable called "wLastOAMAddress". The "DrawMetasprites" function can be found in the "src/main/utils/metasprites.asm" file:
Expand Down
Loading