Skip to content

Commit f98bfdf

Browse files
authored
Four minor blitter fixes (#20)
* Fix blitter initial colors, resize, and flicker * remove the 'AND' comment, this was misguided * *always* use synchronized output for every frame this prevents "rolling bars" as described * use 0x0 / zeros as redraw sentinel
1 parent 9c0d19b commit f98bfdf

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

gambaterm/run.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ def run(
129129
# Check terminal size
130130
new_size = app_session.output.get_size()
131131
if new_size != (height, width):
132-
app_session.output.erase_screen()
133-
app_session.output.flush()
132+
maybe_clear_seq = b"\033[H\033[2J"
134133
height, width = new_size
135134
refx, refy = get_ref(width, height, console)
136-
last_frame.fill(0xFFFFFFFF)
137-
# Render frame
138-
video_data = blit(
139-
video, last_frame, refx, refy, width - 1, height, color_mode
135+
last_frame.fill(0)
136+
else:
137+
maybe_clear_seq = b""
138+
# Render frame with synchronized output mode (DEC 2026) to prevent flickering
139+
# when the screen is cleared, or an artificial CRT-like "rolling band" side-effects
140+
# from fast "sprite blinking" meant to cause "transparency" effect on original HW,
141+
# https://zladx.github.io/posts/links-awakening-partial-translucency
142+
video_data = (
143+
b"\033[?2026h"
144+
+ maybe_clear_seq
145+
+ blit(video, last_frame, refx, refy, width - 1, height, color_mode)
146+
+ b"\033[?2026l"
140147
)
141148
last_frame = video.copy()
142149
# Update reporting

termblit_ext/termblit.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ cdef char* _blit(
154154

155155
cdef int current_x = refx
156156
cdef int current_y = refy
157-
cdef uint32_t current_fg = -1
158-
cdef uint32_t current_bg = -2
157+
# Use 0x0 as "undrawn" sentinel: real GB pixels always have 0xFF
158+
# in the high byte, so 0x0 can never match
159+
cdef uint32_t current_fg = 0x0
160+
cdef uint32_t current_bg = 0x0
159161
cdef int row_index, column_index
160162
cdef uint32_t color1, color2
161163
cdef int new_x, new_y

0 commit comments

Comments
 (0)