English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 04 October 2018, 12:06   #1
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
Post AlphaOne Trackloader Vers 2004 (404 Byte) Question

Hi !

This version of Trackloader work with D0=size In byte to read

In a standard floppy where I put some Data, I use this version of trackloader to read it.
But...

My real size of data is $1E460
If D0=1E460 when I call the trackloader code, no problem, all work.

BUT... my real code work with 'count of track to read'
so for 1E460 of DATA I need to read $17

--
$1600=!5632 (size of One Track)
$1E460 = !124000
!124000 / !5632 = 22,017
so I need !23 track, in hexa : $17
--

If I use a mulu to do the job, like : mulu #$1600,D0 before calling trackloader code, D0 becomes the good value (so 1FA00)
But... whith D0=1FA00 the AlphaOne Trackloader don't work.

It's start to read the tracks but seems stuck in the end in MFM decoding (stuck in loop searching #4489... not sure about this, but stuck in trackloader code).
and finaly, crash amiga.

Question... why ?
I try to sub D0 with 200, don't work
with 400, don't work
with B00 (alf of $1600), Work

Strange...

And I can't use (in my code) the real size directly in D0
MOVE.l #12345,D0 need 6 opcode, I don't have this space.

If anybody have the answer why this trackloader don't work with a multiple of $1600, i want it

Thks a lot

Last edited by Giants; 04 October 2018 at 12:08. Reason: Formarting Not good
Giants is offline  
Old 04 October 2018, 12:57   #2
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,251
If you post some binary someone could help you..
ross is offline  
Old 04 October 2018, 13:32   #3
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
I asume all people have or know the AlphaOne trackloader v2004 (404 byte)
But you right, here with the code is better


Code:
init:    
    move.w    $dff01c,oldintena
    move.w    $dff01e,oldintreq
    bset    #7,oldintena
    bset    #7,oldintreq
    move.w    #$7fff,$dff09a        ; interrupts aus.
    move.w    #$7fff,$dff09c        ; 

;****************************************************************
    lea    $dff000,a6
    lea    mfmbuffer,a2
    lea    buffer(pc),a0
    move.l    #4*$1600,d0
    moveq    #0,d1
    move.l    #0,d2
    jsr    TRACKLOADER

;****************************************************************

    move.w    oldintena(pc),$dff09a
    move.w    oldintreq(pc),$dff09c
    moveq    #0,d0
    rts

oldintena:    dc.w    0
oldintreq:    dc.w    0
buffer:        blk.b    130000,0
mfmbuffer:    blk.w    6400,0

; HARDWARE-DISKLOADER (c) ALPHA ONE 2004.
; EASY VERSION -> WITHOUT TRACKCOUNTER.
; ***************************************
; IN: A6=$DFF000
;     A2=MFMBUFFER.L
;     A0=BUFFER.L
;     D0=LENGTH.L        /!\ Length in BYTE
;     D1=TRACKNR.L       /!\ In TRACK, not in cylindre. Example : D1=6 Start to read from Track 06
;     D2=BYTEOFFSET.L    /!\ Offset in the Track. If in the start of the Track, so D2=0
;

TRACKLOADER:
        
        LEA    $BFD100,A4        ; DRIVESELECT REGISTER
        LEA    $BFE001,A5        ; DRIVESTATUS REGISTER
        MOVEQ    #0,D7            ; D7 = BYTECOUNTER
        ADD.L    D2,D0            ; BYTES TO READ + BYTEOFFSET

        MOVE.B    #$7D,(A4)        ; SWITCH MOTOR DRIVE 0 ON
        NOP                ; =======================
        NOP
        MOVE.B    #$75,(A4)
        BSR.W    DISKREADY

STEPHEADZERO:    BTST    #4,(A5)            ; MOVE HEADS TO CYLINDER 0
        BEQ.B    HEADONZERO        ; ========================
        BSET    #1,(A4)    
        BSET    #0,(A4)    
        NOP
        NOP
        BCLR    #0,(A4)
        NOP
        NOP
        BSET    #0,(A4)    
        BSR.W    DELAY
        BSR.W    DISKREADY
        BRA.B    STEPHEADZERO

HEADONZERO:    DIVS.W    #2,D1            ; GET CURRENT CYLINDER NUMBER
        SWAP    D1            ; ===========================
        TST.W    D1
        BEQ.B    CHOOSEHEADDOWN
        BCLR    #2,(A4)
        BRA.B    MOVEHEADS
CHOOSEHEADDOWN:    BSET    #2,(A4)

MOVEHEADS:    SWAP    D1            ; MOVE HEADS TO CORR. CYLINDER
MOVELOOP:    TST.B    D1            ; ============================
        BEQ.B    READTRACK
        BCLR    #1,(A4)    
        BSET    #0,(A4)    
        NOP
        NOP
        BCLR    #0,(A4)
        NOP
        NOP
        BSET    #0,(A4)    
        BSR.W    DELAY
        BSR.W    DISKREADY
        DBF    D1,MOVELOOP

READTRACK:    BSR.W    DISKREADY        ; READ TRACK
        MOVE.W    #$8210,$96(A6)        ; =================
        MOVE.W    #$7F00,$9E(A6)
        MOVE.W    #$8500,$9E(A6)
        MOVE.W    #$4489,$7E(A6)
        MOVE.W    #$4000,$24(A6)
        MOVE.L    A2,$20(A6)
        MOVE.W    #$9900,$24(A6)
        MOVE.W    #$9900,$24(A6)
        MOVE.W    #$2,$9C(A6)
TRACKREADY:    BTST    #1,$DFF01F
        BEQ.B    TRACKREADY
        MOVE.W    #$4000,$24(A6)

        MOVEQ    #0,D5            ; DECODE TRACK
DECODE:        MOVE.L    A2,A1            ; ============
        MOVE.L    #$55555555,D4
FINDSYNC:    CMP.W    #$4489,(A1)+
        BNE.B    FINDSYNC
        CMP.W    #$4489,(A1)
        BEQ.B    FINDSYNC
        MOVE.L    (A1),D3
        MOVE.L    4(A1),D1
        AND.L    D4,D3
        AND.L    D4,D1
        ASL.L    #1,D3
        OR.L    D1,D3
        ROR.L    #8,D3
        CMP.B    D5,D3
        BEQ.B    SECTORFOUND
        ADD.L    #1086,A1
        BRA.B    FINDSYNC
SECTORFOUND:    ADD.L    #56,A1
        MOVE.L    #(512/4)-1,D6
DECODESECTOR:    MOVE.L    512(A1),D1
        MOVE.L    (A1)+,D3
        AND.L    D4,D3
        AND.L    D4,D1
        ASL.L    #1,D3
        OR.L    D1,D3
        CMP.L    D7,D2
        BGT.B    BELOWOFFSET1
        SWAP    D3
        MOVE.W    D3,(A0)+
        SWAP    D3
BELOWOFFSET1:    ADDQ.L    #2,D7
        CMP.L    D7,D2
        BGT.B    BELOWOFFSET2
        MOVE.W    D3,(A0)+
BELOWOFFSET2:    ADDQ.L    #2,D7
        CMP.L    D7,D0
        BLE.W    READREADY
        DBF    D6,DECODESECTOR
        ADDQ.B    #1,D5
        CMP.B    #11,D5
        BNE.B    DECODE
        
TRACKDONE:    BTST    #2,(A4)            ; TRACK DONE, GET ONTO NEXT.
        BEQ.B    MOVECYLINDER        ; ==========================
        BCLR    #2,(A4)
        BRA.W    READTRACK
MOVECYLINDER:    BSET    #2,(A4)
        BCLR    #1,(A4)    
        BSET    #0,(A4)    
        NOP
        NOP
        BCLR    #0,(A4)
        NOP
        NOP
        BSET    #0,(A4)    
        BSR.W    DELAY
        BRA.W    READTRACK

READREADY:    MOVE.B    #$FD,(A4)        ; SWITCH MOTOR DRIVE 0 OFF
        NOP                ; ========================
        NOP
        MOVE.B    #$E7,(A4)
        RTS

DELAY:        MOVE.L    #$2500,D4        ; DELAY ROUTINE
WAIT:        DBF    D4,WAIT            ; =============
        RTS
        
DISKREADY:    BTST    #5,(A5)            ; WAIT FOR DISK-READY
        BNE.B    DISKREADY        ; ===================
        RTS

TRACKLOADERENDE:

; ============================================================================



Some modifications (for me) in this code, I don't use D2 so :

ADD.L D2,D0 become MOVE.L #0,D2
and I change the value of A2
but no matter.
Giants is offline  
Old 04 October 2018, 13:33   #4
Alpha One
Registered User
 
Join Date: Jun 2011
Location: Ger
Posts: 36
Quote:
Originally Posted by Giants View Post
Hi !

This version of Trackloader work with D0=size In byte to read

In a standard floppy where I put some Data, I use this version of trackloader to read it.
But...

My real size of data is $1E460
If D0=1E460 when I call the trackloader code, no problem, all work.

BUT... my real code work with 'count of track to read'
so for 1E460 of DATA I need to read $17

--
$1600=!5632 (size of One Track)
$1E460 = !124000
!124000 / !5632 = 22,017
so I need !23 track, in hexa : $17
--

If I use a mulu to do the job, like : mulu #$1600,D0 before calling trackloader code, D0 becomes the good value (so 1FA00)
But... whith D0=1FA00 the AlphaOne Trackloader don't work.

It's start to read the tracks but seems stuck in the end in MFM decoding (stuck in loop searching #4489... not sure about this, but stuck in trackloader code).
and finaly, crash amiga.

Question... why ?
I try to sub D0 with 200, don't work
with 400, don't work
with B00 (alf of $1600), Work

Strange...

And I can't use (in my code) the real size directly in D0
MOVE.l #12345,D0 need 6 opcode, I don't have this space.

If anybody have the answer why this trackloader don't work with a multiple of $1600, i want it

Thks a lot

Sounds strange but I'll have a look, too.
Btw. this was a really quick code and the loader is not very accurate or safe I think, there are dozens of better ones out there.

Last edited by Alpha One; 04 October 2018 at 13:38.
Alpha One is offline  
Old 04 October 2018, 14:06   #5
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
Ah ?

I have only a small space for him, maximum 430 Bytes
If you have other version that work better and don't exceeds 430 byte, I want it
(I have also other version of AlphaOne trackloader but who are bigger)

note : Not sure it's a D0 problem... maybe it's MFM size or adresss or other thing

Last edited by Giants; 04 October 2018 at 14:44.
Giants is offline  
Old 04 October 2018, 14:25   #6
Alpha One
Registered User
 
Join Date: Jun 2011
Location: Ger
Posts: 36
Hmmm I can't reproduce this bug here on Standard A1200, my tloader version is from 2005 but the code is nearly 100% identical.
https://www72.zippyshare.com/v/gGq0E5HE/file.html
Get the same error with this?
I tried also with $17 in d0 and mulu, no problems.
Alpha One is offline  
Old 04 October 2018, 15:00   #7
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
Try this : http://sasfepu78.ddns.net/tmp/In_progress.adf
I add a green screen after use JSR -1C8 in bootsector, just push button mouse to start the loaded code.

First call to AlphaOne trackloader is in $7A44E
Start load Data from Track 05 to cylinder 13 and... stuck
Enter AR, we are in 7C512 CMPI.W #4489,(A1)

And... strange, if we re-start the code by tapping in AR : G 7A44E
sometimes it's work...

But if you remove mulu and change the moveq #17,d0 by move.l #1E460,D0
It's work all the time

Last edited by Giants; 04 October 2018 at 15:06.
Giants is offline  
Old 04 October 2018, 15:24   #8
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
First thing you should do is adding a range check in the MFM decoding loop. That way you can easily see if the loaded data is OK or not. My guess is that the MFM buffer gets trashed for one reason or another.

Also, if you really need very small code you shouldn't add instructions which are much longer than the original ones (move.l #0,d2 *cough*).

What are you doing that you don't even have space for a simple move.l #xxxx,dx instruction?
StingRay is offline  
Old 04 October 2018, 15:40   #9
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
Create Old tuto for hacking old game
So I don't have any time the space to put a move.l
Giants is offline  
Old 04 October 2018, 15:46   #10
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,251
There was a reason because i've called for a binary..

Your MFM buffer: $76ebc
Destination: $58e44
Length: $1fa00

Ring a bell?
ross is offline  
Old 04 October 2018, 15:53   #11
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
Your MFM buffer: $76ebc
Destination: $58e44
Length: $1fa00

Yes, Right, this it.
And ? What's the problem ?

It's Working good with D0 in Long Word and no mulu in trackloadercode
and don't work with D0 in Track Number and mulu in trackloadercode

If they are a MFM buffer mistake, with or without mulu would don't work.

I think, I can get around this problem in creating a table of all adress I have for D0
And before call Trackloader, go through to this table to recover the good value for D0 in Byte
Giants is offline  
Old 04 October 2018, 16:02   #12
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,251
At some point you trash the MFM buffer, the $4489 search (without bound) fail and you have a CPU freerun.
[simple math: $58e44+$1fa00>$76ebc]
ross is offline  
Old 04 October 2018, 16:05   #13
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
Quote:
Originally Posted by Giants View Post
Your MFM buffer: $76ebc
Destination: $58e44
Length: $1fa00

Yes, Right, this it.
And ? What's the problem ?

It's Working good with D0 in Long Word and no mulu in trackloadercode
and don't work with D0 in Track Number and mulu in trackloadercode

If they are a MFM buffer mistake, with or without mulu would don't work.

I think, I can get around this problem in creating a table of all adress I have for D0
And before call Trackloader, go through to this table to recover the good value for D0 in Byte

$58e44+$1fa00= $78844... So my guess was correct. And I'm not sure you should write tutorials...

Edit: Ross was faster.
StingRay is offline  
Old 04 October 2018, 16:18   #14
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,251
Quote:
Originally Posted by StingRay View Post
So my guess was correct. And I'm not sure you should write tutorials...
Hi Sting
I had this feeling from the beginning, the things he has described carried in that direction.


Alpha One (hi!) had to brush up its old code, which is also deprecated

@Giants: why don't you write you own trackloader? It's a good exercise and so you can understand the inner working.
And it's fun too

Last edited by ross; 04 October 2018 at 16:36.
ross is offline  
Old 04 October 2018, 16:31   #15
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
I understand what you are saying but, the question 'original' question is :
Why I don't have this 'crash/don't woking issue' when I don't use mulu...

As you say it's simple math: $58e44+$1fa00>$76ebc
With or without mulu it should not be working !

This is not the case.
Without mulu, it's working !

Last edited by Giants; 04 October 2018 at 16:48.
Giants is offline  
Old 04 October 2018, 16:47   #16
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,251
Quote:
Originally Posted by Giants View Post
I understand what you are saying but, the question is :
Why I don't have this 'crash/don't woking issue' when I don't use mulu...

As you say it's simple math: $58e44+$1fa00>$76ebc
With or without mulu it should not be working !

This is not the case.
Without mulu, it's working !
It's random.
You have an MFM buffer of $1900*2 bytes from $76ebc, so up to $7a0bc, that is partly after the file buffer.
It depends on where the floppy head start to read on physical track if you crash or not.
Different code and timing make subtle differences.
(you've no idea, when you have to patch old code.. a few cycles differences make a production works no more)
ross is offline  
Old 04 October 2018, 16:54   #17
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 575
Quote:
Originally Posted by Giants View Post
I understand what you are saying but, the question is :
Why I don't have this 'crash/don't woking issue' when I don't use mulu...

As you say it's simple math: $58e44+$1fa00>$76ebc
With or without mulu it should not be working !

This is not the case.
Without mulu, it's working !
Earlier in the thread, you point out that when you don't use a mulu, you put a different (lower) number into D0 ($1e460 rather than $1fa00). This means much less of the buffer gets overwritten.

IMHO this explains everything: the MFM buffer contains the $4489 sync word(s) somewhere. Apparently, in this particular case the sync word(s) happen to only exist near the start of the buffer. As such, overwriting a larger part of the buffer can cause this problem by removing the sync words.

Edit: a bit late here it seems

--
However, I'd say it's not actually all that relevant why this buffer overwriting sometimes does and sometimes does not cause problems. The relevant problem here is that the buffer is overwritten to begin with.

Fix that and the problem will go away, mulu or no mulu.
roondar is offline  
Old 04 October 2018, 16:55   #18
Giants
Registered User
 
Join Date: Nov 2017
Location: france
Posts: 73
>You have a buffer of $1900*2 bytes from $76ebc, so up to $7a0bc, that is partly after the file buffer.
Yes, I already understand that.

>It's random.
...Not in my example, Always work with no Mulu
But maybe you said 'random' thinking general code.

If I reduced the size of MFM buffer, may it's work ?
But I think MFM buffer need to have a minimum value...

Humm, need to find another adress for MFM buffer

Add : yes, You totaly right roondar, ok, more clear.
I going to check all my call don't exceed the MFM buffer
and if yes, going to create a table before before calling trackloader.

Thank you all
Giants is offline  
Old 04 October 2018, 16:57   #19
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,251
Quote:
Originally Posted by Giants View Post
Humm, need to find another adress for MFM buffer
This
Or read data to max address as $76ebc.
ross is offline  
Old 04 October 2018, 21:27   #20
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
Quote:
@Giants: why don't you write you own trackloader? It's a good exercise and so you can understand the inner working.
And it's fun too
Hi Ross I completely agree here! Writing an own loader is indeed a good exercise and helps to avoid mistakes such as using a wrong location for the MFM buffer or it makes one adding certain checks to detect such problems easily. Another advantage is that own code can easily be tailor-made for special situations. And yes, it's fun too.
StingRay 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
REQ:ASM Trackloader spud Coders. Tutorials 9 16 August 2018 12:11
Juggler movie demo v2.0 BYTE by BYTE! TjLaZer support.Demos 3 30 November 2017 13:06
Google Search 404 error DH project.EAB 6 07 November 2017 16:52
Wonderful world trackloader demo dottyflowers request.Demos 1 23 May 2016 01:41
HOL -404 error- amigamemo HOL suggestions and feedback 2 21 March 2007 02:19

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:55.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.09893 seconds with 15 queries