Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BritLion's Putchars
#12
Waiting for something better ...
In 10-06-10 I modified this routine because Britlion suggest that atributtes are readed better per files instead of per columns, as the cathodic ray bright the pixels in the tv(I say first all the chars of file 0, all chars file 1, ...)for see this uncomment the pause demo besides setattr commands
Code:
'===========================
'= putchat britlion        =
'===========================
'thx2Boriel idea using setattr
'modified by compiuter
'version 2.100609 <-date
#include <attr.bas>
'===========================================
SUB putChars(x as uByte,y as uByte,height as uByte,width as uByte,dataAddress as uInteger)
DIM columns as uByte

REM Let's put our variables into our code:
POKE @BLPutCharWidth+1,width
POKE @BLPutCharHeight+1,height
POKE @BLPutCharX+1, x
POKE @BLPutCharY+1, y
POKE uInteger @BLPutCharData+1,dataAddress

asm
call BLPutChar
end asm
return

BLPutCharX:
asm
BLPutChar:
         LD      a,1
         AND     31
         ld      l,a
end asm
BLPutCharY:
asm
         ld      a,2 ; 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

PUSH HL ; save our address.

end asm
BLPutCharData:
asm
LD DE,16384 ; Marker - This will be poked for the data address by the subroutine


end asm
BLPutCharWidth:
asm
LD B,3 ; Marker - this will be poked for the width
PUSH BC ; save our column count.

BLPutCharColumnLoop:

end asm
BLPutCharHeight:
asm
LD B,1 ; Marker - this will be poked for the height by the subroutine.

BLPutCharInColumnLoop:
call BLPutBytes
DEC B
JR Z,BLPutCharNextColumn
;The following code calculates the address of the next line down below current HL address.
PUSH DE ; save DE
         ld   a,l  
         and  224  
         cp   224  
         jp   z,BLPutCharSameThird

BLPutCharNextThird:
         ld   de,-1760      
         ;and  a        
         add  hl,de      
         POP DE ; get our data point back.
         jp BLPutCharInColumnLoop

BLPutCharSameThird:
         ld   de,32      
         ;and  a
         add  hl,de  
         POP DE ; get our data point back.            

JP BLPutCharInColumnLoop

BLPutCharNextColumn:
POP BC
POP HL
DEC B
RET Z

INC HL
PUSH HL
PUSH BC
JP BLPutCharColumnLoop
end asm

asm
BLPutBytes:
; gets screen address in HL, and bytes address in DE. Copies the 8 bytes to the screen.
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
INC H
ld a,(DE)
LD (HL),a
INC DE
ret
end asm
END SUB
'=====================================
'### version atr x files #############
'#####################################
SUB putCharsAtr(x as uByte,y as uByte,height as uByte,width as uByte,Atr as Ubyte)
dim f,n as ubyte
  for g=0 to height-1
   for f=0 to width-1
    setattr(y+g,x+f,Atr) 'for demo pause(10)
   next
  next
END SUB
'#####################################
'### version atr x columns ###########
' SUB putCharsAtr(x as uByte,y as uByte,height as uByte,width as uByte,Atr as Ubyte)
'  dim f,g as ubyte
'   for g=0 to width-1
'    for f=0 to height-1
'     setattr(y+f,x+g,Atr) 'for demo pause(10)
'     pause(10)
'    next
'   next
' END SUB
'#####################################
'=====================================
SUB putChAt(x as uByte,y as uByte,height as uByte,width as uByte,dataAddress as uInteger,Atr as Ubyte)
putChars(x,y,height,width,dataAddress)
putCharsAtr(x,y,height,width,Atr)
END SUB
'=====================================
start:
cls
dim f as ubyte
for f=1 to 19 step 4
putChAt(0+f,0,2,3,@gfx1a,11110011b)
putChAt(0+f,2+f,3,9,@gfx1a,11100010b)
putChAt(0+f,18,3,2,@gfx1a,11000110b)
next
END
'----------------------------------------
gfx1a:
ASM
DEFB 8,8,8,8,8,8,8,8
DEFB 0,60,4,4,60,32,60,0
DEFB 0,60,4,4,60,4,60,0
DEFB 0,36,36,36,60,4,4,0
datapoint:
defb 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32
defb 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64
end asm
'-----------------------------------------
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)