Skip to content

Commit

Permalink
Fix Hercules blend mode so that adjacent lit pixels are brighter again [
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Jun 27, 2024
1 parent a66af3a commit 95d543a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Next:
- Hercules/MDA and InColor integration broke the Hercules blend mode
render, fix the render so that adjacent lit pixels are brighter
again. (joncampbell123).
- Fix "VRD" debugger command bug that didn't properly render out the
rest of the VGA display frame. (joncampbell123).
- Fixed debugger mapper shortcut bug where entering the debugger
Expand Down
17 changes: 17 additions & 0 deletions src/hardware/vga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ void vsync_poll_debug_notify() {
vga_3da_polled = true;
}

uint32_t HercBlend_2_Table[16];
uint32_t CGA_2_Table[16];
uint32_t CGA_4_Table[256];
uint32_t CGA_4_HiRes_Table[256];
Expand Down Expand Up @@ -1216,6 +1217,22 @@ void VGA_Reset(Section*) {
/* Generate tables */
VGA_SetCGA2Table(0,1);
VGA_SetCGA4Table(0,1,2,3);

if (machine == MCH_HERC || machine == MCH_MDA) {
/* alternate table for blend mode, expect mapping 0=black 1-7=gray 8=black 9-f=white
* for use with blend code that reads this table and sums the output with a delayed version of the same */
const uint8_t total[2] = {0x0,0x05}; /* blending will yield {0,5,10} which is sufficient to recreate the effect */
for (Bitu i=0;i<16u;i++) {
HercBlend_2_Table[i]=
#ifdef WORDS_BIGENDIAN
((Bitu)total[(i >> 0u) & 1u] << 0u ) | ((Bitu)total[(i >> 1u) & 1u] << 8u ) |
((Bitu)total[(i >> 2u) & 1u] << 16u ) | ((Bitu)total[(i >> 3u) & 1u] << 24u );
#else
((Bitu)total[(i >> 3u) & 1u] << 0u ) | ((Bitu)total[(i >> 2u) & 1u] << 8u ) |
((Bitu)total[(i >> 1u) & 1u] << 16u ) | ((Bitu)total[(i >> 0u) & 1u] << 24u );
#endif
}
}
}

Section_prop * section2=static_cast<Section_prop *>(control->GetSection("vsync"));
Expand Down
6 changes: 4 additions & 2 deletions src/hardware/vga_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ static uint8_t * VGA_Draw_1BPP_Line(Bitu vidstart, Bitu line) {
return VGA_Draw_1BPP_Line_Common<MCH_CGA,uint8_t>(TempLine,vidstart,line);
}

extern uint32_t HercBlend_2_Table[16];

static uint8_t * VGA_Draw_1BPP_Blend_Line(Bitu vidstart, Bitu line) {
const uint8_t *base = vga.tandy.draw_base + ((line & vga.tandy.line_mask) << vga.tandy.line_shift);
uint32_t *draw = (uint32_t *)TempLine;
Expand All @@ -481,8 +483,8 @@ static uint8_t * VGA_Draw_1BPP_Blend_Line(Bitu vidstart, Bitu line) {
Bitu val1 = base[vidstart & (8 * 1024 -1)];
Bitu val2 = (val1 >> 1) + carry;
carry = (val1 & 1) << 7;
*draw++=CGA_2_Table[val1 >> 4] + CGA_2_Table[val2 >> 4];
*draw++=CGA_2_Table[val1 & 0xf] + CGA_2_Table[val2 & 0xf];
*draw++=HercBlend_2_Table[val1 >> 4] + HercBlend_2_Table[val2 >> 4];
*draw++=HercBlend_2_Table[val1 & 0xf] + HercBlend_2_Table[val2 & 0xf];
}
return TempLine;
}
Expand Down
1 change: 1 addition & 0 deletions src/hardware/vga_other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ void CycleMonoCGABright(bool pressed) {
void HercBlend(bool pressed) {
if (!pressed) return;
vga.herc.blend = !vga.herc.blend;
LOG_MSG("Hercules blend %u",vga.herc.blend);
VGA_SetupDrawing(0);
}

Expand Down

0 comments on commit 95d543a

Please sign in to comment.