English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. AMOS

 
 
Thread Tools
Old 15 August 2021, 16:13   #1
DiabloV
Registered User
 
Join Date: Jan 2021
Location: FRANCE
Posts: 30
Post double buffer and autoback tilemap answer issue

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
Attached Files
File Type: zip maped.zip (15.3 KB, 121 views)
DiabloV is offline  
Old 15 August 2021, 16:40   #2
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
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.
Retro1234 is offline  
Old 15 August 2021, 16:44   #3
DiabloV
Registered User
 
Join Date: Jan 2021
Location: FRANCE
Posts: 30
Quote:
Originally Posted by Retro1234 View Post
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.
DiabloV is offline  
Old 15 August 2021, 16:48   #4
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
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.
Retro1234 is offline  
Old 15 August 2021, 17:07   #5
DiabloV
Registered User
 
Join Date: Jan 2021
Location: FRANCE
Posts: 30
Quote:
Originally Posted by Retro1234 View Post
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.

Last edited by DiabloV; 15 August 2021 at 17:14.
DiabloV is offline  
Old 15 August 2021, 17:24   #6
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
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.
Retro1234 is offline  
Old 15 August 2021, 17:30   #7
DiabloV
Registered User
 
Join Date: Jan 2021
Location: FRANCE
Posts: 30
Quote:
Originally Posted by Retro1234 View Post
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!
DiabloV is offline  
Old 15 August 2021, 17:36   #8
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
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!
Retro1234 is offline  
Old 15 August 2021, 17:38   #9
DiabloV
Registered User
 
Join Date: Jan 2021
Location: FRANCE
Posts: 30
Quote:
Originally Posted by Retro1234 View Post
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
DiabloV is offline  
Old 15 August 2021, 17:42   #10
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
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.
Retro1234 is offline  
Old 15 August 2021, 19:40   #11
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
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.
Samurai_Crow is offline  
Old 15 August 2021, 20:58   #12
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
I never really looked but iirc nearly all the Tome examples used screen copy for scrolling like these [ Show youtube player ]
Retro1234 is offline  
Old 15 August 2021, 21:01   #13
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
Screen copy uses large blitter operations. Very expensive. Screen scroll uses screen offsets and the copper for almost no time cost.
Samurai_Crow is offline  
Old 15 August 2021, 21:06   #14
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
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.
Retro1234 is offline  
Old 19 May 2022, 13:44   #15
DiabloV
Registered User
 
Join Date: Jan 2021
Location: FRANCE
Posts: 30
Quote:
Originally Posted by Retro1234 View Post
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.




[ Show youtube player ]

DiabloV is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Game development using C and sys functions, double buffer problem balrogsoft Coders. C/C++ 7 28 December 2022 21:32
Double Buffer & Hardware Scroll DanielAllsopp Coders. Asm / Hardware 13 29 January 2020 19:07
ScrollVPort double buffer problem with garbage pixels balrogsoft Coders. General 5 29 May 2014 12:31
Double buffer copper?? h0ffman Coders. General 8 19 July 2011 19:10
Vsync Fullscreen and Double Buffer, incorrect frame rate? rsn8887 support.WinUAE 1 07 April 2011 20:43

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:45.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.43791 seconds with 14 queries