mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 11:16:42 +01:00
add playNote fn and bell chr (7)
This commit is contained in:
@@ -33,6 +33,7 @@ import "env.setCursorPosition" fn setCursorPosition(i32, i32);
|
|||||||
import "env.rectangle_outline" fn rectangle_outline(f32, f32, f32, f32, i32);
|
import "env.rectangle_outline" fn rectangle_outline(f32, f32, f32, f32, i32);
|
||||||
import "env.circle_outline" fn circle_outline(f32, f32, f32, i32);
|
import "env.circle_outline" fn circle_outline(f32, f32, f32, i32);
|
||||||
import "env.exp" fn exp(f32) -> f32;
|
import "env.exp" fn exp(f32) -> f32;
|
||||||
|
import "env.playNote" fn playNote(i32, i32);
|
||||||
|
|
||||||
const TIME_MS = 0x40;
|
const TIME_MS = 0x40;
|
||||||
const GAMEPAD = 0x44;
|
const GAMEPAD = 0x44;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
(import "env" "rectangle_outline" (func $rectangle_outline (param f32) (param f32) (param f32) (param f32) (param i32)))
|
(import "env" "rectangle_outline" (func $rectangle_outline (param f32) (param f32) (param f32) (param f32) (param i32)))
|
||||||
(import "env" "circle_outline" (func $circle_outline (param f32) (param f32) (param f32) (param i32)))
|
(import "env" "circle_outline" (func $circle_outline (param f32) (param f32) (param f32) (param i32)))
|
||||||
(import "env" "exp" (func $exp (param f32) (result f32)))
|
(import "env" "exp" (func $exp (param f32) (result f32)))
|
||||||
|
(import "env" "playNote" (func $playNote (param i32) (param i32)))
|
||||||
|
|
||||||
;; to use defines, include this file with a preprocessor
|
;; to use defines, include this file with a preprocessor
|
||||||
;; like gpp (https://logological.org/gpp).
|
;; like gpp (https://logological.org/gpp).
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -339,6 +339,11 @@ fn printSingleChar(char: i32) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if char == 7 {
|
||||||
|
80?0 = 80?0 ^ 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if char == 8 {
|
if char == 8 {
|
||||||
textCursorX = textCursorX - 8;
|
textCursorX = textCursorX - 8;
|
||||||
if !graphicsText & textCursorX < 0 {
|
if !graphicsText & textCursorX < 0 {
|
||||||
@@ -509,6 +514,26 @@ export fn setCursorPosition(x: i32, y: i32) {
|
|||||||
|
|
||||||
include "ges.cwa"
|
include "ges.cwa"
|
||||||
|
|
||||||
|
export fn playNote(channel: i32, note: i32) {
|
||||||
|
(channel * 6)?80 = (channel * 6)?80 & 0xfe ^ if note {
|
||||||
|
(channel * 6)?83 = note & 127;
|
||||||
|
2 | !(note >> 7)
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
data 80 {
|
||||||
|
i8(
|
||||||
|
0x80, 0xc0, 0, 81, 0xa0, 0x50,
|
||||||
|
0xc4, 0, 0, 69, 0x60, 0x40,
|
||||||
|
0x44, 0xb0, 0, 69, 0x90, 0x43,
|
||||||
|
0x4, 0xf0, 0, 69, 0xa4, 0x44,
|
||||||
|
0xff, 0xff,
|
||||||
|
1, 1, 0, 100, 0, 100
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// SETUP //
|
// SETUP //
|
||||||
///////////
|
///////////
|
||||||
@@ -565,17 +590,6 @@ start fn setup() {
|
|||||||
randomSeed(random());
|
randomSeed(random());
|
||||||
}
|
}
|
||||||
|
|
||||||
data 80 {
|
|
||||||
i8(
|
|
||||||
0, 128, 0, 69, 0x8, 0xc8,
|
|
||||||
0, 128, 0, 69, 0x8, 0xc8,
|
|
||||||
0, 128, 0, 69, 0x8, 0xc8,
|
|
||||||
0, 128, 0, 69, 0x8, 0xc8,
|
|
||||||
0xff, 0xff,
|
|
||||||
1, 1, 0, 100, 0, 100
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
data 0x12c78 {
|
data 0x12c78 {
|
||||||
i32(80)
|
i32(80)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ impl BaseModule {
|
|||||||
|
|
||||||
add_function(&mut functions, &type_map, "exp", &[F32], Some(F32));
|
add_function(&mut functions, &type_map, "exp", &[F32], Some(F32));
|
||||||
|
|
||||||
|
add_function(&mut functions, &type_map, "playNote", &[I32, I32], None);
|
||||||
|
|
||||||
for i in functions.len()..64 {
|
for i in functions.len()..64 {
|
||||||
add_function(
|
add_function(
|
||||||
&mut functions,
|
&mut functions,
|
||||||
@@ -291,7 +293,10 @@ impl BaseModule {
|
|||||||
|
|
||||||
pub fn write_as_cwa<P: AsRef<Path>>(&self, path: P) -> Result<()> {
|
pub fn write_as_cwa<P: AsRef<Path>>(&self, path: P) -> Result<()> {
|
||||||
fn inner(mut file: File, base: &BaseModule) -> Result<()> {
|
fn inner(mut file: File, base: &BaseModule) -> Result<()> {
|
||||||
writeln!(file, "// MicroW8 APIs, to be `include`d in CurlyWas sources")?;
|
writeln!(
|
||||||
|
file,
|
||||||
|
"// MicroW8 APIs, to be `include`d in CurlyWas sources"
|
||||||
|
)?;
|
||||||
writeln!(file, "import \"env.memory\" memory({});", base.memory)?;
|
writeln!(file, "import \"env.memory\" memory({});", base.memory)?;
|
||||||
writeln!(file)?;
|
writeln!(file)?;
|
||||||
for &(module, ref name, type_id) in &base.function_imports {
|
for &(module, ref name, type_id) in &base.function_imports {
|
||||||
@@ -402,5 +407,5 @@ const CONSTANTS: &[(&str, u32)] = &[
|
|||||||
("BUTTON_A", 4),
|
("BUTTON_A", 4),
|
||||||
("BUTTON_B", 5),
|
("BUTTON_B", 5),
|
||||||
("BUTTON_X", 6),
|
("BUTTON_X", 6),
|
||||||
("BUTTON_Y", 7)
|
("BUTTON_Y", 7),
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user