start-microcode fullscreen_bitmap

\ Interface:
\ 4500-7f97 bitmap, 1 bit per pixel, so 50 bytes per line
\ 7ff0-7fff stretch lookup table

: 1+    d# 1 + ;
: 0=    d# 0 = ;

: stretch! ( dst a -- dst' ) \ expand 4 bit graphic a, write to dst
    h# f and
    h# 7ff0 + c@
    over c! 1+
    ;

: byte ( src dst -- src' dst' ) \ expand 8 pixels from src to dst
    over c@ swap    ( src a dst )
                    
    over d# 4 rshift stretch!
    swap stretch!  ( src dst' )
    swap d# 50 + swap      \ down 1 line in video memory
;

: pixelcopy ( y -- ) \ copy 8 rows of bitmap into chars 0-49 or 50-99
    dup d# 50 * h# 4500 +              ( y src )
    swap d# 3 rshift d# 1 and d# 800 * RAM_CHR +   ( src dst )
    d# 50 
    begin
        >r
        byte byte byte byte byte byte byte byte
        \ move src back 400 and right 1 byte
        swap d# -399 + swap
        r> 1- dup 0=
    until drop drop drop
;

: main
    d# 0
    begin
        begin dup YLINE c@ = until
        d# 8 + d# 300 over < if drop d# 0 then
        dup pixelcopy
    again
;

end-microcode

