refactored

This commit is contained in:
Wolfgang Hottgenroth 2024-03-26 15:05:39 +01:00
parent bd11d12620
commit 9ddb747f16
5 changed files with 50 additions and 60 deletions

View File

@ -1,13 +0,0 @@
#include <stdint.h>
#include "notes.h"
const uint16_t frequencyCodes[8][12] = {
{ 06535, 06234, 05747, 05474, 05233, 05002, 04563, 04353, 04153, 03762, 03600, 03424 },
{ 03256, 03116, 02764, 02636, 02515, 02401, 02271, 02165, 02065, 01771, 01700, 01612 },
{ 01527, 01447, 01372, 01317, 01247, 01201, 01135, 01073, 01033, 00774, 00740, 00705 },
{ 00654, 00624, 00575, 00550, 00523, 00500, 00456, 00435, 00415, 00376, 00360, 00342 },
{ 00326, 00312, 00276, 00264, 00252, 00240, 00227, 00217, 00207, 00177, 00170, 00161 },
{ 00153, 00145, 00137, 00132, 00125, 00120, 00114, 00107, 00103, 00100, 00074, 00071 },
{ 00065, 00062, 00060, 00055, 00052, 00050, 00046, 00044, 00042, 00040, 00036, 00034 },
{ 00033, 00031, 00030, 00026, 00025, 00024, 00023, 00022, 00021, 00020, 00017, 00016 }
};

View File

@ -1,45 +0,0 @@
#ifndef _NOTES_H_
#define _NOTES_H_
typedef enum {
e_O_1 = 0,
e_O_2,
e_O_3,
e_O_4,
e_O_5,
e_O_6,
e_O_7,
e_O_8
} t_octave;
typedef enum {
e_C = 0,
e_Cis,
e_D,
e_Dis,
e_E,
e_F,
e_Fis,
e_G,
e_Gis,
e_A,
e_Ais,
e_H
} t_note;
// length of notes in multiples of 25ms
typedef enum {
e_L_1 = 80,
e_L_1_2 = 40,
e_L_1_4 = 20,
e_L_1_8 = 10,
e_L_1_16 = 5
} t_noteLength;
extern const uint16_t frequencyCodes[8][12];
#endif // _NOTES_H_

View File

@ -7,6 +7,19 @@
#include "notes.h"
const uint16_t frequencyCodes[8][12] = {
{ 06535, 06234, 05747, 05474, 05233, 05002, 04563, 04353, 04153, 03762, 03600, 03424 },
{ 03256, 03116, 02764, 02636, 02515, 02401, 02271, 02165, 02065, 01771, 01700, 01612 },
{ 01527, 01447, 01372, 01317, 01247, 01201, 01135, 01073, 01033, 00774, 00740, 00705 },
{ 00654, 00624, 00575, 00550, 00523, 00500, 00456, 00435, 00415, 00376, 00360, 00342 },
{ 00326, 00312, 00276, 00264, 00252, 00240, 00227, 00217, 00207, 00177, 00170, 00161 },
{ 00153, 00145, 00137, 00132, 00125, 00120, 00114, 00107, 00103, 00100, 00074, 00071 },
{ 00065, 00062, 00060, 00055, 00052, 00050, 00046, 00044, 00042, 00040, 00036, 00034 },
{ 00033, 00031, 00030, 00026, 00025, 00024, 00023, 00022, 00021, 00020, 00017, 00016 }
};
#define ADDR_DATA_REG P2OUT
#define BUS_CTRL_REG P1OUT
#define BC1 BIT3

View File

@ -1,8 +1,43 @@
#ifndef _PSG_H_
#define _PSG_H_
void psgInit();
typedef enum {
e_O_1 = 0,
e_O_2,
e_O_3,
e_O_4,
e_O_5,
e_O_6,
e_O_7,
e_O_8
} t_octave;
typedef enum {
e_C = 0,
e_Cis,
e_D,
e_Dis,
e_E,
e_F,
e_Fis,
e_G,
e_Gis,
e_A,
e_Ais,
e_H
} t_note;
typedef enum {
e_L_1 = 80,
e_L_1_2 = 40,
e_L_1_4 = 20,
e_L_1_8 = 10,
e_L_1_16 = 5
} t_noteLength;
void psgInit();
void psgPlayTone(uint8_t channel, t_octave octave, t_note note);

View File

@ -6,7 +6,7 @@
#define MAX_NUM_OF_TASKS 2
#define MAX_NUM_OF_TASKS 8
typedef struct {