Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Make this faster??
2007-09-26 17:00
cbmeeks

Registered: Oct 2005
Posts: 78
Make this faster??

I'm at work doing some paper coding (using a pen and paper) and was wondering if this snippet could be made faster.

What it does is grab the left side of a 2x2 char tile and blit it on the screen.

IE:

AB
CD

This would grab "AC" because my data is laid out like: "ACBD"


LDA #1     // tile number
ROL        // multiply by 4 to get the starting addr
TAX
LDA (TILES),X
STA SCREEN
INX         // get the next char
LDA (TILES),X
STA SCREEN + 40



Thanks for any tips!
cbmeeks

METROID
http://www.metroidclassic.com
2007-09-26 17:04
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quote: I'm at work doing some paper coding (using a pen and paper) and was wondering if this snippet could be made faster.

What it does is grab the left side of a 2x2 char tile and blit it on the screen.

IE:

AB
CD

This would grab "AC" because my data is laid out like: "ACBD"


LDA #1     // tile number
ROL        // multiply by 4 to get the starting addr
TAX
LDA (TILES),X
STA SCREEN
INX         // get the next char
LDA (TILES),X
STA SCREEN + 40



Thanks for any tips!
cbmeeks

METROID
http://www.metroidclassic.com


Why not simply store each of the for sub-tiles in a separate (byte-indexed) array?
For the most part you should prefer SoA (structure of arrays) layouts on the 6502.
2007-09-26 17:05
cadaver

Registered: Feb 2002
Posts: 1160
Drawing new stuff on edges of screen rarely needs to be super-optimized, because the screen-copy (shifting the screen data one char to whatever direction) still takes much much more time.

If you plan to scroll by always redrawing the whole screenful of blocks, it'll be too slow.

Of course you still need a redraw routine for the case when the game starts or the player teleports, but that doesn't need to be mega-optimal then, as doesn't happen every frame :)
2007-09-26 17:08
cbmeeks

Registered: Oct 2005
Posts: 78
Right now I am playing with data layout.

It is broken down like this:

World Map contains ROOMS.
Rooms contain tiles.
Tiles contain chars.

So the world map would be like:

R1R1R1R2
R2 R3

...

R1 would contain tiles:
01 02 01 01 03 ....

And each tile would contain chars:
01 -> AB
CD

etc..

As I am scrolling left, I will need to blit a new column containing the left side of the tile (AB).

I also want to optimize this for scrolling UP/DOWN by storing the tiles in ABCD.

Hope that makes sense. I am trying for the smallest number of cycles possible.

Unless I am just missing the big picture??

Thanks

METROID
http://www.metroidclassic.com
2007-09-26 17:08
Oswald

Registered: Apr 2002
Posts: 5094
- rol does only multiply with 2
- use 2 asl instead as rol will put the c bit into the least significant bit
- what cadaver and doynax said
2007-09-26 17:11
cbmeeks

Registered: Oct 2005
Posts: 78
Quote: - rol does only multiply with 2
- use 2 asl instead as rol will put the c bit into the least significant bit
- what cadaver and doynax said


Dur...oh yeah. lol

as far as not optimizing a single column, I guess that is a good point. I know the screen copy is going to be 99.9999% of the CPU hog when scrolling. That is why I was trying to have a great routine for drawing the tiles. Remember the tiles will be mixed and I will only ever be drawing a half-tile at any time.

METROID
http://www.metroidclassic.com
2007-09-26 17:15
Oswald

Registered: Apr 2002
Posts: 5094
optimizing your tile array layout will give you:

one tile:

tiletable1|tiletable2
----------+----------
tiletable3|tiletable4

code:

ldx tilenumber
lda tiletable1,x
sta wherever
lda tiletable2,x
sta wherever
lda tiletable3,x
sta wherever
lda tiletable4,x
sta wherever

some extremely good tutorials on game coding (go to rants):

http://cadaver.homeftp.net/

edit:

only one column from the tile at a time naturally:

ldx tilenumber
lda tiletable1,x
sta wherever
lda tiletable3,x
sta wherever
2007-09-26 17:29
cbmeeks

Registered: Oct 2005
Posts: 78
Quote: optimizing your tile array layout will give you:

one tile:

tiletable1|tiletable2
----------+----------
tiletable3|tiletable4

code:

ldx tilenumber
lda tiletable1,x
sta wherever
lda tiletable2,x
sta wherever
lda tiletable3,x
sta wherever
lda tiletable4,x
sta wherever

some extremely good tutorials on game coding (go to rants):

http://cadaver.homeftp.net/

edit:

only one column from the tile at a time naturally:

ldx tilenumber
lda tiletable1,x
sta wherever
lda tiletable3,x
sta wherever


Arg!! You see, that's why I asked. That is a simple, obvious idea but my feeble mind didn't think of it. Kinda like the Pet Rock. lol

Thanks!

I will draft something up in that fashion.


METROID
http://www.metroidclassic.com
2007-09-26 21:11
Fungus

Registered: Sep 2002
Posts: 686
lda tiletable,x
sta whereever
ora #$40
sta whereever
eor #$c0
sta whereever
ora #$40
sta whereever

etc...

2007-09-27 02:09
cbmeeks

Registered: Oct 2005
Posts: 78
Quote: <Post censored by CSDb staff>

lol.

Well, I'm the new kid in town so I will take Oswald's help with great appreciation. :-)

METROID
http://www.metroidclassic.com
2007-09-27 05:32
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: lol.

Well, I'm the new kid in town so I will take Oswald's help with great appreciation. :-)

METROID
http://www.metroidclassic.com


Just for the record: "Oswald is NOT crappy coder"...
2007-09-27 05:43
null
Account closed

Registered: Jun 2006
Posts: 645
During daytime, Oswald is just a simple 6510 programmer.. but on CSDb, he transforms into...:



:_D :_D :_D

------------------------------------
Knoeki/DigitalSoundsSystem/GheyMaidInc/SwappersWithAttitude
http://hardwarehacks.untergrund.net/zomgwtfbbq/index.php
2007-10-21 09:32
Richard

Registered: Dec 2001
Posts: 621
Lol, that picture still makes me laugh :)
2007-10-21 09:47
Conrad

Registered: Nov 2006
Posts: 849
2007-10-21 12:17
Richard

Registered: Dec 2001
Posts: 621
Nice one ;)
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
psych
Thierry
Raf/Vulture Design
Guests online: 137
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.051 sec.