Post Sat Jan 17, 2015 9:46 pm

RND attributes in "paint" ASM program?

Hi, i've succesfully tested the paint program taken here: ... .bas#Paint

It uses five variables (x,y,width,height and attribute) to instantly colour a specified screen area.

I've minimized the asm code to just one variable (the attribute), setting x,y,width,height as fixed values (don't need to set them at every call), this way:

SUB paint (attribute AS UBYTE)
    ld      a,1        ;ypos
    rrca               ; Multiply by 32
    ld      l,a        ; Pass TO L
    AND     3          ; Mask with 00000011
    add     a,88       ; 88 * 256 = 22528 - start of attributes.
    ld      h,a        ; Put it in the High BYTE
    ld      a,l        ; We get y value *32
    AND     224        ; Mask with 11100000
    ld      l,a        ; Put it in L
    ld      a,8        ; xpos
    add     a,l        ; Add it TO the Low BYTE
    ld      l,a        ; Put it back in L, AND we're done. HL=Address.
    push HL            ; SAVE address
    LD A,(IX+5)        ; attribute
    LD DE,32
    LD c,22            ; height
    LD b,4             ; width
    LD (HL),a          ; paint a character
    INC L              ; Move TO the right
    DJNZ BLPaintWidthLoop
    POP HL             ; recover our left edge
    DEC C
    JR Z, BLPaintHeightExitLoop
    ADD HL,DE          ; move 32 down
    PUSH HL            ; SAVE it again
    JP BLPaintHeightLoop

paint (65+INT(RND*3))

As you can see, the last command is the function call, and the colour is RANDOM ("65+INT(RND*3)" means from bright-blue to bright-magenta).
All perfect but... can i set the same RND colour range to each single character, rather than to the whole area?