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
Scrolling Tiles
#1
I managed to get it done using ZXBASIC
Code:
DIM mapdata(31) AS UBYTE => {1,0,2,0,2,1,1,2,1,0,2,0,2,1,1,2,1,0,2,0,2,1,1,2,1,0,2,0,2,1,1,2} DIM brick(7) AS UBYTE =>{249,249,0,159,159,0,249,249} DIM crystal(7) AS UBYTE =>{16,40,84,40,84,40,16,0} Dim CurrentGraphic as ubyte=1 Dim NextGraphic as Ubyte Dim PreviousGraphic as ubyte Dim address as UInteger Dim LineStartAddress as UInteger addr=16384 LineStartAddress=addr Dim PreviousAddress as UInteger Dim LandscapeEightIter as Ubyte Dim LandscapeIter as ubyte Dim LineNumber as UByte for x=0 to 31 Print AT 0,x;"[" next for iterations=0 to 258 'scroll left 258 times address=16384 for y=0 to 7 LineStartAddress=address for x=0 to 31 CurrentGraphic = PEEK(address) 'pause 5 if x>0 'the leftmost byte has no graphics to its left if CurrentGraphic Band 128=128 'if this graphic has a dot on the left PreviousGraphic=PreviousGraphic Bor 1 'Add a dot to the right of the previous graphic byte POKE PreviousAddress,PreviousGraphic end if end if PreviousAddress=address 'save the address of the byte on the left CurrentGraphic=CurrentGraphic SHL 1 'shift dors to left PreviousGraphic=CurrentGraphic 'save graphic if x<31 POKE address,CurrentGraphic end if if x=31 if mapdata(LandscapeIter)=1 NextGraphic=brick(LineNumber) end if if mapdata(LandscapeIter)=2 NextGraphic=crystal(LineNumber) end if if mapdata(LandscapeIter)=0 NextGraphic=0 end if if LandscapeEightIter=0 if NextGraphic Band 1=1 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=1 if NextGraphic Band 2=2 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=2 if NextGraphic Band 4=4 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=3 if NextGraphic Band 8=8 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=4 if NextGraphic Band 16=16 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=5 if NextGraphic Band 32=32 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=6 if NextGraphic Band 64=64 CurrentGraphic=CurrentGraphic BOR 1 end if end if if LandscapeEightIter=7 if NextGraphic Band 128=128 CurrentGraphic=CurrentGraphic BOR 1 end if end if POKE address,CurrentGraphic end if address=address+1 'move one square right next address=LineStartAddress address=address+256 'move one line down LineNumber=LineNumber+1 next LineNumber=0 LandscapeEightIter=LandscapeEightIter+1 if LandscapeEightIter=8 LandscapeEightIter=0 LandscapeIter=LandscapeIter+1 end if next Print "done" Print STR(178 Band 128) STOP

but I could never get it done using assembly:
Code:
function FASTCALL drawthis() as ubyte asm ;LD HL,2000 ;LD (delayiter),HL LD HL,16384 ;drawvert: ;LD A,31 ;LD L,A ;LD (screenwidthiter),A ;drawblokes: ;LD A,(graphic) ;DEC A ;LD (graphic),A ;LD (HL),A ;LD A,(screenwidthiter) ;LD L,A ;DEC A ;LD (screenwidthiter),A ;LD B,A ;INC B ;INC B ;INC B ;djnz drawblokes ;LD A,(screenheightiter) ;LD L,A ;INC H ;DEC A ;LD (screenheightiter),A ;LD B,A ;INC B ;djnz drawvert LD A,31 LD (screenwidthiter),A LD A,7 LD (screenheightiter),A LD HL,60000 LD (delayiter),HL loop: LD BC,20000 LD A,7 LD (screenheightiter),A LD HL,16384 LD (screenaddress),HL screenvert: ;LD BC,6000 ;wait: ;DEC BC ;LD A,B ;Or C ;jp nz,wait LD (screenaddress),HL ;load landscape number into a LD HL,data LD BC,(landscapeiter) ADD HL,BC LD A,(HL) LD (__LABEL__printablevar),A ;load graphic into B CP 0 jp z,thisisempty CP 1 jp z,thisisbrick CP 2 jp z,thisiscrystal jp thisisbrick thisisempty: LD B,0 jp donegraphic thisisbrick: LD HL,brick LD DE,(screenheightiter) ADD HL,DE LD B,(HL) jp donegraphic thisiscrystal: LD HL,crystal LD DE,(screenheightiter) ADD HL,DE LD B,(HL) jp donegraphic donegraphic: LD A,0 LD (rightbit),A LD A,(landscapeiter) CP 0 jp z,bit0 CP 1 jp z,bit1 CP 2 jp z,bit2 CP 3 jp z,bit3 CP 4 jp z,bit4 CP 5 jp z,bit5 CP 6 jp z,bit6 CP 7 jp z,bit7 bit0: BIT 0,B jp nz,setbitfirst jp z,dontsetbitfirst bit1: BIT 1,B jp nz,setbitfirst jp z,dontsetbitfirst bit2: BIT 2,B jp nz,setbitfirst jp z,dontsetbitfirst bit3: BIT 3,B jp nz,setbitfirst jp z,dontsetbitfirst bit4: BIT 4,B jp nz,setbitfirst jp z,dontsetbitfirst bit5: BIT 5,B jp nz,setbitfirst jp z,dontsetbitfirst bit6: BIT 6,B jp nz,setbitfirst jp z,dontsetbitfirst bit7: BIT 7,B jp z,dontsetbitfirst jp nz,setbitfirst setbitfirst: LD A,1 LD (rightbit),A dontsetbitfirst: LD HL,(screenaddress) LD A,31 LD L,A LD (screenwidthiter),A LD (screenaddress),HL LD A,0 LD (leftbit),A BIT 7,(HL) jp nz,dontsetbit LD A,1 LD (leftbit),A dontsetbit: LD A,(HL) SLA A LD (HL),A LD A,(rightbit) CP 0 jp z, dontsetrightbit LD A,(HL) OR 1 LD (HL),A dontsetrightbit: LD A,(leftbit) LD (rightbit),A LD A,30 LD (screenwidthiter),A LD L,A LD (screenaddress),HL screenhori: LD A,0 LD (leftbit),A BIT 7,(HL) jp nz,dontsetbit3 LD A,1 LD (leftbit),A dontsetbit3: LD B,(HL) SLA B LD A,(rightbit) CP 0 jp nz,dontsetblockbit2 LD A,B OR 1 LD B,A dontsetblockbit2: LD (HL),B LD A,(screenwidthiter) LD L,A DEC A LD (screenwidthiter),A LD A,(leftbit) LD (rightbit),A LD A,(screenwidthiter) CP 0 jp nz,screenhori LD A,(screenheightiter) INC H DEC A LD (screenaddress),HL LD (screenheightiter),A CP 0 jp nz,screenvert LD A,(__LABEL__landscapeeightiter) INC A LD (__LABEL__landscapeeightiter),A LD A,(__LABEL__landscapeeightiter) CP 8 jp nz,dontresetblock LD A,0 LD (__LABEL__landscapeeightiter),A LD A,(landscapeiter) INC A LD (landscapeiter),A dontresetblock: ;jp loop end asm end function Dim x as Integer for x=0 to 31 Print AT 0,x;STR(x) next for x=0 to 30 drawthis() Print AT x,0;STR(PEEK(@printablevar))+"-" next Print "done" STOP: printablevar: ASM defb 255 END ASM landscapeeightiter: ASM defb 0 blockiter: defw 8 delayiter: defw 60000 screenwidthiter: defb 31 screenheightiter: defb 8 scrolliter: defw 10000 graphic: defb 255 screenaddress: defw 0 landscapeiter: defb 0 data: defb 1,1,0,1,1,1,0,1,1,2,2,2,2,0,1,0,1,0,2,2,2,2 brick: defb 249,249,0,159,159,0,249,249 crystal: defb 16,40,84,40,84,40,16,0 rightbit: defb 0 leftbit: defb 0 DISPNUM: call 11563 ; We'll push the BC register onto the calculator stack call 11747 ; and then output that number to the screen by calling this routine ret end asm
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)