Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Fade Screen to Black
- ; Improvement would be to handle bright and flash attributes as well
- ; BASIC Test code
- ; 1 bright 1: flash 1: ink 6: paper 3: cls: print "a"
- ORG 0x8000
- ; Start of attribute memory
- SCREEN = 0x4000
- ; 24 rows, 32 columns
- ; 8 x 8 characters
- ; 24 * 8 = bytes per row = 192
- ; 192 * 32 = 614
- ; 24 * 32 = 768 attributes
- ATTRIBUTES_COUNT = 0x300
- ;ATTRIBUTES = (SCREEN + ATTRIBUTES_COUNT)
- ATTRIBUTES = 0x5800
- INK = %00000111
- PAPER = %00111000
- LD D, 7; Maximum of 7 subtractions to get to black
- MAIN_LOOP
- LD HL, ATTRIBUTES
- LD BC, ATTRIBUTES_COUNT
- ; Decrement attribute colours
- ATTR_LOOP
- LD A,0x80
- PAUSE
- DEC A
- JR NZ, PAUSE
- LD A, (HL)
- EXX
- LD D, A
- LD E, A
- AND INK
- JR Z, IS_ZERO_INK
- DEC A
- IS_ZERO_INK
- LD E, A
- LD A, D
- AND PAPER
- JR Z, IS_ZERO_PAPER
- DEC A
- IS_ZERO_PAPER
- AND PAPER
- OR E
- EXX
- LD (HL), A
- INC HL
- ; End Decrement attribute colours
- ; If BC != 0 loop
- DEC BC
- XOR A
- OR B
- JR NZ, ATTR_LOOP
- XOR A
- OR C
- JR NZ, ATTR_LOOP
- ; If D == 0 return
- DEC D
- XOR A
- OR D
- JR NZ, MAIN_LOOP
- RET
Advertisement
Add Comment
Please, Sign In to add comment