06-03-2010, 09:19 PM
Try this... Attribute is now handed over in sub header
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 putchar(x as Ubyte,y as Ubyte,attribute as ubyte,adr as Uinteger)
dim scr as uinteger
dim attradr as uinteger
scr=scrAddress(x,y)
attradr=attrAddress(x,y)
poke ubyte scr,peek(adr)
poke ubyte scr+256,peek(adr+1)
poke ubyte scr+512,peek(adr+2)
poke ubyte scr+768,peek(adr+3)
poke ubyte scr+1024,peek(adr+4)
poke ubyte scr+1280,peek(adr+5)
poke ubyte scr+1536,peek(adr+6)
poke ubyte scr+1792,peek(adr+7)
poke ubyte attradr,attribute
End sub
dim x,y,atr as ubyte
dim adr as Uinteger
adr=32768
poke 32768,%00000000
poke 32769,%01111110
poke 32770,%01000010
poke 32771,%01010010
poke 32772,%01001010
poke 32773,%01000010
poke 32774,%01111110
poke 32775,%00000000
atr=0
for y=0 to 23
for x=0 to 31
putchar(x,y,atr,adr)
atr=atr+1
next x
next y
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!