Skip to content

Commit

Permalink
.s name now matches .gb name
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotlinski committed Jun 27, 2018
1 parent 07582ed commit d362f6c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .lvimrc
Original file line number Original file line Diff line number Diff line change
@@ -1,2 +1,2 @@
map <F3> :wall!<CR>:make<CR>:!./lsdpack.exe ../lsdj/lsdj.gb<CR> 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>
6 changes: 3 additions & 3 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Requires CMake and a C++ compiler. Exact build steps are platform dependent - se


## Usage ## 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 boot.o boot.s
rgbasm -o player.o player.s rgbasm -o player.o player.s
rgbasm -o music.o music.s rgbasm -o lsdj.o lsdj.s
rgblink -o player.gb boot.o player.o music.o rgblink -o player.gb boot.o player.o lsdj.o
rgbfix -v -m 0x19 -p 0 player.gb rgbfix -v -m 0x19 -p 0 player.gb
19 changes: 15 additions & 4 deletions lsdpack.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include "writer.h" #include "writer.h"


int written_songs; int written_songs;

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


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


bool sound_enabled; bool sound_enabled;


void play_song() { void play_song() {
sound_enabled = false; sound_enabled = false;
input.press(START); input.press(START);
record_song_start(); record_song_start(out_path.c_str());
do { do {
wait(1); wait(1);
} while(sound_enabled); } while(sound_enabled);
Expand Down Expand Up @@ -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[]) { int main(int argc, char* argv[]) {
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "usage: lsdpack <lsdj.gb>"); fprintf(stderr, "usage: lsdpack <lsdj.gb>");
Expand All @@ -107,6 +116,8 @@ int main(int argc, char* argv[]) {
gameboy.setLcdHandler(on_lcd_interrupt); gameboy.setLcdHandler(on_lcd_interrupt);
gameboy.load(argv[1]); gameboy.load(argv[1]);


make_out_path(argv[1]);

press(0, 3); press(0, 3);


int i = 0; int i = 0;
Expand Down
6 changes: 3 additions & 3 deletions writer.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <map> #include <map>
#include <vector> #include <vector>


FILE* f; static FILE* f;


struct Location { struct Location {
int bank; int bank;
Expand Down Expand Up @@ -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) { if (f == 0) {
f = fopen("music.s", "w"); f = fopen(out_path, "w");
new_bank(); new_bank();
} }
music_stream.push_back(START); music_stream.push_back(START);
Expand Down
2 changes: 1 addition & 1 deletion writer.h
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once #pragma once


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

0 comments on commit d362f6c

Please sign in to comment.