English Amiga Board Amiga Lore


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

 
 
Thread Tools
Old 23 June 2009, 15:16   #1
Vortex
Used Register
Vortex's Avatar
 
Join Date: Nov 2008
Location: Headvillage / The Nethervoids
Age: 43
Posts: 103
ASM: Hardware Track Loader

Gentlemen,

Attached is the code for a basic hardware track loader.
Tested it on a real Amiga 500, and df0: is still alive

Some remarks:
- Hardly any checks in there. For instance, if you want to try and read track 2000..., the result will be ehhhm.. undefined.
- It can probably be coded a little more compact, but at least it's readable now
- Uses df0: (hardcoded).
- The example loads track 0 and 1 from disk and then exits. use D DecodeBuffer or H DecodeBuffer to see what has been read (Both ASMOne).

Enjoy, and comments are always welcome.

Cheers,

V.
Attached Files
File Type: zip trackloader.zip (3.5 KB, 558 views)

Last edited by Vortex; 23 June 2009 at 15:18. Reason: (forgot attachment)
Vortex is offline  
AdSense AdSense  
Old 23 June 2009, 15:37   #2
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Nice one mate.

Time to download and check.
pmc is offline  
Old 25 June 2009, 03:03   #3
xaind
Registered User
 
Join Date: Apr 2006
Location: Sydney / Australia
Posts: 99
Thanks Vortex, especially for commenting the code so well.
xaind is offline  
Old 17 March 2010, 14:47   #4
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Watcha chaps.

I made a small trackloader routine that can be installed on a bootblock (526 bytes total) and I'm trying to test it to see if it works OK.

I wrote the trackloader bootblock to disk using Asm-One and calculated the checksum and the disk is bootable so that seems to have worked.

I can see that when it boots it finds track 0 OK, moves to the required track OK and reads that track. But then it just sits there.

If I hit the HRTMon freeze button I can see that where it's sitting is in a loop looking for the $44894489 MFM sync mark longword.

This is making me think I'm not writing my test binary routine that I want to load and execute with the trackloader to disk correctly with Asm-One.

Well, either that or my code isn't working as I think it should...

Anyone got any advice either about using Asm-One correctly or whether the approach I've used in my code is OK?

EDIT: Old version of code removed.

Last edited by pmc; 17 March 2010 at 19:32.
pmc is offline  
Old 17 March 2010, 14:50   #5
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Had a quick look and can't see anywhere that you properly "kill" the system and stuff. Which is most probably the reason for your problem (track not loaded correctly, no SYNC marker => bang bang you're dead)
StingRay is offline  
Old 17 March 2010, 14:56   #6
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
OK so I still have to do all the forbid stuff up front then...?

Quote:
Originally Posted by StingRay
(track not loaded correctly, no SYNC marker => bang bang you're dead)
Am I also writing the track to disk wrong in the first place too then...?
pmc is offline  
Old 17 March 2010, 15:00   #7
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by pmc View Post
OK so I still have to do all the forbid stuff up front then...?
Yeah, just kill interrupts/dma etc and then enable disk dma. for a very quick (and dirty) test a move.w #$4000,$dff09a might be enough.

Quote:
Originally Posted by pmc View Post
Am I also writing the track to disk wrong in the first place too then...?
If you're using ASM1 to write the track then there shouldn't be any problems.
StingRay is offline  
Old 17 March 2010, 15:01   #8
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Nice one mate - I'll do more testing.
pmc is offline  
Old 17 March 2010, 15:44   #9
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Added a jsr forbid, and move.w $7fff to intena, dmacon and intreq to the code and now when it boots it just gurus out.

More testing needed I think...
pmc is offline  
Old 17 March 2010, 15:51   #10
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,674
Sync check is bad, always use word comparison because there can be 0 to 2 sync words at the beginning depending on disk position when DMA was started. (and position of Paula's internal word counter)

EDIT: or was it 0 to 1? I don't remember and too lazy to check
Toni Wilen is online now  
Old 17 March 2010, 15:52   #11
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Cheers Toni - I'll swap longword cmp over to two word cmp's.
pmc is offline  
Old 17 March 2010, 15:53   #12
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by pmc View Post
Added a jsr forbid, and move.w $7fff to intena, dmacon and intreq to the code and now when it boots it just gurus out.
Now that doesn't make sense. Check your code. And what Toni said (just noticed that too).
StingRay is offline  
Old 17 March 2010, 19:37   #13
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
OK - new version of code attached.

This one forbids multitasking and turns off dma and interrupts and doesn't guru out in doing so.

Also, it now locates the $4489 sync words a word at a time instead of as one longword and seems to find the syncs as it doesn't freeze anymore.

However, what it does now is in some ways worse! It starts stepping the heads and runs away and tries to step them up and beyond cylinder 79. Ooooops!

So - DON'T run this version on a real Amiga!!

Glad I'm testing this on WinUAE or I might now have a dead drive!

More bugfixing to do but I'm nearly there I think...

EDIT: Bad code described above removed - I looked at the decode routine again this morning (I always spot bugs in code in the morning! ) and found some *really* obvious mistakes. They've been fixed so now just some more testing...

Last edited by pmc; 18 March 2010 at 09:37.
pmc is offline  
Old 19 March 2010, 15:35   #14
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
OK chaps forget all about my previous trackloader attempt per my posts above - I was trying to cut way too many corners with that one and, in short, it was a load of crap.

Anyways, I went away, actually *thought* about it and recoded it from scratch.

So, tested working bootblock trackloader (736 bytes total size) attached.

Last edited by pmc; 21 March 2010 at 00:20.
pmc is offline  
Old 19 March 2010, 15:41   #15
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by pmc View Post
So, tested working bootblock trackloader (736 bytes total size) attached.
Nice that you got it to work. It can easily be made smaller (mine is 494 bytes :P) and faster, you can access the CIA registers indirect like the HW regs f.e. =) Also, there is no need to start/stop motor for each track, just turn on the motor, check if the drive is ready, load your tracks and then turn the motor off.
StingRay is offline  
Old 19 March 2010, 15:49   #16
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
Originally Posted by StingRay
It can easily be made smaller (mine is 494 bytes :P) and faster
LOL!

One step at a time! I was just glad to get it working!

Thanks for the advice on some of the savings I can make - now that it's working OK I can go back and optimise.

This is probably a silly question but has your bootblock trackloader got enough space left over to also do decrunch of the loaded data...?

I just wonder whether it might be posslble for me, after I trim the existing loader down, to add a decrunch routine too...
pmc is offline  
Old 19 March 2010, 15:58   #17
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by pmc View Post
One step at a time! I was just glad to get it working!
I know.


Quote:
Originally Posted by pmc View Post
This is probably a silly question but has your bootblock trackloader got enough space left over to also do decrunch of the loaded data...?
Not a silly question at all. Actually, I never really made a "bootblock trackloader", I just coded a size optimized trackloader which happens to fit on a bootblock. And yes, there is enough space for a decruncher, the CRM decruncher I am using is 328 bytes so that makes 494+328=822 bytes. Still 190 bytes (1012-822) left for code.

Quote:
Originally Posted by pmc View Post
I just wonder whether it might be posslble for me, after I trim the existing loader down, to add a decrunch routine too...
I'm sure you can do that!
StingRay is offline  
Old 19 March 2010, 16:04   #18
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
Originally Posted by StingRay
I know.


Quote:
Originally Posted by StingRay
And yes, there is enough space for a decruncher, the CRM decruncher I am using is 328 bytes so that makes 494+328=822 bytes. Still 190 bytes (1012-822) left for code.
Cool.

For my trackloader though, 736 + 328 = 1064

I better get optimising!
pmc is offline  
Old 19 March 2010, 16:06   #19
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by pmc View Post
I better get optimising!
Have fun. Another (maybe not so obvious) optimizing tip is: bsr followed by rts -> bra =)
StingRay is offline  
Old 19 March 2010, 22:35   #20
musashi5150
move.w #$4489,$dff07e
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 36
Posts: 2,284
Yes, as Dr Sting says it can be done with room to spare I did a bootblock trackloader and decruncher for an old crack of Strider I did when I was learning and then packed all datas on the disk with my own cruncher. I made sure it did depack stripes of course for that 'pro' touch

Once you've written your own trackloader the natural progression from there is cracking y'know Well, it was for me
musashi5150 is offline  
AdSense AdSense  
 


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


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.22662 seconds with 13 queries