├── chiptracker.png ├── Makefile ├── main.c ├── packedformat ├── fivefour.song ├── bombstrt.song ├── bomber.song ├── ncurses.h ├── stuff.h ├── README.md ├── CODE_OF_CONDUCT.md ├── extrafat.c ├── bomberin.song ├── testfm.song ├── chip.c ├── bdash.song ├── io.c ├── gui.c └── test2.song /chiptracker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pulkomandy/bitbox-chiptracker/HEAD/chiptracker.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | USE_SDCARD = 1 # allow use of SD card for io 2 | 3 | NAME = chiptracker 4 | GAME_C_FILES = main.c chip.c gui.c io.c extrafat.c \ 5 | lib/chiptune/chiptune.c lib/chiptune/player.c \ 6 | lib/textmode/textmode.c \ 7 | lib/events/events.c \ 8 | 9 | 10 | DEFINES += MAX_CHANNELS=4 FONT_W=8 FONT_H=16 11 | 12 | BITBOX ?= ../sdk 13 | 14 | include $(BITBOX)/kernel/bitbox.mk 15 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "stuff.h" 4 | 5 | void game_init() 6 | { 7 | initio(); 8 | initchip(); 9 | initgui(); 10 | clear_song(); 11 | // loadfile("bomberin.chp"); 12 | } 13 | 14 | #ifndef EMULATOR 15 | // This is needed for use of sprintf 16 | void* __attribute__((used)) _sbrk(intptr_t increment) 17 | { 18 | extern void* end; 19 | static void* ptr = &end; 20 | 21 | ptr += increment; 22 | return ptr; 23 | } 24 | 25 | void _exit() 26 | { 27 | for(;;); 28 | } 29 | 30 | // I'm not sure why this is needed. Whatever. 31 | void _read() 32 | { 33 | } 34 | 35 | void _write() 36 | { 37 | } 38 | 39 | void _close() 40 | { 41 | } 42 | 43 | void _lseek() 44 | { 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /packedformat: -------------------------------------------------------------------------------- 1 | 2 | 3 | resource 0 = song 4 | resource 1 = instrument 1 5 | ... 6 | resource 15 = instrument 15 7 | resource 16 = track 1 8 | ... 9 | 10 | resource table: 11 | xxxxxxxxxxxxx = byte offset into songdata 12 | (for each resource) 13 | 14 | song: 15 | 0xxxxxx = track x, transp 0 16 | 1xxxxxxyyyy = track x, transp y (signed) 17 | (times four, for each line) 18 | 19 | instrument: 20 | 00000000 = end 21 | 0000ccccpppppppp = command c, parameter p 22 | (for each cmd) 23 | 24 | track: 25 | 000 = blank line 26 | 100xxxxxxx = note x, instr 0 (last) 27 | 110xxxxxxxiiii = note x, instr i 28 | 001ccccpppppppp = cmd c, param p 29 | 101xxxxxxxccccpppppppp = note x, instr 0 (last), cmd c, param p 30 | 111xxxxxxxiiiiccccpppppppp = note x, instr i, cmd c, param p 31 | (for each line) 32 | -------------------------------------------------------------------------------- /fivefour.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | tracklength 14 5 | 6 | songline 00 02 00 02 00 01 00 01 00 7 | songline 01 02 00 02 00 03 00 03 00 8 | songline 02 02 ff 02 ff 01 ff 01 ff 9 | songline 03 02 fe 02 fe 03 fe 03 fe 10 | 11 | trackline 01 00 31 01 00 00 00 00 12 | trackline 01 0a 36 01 00 00 00 00 13 | trackline 02 00 41 01 00 00 00 00 14 | trackline 02 05 3d 01 00 00 00 00 15 | trackline 02 0a 42 01 00 00 00 00 16 | trackline 02 0f 46 01 00 00 00 00 17 | trackline 03 00 49 01 00 00 00 00 18 | trackline 03 04 47 01 00 00 00 00 19 | trackline 03 08 46 01 00 00 00 00 20 | trackline 03 0c 44 01 00 00 00 00 21 | trackline 03 10 42 01 00 00 00 00 22 | 23 | instrumentline 01 00 2b 25 24 | instrumentline 01 01 77 03 25 | instrumentline 01 02 76 45 26 | instrumentline 01 03 74 02 27 | instrumentline 01 04 66 f0 28 | instrumentline 01 05 76 ff 29 | instrumentline 01 06 77 02 30 | instrumentline 01 07 7e 14 31 | instrumentline 01 08 69 00 32 | 33 | 34 | -------------------------------------------------------------------------------- /bombstrt.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | songline 00 01 00 02 00 00 00 00 00 5 | songline 01 00 00 00 e0 00 00 00 00 6 | 7 | trackline 01 00 30 01 00 00 00 00 8 | trackline 01 02 2f 01 00 00 00 00 9 | trackline 01 03 30 01 00 00 00 00 10 | trackline 01 04 2f 01 00 00 00 00 11 | trackline 01 05 30 01 00 00 00 00 12 | trackline 01 06 2f 01 00 00 00 00 13 | trackline 01 07 30 01 00 00 00 00 14 | trackline 01 08 2b 01 00 00 00 00 15 | trackline 01 0a 2a 01 00 00 00 00 16 | trackline 01 0b 2b 01 00 00 00 00 17 | trackline 01 0c 2a 01 00 00 00 00 18 | trackline 01 0d 2b 01 00 00 00 00 19 | trackline 01 0e 2a 01 00 00 00 00 20 | trackline 01 0f 2b 01 00 00 00 00 21 | trackline 01 10 28 01 00 00 00 00 22 | trackline 01 11 29 01 00 00 00 00 23 | trackline 01 12 2a 01 00 00 00 00 24 | trackline 01 13 2b 01 00 00 00 00 25 | trackline 01 14 28 01 00 00 00 00 26 | trackline 01 15 29 01 00 00 00 00 27 | trackline 01 16 2a 01 00 00 00 00 28 | trackline 01 17 2b 01 00 00 00 00 29 | trackline 01 18 28 01 00 00 00 00 30 | trackline 01 1a 24 01 00 00 00 00 31 | trackline 01 1c 22 01 00 00 00 00 32 | trackline 02 00 17 01 00 00 00 00 33 | trackline 02 02 18 01 00 00 00 00 34 | trackline 02 04 17 01 00 00 00 00 35 | trackline 02 06 18 01 00 00 00 00 36 | trackline 02 08 12 01 00 00 00 00 37 | trackline 02 0a 13 01 00 00 00 00 38 | trackline 02 0c 12 01 00 00 00 00 39 | trackline 02 0e 13 01 00 00 00 00 40 | trackline 02 10 10 01 00 00 00 00 41 | trackline 02 11 11 01 00 00 00 00 42 | trackline 02 12 12 01 00 00 00 00 43 | trackline 02 13 13 01 00 00 00 00 44 | trackline 02 14 10 01 00 00 00 00 45 | trackline 02 15 11 01 00 00 00 00 46 | trackline 02 16 12 01 00 00 00 00 47 | trackline 02 17 13 01 00 00 00 00 48 | trackline 02 18 10 01 00 00 00 00 49 | trackline 02 1a 0c 01 00 00 00 00 50 | trackline 02 1c 0a 01 00 00 00 00 51 | 52 | instrumentline 01 00 2b 31 53 | instrumentline 01 01 77 02 54 | instrumentline 01 02 64 80 55 | instrumentline 01 03 76 80 56 | instrumentline 01 04 74 06 57 | instrumentline 01 05 66 fc 58 | -------------------------------------------------------------------------------- /bomber.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | songline 00 01 0c 01 00 00 00 00 00 5 | songline 01 02 00 02 f4 00 00 00 00 6 | songline 02 03 05 03 f9 00 00 00 00 7 | songline 03 04 00 04 f4 00 00 00 00 8 | 9 | trackline 01 00 1b 01 00 00 00 00 10 | trackline 01 02 1b 00 00 00 00 00 11 | trackline 01 04 27 00 00 00 00 00 12 | trackline 01 06 1b 00 00 00 00 00 13 | trackline 01 08 1e 00 00 00 00 00 14 | trackline 01 0c 22 00 00 00 00 00 15 | trackline 01 0e 24 00 00 00 00 00 16 | trackline 01 10 25 00 00 00 00 00 17 | trackline 01 14 25 00 00 00 00 00 18 | trackline 01 18 24 00 00 00 00 00 19 | trackline 02 00 25 01 00 00 00 00 20 | trackline 02 02 25 00 00 00 00 00 21 | trackline 02 04 31 00 00 00 00 00 22 | trackline 02 06 25 00 00 00 00 00 23 | trackline 02 08 28 00 00 00 00 00 24 | trackline 02 0c 2c 00 00 00 00 00 25 | trackline 02 0e 2e 00 00 00 00 00 26 | trackline 02 10 2f 00 00 00 00 00 27 | trackline 02 14 2e 00 00 00 00 00 28 | trackline 02 16 2f 00 00 00 00 00 29 | trackline 02 18 25 00 00 00 00 00 30 | trackline 02 1a 24 00 00 00 00 00 31 | trackline 02 1c 25 00 00 00 00 00 32 | trackline 03 00 1d 01 00 00 00 00 33 | trackline 03 02 1d 00 00 00 00 00 34 | trackline 03 04 29 00 00 00 00 00 35 | trackline 03 06 1d 00 00 00 00 00 36 | trackline 03 08 27 00 00 00 00 00 37 | trackline 03 0c 26 00 00 00 00 00 38 | trackline 03 0e 27 00 00 00 00 00 39 | trackline 03 10 1d 00 00 00 00 00 40 | trackline 03 14 29 00 00 00 00 00 41 | trackline 03 18 1d 00 00 00 00 00 42 | trackline 04 00 22 01 00 00 00 00 43 | trackline 04 02 22 00 00 00 00 00 44 | trackline 04 04 2e 00 00 00 00 00 45 | trackline 04 06 22 00 00 00 00 00 46 | trackline 04 08 2c 00 00 00 00 00 47 | trackline 04 0c 2b 00 00 00 00 00 48 | trackline 04 0e 2c 00 00 00 00 00 49 | trackline 04 10 22 00 00 00 00 00 50 | trackline 04 14 2e 00 00 00 00 00 51 | trackline 04 18 22 00 00 00 00 00 52 | trackline 04 1a 22 00 00 00 00 00 53 | trackline 04 1c 24 00 00 00 00 00 54 | trackline 04 1e 26 00 00 00 00 00 55 | 56 | instrumentline 01 00 2b 31 57 | instrumentline 01 01 77 02 58 | instrumentline 01 02 64 80 59 | instrumentline 01 03 76 63 60 | instrumentline 01 04 74 08 61 | instrumentline 01 05 66 f0 62 | -------------------------------------------------------------------------------- /ncurses.h: -------------------------------------------------------------------------------- 1 | /* ncurses wrapper for bitbox text mode 2 | * 3 | * Copyright 2015, Adrien Destugues 4 | * 5 | * This file is distributed under the terms of the MIT license. 6 | */ 7 | 8 | #include "lib/textmode/textmode.h" 9 | #include "lib/events/events.h" 10 | 11 | int X; 12 | int Y; 13 | extern uint8_t text_color; 14 | 15 | enum attributes{ 16 | A_NORMAL, 17 | A_REVERSE, 18 | A_BOLD 19 | }; 20 | 21 | #define LINES 30 22 | #define COLUMNS 80 23 | 24 | #define WHITE RGB(255,255,255) 25 | #define BLACK RGB(0,0,0) 26 | #define PINK RGB(200,0,200) 27 | #define LIGHTPINK RGB(255,130,255) 28 | #define RED RGB(255,0,0) 29 | #define BLUE RGB(0,0,255) 30 | #define GREEN RGB(0,255,0) 31 | #define YELLOW RGB(255,255,0) 32 | #define CYAN RGB(0,255,255) 33 | 34 | static inline void initscr() 35 | { 36 | text_color = 0; 37 | clear(); 38 | 39 | set_palette(A_NORMAL, WHITE,BLACK); // boring white on black 40 | set_palette(A_REVERSE, LIGHTPINK, PINK); // light pink on pink 41 | set_palette(A_BOLD, YELLOW, BLACK); // gold on black 42 | set_palette(3, WHITE, PINK); 43 | set_palette(4, WHITE, BLUE); 44 | set_palette(5, WHITE, GREEN); 45 | set_palette(6, WHITE, YELLOW); 46 | 47 | set_palette(A_NORMAL | 8,WHITE, BLUE); // white on blue (cursor) 48 | set_palette(A_REVERSE | 8,BLACK, BLUE); // black on blue (cursor) 49 | set_palette(A_BOLD | 8,YELLOW, BLUE); // gold on blue (cursor) 50 | } 51 | 52 | static inline void erase() 53 | { 54 | clear(); 55 | } 56 | 57 | static inline void refresh() 58 | { 59 | vram_attr[Y][X] |= 8; 60 | } 61 | 62 | static inline void mvaddstr(int y, int x, char* text) 63 | { 64 | int k = print_at(x, y, text_color, text); 65 | 66 | Y = y; 67 | X = (x + k) % 80; 68 | } 69 | 70 | static inline void addstr(char* text) 71 | { 72 | int k = print_at(X, Y, text_color, text); 73 | X = (X + k) % 80; 74 | } 75 | 76 | static inline void addch(char ch) 77 | { 78 | vram[Y][X] = ch; 79 | vram_attr[Y][X] = text_color; 80 | X++; 81 | if (X > 79) X = 0; 82 | } 83 | 84 | static inline void move(int y, int x) 85 | { 86 | X = x; 87 | Y = y; 88 | } 89 | 90 | static inline void attrset(int attr) 91 | { 92 | text_color = attr; 93 | }; 94 | 95 | 96 | static inline int getch() 97 | { 98 | struct event e = event_get(); 99 | if (e.type != evt_keyboard_press) 100 | return KEY_ERR; 101 | 102 | return e.kbd.sym; 103 | } 104 | -------------------------------------------------------------------------------- /stuff.h: -------------------------------------------------------------------------------- 1 | #define TRACKLEN 32 2 | 3 | #include 4 | #include 5 | 6 | #define NINST 40 7 | #define NINSTLINE 48 // number of lines to make an instrument 8 | //#define NTRACK 64 9 | //#define NTRACKLINE 12288 10 | #define NTRACKLINE 8192 11 | // note that 8192 = 32*256 is the total number of tracklines you'd expect 12 | // with the old constraints (32 notes/track, 256 tracks total) 13 | 14 | void message (const char *fmt, ...); 15 | 16 | typedef uint8_t u8; 17 | typedef uint16_t u16; 18 | typedef int8_t s8; 19 | typedef int16_t s16; 20 | typedef uint32_t u32; 21 | 22 | struct trackline { 23 | u8 note; 24 | u8 instr; 25 | u8 cmd[2]; 26 | u8 param[2]; 27 | }; 28 | 29 | /* 30 | struct track { 31 | struct trackline line[256]; 32 | }; 33 | */ 34 | 35 | struct instrline { 36 | u8 cmd; 37 | u8 param; 38 | u8 cmd2; 39 | u8 param2; 40 | }; 41 | 42 | struct instrument { 43 | int length; 44 | struct instrline line[NINSTLINE]; 45 | }; 46 | 47 | struct songline { 48 | u8 track[4]; 49 | u8 transp[4]; 50 | }; 51 | 52 | 53 | void initchip(); 54 | void playroutine(); 55 | 56 | void readsong(int pos, uint8_t ch, u8 *dest); 57 | void readtrack(uint8_t num, uint8_t pos, struct trackline *tl); 58 | void readinstr(uint8_t num, uint8_t pos, u8 *il); 59 | 60 | void silence(); 61 | void iedplonk(int, int); 62 | 63 | void initgui(); 64 | void guiloop(); 65 | int packcmd(u8 ch); 66 | 67 | void startplaysong(int); 68 | void startplaytrack(int); 69 | 70 | // input/output stuff 71 | void initio(); 72 | bool loadfile(char *); 73 | void savefile(char *); 74 | void clear_song(); 75 | 76 | extern u8 trackpos; 77 | extern u8 playtrack; 78 | extern u8 playsong; 79 | extern u16 songpos; 80 | extern u16 songlen; 81 | extern u16 numtracks; 82 | extern u8 songspeed; 83 | extern int tracklen; 84 | 85 | extern struct songline song[256]; 86 | //extern struct track track[NTRACK]; 87 | extern struct trackline tracking[NTRACKLINE]; 88 | extern struct instrument instrument[NINST]; 89 | inline struct trackline *track(uint8_t track_index, uint8_t track_pos) 90 | { 91 | return &tracking[(track_index-1)*tracklen + track_pos]; 92 | } 93 | int realign_tracks(int new_tracklen); 94 | 95 | extern char filename[13]; // FatFS short filename constraints: 8.3 + null char 96 | 97 | 98 | extern char alert[32]; 99 | void setalert(const char *alerto); 100 | 101 | void redrawgui(); 102 | int rsscanf(const char* str, const char* format, ...); 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chiptracker 2 | 3 | Chip tracker for the bitbox, based on [lft's Hardware Chiptune](http://www.linusakesson.net/hardware/chiptune.php) 4 | 5 | ![screenshot](chiptracker.png) 6 | 7 | ## Updated documentation (things that changed from lft's original tracker) 8 | 9 | Start the tracker by loading the binary from the bitbox bootloader, or use the 10 | emulator version. 11 | 12 | * Press Ctrl+O to list and load files (from SD card or current directory in emu). 13 | * Press Ctrl+F to change the file name, then Ctrl+W to save. 14 | * Press space to play/pause, enter to toggle edit mode 15 | * In the emulator, press escape to exit. On real hardware, use the reset button. 16 | 17 | Don't worry, there are on-screen hints to all this. 18 | 19 | ## Original Documentation (with out of date information removed) 20 | 21 | Hi! 22 | 23 | This is the tracker I used in the 24 | [hardware chiptune project](http://www.linusakesson.net/hardware/chiptune.php). 25 | It was never intended to 26 | be used by anyone other than me, so it's not exactly user friendly. 27 | 28 | This is a quick documentation attempt. 29 | 30 | Once you've started the tracker, you'll see that the screen is divided into 31 | three sections: song, track and instrument. Use TAB to move between these 32 | sections. Alternatively, if you're in the song section and the cursor is on a 33 | track identifier, you can press ` (backquote) to start editing this track. 34 | 35 | Use { and } to change the current track, and [ and ] to change the current 36 | instrument. Use enter to start playing the current track (in the track section) 37 | or the song (in the song section). Use space to stop playing or to enter edit 38 | mode. 39 | 40 | Use < and > to change the current octave. The main part of the keyboard is used 41 | to enter notes. The keyboard layout is adapted for a US qwerty keymap. You can 42 | edit gui.c to change this to fit a Dvorak keymap instead. 43 | 44 | Press ^W ("write") to save. Press 45 | \# to optimize the song (remove unused tracks, move tracks together). 46 | 47 | In the song and instrument editors, use capital A, I and D to add, insert and 48 | delete lines. In the track and instrument editors, use capital C and V for copy 49 | and paste. 50 | 51 | A line in the instrument editor is either a command, a relative note or an 52 | absolute note. Relative notes are indicated by + in the command column, 53 | absolute notes by =. Commands in the instrument editor are the same as commands 54 | in the track editor. 55 | 56 | The available commands are: 57 | 58 | dxx Set duty cycle (pulse width) to xx. 59 | fxx Set volume fade speed to xx. So, fff is a slow fadeout, f01 is a slow fadein. 60 | ixx Set channel inertia. A high inertia causes automatic slides between notes. Default 0. 61 | jxx Jump to instrument line xx. Used to create arpeggio loops. 62 | Warning: The loop must contain a delay element (t command), otherwise you'll crash the software. 63 | lxx Set sLide. So, lff is a slow slide down, l01 is a slow slide up. 64 | mxx Set pulse width modulation rate to xx. 65 | txx Wait xx time units. 66 | vxx Set channel volume to xx. 67 | wxx Set waveform. 00 = triangle, 01 = saw, 02 = pulse, 03 = noise. 68 | ~xy Set vibrato. x = depth, y = rate. 69 | 70 | Investigate test2.song, and play around, and you'll probably get the hang of 71 | things! 72 | 73 | Good luck! 74 | 75 | Linus (lft^kryo) 76 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at pulkomandy@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /extrafat.c: -------------------------------------------------------------------------------- 1 | #include "fatfs/ff.h" 2 | #include // va_list 3 | 4 | // bringing in some fat functions (from ff.c) 5 | 6 | /*----------------------------------------------------------------------------/ 7 | / FatFs - FAT file system module R0.10a (C)ChaN, 2014 8 | /-----------------------------------------------------------------------------/ 9 | / FatFs module is a generic FAT file system module for small embedded systems. 10 | / This is a free software that opened for education, research and commercial 11 | / developments under license policy of following terms. 12 | / 13 | / Copyright (C) 2014, ChaN, all right reserved. 14 | / 15 | / * The FatFs module is a free software and there is NO WARRANTY. 16 | / * No restriction on use. You can use, modify and redistribute it for 17 | / personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. 18 | / * Redistributions of source code must retain the above copyright notice. 19 | / 20 | /-----------------------------------------------------------------------------*/ 21 | 22 | /* Character code support macros */ 23 | 24 | #define IsUpper(c) (((c)>='A')&&((c)<='Z')) 25 | #define IsLower(c) (((c)>='a')&&((c)<='z')) 26 | #define IsDigit(c) (((c)>='0')&&((c)<='9')) 27 | 28 | typedef struct { 29 | FIL* fp; 30 | int idx, nchr; 31 | BYTE buf[64]; 32 | } putbuff; 33 | 34 | static 35 | void putc_bfd ( 36 | putbuff* pb, 37 | TCHAR c 38 | ) 39 | { 40 | UINT bw; 41 | int i; 42 | 43 | 44 | if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ 45 | putc_bfd(pb, '\r'); 46 | 47 | i = pb->idx; /* Buffer write index (-1:error) */ 48 | if (i < 0) return; 49 | 50 | #if _USE_LFN && _LFN_UNICODE 51 | #if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ 52 | if (c < 0x80) { /* 7-bit */ 53 | pb->buf[i++] = (BYTE)c; 54 | } else { 55 | if (c < 0x800) { /* 11-bit */ 56 | pb->buf[i++] = (BYTE)(0xC0 | c >> 6); 57 | } else { /* 16-bit */ 58 | pb->buf[i++] = (BYTE)(0xE0 | c >> 12); 59 | pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); 60 | } 61 | pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); 62 | } 63 | #elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ 64 | pb->buf[i++] = (BYTE)(c >> 8); 65 | pb->buf[i++] = (BYTE)c; 66 | #elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ 67 | pb->buf[i++] = (BYTE)c; 68 | pb->buf[i++] = (BYTE)(c >> 8); 69 | #else /* Write a character in ANSI/OEM */ 70 | c = ff_convert(c, 0); /* Unicode -> OEM */ 71 | if (!c) c = '?'; 72 | if (c >= 0x100) 73 | pb->buf[i++] = (BYTE)(c >> 8); 74 | pb->buf[i++] = (BYTE)c; 75 | #endif 76 | #else /* Write a character without conversion */ 77 | pb->buf[i++] = (BYTE)c; 78 | #endif 79 | 80 | if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ 81 | f_write(pb->fp, pb->buf, (UINT)i, &bw); 82 | i = (bw == (UINT)i) ? 0 : -1; 83 | } 84 | pb->idx = i; 85 | pb->nchr++; 86 | } 87 | 88 | int f_printf ( 89 | FIL* fp, /* Pointer to the file object */ 90 | const TCHAR* fmt, /* Pointer to the format string */ 91 | ... /* Optional arguments... */ 92 | ) 93 | { 94 | va_list arp; 95 | BYTE f, r; 96 | UINT nw, i, j, w; 97 | DWORD v; 98 | TCHAR c, d, s[16], *p; 99 | putbuff pb; 100 | 101 | 102 | pb.fp = fp; /* Initialize output buffer */ 103 | pb.nchr = pb.idx = 0; 104 | 105 | va_start(arp, fmt); 106 | 107 | for (;;) { 108 | c = *fmt++; 109 | if (c == 0) break; /* End of string */ 110 | if (c != '%') { /* Non escape character */ 111 | putc_bfd(&pb, c); 112 | continue; 113 | } 114 | w = f = 0; 115 | c = *fmt++; 116 | if (c == '0') { /* Flag: '0' padding */ 117 | f = 1; c = *fmt++; 118 | } else { 119 | if (c == '-') { /* Flag: left justified */ 120 | f = 2; c = *fmt++; 121 | } 122 | } 123 | while (IsDigit(c)) { /* Precision */ 124 | w = w * 10 + c - '0'; 125 | c = *fmt++; 126 | } 127 | if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ 128 | f |= 4; c = *fmt++; 129 | } 130 | if (!c) break; 131 | d = c; 132 | if (IsLower(d)) d -= 0x20; 133 | switch (d) { /* Type is... */ 134 | case 'S' : /* String */ 135 | p = va_arg(arp, TCHAR*); 136 | for (j = 0; p[j]; j++) ; 137 | if (!(f & 2)) { 138 | while (j++ < w) putc_bfd(&pb, ' '); 139 | } 140 | while (*p) putc_bfd(&pb, *p++); 141 | while (j++ < w) putc_bfd(&pb, ' '); 142 | continue; 143 | case 'C' : /* Character */ 144 | putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; 145 | case 'B' : /* Binary */ 146 | r = 2; break; 147 | case 'O' : /* Octal */ 148 | r = 8; break; 149 | case 'D' : /* Signed decimal */ 150 | case 'U' : /* Unsigned decimal */ 151 | r = 10; break; 152 | case 'X' : /* Hexdecimal */ 153 | r = 16; break; 154 | default: /* Unknown type (pass-through) */ 155 | putc_bfd(&pb, c); continue; 156 | } 157 | 158 | /* Get an argument and put it in numeral */ 159 | v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); 160 | if (d == 'D' && (v & 0x80000000)) { 161 | v = 0 - v; 162 | f |= 8; 163 | } 164 | i = 0; 165 | do { 166 | d = (TCHAR)(v % r); v /= r; 167 | if (d > 9) d += (c == 'x') ? 0x27 : 0x07; 168 | s[i++] = d + '0'; 169 | } while (v && i < sizeof s / sizeof s[0]); 170 | if (f & 8) s[i++] = '-'; 171 | j = i; d = (f & 1) ? '0' : ' '; 172 | while (!(f & 2) && j++ < w) putc_bfd(&pb, d); 173 | do putc_bfd(&pb, s[--i]); while (i); 174 | while (j++ < w) putc_bfd(&pb, d); 175 | } 176 | 177 | va_end(arp); 178 | 179 | if ( pb.idx >= 0 /* Flush buffered characters to the file */ 180 | && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK 181 | && (UINT)pb.idx == nw) return pb.nchr; 182 | return EOF; 183 | } 184 | 185 | 186 | TCHAR* f_gets ( 187 | TCHAR* buff, /* Pointer to the string buffer to read */ 188 | int len, /* Size of string buffer (characters) */ 189 | FIL* fp /* Pointer to the file object */ 190 | ) 191 | { 192 | int n = 0; 193 | TCHAR c, *p = buff; 194 | BYTE s[2]; 195 | UINT rc; 196 | 197 | // chopped down a bit (ignoring LFN stuff) 198 | while (n < len - 1) { /* Read characters until buffer gets filled */ 199 | f_read(fp, s, 1, &rc); 200 | if (rc != 1) break; 201 | c = s[0]; 202 | *p++ = c; 203 | n++; 204 | if (c == '\n') break; /* Break on EOL */ 205 | } 206 | *p = 0; 207 | return n ? buff : 0; /* When no data read (eof or error), return with error. */ 208 | } 209 | 210 | -------------------------------------------------------------------------------- /bomberin.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | songline 00 01 00 01 f4 0c 00 00 00 5 | songline 01 02 00 07 00 0d 00 00 00 6 | songline 02 03 f4 08 00 0e 00 00 00 7 | songline 03 04 f4 09 00 0f 00 00 00 8 | songline 04 03 f4 08 00 0e 00 00 00 9 | songline 05 04 f4 09 00 0f 00 00 00 10 | songline 06 03 f4 08 00 0e 00 00 00 11 | songline 07 04 f4 09 00 0f 00 00 00 12 | songline 08 03 f4 08 00 0e 00 00 00 13 | songline 09 04 f4 09 00 0f 00 00 00 14 | songline 0a 05 00 0a 00 10 f4 00 00 15 | songline 0b 06 00 0b 00 11 f4 00 00 16 | 17 | trackline 01 00 24 01 00 00 00 00 18 | trackline 01 02 30 01 00 00 00 00 19 | trackline 01 04 3c 01 00 00 00 00 20 | trackline 01 06 30 01 00 00 00 00 21 | trackline 01 08 33 01 00 00 00 00 22 | trackline 01 0a 34 01 00 00 00 00 23 | trackline 01 0c 30 01 00 00 00 00 24 | trackline 01 0e 2e 01 00 00 00 00 25 | trackline 01 10 24 01 00 00 00 00 26 | trackline 01 12 30 01 00 00 00 00 27 | trackline 01 14 3c 01 00 00 00 00 28 | trackline 01 16 30 01 00 00 00 00 29 | trackline 01 18 33 01 00 00 00 00 30 | trackline 01 1a 34 01 00 00 00 00 31 | trackline 01 1c 30 01 00 00 00 00 32 | trackline 01 1e 2e 01 00 00 00 00 33 | trackline 02 00 1f 01 00 00 00 00 34 | trackline 02 02 1f 01 00 00 00 00 35 | trackline 02 04 1f 01 00 00 00 00 36 | trackline 02 08 2b 01 00 00 00 00 37 | trackline 02 0a 2b 01 00 00 00 00 38 | trackline 02 0c 37 01 00 00 00 00 39 | trackline 02 10 22 01 00 00 00 00 40 | trackline 02 14 24 01 00 00 00 00 41 | trackline 02 18 41 01 00 00 00 00 42 | trackline 02 1a 37 01 00 00 00 00 43 | trackline 02 1c 3c 01 00 00 00 00 44 | trackline 02 1e 41 01 00 00 00 00 45 | trackline 03 00 40 01 00 00 00 00 46 | trackline 03 04 3c 01 00 00 00 00 47 | trackline 03 08 3a 01 00 00 00 00 48 | trackline 03 0c 3c 01 00 00 00 00 49 | trackline 03 10 37 02 00 00 00 00 50 | trackline 03 18 35 01 00 00 00 00 51 | trackline 03 1a 36 01 00 00 00 00 52 | trackline 03 1c 33 01 00 00 00 00 53 | trackline 03 1e 34 01 00 00 00 00 54 | trackline 04 04 43 02 00 00 00 00 55 | trackline 04 0c 43 01 00 00 00 00 56 | trackline 04 10 3c 01 00 00 00 00 57 | trackline 04 12 3c 01 00 00 00 00 58 | trackline 04 14 3c 01 00 00 00 00 59 | trackline 04 18 41 01 00 00 00 00 60 | trackline 04 1a 37 01 00 00 00 00 61 | trackline 04 1c 3a 01 00 00 00 00 62 | trackline 04 1e 41 01 00 00 00 00 63 | trackline 05 00 34 01 00 00 00 00 64 | trackline 05 04 2f 01 00 00 00 00 65 | trackline 05 06 30 01 00 00 00 00 66 | trackline 05 08 29 01 00 00 00 00 67 | trackline 05 0a 2b 01 00 00 00 00 68 | trackline 05 0c 28 01 00 00 00 00 69 | trackline 05 10 29 01 00 00 00 00 70 | trackline 05 12 29 01 00 00 00 00 71 | trackline 05 14 29 01 00 00 00 00 72 | trackline 05 18 28 01 00 00 00 00 73 | trackline 05 1a 28 01 00 00 00 00 74 | trackline 05 1c 28 01 00 00 00 00 75 | trackline 06 00 24 01 00 00 00 00 76 | trackline 06 04 24 02 00 00 00 00 77 | trackline 06 0c 22 01 00 00 00 00 78 | trackline 06 0e 23 01 00 00 00 00 79 | trackline 06 10 24 02 00 00 00 00 80 | trackline 07 00 1c 01 00 00 00 00 81 | trackline 07 02 1c 01 00 00 00 00 82 | trackline 07 04 1c 01 00 00 00 00 83 | trackline 07 08 28 01 00 00 00 00 84 | trackline 07 0a 28 01 00 00 00 00 85 | trackline 07 0c 34 01 00 00 00 00 86 | trackline 07 10 0a 01 00 00 00 00 87 | trackline 07 14 0c 01 00 00 00 00 88 | trackline 07 18 29 01 00 00 00 00 89 | trackline 07 1a 1f 01 00 00 00 00 90 | trackline 07 1c 24 01 00 00 00 00 91 | trackline 07 1e 29 01 00 00 00 00 92 | trackline 08 00 30 01 00 00 00 00 93 | trackline 08 04 2b 01 00 00 00 00 94 | trackline 08 08 27 01 00 00 00 00 95 | trackline 08 0c 28 01 00 00 00 00 96 | trackline 08 10 22 02 00 00 00 00 97 | trackline 09 00 24 01 00 00 00 00 98 | trackline 09 04 1f 01 00 00 00 00 99 | trackline 09 08 22 01 00 00 00 00 100 | trackline 09 0c 29 01 00 00 00 00 101 | trackline 09 10 28 02 00 00 00 00 102 | trackline 09 18 29 01 00 00 00 00 103 | trackline 09 1a 1f 01 00 00 00 00 104 | trackline 09 1c 24 01 00 00 00 00 105 | trackline 09 1e 29 01 00 00 00 00 106 | trackline 0a 00 30 01 00 00 00 00 107 | trackline 0a 04 27 01 00 00 00 00 108 | trackline 0a 06 28 01 00 00 00 00 109 | trackline 0a 08 22 01 00 00 00 00 110 | trackline 0a 0a 23 01 00 00 00 00 111 | trackline 0a 0c 1f 01 00 00 00 00 112 | trackline 0a 10 24 01 00 00 00 00 113 | trackline 0a 12 24 01 00 00 00 00 114 | trackline 0a 14 24 01 00 00 00 00 115 | trackline 0a 18 24 01 00 00 00 00 116 | trackline 0a 1a 24 01 00 00 00 00 117 | trackline 0a 1c 24 01 00 00 00 00 118 | trackline 0b 00 1c 01 00 00 00 00 119 | trackline 0b 04 1c 02 00 00 00 00 120 | trackline 0b 0c 16 01 00 00 00 00 121 | trackline 0b 0e 17 01 00 00 00 00 122 | trackline 0b 10 18 02 00 00 00 00 123 | trackline 0c 00 18 03 00 00 00 00 124 | trackline 0c 02 18 03 00 00 00 00 125 | trackline 0c 04 18 03 00 00 00 00 126 | trackline 0c 06 18 03 00 00 00 00 127 | trackline 0c 0e 18 03 00 00 00 00 128 | trackline 0c 10 18 03 00 00 00 00 129 | trackline 0c 12 18 03 00 00 00 00 130 | trackline 0c 14 18 03 00 00 00 00 131 | trackline 0c 16 18 03 00 00 00 00 132 | trackline 0d 00 16 03 00 00 00 00 133 | trackline 0d 02 16 03 00 00 00 00 134 | trackline 0d 04 16 03 00 00 00 00 135 | trackline 0d 10 16 03 00 00 00 00 136 | trackline 0d 12 16 03 00 00 00 00 137 | trackline 0d 14 22 03 00 00 00 00 138 | trackline 0e 00 0c 03 00 00 00 00 139 | trackline 0e 02 0c 03 00 00 00 00 140 | trackline 0e 04 0c 03 00 00 00 00 141 | trackline 0e 08 0f 03 00 00 00 00 142 | trackline 0e 0c 13 03 00 00 00 00 143 | trackline 0e 0e 15 03 00 00 00 00 144 | trackline 0e 10 18 03 00 00 00 00 145 | trackline 0e 12 0c 03 00 00 00 00 146 | trackline 0e 14 0c 03 00 00 00 00 147 | trackline 0e 16 0c 03 00 00 00 00 148 | trackline 0e 18 0f 03 00 00 00 00 149 | trackline 0e 1a 13 03 00 00 00 00 150 | trackline 0e 1e 09 03 00 00 00 00 151 | trackline 0f 00 0a 03 00 00 00 00 152 | trackline 0f 02 0a 03 00 00 00 00 153 | trackline 0f 04 0a 03 00 00 00 00 154 | trackline 0f 06 16 03 00 00 00 00 155 | trackline 0f 08 0a 03 00 00 00 00 156 | trackline 0f 0a 0c 03 00 00 00 00 157 | trackline 0f 0c 16 03 00 00 00 00 158 | trackline 0f 0e 07 03 00 00 00 00 159 | trackline 0f 12 16 03 00 00 00 00 160 | trackline 0f 14 0a 03 00 00 00 00 161 | trackline 0f 16 0a 03 00 00 00 00 162 | trackline 0f 18 0a 03 00 00 00 00 163 | trackline 10 00 2b 03 00 00 00 00 164 | trackline 10 04 2a 03 00 00 00 00 165 | trackline 10 06 2b 03 00 00 00 00 166 | trackline 10 08 27 03 00 00 00 00 167 | trackline 10 0a 28 03 00 00 00 00 168 | trackline 10 0c 24 03 00 00 00 00 169 | trackline 10 0e 1f 03 00 00 00 00 170 | trackline 10 18 20 03 00 00 00 00 171 | trackline 10 1a 20 03 00 00 00 00 172 | trackline 10 1c 20 03 00 00 00 00 173 | trackline 11 00 18 03 00 00 00 00 174 | trackline 11 04 18 04 00 00 00 00 175 | trackline 11 0c 16 03 00 00 00 00 176 | trackline 11 0e 17 03 00 00 00 00 177 | trackline 11 10 18 04 00 00 00 00 178 | 179 | instrumentline 01 00 2b 31 180 | instrumentline 01 01 77 02 181 | instrumentline 01 02 64 80 182 | instrumentline 01 03 76 80 183 | instrumentline 01 04 66 f9 184 | instrumentline 02 00 2b 31 185 | instrumentline 02 01 77 02 186 | instrumentline 02 02 64 80 187 | instrumentline 02 03 76 80 188 | instrumentline 02 04 66 fe 189 | instrumentline 03 00 2b 31 190 | instrumentline 03 01 77 01 191 | instrumentline 03 02 64 80 192 | instrumentline 03 03 76 c0 193 | instrumentline 03 04 66 f4 194 | instrumentline 04 00 2b 31 195 | instrumentline 04 01 77 01 196 | instrumentline 04 02 64 80 197 | instrumentline 04 03 76 c0 198 | instrumentline 04 04 66 fe 199 | -------------------------------------------------------------------------------- /testfm.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | speed 04 5 | 6 | songline 00 01 00 01 f4 0c 00 00 00 7 | songline 01 02 00 07 00 0d 00 00 00 8 | songline 02 03 f4 08 00 0e 00 00 00 9 | songline 03 04 f4 09 00 0f 00 00 00 10 | songline 04 03 f4 08 00 0e 00 00 00 11 | songline 05 04 f4 09 00 0f 00 00 00 12 | songline 06 03 f4 08 00 0e 00 00 00 13 | songline 07 04 f4 09 00 0f 00 00 00 14 | songline 08 03 f4 08 00 0e 00 00 00 15 | songline 09 04 f4 09 00 0f 00 00 00 16 | songline 0a 05 00 0a 00 10 f4 00 00 17 | songline 0b 06 00 0b 00 11 f4 00 00 18 | 19 | trackline 01 00 24 01 00 00 00 00 20 | trackline 01 02 30 01 00 00 00 00 21 | trackline 01 04 3c 01 00 00 00 00 22 | trackline 01 06 30 01 00 00 00 00 23 | trackline 01 08 33 01 00 00 00 00 24 | trackline 01 0a 34 01 00 00 00 00 25 | trackline 01 0c 30 01 00 00 00 00 26 | trackline 01 0e 2e 01 00 00 00 00 27 | trackline 01 10 24 01 00 00 00 00 28 | trackline 01 12 30 01 00 00 00 00 29 | trackline 01 14 3c 01 00 00 00 00 30 | trackline 01 16 30 01 00 00 00 00 31 | trackline 01 18 33 01 00 00 00 00 32 | trackline 01 1a 34 01 00 00 00 00 33 | trackline 01 1c 30 01 00 00 00 00 34 | trackline 01 1e 2e 01 00 00 00 00 35 | trackline 02 00 1f 01 00 00 00 00 36 | trackline 02 02 1f 01 00 00 00 00 37 | trackline 02 04 1f 01 00 00 00 00 38 | trackline 02 08 2b 01 00 00 00 00 39 | trackline 02 0a 2b 01 00 00 00 00 40 | trackline 02 0c 37 01 00 00 00 00 41 | trackline 02 10 22 01 00 00 00 00 42 | trackline 02 14 24 01 00 00 00 00 43 | trackline 02 18 41 01 00 00 00 00 44 | trackline 02 1a 37 01 00 00 00 00 45 | trackline 02 1c 3c 01 00 00 00 00 46 | trackline 02 1e 41 01 00 00 00 00 47 | trackline 03 00 40 01 00 00 00 00 48 | trackline 03 04 3c 01 00 00 00 00 49 | trackline 03 08 3a 01 00 00 00 00 50 | trackline 03 0c 3c 01 00 00 00 00 51 | trackline 03 10 37 02 00 00 00 00 52 | trackline 03 18 35 01 00 00 00 00 53 | trackline 03 1a 36 01 00 00 00 00 54 | trackline 03 1c 33 01 00 00 00 00 55 | trackline 03 1e 34 01 00 00 00 00 56 | trackline 04 04 43 02 00 00 00 00 57 | trackline 04 0c 43 01 00 00 00 00 58 | trackline 04 10 3c 01 00 00 00 00 59 | trackline 04 12 3c 01 00 00 00 00 60 | trackline 04 14 3c 01 00 00 00 00 61 | trackline 04 18 41 01 00 00 00 00 62 | trackline 04 1a 37 01 00 00 00 00 63 | trackline 04 1c 3a 01 00 00 00 00 64 | trackline 04 1e 41 01 00 00 00 00 65 | trackline 05 00 34 01 00 00 00 00 66 | trackline 05 04 2f 01 00 00 00 00 67 | trackline 05 06 30 01 00 00 00 00 68 | trackline 05 08 29 01 00 00 00 00 69 | trackline 05 0a 2b 01 00 00 00 00 70 | trackline 05 0c 28 01 00 00 00 00 71 | trackline 05 10 29 01 00 00 00 00 72 | trackline 05 12 29 01 00 00 00 00 73 | trackline 05 14 29 01 00 00 00 00 74 | trackline 05 18 28 01 00 00 00 00 75 | trackline 05 1a 28 01 00 00 00 00 76 | trackline 05 1c 28 01 00 00 00 00 77 | trackline 06 00 24 01 00 00 00 00 78 | trackline 06 04 24 02 00 00 00 00 79 | trackline 06 0c 22 01 00 00 00 00 80 | trackline 06 0e 23 01 00 00 00 00 81 | trackline 06 10 24 02 00 00 00 00 82 | trackline 07 00 1c 01 00 00 00 00 83 | trackline 07 02 1c 01 00 00 00 00 84 | trackline 07 04 1c 01 00 00 00 00 85 | trackline 07 08 28 01 00 00 00 00 86 | trackline 07 0a 28 01 00 00 00 00 87 | trackline 07 0c 34 01 00 00 00 00 88 | trackline 07 10 0a 01 00 00 00 00 89 | trackline 07 14 0c 01 00 00 00 00 90 | trackline 07 18 29 01 00 00 00 00 91 | trackline 07 1a 1f 01 00 00 00 00 92 | trackline 07 1c 24 01 00 00 00 00 93 | trackline 07 1e 29 01 00 00 00 00 94 | trackline 08 00 30 01 00 00 00 00 95 | trackline 08 04 2b 01 00 00 00 00 96 | trackline 08 08 27 01 00 00 00 00 97 | trackline 08 0c 28 01 00 00 00 00 98 | trackline 08 10 22 02 00 00 00 00 99 | trackline 09 00 24 01 00 00 00 00 100 | trackline 09 04 1f 01 00 00 00 00 101 | trackline 09 08 22 01 00 00 00 00 102 | trackline 09 0c 29 01 00 00 00 00 103 | trackline 09 10 28 02 00 00 00 00 104 | trackline 09 18 29 01 00 00 00 00 105 | trackline 09 1a 1f 01 00 00 00 00 106 | trackline 09 1c 24 01 00 00 00 00 107 | trackline 09 1e 29 01 00 00 00 00 108 | trackline 0a 00 30 01 00 00 00 00 109 | trackline 0a 04 27 01 00 00 00 00 110 | trackline 0a 06 28 01 00 00 00 00 111 | trackline 0a 08 22 01 00 00 00 00 112 | trackline 0a 0a 23 01 00 00 00 00 113 | trackline 0a 0c 1f 01 00 00 00 00 114 | trackline 0a 10 24 01 00 00 00 00 115 | trackline 0a 12 24 01 00 00 00 00 116 | trackline 0a 14 24 01 00 00 00 00 117 | trackline 0a 18 24 01 00 00 00 00 118 | trackline 0a 1a 24 01 00 00 00 00 119 | trackline 0a 1c 24 01 00 00 00 00 120 | trackline 0b 00 1c 01 00 00 00 00 121 | trackline 0b 04 1c 02 00 00 00 00 122 | trackline 0b 0c 16 01 00 00 00 00 123 | trackline 0b 0e 17 01 00 00 00 00 124 | trackline 0b 10 18 02 00 00 00 00 125 | trackline 0c 00 18 03 00 00 00 00 126 | trackline 0c 02 18 03 00 00 00 00 127 | trackline 0c 04 18 03 00 00 00 00 128 | trackline 0c 06 18 03 00 00 00 00 129 | trackline 0c 0e 18 03 00 00 00 00 130 | trackline 0c 10 18 03 00 00 00 00 131 | trackline 0c 12 18 03 00 00 00 00 132 | trackline 0c 14 18 03 00 00 00 00 133 | trackline 0c 16 18 03 00 00 00 00 134 | trackline 0d 00 16 03 00 00 00 00 135 | trackline 0d 02 16 03 00 00 00 00 136 | trackline 0d 04 16 03 00 00 00 00 137 | trackline 0d 10 16 03 00 00 00 00 138 | trackline 0d 12 16 03 00 00 00 00 139 | trackline 0d 14 22 03 00 00 00 00 140 | trackline 0e 00 0c 03 00 00 00 00 141 | trackline 0e 02 0c 03 00 00 00 00 142 | trackline 0e 04 0c 03 00 00 00 00 143 | trackline 0e 08 0f 03 00 00 00 00 144 | trackline 0e 0c 13 03 00 00 00 00 145 | trackline 0e 0e 15 03 00 00 00 00 146 | trackline 0e 10 18 03 00 00 00 00 147 | trackline 0e 12 0c 03 00 00 00 00 148 | trackline 0e 14 0c 03 00 00 00 00 149 | trackline 0e 16 0c 03 00 00 00 00 150 | trackline 0e 18 0f 03 00 00 00 00 151 | trackline 0e 1a 13 03 00 00 00 00 152 | trackline 0e 1e 09 03 00 00 00 00 153 | trackline 0f 00 0a 03 00 00 00 00 154 | trackline 0f 02 0a 03 00 00 00 00 155 | trackline 0f 04 0a 03 00 00 00 00 156 | trackline 0f 06 16 03 00 00 00 00 157 | trackline 0f 08 0a 03 00 00 00 00 158 | trackline 0f 0a 0c 03 00 00 00 00 159 | trackline 0f 0c 16 03 00 00 00 00 160 | trackline 0f 0e 07 03 00 00 00 00 161 | trackline 0f 12 16 03 00 00 00 00 162 | trackline 0f 14 0a 03 00 00 00 00 163 | trackline 0f 16 0a 03 00 00 00 00 164 | trackline 0f 18 0a 03 00 00 00 00 165 | trackline 10 00 2b 03 00 00 00 00 166 | trackline 10 04 2a 03 00 00 00 00 167 | trackline 10 06 2b 03 00 00 00 00 168 | trackline 10 08 27 03 00 00 00 00 169 | trackline 10 0a 28 03 00 00 00 00 170 | trackline 10 0c 24 03 00 00 00 00 171 | trackline 10 0e 1f 03 00 00 00 00 172 | trackline 10 18 20 03 00 00 00 00 173 | trackline 10 1a 20 03 00 00 00 00 174 | trackline 10 1c 20 03 00 00 00 00 175 | trackline 11 00 18 03 00 00 00 00 176 | trackline 11 04 18 04 00 00 00 00 177 | trackline 11 0c 16 03 00 00 00 00 178 | trackline 11 0e 17 03 00 00 00 00 179 | trackline 11 10 18 04 00 00 00 00 180 | 181 | instrumentline 01 00 2b 31 2b 38 182 | instrumentline 01 01 77 04 77 04 183 | instrumentline 01 02 64 80 6c 00 184 | instrumentline 01 03 76 80 76 f6 185 | instrumentline 01 04 66 f9 66 f0 186 | instrumentline 02 00 2b 31 2b 38 187 | instrumentline 02 01 77 04 77 04 188 | instrumentline 02 02 64 80 64 80 189 | instrumentline 02 03 76 ff 76 5f 190 | instrumentline 02 04 66 fc 66 ff 191 | instrumentline 03 00 2b 31 2b 31 192 | instrumentline 03 01 77 00 77 00 193 | instrumentline 03 02 64 80 64 80 194 | instrumentline 03 03 76 ff 76 5f 195 | instrumentline 03 04 66 f4 66 ff 196 | instrumentline 04 00 2b 31 2b 31 197 | instrumentline 04 01 77 00 77 00 198 | instrumentline 04 02 64 80 64 80 199 | instrumentline 04 03 76 ff 76 5f 200 | instrumentline 04 04 66 fe 66 ff 201 | -------------------------------------------------------------------------------- /chip.c: -------------------------------------------------------------------------------- 1 | #include "stuff.h" 2 | #include "lib/chiptune/chiptune.h" 3 | #include "lib/chiptune/player.h" 4 | #include "lib/chiptune/player_internals.h" 5 | 6 | #include 7 | 8 | //static u16 callbackwait; 9 | 10 | volatile u8 test; 11 | volatile u8 testwait; 12 | 13 | u8 songwait; 14 | u8 trackpos; 15 | u16 songpos; 16 | 17 | int tracklen = 32; 18 | u8 songspeed = 4; 19 | 20 | u8 playsong; 21 | u8 playtrack; 22 | 23 | struct instrument instrument[NINST]; 24 | //struct track track[NTRACK]; 25 | struct trackline tracking[NTRACKLINE]; 26 | struct songline song[256]; 27 | 28 | struct channel channel[8]; 29 | 30 | void silence() { 31 | for(u8 i = 0; i < 8; i++) { 32 | osc[i].volume = 0; 33 | channel[i].volumed = 0; 34 | } 35 | playsong = 0; 36 | playtrack = 0; 37 | } 38 | 39 | void readsong(int pos, uint8_t ch, u8 *dest) { 40 | dest[0] = song[pos].track[ch]; 41 | dest[1] = song[pos].transp[ch]; 42 | } 43 | 44 | void readtrack(uint8_t num, uint8_t pos, struct trackline *tl) { 45 | tl->note = track(num, pos)->note; 46 | tl->instr = track(num, pos)->instr; 47 | tl->cmd[0] = track(num, pos)->cmd[0]; 48 | tl->cmd[1] = track(num, pos)->cmd[1]; 49 | tl->param[0] = track(num, pos)->param[0]; 50 | tl->param[1] = track(num, pos)->param[1]; 51 | } 52 | 53 | void readinstr(uint8_t num, uint8_t pos, u8 *il) { 54 | if(pos >= instrument[num].length) { 55 | il[0] = 0; 56 | il[1] = 0; 57 | il[2] = 0; 58 | il[3] = 0; 59 | } else { 60 | il[0] = instrument[num].line[pos].cmd; 61 | il[1] = instrument[num].line[pos].param; 62 | 63 | il[2] = instrument[num].line[pos].cmd2; 64 | il[3] = instrument[num].line[pos].param2; 65 | } 66 | } 67 | 68 | 69 | void myruncmd(u8 ch, u8 cmd, u8 param, u8 context) { 70 | if (context == 2) 71 | ch += 4; 72 | 73 | switch(cmd) { 74 | // Commands affecting channel 75 | case 0: 76 | channel[ch].inum = 0; 77 | break; 78 | case 'f': 79 | channel[ch].volumed = param; 80 | break; 81 | case 'i': 82 | channel[ch].inertia = param << 1; 83 | break; 84 | case 'j': 85 | channel[ch].iptr = param; 86 | break; 87 | case 'l': 88 | channel[ch].bendd = param; 89 | break; 90 | case 'm': 91 | channel[ch].dutyd = param << 6; 92 | break; 93 | case 't': 94 | if (!context) 95 | channel[ch].iwait = param; 96 | else 97 | songspeed = param; 98 | break; 99 | case '+': 100 | channel[ch].inote = param + channel[ch].tnote - 12 * 4; 101 | break; 102 | case '=': 103 | if (!context) 104 | channel[ch].inote = param; 105 | else 106 | channel[ch].lastinstr = param; 107 | break; 108 | case '~': 109 | if(channel[ch].vdepth != (param >> 4)) { 110 | channel[ch].vpos = 0; 111 | } 112 | channel[ch].vdepth = param >> 4; 113 | channel[ch].vrate = param & 15; 114 | break; 115 | 116 | // Commands affecting oscillator 117 | case 'b': 118 | osc[ch].bitcrush = param & 0x7; 119 | break; 120 | case 'd': 121 | osc[ch].duty = param << 8; 122 | break; 123 | case 'v': 124 | osc[ch].volume = param; 125 | break; 126 | case 'w': 127 | osc[ch].waveform = param; 128 | break; 129 | } 130 | } 131 | 132 | void iedplonk(int note, int instr) { 133 | channel[0].tnote = note; 134 | channel[0].inum = instr; 135 | channel[0].iptr = 0; 136 | channel[0].iwait = 0; 137 | channel[0].bend = 0; 138 | channel[0].bendd = 0; 139 | channel[0].volumed = 0; 140 | channel[0].dutyd = 0; 141 | channel[0].vdepth = 0; 142 | 143 | channel[4].tnote = note; 144 | channel[4].inum = instr; 145 | channel[4].iptr = 0; 146 | channel[4].iwait = 0; 147 | channel[4].bend = 0; 148 | channel[4].bendd = 0; 149 | channel[4].volumed = 0; 150 | channel[4].dutyd = 0; 151 | channel[4].vdepth = 0; 152 | } 153 | 154 | void startplaytrack(int t) { 155 | channel[0].tnum = t; 156 | channel[1].tnum = t; 157 | channel[2].tnum = 0; 158 | channel[3].tnum = 0; 159 | channel[4].tnum = t; 160 | channel[5].tnum = t; 161 | channel[6].tnum = 0; 162 | channel[7].tnum = 0; 163 | trackpos = 0; 164 | songwait = 0; 165 | playtrack = 1; 166 | playsong = 0; 167 | } 168 | 169 | void startplaysong(int p) { 170 | songpos = p; 171 | trackpos = 0; 172 | songwait = 0; 173 | playtrack = 0; 174 | playsong = 1; 175 | } 176 | 177 | void playroutine() { // called at 50 Hz 178 | u8 ch; 179 | if(playtrack || playsong) { 180 | if(songwait) { 181 | songwait--; 182 | } else { 183 | songwait = songspeed; 184 | 185 | if(!trackpos) { 186 | if(playsong) { 187 | if(songpos >= songlen) { 188 | playsong = 0; 189 | } else { 190 | for(ch = 0; ch < 4; ch++) { 191 | u8 tmp[2]; 192 | 193 | readsong(songpos, ch, tmp); 194 | channel[ch].tnum = tmp[0]; 195 | channel[ch].transp = tmp[1]; 196 | 197 | channel[ch+4].tnum = tmp[0]; 198 | channel[ch+4].transp = tmp[1]; 199 | } 200 | songpos++; 201 | } 202 | } 203 | } 204 | 205 | if(playtrack || playsong) { 206 | for(ch = 0; ch < 4; ch++) { 207 | if(channel[ch].tnum) { 208 | struct trackline tl; 209 | u8 instr = 0; 210 | readtrack(channel[ch].tnum, trackpos, &tl); 211 | if(tl.note) { 212 | channel[ch].tnote = tl.note + channel[ch].transp; 213 | channel[ch+4].tnote = tl.note + channel[ch+4].transp; 214 | instr = channel[ch].lastinstr; 215 | } 216 | if(tl.instr) { 217 | instr = tl.instr; 218 | } 219 | if(instr) { 220 | channel[ch].lastinstr = instr; 221 | channel[ch].inum = instr; 222 | channel[ch].iptr = 0; 223 | channel[ch].iwait = 0; 224 | channel[ch].bend = 0; 225 | channel[ch].bendd = 0; 226 | channel[ch].volumed = 0; 227 | channel[ch].dutyd = 0; 228 | channel[ch].vdepth = 0; 229 | 230 | channel[ch+4].lastinstr = instr; 231 | channel[ch+4].inum = instr; 232 | channel[ch+4].iptr = 0; 233 | channel[ch+4].iwait = 0; 234 | channel[ch+4].bend = 0; 235 | channel[ch+4].bendd = 0; 236 | channel[ch+4].volumed = 0; 237 | channel[ch+4].dutyd = 0; 238 | channel[ch+4].vdepth = 0; 239 | } 240 | if(tl.cmd[0]) 241 | myruncmd(ch, tl.cmd[0], tl.param[0], 1); 242 | if(tl.cmd[1]) 243 | myruncmd(ch, tl.cmd[1], tl.param[1], 2); 244 | } 245 | } 246 | 247 | trackpos++; 248 | if (trackpos == tracklen) 249 | trackpos = 0; 250 | } 251 | } 252 | } 253 | 254 | for(ch = 0; ch < 8; ch++) { 255 | s16 vol; 256 | u16 duty; 257 | u16 slur; 258 | 259 | while(channel[ch].inum && !channel[ch].iwait) { 260 | u8 il[4]; 261 | 262 | readinstr(channel[ch].inum, channel[ch].iptr, il); 263 | channel[ch].iptr++; 264 | 265 | //myruncmd(ch, packcmd(il[0]), il[1], 0); 266 | myruncmd(ch, ch < 4 ? il[0] : il[2], ch < 4 ? il[1] : il[3], 0); 267 | } 268 | if(channel[ch].iwait) channel[ch].iwait--; 269 | 270 | if(channel[ch].inertia) { 271 | s16 diff; 272 | 273 | slur = channel[ch].slur; 274 | diff = chip_freqtable[channel[ch].inote] - slur; 275 | //diff >>= channel[ch].inertia; 276 | if(diff > 0) { 277 | if(diff > channel[ch].inertia) diff = channel[ch].inertia; 278 | } else if(diff < 0) { 279 | if(diff < -channel[ch].inertia) diff = -channel[ch].inertia; 280 | } 281 | slur += diff; 282 | channel[ch].slur = slur; 283 | } else { 284 | slur = chip_freqtable[channel[ch].inote]; 285 | } 286 | osc[ch].freq = 287 | slur + 288 | channel[ch].bend + 289 | ((channel[ch].vdepth * chip_sinetable[channel[ch].vpos & 63]) >> 2); 290 | channel[ch].bend += channel[ch].bendd; 291 | vol = osc[ch].volume + channel[ch].volumed; 292 | if(vol < 0) vol = 0; 293 | if(vol > 255) vol = 255; 294 | osc[ch].volume = vol; 295 | 296 | duty = osc[ch].duty + channel[ch].dutyd; 297 | if(duty > 0xe000) duty = 0x2000; 298 | if(duty < 0x2000) duty = 0xe000; 299 | osc[ch].duty = duty; 300 | 301 | channel[ch].vpos += channel[ch].vrate; 302 | } 303 | } 304 | 305 | void initchip() { 306 | songwait = 0; 307 | trackpos = 0; 308 | playsong = 0; 309 | playtrack = 0; 310 | 311 | osc[0].volume = 0; 312 | channel[0].inum = 0; 313 | osc[1].volume = 0; 314 | channel[1].inum = 0; 315 | osc[2].volume = 0; 316 | channel[2].inum = 0; 317 | osc[3].volume = 0; 318 | channel[3].inum = 0; 319 | channel[4].inum = 0; 320 | channel[5].inum = 0; 321 | channel[6].inum = 0; 322 | channel[7].inum = 0; 323 | 324 | // Initialize the second set of oscillators to an "idle" value for backwards compatibility. 325 | osc[4].volume = 0; 326 | osc[5].volume = 0; 327 | osc[6].volume = 0; 328 | osc[7].volume = 0; 329 | 330 | osc[4].freq = 0; 331 | osc[4].phase = 0; 332 | osc[5].freq = 0; 333 | osc[5].phase = 0; 334 | osc[6].freq = 0; 335 | osc[6].phase = 0; 336 | osc[7].freq = 0; 337 | osc[7].phase = 0; 338 | } 339 | 340 | -------------------------------------------------------------------------------- /bdash.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | songline 00 01 00 08 00 0f 00 00 00 5 | songline 01 02 00 09 00 10 00 00 00 6 | songline 02 03 00 0a 00 11 00 00 00 7 | songline 03 04 00 0b 00 12 00 00 00 8 | songline 04 05 00 0c 00 13 00 00 00 9 | songline 05 06 00 0d 00 14 00 00 00 10 | songline 06 05 00 0c 00 13 00 00 00 11 | songline 07 07 00 0e 00 15 00 00 00 12 | 13 | trackline 01 00 22 01 00 00 00 00 14 | trackline 01 02 26 01 00 00 00 00 15 | trackline 01 04 29 01 00 00 00 00 16 | trackline 01 06 2e 01 00 00 00 00 17 | trackline 01 08 30 01 00 00 00 00 18 | trackline 01 0a 27 01 00 00 00 00 19 | trackline 01 0c 29 01 00 00 00 00 20 | trackline 01 0e 30 01 00 00 00 00 21 | trackline 01 10 2a 01 00 00 00 00 22 | trackline 01 12 2c 01 00 00 00 00 23 | trackline 01 14 2e 01 00 00 00 00 24 | trackline 01 16 31 01 00 00 00 00 25 | trackline 01 18 2c 01 00 00 00 00 26 | trackline 01 1a 37 01 00 00 00 00 27 | trackline 01 1c 2d 01 00 00 00 00 28 | trackline 01 1e 35 01 00 00 00 00 29 | trackline 02 00 22 01 00 00 00 00 30 | trackline 02 02 2e 01 00 00 00 00 31 | trackline 02 04 1d 01 00 00 00 00 32 | trackline 02 06 24 01 00 00 00 00 33 | trackline 02 08 20 01 00 00 00 00 34 | trackline 02 0a 30 01 00 00 00 00 35 | trackline 02 0c 24 01 00 00 00 00 36 | trackline 02 0e 20 01 00 00 00 00 37 | trackline 02 10 22 01 00 00 00 00 38 | trackline 02 12 2e 01 00 00 00 00 39 | trackline 02 14 1d 01 00 00 00 00 40 | trackline 02 16 24 01 00 00 00 00 41 | trackline 02 18 2a 01 00 00 00 00 42 | trackline 02 1a 3a 01 00 00 00 00 43 | trackline 02 1c 2e 01 00 00 00 00 44 | trackline 02 1e 2a 01 00 00 00 00 45 | trackline 03 00 20 01 00 00 00 00 46 | trackline 03 02 2c 01 00 00 00 00 47 | trackline 03 04 1b 01 00 00 00 00 48 | trackline 03 06 22 01 00 00 00 00 49 | trackline 03 08 28 01 00 00 00 00 50 | trackline 03 0a 38 01 00 00 00 00 51 | trackline 03 0c 2c 01 00 00 00 00 52 | trackline 03 0e 28 01 00 00 00 00 53 | trackline 03 10 1d 01 00 00 00 00 54 | trackline 03 12 2d 01 00 00 00 00 55 | trackline 03 14 1f 01 00 00 00 00 56 | trackline 03 16 2e 01 00 00 00 00 57 | trackline 03 18 27 01 00 00 00 00 58 | trackline 03 1a 27 01 00 00 00 00 59 | trackline 03 1c 33 01 00 00 00 00 60 | trackline 03 1e 27 01 00 00 00 00 61 | trackline 04 00 2e 01 00 00 00 00 62 | trackline 04 02 2e 01 00 00 00 00 63 | trackline 04 04 2e 01 00 00 00 00 64 | trackline 04 06 2e 01 00 00 00 00 65 | trackline 04 08 2e 01 00 00 00 00 66 | trackline 04 0a 2e 01 00 00 00 00 67 | trackline 04 0c 2e 01 00 00 00 00 68 | trackline 04 0e 2e 01 00 00 00 00 69 | trackline 04 10 2e 01 00 00 00 00 70 | trackline 04 12 2e 01 00 00 00 00 71 | trackline 04 14 2e 01 00 00 00 00 72 | trackline 04 16 2e 01 00 00 00 00 73 | trackline 04 18 2e 01 00 00 00 00 74 | trackline 04 1a 2e 01 00 00 00 00 75 | trackline 04 1c 2e 01 00 00 00 00 76 | trackline 04 1e 2e 01 00 00 00 00 77 | trackline 05 00 2e 01 00 00 00 00 78 | trackline 05 02 2e 01 00 00 00 00 79 | trackline 05 04 2e 01 00 00 00 00 80 | trackline 05 06 2e 01 00 00 00 00 81 | trackline 05 08 2e 01 00 00 00 00 82 | trackline 05 0a 2e 01 00 00 00 00 83 | trackline 05 0c 2e 01 00 00 00 00 84 | trackline 05 0e 2e 01 00 00 00 00 85 | trackline 05 10 2e 01 00 00 00 00 86 | trackline 05 12 2e 01 00 00 00 00 87 | trackline 05 14 2e 01 00 00 00 00 88 | trackline 05 16 2e 01 00 00 00 00 89 | trackline 05 18 2c 01 00 00 00 00 90 | trackline 05 1a 2c 01 00 00 00 00 91 | trackline 05 1c 2c 01 00 00 00 00 92 | trackline 05 1e 2c 01 00 00 00 00 93 | trackline 06 00 2e 01 00 00 00 00 94 | trackline 06 02 3a 01 00 00 00 00 95 | trackline 06 04 2e 01 00 00 00 00 96 | trackline 06 06 38 01 00 00 00 00 97 | trackline 06 08 2e 01 00 00 00 00 98 | trackline 06 0a 37 01 00 00 00 00 99 | trackline 06 0c 2e 01 00 00 00 00 100 | trackline 06 0e 35 01 00 00 00 00 101 | trackline 06 10 2c 01 00 00 00 00 102 | trackline 06 12 38 01 00 00 00 00 103 | trackline 06 14 2c 01 00 00 00 00 104 | trackline 06 16 38 01 00 00 00 00 105 | trackline 06 18 2c 01 00 00 00 00 106 | trackline 06 1a 33 01 00 00 00 00 107 | trackline 06 1c 2c 01 00 00 00 00 108 | trackline 06 1e 38 01 00 00 00 00 109 | trackline 07 00 32 01 00 00 00 00 110 | trackline 07 02 2e 01 00 00 00 00 111 | trackline 07 04 29 01 00 00 00 00 112 | trackline 07 06 26 01 00 00 00 00 113 | trackline 07 08 30 01 00 00 00 00 114 | trackline 07 0a 2c 01 00 00 00 00 115 | trackline 07 0c 27 01 00 00 00 00 116 | trackline 07 0e 20 01 00 00 00 00 117 | trackline 07 10 32 01 00 00 00 00 118 | trackline 07 12 2e 01 00 00 00 00 119 | trackline 07 14 29 01 00 00 00 00 120 | trackline 07 16 26 01 00 00 00 00 121 | trackline 07 18 30 01 00 00 00 00 122 | trackline 07 1a 2c 01 00 00 00 00 123 | trackline 07 1c 27 01 00 00 00 00 124 | trackline 07 1e 20 01 00 00 00 00 125 | trackline 08 00 22 02 00 00 00 00 126 | trackline 08 08 20 02 00 00 00 00 127 | trackline 08 10 1e 02 00 00 00 00 128 | trackline 08 12 1e 02 00 00 00 00 129 | trackline 08 16 1e 02 00 00 00 00 130 | trackline 09 00 22 02 00 00 00 00 131 | trackline 09 02 22 02 00 00 00 00 132 | trackline 09 04 22 02 00 00 00 00 133 | trackline 09 06 22 02 00 00 00 00 134 | trackline 09 08 20 02 00 00 00 00 135 | trackline 09 0a 20 02 00 00 00 00 136 | trackline 09 0c 20 02 00 00 00 00 137 | trackline 09 0e 20 02 00 00 00 00 138 | trackline 09 10 22 02 00 00 00 00 139 | trackline 09 12 22 02 00 00 00 00 140 | trackline 09 14 22 02 00 00 00 00 141 | trackline 09 16 22 02 00 00 00 00 142 | trackline 0a 00 20 02 00 00 00 00 143 | trackline 0a 02 20 02 00 00 00 00 144 | trackline 0a 04 20 02 00 00 00 00 145 | trackline 0a 06 20 02 00 00 00 00 146 | trackline 0a 10 1d 02 00 00 00 00 147 | trackline 0a 14 1d 02 00 00 00 00 148 | trackline 0a 18 1b 02 00 00 00 00 149 | trackline 0a 1a 1b 02 00 00 00 00 150 | trackline 0a 1c 22 02 00 00 00 00 151 | trackline 0a 1e 22 02 00 00 00 00 152 | trackline 0b 00 22 02 00 00 00 00 153 | trackline 0b 02 22 02 00 00 00 00 154 | trackline 0b 04 22 02 00 00 00 00 155 | trackline 0b 06 22 02 00 00 00 00 156 | trackline 0b 0c 22 02 00 00 00 00 157 | trackline 0b 0e 22 02 00 00 00 00 158 | trackline 0b 10 20 02 00 00 00 00 159 | trackline 0b 12 20 02 00 00 00 00 160 | trackline 0b 14 20 02 00 00 00 00 161 | trackline 0b 16 20 02 00 00 00 00 162 | trackline 0b 1c 20 02 00 00 00 00 163 | trackline 0b 1e 20 02 00 00 00 00 164 | trackline 0c 00 22 02 00 00 00 00 165 | trackline 0c 04 22 02 00 00 00 00 166 | trackline 0c 0c 22 02 00 00 00 00 167 | trackline 0c 10 20 02 00 00 00 00 168 | trackline 0c 14 20 02 00 00 00 00 169 | trackline 0c 1c 20 02 00 00 00 00 170 | trackline 0d 00 22 02 00 00 00 00 171 | trackline 0d 02 22 02 00 00 00 00 172 | trackline 0d 04 22 02 00 00 00 00 173 | trackline 0d 0c 22 02 00 00 00 00 174 | trackline 0d 10 20 02 00 00 00 00 175 | trackline 0d 12 20 02 00 00 00 00 176 | trackline 0d 14 20 02 00 00 00 00 177 | trackline 0d 16 20 02 00 00 00 00 178 | trackline 0d 1c 20 02 00 00 00 00 179 | trackline 0d 1e 20 02 00 00 00 00 180 | trackline 0e 0e 20 02 00 00 00 00 181 | trackline 0e 1e 20 02 00 00 00 00 182 | trackline 0f 00 16 01 00 00 00 00 183 | trackline 0f 02 1d 01 00 00 00 00 184 | trackline 0f 04 22 01 00 00 00 00 185 | trackline 0f 06 25 01 00 00 00 00 186 | trackline 0f 08 14 01 00 00 00 00 187 | trackline 0f 0a 1f 01 00 00 00 00 188 | trackline 0f 0c 20 01 00 00 00 00 189 | trackline 0f 0e 27 01 00 00 00 00 190 | trackline 0f 10 12 01 00 00 00 00 191 | trackline 0f 12 12 01 00 00 00 00 192 | trackline 0f 14 1e 01 00 00 00 00 193 | trackline 0f 16 12 01 00 00 00 00 194 | trackline 0f 18 20 01 00 00 00 00 195 | trackline 0f 1a 33 01 00 00 00 00 196 | trackline 0f 1c 21 01 00 00 00 00 197 | trackline 0f 1e 31 01 00 00 00 00 198 | trackline 10 00 16 01 00 00 00 00 199 | trackline 10 02 16 01 00 00 00 00 200 | trackline 10 04 16 01 00 00 00 00 201 | trackline 10 06 16 01 00 00 00 00 202 | trackline 10 08 14 01 00 00 00 00 203 | trackline 10 0a 14 01 00 00 00 00 204 | trackline 10 0c 14 01 00 00 00 00 205 | trackline 10 0e 14 01 00 00 00 00 206 | trackline 10 10 16 01 00 00 00 00 207 | trackline 10 12 16 01 00 00 00 00 208 | trackline 10 14 16 01 00 00 00 00 209 | trackline 10 16 16 01 00 00 00 00 210 | trackline 10 18 1e 01 00 00 00 00 211 | trackline 10 1a 1e 01 00 00 00 00 212 | trackline 10 1c 1e 01 00 00 00 00 213 | trackline 10 1e 1e 01 00 00 00 00 214 | trackline 11 00 14 01 00 00 00 00 215 | trackline 11 02 14 01 00 00 00 00 216 | trackline 11 04 14 01 00 00 00 00 217 | trackline 11 06 14 01 00 00 00 00 218 | trackline 11 08 1c 01 00 00 00 00 219 | trackline 11 0a 1c 01 00 00 00 00 220 | trackline 11 0c 1c 01 00 00 00 00 221 | trackline 11 0e 1c 01 00 00 00 00 222 | trackline 11 10 11 01 00 00 00 00 223 | trackline 11 12 29 01 00 00 00 00 224 | trackline 11 14 11 01 00 00 00 00 225 | trackline 11 16 29 01 00 00 00 00 226 | trackline 11 18 0f 01 00 00 00 00 227 | trackline 11 1a 0f 01 00 00 00 00 228 | trackline 11 1c 16 01 00 00 00 00 229 | trackline 11 1e 16 01 00 00 00 00 230 | trackline 12 00 16 01 00 00 00 00 231 | trackline 12 02 16 01 00 00 00 00 232 | trackline 12 04 16 01 00 00 00 00 233 | trackline 12 06 16 01 00 00 00 00 234 | trackline 12 08 22 01 00 00 00 00 235 | trackline 12 0a 22 01 00 00 00 00 236 | trackline 12 0c 16 01 00 00 00 00 237 | trackline 12 0e 16 01 00 00 00 00 238 | trackline 12 10 14 01 00 00 00 00 239 | trackline 12 12 14 01 00 00 00 00 240 | trackline 12 14 14 01 00 00 00 00 241 | trackline 12 16 14 01 00 00 00 00 242 | trackline 12 18 20 01 00 00 00 00 243 | trackline 12 1a 20 01 00 00 00 00 244 | trackline 12 1c 14 01 00 00 00 00 245 | trackline 12 1e 14 01 00 00 00 00 246 | trackline 13 00 16 01 00 00 00 00 247 | trackline 13 02 32 01 00 00 00 00 248 | trackline 13 04 16 01 00 00 00 00 249 | trackline 13 06 33 01 00 00 00 00 250 | trackline 13 08 22 01 00 00 00 00 251 | trackline 13 0a 32 01 00 00 00 00 252 | trackline 13 0c 16 01 00 00 00 00 253 | trackline 13 0e 33 01 00 00 00 00 254 | trackline 13 10 14 01 00 00 00 00 255 | trackline 13 12 32 01 00 00 00 00 256 | trackline 13 14 14 01 00 00 00 00 257 | trackline 13 16 33 01 00 00 00 00 258 | trackline 13 18 20 01 00 00 00 00 259 | trackline 13 1a 30 01 00 00 00 00 260 | trackline 13 1c 14 01 00 00 00 00 261 | trackline 13 1e 31 01 00 00 00 00 262 | trackline 14 00 16 01 00 00 00 00 263 | trackline 14 02 16 01 00 00 00 00 264 | trackline 14 04 16 01 00 00 00 00 265 | trackline 14 06 35 01 00 00 00 00 266 | trackline 14 08 22 01 00 00 00 00 267 | trackline 14 0a 22 01 00 00 00 00 268 | trackline 14 0c 16 01 00 00 00 00 269 | trackline 14 0e 31 01 00 00 00 00 270 | trackline 14 10 14 01 00 00 00 00 271 | trackline 14 12 14 01 00 00 00 00 272 | trackline 14 14 14 01 00 00 00 00 273 | trackline 14 16 14 01 00 00 00 00 274 | trackline 14 18 20 01 00 00 00 00 275 | trackline 14 1a 20 01 00 00 00 00 276 | trackline 14 1c 14 01 00 00 00 00 277 | trackline 14 1e 14 01 00 00 00 00 278 | trackline 15 00 2e 01 00 00 00 00 279 | trackline 15 02 29 01 00 00 00 00 280 | trackline 15 04 26 01 00 00 00 00 281 | trackline 15 06 22 01 00 00 00 00 282 | trackline 15 08 2c 01 00 00 00 00 283 | trackline 15 0a 27 01 00 00 00 00 284 | trackline 15 0c 24 01 00 00 00 00 285 | trackline 15 0e 14 01 00 00 00 00 286 | trackline 15 10 35 01 00 00 00 00 287 | trackline 15 12 32 01 00 00 00 00 288 | trackline 15 14 2e 01 00 00 00 00 289 | trackline 15 16 29 01 00 00 00 00 290 | trackline 15 18 27 01 00 00 00 00 291 | trackline 15 1a 24 01 00 00 00 00 292 | trackline 15 1c 20 01 00 00 00 00 293 | trackline 15 1e 14 01 00 00 00 00 294 | 295 | instrumentline 01 00 77 02 296 | instrumentline 01 01 66 fa 297 | instrumentline 01 02 76 63 298 | instrumentline 01 03 6d 80 299 | instrumentline 01 04 2b 31 300 | instrumentline 02 00 77 00 301 | instrumentline 02 01 66 ff 302 | instrumentline 02 02 76 63 303 | instrumentline 02 03 2b 31 304 | -------------------------------------------------------------------------------- /io.c: -------------------------------------------------------------------------------- 1 | #include "fatfs/ff.h" 2 | #include // va_list 3 | #include 4 | #include // memset 5 | #include "stuff.h" 6 | #include 7 | 8 | 9 | char filename[13]; 10 | u16 numtracks; 11 | 12 | static FATFS fat_fs; 13 | static FIL fat_file; 14 | static FRESULT fat_result; 15 | 16 | void initio() 17 | { 18 | fat_result = f_mount(&fat_fs, "", 1); 19 | } 20 | 21 | void savefile(char *fname) { 22 | fat_result = f_open(&fat_file, fname, FA_WRITE | FA_OPEN_ALWAYS); 23 | if (fat_result != FR_OK) { 24 | switch (fat_result) { 25 | case (FR_DISK_ERR): 26 | setalert("low level error!"); break; 27 | case (FR_INT_ERR): 28 | setalert("assertion error"); break; 29 | case (FR_NOT_READY): 30 | setalert("physical drive not ready"); break; 31 | case (FR_NO_FILE): 32 | setalert("could not find file"); break; 33 | case (FR_NO_PATH): 34 | setalert("could not find path"); break; 35 | case (FR_INVALID_NAME): 36 | setalert("invalid name format"); break; 37 | case (FR_DENIED): 38 | setalert("denied access (full?)"); break; 39 | case (FR_EXIST): 40 | setalert("prohibited access"); break; 41 | case (FR_INVALID_OBJECT): 42 | setalert("invalid file/dir obj"); break; 43 | case (FR_WRITE_PROTECTED): 44 | setalert("drive is write protected"); break; 45 | case (FR_INVALID_DRIVE): 46 | setalert("drive number is invalid"); break; 47 | case (FR_NOT_ENABLED): 48 | setalert("no work area in volume"); break; 49 | case (FR_NO_FILESYSTEM): 50 | setalert("not valid FAT volume"); break; 51 | case (FR_MKFS_ABORTED): 52 | setalert("f_mkfs abort?"); break; 53 | case (FR_TIMEOUT): 54 | setalert("timeout"); break; 55 | case (FR_LOCKED): 56 | setalert("locked due to sharing"); break; 57 | case (FR_NOT_ENOUGH_CORE): 58 | setalert("LFN buffer no-allocate"); break; 59 | case (FR_TOO_MANY_OPEN_FILES): 60 | setalert("too many open files"); break; 61 | case (FR_INVALID_PARAMETER): 62 | setalert("invalid parameter"); break; 63 | default: 64 | setalert("weird, some other error!"); 65 | } 66 | return; 67 | } 68 | 69 | int i, j; 70 | f_printf(&fat_file, "musicchip tune\nversion 1\n\n"); 71 | if(tracklen != 32) 72 | { 73 | f_printf(&fat_file, "tracklength %02x\n\n", tracklen); 74 | } 75 | f_printf(&fat_file, "speed %02x\n\n", songspeed); 76 | for(i = 0; i < songlen; i++) { 77 | f_printf(&fat_file, "songline %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 78 | i, 79 | song[i].track[0], 80 | song[i].transp[0], 81 | song[i].track[1], 82 | song[i].transp[1], 83 | song[i].track[2], 84 | song[i].transp[2], 85 | song[i].track[3], 86 | song[i].transp[3]); 87 | } 88 | f_printf(&fat_file, "\n"); 89 | struct trackline *tl = track(1,0); 90 | for(i = 1; i <= numtracks; i++) { 91 | for(j = 0; j < tracklen; j++) { 92 | if(tl->note || tl->instr || tl->cmd[0] || tl->cmd[1]) { 93 | f_printf(&fat_file, "trackline %02x %02x %02x %02x %02x %02x %02x %02x\n", 94 | i, 95 | j, 96 | tl->note, 97 | tl->instr, 98 | tl->cmd[0], 99 | tl->param[0], 100 | tl->cmd[1], 101 | tl->param[1]); 102 | } 103 | tl++; 104 | } 105 | } 106 | f_printf(&fat_file, "\n"); 107 | for(i = 1; i < NINST; i++) { 108 | if(instrument[i].length > 1) { 109 | for(j = 0; j < instrument[i].length; j++) { 110 | f_printf(&fat_file, "instrumentline %02x %02x %02x %02x %02x %02x\n", 111 | i, 112 | j, 113 | instrument[i].line[j].cmd, 114 | instrument[i].line[j].param, 115 | instrument[i].line[j].cmd2, 116 | instrument[i].line[j].param2); 117 | } 118 | } 119 | } 120 | 121 | f_close(&fat_file); 122 | setalert("file saved!"); 123 | } 124 | 125 | bool loadfile(char *fname) { 126 | clear_song(); 127 | fat_result = f_open(&fat_file, fname, FA_READ); 128 | strcpy(filename, fname); 129 | if(fat_result == FR_OK) { 130 | setalert("Loading..."); 131 | } else { 132 | switch (fat_result) { 133 | case (FR_DISK_ERR): 134 | setalert("low level error!"); break; 135 | case (FR_INT_ERR): 136 | setalert("assertion error"); break; 137 | case (FR_NOT_READY): 138 | setalert("physical drive not ready"); break; 139 | case (FR_NO_FILE): 140 | setalert("could not find file"); break; 141 | case (FR_NO_PATH): 142 | setalert("could not find path"); break; 143 | case (FR_INVALID_NAME): 144 | setalert("invalid name format"); break; 145 | case (FR_DENIED): 146 | setalert("denied access (full?)"); break; 147 | case (FR_EXIST): 148 | setalert("prohibited access"); break; 149 | case (FR_INVALID_OBJECT): 150 | setalert("invalid file/dir obj"); break; 151 | case (FR_WRITE_PROTECTED): 152 | setalert("drive is write protected"); break; 153 | case (FR_INVALID_DRIVE): 154 | setalert("drive number is invalid"); break; 155 | case (FR_NOT_ENABLED): 156 | setalert("no work area in volume"); break; 157 | case (FR_NO_FILESYSTEM): 158 | setalert("not valid FAT volume"); break; 159 | case (FR_MKFS_ABORTED): 160 | setalert("f_mkfs abort?"); break; 161 | case (FR_TIMEOUT): 162 | setalert("timeout"); break; 163 | case (FR_LOCKED): 164 | setalert("locked due to sharing"); break; 165 | case (FR_NOT_ENOUGH_CORE): 166 | setalert("LFN buffer no-allocate"); break; 167 | case (FR_TOO_MANY_OPEN_FILES): 168 | setalert("too many open files"); break; 169 | case (FR_INVALID_PARAMETER): 170 | setalert("invalid parameter"); break; 171 | default: 172 | setalert("weird, some other error!"); 173 | } 174 | return false; 175 | } 176 | 177 | char buf[48]; 178 | int cmd[3]; 179 | int i1, i2, trk[4], transp[4], param[3], note, instr; 180 | int i; 181 | 182 | // Restore default values for old songs that don't have one 183 | tracklen = 32; 184 | songspeed = 4; 185 | 186 | while (f_gets(buf, sizeof(buf), &fat_file)) { 187 | if(9 == rsscanf(buf, "songline %x %x %x %x %x %x %x %x %x", 188 | &i1, 189 | &trk[0], 190 | &transp[0], 191 | &trk[1], 192 | &transp[1], 193 | &trk[2], 194 | &transp[2], 195 | &trk[3], 196 | &transp[3])) { 197 | 198 | for(i = 0; i < 4; i++) { 199 | song[i1].track[i] = trk[i]; 200 | song[i1].transp[i] = transp[i]; 201 | } 202 | if(songlen <= i1) songlen = i1 + 1; 203 | } else if(8 == rsscanf(buf, "trackline %x %x %x %x %x %x %x %x", 204 | &i1, 205 | &i2, 206 | ¬e, 207 | &instr, 208 | &cmd[0], 209 | ¶m[0], 210 | &cmd[1], 211 | ¶m[1])) { 212 | 213 | if (i1 > numtracks) 214 | numtracks = i1; 215 | track(i1, i2)->note = note; 216 | track(i1, i2)->instr = instr; 217 | for(i = 0; i < 2; i++) { 218 | track(i1, i2)->cmd[i] = cmd[i]; 219 | track(i1, i2)->param[i] = param[i]; 220 | } 221 | } else if(6 == rsscanf(buf, "instrumentline %x %x %x %x %x %x", 222 | &i1, 223 | &i2, 224 | &cmd[0], 225 | ¶m[0], &cmd[1], ¶m[1])) { 226 | 227 | instrument[i1].line[i2].cmd = cmd[0]; 228 | instrument[i1].line[i2].param = param[0]; 229 | instrument[i1].line[i2].cmd2 = cmd[1]; 230 | instrument[i1].line[i2].param2 = param[1]; 231 | if(instrument[i1].length <= i2) instrument[i1].length = i2 + 1; 232 | } else if(4 == rsscanf(buf, "instrumentline %x %x %x %x", 233 | &i1, 234 | &i2, 235 | &cmd[0], 236 | ¶m[0])) { 237 | // Old format with single oscillator per channel 238 | // Set second oscillator to volume = 0 so it doesn't disturb us 239 | 240 | instrument[i1].line[i2].cmd = cmd[0]; 241 | instrument[i1].line[i2].param = param[0]; 242 | instrument[i1].line[i2].cmd2 = 'v'; 243 | instrument[i1].line[i2].param2 = 00; 244 | if(instrument[i1].length <= i2) instrument[i1].length = i2 + 1; 245 | } else if(1 == rsscanf(buf, "tracklength %x", &i)) { 246 | tracklen = i; 247 | } else if(1 == rsscanf(buf, "speed %x", &i)) { 248 | songspeed = i; 249 | } 250 | } 251 | 252 | f_close(&fat_file); 253 | return true; 254 | } 255 | 256 | void clear_song() 257 | { 258 | for(int i = 1; i < NINST; i++) { 259 | instrument[i].length = 1; 260 | instrument[i].line[0].cmd = '0'; 261 | instrument[i].line[0].param = 0; 262 | instrument[i].line[0].cmd2 = '0'; 263 | instrument[i].line[0].param2 = 0; 264 | } 265 | memset(tracking, 0, sizeof(tracking)); 266 | memset(song, 0, sizeof(song)); 267 | songlen = 1; 268 | tracklen = 32; // default 269 | numtracks = 0; 270 | } 271 | 272 | int realign_tracks(int new_tracklen) 273 | { 274 | if (new_tracklen == tracklen) 275 | return 0; 276 | // return 0 if everything went fine, 277 | // return 1 if we lost a few tracks since we have a huge new tracklen 278 | int returnvalue = 0; 279 | if (new_tracklen > tracklen) 280 | { 281 | for (int fix_index=numtracks; fix_index>1; fix_index--) 282 | { 283 | if (fix_index*new_tracklen >= NTRACKLINE) 284 | { 285 | returnvalue = 1; 286 | numtracks--; 287 | } 288 | else 289 | { 290 | struct trackline *src = &tracking[(fix_index-1)*tracklen]; 291 | struct trackline *dest = &tracking[(fix_index-1)*new_tracklen]; 292 | // copy the original track into the new spot 293 | memcpy(dest, src, tracklen*sizeof(struct trackline)); 294 | dest += tracklen; 295 | // zero out the rest of the track 296 | memset(dest, 0, (new_tracklen-tracklen)*sizeof(struct trackline)); 297 | } 298 | } 299 | // zero out the rest of the track 1 300 | memset(&tracking[tracklen], 0, (new_tracklen-tracklen)*sizeof(struct trackline)); 301 | } 302 | else 303 | { 304 | for (int fix_index=2; fix_index<=numtracks; fix_index++) 305 | { 306 | struct trackline *src = &tracking[(fix_index-1)*tracklen]; 307 | struct trackline *dest = &tracking[(fix_index-1)*new_tracklen]; 308 | // copy the original track into the new spot 309 | memcpy(dest, src, new_tracklen*sizeof(struct trackline)); 310 | } 311 | 312 | } 313 | tracklen = new_tracklen; 314 | return returnvalue; // if everything is alright 315 | } 316 | 317 | 318 | // Reduced version of scanf (%d, %x, %c, %n are supported) 319 | // thanks to https://groups.google.com/d/msg/comp.arch.fpga/ImYAZ6X_Wm4/WE-gYX-mNSgJ 320 | // %d dec integer (E.g.: 12) 321 | // %x hex integer (E.g.: 0xa0) 322 | // %b bin integer (E.g.: b1010100010) 323 | // %n hex, de or bin integer (e.g: 12, 0xa0, b1010100010) 324 | // %c any character 325 | // 326 | int rsscanf(const char* str, const char* format, ...) 327 | { 328 | va_list ap; 329 | int value, tmp; 330 | int count; 331 | int pos; 332 | char neg, fmt_code; 333 | //const char* pf; 334 | 335 | va_start(ap, format); 336 | 337 | for (/*pf = format, */count = 0; *format != 0 && *str != 0; format++, str++) 338 | { 339 | while (*format == ' ' && *format != 0) 340 | format++; 341 | if (*format == 0) 342 | break; 343 | 344 | while (*str == ' ' && *str != 0) 345 | str++; 346 | if (*str == 0) 347 | break; 348 | 349 | if (*format == '%') 350 | { 351 | format++; 352 | if (*format == 'n') 353 | { 354 | if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) 355 | { 356 | fmt_code = 'x'; 357 | str += 2; 358 | } 359 | else 360 | if (str[0] == 'b') 361 | { 362 | fmt_code = 'b'; 363 | str++; 364 | } 365 | else 366 | fmt_code = 'd'; 367 | } 368 | else 369 | fmt_code = *format; 370 | 371 | switch (fmt_code) 372 | { 373 | case 'x': 374 | case 'X': 375 | for (value = 0, pos = 0; *str != 0; str++, pos++) 376 | { 377 | if ('0' <= *str && *str <= '9') 378 | tmp = *str - '0'; 379 | else 380 | if ('a' <= *str && *str <= 'f') 381 | tmp = *str - 'a' + 10; 382 | else 383 | if ('A' <= *str && *str <= 'F') 384 | tmp = *str - 'A' + 10; 385 | else 386 | break; 387 | 388 | value *= 16; 389 | value += tmp; 390 | } 391 | if (pos == 0) 392 | return count; 393 | *(va_arg(ap, int*)) = value; 394 | count++; 395 | break; 396 | 397 | case 'b': 398 | for (value = 0, pos = 0; *str != 0; str++, pos++) 399 | { 400 | if (*str != '0' && *str != '1') 401 | break; 402 | value *= 2; 403 | value += *str - '0'; 404 | } 405 | if (pos == 0) 406 | return count; 407 | *(va_arg(ap, int*)) = value; 408 | count++; 409 | break; 410 | 411 | case 'd': 412 | if (*str == '-') 413 | { 414 | neg = 1; 415 | str++; 416 | } 417 | else 418 | neg = 0; 419 | for (value = 0, pos = 0; *str != 0; str++, pos++) 420 | { 421 | if ('0' <= *str && *str <= '9') 422 | value = value*10 + (int)(*str - '0'); 423 | else 424 | break; 425 | } 426 | if (pos == 0) 427 | return count; 428 | *(va_arg(ap, int*)) = neg ? -value : value; 429 | count++; 430 | break; 431 | 432 | case 'c': 433 | *(va_arg(ap, char*)) = *str; 434 | count++; 435 | break; 436 | 437 | default: 438 | return count; 439 | } 440 | } 441 | else 442 | { 443 | if (*format != *str) 444 | break; 445 | } 446 | } 447 | 448 | va_end(ap); 449 | 450 | return count; 451 | } 452 | -------------------------------------------------------------------------------- /gui.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ncurses.h" 5 | #include 6 | 7 | #include "lib/events/events.h" 8 | 9 | #include "lib/chiptune/chiptune.h" 10 | #include "fatfs/ff.h" 11 | 12 | // TODO: 13 | // FEATURES: 14 | // * ` on a track, if on a note, goes to edit that note's instrument 15 | // * Home/End - sends you to tracky songy = 0 type of thing, depending on tab 16 | // * PgUp/PgDn - sends you up/down the list by 16 or so lines 17 | // * shift+space -> play song from beginning 18 | // * ctrl+space -> loop song? 19 | // * shift+tab -> move backwards through tabs 20 | // ALGORITHMS 21 | // * make numtracks go up when adding a note to a track, not just when moving to a new one 22 | // * efficiently clear out instrument column when changing instrument when next one has less length 23 | 24 | 25 | #include "stuff.h" 26 | 27 | // choose the way to write your scale here: 28 | #ifdef GERMAN_KEYS 29 | static const char * const notenames[] = {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "H-"}; 30 | #else 31 | static const char * const notenames[] = {"C-", "C#", "D-", "Eb", "E-", "F-", "F#", "G-", "Ab", "A-", "Bb", "B-"}; 32 | #endif 33 | uint8_t text_color; 34 | 35 | static const char *keymap[2] = { // how to layout two octaves chromatically on the keyboard 36 | "zsxdcvgbhnjm,l.;/", // first octave 37 | "q2w3er5t6y7ui9o0p" // second octave 38 | }; 39 | 40 | static const char *validcmds = "0bdfijlmtvw~+="; 41 | 42 | #define SETLO(v,x) v = ((v) & 0xf0) | (x) 43 | #define SETHI(v,x) v = ((v) & 0x0f) | ((x) << 4) 44 | int songx, songy, songoffs; 45 | u16 songlen=1; 46 | int trackx=0, tracky=0, trackoffs=0; 47 | int instrx=0, instry=0, instroffs=0; 48 | int currtrack=1, currinstr=1; 49 | int currtab=0; 50 | int octave=4; 51 | 52 | char cmd[16] = {0, 0}; // we do this to avoid undefined behavior in setcmd 53 | char cmdinput[8]; 54 | u8 cmdinputpos; 55 | u8 cmdinputnumeric; 56 | 57 | enum { 58 | MODE_NONE = 0, 59 | MODE_EDIT = 1 60 | }; 61 | int mode = MODE_NONE; 62 | 63 | struct instrument iclip; 64 | struct trackline tclip[256]; 65 | 66 | static void drawgui(); 67 | 68 | static void resetgui() 69 | { 70 | mode = MODE_NONE; 71 | currtab = 0; 72 | songx = 0; 73 | songy = 0; 74 | currtrack = 1; 75 | tracky = 0; 76 | trackx = 0; 77 | currinstr = 1; 78 | instry = 0; 79 | instrx = 0; 80 | } 81 | 82 | void setalert(const char *alerto) 83 | { 84 | int i = print_at(0, LINES - 1, text_color, alerto); 85 | char* alert = &vram[LINES - 1][0]; 86 | for(; i < 32; i++) 87 | alert[i] = ' '; 88 | } 89 | 90 | static void setcmd(const char *cmdo) 91 | { 92 | if(!cmd[0]) // if cmd had nothing in it 93 | { 94 | if (cmd[1] != cmdo[1]) // check if the previous command was the desired command 95 | { // if not, then we need to remove previous input. 96 | cmdinput[0] = 0; // kill previous input 97 | cmdinputpos = 0; 98 | } 99 | strcpy(cmd, cmdo); 100 | } 101 | else if (cmd[0] != cmdo[0]) // command did not start with cmdo[0] 102 | { 103 | strcpy(cmd, cmdo); 104 | cmdinput[0] = 0; // zero the input string, we just changed input. 105 | cmdinputpos = 0; 106 | } 107 | else // cmd[0] was cmdo[0], so we want to remove command. 108 | { 109 | cmd[0] = 0; 110 | return; 111 | } 112 | switch (cmd[0]) 113 | { 114 | case 'b': // base filename 115 | case 'f': // file to open 116 | cmdinputnumeric = 0; 117 | break; 118 | case 't': // tracklength 119 | case 's': // songspeed 120 | cmdinputnumeric = 1; 121 | break; 122 | } 123 | } 124 | 125 | void evalcmd() 126 | { 127 | if (cmdinput[0]) 128 | { 129 | int result; 130 | switch (cmd[0]) 131 | { 132 | case 'b': // basename of file 133 | sprintf(filename, "%s.song", cmdinput); 134 | break; 135 | case 'f': // file to open 136 | silence(); 137 | char newfile[13]; 138 | sprintf(newfile, "%s.song", cmdinput); 139 | if (loadfile(newfile)) { 140 | cmd[0] = 0; 141 | resetgui(); 142 | redrawgui(); 143 | } 144 | break; 145 | case 't': // tracklength 146 | if (1 == sscanf(cmdinput, "%d", &result)) 147 | { 148 | if (result > 0 && result < 257) 149 | { 150 | if (realign_tracks(result)) 151 | { 152 | setalert("lost some higher tracks due to memory constraints!"); 153 | if (currtrack*tracklen > NTRACKLINE) 154 | currtrack = NTRACKLINE/tracklen; 155 | } 156 | drawgui(); 157 | } 158 | else 159 | setalert("need tracklength > 0 and < 257"); 160 | } 161 | else 162 | setalert("unknown input!!"); 163 | break; 164 | case 's': // songspeed 165 | if (1 == sscanf(cmdinput, "%d", &result)) 166 | { 167 | if (result > 0 && result < 256) 168 | songspeed = result; 169 | else 170 | setalert("need songspeed > 0 and < 256"); 171 | } 172 | else 173 | setalert("unknown input!!"); 174 | break; 175 | } 176 | } 177 | cmd[0] = 0; 178 | cmdinput[0] = 0; 179 | cmdinputpos = 0; 180 | } 181 | 182 | 183 | static void listfiles(void) 184 | { 185 | DIR dir; 186 | FRESULT res; 187 | FILINFO fno; 188 | 189 | res = f_opendir(&dir, ""); 190 | if (res != FR_OK) 191 | return; 192 | 193 | clear(); 194 | 195 | res = f_readdir(&dir, &fno); 196 | int line = 6; 197 | for (;;) 198 | { 199 | res = f_readdir(&dir, &fno); 200 | 201 | // End of dir? 202 | if (res != FR_OK || fno.fname[0] == 0) 203 | break; 204 | 205 | char* pos = strchr(fno.fname, '.'); 206 | if (pos == NULL) { 207 | continue; 208 | } 209 | 210 | if (!strncmp(".SON", pos, 4) || !strncmp(".son", pos, 4)) 211 | { 212 | print_at(2, line++, text_color, fno.fname); 213 | } 214 | } 215 | 216 | print_at(2, line++, text_color, "-------------"); 217 | f_closedir(&dir); 218 | } 219 | 220 | 221 | int hexdigit(char c) { 222 | if(c >= '0' && c <= '9') return c - '0'; 223 | if(c >= 'a' && c <= 'f') return c - 'a' + 10; 224 | return -1; 225 | } 226 | 227 | int freqkey(int c) { 228 | char *s; 229 | int f = -1; 230 | 231 | if(c == '-' /*|| c == KEY_DC*/) return 0; 232 | if(c == '=') return 12 * 9 + 2; // Stop oscillator (in instruments) 233 | if(c > 0 && c < 256) { 234 | s = strchr(keymap[0], c); 235 | if(s) { 236 | f = (s - (keymap[0])) + octave * 12 + 1; 237 | } else { 238 | s = strchr(keymap[1], c); 239 | if(s) { 240 | f = (s - (keymap[1])) + octave * 12 + 12 + 1; 241 | } 242 | } 243 | } 244 | if(f > 12 * 9 + 1) return -1; 245 | return f; 246 | } 247 | 248 | //void exitgui() { 249 | // endwin(); 250 | //} 251 | 252 | void initgui() { 253 | initscr(); 254 | //noecho(); 255 | //keypad(stdscr, TRUE); 256 | //raw(); 257 | redrawgui(); 258 | //atexit(exitgui); 259 | } 260 | 261 | static void hexstr(char* target, uint8_t value) 262 | { 263 | static const char hex[] = "0123456789ABCDEF"; 264 | target[0] = hex[value >> 4]; 265 | target[1] = hex[value & 0xF]; 266 | } 267 | 268 | static void scrollbar(int x, int y, int height, int pos, int range) 269 | { 270 | int start = pos * height / range; 271 | int end = start + height * height / range; 272 | 273 | for (int i = 0; i < height; i++) 274 | { 275 | uint8_t* tgt = &vram_attr[y+i][x]; 276 | if (i >= start && i <= end) 277 | *tgt = 6; 278 | else 279 | *tgt = 0; 280 | } 281 | } 282 | 283 | static void drawsonged(int x, int y, int height) { 284 | int i, j, k = 0; 285 | char buf[6]; 286 | 287 | int showline; 288 | 289 | if (playsong) 290 | showline = (songpos - 1 + songlen) % songlen; 291 | else 292 | showline = songy; 293 | 294 | if(showline < songoffs) songoffs = showline; 295 | if(showline >= songoffs + height) songoffs = showline - height + 1; 296 | 297 | buf[5] = 0; 298 | buf[2] = ':'; 299 | 300 | for(i = 0; i < songlen; i++) { 301 | if(i >= songoffs && i - songoffs < height) { 302 | move(y + k, x + 0); 303 | if(i == songy) 304 | attrset(A_BOLD); 305 | else 306 | attrset(A_NORMAL); 307 | hexstr(buf, i); 308 | buf[3] = 0; 309 | addstr(buf); 310 | for(j = 0; j < 4; j++) { 311 | addch(' '); 312 | hexstr(buf, song[i].track[j]); 313 | hexstr(buf + 3, song[i].transp[j]); 314 | addstr(buf); 315 | } 316 | if(playsong && songpos == (i + 1)) 317 | *(uint16_t*)(&vram_attr[y+k][x]) = 0x0505; 318 | k++; 319 | } 320 | } 321 | 322 | // blank lines at song end 323 | while (k < height) { 324 | move(y + k, x + 0); 325 | addstr(" "); 326 | k++; 327 | } 328 | 329 | if (songlen > height) { 330 | scrollbar(x-1, y, height, songoffs, songlen); 331 | } 332 | } 333 | 334 | static void drawtracked(int x, int y, int height) { 335 | int i, j; 336 | char buf[6]; 337 | 338 | if (height > tracklen) 339 | height = tracklen; 340 | 341 | int position; 342 | if (playtrack) 343 | position = (trackpos - 1 + tracklen) % tracklen ; 344 | else 345 | position = tracky; 346 | 347 | if(position < trackoffs) trackoffs = position; 348 | if(position >= trackoffs + height) trackoffs = position - height + 1; 349 | 350 | for(i = 0; i < tracklen; i++) { 351 | if(i >= trackoffs && i - trackoffs < height) { 352 | move(y + i - trackoffs, x + 0); 353 | if(i == tracky) 354 | attrset(A_BOLD); 355 | else 356 | attrset(A_NORMAL); 357 | buf[2] = ':'; 358 | buf[3] = ' '; 359 | buf[4] = 0; 360 | hexstr(buf, i); 361 | addstr(buf); 362 | if(track(currtrack,i)->note) { 363 | sprintf(buf, "%s%d ", 364 | notenames[(track(currtrack,i)->note - 1) % 12], 365 | (track(currtrack,i)->note - 1) / 12); 366 | } else { 367 | buf[0] = buf[1] = buf[2] = '-'; 368 | } 369 | addstr(buf); 370 | 371 | buf[2] = 0; 372 | hexstr(buf, track(currtrack, i)->instr); 373 | addstr(buf); 374 | for(j = 0; j < 2; j++) { 375 | buf[0] = ' '; 376 | if(track(currtrack,i)->cmd[j]) { 377 | buf[1] = track(currtrack,i)->cmd[j]; 378 | hexstr(buf + 2, track(currtrack,i)->param[j]); 379 | } else { 380 | buf[1] = buf[2] = buf[3] = '.'; 381 | buf[4] = 0; 382 | } 383 | addstr(buf); 384 | } 385 | if(playtrack && ((i + 1) % tracklen) == trackpos) 386 | *(uint16_t*)(&vram_attr[y+i-trackoffs][x]) = 0x0505; 387 | } 388 | } 389 | 390 | if (tracklen > height) { 391 | scrollbar(x-1, y, height, trackoffs, tracklen); 392 | } 393 | } 394 | 395 | static void drawinstred(int x, int y, int height) { 396 | int i, j = 0; 397 | char buf[8]; 398 | 399 | // TODO: 400 | // what is modifying instry/instroffs to be -1? 401 | // this should not be required! 402 | if(instroffs <0) instroffs=0; 403 | if(instry <0) instry=0; 404 | // but for some reason somehow these guys get turned to -1 somewhere 405 | 406 | if(instry >= instrument[currinstr].length) instry = instrument[currinstr].length - 1; 407 | 408 | if(instry < instroffs) instroffs = instry; 409 | if(instry >= instroffs + height) instroffs = instry - height + 1; 410 | 411 | for(i = 0; i < instrument[currinstr].length; i++) { 412 | if(i >= instroffs && i - instroffs < height) { 413 | move(y + j, x + 0); 414 | if(i == instry) attrset(A_BOLD); 415 | sprintf(buf, "%02x: %c ", i, instrument[currinstr].line[i].cmd); 416 | addstr(buf); 417 | if(instrument[currinstr].line[i].cmd == '+' || instrument[currinstr].line[i].cmd == '=') { 418 | if(instrument[currinstr].line[i].param > 83) 419 | sprintf(buf, "---"); 420 | else if(instrument[currinstr].line[i].param) { 421 | sprintf(buf, "%s%d", 422 | notenames[(instrument[currinstr].line[i].param - 1) % 12], 423 | (instrument[currinstr].line[i].param - 1) / 12); 424 | } else { 425 | buf[0] = buf[1] = buf[2] = '-'; 426 | buf[3] = 0; 427 | } 428 | } else { 429 | hexstr(buf, instrument[currinstr].line[i].param); 430 | buf[2] = '-'; 431 | buf[3] = 0; 432 | } 433 | addstr(buf); 434 | 435 | sprintf(buf, " %c ", instrument[currinstr].line[i].cmd2); 436 | addstr(buf); 437 | 438 | if(instrument[currinstr].line[i].cmd2 == '+' || instrument[currinstr].line[i].cmd2 == '=') { 439 | if(instrument[currinstr].line[i].param2 > 83) 440 | sprintf(buf, "---"); 441 | else if(instrument[currinstr].line[i].param2) { 442 | sprintf(buf, "%s%d", 443 | notenames[(instrument[currinstr].line[i].param2 - 1) % 12], 444 | (instrument[currinstr].line[i].param2 - 1) / 12); 445 | } else { 446 | buf[0] = buf[1] = buf[2] = '-'; 447 | buf[3] = 0; 448 | } 449 | } else { 450 | hexstr(buf, instrument[currinstr].line[i].param2); 451 | buf[2] = '-'; 452 | buf[3] = 0; 453 | } 454 | addstr(buf); 455 | 456 | attrset(A_NORMAL); 457 | j++; 458 | } 459 | } 460 | 461 | while (j < height) 462 | { 463 | move(y + j, x + 0); 464 | addstr(" "); 465 | j++; 466 | } 467 | } 468 | 469 | void handleinput() { 470 | int c, x; 471 | if ((c = getch()) != KEY_ERR) 472 | { 473 | if (cmd[0]) 474 | { 475 | // numbers uppercase letters lowercase letters _ or - 476 | if ( (c>=48 && c<=57) || (c>=65 && c<=90) || (c>=97 && c<=122) || (c == 95 || c == 45) ) 477 | { 478 | if (cmdinputnumeric) 479 | { 480 | // only allow inputting numbers 481 | if (c>=48 && c<=57) 482 | { 483 | if (cmdinputpos < 2) 484 | { 485 | cmdinput[cmdinputpos] = c; 486 | cmdinput[++cmdinputpos] = 0; 487 | } 488 | else 489 | { 490 | cmdinput[cmdinputpos] = c; 491 | cmdinput[cmdinputpos+1] = 0; 492 | } 493 | } 494 | } 495 | else 496 | { 497 | if (cmdinputpos < 7) 498 | { 499 | cmdinput[cmdinputpos] = c; 500 | cmdinput[++cmdinputpos] = 0; 501 | } 502 | else 503 | cmdinput[cmdinputpos] = c; 504 | } 505 | } 506 | else switch (c) 507 | { 508 | case 8: // backspace 509 | if (cmdinputpos > 0) 510 | { 511 | if (cmdinputnumeric) 512 | { 513 | if (cmdinputpos == 2 && cmdinput[cmdinputpos]) 514 | cmdinput[cmdinputpos] = 0; 515 | else 516 | cmdinput[--cmdinputpos] = 0; 517 | } 518 | else 519 | { 520 | if (cmdinputpos == 7 && cmdinput[cmdinputpos]) 521 | cmdinput[cmdinputpos] = 0; 522 | else 523 | cmdinput[--cmdinputpos] = 0; 524 | } 525 | } 526 | break; 527 | case '\n': 528 | evalcmd(); 529 | break; 530 | case 'T' - '@': 531 | setcmd("tracklength"); 532 | break; 533 | case 'F' - '@': 534 | setcmd("base filename"); 535 | break; 536 | case 'O' - '@': 537 | setcmd("file to open"); 538 | listfiles(); 539 | break; 540 | case 'S' - '@': 541 | setcmd("songspeed"); 542 | break; 543 | } 544 | } 545 | else 546 | switch(c) { 547 | case ' ': 548 | if (playsong || playtrack) 549 | { 550 | // stop play 551 | silence(); 552 | } 553 | else 554 | { 555 | // start play 556 | if(currtab == 1) { 557 | startplaytrack(currtrack); 558 | } else if (currtab == 0) { 559 | startplaysong(songy); 560 | } else { 561 | startplaysong(0); 562 | } 563 | } 564 | break; 565 | case 10: // enter: toggle edit mode 566 | case 13: // enter on other systems... 567 | if (mode & MODE_EDIT) 568 | { 569 | mode -= MODE_EDIT; // lock it down 570 | } 571 | else 572 | { 573 | mode += MODE_EDIT; // allow editing 574 | } 575 | break; 576 | case 'N' - '@': 577 | case 'N': 578 | case 9: 579 | currtab++; 580 | if (mode & MODE_EDIT) 581 | currtab %= 3; 582 | else 583 | currtab %= 2; // this glosses over a bug 584 | break; 585 | case 'P' - '@': 586 | case 'P': 587 | currtab--; 588 | if (mode & MODE_EDIT) 589 | currtab %= 3; 590 | else 591 | currtab %= 2; 592 | break; 593 | case 'W' - '@': 594 | if (mode & MODE_EDIT) 595 | savefile(filename); 596 | break; 597 | case 'T' - '@': 598 | if (mode & MODE_EDIT) 599 | setcmd("tracklength"); 600 | break; 601 | case 'F' - '@': 602 | setcmd("base filename"); 603 | break; 604 | case 'O' - '@': 605 | setcmd("file to open"); 606 | listfiles(); 607 | break; 608 | case 'S' - '@': 609 | if (mode & MODE_EDIT) 610 | setcmd("songspeed"); 611 | break; 612 | case '<': 613 | if(octave) octave--; 614 | break; 615 | case '>': 616 | if(octave < 8) octave++; 617 | break; 618 | case '[': 619 | if(currinstr > 1) { 620 | currinstr--; 621 | if (instrument[currinstr].length < instrument[currinstr+1].length) 622 | redrawgui(); 623 | } 624 | break; 625 | case ']': 626 | if(currinstr < NINST-1) { 627 | currinstr++; 628 | if (instrument[currinstr].length < instrument[currinstr-1].length) 629 | redrawgui(); 630 | } 631 | break; 632 | case '{': 633 | if(currtrack > 1) currtrack--; 634 | break; 635 | case '}': 636 | if((currtrack+1)*tracklen <= NTRACKLINE && currtrack < 255) { 637 | currtrack++; 638 | // update the number of tracks -- TODO: probably should wait to put 639 | // something in them, but nevertheless keep track of it. 640 | if (numtracks < currtrack) 641 | numtracks = currtrack; 642 | } else { 643 | setalert("can't fit more tracks in memory"); 644 | } 645 | break; 646 | case '`': 647 | if(currtab == 0) { 648 | int t = song[songy].track[songx / 4]; 649 | if(t) currtrack = t; 650 | currtab = 1; 651 | } else if(currtab == 1) { 652 | currtab = 0; 653 | } 654 | break; 655 | // case '#': // or '\\' ? 656 | // optimize(); 657 | // break; 658 | // case '%': // or '=' ? 659 | // export(); 660 | // break; 661 | case KEY_LEFT: 662 | switch(currtab) { 663 | case 0: 664 | if(songx) songx--; 665 | break; 666 | case 1: 667 | if(trackx) trackx--; 668 | break; 669 | case 2: 670 | if((mode&MODE_EDIT) && instrx) instrx--; 671 | break; 672 | } 673 | break; 674 | case KEY_RIGHT: 675 | switch(currtab) { 676 | case 0: 677 | if(songx < 15) songx++; 678 | break; 679 | case 1: 680 | if(trackx < 8) trackx++; 681 | break; 682 | case 2: 683 | if((mode&MODE_EDIT) && instrx < 5) instrx++; 684 | break; 685 | } 686 | break; 687 | case KEY_UP: 688 | case KEY_PAGEUP: 689 | { 690 | int off = (c == KEY_PAGEUP) ? 16 : 1; 691 | switch(currtab) { 692 | case 0: 693 | if(songy >= off) songy-=off; 694 | break; 695 | case 1: 696 | if(tracky >= off) { 697 | tracky-=off; 698 | } else { 699 | tracky = tracklen - 1; 700 | } 701 | break; 702 | case 2: 703 | if(instry >= off) instry-=off; 704 | break; 705 | } 706 | break; 707 | } 708 | case KEY_DOWN: 709 | case KEY_PAGEDOWN: 710 | { 711 | int off = (c == KEY_PAGEDOWN) ? 16 : 1; 712 | switch(currtab) { 713 | case 0: 714 | if(songy < songlen - off) songy+=off; 715 | break; 716 | case 1: 717 | if(tracky < tracklen - off) { 718 | tracky+=off; 719 | } else { 720 | tracky = 0; 721 | } 722 | break; 723 | case 2: 724 | if(instry < instrument[currinstr].length - off) instry+=off; 725 | break; 726 | } 727 | break; 728 | } 729 | case 'C': // copy 730 | if (mode & MODE_EDIT) 731 | { 732 | if(currtab == 2) { 733 | memcpy(&iclip, &instrument[currinstr], sizeof(struct instrument)); 734 | } else if(currtab == 1) { 735 | memcpy(&tclip, &tracking[tracklen*currtrack], tracklen*sizeof(struct trackline)); 736 | } 737 | } 738 | break; 739 | case 'V': // paste 740 | if (mode & MODE_EDIT) 741 | { 742 | if(currtab == 2) { 743 | memcpy(&instrument[currinstr], &iclip, sizeof(struct instrument)); 744 | } else if(currtab == 1) { 745 | memcpy(&tracking[tracklen*currtrack], &tclip, tracklen*sizeof(struct trackline)); 746 | } 747 | } 748 | break; 749 | case 8: // backspace 750 | case 127: // delete 751 | if(mode & MODE_EDIT) switch (currtab) { 752 | case 0: 753 | song[songy].track[songx/4] = 0; 754 | song[songy].transp[songx/4] = 0; 755 | break; 756 | case 1: 757 | memset(track(currtrack,tracky), 0, sizeof(struct trackline)); 758 | break; 759 | case 2: 760 | instrument[currinstr].line[instry].cmd = '0'; 761 | instrument[currinstr].line[instry].param = 0; 762 | } 763 | break; 764 | default: 765 | if(mode & MODE_EDIT) { 766 | x = hexdigit(c); 767 | // helpful for debugging: 768 | // sprintf(alert, "%d %x %c", (int) c, x, c); 769 | if(x >= 0) { 770 | if(currtab == 2 771 | && instrx > 0 772 | && instrument[currinstr].line[instry].cmd != '+' 773 | && instrument[currinstr].line[instry].cmd != '=') { 774 | switch(instrx) { 775 | case 1: SETHI(instrument[currinstr].line[instry].param, x); break; 776 | case 2: SETLO(instrument[currinstr].line[instry].param, x); break; 777 | case 4: SETHI(instrument[currinstr].line[instry].param2, x); break; 778 | case 5: SETLO(instrument[currinstr].line[instry].param2, x); break; 779 | } 780 | } 781 | if(currtab == 1 && trackx > 0) { 782 | switch(trackx) { 783 | case 1: SETHI(track(currtrack,tracky)->instr, x); break; 784 | case 2: SETLO(track(currtrack,tracky)->instr, x); break; 785 | case 4: if(track(currtrack,tracky)->cmd[0]) 786 | SETHI(track(currtrack,tracky)->param[0], x); break; 787 | case 5: if(track(currtrack,tracky)->cmd[0]) 788 | SETLO(track(currtrack,tracky)->param[0], x); break; 789 | case 7: if(track(currtrack,tracky)->cmd[1]) 790 | SETHI(track(currtrack,tracky)->param[1], x); break; 791 | case 8: if(track(currtrack,tracky)->cmd[1]) 792 | SETLO(track(currtrack,tracky)->param[1], x); break; 793 | } 794 | } 795 | if(currtab == 0) { 796 | switch(songx & 3) { 797 | case 0: SETHI(song[songy].track[songx / 4], x); break; 798 | case 1: SETLO(song[songy].track[songx / 4], x); break; 799 | case 2: SETHI(song[songy].transp[songx / 4], x); break; 800 | case 3: SETLO(song[songy].transp[songx / 4], x); break; 801 | } 802 | } 803 | } 804 | x = freqkey(c); 805 | if(x >= 0) { 806 | if(currtab == 2 807 | && instrx && instrx < 3 808 | && (instrument[currinstr].line[instry].cmd == '+' || instrument[currinstr].line[instry].cmd == '=')) { 809 | instrument[currinstr].line[instry].param = x; 810 | } 811 | if(currtab == 2 812 | && instrx > 3 813 | && (instrument[currinstr].line[instry].cmd2 == '+' || instrument[currinstr].line[instry].cmd2 == '=')) { 814 | instrument[currinstr].line[instry].param2 = x; 815 | } 816 | if(currtab == 1 && !trackx) { 817 | track(currtrack,tracky)->note = x; 818 | if(x) { 819 | track(currtrack,tracky)->instr = currinstr; 820 | } else { 821 | track(currtrack,tracky)->instr = 0; 822 | } 823 | tracky++; 824 | tracky %= tracklen; 825 | if(x) iedplonk(x, currinstr); 826 | } 827 | } 828 | if(currtab == 2 && instrx == 0) { 829 | if(strchr(validcmds, c)) { 830 | instrument[currinstr].line[instry].cmd = c; 831 | } 832 | } 833 | if(currtab == 2 && instrx == 3) { 834 | if(strchr(validcmds, c)) { 835 | instrument[currinstr].line[instry].cmd2 = c; 836 | } 837 | } 838 | if(currtab == 1 && (trackx == 3 || trackx == 6 || trackx == 9)) { 839 | if(strchr(validcmds, c)) { 840 | if(c == '.' || c == '0') c = 0; 841 | track(currtrack,tracky)->cmd[(trackx - 3) / 3] = c; 842 | } 843 | } 844 | if(c == 'A') { 845 | if(currtab == 2) { 846 | struct instrument *in = &instrument[currinstr]; 847 | 848 | if(in->length < NINSTLINE) { 849 | memmove(&in->line[instry + 2], &in->line[instry + 1], sizeof(struct instrline) * (in->length - instry - 1)); 850 | instry++; 851 | in->length++; 852 | in->line[instry].cmd = '0'; 853 | in->line[instry].param = 0; 854 | } 855 | } else if(currtab == 0) { 856 | if(songlen < 256) { 857 | memmove(&song[songy + 2], &song[songy + 1], sizeof(struct songline) * (songlen - songy - 1)); 858 | songy++; 859 | songlen++; 860 | memset(&song[songy], 0, sizeof(struct songline)); 861 | } 862 | } 863 | } else if(c == 'I') { 864 | if(currtab == 2) { 865 | struct instrument *in = &instrument[currinstr]; 866 | 867 | if(in->length < NINSTLINE) { 868 | memmove(&in->line[instry + 1], &in->line[instry + 0], sizeof(struct instrline) * (in->length - instry)); 869 | in->length++; 870 | in->line[instry].cmd = '0'; 871 | in->line[instry].param = 0; 872 | } 873 | } else if(currtab == 0) { 874 | if(songlen < 256) { 875 | memmove(&song[songy + 1], &song[songy + 0], sizeof(struct songline) * (songlen - songy)); 876 | songlen++; 877 | memset(&song[songy], 0, sizeof(struct songline)); 878 | } 879 | } 880 | } else if(c == 'D') { 881 | if(currtab == 2) { 882 | struct instrument *in = &instrument[currinstr]; 883 | 884 | if(in->length > 1) { 885 | memmove(&in->line[instry + 0], &in->line[instry + 1], sizeof(struct instrline) * (in->length - instry - 1)); 886 | in->length--; 887 | if(instry >= in->length) instry = in->length - 1; 888 | redrawgui(); 889 | } 890 | } else if(currtab == 0) { 891 | if(songlen > 1) { 892 | memmove(&song[songy + 0], &song[songy + 1], sizeof(struct songline) * (songlen - songy - 1)); 893 | songlen--; 894 | if(songy >= songlen) songy = songlen - 1; 895 | redrawgui(); 896 | } 897 | } 898 | } 899 | } 900 | else { // 901 | x = freqkey(c); 902 | 903 | if(x > 0) { 904 | iedplonk(x, currinstr); 905 | } 906 | } 907 | break; 908 | } 909 | } 910 | } 911 | 912 | static void drawgui() { 913 | char buf[32]; 914 | int songcols[] = {0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21, 22}; 915 | int trackcols[] = {0, 4, 5, 7, 8, 9, 11, 12, 13}; 916 | int instrcols[] = {0, 2, 3, 6, 8, 9}; 917 | 918 | if (mode & MODE_EDIT) 919 | { 920 | mvaddstr(0, COLUMNS-22, "lock"); 921 | } 922 | else 923 | { 924 | mvaddstr(0, COLUMNS-22, "edit"); 925 | } 926 | if (playsong||playtrack) 927 | { 928 | mvaddstr(1, COLUMNS-22, "stop"); 929 | } 930 | else 931 | { 932 | mvaddstr(1, COLUMNS-22, "play"); 933 | } 934 | 935 | mvaddstr(2, 14, " "); 936 | mvaddstr(2, 14, filename); 937 | text_color = 3; 938 | if (mode & MODE_EDIT) 939 | text_color = 3; 940 | else 941 | text_color = A_REVERSE; 942 | sprintf(buf, "^S)ongspeed: %d ", songspeed); 943 | mvaddstr(3, 1, buf); 944 | sprintf(buf, "^T)racklength: %d ", tracklen); 945 | mvaddstr(3, 30, buf); 946 | mvaddstr(3, COLUMNS - 23, "^W)rite"); 947 | 948 | text_color = 0; 949 | if (cmd[0] != 'f') { 950 | drawsonged(2, 6, LINES - 8); 951 | } 952 | 953 | buf[2] = 0; 954 | hexstr(buf, currtrack); 955 | mvaddstr(5, 37, buf); 956 | drawtracked(31, 6, LINES - 8); 957 | 958 | hexstr(buf, currinstr); 959 | mvaddstr(5, 58, buf); 960 | drawinstred(50, 6, LINES - 12); 961 | 962 | hexstr(buf, octave); 963 | mvaddstr(5, COLUMNS - 7, buf); 964 | 965 | // Draw channel volumes 966 | int p = 5; 967 | for (int o = 0; o < 4; o++) 968 | { 969 | int v = osc[o].volume >> 4; 970 | int k; 971 | for (k = 0; k < v; k++) 972 | { 973 | vram_attr[6 + k][p] = 3 + osc[o].waveform; 974 | } 975 | for (; k < 16; k++) 976 | { 977 | vram_attr[6 + k][p] = 0; 978 | } 979 | p += 6; 980 | } 981 | 982 | // Update cursor position 983 | int cx, cy; 984 | if (cmd[0]) 985 | { 986 | int off = sprintf(buf, "new %s? %s", cmd, cmdinput); 987 | setalert(buf); 988 | cy = LINES - 1; 989 | cx = off; 990 | } else { 991 | switch(currtab) { 992 | case 0: 993 | default: 994 | cy = 6 + songy - songoffs; 995 | cx = 0 + 6 + songcols[songx]; 996 | break; 997 | case 1: 998 | cy = 6 +tracky - trackoffs; 999 | cx = 29 + 6 + trackcols[trackx]; 1000 | break; 1001 | case 2: 1002 | cy = 6 + instry - instroffs; 1003 | cx = 48 + 6 + instrcols[instrx]; 1004 | break; 1005 | } 1006 | 1007 | if (cy < 6) 1008 | return; 1009 | if (cy >= LINES - 2) 1010 | return; 1011 | } 1012 | 1013 | move (cy, cx); 1014 | refresh(); 1015 | } 1016 | 1017 | void redrawgui() { 1018 | memset(vram_attr, 3, SCREEN_H * SCREEN_W); 1019 | text_color = 3; 1020 | mvaddstr(0, 0, " MUSIC CHIP TRACKER"); 1021 | 1022 | mvaddstr(0, COLUMNS-29, "enter [ ]"); 1023 | mvaddstr(1, COLUMNS-29, "space [ ]"); 1024 | 1025 | mvaddstr(2, 1, "^F)ilename:"); 1026 | 1027 | mvaddstr(3, COLUMNS - 30, "^O)pen"); 1028 | 1029 | mvaddstr(5, 1, "Song L1:\x1f\x1e R1:\x1f\x1e L2:\x1f\x1e R2:\x1f\x1e"); 1030 | 1031 | mvaddstr(5, 31, "Track {}"); 1032 | mvaddstr(5, 51, "Instr. []"); 1033 | mvaddstr(5, COLUMNS - 15, "Octave: <>"); 1034 | 1035 | mvaddstr(7, COLUMNS - 15, "-- KEYS --"); 1036 | mvaddstr(8, COLUMNS - 15, "A)ppend"); 1037 | mvaddstr(9, COLUMNS - 15, "I)nsert"); 1038 | mvaddstr(10,COLUMNS - 15, "D)elete"); 1039 | mvaddstr(11,COLUMNS - 15, "C)opy"); 1040 | mvaddstr(12,COLUMNS - 15, "V) Paste"); 1041 | mvaddstr(13,COLUMNS - 15, "TAB switch"); 1042 | mvaddstr(14,COLUMNS - 15, "` Goto track"); 1043 | 1044 | mvaddstr(15,COLUMNS - 15, "-- COMMANDS --"); 1045 | mvaddstr(16,COLUMNS - 15, "+ Rel. Note"); 1046 | mvaddstr(17,COLUMNS - 15, "= Abs. Note"); 1047 | mvaddstr(18,COLUMNS - 15, "b)itcrush"); 1048 | mvaddstr(19,COLUMNS - 15, "d)uty cycle"); 1049 | mvaddstr(20,COLUMNS - 15, "f)ade volume"); 1050 | mvaddstr(21,COLUMNS - 15, "i)nertia"); 1051 | mvaddstr(22,COLUMNS - 15, "j)ump"); 1052 | mvaddstr(23,COLUMNS - 15, "s(l)ide"); 1053 | mvaddstr(24,COLUMNS - 15, "pw(m)"); 1054 | mvaddstr(25,COLUMNS - 15, "t)ime delay"); 1055 | mvaddstr(26,COLUMNS - 15, "v)olume"); 1056 | mvaddstr(27,COLUMNS - 15, "w)aveform TSPN"); 1057 | mvaddstr(28,COLUMNS - 15, "~ Vibrato d/r"); 1058 | 1059 | text_color = 0; 1060 | drawgui(); 1061 | } 1062 | 1063 | void game_frame() { 1064 | events_poll(); 1065 | // palette[A_NORMAL] = 0xFFFF0000 | PINK; 1066 | playroutine(); 1067 | handleinput(); 1068 | drawgui(); 1069 | // palette[A_NORMAL] = 0xFFFF0000; // boring white on black 1070 | 1071 | } 1072 | -------------------------------------------------------------------------------- /test2.song: -------------------------------------------------------------------------------- 1 | musicchip tune 2 | version 1 3 | 4 | songline 00 00 00 00 00 81 00 00 00 5 | songline 01 00 00 00 00 80 00 67 00 6 | songline 02 00 00 00 00 82 00 68 00 7 | songline 03 01 00 00 00 00 00 00 00 8 | songline 04 01 00 00 00 00 00 00 00 9 | songline 05 01 00 10 00 03 00 00 00 10 | songline 06 01 00 10 00 00 00 00 00 11 | songline 07 01 00 10 00 00 00 30 00 12 | songline 08 01 00 10 00 00 00 31 00 13 | songline 09 01 00 10 00 00 00 32 00 14 | songline 0a 08 00 10 00 00 00 30 00 15 | songline 0b 01 00 10 00 00 00 30 00 16 | songline 0c 01 00 10 00 00 00 31 00 17 | songline 0d 01 00 10 00 00 00 32 00 18 | songline 0e 01 00 10 00 04 00 30 00 19 | songline 0f 01 00 10 00 20 00 30 00 20 | songline 10 01 00 10 00 21 00 31 00 21 | songline 11 01 00 10 00 22 00 32 00 22 | songline 12 01 00 10 00 23 00 30 00 23 | songline 13 01 00 10 00 24 00 30 00 24 | songline 14 01 00 10 00 25 00 31 00 25 | songline 15 01 00 10 00 28 00 34 00 26 | songline 16 08 00 10 00 23 00 30 00 27 | songline 17 02 00 60 00 40 00 50 00 28 | songline 18 02 00 61 00 41 00 51 00 29 | songline 19 02 00 62 00 42 00 52 00 30 | songline 1a 02 00 63 00 43 00 53 00 31 | songline 1b 02 00 62 ff 44 00 54 00 32 | songline 1c 02 00 64 00 45 00 55 00 33 | songline 1d 02 00 66 00 46 00 56 00 34 | songline 1e 08 00 65 00 03 00 04 00 35 | songline 1f 01 00 10 00 70 00 30 00 36 | songline 20 01 00 10 00 71 00 31 00 37 | songline 21 01 00 10 00 72 00 32 00 38 | songline 22 01 00 10 00 73 00 30 00 39 | songline 23 01 00 10 00 74 00 30 00 40 | songline 24 01 00 10 00 75 00 31 00 41 | songline 25 01 00 10 00 72 00 34 00 42 | songline 26 08 00 10 00 73 00 30 00 43 | songline 27 01 00 70 03 24 03 30 03 44 | songline 28 01 00 71 03 25 03 31 03 45 | songline 29 02 00 72 03 22 03 32 03 46 | songline 2a 01 00 73 03 23 03 30 03 47 | songline 2b 01 00 10 03 26 03 30 03 48 | songline 2c 01 00 10 03 26 03 31 03 49 | songline 2d 02 00 10 03 27 03 32 03 50 | songline 2e 08 00 10 03 27 03 30 03 51 | songline 2f 06 00 91 03 92 03 30 03 52 | songline 30 06 00 91 03 92 03 31 03 53 | songline 31 06 00 91 03 92 03 32 03 54 | songline 32 06 00 91 03 92 03 30 03 55 | songline 33 06 00 91 03 92 03 30 03 56 | songline 34 06 00 91 03 92 03 31 03 57 | songline 35 04 00 67 03 92 03 34 03 58 | songline 36 09 00 68 03 05 00 33 03 59 | 60 | trackline 01 00 0d 01 00 00 00 00 61 | trackline 01 06 0d 01 00 00 00 00 62 | trackline 01 08 19 02 00 00 00 00 63 | trackline 01 0a 0d 01 00 00 00 00 64 | trackline 01 0e 0d 01 76 80 00 00 65 | trackline 01 0f 00 00 76 80 00 00 66 | trackline 01 10 0d 01 00 00 00 00 67 | trackline 01 12 0d 01 00 00 00 00 68 | trackline 01 14 0d 01 00 00 00 00 69 | trackline 01 16 19 02 00 00 00 00 70 | trackline 01 1a 0d 01 00 00 00 00 71 | trackline 01 1c 0d 01 00 00 00 00 72 | trackline 01 1f 00 00 76 00 00 00 73 | trackline 02 00 0d 01 00 00 00 00 74 | trackline 02 02 0d 01 00 00 00 00 75 | trackline 02 08 19 02 00 00 00 00 76 | trackline 02 0e 0d 01 00 00 00 00 77 | trackline 02 14 0d 01 00 00 00 00 78 | trackline 02 18 19 02 00 00 00 00 79 | trackline 03 00 00 00 66 ff 00 00 80 | trackline 04 03 00 00 69 00 00 00 81 | trackline 04 04 31 01 00 00 00 00 82 | trackline 04 05 31 01 00 00 00 00 83 | trackline 04 06 31 01 00 00 00 00 84 | trackline 04 07 31 01 00 00 00 00 85 | trackline 04 08 31 01 00 00 00 00 86 | trackline 04 0a 31 01 00 00 00 00 87 | trackline 04 0e 31 01 00 00 00 00 88 | trackline 04 10 2c 01 00 00 00 00 89 | trackline 04 12 2c 01 00 00 00 00 90 | trackline 04 16 2c 01 00 00 00 00 91 | trackline 04 18 25 01 00 00 00 00 92 | trackline 04 1a 25 01 00 00 00 00 93 | trackline 04 1c 20 01 00 00 00 00 94 | trackline 04 1e 20 01 00 00 00 00 95 | trackline 05 00 25 07 00 00 00 00 96 | trackline 06 00 19 02 00 00 00 00 97 | trackline 06 01 00 00 76 50 00 00 98 | trackline 06 02 0d 01 00 00 00 00 99 | trackline 06 03 0d 01 00 00 00 00 100 | trackline 06 04 0d 01 00 00 00 00 101 | trackline 06 06 0d 01 00 00 00 00 102 | trackline 06 08 19 02 00 00 00 00 103 | trackline 06 09 00 00 76 00 00 00 104 | trackline 06 0a 19 02 76 50 00 00 105 | trackline 06 0b 00 00 76 00 00 00 106 | trackline 06 0c 0d 01 00 00 00 00 107 | trackline 06 0e 0d 01 00 00 00 00 108 | trackline 06 10 19 02 00 00 00 00 109 | trackline 06 11 00 00 76 50 00 00 110 | trackline 06 12 0d 01 00 00 00 00 111 | trackline 06 14 0d 01 00 00 00 00 112 | trackline 06 16 0d 01 00 00 00 00 113 | trackline 06 18 19 02 00 00 00 00 114 | trackline 06 19 00 00 76 50 00 00 115 | trackline 06 1a 0d 01 00 00 00 00 116 | trackline 06 1c 0d 01 00 00 00 00 117 | trackline 06 1d 0d 01 00 00 00 00 118 | trackline 06 1e 0d 01 00 00 00 00 119 | trackline 06 1f 0d 01 00 00 00 00 120 | trackline 07 00 0d 01 00 00 00 00 121 | trackline 07 03 00 00 69 00 00 00 122 | trackline 07 04 31 01 00 00 00 00 123 | trackline 07 05 31 01 00 00 00 00 124 | trackline 07 06 31 01 00 00 00 00 125 | trackline 07 07 31 01 00 00 00 00 126 | trackline 07 08 31 01 00 00 00 00 127 | trackline 07 0a 31 01 00 00 00 00 128 | trackline 07 0e 31 01 00 00 00 00 129 | trackline 07 10 2c 01 00 00 00 00 130 | trackline 07 12 2c 01 00 00 00 00 131 | trackline 07 16 2c 01 00 00 00 00 132 | trackline 07 18 25 01 00 00 00 00 133 | trackline 07 1a 25 01 00 00 00 00 134 | trackline 07 1c 20 01 00 00 00 00 135 | trackline 07 1e 20 01 00 00 00 00 136 | trackline 08 00 0d 01 00 00 00 00 137 | trackline 08 06 0d 01 00 00 00 00 138 | trackline 08 08 19 02 00 00 00 00 139 | trackline 08 09 00 00 76 00 00 00 140 | trackline 08 0a 0d 01 00 00 00 00 141 | trackline 08 0e 0d 01 76 80 00 00 142 | trackline 08 0f 0d 01 00 80 00 00 143 | trackline 08 10 19 02 00 00 00 00 144 | trackline 08 11 00 00 76 00 00 00 145 | trackline 08 12 0d 01 00 00 00 00 146 | trackline 08 14 0d 01 00 00 00 00 147 | trackline 08 16 0d 01 00 00 00 00 148 | trackline 08 18 19 02 00 00 00 00 149 | trackline 08 1a 0d 01 00 00 00 00 150 | trackline 08 1c 19 02 00 00 00 00 151 | trackline 08 1d 00 00 76 00 00 00 152 | trackline 08 1e 19 02 00 00 00 00 153 | trackline 08 1f 00 00 76 00 00 00 154 | trackline 09 00 0d 01 00 00 00 00 155 | trackline 10 00 34 04 69 00 00 00 156 | trackline 10 02 25 04 00 00 00 00 157 | trackline 10 04 34 04 00 00 00 00 158 | trackline 10 06 33 04 00 00 00 00 159 | trackline 10 08 25 04 00 00 00 00 160 | trackline 10 0a 31 04 00 00 00 00 161 | trackline 10 0c 36 04 00 00 00 00 162 | trackline 10 0e 33 04 00 00 00 00 163 | trackline 10 10 34 04 00 00 00 00 164 | trackline 10 12 25 04 00 00 00 00 165 | trackline 10 14 34 04 00 00 00 00 166 | trackline 10 16 33 04 00 00 00 00 167 | trackline 10 18 25 04 00 00 00 00 168 | trackline 10 1a 31 04 00 00 00 00 169 | trackline 10 1c 33 04 00 00 00 00 170 | trackline 10 1e 2f 04 00 00 00 00 171 | trackline 20 00 38 03 69 00 00 00 172 | trackline 20 03 00 00 76 c0 00 00 173 | trackline 20 08 31 03 00 00 00 00 174 | trackline 20 0b 00 00 76 c0 00 00 175 | trackline 20 10 38 03 00 00 00 00 176 | trackline 20 11 00 00 76 40 00 00 177 | trackline 20 12 00 00 76 00 00 00 178 | trackline 20 14 38 03 00 00 00 00 179 | trackline 20 15 00 00 76 00 00 00 180 | trackline 20 16 39 03 00 00 00 00 181 | trackline 20 19 00 00 76 00 00 00 182 | trackline 20 1a 36 03 00 00 00 00 183 | trackline 20 1b 00 00 76 00 00 00 184 | trackline 20 1c 3d 03 00 00 00 00 185 | trackline 20 1e 37 03 00 00 00 00 186 | trackline 21 00 38 03 00 00 00 00 187 | trackline 21 03 00 00 76 c0 00 00 188 | trackline 21 08 31 03 00 00 00 00 189 | trackline 21 0b 00 00 76 c0 00 00 190 | trackline 21 10 38 03 00 00 00 00 191 | trackline 21 12 36 03 00 00 00 00 192 | trackline 21 14 34 03 00 00 00 00 193 | trackline 21 15 00 00 76 00 00 00 194 | trackline 21 16 31 03 00 00 00 00 195 | trackline 21 19 00 00 76 00 00 00 196 | trackline 21 1a 34 03 00 00 00 00 197 | trackline 21 1b 00 00 76 00 00 00 198 | trackline 21 1c 38 03 00 00 00 00 199 | trackline 21 1d 39 03 00 00 00 00 200 | trackline 21 1e 3b 03 00 00 00 00 201 | trackline 21 1f 3d 03 00 00 00 00 202 | trackline 22 00 40 03 00 00 00 00 203 | trackline 22 04 40 03 00 00 00 00 204 | trackline 22 06 3d 03 00 00 00 00 205 | trackline 22 0a 39 03 00 00 00 00 206 | trackline 22 0c 42 03 00 00 00 00 207 | trackline 22 0e 40 03 00 00 00 00 208 | trackline 22 10 3f 03 00 00 00 00 209 | trackline 22 12 40 03 00 00 00 00 210 | trackline 22 14 42 03 00 00 00 00 211 | trackline 22 16 3b 03 00 00 00 00 212 | trackline 22 1a 38 03 00 00 00 00 213 | trackline 22 1c 33 03 00 00 00 00 214 | trackline 22 1e 36 03 00 00 00 00 215 | trackline 23 00 40 03 00 00 00 00 216 | trackline 23 02 3f 03 00 00 00 00 217 | trackline 23 04 00 00 76 00 00 00 218 | trackline 23 06 3d 03 00 00 00 00 219 | trackline 23 14 00 00 66 fe 00 00 220 | trackline 24 00 31 03 00 00 00 00 221 | trackline 24 01 00 00 76 00 00 00 222 | trackline 24 02 33 03 00 00 00 00 223 | trackline 24 03 00 00 76 c0 00 00 224 | trackline 24 06 34 03 00 00 00 00 225 | trackline 24 08 00 00 76 00 00 00 226 | trackline 24 0a 31 03 00 00 00 00 227 | trackline 24 0b 00 00 76 c0 00 00 228 | trackline 24 0c 36 03 00 00 00 00 229 | trackline 24 0d 00 00 76 00 00 00 230 | trackline 24 0e 31 03 00 00 00 00 231 | trackline 24 0f 00 00 76 00 00 00 232 | trackline 24 10 38 03 00 00 00 00 233 | trackline 24 11 36 03 00 40 00 00 234 | trackline 24 12 34 03 00 00 00 00 235 | trackline 24 14 38 03 00 00 00 00 236 | trackline 24 15 00 00 76 00 00 00 237 | trackline 24 16 36 03 00 00 00 00 238 | trackline 24 18 34 03 00 00 00 00 239 | trackline 24 19 00 00 76 00 00 00 240 | trackline 24 1a 33 03 00 00 00 00 241 | trackline 24 1b 00 00 76 00 00 00 242 | trackline 24 1c 31 03 00 00 00 00 243 | trackline 25 00 2c 03 00 00 00 00 244 | trackline 25 01 00 00 69 ff 00 00 245 | trackline 25 02 25 03 00 00 00 00 246 | trackline 25 04 31 03 00 00 00 00 247 | trackline 25 06 25 03 00 00 00 00 248 | trackline 25 08 2c 03 00 00 00 00 249 | trackline 25 0a 25 03 00 00 00 00 250 | trackline 25 0c 31 03 00 00 00 00 251 | trackline 25 0d 00 00 69 00 00 00 252 | trackline 25 0e 25 03 00 00 00 00 253 | trackline 25 10 34 03 00 00 00 00 254 | trackline 25 11 33 03 00 00 00 00 255 | trackline 25 12 31 03 00 00 00 00 256 | trackline 25 13 2c 03 00 00 00 00 257 | trackline 25 14 2a 03 00 00 00 00 258 | trackline 25 15 28 03 00 00 00 00 259 | trackline 25 16 25 03 00 00 00 00 260 | trackline 25 17 20 03 00 00 00 00 261 | trackline 25 18 1c 03 00 00 00 00 262 | trackline 25 19 1e 03 00 00 00 00 263 | trackline 25 1a 1f 03 00 00 00 00 264 | trackline 25 1b 20 03 00 00 00 00 265 | trackline 25 1c 25 03 00 00 00 00 266 | trackline 25 1d 2d 03 00 00 00 00 267 | trackline 25 1e 31 03 00 00 00 00 268 | trackline 25 1f 38 03 00 00 00 00 269 | trackline 26 00 25 03 00 00 00 00 270 | trackline 26 01 00 00 69 ff 00 00 271 | trackline 26 02 19 03 00 00 00 00 272 | trackline 26 04 19 03 00 00 00 00 273 | trackline 26 06 28 03 00 00 00 00 274 | trackline 26 08 19 03 00 00 00 00 275 | trackline 26 0a 25 03 00 00 00 00 276 | trackline 26 0c 2c 03 00 00 00 00 277 | trackline 26 0e 23 03 00 00 00 00 278 | trackline 26 10 25 03 00 00 00 00 279 | trackline 26 12 19 03 00 00 00 00 280 | trackline 26 14 19 03 00 00 00 00 281 | trackline 26 16 28 03 00 00 00 00 282 | trackline 26 18 2f 03 00 00 00 00 283 | trackline 26 1a 2c 03 00 00 00 00 284 | trackline 26 1b 00 00 69 00 00 00 285 | trackline 26 1c 25 03 00 00 00 00 286 | trackline 26 1d 27 03 00 00 00 00 287 | trackline 26 1e 28 03 00 00 00 00 288 | trackline 26 1f 2c 03 00 00 00 00 289 | trackline 27 00 2c 03 00 00 00 00 290 | trackline 27 01 00 00 69 ff 00 00 291 | trackline 27 02 31 03 00 00 00 00 292 | trackline 27 04 19 03 00 00 00 00 293 | trackline 27 06 2c 03 00 00 00 00 294 | trackline 27 08 25 03 00 00 00 00 295 | trackline 27 0a 19 03 00 00 00 00 296 | trackline 27 0c 2c 03 00 00 00 00 297 | trackline 27 0d 00 00 76 00 00 00 298 | trackline 27 0e 31 03 69 00 00 00 299 | trackline 27 0f 00 00 76 00 00 00 300 | trackline 27 10 19 03 00 00 00 00 301 | trackline 27 11 00 00 69 ff 00 00 302 | trackline 27 12 2c 03 00 00 00 00 303 | trackline 27 14 25 03 00 00 00 00 304 | trackline 27 16 19 03 00 00 00 00 305 | trackline 27 18 25 03 00 00 00 00 306 | trackline 27 1a 19 03 00 00 00 00 307 | trackline 27 1b 00 00 69 00 00 00 308 | trackline 27 1c 2c 03 00 00 00 00 309 | trackline 27 1d 00 00 76 00 00 00 310 | trackline 27 1e 2f 03 00 00 00 00 311 | trackline 27 1f 00 00 76 00 00 00 312 | trackline 28 00 34 03 00 00 00 00 313 | trackline 28 01 00 00 76 00 00 00 314 | trackline 28 02 36 03 00 00 00 00 315 | trackline 28 06 38 03 00 00 00 00 316 | trackline 28 07 00 00 76 80 00 00 317 | trackline 28 0a 34 03 00 00 00 00 318 | trackline 28 0c 3b 03 00 00 00 00 319 | trackline 28 0d 39 03 00 00 00 00 320 | trackline 28 0e 38 03 00 00 00 00 321 | trackline 28 10 3b 03 00 00 00 00 322 | trackline 28 12 3d 03 00 00 00 00 323 | trackline 28 14 3f 03 00 00 00 00 324 | trackline 28 15 00 00 76 00 00 00 325 | trackline 28 16 42 03 00 00 00 00 326 | trackline 28 1a 38 03 00 00 00 00 327 | trackline 28 1c 33 03 00 00 00 00 328 | trackline 28 1e 36 03 00 00 00 00 329 | trackline 30 00 0d 05 00 00 00 00 330 | trackline 30 02 01 05 00 00 00 00 331 | trackline 30 09 00 00 76 00 00 00 332 | trackline 30 0c 06 05 00 00 00 00 333 | trackline 30 0d 08 05 00 00 00 00 334 | trackline 30 0e 0b 05 00 00 00 00 335 | trackline 30 10 0d 05 00 00 00 00 336 | trackline 30 12 01 05 00 00 00 00 337 | trackline 30 14 01 05 00 00 00 00 338 | trackline 30 19 00 00 76 00 00 00 339 | trackline 31 04 0d 05 00 00 00 00 340 | trackline 31 07 00 00 76 80 00 00 341 | trackline 31 0a 0d 05 00 00 00 00 342 | trackline 31 0c 00 00 76 00 00 00 343 | trackline 31 0e 0d 05 00 00 00 00 344 | trackline 31 10 01 05 00 00 00 00 345 | trackline 32 00 09 05 00 00 00 00 346 | trackline 32 06 15 05 00 00 00 00 347 | trackline 32 08 00 00 76 00 00 00 348 | trackline 32 0a 10 05 00 00 00 00 349 | trackline 32 0c 09 05 00 00 00 00 350 | trackline 32 0e 06 05 00 00 00 00 351 | trackline 32 10 0b 05 00 00 00 00 352 | trackline 32 12 0b 05 00 00 00 00 353 | trackline 32 15 00 00 76 00 00 00 354 | trackline 32 16 08 05 00 00 00 00 355 | trackline 32 17 00 00 76 c0 00 00 356 | trackline 32 1a 03 05 00 00 00 00 357 | trackline 32 1b 00 00 76 c0 00 00 358 | trackline 32 1e 08 05 00 00 00 00 359 | trackline 33 00 01 05 00 00 00 00 360 | trackline 34 00 09 05 00 00 00 00 361 | trackline 34 06 15 05 00 00 00 00 362 | trackline 34 08 00 00 76 00 00 00 363 | trackline 34 0a 10 05 00 00 00 00 364 | trackline 34 0c 09 05 00 00 00 00 365 | trackline 34 0e 06 05 00 00 00 00 366 | trackline 34 10 08 05 00 00 00 00 367 | trackline 34 12 08 05 00 00 00 00 368 | trackline 34 15 00 00 76 00 00 00 369 | trackline 34 16 08 05 00 00 00 00 370 | trackline 34 17 00 00 76 c0 00 00 371 | trackline 34 1a 03 05 00 00 00 00 372 | trackline 34 1b 00 00 76 c0 00 00 373 | trackline 34 1e 08 05 00 00 00 00 374 | trackline 40 00 28 06 00 00 00 00 375 | trackline 40 0c 23 06 00 00 00 00 376 | trackline 40 0e 00 00 76 00 00 00 377 | trackline 40 10 2b 06 00 00 00 00 378 | trackline 40 15 00 00 76 00 00 00 379 | trackline 40 16 2a 06 00 00 00 00 380 | trackline 40 1b 00 00 76 00 00 00 381 | trackline 40 1c 28 06 00 00 00 00 382 | trackline 40 1f 00 00 76 00 00 00 383 | trackline 41 00 27 06 00 34 00 00 384 | trackline 41 05 00 00 76 00 00 00 385 | trackline 41 06 28 06 00 00 00 00 386 | trackline 41 07 00 00 76 00 00 00 387 | trackline 41 08 2a 06 00 00 00 00 388 | trackline 41 12 00 00 66 fd 00 00 389 | trackline 42 00 24 06 00 00 00 00 390 | trackline 42 0c 26 06 00 00 00 00 391 | trackline 42 10 28 06 00 00 00 00 392 | trackline 42 18 24 06 00 00 00 00 393 | trackline 42 1b 00 00 6c f8 00 00 394 | trackline 43 00 23 06 00 00 00 00 395 | trackline 43 08 00 00 66 ff 00 00 396 | trackline 44 00 27 06 00 00 00 00 397 | trackline 44 04 27 06 00 00 00 00 398 | trackline 44 06 28 06 00 00 00 00 399 | trackline 44 0a 28 06 00 00 00 00 400 | trackline 44 0c 2a 06 00 00 00 00 401 | trackline 44 10 00 00 66 f8 00 00 402 | trackline 44 14 2d 06 00 00 00 00 403 | trackline 44 18 2d 06 00 00 00 00 404 | trackline 44 1a 2a 06 00 00 00 00 405 | trackline 44 1b 00 00 76 00 00 00 406 | trackline 44 1c 24 06 00 00 00 00 407 | trackline 44 1d 00 00 76 00 00 00 408 | trackline 44 1e 23 06 00 00 00 00 409 | trackline 44 1f 00 00 76 00 00 00 410 | trackline 45 00 28 06 00 00 00 00 411 | trackline 45 04 00 00 66 fc 00 00 412 | trackline 45 08 2b 06 00 00 00 00 413 | trackline 45 0c 00 00 66 fc 00 00 414 | trackline 45 10 2a 06 00 00 00 00 415 | trackline 45 14 00 00 66 fc 00 00 416 | trackline 45 18 26 06 00 00 00 00 417 | trackline 45 1a 00 00 6c 03 00 00 418 | trackline 46 00 28 06 00 00 00 00 419 | trackline 50 00 04 05 00 00 00 00 420 | trackline 50 04 04 05 00 00 00 00 421 | trackline 50 06 10 05 00 00 00 00 422 | trackline 50 0a 0b 05 00 00 00 00 423 | trackline 50 0c 0e 05 00 00 00 00 424 | trackline 50 0e 0f 05 00 00 00 00 425 | trackline 50 10 04 05 00 00 00 00 426 | trackline 50 14 04 05 00 00 00 00 427 | trackline 50 16 10 05 00 00 00 00 428 | trackline 50 1a 0b 05 00 00 00 00 429 | trackline 50 1c 10 05 00 00 00 00 430 | trackline 50 1d 10 05 00 00 00 00 431 | trackline 50 1e 0b 05 00 00 00 00 432 | trackline 50 1f 04 05 00 00 00 00 433 | trackline 51 00 0b 05 00 00 00 00 434 | trackline 51 04 0b 05 00 00 00 00 435 | trackline 51 06 17 05 00 00 00 00 436 | trackline 51 0a 06 05 00 00 00 00 437 | trackline 51 0c 09 05 00 00 00 00 438 | trackline 51 0e 0a 05 00 00 00 00 439 | trackline 51 10 0b 05 00 00 00 00 440 | trackline 51 14 0d 05 00 00 00 00 441 | trackline 51 18 0e 05 00 00 00 00 442 | trackline 51 1c 0f 05 00 00 00 00 443 | trackline 51 1d 00 00 6c e0 00 00 444 | trackline 52 00 0c 05 00 00 00 00 445 | trackline 52 02 0c 05 00 00 00 00 446 | trackline 52 04 00 00 76 00 00 00 447 | trackline 52 06 07 05 00 00 00 00 448 | trackline 52 08 0a 05 00 00 00 00 449 | trackline 52 0a 0c 05 00 00 00 00 450 | trackline 52 0c 00 00 76 00 00 00 451 | trackline 52 0e 0a 05 00 00 00 00 452 | trackline 52 10 0c 05 00 00 00 00 453 | trackline 52 12 0c 05 00 00 00 00 454 | trackline 52 14 00 00 76 00 00 00 455 | trackline 52 16 07 05 00 00 00 00 456 | trackline 52 18 0f 05 00 00 00 00 457 | trackline 52 1a 0e 05 00 00 00 00 458 | trackline 52 1c 0c 05 00 00 00 00 459 | trackline 52 1e 05 05 00 00 00 00 460 | trackline 53 00 07 05 00 00 00 00 461 | trackline 53 02 07 05 00 00 00 00 462 | trackline 53 06 13 05 00 00 00 00 463 | trackline 53 0a 10 05 00 00 00 00 464 | trackline 53 0c 0e 05 00 00 00 00 465 | trackline 53 0e 0b 05 00 00 00 00 466 | trackline 53 10 09 05 00 00 00 00 467 | trackline 53 11 07 05 00 00 00 00 468 | trackline 53 12 17 05 00 00 00 00 469 | trackline 53 13 15 05 00 00 00 00 470 | trackline 53 14 13 05 00 00 00 00 471 | trackline 53 15 10 05 00 00 00 00 472 | trackline 53 16 0e 05 00 00 00 00 473 | trackline 53 17 09 05 00 00 00 00 474 | trackline 53 18 07 05 00 00 00 00 475 | trackline 53 1c 09 05 00 00 00 00 476 | trackline 54 00 0b 05 00 00 00 00 477 | trackline 55 00 0c 05 00 00 00 00 478 | trackline 55 0c 0c 05 00 00 00 00 479 | trackline 55 10 0e 05 00 00 00 00 480 | trackline 55 1c 0e 05 00 00 00 00 481 | trackline 56 00 10 05 00 00 00 00 482 | trackline 56 06 10 05 00 00 00 00 483 | trackline 56 08 00 00 76 00 00 00 484 | trackline 56 0c 04 05 00 00 00 00 485 | trackline 60 00 25 07 00 00 00 00 486 | trackline 60 0a 28 08 00 00 00 00 487 | trackline 60 0e 28 08 00 00 00 00 488 | trackline 60 0f 00 00 76 00 00 00 489 | trackline 60 10 28 08 00 00 00 00 490 | trackline 60 16 34 08 00 00 00 00 491 | trackline 60 17 00 00 76 80 00 00 492 | trackline 60 1a 34 08 00 00 00 00 493 | trackline 60 1b 00 00 76 00 00 00 494 | trackline 60 1c 28 08 00 00 00 00 495 | trackline 61 00 23 09 00 00 00 00 496 | trackline 61 05 00 00 76 00 00 00 497 | trackline 61 06 2f 09 00 00 00 00 498 | trackline 61 07 00 00 76 80 00 00 499 | trackline 61 0a 23 09 00 00 00 00 500 | trackline 61 0e 23 09 00 00 00 00 501 | trackline 61 0f 00 00 76 00 00 00 502 | trackline 61 10 2f 09 00 00 00 00 503 | trackline 61 14 23 09 00 00 00 00 504 | trackline 61 18 23 09 00 00 00 00 505 | trackline 61 1a 2f 09 00 00 00 00 506 | trackline 61 1c 23 09 00 00 00 00 507 | trackline 62 00 24 09 00 00 00 00 508 | trackline 62 05 00 00 76 00 00 00 509 | trackline 62 06 30 09 00 00 00 00 510 | trackline 62 07 00 00 76 80 00 00 511 | trackline 62 0a 24 09 00 00 00 00 512 | trackline 62 0e 24 09 00 00 00 00 513 | trackline 62 0f 00 00 76 00 00 00 514 | trackline 62 10 24 09 00 00 00 00 515 | trackline 62 16 30 09 00 00 00 00 516 | trackline 62 17 00 00 76 80 00 00 517 | trackline 62 1a 30 09 00 00 00 00 518 | trackline 62 1b 00 00 76 00 00 00 519 | trackline 62 1c 24 09 00 00 00 00 520 | trackline 63 00 2b 09 00 00 00 00 521 | trackline 63 01 00 00 76 00 00 00 522 | trackline 63 02 1f 09 00 00 00 00 523 | trackline 63 05 00 00 76 00 00 00 524 | trackline 63 06 2b 09 00 00 00 00 525 | trackline 63 07 00 00 76 00 00 00 526 | trackline 63 08 2b 09 00 00 00 00 527 | trackline 63 09 00 00 76 00 00 00 528 | trackline 63 0a 1f 09 00 00 00 00 529 | trackline 63 0d 00 00 76 00 00 00 530 | trackline 63 0e 2b 09 00 00 00 00 531 | trackline 63 0f 00 00 76 00 00 00 532 | trackline 63 10 2b 09 00 00 00 00 533 | trackline 63 11 00 00 76 00 00 00 534 | trackline 63 12 1f 09 00 00 00 00 535 | trackline 63 15 00 00 76 00 00 00 536 | trackline 63 16 1f 09 00 00 00 00 537 | trackline 63 1a 2b 09 00 00 00 00 538 | trackline 63 1b 00 00 76 80 00 00 539 | trackline 63 1e 1f 09 00 00 00 00 540 | trackline 63 1f 00 00 76 00 00 00 541 | trackline 64 00 24 09 00 00 00 00 542 | trackline 64 04 24 09 00 00 00 00 543 | trackline 64 05 00 00 76 00 00 00 544 | trackline 64 06 30 09 00 00 00 00 545 | trackline 64 08 00 00 76 00 00 00 546 | trackline 64 0a 30 09 00 00 00 00 547 | trackline 64 0b 00 00 76 00 00 00 548 | trackline 64 0c 24 09 00 00 00 00 549 | trackline 64 10 26 09 00 00 00 00 550 | trackline 64 12 00 00 76 00 00 00 551 | trackline 64 14 26 09 00 00 00 00 552 | trackline 64 15 00 00 76 00 00 00 553 | trackline 64 16 32 09 00 00 00 00 554 | trackline 64 19 00 00 76 00 00 00 555 | trackline 64 1a 32 09 00 00 00 00 556 | trackline 64 1b 00 00 76 00 00 00 557 | trackline 64 1c 26 09 00 00 00 00 558 | trackline 64 1d 00 00 76 00 00 00 559 | trackline 64 1e 32 09 00 00 00 00 560 | trackline 64 1f 00 00 76 00 00 00 561 | trackline 65 00 34 09 00 00 00 00 562 | trackline 65 02 34 09 00 00 00 00 563 | trackline 65 03 34 09 00 00 00 00 564 | trackline 65 04 34 09 00 00 00 00 565 | trackline 65 05 00 00 76 00 00 00 566 | trackline 65 06 28 09 00 00 00 00 567 | trackline 65 08 00 00 76 00 00 00 568 | trackline 65 0a 28 09 00 00 00 00 569 | trackline 65 0b 00 00 76 00 00 00 570 | trackline 65 0c 28 09 00 00 00 00 571 | trackline 65 0e 34 09 00 00 00 00 572 | trackline 65 10 28 09 00 00 00 00 573 | trackline 66 00 34 0a 00 00 00 00 574 | trackline 66 02 34 0a 00 00 00 00 575 | trackline 66 03 28 0a 00 00 00 00 576 | trackline 66 04 34 0a 00 00 00 00 577 | trackline 66 05 00 00 76 00 00 00 578 | trackline 66 06 28 0a 00 00 00 00 579 | trackline 66 08 00 00 76 00 00 00 580 | trackline 66 0a 28 0a 00 00 00 00 581 | trackline 66 0b 00 00 76 00 00 00 582 | trackline 66 0c 28 0a 00 00 00 00 583 | trackline 66 10 34 0a 00 00 00 00 584 | trackline 66 12 34 0a 00 00 00 00 585 | trackline 66 13 34 0a 00 00 00 00 586 | trackline 66 14 34 0a 00 00 00 00 587 | trackline 66 15 00 00 76 00 00 00 588 | trackline 66 16 28 0a 00 00 00 00 589 | trackline 66 18 00 00 76 00 00 00 590 | trackline 66 1a 28 0a 00 00 00 00 591 | trackline 66 1b 00 00 76 00 00 00 592 | trackline 66 1c 28 0a 00 00 00 00 593 | trackline 66 1e 34 0a 00 00 00 00 594 | trackline 67 00 21 09 00 00 00 00 595 | trackline 67 10 23 09 00 00 00 00 596 | trackline 68 00 25 08 00 00 00 00 597 | trackline 70 00 25 07 00 ff 00 00 598 | trackline 70 08 2c 0b 00 00 00 00 599 | trackline 70 0a 25 0b 00 00 00 00 600 | trackline 70 0e 2c 0b 00 00 00 00 601 | trackline 70 10 31 0b 00 00 00 00 602 | trackline 70 12 2c 0b 00 00 00 00 603 | trackline 70 14 25 0b 00 00 00 00 604 | trackline 70 16 34 0b 00 00 00 00 605 | trackline 70 17 00 00 66 00 00 00 606 | trackline 70 18 33 0b 00 00 00 00 607 | trackline 70 1a 2c 0b 00 00 00 00 608 | trackline 70 1c 25 0b 00 00 00 00 609 | trackline 70 1e 36 0b 00 00 00 00 610 | trackline 71 00 38 0b 00 00 00 00 611 | trackline 71 18 31 0b 00 00 00 00 612 | trackline 71 1a 34 0b 00 00 00 00 613 | trackline 71 1b 36 0b 00 00 00 00 614 | trackline 71 1c 37 0b 00 00 00 00 615 | trackline 71 1d 38 0b 00 00 00 00 616 | trackline 71 1e 3b 0b 00 00 00 00 617 | trackline 71 1f 3d 0b 00 00 00 00 618 | trackline 72 00 40 0b 00 00 00 00 619 | trackline 72 08 3d 0b 00 00 00 00 620 | trackline 72 0c 40 0b 00 00 00 00 621 | trackline 72 10 3f 0b 00 00 00 00 622 | trackline 72 11 00 00 76 00 00 00 623 | trackline 72 12 3b 0b 00 00 00 00 624 | trackline 72 14 00 00 76 00 00 00 625 | trackline 72 16 38 0b 00 00 00 00 626 | trackline 72 1a 38 0b 00 00 00 00 627 | trackline 72 1b 00 00 76 00 00 00 628 | trackline 72 1c 3f 0b 00 00 00 00 629 | trackline 72 1e 3b 0b 00 00 00 00 630 | trackline 73 00 40 0b 00 00 00 00 631 | trackline 73 01 3f 0b 00 00 00 00 632 | trackline 73 02 3d 0b 00 00 00 00 633 | trackline 73 03 38 0b 00 00 00 00 634 | trackline 73 04 34 0b 00 00 00 00 635 | trackline 73 05 33 0b 00 00 00 00 636 | trackline 73 06 36 0b 00 00 00 00 637 | trackline 73 07 33 0b 00 00 00 00 638 | trackline 73 08 34 0b 00 00 00 00 639 | trackline 73 09 33 0b 00 00 00 00 640 | trackline 73 0a 31 0b 00 00 00 00 641 | trackline 73 0b 2c 0b 00 00 00 00 642 | trackline 73 0c 2f 0b 00 00 00 00 643 | trackline 73 0d 2a 0b 00 00 00 00 644 | trackline 73 0e 33 0b 00 00 00 00 645 | trackline 73 0f 2f 0b 00 00 00 00 646 | trackline 73 10 31 0b 00 00 00 00 647 | trackline 73 11 00 00 76 00 00 00 648 | trackline 73 12 31 0b 00 00 00 00 649 | trackline 73 13 00 00 76 00 00 00 650 | trackline 73 14 31 0b 00 00 00 00 651 | trackline 73 15 00 00 76 00 00 00 652 | trackline 73 16 31 0b 00 00 00 00 653 | trackline 73 19 00 00 76 00 00 00 654 | trackline 73 1a 31 0b 00 00 00 00 655 | trackline 73 1b 00 00 76 00 00 00 656 | trackline 73 1c 3d 0b 00 00 00 00 657 | trackline 73 1d 00 00 76 00 00 00 658 | trackline 73 1e 31 0b 00 00 00 00 659 | trackline 73 1f 00 00 76 00 00 00 660 | trackline 74 00 40 0b 00 00 00 00 661 | trackline 74 02 31 0b 00 00 00 00 662 | trackline 74 04 31 0b 00 00 00 00 663 | trackline 74 06 3d 0b 00 00 00 00 664 | trackline 74 08 31 0b 00 00 00 00 665 | trackline 74 0a 3d 0b 00 00 00 00 666 | trackline 74 0c 42 0b 00 00 00 00 667 | trackline 74 0d 40 0b 00 00 00 00 668 | trackline 74 0e 3f 0b 00 00 00 00 669 | trackline 74 10 40 0b 00 00 00 00 670 | trackline 74 12 31 0b 00 00 00 00 671 | trackline 74 14 31 0b 00 00 00 00 672 | trackline 74 16 3d 0b 00 00 00 00 673 | trackline 74 18 31 0b 00 00 00 00 674 | trackline 74 1a 3d 0b 00 00 00 00 675 | trackline 74 1c 42 0b 00 00 00 00 676 | trackline 74 1d 40 0b 00 00 00 00 677 | trackline 74 1e 3f 0b 00 00 00 00 678 | trackline 75 00 3f 0b 00 00 00 00 679 | trackline 75 02 40 0b 00 00 00 00 680 | trackline 75 03 00 00 76 00 00 00 681 | trackline 75 04 44 0b 00 00 00 00 682 | trackline 75 05 00 00 76 00 00 00 683 | trackline 75 06 3d 0b 00 00 00 00 684 | trackline 75 07 44 0d 00 10 00 00 685 | trackline 75 08 42 0b 00 00 00 00 686 | trackline 75 09 3d 0d 00 10 00 00 687 | trackline 75 0a 31 0b 00 00 00 00 688 | trackline 75 0b 42 0d 00 00 00 00 689 | trackline 75 0c 40 0b 00 00 00 00 690 | trackline 75 0d 31 0d 00 00 00 00 691 | trackline 75 0e 38 0b 00 00 00 00 692 | trackline 75 0f 40 0d 00 00 00 00 693 | trackline 75 10 3f 0b 00 00 00 00 694 | trackline 75 11 3d 0d 00 00 00 00 695 | trackline 75 12 31 0b 00 00 00 00 696 | trackline 75 13 3f 0d 00 00 00 00 697 | trackline 75 14 3b 0b 00 00 00 00 698 | trackline 75 15 31 0d 00 00 00 00 699 | trackline 75 16 38 0b 00 00 00 00 700 | trackline 75 17 3b 0d 00 00 00 00 701 | trackline 75 18 38 0b 00 00 00 00 702 | trackline 75 19 38 0d 00 00 00 00 703 | trackline 75 1a 31 0b 00 00 00 00 704 | trackline 75 1b 44 0d 00 00 00 00 705 | trackline 75 1c 3b 0b 00 00 00 00 706 | trackline 75 1d 31 0d 00 00 00 00 707 | trackline 75 1e 3d 0b 00 00 00 00 708 | trackline 75 1f 3f 0b 00 00 00 00 709 | trackline 80 00 34 03 00 00 00 00 710 | trackline 80 08 31 03 00 00 00 00 711 | trackline 80 0c 34 03 00 00 00 00 712 | trackline 80 10 33 03 00 00 00 00 713 | trackline 80 18 31 03 00 00 00 00 714 | trackline 80 1c 2f 03 00 00 00 00 715 | trackline 81 1d 2f 03 00 00 00 00 716 | trackline 81 1e 31 03 00 00 00 00 717 | trackline 81 1f 33 03 00 00 00 00 718 | trackline 82 00 2f 03 6c 10 00 00 719 | trackline 82 04 31 03 00 00 00 00 720 | trackline 83 00 01 0b 00 00 00 00 721 | trackline 90 00 21 09 69 00 00 00 722 | trackline 90 04 21 09 00 00 00 00 723 | trackline 90 05 00 00 76 00 00 00 724 | trackline 90 06 2d 09 00 00 00 00 725 | trackline 90 0a 2d 09 00 00 00 00 726 | trackline 90 0b 00 00 76 00 00 00 727 | trackline 90 0c 21 09 00 00 00 00 728 | trackline 90 10 23 09 00 00 00 00 729 | trackline 90 12 00 00 76 80 00 00 730 | trackline 90 14 23 09 00 00 00 00 731 | trackline 90 16 00 00 76 80 00 00 732 | trackline 90 18 20 08 00 00 00 00 733 | trackline 90 1a 00 00 76 80 00 00 734 | trackline 90 1c 20 08 00 00 00 00 735 | trackline 90 1e 00 00 76 80 00 00 736 | trackline 91 00 25 08 00 00 00 00 737 | trackline 91 01 00 00 76 00 00 00 738 | trackline 91 02 25 08 00 00 00 00 739 | trackline 91 05 00 00 76 00 00 00 740 | trackline 91 06 31 08 00 00 00 00 741 | trackline 91 07 31 08 00 00 00 00 742 | trackline 91 08 25 08 00 00 00 00 743 | trackline 91 09 00 00 76 00 00 00 744 | trackline 91 0a 25 08 00 00 00 00 745 | trackline 91 0b 00 00 76 00 00 00 746 | trackline 91 0e 25 08 00 00 00 00 747 | trackline 91 0f 00 00 76 00 00 00 748 | trackline 91 10 25 0a 00 00 00 00 749 | trackline 91 11 00 00 76 00 00 00 750 | trackline 91 14 25 0a 00 00 00 00 751 | trackline 91 15 00 00 76 00 00 00 752 | trackline 91 16 25 08 00 00 00 00 753 | trackline 91 17 00 00 76 00 00 00 754 | trackline 91 1a 25 08 00 00 00 00 755 | trackline 91 1b 00 00 76 00 00 00 756 | trackline 91 1c 25 08 00 00 00 00 757 | trackline 91 1d 00 00 76 00 00 00 758 | trackline 91 1e 25 08 00 00 00 00 759 | trackline 91 1f 00 00 76 00 00 00 760 | trackline 92 00 19 03 69 70 00 00 761 | trackline 92 01 00 00 76 00 00 00 762 | trackline 92 02 25 03 00 00 00 00 763 | trackline 92 03 00 00 76 00 00 00 764 | trackline 92 04 25 03 00 00 00 00 765 | trackline 92 05 00 00 76 00 00 00 766 | trackline 92 06 19 03 00 00 00 00 767 | trackline 92 07 00 00 76 00 00 00 768 | trackline 92 08 25 03 00 00 00 00 769 | trackline 92 09 00 00 76 00 00 00 770 | trackline 92 0a 19 03 00 00 00 00 771 | trackline 92 0b 00 00 76 00 00 00 772 | trackline 92 0c 25 03 00 00 00 00 773 | trackline 92 0d 00 00 76 00 00 00 774 | trackline 92 0e 25 03 00 00 00 00 775 | trackline 92 0f 00 00 76 00 00 00 776 | trackline 92 10 19 03 00 00 00 00 777 | trackline 92 11 00 00 76 00 00 00 778 | trackline 92 12 25 03 00 00 00 00 779 | trackline 92 13 00 00 76 00 00 00 780 | trackline 92 14 25 03 00 00 00 00 781 | trackline 92 15 00 00 76 00 00 00 782 | trackline 92 16 19 03 00 00 00 00 783 | trackline 92 17 00 00 76 00 00 00 784 | trackline 92 18 25 03 00 00 00 00 785 | trackline 92 19 00 00 76 00 00 00 786 | trackline 92 1a 19 03 69 00 00 00 787 | trackline 92 1b 19 03 66 c0 00 00 788 | trackline 92 1c 25 03 00 00 00 00 789 | trackline 92 1d 00 00 76 00 00 00 790 | trackline 92 1e 25 03 00 00 00 00 791 | trackline 92 1f 00 00 76 00 00 00 792 | 793 | instrumentline 01 00 77 03 794 | instrumentline 01 01 76 ff 795 | instrumentline 01 02 74 01 796 | instrumentline 01 03 77 02 797 | instrumentline 01 04 64 90 798 | instrumentline 01 05 2b 31 799 | instrumentline 01 06 6c a0 800 | instrumentline 01 07 66 f0 801 | instrumentline 02 00 76 ff 802 | instrumentline 02 01 77 03 803 | instrumentline 02 02 74 02 804 | instrumentline 02 03 77 02 805 | instrumentline 02 04 2b 31 806 | instrumentline 02 05 64 70 807 | instrumentline 02 06 6c d0 808 | instrumentline 02 07 74 02 809 | instrumentline 02 08 66 f8 810 | instrumentline 02 09 6a 01 811 | instrumentline 03 00 77 02 812 | instrumentline 03 01 6d 05 813 | instrumentline 03 02 2b 31 814 | instrumentline 03 03 76 ff 815 | instrumentline 03 04 66 f0 816 | instrumentline 03 05 74 06 817 | instrumentline 03 06 66 00 818 | instrumentline 03 07 74 16 819 | instrumentline 03 08 7e 25 820 | instrumentline 04 00 77 03 821 | instrumentline 04 01 76 ff 822 | instrumentline 04 02 74 01 823 | instrumentline 04 03 77 00 824 | instrumentline 04 04 6d 05 825 | instrumentline 04 05 2b 3d 826 | instrumentline 04 06 66 f0 827 | instrumentline 04 07 74 06 828 | instrumentline 04 08 66 00 829 | instrumentline 04 09 74 20 830 | instrumentline 04 0a 66 f0 831 | instrumentline 05 00 77 03 832 | instrumentline 05 01 76 ff 833 | instrumentline 05 02 74 01 834 | instrumentline 05 03 77 02 835 | instrumentline 05 04 64 50 836 | instrumentline 05 05 6d 01 837 | instrumentline 05 06 2b 31 838 | instrumentline 05 07 74 05 839 | instrumentline 05 08 66 fe 840 | instrumentline 06 00 77 02 841 | instrumentline 06 01 64 80 842 | instrumentline 06 02 2b 3d 843 | instrumentline 06 03 76 c0 844 | instrumentline 06 04 66 08 845 | instrumentline 06 05 74 02 846 | instrumentline 06 06 66 f0 847 | instrumentline 06 07 74 02 848 | instrumentline 06 08 66 00 849 | instrumentline 06 09 74 16 850 | instrumentline 06 0a 7e 34 851 | instrumentline 07 00 77 03 852 | instrumentline 07 01 76 ff 853 | instrumentline 07 02 66 fc 854 | instrumentline 08 00 69 00 855 | instrumentline 08 01 77 03 856 | instrumentline 08 02 76 ff 857 | instrumentline 08 03 74 01 858 | instrumentline 08 04 77 02 859 | instrumentline 08 05 6d 05 860 | instrumentline 08 06 66 ff 861 | instrumentline 08 07 2b 3d 862 | instrumentline 08 08 74 03 863 | instrumentline 08 09 2b 38 864 | instrumentline 08 0a 74 03 865 | instrumentline 08 0b 2b 34 866 | instrumentline 08 0c 74 03 867 | instrumentline 08 0d 2b 31 868 | instrumentline 08 0e 74 03 869 | instrumentline 08 0f 6a 07 870 | instrumentline 09 00 69 00 871 | instrumentline 09 01 77 03 872 | instrumentline 09 02 76 ff 873 | instrumentline 09 03 74 01 874 | instrumentline 09 04 77 02 875 | instrumentline 09 05 6d 05 876 | instrumentline 09 06 66 ff 877 | instrumentline 09 07 2b 3d 878 | instrumentline 09 08 74 03 879 | instrumentline 09 09 2b 38 880 | instrumentline 09 0a 74 03 881 | instrumentline 09 0b 2b 35 882 | instrumentline 09 0c 74 03 883 | instrumentline 09 0d 2b 31 884 | instrumentline 09 0e 74 03 885 | instrumentline 09 0f 6a 07 886 | instrumentline 0a 00 69 00 887 | instrumentline 0a 01 77 03 888 | instrumentline 0a 02 76 ff 889 | instrumentline 0a 03 74 01 890 | instrumentline 0a 04 77 02 891 | instrumentline 0a 05 6d 05 892 | instrumentline 0a 06 66 ff 893 | instrumentline 0a 07 2b 3d 894 | instrumentline 0a 08 74 03 895 | instrumentline 0a 09 2b 38 896 | instrumentline 0a 0a 74 03 897 | instrumentline 0a 0b 2b 36 898 | instrumentline 0a 0c 74 03 899 | instrumentline 0a 0d 2b 31 900 | instrumentline 0a 0e 74 03 901 | instrumentline 0a 0f 6a 07 902 | instrumentline 0b 00 77 03 903 | instrumentline 0b 01 76 ff 904 | instrumentline 0b 02 74 01 905 | instrumentline 0b 03 77 00 906 | instrumentline 0b 04 6d 05 907 | instrumentline 0b 05 2b 3d 908 | instrumentline 0b 06 66 f0 909 | instrumentline 0b 07 74 06 910 | instrumentline 0b 08 66 00 911 | instrumentline 0b 09 74 06 912 | instrumentline 0b 0a 7e 25 913 | instrumentline 0c 00 77 03 914 | instrumentline 0c 01 76 ff 915 | instrumentline 0c 02 66 f0 916 | instrumentline 0d 00 76 c4 917 | instrumentline 0d 01 77 00 918 | instrumentline 0d 02 6d 05 919 | instrumentline 0d 03 2b 3d 920 | instrumentline 0d 04 66 f0 921 | instrumentline 0d 05 74 06 922 | instrumentline 0d 06 66 00 923 | instrumentline 0d 07 74 06 924 | instrumentline 0d 08 7e 25 925 | --------------------------------------------------------------------------------