Skip to content

Commit

Permalink
Add Note Mode to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
JerwuQu committed Apr 18, 2024
1 parent 88eb6cd commit 537cda5
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions cli/assets/templates/assemblyscript/src/wasm4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const TONE_MODE3: u32 = 8;
export const TONE_MODE4: u32 = 12;
export const TONE_PAN_LEFT: u32 = 16;
export const TONE_PAN_RIGHT: u32 = 32;
export const TONE_NOTE_MODE: u32 = 64;

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/c/src/wasm4.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void tone (uint32_t frequency, uint32_t duration, uint32_t volume, uint32_t flag
#define TONE_MODE4 12
#define TONE_PAN_LEFT 16
#define TONE_PAN_RIGHT 32
#define TONE_NOTE_MODE 64

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/c3/cart/src/wasm4.c3
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const TONE_MODE3 = 8;
const TONE_MODE4 = 12;
const TONE_PAN_LEFT = 16;
const TONE_PAN_RIGHT = 32;
const TONE_NOTE_MODE = 64;

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/d/source/wasm4.d
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ enum toneMode3 = 8;
enum toneMode4 = 12;
enum tonePanLeft = 16;
enum tonePanRight = 32;
enum toneNoteMode = 64;

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/go/w4/wasm4.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const TONE_MODE3 = 8
const TONE_MODE4 = 12
const TONE_PAN_LEFT = 16
const TONE_PAN_RIGHT = 32
const TONE_NOTE_MODE = 64

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/nelua/src/wasm4.nelua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ global TONE_MODE3 <comptime> = 8
global TONE_MODE4 <comptime> = 12
global TONE_PAN_LEFT <comptime> = 16
global TONE_PAN_RIGHT <comptime> = 32
global TONE_NOTE_MODE <comptime> = 64

-- ┌───────────────────────────────────────────────────────────────────────────┐
-- │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/nim/src/cart/wasm4.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const
TONE_MODE4* = 12
TONE_PAN_LEFT* = 16
TONE_PAN_RIGHT* = 32
TONE_NOTE_MODE* = 64

{.push importc, codegenDecl: "__attribute__((import_name(\"$2\"))) $1 $2$3".}
proc blit*(data: ptr uint8; x: int32; y: int32; width: uint32; height: uint32;
Expand Down
12 changes: 8 additions & 4 deletions cli/assets/templates/odin/src/w4/wasm4_wasm32.odin
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ Tone_Pan :: enum u32 {
Left = 16,
Right = 32,
}
Tone_Mode :: enum u32 {
Frequency = 0,
Note = 64,
}

Tone_Duration :: struct {
attack: u8, // in frames
Expand All @@ -135,13 +139,13 @@ foreign wasm4 {
}

// Plays a sound tone.
tone :: proc "c" (frequency: u32, duration: u32, volume_percent: u32, channel: Tone_Channel, duty_cycle := Tone_Duty_Cycle.Eigth, pan := Tone_Pan.Center) {
flags := u32(channel) | u32(duty_cycle) | u32(pan)
tone :: proc "c" (frequency: u32, duration: u32, volume_percent: u32, channel: Tone_Channel, duty_cycle := Tone_Duty_Cycle.Eigth, pan := Tone_Pan.Center, tone_mode := Tone_Mode.Frequency) {
flags := u32(channel) | u32(duty_cycle) | u32(pan) | u32(tone_mode)
internal_tone(frequency, duration, volume_percent, flags)
}

tone_complex :: proc "c" (start_frequency, end_frequency: u16, duration: Tone_Duration, volume_percent: u32, channel: Tone_Channel, duty_cycle := Tone_Duty_Cycle.Eigth, pan := Tone_Pan.Center) {
flags := u32(channel) | u32(duty_cycle) | u32(pan)
tone_complex :: proc "c" (start_frequency, end_frequency: u16, duration: Tone_Duration, volume_percent: u32, channel: Tone_Channel, duty_cycle := Tone_Duty_Cycle.Eigth, pan := Tone_Pan.Center, tone_mode := Tone_Mode.Frequency) {
flags := u32(channel) | u32(duty_cycle) | u32(pan) | u32(tone_mode)
frequency := u32(start_frequency) | u32(end_frequency)<<16
duration_in_frames := u32(duration.attack)<<24 | u32(duration.delay)<<16 | u32(duration.release)<<8 | u32(duration.sustain)

Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/penne/src/wasm4.pn
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub const TONE_MODE3: u32 = 8;
pub const TONE_MODE4: u32 = 12;
pub const TONE_PAN_LEFT: u32 = 16;
pub const TONE_PAN_RIGHT: u32 = 32;
pub const TONE_NOTE_MODE: u32 = 64;

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/rust/src/wasm4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ pub const TONE_MODE3: u32 = 8;
pub const TONE_MODE4: u32 = 12;
pub const TONE_PAN_LEFT: u32 = 16;
pub const TONE_PAN_RIGHT: u32 = 32;
pub const TONE_NOTE_MODE: u32 = 64;

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/wat/main.wat
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
(global $TONE_MODE4 i32 (i32.const 12))
(global $TONE_PAN_LEFT i32 (i32.const 16))
(global $TONE_PAN_RIGHT i32 (i32.const 32))
(global $TONE_NOTE_MODE i32 (i32.const 64))


;; smiley
Expand Down
1 change: 1 addition & 0 deletions cli/assets/templates/zig/src/wasm4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub const TONE_MODE3: u32 = 8;
pub const TONE_MODE4: u32 = 12;
pub const TONE_PAN_LEFT: u32 = 16;
pub const TONE_PAN_RIGHT: u32 = 32;
pub const TONE_NOTE_MODE: u32 = 64;

// ┌───────────────────────────────────────────────────────────────────────────┐
// │ │
Expand Down

0 comments on commit 537cda5

Please sign in to comment.