English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 19 March 2010, 23:32   #21
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by musashi5150
Yes, as Dr Sting says it can be done with room to spare
Cool - I'll keep squeezing it down till I get there.

Quote:
Originally Posted by musashi5150
packed all datas on the disk with my own cruncher.
Heavy skills.

Got any good advice for things to read for learning how to write my own cruncher...? Always nice to learn new things.
pmc is offline  
Old 20 March 2010, 00:53   #22
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
Quote:
Originally Posted by pmc View Post
Got any good advice for things to read for learning how to write my own cruncher...? Always nice to learn new things.
Unless you have uber skills to come up with something good yourself (not in my case ), it's a case of finding an algorithm you like from a paper or book and modding it so it works for you. I usually get it all working in C first and then just port and optimise the decrunching code to 68K The optimising part is the fun bit - I found I keep coming back to it and spend time shaving off a couple of bytes... or making it a whisker faster each time
musashi5150 is offline  
Old 20 March 2010, 13:28   #23
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Nice one.

Looks like another project added to my list will be my own crunch / decrunch routines at some point then.

In the meantime though I think I'll try to make my bb trackloader as small as possible and use something already available for crunching. Load and decrunch is what I need if I want to start thinking about making my own multipart demos.
pmc is offline  
Old 20 March 2010, 22:45   #24
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Shortened version attached.

Now down to a bit more respectable 532 bytes.

Quote:
Originally Posted by StingRay
Another (maybe not so obvious) optimizing tip is: bsr followed by rts -> bra =)
I didn't quite get what you meant by this Sting - is this something I could use to make the trackloader even shorter...?

Last edited by pmc; 21 March 2010 at 00:20.
pmc is offline  
Old 20 March 2010, 23:28   #25
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
Quote:
Originally Posted by pmc View Post
I didn't quite get what you meant by this Sting - is this something I could use to make the trackloader even shorter...?
He means if you replace (for example)...

Code:
.at_trk_0:         bsr.s .lower_head
                   move.b #0,d5 ;set track 0 as current track
                   bsr.s .dir_change
                   bsr.s .seek_inwards
                   rts
with

Code:
.at_trk_0:         bsr.s .lower_head
                   move.b #0,d5 ;set track 0 as current track
                   bsr.s .dir_change
                   bra.s .seek_inwards
it does the same job and saves some bytes by using the 'rts' in the .seek_inwards routine to jump 2 steps back if you like Do this in a few other places in your code and that's quite a saving
musashi5150 is offline  
Old 21 March 2010, 00:01   #26
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@ musashi5150 - ah, of course, thanks mate. I'll have a look through the code again.

Meantime, in case it's of any use, attached is the previous version only this time there's the StoneCracker optimised decrunch routine included. With this it totals 884 bytes so it still fits nicely onto a bootblock and can be used to trackload StoneCracker crunched binaries straight off disk.

Last edited by pmc; 21 March 2010 at 00:19.
pmc is offline  
Old 21 March 2010, 00:24   #27
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Thanks to Sting and musashi5150, the trackloader, including the bootblock header stuff, is now 486 bytes.

Also attached is the shorter decrunch version too which is now 838 bytes.

Thanks guys, your advice has been really appreciated.

EDIT: Found some more savings - trackloaders are now smaller still as per new byte values.

EDIT 2: Found some more savings - trackloaders smaller again, as per new byte values.

EDIT 3: Added a version that does some nice old skool $dff180 colours on decrunch - adds 10 bytes to the code, but come on - it's for decrunch colours! \o/

EDIT 4: Found yet another saving - new byte sizes as per above.

Source code removed - newer smaller version posted further down this thread...

Last edited by pmc; 22 March 2010 at 13:02.
pmc is offline  
Old 22 March 2010, 10:05   #28
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by pmc View Post
Thanks to Sting and musashi5150, the trackloader, including the bootblock header stuff, is now 486 bytes.

EDIT 4: Found yet another saving - new byte sizes as per above.
Nice =) Just for fun I had a look at the code and my version is 464 bytes.
StingRay is offline  
Old 22 March 2010, 10:23   #29
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
ROFL!

I knew you'd win!

To be fair, without your and musashi5150's advice I wouldn't have got it down to 486 bytes anyway so even if I had made mine shorter it still would've been a joint victory!

Regardless, I really enjoyed minimising it and learned loads. Making code more compact is almost as fun as making code in the first place!
pmc is offline  
Old 22 March 2010, 10:38   #30
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by pmc View Post
Making code more compact is almost as fun as making code in the first place!
Agreed. You can learn a lot when you size optimize code. Btw, my version is now 450 bytes. (but I have to stop now as I have to work ;D)
StingRay is offline  
Old 22 March 2010, 10:50   #31
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by StingRay
Btw, my version is now 450 bytes.
Now you're just rubbing salt in the wound!

Mind you, I should expect any man who can fit the whole Lotus Espirit Turbo game into 96k to have made a trackloader of 450 bytes or less.

Once you finish your uber shrinking of that ultra small trackloader I wouldn't mind having a peek at the source code if you wouldn't mind...? - it'll help me learn even more ways from the master about how to save bytes in code.
pmc is offline  
Old 22 March 2010, 10:57   #32
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
There are few obvious SIZE optimizing ( after StingRay correction. Thanks ) in your code, like changing some move.x to moveq. I'm sure you will find it.

Cheers

Last edited by Asman; 22 March 2010 at 11:10.
Asman is offline  
Old 22 March 2010, 11:04   #33
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by pmc View Post
Once you finish your uber shrinking of that ultra small trackloader I wouldn't mind having a peek at the source code if you wouldn't mind...? - it'll help me learn even more ways from the master about how to save bytes in code.
Edit: just in case you misunderstood, I optimized your code, not mine.

I can do but I'm sure you can find ways to kill some bytes yourself, it's more fun that way. =)
Some hints:
- add.l -> add.w
- lea $xxxx.l -> lea $xxxx.w
- move.l ax,$xx.l -> move.l ax,$xx.w
- "chain" your routines, e.g.
move.w #val,d7
bra.w .wait_timer
; some other code
move.w #val,d7
bra.w .wait_timer
; some other code
move.w #val,d7
bra.w .wait_timer


can be changed to:
move.w #val,d7
bra.b .w_timer
; some other code
move.w #val,d7
bra.b .w_timer
; some other code
move.w #val,d7
.w_timer
bra.w .wait_timer

- check the wait_timer routine (absolute cia addresses used there), just noticed that so it would be <450 bytes if I would have time to "fix" that

etc


Quote:
Originally Posted by Asman View Post
There are few obvious speed ups in your code, like changing some move.x to moveq. I'm sure you will find it.
Even though this is correct this is about SIZE optimizing, not speed optimizing. And usually, the shorter the code, the slower it is.

Last edited by StingRay; 22 March 2010 at 11:26. Reason: some additions
StingRay is offline  
Old 22 March 2010, 11:28   #34
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by StingRay
I can do but I'm sure you can find ways to kill some bytes yourself, it's more fun that way. =)
You know what, you're right.

Since my last post I shaved off another 2 bytes and now, with your extra advice, I'm sure I can shave off some more on my own.

@ Asman - thanks for checking my code fella.

What Sting said though - never mind speed, I just want to make the shortest possible trackloader that I can make. \o/
pmc is offline  
Old 22 March 2010, 11:34   #35
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by StingRay
Edit: just in case you misunderstood, I optimized your code, not mine.
You're right - I had misunderstood. I didn't realise you'd shaved *my code* down to under 450!

I'll try to shave it myself!

If I can shave it down like you did do you think it might be the world record shortest Amiga trackloader...?

What I mean is - surely there must come a point where any routine just *can't* become any smaller...?
pmc is offline  
Old 22 March 2010, 11:41   #36
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by pmc View Post
If I can shave it down like you did do you think it might be the world record shortest Amiga trackloader...?

What I mean is - surely there must come a point where any routine just *can't* become any smaller...?

Of course there'll be a point where you can't optimize anymore, then it's just a matter to decide if you want to do some "hardcore" optimizing or not, e.g. in this case: it's a bootblock trackloader -> no need to step to track 0 (OS did that already). But then it wouldn't be a "normal" trackloader anymore which is of course a disadvantage. Decisions, decisions.
StingRay is offline  
Old 22 March 2010, 11:53   #37
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by StingRay
Of course there'll be a point where you can't optimize anymore, then it's just a matter to decide if you want to do some "hardcore" optimizing or not, e.g. in this case: it's a bootblock trackloader -> no need to step to track 0 (OS did that already). But then it wouldn't be a "normal" trackloader anymore which is of course a disadvantage. Decisions, decisions.
Hmmmm... I like the sound of doing hardcore optimising but I'm not sure if I want to remove the seek track 0 stuff cos I'd like to also be able to use this trackloader in a non-bootblock situation... As you know, my reason for coding a trackloder wasn't initially to do a bootblock one - I need a trackloader for other (top secret project ) reasons.

By the way - trackloader now currently standing at 470 bytes and counting.
pmc is offline  
Old 22 March 2010, 12:08   #38
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by pmc View Post
Hmmmm... I like the sound of doing hardcore optimising
It's a lot of fun. If you really like the sound of doing hardcore optimizing try to code a bootblock intro.

Quote:
Originally Posted by pmc View Post
but I'm not sure if I want to remove the seek track 0 stuff cos I'd like to also be able to use this trackloader in a non-bootblock situation... As you know, my reason for coding a trackloder wasn't initially to do a bootblock one - I need a trackloader for other (top secret project ) reasons.
I know. It was just an example, a bootblock trackloader is a special case of a trackloader and thus it's possible to cut some corners. But except for some "code the shortest trackloader that fits on a bootblock" compo I wouldn't do such optimizations.

Quote:
Originally Posted by pmc View Post
By the way - trackloader now currently standing at 470 bytes and counting.
20+ bytes to go.
StingRay is offline  
Old 22 March 2010, 12:18   #39
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Trackloader now 444 bytes.

Still not done any work on the CIA timer routine absolutes as yet...
pmc is offline  
Old 22 March 2010, 12:18   #40
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by pmc View Post
Trackloader now 444 bytes.

Still not done any work on the CIA timer routine absolutes as yet...
See, I knew you can do it. Cool!
StingRay is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
HD loader example st! Coders. General 4 16 October 2012 21:56
Game loader stuck on certain track after save state restore andreas support.WinUAE 2 26 March 2011 19:59
Can't transfer Supaplex cause of CSL track loader ! Vollldo support.Games 4 12 March 2011 21:51
Hardware File Loader h0ffman Coders. General 9 02 December 2010 16:40
mfm/custom regs/track loader snyp Coders. General 9 06 June 2006 19:42

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 23:29.

Top

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