Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BritLion's Putchars
#14
britlion Wrote:What do you actually need it to do? I suspect you have some issue with attributes; but LCD hasn't mentioned what he wanted on that front either; so I'm a bit stuck for what additions or changes to make. If any.

For 2x2 char I'm happy with your version BritLion as it is extremly fast. For 1x1 char I prefer to have two versions: One where you read 9 bytes inclusive chars, and one with 8 bytes, where the attribute byte is handed over in SUB call (PutChar(x,y,@adress,attribute))

Oh, I have a nice one for bigger blocks:
Code:
FUNCTION scrAddress(x as uByte, y as uByte) as Uinteger
asm
;' This fn returns the address into HL of the screen address
;' x,y in character grid notation.
;' Original code was extracted by BloodBaz - Adapted for ZX BASiC by Britlion from Na_TH_AN's fourspriter

         ; x Arrives in A, y is in stack.
         and     31
         ld      l,a
         ld      a,(IX+7) ; Y value
         ld      d,a
         and     24
         add     a,64
         ld      h,a
         ld      a,d
         and     7
         rrca
         rrca
         rrca
         or      l
         ld      l,a
              
end asm
END FUNCTION
FUNCTION attrAddress(x as uByte, y as uByte) as uInteger              
';; This function returns the memory address of the Character Position
';; x,y in the attribute screen memory.
';; Adapted from code by Jonathan Cauldwell - Adapted for ZX BASiC by Britlion from Na_TH_AN's fourspriter

asm
         ld      a,(IX+7)        ;ypos
         rrca
         rrca
         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,(IX+5)   ; xpos
         add     a,l        ; Add it to the Low byte
         ld      l,a        ; Put it back in L, and we're done. HL=Address.

end asm

END FUNCTION
sub putblock(x as Ubyte,y as ubyte,wid as ubyte,hgt as ubyte,adr as Uinteger)
    dim scr,attribute as Uinteger
    dim x1,y1 as Ubyte
    dim a as Ubyte
    poke uinteger @putblock1+7,wid
    poke uinteger @putblock2+7,wid
    for y1=0 to hgt-1
        scr=scrAddress(x,y+y1)
        for a=0 to 7
            poke uinteger @putblock1+1,adr
            poke uinteger @putblock1+4,scr
            putblock1:
            asm
                ld hl,1
                ld de,2
                ld bc,3
                ldir
            end asm
            adr=adr+wid
            scr=scr+256
        next a
    next y1
    attribute=attrAddress(x,y)
    for y1=0 to hgt-1
        poke uinteger @putblock2+1,adr
        poke uinteger @putblock2+4,attribute
        adr=adr+wid
        attribute=attribute+32
        putblock2:
        asm
            ld hl,4
            ld de,5
            ld bc,6
            ldir
        end asm
    next y1
End sub
start:

putblock(0,18,8,6,0)
putblock(24,18,8,6,0)
putblock(24,0,8,6,0)

putblock(0,0,24,18,0)
pause 0

The speed is much better than the one I coded ten years ago.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)