Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org #8000
- install:
- ld sp,$
- ld hl,(#5c36) ; get system font address
- ld (setFontAddress+1),hl
- ld hl,#5800
- ld de,#5801
- ld bc,#FF
- ld (hl),#05
- ldir
- ld hl,#4000
- ld de,#AA55
- fillTopThird:
- ld (hl),e
- bit 0,h
- jr z,ftt
- ld (hl),d
- ftt:
- inc hl
- ld a,h
- cp #48
- jr c,fillTopThird
- mainLoop:
- ei
- halt
- call printChar
- call move
- jr mainLoop
- ;-----------------------------------------
- printChar:
- ld hl,text
- ld de,#583f ; start print attribute address
- ld (attrAddr),de
- ld a,(letterBit)
- ld e,a ; current bit of letter to register E
- ld a,(hl) ; get char from text
- or a
- jr nz,useChar
- ; if A == 0 > restore start address of text
- ld hl,text
- ld (printChar+1),hl
- ld a,(hl) ; get char from text
- useChar:
- push hl ; save HL
- call charAddress
- inc hl ; second byte of char
- ld b,6 ; height of char
- charLoop:
- push bc
- push hl ; save HL
- ld a,(bgColor)
- ld d,a ; D > background color
- ld a,(hl)
- and e ; check char bit
- jr z,drawLed ; bit is set
- ; bit is reset
- ld a,(ledColor)
- ld d,a ; D > letter color
- drawLed:
- ld hl,(attrAddr); get current attribute address
- ld (hl),d ; set attribute color
- ld bc,32
- add hl,bc ; down attribute address
- ld (attrAddr),hl; save new attribute address
- pop hl ; restore HL
- inc hl ; next char byte (or use inc hl if font address != low byte / 8)
- pop bc
- djnz charLoop ; loop next char byte
- pop HL ; restore HL
- ld a,e ; get char bit
- rrca ; rotate to next bit
- ld (letterBit),a; save new bit
- ret nc ; exit if char bit is not full rotate
- ; char bit back to #80
- inc hl ; next char of text
- ld (printChar+1),hl ;save next text letter address
- ret
- ;-----------------------------------------
- move:
- ld hl,#5822
- ld b,6
- ; move six attribute lines
- moveLoop:
- push bc
- push hl
- pop de
- dec e
- dup 31
- ldi ; repeat 'LDI' 31 time
- edup
- inc hl
- pop bc
- djnz moveLoop
- ret
- ;-----------------------------------------
- charAddress:
- ; calc address of char in font
- ld l,a
- ld h,0
- add hl,hl
- add hl,hl
- add hl,hl
- setFontAddress:
- ld bc,#0000 ; font addr - 256
- add hl,bc ; hl=char address in font
- ret
- ;-----------------------------------------
- /*
- bits #80#40#20#10#08#04#02#01
- letter A
- 0 0 0 0 0 0 0 0
- 0 0 A A A A 0 0
- 0 A 0 0 0 0 A 0
- 0 A 0 0 0 0 A 0
- 0 A A A A A A 0
- 0 A 0 0 0 0 A 0
- 0 A 0 0 0 0 A 0
- 0 0 0 0 0 0 0 0
- */
- letterBit: db #80 ; bit of current letter
- ledColor: db #06 ; chars color
- bgColor: db #01 ; background color
- attrAddr: dw #581f ; start print attribute address
- text: db "+++ Hello ZX world +++ LED SCROLL for Chris Flynn. "
- db 0 ; end of text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement