c2p
        ld bc,scrtop+31
        exx
        ld h,chmap/256
        call c2p_sub
        ld bc,scrtop+31 + #400
        exx
        ld h,chmap/256 + 1
c2p_sub
        ld (c2psp),sp
        ld b,chmhgt/2
c2p_line0
        ld l,chmap&255
        ld sp,hl
        exx
        ld d,b
        ld e,c
        inc d

        inc bc
        
        dup 32
        pop hl
        ld a,(hl)
        ld (de),a
        inc l
        inc d
        ld a,(hl)
        ld (de),a
        inc h
        inc d
        ldd ;dec l ;dec e ; dec c
        ld a,(hl)
        ld (bc),a ;line0
        dec d
        dec d
        edup
        org $-2
        
        ld a,c
        add a,31+32
        ld c,a
        jp nc,$+7
        ld a,b
        add a,8
        ld b,a
        
        exx
        inc h
        inc h
        dec b
        jp nz,c2p_line0
c2psp=$+1
        ld sp,0
        ret

