Permalink
Browse files

.s name now matches .gb name

  • Loading branch information...
jkotlinski committed Jun 27, 2018
1 parent 07582ed commit d362f6c0c52b98a92fb03aa6fe2f5364f1ef5e18
Showing with 23 additions and 12 deletions.
  1. +1 −1 .lvimrc
  2. +3 −3 README.md
  3. +15 −4 lsdpack.cpp
  4. +3 −3 writer.cpp
  5. +1 −1 writer.h
@@ -1,2 +1,2 @@
map <F3> :wall!<CR>:make<CR>:!./lsdpack.exe ../lsdj/lsdj.gb<CR>
map <F4> :wall!<CR>:!rgbasm -o music.o music.s<CR>:!rgbasm -o boot.o boot.s<CR>:!rgbasm -o player.o player.s<CR>:!rgblink -o player.gb boot.o player.o music.o<CR>:!rgbfix -v -m 0x19 -p 0 player.gb<CR>
map <F4> :wall!<CR>:!rgbasm -o lsdj.o lsdj.s<CR>:!rgbasm -o boot.o boot.s<CR>:!rgbasm -o player.o player.s<CR>:!rgblink -o player.gb boot.o player.o lsdj.o<CR>:!rgbfix -v -m 0x19 -p 0 player.gb<CR>
@@ -8,10 +8,10 @@ Requires CMake and a C++ compiler. Exact build steps are platform dependent - se

## Usage

All songs in the .sav must first be prepared so that they are eventually stopped with the HFF command. Then, place your .sav and .gb file in the same directory and run e.g. `./lsdjpack.exe lsdj.gb` to record the songs to `music.s`. The Game Boy player ROM can now be built using RGBDS:
All songs in the .sav must first be prepared so that they are eventually stopped with the HFF command. Then, place your .sav and .gb file in the same directory and run e.g. `./lsdjpack.exe lsdj.gb` to record the songs to `lsdj.s`. The Game Boy player ROM can now be built using RGBDS:

rgbasm -o boot.o boot.s
rgbasm -o player.o player.s
rgbasm -o music.o music.s
rgblink -o player.gb boot.o player.o music.o
rgbasm -o lsdj.o lsdj.s
rgblink -o player.gb boot.o player.o lsdj.o
rgbfix -v -m 0x19 -p 0 player.gb
@@ -7,9 +7,9 @@
#include "writer.h"

int written_songs;

gambatte::GB gameboy;
Input input;
std::string out_path;

void run_one_frame() {
size_t samples = 35112;
@@ -55,18 +55,18 @@ void load_song(int position) {
press(0, 5);
if (gameboy.isSongEmpty()) {
record_complete();
puts("ok");
puts("OK");
exit(0);
}
printf("Recording song %i...\n", ++written_songs);
printf("Song %i...\n", ++written_songs);
}

bool sound_enabled;

void play_song() {
sound_enabled = false;
input.press(START);
record_song_start();
record_song_start(out_path.c_str());
do {
wait(1);
} while(sound_enabled);
@@ -97,6 +97,15 @@ void on_lcd_interrupt() {
}
}

void make_out_path(const char* in_path) {
out_path = in_path;
// .gb => .s
out_path.replace(out_path.end() - 2, out_path.end(), "s");
out_path.replace(out_path.begin(), out_path.begin() + out_path.rfind('/') + 1, "");
out_path.replace(out_path.begin(), out_path.begin() + out_path.rfind('\\') + 1, "");
printf("Recording to '%s'\n", out_path.c_str());
}

int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr, "usage: lsdpack <lsdj.gb>");
@@ -107,6 +116,8 @@ int main(int argc, char* argv[]) {
gameboy.setLcdHandler(on_lcd_interrupt);
gameboy.load(argv[1]);

make_out_path(argv[1]);

press(0, 3);

int i = 0;
@@ -7,7 +7,7 @@
#include <map>
#include <vector>

FILE* f;
static FILE* f;

struct Location {
int bank;
@@ -127,9 +127,9 @@ static void record_byte(unsigned char byte) {

// -----

void record_song_start() {
void record_song_start(const char* out_path) {
if (f == 0) {
f = fopen("music.s", "w");
f = fopen(out_path, "w");
new_bank();
}
music_stream.push_back(START);
@@ -1,6 +1,6 @@
#pragma once

void record_song_start();
void record_song_start(const char* out_path);
void record_song_stop();
void record_write(char addr, char data);
void record_lcd();

0 comments on commit d362f6c

Please sign in to comment.