Skip to content

Commit

Permalink
Merge pull request kotetuco#5 from kotetuco/feature/draw_string
Browse files Browse the repository at this point in the history
文字列表示処理を実装。
  • Loading branch information
kotetuco authored Mar 26, 2017
2 parents 12fc115 + fd0e501 commit 78aab45
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 100 deletions.
26 changes: 0 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ lto = true
panic = "abort"
opt-level = 2
lto = true

[dependencies]
rlibc = "1.0.0"
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins" }
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ default:
mkdir -p $(BUILD_DIR)
make $(BUILD_DIR)/$(BUILD_NAME).mb

$(BUILD_DIR)/$(BUILD_NAME).mb: $(BUILD_DIR)/$(BUILD_NAME).elf Makefile
$(TARGET_ARCH)-objcopy -O binary $(BUILD_DIR)/$(BUILD_NAME).elf $(BUILD_DIR)/$(BUILD_NAME).mb
$(BUILD_DIR)/$(BUILD_NAME).mb: $(BUILD_DIR)/$(BUILD_NAME).elf
$(TARGET_ARCH)-objcopy -O binary $(BUILD_DIR)/$(BUILD_NAME).elf \
$(BUILD_DIR)/$(BUILD_NAME).mb

$(BUILD_DIR)/$(BUILD_NAME).elf: $(BUILD_DIR)/crt.o rom.ld target/$(TARGET_ARCH_RUST)/$(BUILD_MODE)/librust_basemetal_gba.a
$(TARGET_ARCH)-ld --gc-sections -t -T rom.ld -o $(BUILD_DIR)/$(BUILD_NAME).elf $(BUILD_DIR)/crt.o --library-path=target/$(TARGET_ARCH_RUST)/$(BUILD_MODE) -lrust_basemetal_gba -Map $(BUILD_DIR)/$(BUILD_NAME).map
$(BUILD_DIR)/$(BUILD_NAME).elf: $(BUILD_DIR)/crt.o rom.ld \
target/$(TARGET_ARCH_RUST)/$(BUILD_MODE)/librust_basemetal_gba.a
$(TARGET_ARCH)-ld --gc-sections -t -T rom.ld -o $(BUILD_DIR)/$(BUILD_NAME).elf \
$(BUILD_DIR)/crt.o --library-path=target/$(TARGET_ARCH_RUST)/$(BUILD_MODE) \
-lrust_basemetal_gba -Map $(BUILD_DIR)/$(BUILD_NAME).map

target/$(TARGET_ARCH_RUST)/$(BUILD_MODE)/librust_basemetal_gba.a: $(TARGET_ARCH_RUST).json Cargo.toml src/*.rs
RUST_TARGET_PATH=$(PWD) rustup run nightly `which xargo` build -v --target=$(TARGET_ARCH_RUST)
target/$(TARGET_ARCH_RUST)/$(BUILD_MODE)/librust_basemetal_gba.a: \
$(TARGET_ARCH_RUST).json Cargo.toml src/*.rs
RUST_TARGET_PATH=$(PWD) rustup run nightly `which xargo` build -v \
--target=$(TARGET_ARCH_RUST)

$(BUILD_DIR)/crt.o: crt.S
$(TARGET_ARCH)-as crt.S -o $(BUILD_DIR)/crt.o
Expand Down
2 changes: 1 addition & 1 deletion arm-none-eabi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"relocation-model": "static",
"archive-format": "gnu",
"target-env": "gnu",
"no-compiler-rt": false,
"no-compiler-rt": true,
"linker-is-gnu": true,
"disable-redzone": true,
"cpu": "arm7tdmi"
Expand Down
30 changes: 3 additions & 27 deletions crt.S
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
.text

.global _start
.global _start
_start:
b entry @ Branch to entry()
b entry @ Branch to entry()
loop:
b loop

@ multi-threading is also not supportd
.global __sync_val_compare_and_swap_1
.global __sync_val_compare_and_swap_2
.global __sync_val_compare_and_swap_4
__sync_val_compare_and_swap_1:
__sync_val_compare_and_swap_2:
__sync_val_compare_and_swap_4:
1: b 1b

@ floating point operations are not supported
.global __aeabi_ul2f
.global __aeabi_ul2d
.global __aeabi_fmul
.global __aeabi_fdiv
.global __aeabi_dmul
.global __aeabi_ddiv
__aeabi_ul2f:
__aeabi_ul2d:
__aeabi_fmul:
__aeabi_fdiv:
__aeabi_dmul:
__aeabi_ddiv:
1: b 1b
b loop
32 changes: 32 additions & 0 deletions src/font.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// kotetuco, 2017
//

use font_def::FONT_DATAS;

pub struct Font {
size_width: u16,
size_height: u16,
}

impl Font {
pub fn new() -> Self {
Font {
size_width: 8,
size_height: 16,
}
}

pub fn get_character(&self, ch: char) -> [u8; 16] {
let index = ch as usize;
return FONT_DATAS[index];
}

pub fn font_width(&self) -> u16 {
return self.size_width;
}

pub fn font_height(&self) -> u16 {
return self.size_height;
}
}
Loading

0 comments on commit 78aab45

Please sign in to comment.