Skip to content

Commit

Permalink
Support load and store instructions; Update messages; Implement some …
Browse files Browse the repository at this point in the history
…move instructions; Update log function; Add equivalent write functions; Fix conditional execution; Fix branch; Add device helper structure; Update trap print; Reenable overflow checks; License under AGPL3; Fix default configuration not being made; Update readme; Add spsr registers;
  • Loading branch information
bjoernager committed Jul 1, 2023
1 parent d8781b7 commit 9a19307
Show file tree
Hide file tree
Showing 37 changed files with 1,102 additions and 266 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 0.25

* Support load and store instructions;
* Update messages;
* Implement some move instructions;
* Update log function;
* Add equivalent write functions;
* Fix conditional execution;
* Fix branch;
* Add device helper structure;
* Update trap print;
* Reenable overflow checks;
* License under AGPL3;
* Fix default configuration not being made;
* Update readme;
* Add spsr registers;

# 0.24

* Bump dependency versions;
Expand Down
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "luma"
version = "0.36.0"
version = "0.37.0"
authors = ["Gabriel Jensen"]
edition = "2021"
description = "AGB emulator."
Expand All @@ -13,9 +13,6 @@ categories = ["emulators"]
name = "luma"
path = "src/main.rs"

[profile.dev]
overflow-checks = false

[profile.release]
lto = true

Expand Down
48 changes: 38 additions & 10 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,61 @@
LUMA
- LUMA

Copyright 2021-2023 Gabriel Jensen.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU 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 General Public License for more details.

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

- ABOUT

luma is an emulator for the AGB - Game Boy Advance - platform.

USAGE
- USAGE

luma [image] [bootloader]

Invoke the emulator via the 'luma' command.

CONFIGURATION
- CONFIGURATION

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:
- version: (Integer) The version of the configuration file (0)
* version: (Integer) The version of the configuration file (0)

device:
- bootloader: (String) The path to the bootloader file (home-relative)
- image: (String) The path to the image file (home-relative)
* bootloader: (String) The path to the bootloader file (home-relative)
* image: (String) The path to the image file (home-relative)

video:
- scale: (Integer) The scale modifier applied to the screen (min 1; max (2^32-1))
* scale: (Integer) The scale modifier applied to the screen (min 1; max (2^32-1))

These settings are overwritten by terminal parameters (see USAGE).

COMPATIBILITY
- COMPATIBILITY

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

* b{cond}{l}
* ldr{cond} Rn, +/-offset
* mov{cond} Rd, Rn
* mov{cons}s r15, Rn
* str{cond} Rn, +/-offset

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.

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

Currently, the emulator only supports the b{cond}{l}.w instruction. Improved
support is, of course, planned.
Improved support is, of course, planned.
44 changes: 24 additions & 20 deletions src/luma.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
// Copyright 2021-2023 Gabriel Jensen.
/*
Copyright 2021-2023 Gabriel Jensen.
This file is part of Luma.
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
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
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/>.
*/

pub mod application;
pub mod configuration;
pub mod device;

pub struct VersionType<T> {
major: T,
Expand All @@ -10,27 +32,9 @@ pub struct VersionType<T> {

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

#[allow(dead_code)]
pub enum LogType {
Branch( i32, u32),
Continue( u32),
Link( u32),
Load( u8, u32),
MoveRegister( u8, u8),
MoveImmediate(u8, u32),
Store( u32, u8),
}

#[allow(dead_code)]
pub enum TrapKind {
BadAlignment( u32, u32),
InvalidOpcode(u32, u32),
OutOfBounds( u32),
}

pub const CONFIGURATION_VERSION: u32 = 0x0;

pub const MEMORY_SIZE: usize = 0x0E010000;
Expand Down
34 changes: 24 additions & 10 deletions src/luma/application.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
// Copyright 2021-2023 Gabriel Jensen.
/*
Copyright 2021-2023 Gabriel Jensen.
This file is part of Luma.
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
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
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/>.
*/

use crate::luma::configuration::Configuration;
use crate::luma::device::Device;

extern crate sdl2;

use sdl2::{Sdl, VideoSubsystem};
use sdl2::video::Window;
use std::sync::atomic::AtomicBool;

pub mod bootloader;
pub mod decode;
pub mod drop;
pub mod image;
pub mod initialise;
pub mod load;
pub mod log;
pub mod read;
pub mod run;
pub mod trap;

pub struct Application {
configuration: Configuration,
sdl: Sdl,
sdl_video: VideoSubsystem,
window: Window,
memory: *mut u8,
registers: [u32; 0x10],
psr: u32,
device: Device,
}

pub static mut GOT_SIGNAL: AtomicBool = AtomicBool::new(false);
12 changes: 0 additions & 12 deletions src/luma/application/bootloader.rs

This file was deleted.

48 changes: 0 additions & 48 deletions src/luma/application/decode.rs

This file was deleted.

29 changes: 22 additions & 7 deletions src/luma/application/drop.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
// Copyright 2021-2023 Gabriel Jensen.
/*
Copyright 2021-2023 Gabriel Jensen.
use crate::luma::application::Application;
use crate::luma::MEMORY_SIZE;
This file is part of Luma.
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
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
Affero General Public License for more details.
use std::alloc::{dealloc, Layout};
use std::mem::size_of;
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;

impl Drop for Application {
fn drop(&mut self) {
eprintln!("ending");

unsafe { dealloc(self.memory, Layout::new::<[u32; MEMORY_SIZE / size_of::<u32>()]>()) };
}
}
12 changes: 0 additions & 12 deletions src/luma/application/image.rs

This file was deleted.

Loading

0 comments on commit 9a19307

Please sign in to comment.