Skip to content

Commit 23807b7

Browse files
committed
part 3 - project structure: minor improvements and formatting overhaul
1 parent 93447ce commit 23807b7

File tree

1 file changed

+60
-52
lines changed

1 file changed

+60
-52
lines changed

src/part3/project-structure.md

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,45 @@ This page is going to give you an idea of how the Galactic Armada project is str
44

55
## Folder Layout
66

7-
For organizational purposes, many parts of the logic are separated into reusable functions. This is to reduce file size, and make logic more clear.
8-
9-
Here’s a basic look at how the project is structured
10-
11-
> NOTE: Generated files should never be included in VCS repositories. It unneccessarily bloats the repo. The folders below that are not included in the project contain assets generated from running the Makefile.
12-
13-
- libs - Two assembly files for input and sprites are located here.
14-
- src
15-
- generated - the results of RGBGFX are stored here. **This is not included in the repo**
16-
- resources - Here exist some PNGs and Aseprite files for usage with RGBGFX
17-
- main - All assembly files are located here, or in subfolders
18-
- states
19-
- gameplay - for gameplay related files
20-
- objects - for gameplay objects like the player, bullets, and enemies
21-
- collision - for collision among objects
22-
- story - for our story state's related files
23-
- title-screen - for our title screen's related files
24-
- utils - Extra functions includes to assist with development
25-
- macros
26-
- dist - The final ROM file will be created here. **This is not included in the repo**
27-
- obj - Intermediate files from the compile process. **This is not included in the repo**
28-
- Makefile - used to create the final ROM file and intermediate files
7+
For organizational purposes, many parts of the logic are separated into reusable functions. This is to reduce duplicate code, and make logic more clear.
8+
9+
Here’s a basic look at how the project is structured:
10+
11+
::: tip
12+
13+
Generated files should never be included in VCS repositories. It unneccessarily bloats the repo. The folders below marked with \* contains assets generated from running the Makefile and are not included in the repository.
14+
15+
:::
16+
17+
- `libs` - Two assembly files for input and sprites are located here.
18+
- `src`
19+
- `generated` - the results of RGBGFX are stored here. \*
20+
- `resources` - Here exist some PNGs and Aseprite files for usage with RGBGFX
21+
- `main` - All assembly files are located here, or in subfolders
22+
- `states`
23+
- `gameplay` - for gameplay related files
24+
- `objects` - for gameplay objects like the player, bullets, and enemies
25+
- collision - for collision among objects
26+
- `story` - for our story state's related files
27+
- `title-screen` - for our title screen's related files
28+
- `utils` - Extra functions includes to assist with development
29+
- `macros`
30+
- `dist` - The final ROM file will be created here. \*
31+
- `obj` - Intermediate files from the compile process. \*
32+
- `Makefile` - used to create the final ROM file and intermediate files
2933

3034
## Background & Sprite Resources
3135

3236
The following backgrounds and sprites are used in Galactic Armada:
3337

3438
- Backgrounds
35-
- Star Field
36-
- Title Screen
37-
- Text Font (Tiles only)
39+
- Star Field
40+
- Title Screen
41+
- Text Font (Tiles only)
3842
- Sprites
39-
- Enemy Ship
40-
- Player Ship
41-
- Bullet
43+
- Enemy Ship
44+
- Player Ship
45+
- Bullet
4246

4347
![star-field.png](../assets/part3/img/star-field.png)
4448

@@ -52,17 +56,15 @@ The following backgrounds and sprites are used in Galactic Armada:
5256

5357
![bullet.png](../assets/part3/img/bullet.png)
5458

55-
These images were originally created in Aseprite. The original templates are also included in the repository. They were exported as a PNG **with a specific color palette**. Ater being exported as a PNG, when you run `make`, they are converted into .2bpp and .tilemap files via the RGBDS tool: RGBGFX.
59+
These images were originally created in Aseprite. The original templates are also included in the repository. They were exported as a PNG **with a specific color palette**. Ater being exported as a PNG, when you run `make`, they are converted into .2bpp and .tilemap files via the RGBDS tool: RGBGFX.
5660

5761
> The **`rgbgfx`** program converts PNG images into data suitable for display on the Game Boy and Game Boy Color, or vice-versa.
58-
>
59-
>
62+
>
6063
> The main function of **`rgbgfx`** is to divide the input PNG into 8×8 pixel *[squares](https://rgbds.gbdev.io/docs/v0.6.1/rgbgfx.1#squares)*, convert each of those squares into 1bpp or 2bpp tile data, and save all of the tile data in a file. It also has options to generate a tile map, attribute map, and/or palette set as well; more on that and how the conversion process can be tweaked below.
61-
>
6264
6365
RGBGFX can be found here: [https://rgbds.gbdev.io/docs/v0.6.1/rgbgfx.1](https://rgbds.gbdev.io/docs/v0.6.1/rgbgfx.1)
6466

65-
We'll use it to convert all of our graphics to .2bpp, and .tilemap formats (binary files)
67+
We'll use it to convert all of our graphics to .2bpp, and .tilemap formats (binary files)
6668

6769
```bash,linenos,start={{#line_no_of "" ../../galactic-armada/Makefile:generate-graphics}}
6870
{{#include ../../galactic-armada/Makefile:generate-graphics}}
@@ -74,30 +76,36 @@ From there, INCBIN commands are used to store reference the binary tile data.
7476
{{#include ../../galactic-armada/main.asm:sprite-tile-data}}
7577
```
7678

77-
You can find more about the INCBIN command here: [https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.5#Including_binary_files](https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.5#Including_binary_files)
78-
79-
> ### [Including binary files](https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.5#Including_binary_files)
80-
>
81-
> You probably have some graphics, level data, etc. you'd like to include. Use **`INCBIN`** to include a raw binary file as it is. If the file isn't found in the current directory, the include-path list passed to [rgbasm(1)](https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.1) (see the **`-i`** option) on the command line will be searched.
82-
>
83-
> **`INCBIN "titlepic.bin"
84-
> INCBIN "sprites/hero.bin"`**
85-
>
86-
> You can also include only part of a file with **`INCBIN`**. The example below includes 256 bytes from data.bin, starting from byte 78.
87-
>
88-
> **`INCBIN "data.bin",78,256`**
89-
>
90-
> The length argument is optional. If only the start position is specified, the bytes from the start position until the end of the file will be included.
79+
::: tip Including binary files
80+
81+
You probably have some graphics, level data, etc. you'd like to include. Use **`INCBIN`** to include a raw binary file as it is. If the file isn't found in the current directory, the include-path list passed to [rgbasm(1)](https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.1) (see the **`-i`** option) on the command line will be searched.
82+
83+
```
84+
INCBIN "titlepic.bin"
85+
INCBIN "sprites/hero.bin"
86+
```
87+
88+
You can also include only part of a file with **`INCBIN`**. The example below includes 256 bytes from data.bin, starting from byte 78.
89+
90+
```
91+
INCBIN "data.bin",78,256
92+
```
93+
94+
The length argument is optional. If only the start position is specified, the bytes from the start position until the end of the file will be included.
95+
96+
See also: [Including binary files - RGBASM documentation](https://rgbds.gbdev.io/docs/v0.6.1/rgbasm.5#Including_binary_files)
97+
98+
:::
9199

92100
## Compilation
93101

94-
Compilation is done via a Makefile. This makefile can be run using the `make` command. Make should be preinstalled on Linux and Mac systems. For Windows users, check out [cygwin](https://www.cygwin.com/).
102+
Compilation is done via a Makefile. This Makefile can be run using the `make` command. Make should be preinstalled on Linux and Mac systems. For Windows users, check out [cygwin](https://www.cygwin.com/).
95103

96-
Without going over everything in detail, here’s what the makefile does:
104+
Without going over everything in detail, here’s what the Makefile does:
97105

98106
- Clean generated folders
99107
- Recreate generated folders
100-
- Convert PNGs in src/resources to .2bpp, and .tilemap formats
101-
- Convert .asm files to .o
102-
- Use the .o files to build the ROM file
108+
- Convert PNGs in src/resources to `.2bpp`, and `.tilemap` formats
109+
- Convert `.asm` files to `.o`
110+
- Use the `.o` files to build the ROM file
103111
- Apply the RGBDS “fix” utility.

0 commit comments

Comments
 (0)