English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. AMOS (https://eab.abime.net/forumdisplay.php?f=119)
-   -   double buffer and autoback tilemap answer issue (https://eab.abime.net/showthread.php?t=107944)

DiabloV 15 August 2021 16:13

double buffer and autoback tilemap answer issue
 
1 Attachment(s)
Hello
I create a map editor on AMOSPRO.
I coded everything myself, even the silder.

I use drawing instructions (box, bar, plot) for the sliders and grid, a bob for the arrow and a sprite for the map cursor.

I find it extremely slow

to display the map in a 34*34 plot it takes several seconds.

I have tried double buffering, autoback, nothing I have found a solution.

WINUAE 68020 + fast... or 68030 the fastest is the same.


' Dungeon crawler by DarkN3mo
Set Buffer 100
_INITSCREEN
Global MAPOX,MAPOY,MAPESP,NBCASED
Global GINX,GINY
Global ACTUALSEL
Global DIAD
Global MX,MY,MAPSIZEX,MAPSIZEY,BANKSIZE
Global DAT_START
Global POSINBANK,OSET,QUOIDANSBANK
Global PDIR,PX,PY
Global G_TR,G_DEPLACEMENT
Global V
Global AFFOUPAS
' vertical slider
Global VSDX,VSDY,VSDLARG,YCUH
Global VSDHAUT,VSDPAS,VSDECH,VSDVAL
Global MEMY,YCU,DIFF

_INITVARS
NBCASED=35
AFFOUPAS=1
DAT_START=Start(10)
V=DAT_START
_LOADMAP

MAPOX=8
MAPOY=8
MAPESP=5 : Rem taille cases map

VSDX=2
VSDY=20
VSDLARG=4
VSDHAUT=160
YCUH=8
YCU=VSDY+1
VSDECH=1
MEMY=YCU
_DRAWEDITOR
Procedure _DRAWEDITOR


Procedure _SLIDER2

DIFF=1
MX=2
MY=2
_DRAWMAP

PX=0
PY=0
_MAINLOOP
Edit
Procedure _MAINLOOP
Do
Exit If Key State(69)
Timer=0


_GETINPUT
_SLIDER2

If MX>=MAPOX and MY>=MAPOY and MX<=MAPOX+(MAPESP*NBCASED) and MY<=MAPOY+(MAPESP*NBCASED)
Bob Off 1

POSINBANK=DAT_START
' offest de base
OSET=VSDVAL*MAPSIZEX+PX
'POSINBANK=POSINBANK+OSET
'QUOIDANSBANK=Peek(POSINBANK)


TEMPCASEX=(((MX-1)-MAPOX)/MAPESP)
TEMPCASEY=(((MY-1)-MAPOY)/MAPESP)



If TEMPCASEX<0
TEMPCASEX=0
End If
If TEMPCASEY<0
TEMPCASEY=0
End If
TEMPCELL=(TEMPCASEY*40)+TEMPCASEX+OSET
TEMPCELLVAL=Peek(TEMPCELL)

If Mouse Key=1
Poke(TEMPCELL),ACTUALSEL
End If

Sprite 0,X Hard((TEMPCASEX*5)+MAPOX),Y Hard((TEMPCASEY*5+MAPOY)),23
Else
Bob 1,MX,MY,21

End If
If AFFOUPAS=1
Locate 1,27
A$=""
A$=A$+"mx "+Str$(MX)+" my "+Str$(MY)+" "
A$=A$+Str$(MAPO)+Str$(1)+" DIAD "+Str$(DIAD)+" "

Print A$
Locate 1,28
Print B$
' Locate 1,30
' Print Str$(Timer)
End If
Pen 31
Locate 1,29
A$="oset "+Str$(OSET)+" tempcx "+Str$(TEMPCASEX)+" tempcy "+Str$(TEMPCASEY)
A$=A$+" tilsl "+Str$(ACTUALSEL)
B$=" datstart "+Str$(DAT_START)+" "
Print A$
Locate 1,28
Print B$
Locate 1,30
Print "tile :"+Str$(TEMPCELL)+" val "+Str$(Peek(TEMPCELL))+" x"+Str$(TEMPCASEX)+" y "+Str$(TEMPCASEY)+" "
'Text MX,MY,Str$(MX)+" "+Str$(MY)+" "
'_DRAWMAP

Wait Vbl

'Doke $DFF180,$F

Loop
End Proc


Procedure _GETINPUT
Procedure _DRAWMAP
V=DAT_START
PLX=MAPOX
PLY=MAPOY
ES=MAPESP
For Y=0 To 34
For X=0 To 34
AA=Peek(V+OSET)
Inc V
Ink AA
Box 1+PLX+(X*ES),PLY+1+(Y*ES) To 4+PLX+(X*ES),PLY+4+(Y*ES)
' Paste Icon 1+PLX+(X*ES),PLY+1+(Y*ES),1
Next
Next


End Proc
Procedure _SAVEMAP
Procedure _LOADMAP
'Load "map.bin",10
V=DAT_START
PLX=MAPOX
PLY=MAPOY
ES=MAPESP
For Y=0 To MAPSIZEY-1
For X=0 To MAPSIZEX-1
Poke(V),Rnd(254)
Inc V
Next
Next
End Proc
Procedure _INITVARS

Procedure _INITSCREEN
Screen Open 0,320,256,32,Lowres
Flash Off : Curs Off : Hide
'Double Buffer
'Autoback 0
'Update Off
Load "walls.abk"
' Load Iff "d2.iff",0
Get Bob Palette
'Wait Vbl
Screen 0
Screen Offset 0,0,0
Limit Mouse 0,0 To 319,255
End Proc

Retro1234 15 August 2021 16:40

How long does it take to draw 20*16

double buffer will obviously be slower

take a look at an existing map editor like Tome or the excellent Mac Map for comparison.

DiabloV 15 August 2021 16:44

Quote:

Originally Posted by Retro1234 (Post 1501245)
How long does it take to draw 20*16

double buffer will obviously be slower

take a look at an existing map editor like Tome or the excellent Mac Map for comparison.



20*16 about 2 seconds

I know there are other editors but I prefer to code all my own utilities.
I'm not sure how to do this, but I'm not sure I know how to do it.

Retro1234 15 August 2021 16:48

Yeah good idea but just for comparison.

If you load it into a Dim variable it might speed it up but I agree 2 seconds seems a bit long.

print command is also a weakest link it's very slow remove it.

DiabloV 15 August 2021 17:07

Quote:

Originally Posted by Retro1234 (Post 1501247)
Yeah good idea but just for comparison.

If you load it into a Dim variable it might speed it up but I agree 2 seconds seems a bit long.

print command is also a weakest link it's very slow remove it.

yes it's faster with tables

not necessarily the goal, because in binary you consume less space.

ok TEXT command is faster.

Retro1234 15 August 2021 17:24

iirc Text and other bar, line etc are very slow

most stuff like this removing print will be significantly faster but for a map editor it's not a big deal but for a game you should look to replace text with Paste bob or better Paste Icon.

DiabloV 15 August 2021 17:30

Quote:

Originally Posted by Retro1234 (Post 1501247)
Yeah good idea but just for comparison.

If you load it into a Dim variable it might speed it up but I agree 2 seconds seems a bit long.

print command is also a weakest link it's very slow remove it.



yes of course, for the game I'll use bob sprite and bitmap text.

for the map, I redraw the map each time I change the slider, to take into account the offset, I have no choice

my editor will be usable in the end for several types of games

on the other hand, I'm currently making an old school Dungeon crawler engine (Dungeon Master like)

It's going pretty well. If you have any ideas I'm interested :)

I'll share the progress on the forum

I've taken up the Amos again after more than 20 years off, argh!

Retro1234 15 August 2021 17:36

I have no idea about that type of game but iirc they did something with Bloodwych? on the Amos factory maybe those guys can help.

instead of redrawing the map use Screen offset to scroll, hardware scrolling is always the fastest method to scroll.

O and good luck!

DiabloV 15 August 2021 17:38

Quote:

Originally Posted by Retro1234 (Post 1501259)
I have no idea about that type of game but iirc they did something with Bloodwych? on the Amos factory maybe those guys can help.

instead of redrawing the map use Screen offset to scroll, hardware scrolling is always the fastest method to scroll.

O and good luck!



Yes I know but this would mean drawing the whole map on another screen which can take up a lot of chip space if the map is large.

but that's something to consider too.


thanks

Retro1234 15 August 2021 17:42

more complex Hardware scrolling called wrap around or corkscrew means you can have a smaller screen and hardware scroll endlessly but gets more complex.

you can also use the old software scrolling with Screen Copy I never liked this and don't know if it would be faster than redrawing the whole screen but it was commonly used, Tome used it.

also there's a turbo extension that can paste Icons even quicker but I had some problems using it and Double Buffering but I only looked briefly but it is faster.

Samurai_Crow 15 August 2021 19:40

Actually, Tome didn't use it. The culprit is that the blitter clocks at only 3.5 MHz with 16 bit bus accesses. Even on AGA.

Retro1234 15 August 2021 20:58

I never really looked but iirc nearly all the Tome examples used screen copy for scrolling like these https://m.youtube.com/watch?v=8jbf-cSvPOg

Samurai_Crow 15 August 2021 21:01

Screen copy uses large blitter operations. Very expensive. Screen scroll uses screen offsets and the copper for almost no time cost.

Retro1234 15 August 2021 21:06

Screen offset is the command is the command built into Amos that allows smooth hardware scrolling all the Tome commands for scrolling and Screen copy are very slow.

If you look at the Tome examples there mainly based on very small screens because of this, there also very jerky unlike the Screen Offset command.

DiabloV 19 May 2022 13:44

Quote:

Originally Posted by Retro1234 (Post 1501285)
Screen offset is the command is the command built into Amos that allows smooth hardware scrolling all the Tome commands for scrolling and Screen copy are very slow.

If you look at the Tome examples there mainly based on very small screens because of this, there also very jerky unlike the Screen Offset command.





https://www.youtube.com/watch?v=3egJx4ne_cw

:cool


All times are GMT +2. The time now is 02:43.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.07152 seconds with 11 queries