29 March 2017, 16:48 | #1 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
Coding Competition #1
OK... so now that other thread is completely cluttered, and I have finally some free time... it's time for coding competition #1
This first task is very Amiga OCS/ECS orientated (oriented for our American friends ) Write a function to interpolate between two Amiga OCS/ECS 12-bit RGB values over 0 to 15 steps ( i chose this, as there are 0 to 15 steps to interpolate a colour from $000 to $fff) Inputs: d0.w = Colour 1 (12bit RGB) d1.w = Colour 2 (12bit RGB) d2.b = Step value (0-15) Output: d0.w = Final Interpolated Colour (12bit RGB) Please assume all other registers are in an undetermined state, and thus need saving and restoring as part of the function. There will be 2 winners... one for the shortest code, and another for the fastest code For the fastest code, a look-up table will be allowed (up to a maximum of 1kb), and the initialise function to generate the look-up table will not be counted in the cycle count of the routine. Please refrain from turning this thread into a discussion, or going off-topic Thanks Dan |
30 March 2017, 01:38 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Hi Dan, I ask for some clarification.
RGB Colour 2 single components can be minor of Colour 1? (ex. C1=$785, C2=$f37 so negative step in G component) If Amiga OCS/ECS then pure 68k? I can count on zeroed upper bit of d2 and $0RGB? There is a minimum precision for the interpolation rounding? (I've written the 'shortest code' version in hurry and i'm sleepy so better go to bed and recheck tomorrow , xx byte but do not rely too much on this value) Bye, ross Last edited by ross; 30 March 2017 at 18:36. Reason: no reference |
30 March 2017, 08:58 | #3 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
Yes, both RGB values can be ANY value whatsoever
pure 68000. Assume unused upper bits in d0,d1&d2 are all zero too. Precision... well it has to be pretty accurate... |
30 March 2017, 10:05 | #4 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Code no longer here as DanScott wanted...
Last edited by meynaf; 30 March 2017 at 15:25. Reason: code removed from the thread |
30 March 2017, 10:45 | #5 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Hi meynaf, very squeezed code
I have a version in a laptop that is not with me now. It is different from Yours. Last night I wrote it late and I do not remember by heart But no divu, two muls and no 4 component but 3. (i'm in waiting of Dan response ) Bye! ross |
30 March 2017, 11:10 | #6 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
I forgot to say... Please do not post the code in this thread. Meynaf, can you remove your code from your post please
PLEASE SEND ALL ENTRIES TO ME VIA P.M MESSAGE HERE!! This makes it fairer, so others won't use someone elses code as a basis for their own. Optimisations can be discussed after competition closes and results are announced. CLOSING DATE FOR ENTRIES is SUNDAY 9th APRIL Last edited by DanScott; 30 March 2017 at 16:16. |
30 March 2017, 15:32 | #7 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Fairer but now we're blind - no way to know if we're the best or totally out of it... |
|
30 March 2017, 17:46 | #8 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Ok, got some time to check my late-night code (a mess but the idea was good, even an initialized and unused register..).
Different approach than meynaf (like usual, i'm sure if I show my code he can strip-down 2 byte ) For the 4 component, round perfect(*) version: xx byte The pretty usable trunc integer version: xx byte (*i've written a reference code in c with double precision type vars and the results are the same) Now the fast version... Bye! ross Last edited by ross; 30 March 2017 at 18:35. Reason: no reference |
30 March 2017, 17:55 | #9 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
For the speedy version, can the lookup table be placed within 8-bit distance of the code (=> pc relative with index and 8-bit displacement), or it has to be in an entirely different DATA/BSS section?
|
30 March 2017, 17:58 | #10 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Sorry to go slightly off-topic, but is surely related.
I've to show this beauty,I am always fascinated by doodling generated by code. On left my generated data, on right meynaf generated data. Look the diffs Bye, |
30 March 2017, 19:08 | #11 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,104
|
Quote:
*) No point in submitting yet, for reference the md5sum of my implementation is: bdede35f639ab9a7d200629095d4c5a3 c1.xxbytes.s Last edited by paraj; 30 March 2017 at 19:10. Reason: Hiding number of bytes |
|
30 March 2017, 22:29 | #12 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I could beat my first version and therefore i submitted the new one in replacement. This old code has been read by others anyway so it was kinda necessary...
No more 4x loop (i initially missed the obvious) and this is all i will tell here. |
31 March 2017, 10:49 | #13 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,762
|
|
31 March 2017, 11:20 | #14 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
|
31 March 2017, 11:24 | #15 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
However you want It's the cycle count of the routine that is important
|
31 March 2017, 14:25 | #16 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,762
|
Forget what I said, I misread the spec Thought you had to interpolate from one color to another in a number of steps and output to an array It's fine if it's just lerp (d2 should be a word, though).
|
31 March 2017, 15:19 | #17 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
31 March 2017, 15:57 | #18 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,762
|
|
02 April 2017, 13:32 | #19 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Hi all, beated my previous 'small code' not-math-precise-but-enough-accurate version (*).
So I've two small version upped: rigorous math accurate and pretty accurate. Is Dan choice of what to consider. In my opinion both are beautiful pieces of tiny code Now trying to shrink 4KB table into 1KB for the fast version. (*)it's highly likely that at the end my code match the new announced meynaf one i'm very curious about that.. the optimization made was not trivial my stupid tabbed doodle in previous post enlightened me |
03 April 2017, 18:06 | #20 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Quote:
I've a doubt regarding register saving. For the fast routine i destroy even the input value in d1 and d2. I have to maintain their value? (is not simply the cycles for their saving to (re)consider but the routine itself) The rule "assume all other registers are in an undetermined state, and thus need saving and restoring as part of the function" is not clear if includes them or not.. An alternative can be like system routine that save all but d0-d1/a0-a1. Each cycle counts in fast routine Thanks, bye, ross |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Anyone up for an ASM coding competition? | DanScott | Coders. Asm / Hardware | 526 | 22 September 2018 21:38 |
What gives you coding inspiration? | pmc | Coders. General | 55 | 16 November 2009 21:45 |
Need help with audio coding. | Thorham | Coders. General | 6 | 05 March 2008 08:38 |
Help coding | alexh | Coders. General | 14 | 15 August 2006 09:24 |
Coding a Trainer | redblade | Coders. General | 10 | 25 January 2005 21:52 |
|
|