I wrote a little routine to put random attributes around the border of the screen. Later I'm going to rotate the attributes.
I would like the random number to be between 0 and 63 to avoid the flashing and bright attributes. I thought adding an
Code: Select all
and 63
Many thanks
Code: Select all
org $6000
main
call clsscr
call text
ld hl,22528 ;start of attribute memory
ld de,32 ;used to jump up and down rows on left and right
ld b,31 ;counter for columns
top ;fill the top row
push hl
call random
and 63
pop hl
ld (hl),a
inc hl
djnz top
ld b,23
right ;fill the right hand side
push hl
call random
and 63
pop hl
ld (hl),a
add hl,de
djnz right
ld b,31
bottom ;fill the bottom
push hl
call random
and 63
pop hl
ld (hl),a
dec hl
djnz bottom
ld b,23
left ;fill the left
push hl
call random
and 63
pop hl
ld (hl),a
sbc hl,de
djnz left
waitkey ;From JC Book - Thanks!
ld hl,23560
ld (hl),0
wait
ld a,(hl)
cp 0
jr z,wait
ret
random ; From JC Book - Thanks!
ld hl,(seed) ; Pointer
ld a,h
and 31 ; keep it within first 8k of ROM.
ld h,a
ld a,(hl) ; Get "random" number from location.
inc hl ; Increment pointer.
ld (seed),hl
ret
seed defw 0
clsscr ;Thanks to seven-fff
xor a
ld hl,22528
ld de,22528 +1
ld bc,768-1
ld (hl),a
ldir
ret
text ;Thanks to seven-fff for the idea & JC for the code
ld a,2 ; upper screen
call 5633 ; open channel
ld de,string ; address of string
ld bc,eostr-string ; length of string to print
call 8252 ; print our string
ret
string defb 22,1,0,32,22,7,6,17,0,19,1,16,2,83,16,6,80,16,5,69,16,3,67,16,7,84,16,4,82,16,2,85,16,6,77,16,0,32
defb 16,5,67,16,3,79,16,7,77,16,4,80,16,2,85,16,6,84,16,5,73,16,3,78,16,7,71
eostr equ $
END $6000