Skip to content

Commit

Permalink
JV880 support (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
giulioz committed Apr 19, 2024
1 parent 182433e commit 7ae4f02
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 49 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Supported models:
- SC-55mk1 (v1.21/v2.0 firmwares are confirmed to work)
- CM-300/SCC-1 (v1.10/v1.20 firmwares are confirmed to work)
- SC-55st (v1.01)
- JV-880 (v1.0.0)

Special thanks:
- John McMaster: SC-55 PCM chip decap.
Expand Down Expand Up @@ -82,6 +83,13 @@ R15279806 (WAVE A) -> cm300_waverom1.bin
R15279807 (WAVE B) -> cm300_waverom2.bin
R15279808 (WAVE C) -> cm300_waverom3.bin
JV-880 (v1.0.0):
R15199810 (H8/532 mcu) -> jv880_rom1.bin
R15209386 (H8/532 extra code) -> jv880_rom2.bin
R15209312 (WAVE A) -> jv880_waverom1.bin
R15209313 (WAVE B) -> jv880_waverom2.bin
Expansion PCBs -> jv880_waverom_expansion.bin (optional)
```

## License
Expand Down Expand Up @@ -119,6 +127,27 @@ LEFT -> PART L
RIGHT -> PART R
```

- `-mk2`, `-st`, `mk1` and `-cm300` command line arguments can be used to specify rom set. If no model is specified emulator will try to autodetect rom set (based on file names).
- JV-880 buttons are mapped as such (currently hardcoded):

```
P -> PREVIEW
LEFT -> CURSOR L
RIGHT -> CURSOR R
TAB -> DATA
Q -> TONE_SELECT
A -> PATCH_PERFORM
W -> EDIT
E -> SYSTEM
R -> RHYTHM
T -> UTILITY
S -> MUTE
D -> MONITOR
F -> COMPARE
G -> ENTER
COMMA -> ENCODER L
PERIOD -> ENCODER R
```

- `-mk2`, `-st`, `mk1`, `-cm300` and `-jv880` command line arguments can be used to specify rom set. If no model is specified emulator will try to autodetect rom set (based on file names).

- Due to a bug in the SC-55mk2's firmware, some parameters don't reset properly on startup. Do GM, GS or MT-32 reset using buttons to fix this issue.
79 changes: 62 additions & 17 deletions src/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void LCD_Write(uint32_t address, uint8_t data)
else if ((data & 0xff) == 0x01)
{
LCD_DD_RAM = 0;
LCD_ID = 0;
LCD_ID = 1;
memset(LCD_Data, 0x20, sizeof(LCD_Data));
}
else if ((data & 0xff) == 0x02)
Expand Down Expand Up @@ -162,20 +162,22 @@ void LCD_Write(uint32_t address, uint8_t data)
// printf("\n");
}

static const int lcd_width = 741;
static const int lcd_height = 268;
int lcd_width = 741;
int lcd_height = 268;
static const int lcd_width_max = 1024;
static const int lcd_height_max = 1024;
static SDL_Window *window;
static SDL_Renderer *renderer;
static SDL_Texture *texture;

static std::string m_back_path = "back.data";

static uint32_t lcd_buffer[lcd_height][lcd_width];
static uint32_t lcd_background[lcd_height][lcd_width];
static uint32_t lcd_buffer[lcd_height_max][lcd_width_max];
static uint32_t lcd_background[268][741];

static uint32_t lcd_init = 0;

const int button_map[][2] =
const int button_map_sc55[][2] =
{
SDL_SCANCODE_Q, MCU_BUTTON_POWER,
SDL_SCANCODE_W, MCU_BUTTON_INST_ALL,
Expand All @@ -197,7 +199,25 @@ const int button_map[][2] =
SDL_SCANCODE_J, MCU_BUTTON_CHORUS_L,
SDL_SCANCODE_K, MCU_BUTTON_CHORUS_R,
SDL_SCANCODE_LEFT, MCU_BUTTON_PART_L,
SDL_SCANCODE_RIGHT, MCU_BUTTON_PART_R
SDL_SCANCODE_RIGHT, MCU_BUTTON_PART_R,
};

const int button_map_jv880[][2] =
{
SDL_SCANCODE_P, MCU_BUTTON_PREVIEW,
SDL_SCANCODE_LEFT, MCU_BUTTON_CURSOR_L,
SDL_SCANCODE_RIGHT, MCU_BUTTON_CURSOR_R,
SDL_SCANCODE_TAB, MCU_BUTTON_DATA,
SDL_SCANCODE_Q, MCU_BUTTON_TONE_SELECT,
SDL_SCANCODE_A, MCU_BUTTON_PATCH_PERFORM,
SDL_SCANCODE_W, MCU_BUTTON_EDIT,
SDL_SCANCODE_E, MCU_BUTTON_SYSTEM,
SDL_SCANCODE_R, MCU_BUTTON_RHYTHM,
SDL_SCANCODE_T, MCU_BUTTON_UTILITY,
SDL_SCANCODE_S, MCU_BUTTON_MUTE,
SDL_SCANCODE_D, MCU_BUTTON_MONITOR,
SDL_SCANCODE_F, MCU_BUTTON_COMPARE,
SDL_SCANCODE_G, MCU_BUTTON_ENTER,
};


Expand Down Expand Up @@ -326,22 +346,37 @@ void LCD_Update(void)
{
MCU_WorkThread_Lock();

if (!lcd_enable)
if (!lcd_enable && !mcu_jv880)
{
memset(lcd_buffer, 0, sizeof(lcd_buffer));
}
else
{
memcpy(lcd_buffer, lcd_background, sizeof(lcd_buffer));
if (mcu_jv880)
{
for (size_t i = 0; i < lcd_height; i++) {
for (size_t j = 0; j < lcd_width; j++) {
lcd_buffer[i][j] = 0xFF0F6FFF;
}
}
}
else
{
for (size_t i = 0; i < lcd_height; i++) {
for (size_t j = 0; j < lcd_width; j++) {
lcd_buffer[i][j] = lcd_background[i][j];
}
}
}

if (0)
if (mcu_jv880)
{
for (int i = 0; i < 4; i++)
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 20; j++)
for (int j = 0; j < 24; j++)
{
uint8_t ch = LCD_Data[i * 20 + j];
LCD_FontRenderStandard(i * 50, j * 34, ch);
uint8_t ch = LCD_Data[i * 40 + j];
LCD_FontRenderStandard(4 + i * 50, 4 + j * 34, ch);
}
}
}
Expand Down Expand Up @@ -401,14 +436,22 @@ void LCD_Update(void)

MCU_WorkThread_Unlock();

SDL_UpdateTexture(texture, NULL, lcd_buffer, lcd_width * 4);
SDL_UpdateTexture(texture, NULL, lcd_buffer, lcd_width_max * 4);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
}

SDL_Event sdl_event;
while (SDL_PollEvent(&sdl_event))
{
if (sdl_event.type == SDL_KEYDOWN)
{
if (sdl_event.key.keysym.scancode == SDL_SCANCODE_COMMA)
MCU_EncoderTrigger(0);
if (sdl_event.key.keysym.scancode == SDL_SCANCODE_PERIOD)
MCU_EncoderTrigger(1);
}

switch (sdl_event.type)
{
case SDL_QUIT:
Expand All @@ -420,11 +463,13 @@ void LCD_Update(void)
{
if (sdl_event.key.repeat)
continue;

int mask = 0;
uint32_t button_pressed = (uint32_t)SDL_AtomicGet(&mcu_button_pressed);

for (size_t i = 0; i < sizeof(button_map) / sizeof(button_map[0]); i++)
auto button_map = mcu_jv880 ? button_map_jv880 : button_map_sc55;
auto button_size = (mcu_jv880 ? sizeof(button_map_jv880) : sizeof(button_map_sc55)) / sizeof(button_map_sc55[0]);
for (size_t i = 0; i < button_size; i++)
{
if (button_map[i][0] == sdl_event.key.keysym.scancode)
mask |= (1 << button_map[i][1]);
Expand Down
3 changes: 3 additions & 0 deletions src/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#include <stdint.h>
#include <string>

extern int lcd_width;
extern int lcd_height;

void LCD_SetBackPath(const std::string &path);
void LCD_Init(void);
void LCD_UnInit(void);
Expand Down
Loading

0 comments on commit 7ae4f02

Please sign in to comment.