Skip to content

Commit

Permalink
composite options in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
xrip committed Feb 28, 2024
1 parent 2e82469 commit 3efd25c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ option(SOFTTV "Enable TV soft composite output" OFF)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funroll-loops -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -O2")

pico_sdk_init()

Expand Down
6 changes: 3 additions & 3 deletions drivers/tv-software/tv-software.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct tv_out_mode_t {
} tv_out_mode_t;

//параметры по умолчанию
static tv_out_mode_t tv_out_mode = {
tv_out_mode_t tv_out_mode = {
.tv_system = g_TV_OUT_NTSC,
.N_lines = _525_lines,
.mode_bpp = GRAPHICSMODE_DEFAULT,
Expand Down Expand Up @@ -1231,8 +1231,8 @@ void clrScr(const uint8_t color) {

void graphics_set_mode(const enum graphics_mode_t mode) {
tv_out_mode.mode_bpp = mode;
tv_out_mode.color_index = TEXTMODE_DEFAULT == mode ? 0.0 : 1.0;
tv_out_mode.cb_sync_PI_shift_lines = TEXTMODE_DEFAULT == mode ? true : false;
// tv_out_mode.color_index = TEXTMODE_DEFAULT == mode ? 0.0 : 1.0;
// tv_out_mode.cb_sync_PI_shift_lines = TEXTMODE_DEFAULT == mode ? true : false;
graphics_set_modeTV(tv_out_mode);
clrScr(0);
}
5 changes: 3 additions & 2 deletions drivers/tv/tv.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,14 +855,15 @@ void tv_init(const output_format_e output_format) {
dma_start_channel_mask(1u << dma_chan_ctrl);

int hz = 50000;
if (!add_repeating_timer_us(1000000 / hz, video_timer_callbackTV, NULL, &video_timer)) {

if (!alarm_pool_add_repeating_timer_us(alarm_pool_create(2, 16),1000000 / hz, video_timer_callbackTV, NULL, &video_timer)) {
return;
}
};


void graphics_init() {
tv_init(TV_OUT_PAL);
tv_init(TV_OUT_NTSC);

// FIXME сделать конфигурацию пользователем
graphics_set_palette(200, RGB888(0x00, 0x00, 0x00)); //black
Expand Down
37 changes: 35 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
* Game Boy DMG ROM size ranges from 32768 bytes (e.g. Tetris) to 1,048,576 bytes (e.g. Pokemod Red)
*/
#define HOME_DIR (char*)"\\GB"
#define FLASH_TARGET_OFFSET (128 * 1024)
#define FLASH_TARGET_OFFSET (256 * 1024)
const uint8_t* rom = (const uint8_t *)(XIP_BASE + FLASH_TARGET_OFFSET);

static uint8_t ram[32768];
Expand Down Expand Up @@ -695,15 +695,48 @@ bool load() {

return true;
}
#if SOFTTV
typedef struct tv_out_mode_t {
// double color_freq;
float color_index;
COLOR_FREQ_t c_freq;
enum graphics_mode_t mode_bpp;
g_out_TV_t tv_system;
NUM_TV_LINES_t N_lines;
bool cb_sync_PI_shift_lines;
bool cb_sync_PI_shift_half_frame;
} tv_out_mode_t;
extern tv_out_mode_t tv_out_mode;

bool color_mode=true;
bool toggle_color() {
color_mode=!color_mode;
if(color_mode) {
tv_out_mode.color_index= 1.0f;
} else {
tv_out_mode.color_index= 0.0f;
}

return true;
}
#endif
const MenuItem menu_items[] = {
//{ "Player 1: %s", ARRAY, &player_1_input, 2, { "Keyboard ", "Gamepad 1", "Gamepad 2" }},
//{ "Player 2: %s", ARRAY, &player_2_input, 2, { "Keyboard ", "Gamepad 1", "Gamepad 2" }},
{ "Palette: %i ", INT, &manual_palette_selected, nullptr, 12 },
{},
{ "Save state: %i", INT, &save_slot, &save, 5 },
{ "Load state: %i", INT, &save_slot, &load, 5 },
{},
#if SOFTTV
{ "" },
{ "TV system %s", ARRAY, &tv_out_mode.tv_system, nullptr, 1, { "PAL ", "NTSC" } },
{ "TV Lines %s", ARRAY, &tv_out_mode.N_lines, nullptr, 3, { "624", "625", "524", "525" } },
{ "Freq %s", ARRAY, &tv_out_mode.c_freq, nullptr, 1, { "3.579545", "4.433619" } },
{ "Colors: %s", ARRAY, &color_mode, &toggle_color, 1, { "NO ", "YES" } },
{ "Shift lines %s", ARRAY, &tv_out_mode.cb_sync_PI_shift_lines, nullptr, 1, { "NO ", "YES" } },
{ "Shift half frame %s", ARRAY, &tv_out_mode.cb_sync_PI_shift_half_frame, nullptr, 1, { "NO ", "YES" } },
#endif
{},
{
"Overclocking: %s MHz", ARRAY, &frequency_index, &overclock, count_of(frequencies) - 1,
{ "378", "396", "404", "408", "412", "416", "420", "424", "432" }
Expand Down

0 comments on commit 3efd25c

Please sign in to comment.