English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 30 January 2017, 12:43   #1
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
Updating copper list every frame

Guys
another question I can't find the answer myself is:
How to update a CopperList every frame.

Based on the examples I can create custom copper list with by creating a string and passing it to initCopList command - and it works when done at init of the display.
In the main loop right after the VWait I want to do changes to the copper string but how do I pass it to the copper list? I mean I tried the InitCopList in the loop but it crashed with the error message "Out of mem" or similar.
What's the proper way to do it.
I'm thinking about plasma like copper effects but not only that.

TIA
carrion is offline  
Old 30 January 2017, 17:20   #2
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
I think the CustomString command is what you're looking for. It inserts custom commands at a given Y position:

CustomString CopList#, CCOffset, YPos, Copper$

Or maybe DisplayUser:

DisplayUser CopList#, Line, String[, Offset]
Daedalus is offline  
Old 01 February 2017, 16:09   #3
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
ok I tried it and it works, but...
but it's slow
I guess building the string to pass as copper instructions is the bottleneck.
I build an area actually (actually it's dcb.w) and the I have small asm procedure to fill it with nice colors.
but the building the string is working really slow.
any ideas of how to access copper list maybe via assembler or maybe not build the string with all these functions like Mki$ ?

TIA
carrion is offline  
Old 02 February 2017, 15:54   #4
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
You can assign the string and then poke integer values directly into it, should save a lot of time as you're not treating them as strings:

Poke.b &Copper$ + 2, 66

Puts character 66 (capital B) in the third position (first character + 2). The & symbol before a variable or label name returns the address of the variable or label. Poking carefully assembled words or longwords would be even faster:

Poke.l &Copper$, $434F4F4C

Should write the characters COOL to the first 4 positions of the string.

Be very careful doing this though - if you poke past the end of your string, all sorts of bad things could happen. If the string will always be the same length, set up a dummy string at the start of your code and poke the values you need into it. Setting the string using the Maxlen command will reserve the memory, which might help keep things safe:

Maxlen Copper$=1024 ; Allow 1KB string in Copper$

Also, if you change the length of the string to something shorter, remember to poke a 0 after the last character or the previous data will still be seen:

Poke.l &Copper$, $434F4F4C
Poke.b &Copper$ + 4, 0

Of course, using a MOVE instead of Poke should give similar results.
Daedalus is offline  
Old 02 February 2017, 19:04   #5
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
ah yes you are right. I can put ascii characters to the string by using the pointer symbol (&) I even us it somewhere else in my program but
I'm not sure it will speed up things a lot because of the customString$ has to be converted to actual copper list by Blitz itself. which I have suspicion is not very fast.
Well will try and share my research.
carrion is offline  
Old 02 February 2017, 21:28   #6
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
oh
wait, wait, wait... the copper string passed to DisplayUser or CustomString is not an actual ASCII string it's a placeholder for binary copper data...
this may actually work.
so I have to create an empty string but of the size of needed copper list data and then fill it with MOVEs or Pokes.

more research in progress, and if I'll come to some conclusions/results I'll share with you here.
carrion is offline  
Old 02 February 2017, 22:52   #7
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Yep, that's the idea. It's actually treated just like a char array in C, so it can be used the same way.
Daedalus is offline  
Old 07 February 2017, 15:17   #8
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
ok
so my idea works, slow but it works.
first slow part is a creation of empty string. i concat right number of chars to later update it with ASM code with copper wait and move instructions.
question for today.
How can i faster create a empty string? can I create a bank and pass a pointer to it as a string? any other options for just allocating a membership for copper string?

more questions to come
carrion is offline  
Old 08 February 2017, 01:05   #9
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Do you really need to create the empty string more than once?
idrougge is offline  
Old 08 February 2017, 10:24   #10
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
As idrougge says, you should be able to reuse the same string each time, so you only need to create it once at the start of your code. If the strings are different lengths, just poke a 0 after the last character to mark its end.
Daedalus is offline  
Old 09 February 2017, 12:27   #11
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
Ofcoz I'm reusing the same string.
The thing that takes a lot (and on A500 I really mean a lot) of time is something I want to speed up.
carrion is offline  
Old 09 February 2017, 13:21   #12
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
You can get the address of the string using &name_of_string.
idrougge is offline  
Old 02 October 2017, 11:31   #13
Raislin77it
Zone Friend
 
Raislin77it's Avatar
 
Join Date: Jan 2005
Location: italy
Age: 46
Posts: 244
Quote:
Originally Posted by carrion View Post
Ofcoz I'm reusing the same string.
The thing that takes a lot (and on A500 I really mean a lot) of time is something I want to speed up.
any news on the string-copper method?
Raislin77it 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
Combining copper scrolling with copper background phx Coders. Asm / Hardware 16 13 February 2021 12:41
Best way to mix blitting with copper and copper effects roondar Coders. Asm / Hardware 3 12 September 2016 13:12
Copper list execution start. nandius_c Coders. Asm / Hardware 11 14 August 2014 22:28
Can anyone here hack a single load Amiga game to add a copper list please? ImmortalA1000 Amiga scene 10 19 January 2012 08:20
Copper list setup for runtime library Samurai_Crow Coders. General 7 26 August 2010 16:14

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 18:12.

Top

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