Skip to content

Commit

Permalink
User input (#1)
Browse files Browse the repository at this point in the history
* Update SUMMARY.md

* Create ex2.md

* write the second example lesson.
  • Loading branch information
Lokathor committed Apr 24, 2023
1 parent 67d733c commit 72ce445
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ build-std = ["core"]
target = "thumbv4t-none-eabi"

[target.thumbv4t-none-eabi]
rustflags = ["-Clink-arg=-Tlinker_scripts/normal_boot.ld"]
rustflags = ["-Ztrap-unreachable=no", "-Clink-arg=-Tlinker_scripts/normal_boot.ld"]
runner = "mgba-qt"
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ version = "0.1.0"
edition = "2021"
license = "Zlib OR Apache-2.0 OR MIT"
publish = false

[dependencies]
voladdress = "1.3.0"

[profile.dev]
opt-level = 3
1 change: 1 addition & 0 deletions book_src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
[Introduction](introduction.md)

* [A Basic Executable](ex1.md)
* [User Input](ex2.md)
8 changes: 8 additions & 0 deletions book_src/ex1.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ warning: `gba_from_scratch` (example "ex1") generated 1 warning
Okay.
It builds.

## Using mGBA

Let's see if it works I guess.
Personally I like to use [mGBA](https://mgba.io/) as my emulator of choice, but any GBA emulator should be fine.
If you're on Windows then your executable will be called `mgba.exe` by default, and if you're on Mac or Linux you'll get both `mgba` (no UI) and `mgba-qt` (has a menu bar and such around the video frame).
Expand Down Expand Up @@ -493,6 +495,8 @@ Nothing in our program ever calls `main`, and it's not public for outsiders to c
Since no code can call `main` then no code can panic either, and the `panic_handler` function gets removed as well.
We end up with nothing at all.

## Writing A `_start`

We need to add some code to our progam so that there will be something to output.
Might as well define the `_start` function.

Expand Down Expand Up @@ -687,6 +691,8 @@ And so we try again
If everything is right so far, mGBA should launch and show a white screen.
Congrats, it didn't crash.

## Checking With `objdump`

If we want to double check that our code is showing up in the executable properly we can even use `objdump` to check that.
If we pass `--disassemble` we can get a printout of the assembly.
There's a bunch of other options for how to configure that output too, so check the `--help` output to see what you can do.
Expand Down Expand Up @@ -792,3 +798,5 @@ We've had *some effect* on the GBA.
Which is enough to call this article over.
In the next article we'll actually learn more details about what we just did,
as well as more details about how else we can affect the screen.

[This](https://github.com/Lokathor/gba-from-scratch/tree/b6dc1ca7c914f2e93d304c68b923208ccc48a92f) is the exact state of the repo when I finished this article.
Binary file added book_src/ex2-white-line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 72ce445

Please sign in to comment.