Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scrolling Tiles
#4
oh ok thanks

I havent checked this out with 03 yet, i wonder if its faster

I put the bricks on the bottom of the screen and colored them,
and put a few GOTO's in there to make it more efficient.
If there are any other optimizations feel free to share
Code:
'#include<mj/fourspriter.bas>
DIM mapdata(63) AS UBYTE => {1,0,1,1,1,1,1,1,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,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}
INK 2
PAPER 0

'MJfspActivateSprite(1)
'MJfspSetGfxAddress (@brick)
'MJfspSetGfxSprite (1,1,2,3,4)

'MJfspInitSprites ()
'MJfspMoveSprite (1,1,1)
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
for y=0 to 23
Print AT y,x;" "
next
next


Dim startaddress as UInteger

ASM

LD HL,(__LABEL__adr)

LD A,2
SLA A
SLA A
SLA A

OR H
LD H,A

LD A,7
SLA A
SLA A
SLA A
SLA A
SLA A

OR L
LD L,A

LD (__LABEL__adr),HL
END ASM

Print AT 1,0;STR(PEEK(UINTEGER,@adr))

for iterations=0 to 480 'scroll left 480 times
address=PEEK(UInteger,@adr)


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

POKE address,CurrentGraphic

if x=31

if mapdata(LandscapeIter)=1
NextGraphic=brick(LineNumber)
GOTO 50
end if

if mapdata(LandscapeIter)=2
NextGraphic=crystal(LineNumber)
GOTO 50
end if

if mapdata(LandscapeIter)=0
NextGraphic=0

end if


50

if LandscapeEightIter=0
if NextGraphic Band 1
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=1
if NextGraphic Band 2
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=2
if NextGraphic Band 4
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=3
if NextGraphic Band 8=8
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=4
if NextGraphic Band 16
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=5
if NextGraphic Band 32
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=6
if NextGraphic Band 64
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if

if LandscapeEightIter=7
if NextGraphic Band 128
CurrentGraphic=CurrentGraphic BOR 1
GOTO 100
end if
end if


100 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


'MJfspUpdateSprites()
next



'Print "done"
'Print STR(178 Band 128)
STOP
adr:
ASM
defw 16384
END ASM
poker:
ASM
defb 0
END ASM
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)