# HG changeset patch # User Mychaela Falconia # Date 1622350230 0 # Node ID 158dd05fb9f95634f6916c79e973abf1a1d59730 # Parent 9092ff68e37d6cc496a25bd66d68141cef89dc02 buzplayer: implement PWT mode melody play diff -r 9092ff68e37d -r 158dd05fb9f9 target-utils/buzplayer/melplay.c --- a/target-utils/buzplayer/melplay.c Sun May 30 04:42:05 2021 +0000 +++ b/target-utils/buzplayer/melplay.c Sun May 30 04:50:30 2021 +0000 @@ -2,12 +2,16 @@ #include "melody.h" extern struct melentry *melody_buf_start, *melody_buf_tailptr; +extern int melody_mode; #define ARMIO_LOAD_TIM (*(volatile u16 *) 0xFFFE4808) #define BUZZ_LIGHT_REG (*(volatile u16 *) 0xFFFE480E) +#define PWT_FRC_REG (*(volatile u8 *) 0xFFFE8800) +#define PWT_VCR_REG (*(volatile u8 *) 0xFFFE8801) + void -melody_play() +melody_play_bu() { struct melentry *p; int count; @@ -24,3 +28,34 @@ BUZZ_LIGHT_REG = 0; } } + +void +melody_play_pwt() +{ + struct melentry *p; + int count; + + wait_for_tdma_frame(); + for (p = melody_buf_start; p < melody_buf_tailptr; p++) { + PWT_FRC_REG = p->tone; + PWT_VCR_REG = p->vol; + for (count = p->dur; count; count--) + wait_for_tdma_frame(); + PWT_VCR_REG = 0; + } +} + +void +melody_play() +{ + switch (melody_mode) { + case 1: + melody_play_bu(); + return; + case 2: + melody_play_pwt(); + return; + default: + printf("ERROR: no melody entered\n"); + } +}