Files
Sprinter-SDCC/libc/gfx/_gfx_render_row16.c
T
snark13 4a081501d8 libc: сплит «1 функция = 1 модуль» — вся библиотека, wildcard-сборка
- bios/conio/env/errno/gfx/io/mem/mouse/stdio/stdlib/string/sys/time/
  video разложены по модулям: общие статики и helpers — в internal
  _-модулях (_conio.h/_mouse.h/_gfx.h/_palette.h/_atexit.h/_time.h)
- lib/Makefile: LIBC_C = wildcard libc/*/*.c — гранулярность файлов
  = гранулярность DCE линкера
- эффект _CODE: gfx_text 6986→2568 Б, gfx_mous −1745, gfx_demo/d16
  −542; ранее timedir −3270, ls −3098, stattest −2995
- комментарии оставшихся модулей переведены на русский; puts: убран
  мёртвый pchars; videomode_raw разложен на get/set
- docs/libc-split-asm-cases.md — правила asm-связок между модулями;
  docs/libc-roadmap.md — план этапа
- восстановлен examples/mdview/SAMPLE.MD (нужен make floppy)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 16:08:58 +03:00

54 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* _gfx_render_row16 — один 8-пиксельный ряд глифа в mode 0x82
* (640×256×16): 4 выходных байта, каждый пакует два соседних пикселя
* как (LEFT<<4) | RIGHT через прекомпилированную _gfx_t16_pair —
* 2-битный паттерн источника (LEFT*2 + RIGHT) сразу даёт выходной
* байт, без mask/OR на пиксель. Сам делает DI / W3 save+restore —
* вызывать можно из любого контекста без скобок.
*/
#include "_gfx.h"
void _gfx_render_row16(void) __naked
{
__asm
di
in a, (#0xE2)
push af
ld a, #0x50
out (#0xE2), a
ld a, (__gfx_t16_y)
out (#0x89), a
ld hl, (__gfx_t16_addr)
ld a, (__gfx_t16_row)
ld c, a ; C = сдвигаемые биты источника
ld b, #4 ; 4 выходных байта
rr16_loop:
;; Два верхних бита C в индекс A = LEFT*2 + RIGHT.
sla c ; CY = бит LEFT; C <<= 1
ld a, #0
adc a, a ; A = LEFT
sla c ; CY = бит RIGHT; C <<= 1
adc a, a ; A = LEFT*2 + RIGHT (0..3)
;; A = _gfx_t16_pair[A]; HL сохраняем через стек.
push hl
ld e, a
ld d, #0
ld hl, #__gfx_t16_pair
add hl, de
ld a, (hl)
pop hl
ld (hl), a
inc hl
djnz rr16_loop
pop af
out (#0xE2), a
ei
ret
__endasm;
}