The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BritLion's Putchars
#2
LCD, you wanted fast screen handling?

I tested your routine against mine. And against PRINT.

Perhaps I did something wrong, but according to my tests "PRINT AT" is faster than your routine...

(obviously, you are including attributes, and I'm not; yet.)


Code:
10,000 loop test: PRINT AT 10,10;"A" 289 Frames PRINT AT 10,10;"AA" 473 Frames PRINT AT 10,10;"A";AT 11,10;"A" 526 Frames PRINT AT 10,10;"AA";AT 11,10;"AA" 896 Frames BL Putchars - 1X1 163 frames 2x1 211 frames 1x2 211 Frames 2X2 301 Frames 3X3 534 Frames 4X4 853 Frames 8X8 3074 Frames BL's PutTile 2X2 276 Frames* - Best estimate. This can't be frame timed *See other thread for this code. May make it into the wiki library. LCD's 1X1 346 Frames 1X2 658 Frames 2X1 658 Frames 2X2 1294 Frames


For repeating the tests, here's the whole code I used:

EDIT: This code is bugged. My bugfixed version is above!

Code:
'=========================== '= putchar lcd compiuter = '= version 1.100603 <-date = '=========================== '#include <sinclair.bas> '#include <memcopy.bas> '#include <keys.bas> '#include <print42.bas> '#include <attr.bas> '--- 'cls 'border 5 '------------------------------------- sub putcharLcd1x1(x as Uinteger,y as Uinteger,adr as Uinteger) dim scr as Uinteger dim a as Uinteger a=peek(@linebuffer+y) scr=(a<<5)+x+16384 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 22528+x+(y<<5),peek (adr+8) End sub '------------------------------------------- sub putcharLcd1x2(x as Uinteger,y as Uinteger,adr as Uinteger) dim scr as Uinteger dim a as Uinteger a=peek(@linebuffer+y) scr=(a<<5)+x+16384 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 22528+x+(y<<5),peek (adr+8) x=x+1 a=peek(@linebuffer+y) scr=(a<<5)+x+16384 poke ubyte scr,peek(adr+9) poke ubyte scr+256,peek(adr+10) poke ubyte scr+512,peek(adr+11) poke ubyte scr+768,peek(adr+12) poke ubyte scr+1024,peek(adr+13) poke ubyte scr+1280,peek(adr+14) poke ubyte scr+1536,peek(adr+15) poke ubyte scr+1792,peek(adr+16) poke ubyte 22528+x+(y<<5),peek (adr+17) End sub '------------------------------------------- sub putcharLcd2x1(x as Uinteger,y as Uinteger,adr as Uinteger) dim scr as Uinteger dim a as Uinteger a=peek(@linebuffer+y) scr=(a<<5)+x+16384 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 22528+x+(y<<5),peek (adr+8) y=y+1 a=peek(@linebuffer+y) scr=(a<<5)+x+16384 poke ubyte scr,peek(adr+9) poke ubyte scr+256,peek(adr+10) poke ubyte scr+512,peek(adr+11) poke ubyte scr+768,peek(adr+12) poke ubyte scr+1024,peek(adr+13) poke ubyte scr+1280,peek(adr+14) poke ubyte scr+1536,peek(adr+15) poke ubyte scr+1792,peek(adr+16) poke ubyte 22528+x+(y<<5),peek (adr+17) End sub '------------------------------------------- sub putcharLcd2x2(x as Uinteger,y as Uinteger,adr as Uinteger) dim scr as Uinteger dim a as Uinteger a=peek(@linebuffer+y) scr=(a<<5)+x+16384 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 22528+x+(y<<5),peek (adr+8) x=x+1 a=peek(@linebuffer+y) scr=(a<<5)+x+16384 poke ubyte scr,peek(adr+9) poke ubyte scr+256,peek(adr+10) poke ubyte scr+512,peek(adr+11) poke ubyte scr+768,peek(adr+12) poke ubyte scr+1024,peek(adr+13) poke ubyte scr+1280,peek(adr+14) poke ubyte scr+1536,peek(adr+15) poke ubyte scr+1792,peek(adr+16) poke ubyte 22528+x+(y<<5),peek (adr+17) x=x-1 y=y+1 a=peek(@linebuffer+y) scr=(a<<5)+x+16384 poke ubyte scr,peek(adr+18) poke ubyte scr+256,peek(adr+19) poke ubyte scr+512,peek(adr+20) poke ubyte scr+768,peek(adr+21) poke ubyte scr+1024,peek(adr+22) poke ubyte scr+1280,peek(adr+23) poke ubyte scr+1536,peek(adr+24) poke ubyte scr+1792,peek(adr+25) poke ubyte 22528+x+(y<<5),peek (adr+26) x=x+1 a=peek(@linebuffer+y) scr=(a<<5)+x+16384 poke ubyte scr,peek(adr+27) poke ubyte scr+256,peek(adr+28) poke ubyte scr+512,peek(adr+29) poke ubyte scr+768,peek(adr+30) poke ubyte scr+1024,peek(adr+31) poke ubyte scr+1280,peek(adr+32) poke ubyte scr+1536,peek(adr+33) poke ubyte scr+1792,peek(adr+34) poke ubyte 22528+x+(y<<5),peek (adr+35) End sub '---next will be probably putcharlcd1x3 '--- goto start linebuffer: asm defb 0,1,2,3,4,5,6,7,64,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135 end asm '-------------------------- 'start: '---fin--- END '---------------------------------------- 'gfx1a: 'ASM 'DEFB 0,8,8,8,8,8,8,0,00010001B 'DEFB 0,60,4,4,60,32,60,0,00011001B 'DEFB 0,60,4,4,60,4,60,0,00100001B 'DEFB 0,36,36,36,60,4,4,0,00101001B 'END ASM '----------------------------------------- FUNCTION t() as uLong asm LD DE,(23674) LD D,0 LD HL,(23672) end asm end function 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 POP DE ; get our data point back. add hl,de 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 goto start datapoint: asm 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 defb 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96 defb 97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128 end asm start: cls DIM time as uLong DIM i as uInteger time=t() for i=1 to 10000 'putChars(10,10,1,1,@datapoint) : REM Uncomment these lines as you need them. 'print at 10,10;"AA"; AT 11,10;"AA" 'putcharLcd1x1(10,10,@datapoint) 'putcharLcd1x2(10,10,@datapoint) 'putcharLcd2x1(10,10,@datapoint) putcharLcd2x2(10,10,@datapoint) next i print t()-time
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)