saphir/Patch.HC

88 lines
No EOL
2.6 KiB
HolyC

U0 @function_patch(U32 from, U32 to) {
*(from(U8 *)) = 0xE9;
*((from + 1)(I32 *)) = to - from - 5;
}
U0 @gr_update_text_bg2() {
I64 reg RSI *dst = gr.dc2->body, reg R13 c, row, col, num_rows = TEXT_ROWS,
num_cols = TEXT_COLS, i, j, cur_ch,
reg R12 w1 = gr.dc2->width_internal, w2 = -7 * w1 + 8,
w3 = 7 * w1, w4 = 0;
U32 *src = gr.text_base;
Bool blink_flag = Blink;
U8 *dst2 = dst;
if (gr.pan_text_x || gr.hide_col) {
gr.pan_text_x = ClampI64(gr.pan_text_x, -7, 7);
j = AbsI64(gr.pan_text_x) / FONT_WIDTH + 1;
num_cols -= j;
if (gr.pan_text_x < 0) {
src += j;
i = FONT_WIDTH * j + gr.pan_text_x;
} else
i = gr.pan_text_x;
dst2 = dst(U8 *) + i;
w4 = j;
w3 += j * FONT_WIDTH;
j *= FONT_WIDTH;
dst(U8 *) = gr.dc2->body;
for (row = num_rows * FONT_HEIGHT; row--;) {
for (col = i; col--;)
*dst(U8 *)++ = 0;
dst(U8 *) += w1 - i - j;
for (col = j; col--;)
*dst(U8 *)++ = 0;
}
}
dst = dst2;
if (gr.pan_text_y || gr.hide_row) {
gr.pan_text_y = ClampI64(gr.pan_text_y, -7, 7);
j = AbsI64(gr.pan_text_y) / FONT_HEIGHT + 1;
num_rows -= j;
if (gr.pan_text_y < 0) {
src += w1 / FONT_WIDTH * j;
i = w1 * (FONT_HEIGHT * j + gr.pan_text_y);
} else
i = w1 * gr.pan_text_y;
dst2 = dst(U8 *) + i;
j *= w1 * FONT_HEIGHT;
dst(U8 *) = gr.dc2->body;
for (row = i; row--;)
*dst(U8 *)++ = 0;
dst(U8 *) =
gr.dc2->body + TEXT_ROWS * TEXT_COLS * FONT_HEIGHT * FONT_WIDTH - j;
for (row = j; row--;)
*dst(U8 *)++ = 0;
}
dst = dst2;
for (row = num_rows; row--;) {
for (col = num_cols; col--;) {
cur_ch = *src++;
if (cur_ch & (ATTRF_SEL | ATTRF_INVERT | ATTRF_BLINK)) {
if (cur_ch & ATTRF_SEL)
cur_ch.u8[1] = cur_ch.u8[1] ^ 0xFF;
if (cur_ch & ATTRF_INVERT)
cur_ch.u8[1] = cur_ch.u8[1] << 4 + cur_ch.u8[1] >> 4;
if (cur_ch & ATTRF_BLINK && blink_flag)
cur_ch.u8[1] = 0x30;
else
cur_ch.u8[1] = 0xFF;
}
c = gr.to_8_colors[cur_ch.u8[1] >> 4];
MOV U64[RSI], R13 ADD RSI, R12 MOV U64[RSI], R13 ADD RSI,
R12 MOV U64[RSI], R13 ADD RSI, R12 MOV U64[RSI], R13 ADD RSI,
R12 MOV U64[RSI], R13 ADD RSI, R12 MOV U64[RSI], R13 ADD RSI,
R12 MOV U64[RSI], R13 ADD RSI, R12 MOV U64[RSI], R13 dst(U8 *) += w2;
}
src += w4;
dst(U8 *) += w3;
}
}
@function_patch(&GrUpdateTextBG,
&@gr_update_text_bg2); // Patch GrUpdateTextBG to make cursor
// blinking less irritating