-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update xtask-build-rom & Write a rand-text example
- Loading branch information
Showing
91 changed files
with
10,905 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/target | ||
/out | ||
target/ | ||
out/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ resolver = "2" | |
members = [ | ||
"source", | ||
"xtask/*", | ||
"examples/*", | ||
] | ||
exclude = [ | ||
"ext/rust-deps" | ||
"ext/rust-deps", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "filltest" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[build] | ||
target = "avr-unknown-gnu-atmega328" | ||
rustflags = ["--emit=llvm-ir"] | ||
|
||
# [target.avr-unknown-gnu-atmega328] | ||
|
||
[unstable] | ||
build-std = ["core", "alloc"] | ||
|
||
[profile.dev] | ||
panic = "abort" | ||
|
||
[profile.release] | ||
panic = "abort" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "rand-text" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
pub mod gb { | ||
extern "C" { | ||
#[link_name="delay"] | ||
pub fn delay(delay: u16); | ||
#[link_name="waitpad __preserves_regs(b, c, h, l)"] | ||
pub fn waitpad(mask: u8) -> u8; | ||
#[link_name="waitpadup __preserves_regs(a, b, c, d, e, h, l)"] | ||
pub fn waitpadup(); | ||
} | ||
} | ||
|
||
pub mod drawing { | ||
use core::ffi::c_char; | ||
|
||
pub const GRAPHICS_WIDTH: u8 = 160; | ||
pub const GRAPHICS_HEIGHT: u8 = 144; | ||
|
||
pub const SOLID: u8 = 0x00; | ||
pub const OR: u8 = 0x01; | ||
pub const XOR: u8 = 0x02; | ||
pub const AND: u8 = 0x03; | ||
|
||
pub const WHITE: u8 = 0; | ||
pub const LTGREY: u8 = 1; | ||
pub const DKGREY: u8 = 2; | ||
pub const BLACK: u8 = 3; | ||
|
||
pub const M_NOFILL: u8 = 0; | ||
pub const M_FILL: u8 = 1; | ||
|
||
pub const SIGNED: u8 = 1; | ||
pub const UNSIGNED: u8 = 0; | ||
|
||
extern "C" { | ||
#[link_name="gprint __nonbanked"] | ||
pub fn gprint(str: *const c_char); | ||
//gprintln | ||
//gprintn | ||
//gprintf | ||
#[link_name="plot __sdcccall(0)"] | ||
pub fn plot(x: u8, y: u8, colour: u8, mode: u8); | ||
#[link_name="plot_point __sdcccall(0)"] | ||
pub fn plot_point(x: u8, y:u8); | ||
#[link_name="switch_data __sdcccall(0)"] | ||
pub fn switch_data(x: u8, y: u8, src: *const u8, dst: *const u8); | ||
#[link_name="draw_image"] | ||
pub fn draw_image(data: *const u8); | ||
#[link_name="line __sdcccall(0)"] | ||
pub fn line(x1: u8, y1: u8, x2: u8, y2: u8); | ||
#[link_name="box __sdcccall(0)"] | ||
pub fn r#box(x1: u8, y1: u8, x2: u8, y2: u8, style: u8); | ||
#[link_name="circle __sdcccall(0)"] | ||
pub fn circle(x: u8, y: u8, radius: u8, style: u8); | ||
#[link_name="getpix __sdcccall(0)"] | ||
pub fn getpix(x: u8, y: u8) -> u8; | ||
#[link_name="wrtchr __sdcccall(0)"] | ||
pub fn wrtchr(chr: i8); | ||
#[link_name="gotogxy __sdcccall(0)"] | ||
pub fn gotogxy(x: u8, y: u8); | ||
#[link_name="color __sdcccall(0)"] | ||
pub fn color(forecolor: u8, backcolor: u8, mode: u8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod gb; | ||
pub mod rand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
extern "C" { | ||
#[link_name="rand __sdcccall(0)"] | ||
pub fn rand() -> u8; | ||
#[link_name="arand __sdcccall(0)"] | ||
pub fn arand() -> u8; | ||
#[link_name="initarand __sdcccall(0)"] | ||
pub fn initarand(seed: u16); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![allow(dead_code)] | ||
#![feature(asm_experimental_arch)] | ||
|
||
mod gbdk; | ||
|
||
use core::ffi::c_char; | ||
|
||
use gbdk::{gb::{drawing::{gotogxy, gprint, plot, plot_point, LTGREY, SOLID}, gb::{delay, waitpad, waitpadup}}, rand::{initarand, rand}}; | ||
|
||
#[no_mangle] | ||
pub extern fn main() { | ||
unsafe { | ||
gprint("Getting seed\0".as_ptr() as *const c_char); | ||
gotogxy(0, 1); | ||
gprint("Push any key (1)\0".as_ptr() as *const c_char); | ||
let a: u8 = waitpad(0xFF); | ||
waitpadup(); | ||
let mut seed = a as u16; | ||
gotogxy(0, 2); | ||
gprint("Push any key (2)\0".as_ptr() as *const c_char); | ||
let b: u8 = waitpad(0xFF); | ||
waitpadup(); | ||
seed |= (b as u16) << 8; | ||
|
||
initarand(seed); | ||
|
||
loop { | ||
let r = rand(); | ||
gprint([r, 0].as_ptr() as *const c_char); | ||
} | ||
} | ||
} | ||
|
||
#[allow(unconditional_recursion)] | ||
#[cfg(not(test))] | ||
#[panic_handler] | ||
fn panic_handler_phony(_info: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#define USE_C_MEMCPY 0 | ||
#define USE_C_STRCPY 0 | ||
#define USE_C_STRCMP 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef ASM_MOS6502_STDARG_INCLUDE | ||
#define ASM_MOS6502_STDARG_INCLUDE | ||
|
||
/* sdcc pushes right to left with the real sizes, not cast up | ||
to an int. | ||
so printf(int, char, long) | ||
results in push long, push char, push int | ||
On the 6502 the stack grows down, so the things seem to be in | ||
the correct order. | ||
*/ | ||
|
||
typedef unsigned char * va_list; | ||
#define va_start(list, last) list = (unsigned char *)&last + sizeof(last) | ||
#define va_arg(list, type) *((type *)((list += sizeof(type)) - sizeof(type))) | ||
|
||
#define va_end(list) | ||
|
||
#endif |
Oops, something went wrong.