/*
 * activity4.c
 *
 *  Created on: Sep 16, 2025
 *      Author: sowgro
 */

#include "song.h"
#include <printf.h>
#include <endian_converters.h>
#include <stdint.h>
#include "activity4.h"

struct get_header_result_t {
	header_t *p_value;

};

void activity4_run() {
	header_t* p_header;

	p_header = (header_t *) (get_song(0).p_song);

	printf ("Header: \r\n");
	printf ("\tLength: %lu\r\n", p_header->length);
	printf ("\tFormat: %u\r\n", p_header->format);
	printf ("\tNum Tracks: %u\r\n", p_header->ntrcks);
	printf ("\tDivision: %u\r\n", p_header->division);
}

header_t *get_header(uint8_t *p_song, header_t *out_bytes_used) {
	p_header = (header_t *) (p_song);

	p_header->length   = convert_to_uint32((uint8_t*) &p_header->length);
	p_header->format   = convert_to_uint16((uint8_t*) &p_header->format);
	p_header->ntrcks   = convert_to_uint16((uint8_t*) &p_header->ntrcks);
	p_header->division = convert_to_uint16((uint8_t*) &p_header->division);
}

