vito-Z80

attribute scroll

Nov 25th, 2020
618
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     org #8000
  3. install:
  4.     ld sp,$
  5.     ld hl,(#5c36)   ; get system font address
  6.     ld (setFontAddress+1),hl
  7.     ld hl,#5800
  8.     ld de,#5801
  9.     ld bc,#FF
  10.     ld (hl),#05
  11.     ldir
  12.     ld hl,#4000
  13.     ld de,#AA55
  14. fillTopThird:
  15.     ld (hl),e
  16.     bit 0,h
  17.     jr z,ftt
  18.     ld (hl),d
  19. ftt:
  20.     inc hl
  21.     ld a,h
  22.     cp #48
  23.     jr c,fillTopThird
  24. mainLoop:
  25.     ei
  26.     halt
  27.     call printChar
  28.     call move
  29.         jr mainLoop
  30. ;-----------------------------------------
  31. printChar:
  32.     ld hl,text
  33.     ld de,#583f ; start print attribute address
  34.     ld (attrAddr),de
  35.     ld a,(letterBit)
  36.     ld e,a      ; current bit of letter to register E
  37.     ld a,(hl)   ; get char from text
  38.     or a
  39.     jr nz,useChar
  40.     ; if A == 0 > restore start address of text
  41.     ld hl,text
  42.     ld (printChar+1),hl
  43.     ld a,(hl)   ; get char from text
  44. useChar:
  45.     push hl     ; save HL
  46.     call charAddress
  47.     inc hl      ; second byte of char
  48.     ld b,6      ; height of char
  49. charLoop:
  50.     push bc
  51.     push hl     ; save HL
  52.     ld a,(bgColor)
  53.     ld d,a      ; D > background color
  54.     ld a,(hl)
  55.     and e       ; check char bit
  56.     jr z,drawLed        ; bit is set
  57.     ; bit is reset
  58.     ld a,(ledColor)
  59.     ld d,a      ; D > letter color
  60. drawLed:
  61.     ld hl,(attrAddr); get current attribute address
  62.     ld (hl),d   ; set attribute color
  63.     ld bc,32
  64.     add hl,bc   ; down attribute address
  65.     ld (attrAddr),hl; save new attribute address
  66.     pop hl      ; restore HL
  67.     inc hl      ; next char byte (or use inc hl if font address != low byte / 8)
  68.     pop bc
  69.     djnz charLoop   ; loop next char byte
  70.     pop HL      ; restore HL
  71.     ld a,e      ; get char bit
  72.     rrca        ; rotate to next bit
  73.     ld (letterBit),a; save new bit
  74.     ret nc      ; exit if char bit is not full rotate
  75.     ; char bit back to #80
  76.     inc hl      ; next char of text
  77.     ld (printChar+1),hl ;save next text letter address
  78.     ret
  79. ;-----------------------------------------
  80. move:
  81.     ld hl,#5822
  82.     ld b,6
  83.     ; move six attribute lines
  84. moveLoop:
  85.     push bc
  86.     push hl
  87.     pop de
  88.     dec e
  89.     dup 31
  90.     ldi ;   repeat 'LDI' 31 time
  91.     edup
  92.     inc hl
  93.     pop bc
  94.     djnz moveLoop
  95.     ret
  96. ;-----------------------------------------
  97. charAddress:
  98.         ; calc address of char in font
  99.         ld l,a
  100.         ld h,0    
  101.         add hl,hl
  102.         add hl,hl
  103.         add hl,hl
  104. setFontAddress:
  105.         ld bc,#0000 ; font addr - 256
  106.         add hl,bc       ; hl=char address in font
  107.         ret
  108. ;-----------------------------------------
  109.  
  110. /*
  111. bits    #80#40#20#10#08#04#02#01
  112. letter A
  113.     0  0  0  0  0  0  0  0
  114.     0  0  A  A  A  A  0  0
  115.     0  A  0  0  0  0  A  0
  116.     0  A  0  0  0  0  A  0
  117.     0  A  A  A  A  A  A  0
  118.     0  A  0  0  0  0  A  0
  119.     0  A  0  0  0  0  A  0
  120.     0  0  0  0  0  0  0  0
  121. */
  122. letterBit:  db #80      ; bit of current letter
  123. ledColor:   db #06      ; chars color
  124. bgColor:    db #01      ; background color
  125. attrAddr:   dw #581f    ; start print attribute address
  126. text:       db "+++ Hello ZX world +++     LED SCROLL for Chris Flynn.       "
  127.         db 0        ; end of text
RAW Paste Data