English Amiga Board Coding Competition #1
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 29 March 2017, 16:48 #1 DanScott Lemon. / Core Design   Join Date: Mar 2016 Location: Sunny Bournemouth, UK Posts: 633 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 ross Per aspera ad astra   Join Date: Mar 2017 Location: Crossing the Rubicon Age: 50 Posts: 2,707 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 DanScott Lemon. / Core Design   Join Date: Mar 2016 Location: Sunny Bournemouth, UK Posts: 633 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 meynaf son of 68k   Join Date: Nov 2007 Location: Lyon / France Age: 47 Posts: 3,876 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 ross Per aspera ad astra   Join Date: Mar 2017 Location: Crossing the Rubicon Age: 50 Posts: 2,707 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 DanScott Lemon. / Core Design   Join Date: Mar 2016 Location: Sunny Bournemouth, UK Posts: 633 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
meynaf
son of 68k

Join Date: Nov 2007
Location: Lyon / France
Age: 47
Posts: 3,876
Quote:
 Originally Posted by DanScott 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!!
Done.

Quote:
 Originally Posted by DanScott 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.
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 ross Per aspera ad astra   Join Date: Mar 2017 Location: Crossing the Rubicon Age: 50 Posts: 2,707 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 a/b Registered User   Join Date: Jun 2016 Location: europe Posts: 186 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 ross Per aspera ad astra   Join Date: Mar 2017 Location: Crossing the Rubicon Age: 50 Posts: 2,707 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, Attached Thumbnails
30 March 2017, 19:08   #11
paraj
Registered User

Join Date: Feb 2017
Location: Denmark
Posts: 78
Quote:
 Originally Posted by ross 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
I can match xx bytes for a truncating version*. Now it's time to see if I can find any improvements.

*) 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 meynaf son of 68k   Join Date: Nov 2007 Location: Lyon / France Age: 47 Posts: 3,876 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
Thorham
Computer Nerd

Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 44
Posts: 3,089
Quote:
 Originally Posted by DanScott Inputs: d0.w = Colour 1 (12bit RGB) d1.w = Colour 2 (12bit RGB) d2.b = Step value (0-15)
That's a pretty bad interface, yuk I'll skip this one.

31 March 2017, 11:20   #14
DanScott
Lemon. / Core Design

Join Date: Mar 2016
Location: Sunny Bournemouth, UK
Posts: 633
Quote:
 Originally Posted by Thorham That's a pretty bad interface
How?

A function that takes 3 data regs and spits out a result...

31 March 2017, 11:24   #15
DanScott
Lemon. / Core Design

Join Date: Mar 2016
Location: Sunny Bournemouth, UK
Posts: 633
Quote:
 Originally Posted by a/b 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?
However you want It's the cycle count of the routine that is important

31 March 2017, 14:25   #16
Thorham
Computer Nerd

Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 44
Posts: 3,089
Quote:
 Originally Posted by DanScott How? A function that takes 3 data regs and spits out a result...
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
meynaf
son of 68k

Join Date: Nov 2007
Location: Lyon / France
Age: 47
Posts: 3,876
Quote:
 Originally Posted by Thorham (d2 should be a word, though).
Quote:
 Originally Posted by DanScott Assume unused upper bits in d0,d1&d2 are all zero too.
@Thorham :
Not waken up properly today, mate ?

31 March 2017, 15:57   #18
Thorham
Computer Nerd

Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 44
Posts: 3,089
Quote:
 Originally Posted by meynaf Not waken up properly today, mate ?
Didn't have enough coffee

 02 April 2017, 13:32 #19 ross Per aspera ad astra   Join Date: Mar 2017 Location: Crossing the Rubicon Age: 50 Posts: 2,707 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
ross

Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 2,707
Quote:
 Originally Posted by DanScott --cut-- 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. --cut--
Hi Dan, sorry to be pedantic...

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)

 Similar Threads Thread Thread Starter Forum Replies Last Post DanScott Coders. Asm / Hardware 526 22 September 2018 21:38 pmc Coders. General 55 16 November 2009 21:45 Thorham Coders. General 6 05 March 2008 08:38 alexh Coders. General 14 15 August 2006 09:24 redblade Coders. General 10 25 January 2005 21:52

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.EAB File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Creation     Graphics         Graphics. Work In Progress         Graphics. Finished Work         Graphics. Tutorials     Music         Music. Work In Progress         Music. Finished Work         Music. Tutorials Off Topic     OT - General     OT - Entertainment     OT - Sports     OT - Technical     OT - Gaming

All times are GMT +2. The time now is 11:08.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top