Skip to content

Commit 4d84571

Browse files
authored
Merge pull request #16 from visrealm/dev
0.4.2
2 parents 06e600f + 1e770c5 commit 4d84571

File tree

11 files changed

+161
-47
lines changed

11 files changed

+161
-47
lines changed

.vscode/settings.json

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
{
2-
"files.associations": {
3-
"*.md": "markdown",
4-
"xtr1common": "c",
5-
"stdlib.h": "c",
6-
"multicore.h": "c",
7-
"stdio.h": "c",
8-
"tms9918.pio.h": "c"
9-
}
10-
}
2+
"cmake.options.statusBarVisibility": "hidden",
3+
"cmake.options.advanced": {
4+
"build": {
5+
"statusBarVisibility": "hidden"
6+
},
7+
"launch": {
8+
"statusBarVisibility": "hidden"
9+
},
10+
"debug": {
11+
"statusBarVisibility": "hidden"
12+
}
13+
},
14+
"cmake.configureOnEdit": false,
15+
"cmake.automaticReconfigure": false,
16+
"cmake.configureOnOpen": false,
17+
"cmake.generator": "Ninja",
18+
"cmake.cmakePath": "C:\\Users\\troy\\.pico-sdk\\cmake\\v3.28.6\\bin\\cmake",
19+
"C_Cpp.debugShortcut": false,
20+
"terminal.integrated.env.windows": {
21+
"PICO_SDK_PATH": "${env:USERPROFILE}/.pico-sdk/sdk/2.0.0",
22+
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/13_3_Rel1",
23+
"Path": "${env:USERPROFILE}/.pico-sdk/toolchain/13_3_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.0.0/picotool;${env:USERPROFILE}/.pico-sdk/cmake/v3.30.5/bin;${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}"
24+
},
25+
"terminal.integrated.env.osx": {
26+
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.0.0",
27+
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/13_3_Rel1",
28+
"PATH": "${env:HOME}/.pico-sdk/toolchain/13_3_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.0.0/picotool:${env:HOME}/.pico-sdk/cmake/v3.30.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
29+
},
30+
"terminal.integrated.env.linux": {
31+
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.0.0",
32+
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/13_3_Rel1",
33+
"PATH": "${env:HOME}/.pico-sdk/toolchain/13_3_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.0.0/picotool:${env:HOME}/.pico-sdk/cmake/v3.30.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
34+
},
35+
"raspberry-pi-pico.cmakeAutoConfigure": true,
36+
"raspberry-pi-pico.useCmakeTools": false,
37+
"raspberry-pi-pico.cmakePath": "${HOME}/.pico-sdk/cmake/v3.30.5/bin/cmake",
38+
"raspberry-pi-pico.ninjaPath": "${HOME}/.pico-sdk/ninja/v1.12.1/ninja",
39+
"raspberry-pi-pico.python3Path": "${HOME}/.pico-sdk/python/3.12.1/python.exe",
40+
"files.associations": {
41+
"vremutms9918priv.h": "c",
42+
"stdlib.h": "c",
43+
"binary_info.h": "c",
44+
"divider.h": "c"
45+
}
46+
}

CMakeLists.txt

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
1-
cmake_minimum_required(VERSION 3.12)
1+
# Generated Cmake Pico project file
22

3-
# pull in PICO SDK (must be before project)
4-
include(pico_sdk_import.cmake)
3+
cmake_minimum_required(VERSION 3.13)
54

6-
# pull in helpers for my custom tools
7-
include(visrealm_tools.cmake)
5+
set(CMAKE_C_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD 17)
7+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8+
9+
# Initialise pico_sdk from installed location
10+
# (note this can come from environment, CMake cache etc)
11+
12+
# == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==
13+
if(WIN32)
14+
set(USERHOME $ENV{USERPROFILE})
15+
else()
16+
set(USERHOME $ENV{HOME})
17+
endif()
18+
set(sdkVersion 2.0.0)
19+
set(toolchainVersion 13_3_Rel1)
20+
set(picotoolVersion 2.0.0)
21+
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
22+
if (EXISTS ${picoVscode})
23+
include(${picoVscode})
24+
endif()
25+
# ====================================================================================
826

9-
set(BUILD_SHARED_LIBS OFF)
27+
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/src/boards )
28+
set(PICO_BOARD "pico9918_v04" CACHE STRING "Board type")
1029

11-
set(PROJECT pico9918)
30+
# Pull in Raspberry Pi Pico SDK (must be before project)
31+
include(pico_sdk_import.cmake)
1232

13-
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/src/boards )
14-
set(PICO_BOARD "pico9918_v04")
33+
# pull in helpers for my custom tools
34+
include(visrealm_tools.cmake)
1535

16-
project(${PROJECT} C CXX)
36+
project(pico9918 C CXX ASM)
1737

1838
add_definitions(-DPICO_BUILD=1)
1939
add_definitions(-DVR_EMU_TMS9918_SINGLE_INSTANCE=1)
2040

21-
set(CMAKE_C_STANDARD 11)
22-
set(CMAKE_CXX_STANDARD 17)
23-
24-
# Initialize the Pico SDK
41+
# Initialise the Raspberry Pi Pico SDK
2542
pico_sdk_init()
2643

2744
add_subdirectory(submodules/vrEmuTms9918)
2845
add_subdirectory(src)
29-
add_subdirectory(test)
30-
46+
add_subdirectory(test)

pico_sdk_import.cmake

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
1818
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
1919
endif ()
2020

21+
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
22+
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG})
23+
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')")
24+
endif ()
25+
26+
if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
27+
set(PICO_SDK_FETCH_FROM_GIT_TAG "master")
28+
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG")
29+
endif()
30+
2131
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
2232
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
2333
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
34+
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK")
2435

2536
if (NOT PICO_SDK_PATH)
2637
if (PICO_SDK_FETCH_FROM_GIT)
@@ -34,14 +45,14 @@ if (NOT PICO_SDK_PATH)
3445
FetchContent_Declare(
3546
pico_sdk
3647
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
37-
GIT_TAG master
48+
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
3849
GIT_SUBMODULES_RECURSE FALSE
3950
)
4051
else ()
4152
FetchContent_Declare(
4253
pico_sdk
4354
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
44-
GIT_TAG master
55+
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
4556
)
4657
endif ()
4758

src/CMakeLists.txt

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1-
set(PROGRAM pico9918)
1+
cmake_minimum_required(VERSION 3.13)
22

3-
#add_subdirectory(pio-utils)
43

5-
add_executable(${PROGRAM})
4+
# compile-time options
5+
6+
set(PICO9918_VERSION "0.4.2")
7+
set(PICO9918_PCB_MAJOR_VER 0)
8+
set(PICO9918_PCB_MINOR_VER 4)
9+
10+
set(PICO9918_SCANLINES 1)
11+
12+
# end compile-time options
13+
14+
15+
# set up variables for the build process
16+
17+
execute_process(
18+
COMMAND git symbolic-ref --short HEAD
19+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
20+
OUTPUT_VARIABLE PICO9918_GIT_BRANCH
21+
OUTPUT_STRIP_TRAILING_WHITESPACE
22+
)
23+
24+
string(REPLACE "." "-" PICO9918_VERSION_STR "${PICO9918_VERSION}")
25+
26+
set(PICO9918_BINARY_SUFFIX -pcb-v${PICO9918_PCB_MAJOR_VER}-${PICO9918_PCB_MINOR_VER}-${PICO9918_GIT_BRANCH}-build-${PICO9918_VERSION_STR})
27+
28+
if (${PICO9918_SCANLINES})
29+
set(PICO9918_BINARY_SUFFIX ${PICO9918_BINARY_SUFFIX}-sl)
30+
endif()
31+
32+
if (${PICO9918_DIAG})
33+
set(PICO9918_BINARY_SUFFIX ${PICO9918_BINARY_SUFFIX}-diag)
34+
endif()
35+
36+
set(PROGRAM pico9918${PICO9918_BINARY_SUFFIX})
37+
38+
add_executable(${PROGRAM} )
639

740
target_sources(${PROGRAM} PRIVATE main.c palette.c clocks.pio.h tms9918.pio.h)
841

42+
pico_set_program_name(${PROGRAM} "pico9918")
43+
pico_set_program_version(${PROGRAM} ${PICO9918_VERSION})
44+
pico_set_program_description(${PROGRAM} "PICO9918 VDP for PCB v${PICO9918_PCB_MAJOR_VER}.${PICO9918_PCB_MINOR_VER}")
45+
pico_set_program_url(${PROGRAM} "https://github.com/visrealm/pico9918")
46+
947
# generate image array source files from png images
1048
visrealm_generate_image_source_ram(${PROGRAM} splash res/splash.png )
1149

@@ -19,11 +57,16 @@ pico_enable_stdio_uart(${PROGRAM} 0)
1957

2058
pico_set_binary_type(${PROGRAM} copy_to_ram) # TOO SLOW TO BOOT
2159

60+
add_definitions(-DPICO9918_VERSION="${PICO9918_VERSION}")
61+
add_definitions(-DPICO9918_PCB_MAJOR_VER=${PICO9918_PCB_MAJOR_VER})
62+
add_definitions(-DPICO9918_PCB_MINOR_VER=${PICO9918_PCB_MINOR_VER})
63+
add_definitions(-DPICO9918_SCANLINES=${PICO9918_SCANLINES})
64+
2265
add_definitions(-DPICO_DISABLE_SHARED_IRQ_HANDLERS=1)
23-
add_definitions(-DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1)
66+
#add_definitions(-DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1)
2467
add_definitions(-DPICO_PANIC_FUNCTION=)
2568

26-
target_link_libraries(${PROGRAM} PUBLIC
69+
target_link_libraries(${PROGRAM} PUBLIC
2770
pico_stdlib
2871
pico_multicore
2972
hardware_pio

src/boards/pico9918_v04.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
// -----------------------------------------------------
1111

1212
// This header may be included by other board headers as "boards/pico.h"
13-
14-
#ifndef _BOARDS_PICO_H
15-
#define _BOARDS_PICO_H
16-
13+
#pragma once
1714
// For board detection
1815
#define PICO9918
1916

@@ -95,5 +92,3 @@
9592
#ifndef PICO_VSYS_PIN
9693
#define PICO_VSYS_PIN 29
9794
#endif
98-
99-
#endif

src/main.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "pico/stdlib.h"
2626
#include "pico/multicore.h"
27+
#include "pico/binary_info.h"
2728

2829
#include "hardware/pio.h"
2930
#include "hardware/clocks.h"
@@ -104,7 +105,13 @@
104105
#define TMS_PIO pio1
105106
#define TMS_IRQ PIO1_IRQ_0
106107

107-
108+
bi_decl(bi_1pin_with_name(GPIO_GROMCL, "GROM Clock"));
109+
bi_decl(bi_1pin_with_name(GPIO_CPUCL, "CPU Clock"));
110+
bi_decl(bi_pin_mask_with_names(GPIO_CD_MASK, "CPU Data (CD7 - CD0)"));
111+
bi_decl(bi_1pin_with_name(GPIO_CSR, "Read"));
112+
bi_decl(bi_1pin_with_name(GPIO_CSW, "Write"));
113+
bi_decl(bi_1pin_with_name(GPIO_MODE, "Mode"));
114+
bi_decl(bi_1pin_with_name(GPIO_INT, "Interrupt"));
108115

109116

110117
/* file globals */
@@ -299,9 +306,9 @@ static void __time_critical_func(tmsScanline)(uint16_t y, VgaParams* params, uin
299306
pixels[x] = bg;
300307
}
301308

302-
/* convert from palette to bgr12 */
309+
/* convert from palette to bgr12 */
303310
int tmsX = 0;
304-
if (tmsScanlineBuffer[0] & 0xf0)
311+
if (tms9918->mode == TMS_MODE_TEXT80)
305312
{
306313
for (int x = hBorder; x < hBorder + TMS9918_PIXELS_X * 2; x += 2, ++tmsX)
307314
{
@@ -368,7 +375,7 @@ void tmsPioInit()
368375
pio_sm_config writeConfig = tmsWrite_program_get_default_config(tmsWriteProgram);
369376
sm_config_set_in_pins(&writeConfig, GPIO_CD7);
370377
sm_config_set_in_shift(&writeConfig, false, true, 16); // L shift, autopush @ 16 bits
371-
sm_config_set_clkdiv(&writeConfig, 4.0f);
378+
sm_config_set_clkdiv(&writeConfig, 1.0f);
372379

373380
pio_sm_init(TMS_PIO, tmsWriteSm, tmsWriteProgram, &writeConfig);
374381
pio_sm_set_enabled(TMS_PIO, tmsWriteSm, true);
@@ -387,7 +394,7 @@ void tmsPioInit()
387394
sm_config_set_out_pins(&readConfig, GPIO_CD7, 8);
388395
sm_config_set_in_shift(&readConfig, false, false, 32); // L shift
389396
sm_config_set_out_shift(&readConfig, true, false, 32); // R shift
390-
sm_config_set_clkdiv(&readConfig, 4.0f);
397+
sm_config_set_clkdiv(&readConfig, 1.0f);
391398

392399
pio_sm_init(TMS_PIO, tmsReadSm, tmsReadProgram, &readConfig);
393400
pio_sm_set_enabled(TMS_PIO, tmsReadSm, true);

src/res/splash.png

5 Bytes
Loading

src/vga/vga.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
#include "pio_utils.h"
1515

1616
#include "pico/multicore.h"
17+
#include "pico/binary_info.h"
1718

1819
#include "hardware/dma.h"
1920
#include "hardware/pio.h"
2021
#include "hardware/clocks.h"
2122

2223
// compile options
23-
#define VGA_CRT_EFFECT 1
24+
#define VGA_CRT_EFFECT PICO9918_SCANLINES
2425
#define VGA_SCANLINE_TIME_DEBUG 0
2526
#define VGA_HARDCODED_640 1
2627
#define VGA_NO_MALLOC 1
@@ -62,6 +63,11 @@ int roundflt(float x)
6263
#define END_OF_SCANLINE_MSG 0x40000000
6364
#define END_OF_FRAME_MSG 0x80000000
6465

66+
bi_decl(bi_1pin_with_name(SYNC_PINS_START, "H Sync"));
67+
bi_decl(bi_1pin_with_name(SYNC_PINS_START + 1, "V Sync"));
68+
bi_decl(bi_pin_mask_with_names(0xf << RGB_PINS_START, "Red (LSB - MSB)"));
69+
bi_decl(bi_pin_mask_with_names(0xf << RGB_PINS_START + 4, "Green (LSB - MSB)"));
70+
bi_decl(bi_pin_mask_with_names(0xf << RGB_PINS_START + 8, "Blue (LSB - MSB)"));
6571

6672
/*
6773
* sync pio dma data buffers

submodules/vrEmuTms9918

tools/bin2carray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def getFileHeader(fileName, fileList, args, isHeaderFile) -> str:
102102
sanitizedFile = re.sub('[^0-9a-zA-Z]+', '_', baseName.upper())
103103
hdrText += f"#pragma once\n\n"
104104
else:
105-
hdrText += "#include \"pico/platform.h\"\n"
105+
hdrText += "#include \"pico.h\"\n"
106106
hdrText += "#include <inttypes.h>"
107107
return hdrText
108108

0 commit comments

Comments
 (0)