Skip to content

Commit

Permalink
Merge pull request #8 from visrealm/dev
Browse files Browse the repository at this point in the history
v0.4.1
  • Loading branch information
visrealm committed Aug 21, 2024
2 parents dc73003 + 589384f commit 4361997
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 34 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ set(PICO_BOARD "pico9918_v04")
project(${PROJECT} C CXX)

add_definitions(-DPICO_BUILD=1)
add_definitions(-DPICO_DISABLE_SHARED_IRQ_HANDLERS=1)
add_definitions(-DVR_EMU_TMS9918_SINGLE_INSTANCE=1)
add_definitions(-DPICO_PANIC_FUNCTION=)
add_definitions(-DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ pico_enable_stdio_uart(${PROGRAM} 0)

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

add_definitions(-DPICO_DISABLE_SHARED_IRQ_HANDLERS=1)
add_definitions(-DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1)
add_definitions(-DPICO_PANIC_FUNCTION=)

target_link_libraries(${PROGRAM} PUBLIC
pico_stdlib
pico_multicore
Expand Down
49 changes: 22 additions & 27 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

static uint8_t nextValue = 0; /* TMS9918A read-ahead value */
static bool currentInt = false; /* current interrupt state */
static uint8_t currentStatus = 0; /* current status register value */
static uint8_t currentStatus = 0x1f; /* current status register value */

static uint8_t __aligned(4) tmsScanlineBuffer[TMS9918_PIXELS_X];

Expand Down Expand Up @@ -164,7 +164,7 @@ void __not_in_flash_func(pio_irq_handler)()
}
else // read status
{
currentStatus = 0;
currentStatus = 0x1f;
vrEmuTms9918SetStatusImpl(currentStatus);
currentInt = false;
gpio_put(GPIO_INT, !currentInt);
Expand Down Expand Up @@ -269,12 +269,6 @@ static void __time_critical_func(tmsScanline)(uint16_t y, VgaParams* params, uin

y -= vBorder;

/*** left border ***/
for (int x = 0; x < hBorder; ++x)
{
pixels[x] = bg;
}

/*** main display region ***/

/* generate the scanline */
Expand All @@ -286,6 +280,25 @@ static void __time_critical_func(tmsScanline)(uint16_t y, VgaParams* params, uin
tempStatus |= STATUS_INT;
}

disableTmsPioInterrupts();
if ((currentStatus & STATUS_INT) == 0)
{
currentStatus = (currentStatus & 0xe0) | tempStatus;

vrEmuTms9918SetStatusImpl(currentStatus);
updateTmsReadAhead();

currentInt = vrEmuTms9918InterruptStatusImpl();
gpio_put(GPIO_INT, !currentInt);
}
enableTmsPioInterrupts();

/*** left border ***/
for (int x = 0; x < hBorder; ++x)
{
pixels[x] = bg;
}

/* convert from palette to bgr12 */
int tmsX = 0;
if (tmsScanlineBuffer[0] & 0xf0)
Expand All @@ -305,31 +318,13 @@ static void __time_critical_func(tmsScanline)(uint16_t y, VgaParams* params, uin
}
}


/*** right border ***/
for (int x = hBorder + TMS9918_PIXELS_X * 2; x < VIRTUAL_PIXELS_X; ++x)
{
pixels[x] = bg;
}

disableTmsPioInterrupts();
if ((currentStatus & STATUS_INT) == 0)
{
if ((currentStatus & STATUS_5S) != 0)
{
currentStatus |= tempStatus & 0xe0;
}
else
{
currentStatus |= tempStatus;
}

vrEmuTms9918SetStatusImpl(currentStatus);
updateTmsReadAhead();

currentInt = vrEmuTms9918InterruptStatusImpl();
gpio_put(GPIO_INT, !currentInt);
}
enableTmsPioInterrupts();
}

/*
Expand Down
Binary file modified src/res/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/vga/vga-modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ bool setVgaParamsScaleX(VgaParams* params, int pixelScale)
if (!params || pixelScale < 1) return false;

params->hPixelScale = pixelScale;
params->hVirtualPixels = (params->hSyncParams.displayPixels / 1);//params->hPixelScale);
params->hVirtualPixels = (params->hSyncParams.displayPixels / params->hPixelScale);
return true;
}

Expand All @@ -144,7 +144,7 @@ bool setVgaParamsScaleY(VgaParams* params, int pixelScale)
if (!params || pixelScale < 1) return false;

params->vPixelScale = pixelScale;
params->vVirtualPixels = (params->vSyncParams.displayPixels / 2);//params->vPixelScale);
params->vVirtualPixels = (params->vSyncParams.displayPixels / params->vPixelScale);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion submodules/vrEmuTms9918
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12)

add_subdirectory(host)
#add_subdirectory(qc)
add_subdirectory(qc)

0 comments on commit 4361997

Please sign in to comment.