Skip to content

Commit

Permalink
Added LPEN b0 support over main screen
Browse files Browse the repository at this point in the history
LPEN b0 now reflects b0 of the first ASIC display byte over the main
screen area, in addition to BCD0 of the border colour in border regions.
  • Loading branch information
simonowen committed May 27, 2020
1 parent 8b10ee7 commit 40ee9a5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Base/SAMIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,18 @@ static uint8_t update_lpen()
{
int line = g_dwCycleCounter / TSTATES_PER_LINE, line_cycle = g_dwCycleCounter % TSTATES_PER_LINE;

if (!IsScreenLine(line) || line_cycle < (BORDER_PIXELS + BORDER_PIXELS))
if (IsScreenLine(line) && line_cycle >= (BORDER_PIXELS + BORDER_PIXELS))
{
lpen = (lpen & LPEN_TXFMST) | (border & 1);
uint8_t b1, b2, b3, b4;
Frame::GetAsicData(&b1, &b2, &b3, &b4);

auto xpos = static_cast<uint8_t>(line_cycle - (BORDER_PIXELS + BORDER_PIXELS));
auto b0 = (line_cycle < (BORDER_PIXELS + BORDER_PIXELS)) ? (border & 1) : (b1 & 1);
lpen = (xpos & 0xfc) | (lpen & LPEN_TXFMST) | b0;
}
else
{
auto xpos = static_cast<uint8_t>(line_cycle - (BORDER_PIXELS + BORDER_PIXELS));
auto b0 = (xpos < VIDEO_DELAY&& line == TOP_BORDER_LINES) ? 1 : xpos ? 0 : 1;
lpen = (xpos & 0xfc) | (lpen & LPEN_TXFMST) | b0;
lpen = (lpen & LPEN_TXFMST) | (border & 1);
}
}

Expand All @@ -322,7 +325,7 @@ static uint8_t update_hpen()
int line = g_dwCycleCounter / TSTATES_PER_LINE, line_cycle = g_dwCycleCounter % TSTATES_PER_LINE;

if (IsScreenLine(line) && (line != TOP_BORDER_LINES || line_cycle >= (BORDER_PIXELS + BORDER_PIXELS)))
hpen = line -TOP_BORDER_LINES;
hpen = line - TOP_BORDER_LINES;
else
hpen = SCREEN_LINES;
}
Expand Down Expand Up @@ -504,16 +507,12 @@ BYTE In(WORD wPort_)
bRet = pDallas->In(wPort_);
break;

// HPEN and LPEN ports
case LPEN_PORT:
{
// Simulated a disconnected light pen, with LPEN/HPEN tracking the raster position.
if ((wPort_ & PEN_MASK) == LPEN_PORT)
bRet = update_lpen();
else // HPEN
else
bRet = update_hpen();
break;
}

// Spectrum ATTR port
case ATTR_PORT:
Expand Down

0 comments on commit 40ee9a5

Please sign in to comment.