English Amiga Board


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

 
 
Thread Tools
Old 25 March 2010, 20:05   #161
zaz
Registered User
 
Join Date: Mar 2010
Location: Lkpg/Swe
Posts: 12
Quote:
Originally Posted by StingRay View Post
I think I remember some trainers you made back in the day. If you are the same zaz that was in Dual Crew on Amiga too that is ;D
Yep, that's me. Incidentally the super cars ii trainer was also an exercise in size optimization, but that's another story.
zaz is offline  
Old 25 March 2010, 20:06   #162
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by zaz View Post
372 bytes now.
Cool! Gotta check your version in a sec! "I'm a bit rusty", yeah, right. ;P

Quote:
Originally Posted by zaz View Post
But what happens if $60000 is allocated already? Even with AllocAbs() the loader will fail if that happens...
This is a very "dirty" solution anyway which I really do not like. However, in case of using AllocAbs you could call AllocAbs in a loop until it succeeds. F.e. $40000 first, fails -> increase by say $1000 bytes -> loop

Quote:
Originally Posted by zaz View Post
After the system is killed we could copy the loader to $c0 or some low address and just assume the bootblock is not loaded there (like with the stack relocations), but then it's no longer safe to use library calls to flush the cache...
This is the same as my "copy to $60000" approach then (as I also assume that the bootblock isn't loaded there, AFAIK OS loads bootblock quite low into memory). Cleanest approach would be to call AllocMem and copy the code then (I used exactly that approach in the Bootblock intro I made for FAP) but then the stack relocation wouldn't be safe anymore which is why I didn't use it.
StingRay is offline  
Old 25 March 2010, 20:18   #163
zaz
Registered User
 
Join Date: Mar 2010
Location: Lkpg/Swe
Posts: 12
After loading an unspecified number of tracks to $8000 AllocMem() would not have helped, so might as well leave it as it is.

I had a brief idea about AllocMem()ing a big chunk for the loader, MFM buffer, and loaded program, but the loaded program itself is presumably assembled for an absolute address etc... Coming up: bootblock trackloader with amiga hunk loader & relocator? I think not

EDIT: loader is already AllocMem()ed of course but still...

Last edited by zaz; 25 March 2010 at 20:28. Reason: improving
zaz is offline  
Old 25 March 2010, 20:37   #164
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by zaz View Post
After loading an unspecified number of tracks to $8000 AllocMem() would not have helped, so might as well leave it as it is.
That was exactly the reason why I didn't use it. Absolute addresses for the MFM buffer/stacks = good bye AllocMem.

Quote:
Originally Posted by zaz View Post
I had a brief idea about AllocMem()ing a big chunk for the loader, MFM buffer, and loaded program
That thought actually crossed my mind too. But it would only work if there are no absolute addresses used anywhere. It would be clean and safe!

Last edited by StingRay; 25 March 2010 at 20:43. Reason: "typed too fast" typo ;D
StingRay is offline  
Old 25 March 2010, 20:52   #165
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
I checked your version and I can show you what I meant with "I wanted to keep the code readable" and thus didn't use lea dsklen,a5:

Code:
	move.w	#%0000000000000010,intreq(a5)	;clear disk interrupt bit
This is a bug, a5 is not $dff000 anymore. So it would have to be:
Code:
	move.w	#%0000000000000010,intreq-dsklen(a5)	;clear disk interrupt bit
StingRay is offline  
Old 25 March 2010, 21:09   #166
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@Toni, zaz - Thank you for information.

If I understand correctly. Bootblock code is allocated by AllocMem and is not necessary to think about stack pointers relocation, right ?
Mean we should use AllocMem for buffer.

I know The OS is for wimps
Asman is offline  
Old 25 March 2010, 21:10   #167
zaz
Registered User
 
Join Date: Mar 2010
Location: Lkpg/Swe
Posts: 12
@StingRay: Check again, this is what BASEREG does and why I changed all custom reg EQU from $000 etc to $dff000 etc.

Last edited by zaz; 25 March 2010 at 21:11. Reason: clarified who the comment was directed at
zaz is offline  
Old 25 March 2010, 22:26   #168
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by StingRay View Post
This is the same as my "copy to $60000" approach then (as I also assume that the bootblock isn't loaded there, AFAIK OS loads bootblock quite low into memory).
Exactly. The OS always starts to allocate lowest regions first.

Quote:
Cleanest approach would be to call AllocMem and copy the code then
When we take over the machine it doesn't make sense to call AllocMem. There can never be much memory allocated in this early phase when the bootblock is read, so I would simply relocate to a high region which exists on all Amigas, as you did, and we are safe.
phx is offline  
Old 25 March 2010, 22:36   #169
zaz
Registered User
 
Join Date: Mar 2010
Location: Lkpg/Swe
Posts: 12
Ok 360 bytes version attached.
Attached Files
File Type: 68k opt_bb_trkldr_zaz_366.68k (10.6 KB, 582 views)

Last edited by zaz; 25 March 2010 at 22:40. Reason: Am I going cross-eyed? Source assembles to 360 bytes, not 366
zaz is offline  
Old 26 March 2010, 09:35   #170
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by zaz View Post
@StingRay: Check again, this is what BASEREG does and why I changed all custom reg EQU from $000 etc to $dff000 etc.
I checked again and I have to say: Nice one!
Edit: I never used BASEREG, looks like a nifty feature! =)
And I missed that you changed the custom reg equates, now it does make sense to me.

Quote:
Originally Posted by phx View Post
When we take over the machine it doesn't make sense to call AllocMem. There can never be much memory allocated in this early phase when the bootblock is read, so I would simply relocate to a high region which exists on all Amigas, as you did, and we are safe.
Allocating memory works w/o any problem in the bootblock (see my Bootblock intro for a proof). Besides, the machine has not been taken over at the time I'd allocate memory so it is still the safest (=cleanest) approach as long as no absolute addresses are used anywhere.

Last edited by StingRay; 26 March 2010 at 09:51.
StingRay is offline  
Old 18 May 2013, 11:07   #171
FrenchShark
FPGAmiga rulez!
 
FrenchShark's Avatar
 
Join Date: Dec 2007
Location: South of France
Age: 50
Posts: 155
Hello,

FYI, I am using the trackloader code in a verilog testbench to check the correct functionning of Paula / disk emulation.
I think I spotted a bug line 403:
bne.s .time_not_expired
It should be a BEQ not a BNE since ICR bit is set when timer A transitions from 0000 to FFFF.
What do you think ?

Regards,

Frederic
FrenchShark is offline  
Old 18 May 2013, 18:12   #172
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Yes, it should. Already fixed in my own version of the trackloader a long time ago - just never said anything about it here.
pmc is offline  
Old 18 May 2013, 20:44   #173
FrenchShark
FPGAmiga rulez!
 
FrenchShark's Avatar
 
Join Date: Dec 2007
Location: South of France
Age: 50
Posts: 155
Quote:
Originally Posted by pmc View Post
Yes, it should. Already fixed in my own version of the trackloader a long time ago - just never said anything about it here.
Ok, thanks.
There is actually another one in the Disk DMA enable instruction, it should be:
move.w #%1000001000010000,(a0) ;enable disk DMA
Bit #9 has to be set too.

Regards,

Frederic
FrenchShark is offline  
Old 18 October 2022, 16:42   #174
JokerX
Registered User
 
Join Date: Oct 2022
Location: Switzerland
Posts: 3
Hi guys, many thanks for this interesting thread.

There's another bug when you try to read from track 1. I added something like this to line 359:

Code:
    cmp.b #1,d0
    bne .notTrack1
    bclr.b #2,(a6)
.notTrack1:
Bare with me, i'm pretty new to ASM, so there's probably a more optimized solution than mine.

Last edited by JokerX; 18 October 2022 at 19:18.
JokerX is offline  
Old 18 October 2022, 17:18   #175
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by JokerX View Post
Hi guys, many thanks for this interesting thread.

There's another bug when you try to read from track 1. I added something like this to line 359:

Code:
    cmp.b $1,d0
    bne .notTrack1
    bclr.b #2,(a6)
.notTrack1:
Bare with me, i'm pretty new to ASM, so there's probably a more optimized solution than mine.
I've not checked the code at all, but
cmp.b $1,d0
sounds bad to me. Maybe you meant
cmp.b #1,d0
.
ross is offline  
Old 18 October 2022, 19:18   #176
JokerX
Registered User
 
Join Date: Oct 2022
Location: Switzerland
Posts: 3
Quote:
Originally Posted by ross View Post
I've not checked the code at all, but
cmp.b $1,d0
sounds bad to me. Maybe you meant
cmp.b #1,d0
.
you're right, typo on my end, as i didn't copy and paste as it was that short

thanks for pointing it out, i've corrected the code above.
JokerX 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
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 21:45.

Top

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