 ORG 100h
;320x256

 di
 in a,(84h)
 res 0,a
 res 2,a
 res 1,a;pixels
 out (84h),a

; ld hl,8000h
; ld de,8001h
; ld bc,27FFh
; ld (hl),l
; ldir

 ld hl,8000h
 ld de,255
lp0:
 ld c,32
lp2:
 push hl
 ld b,10
 push de
LP1:
 call bswap
 in a,(84h)
 set 1,a
 out (84h),a; 1-color,0-pixel
 push hl
 ld a,l
 bit 3,a
 jr z,noi
 cpl
noi:
 and 7
; sra a
 ;or 64
 push bc
 ld b,40
fl:
 ld (hl),a
 inc h
 djnz fl
 pop bc
 pop hl
 in a,(84h)
 res 1,a
 out (84h),a; 1-color,0-pixel

 ld (hl),e
 inc h
 ld (hl),e
 inc h
 ld (hl),e
 inc h
 ld (hl),e
 inc h
 djnz LP1
 pop de
 ;call bswap
 pop hl
 inc l
 dec c
 jr nz,lp2
 call bswap
 inc l
 dec l
 jr nz,lp0
;;;;;;;;;;;;;;draw;;;;;;;;;;;;;;


i0:
 dec l
 ld a,l
 and 31
 ld l,a
 push hl

;;delay
 ld c,10
dl1:
 ld b,15
dl2:
 nop
 nop
 nop
 nop
 nop
 djnz dl2
 dec c
 jr nz,dl1
;;

i2:
 push hl
 ld b,40
i1:
 ld a,(hl)
 cpl
 ld (hl),a
 inc h
 djnz i1
 pop hl
 ld a,l
 add a,32
 ld l,a
 jp nc,i2

 pop hl
 jp i0

bswap:
 ld a,e
 ld e,d
 ld d,a
 ret