Skip to content

Commit

Permalink
Implement Thumb: * ldr Rd, [Rn, Immediate5]; * ldr Rd, [Rn, Rm]; * ld…
Browse files Browse the repository at this point in the history
…r Rd, [pc, Immediate8]; * ldr Rd, [sp, Immediate8]; * lsl Rd, Rm, Immediate5; * svc Immediate8; * push Registers; * pop Registers; * strh Rd, [Rn, Immediate5]; * lsr Rd, Rm, Immediate5; Update readme; Rework instruction functions; Improve comments; Attach license file; Initialise SP; Optimise sign-extensions; Bump dependency versions
  • Loading branch information
bjoernager committed Jul 5, 2023
1 parent f5cc136 commit a943c5b
Show file tree
Hide file tree
Showing 42 changed files with 1,849 additions and 538 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# 0.2A

* Implement Thumb:
* ldr Rd, [Rn, Immediate5]
* ldr Rd, [Rn, Rm]
* ldr Rd, [pc, Immediate8]
* ldr Rd, [sp, Immediate8]
* lsl Rd, Rm, Immediate5
* svc Immediate8
* push Registers
* pop Registers
* strh Rd, [Rn, Immediate5]
* lsr Rd, Rm, Immediate5
* Update readme
* Rework instruction functions
* Improve comments
* Attach license file
* Initialise SP
* Optimise sign-extensions
* Bump dependency versions

# 0.29

* Implement Thumb:
* mov Rd, Rm;
* movs Rd, immediate_8;
* movs Rd, immediate8;
* movs Rd, Rm;
* Update readme;
* Rename condition method to check_condition;
Expand Down
661 changes: 661 additions & 0 deletions COPYING

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "luma"
version = "0.41.0"
version = "0.42.0"
authors = ["Gabriel Jensen"]
edition = "2021"
description = "AGB emulator."
Expand All @@ -20,4 +20,4 @@ lto = true
toml = "0.7.5"
libc = "0.2.147"
sdl2 = "0.35.2"
serde = { version = "1.0.164", features = ["derive"] }
serde = { version = "1.0.166", features = ["derive"] }
54 changes: 33 additions & 21 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

Copyright 2021-2023 Gabriel Jensen.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.

- ABOUT

Expand All @@ -27,7 +27,7 @@ Invoke the emulator via the 'luma' command.

- CONFIGURATION

The emulator tries to read the configuration file at '${HOME}/.luma.toml'. If
The emulator tries to read the configuration file at '${HOME}/.luma.toml'. If
this file is found, the following fields are read (if present):

luma:
Expand All @@ -44,30 +44,42 @@ These settings are overwritten by terminal parameters (see USAGE).

- COMPATIBILITY

Currently, the emulator supports the following ARM instructions only. Others
Currently, the emulator supports the following ARM instructions only. Others
will be skipped.

* b{cond}{l} +/-offset_24
* bx Rm
* ldr{cond} Rn, +/-offset_12
* b{cond}{l} Immediate24
* bx{cond} Rm
* ldr{cond} Rd, [Rn, Immediate12]
* mov{cond} Rd, Rn
* mov{cond} Rd, immediate_8
* mov{cond} Rd, #Immediate8
* mov{cons}s r15, Rn
* str{cond} Rn, +/-offset_12
* str{cond} Rd, [Rn, Immediate12]

Moreover, the following Thumb instructions are supported:

* b +/-offset_11
* b{cond} +/-offset_8
* b Immediate11
* b{cond} Immediate8
* bl Immediate24
* bx Rm
* ldr Rd, [Rn, Immediate5]
* ldr Rd, [Rn, Rm]
* ldr Rd, [r13, Immediate8]
* ldr Rd, [r15, Immediate8]
* lsl Rd, Rm, Immediate5
* lsr Rd, Rm, Immediate5
* mov Rd, Rn
* movs Rd, immediate_8
* movs Rd, Immediate8
* movs Rd, Rn
* pop Registers
* push Registers
* strh Rd, [Rn, Immediate5]
* svc Immediate8

When the virtual processor boots, the default mode is the sys mode. As no
supported instruction can change this mode, this is also the only mode for now.
When the virtual processor boots, the default mode is the sys mode. This can be
changed using the 'svc Immediate8' (Thumb) or 'svc Immediate24' (ARM)
instructions, which changes this to the svc mode.

The entire memory space (0x00000000 to 0x0E010000, exclusive) is available,
The entire memory space (0x00000000 to 0x0E010000, exclusive) is available,
however, no I/O-mapped addresses are currently functional.

Improved support is, of course, planned.
35 changes: 21 additions & 14 deletions src/luma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This file is part of Luma.
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3
of the License, or (at your option) any later
the Free Software Foundation, either version 3
of the License, or (at your option) any later
version.
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU
Affero General Public License along with Luma. If not,
see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU
Affero General Public License along with Luma.
If not, see <https://www.gnu.org/licenses/>.
*/

pub mod application;
Expand All @@ -32,15 +32,22 @@ pub struct VersionType<T> {

pub const VERSION: VersionType::<u32> = VersionType::<u32> {
major: 0x0,
minor: 0x29,
minor: 0x2A,
};

pub struct WidthHeight<T> {
width: T,
height: T,
}

pub const CONFIGURATION_VERSION: u32 = 0x0;

pub const MEMORY_SIZE: usize = 0x0E010000;

pub const BOOTLOADER_SIZE: usize = 0x00004000;
pub const IMAGE_SIZE: usize = 0x02000000;

pub const SCREEN_WIDTH: u8 = 0xF0;
pub const SCREEN_HEIGHT: u8 = 0xA0;
pub const SCREEN_SIZE: WidthHeight::<u8> = WidthHeight::<u8> {
width: 0xF0,
height: 0xA0,
};
22 changes: 11 additions & 11 deletions src/luma/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This file is part of Luma.
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3
of the License, or (at your option) any later
the Free Software Foundation, either version 3
of the License, or (at your option) any later
version.
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU
Affero General Public License along with Luma. If not,
see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU
Affero General Public License along with Luma.
If not, see <https://www.gnu.org/licenses/>.
*/

use crate::luma::configuration::Configuration;
Expand Down
22 changes: 11 additions & 11 deletions src/luma/application/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This file is part of Luma.
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3
of the License, or (at your option) any later
the Free Software Foundation, either version 3
of the License, or (at your option) any later
version.
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU
Affero General Public License along with Luma. If not,
see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU
Affero General Public License along with Luma.
If not, see <https://www.gnu.org/licenses/>.
*/

use crate::luma::application::Application;
Expand Down
26 changes: 13 additions & 13 deletions src/luma/application/initialise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
This file is part of Luma.
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3
of the License, or (at your option) any later
the Free Software Foundation, either version 3
of the License, or (at your option) any later
version.
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU
Affero General Public License along with Luma. If not,
see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU
Affero General Public License along with Luma.
If not, see <https://www.gnu.org/licenses/>.
*/

use crate::luma::{SCREEN_HEIGHT, SCREEN_WIDTH};
use crate::luma::{SCREEN_SIZE};
use crate::luma::application::{Application, GOT_SIGNAL};
use crate::luma::configuration::Configuration;
use crate::luma::device::Device;
Expand Down Expand Up @@ -53,7 +53,7 @@ impl Application {
let sdl = sdl2::init().expect("unable to initialise sdl2");
let sdl_video = sdl.video().expect("unable to initialise sdl2");

let window = sdl_video.window("luma", SCREEN_WIDTH as u32 * configuration.scale, SCREEN_HEIGHT as u32 * configuration.scale).position_centered().build().unwrap();
let window = sdl_video.window("luma", SCREEN_SIZE.width as u32 * configuration.scale, SCREEN_SIZE.height as u32 * configuration.scale).position_centered().build().unwrap();

return Application {
configuration: configuration.clone(),
Expand Down
22 changes: 11 additions & 11 deletions src/luma/application/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This file is part of Luma.
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3
of the License, or (at your option) any later
the Free Software Foundation, either version 3
of the License, or (at your option) any later
version.
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU
Affero General Public License along with Luma. If not,
see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU
Affero General Public License along with Luma.
If not, see <https://www.gnu.org/licenses/>.
*/

use crate::luma::application::Application;
Expand Down
24 changes: 12 additions & 12 deletions src/luma/application/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This file is part of Luma.
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Luma is free software: you can redistribute it
and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3
of the License, or (at your option) any later
the Free Software Foundation, either version 3
of the License, or (at your option) any later
version.
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Luma is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU
Affero General Public License along with Luma. If not,
see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU
Affero General Public License along with Luma.
If not, see <https://www.gnu.org/licenses/>.
*/

use crate::luma::VERSION;
Expand Down Expand Up @@ -59,7 +59,7 @@ impl Application {

(self.device.decode)(&mut self.device);

sleep(Duration::from_secs(0x1));
sleep(Duration::from_millis(250));
}
}
}
Loading

0 comments on commit a943c5b

Please sign in to comment.