Re: Format sequence
Date: 2006-05-14 20:56:29

Hallo Spiro,

> My bet: You forgot point 2.

My first thought was, you win the bet. But unfortunately for both of us, 
you don't. 

> Anyway, the write routine ($F56E) goes as follows:

The NEW command starts at $EE0D. 
At $EE3D you find the 'FormatFloppy' routine. 
At $EE40 a subroutine at $F005 is called.
At $F005 a subroutine at $EF3A is called.
At $EF3E you find the 'ReadBAM' routine [F0DF]. This routine does some 
things and at $F107 it jumps to $D586. There the code $80 is given to read 
a sector. At $D599 the routine is waiting until the job is finished. And it 
is the IRQ routine that should handle this job.

So there is a read before the actual write first. And second, the $90 code 
for writing is inserted by the same routine that inserted the read code in 
the job table. 

I started looking for the part that does the actual reading and that part 
starts at $F4CA. So I started to look for that part that jumps, branches or 
whatever to this address and ended up with the following piece of code 
which is a part of the IRQ routine.

J_F423		lda	#$7F
		sta	CSECT
		lda	HDRSEC
		adc	#$02
		cmp	SECCNT
		bcc	B_F432

		sbc	SECCNT
B_F432		sta	NEXTS
		ldx	#$05
		stx	JOBN
		ldx	#$FF        [3]

B_F43A		jsr	InitPntr2Buf	; set buffer pointer for disk controller
		bpl	B_F483

		sta	WORK
		and	#$01
		cmp	CURDRV
		bne	B_F483

		ldy	#$00
		lda	(HDRPNT),Y
		cmp	TRACC
		bne	B_F483

		lda	JOB		; command code
		cmp	#$60
		beq	B_F461

		ldy	#$01
		lda	(HDRPNT),Y
		sbc	NEXTS
		bpl	B_F461

		adc	SECCNT
B_F461		cmp	CSECT
		bcs	B_F483

		lda	JOB
		beq	B_F47E

		cmp	#$09
		bcc	B_F483

		cmp	#$0C
		bcs	B_F483

B_F473		sta	CSECT
		lda	JOBN
		adc	#$03
		sta	BUFPNT+1
		bne	B_F483

B_F47E		pla
		cmp	#$06
		bcc	B_F473

B_F483		dec	JOBN
		bpl	B_F43A         [1]

		txa               [2]
		bpl	B_F48D

		jmp	LoopDiskCntrl	; to job loop

B_F48D		stx	JOBN
		jsr	InitPntr2Buf	; get buffer number
		lda	JOB		; command code
		jmp	J_F4CA		; continue checking

The part that leads to $F4CA is only accessed when JOBN = $FF (see [1]) and 
0<=X<128. The routine InitPntr2Buf at $F43A puts the job code in A. The 
problem in my case is that the jobcode $80 is found when JOBN = 4. So the 
BPL at [2] is taken.
When JOBN = 0 nothing is found and X is filled with $FF (see [3]). So at 
[2] the Negative flag is set and the BPL following TXA is not taken.

So at the end nothing is done and at the next interrupt everything starts 
over again. Question: why is the $80 code placed in the table at place 4 
and not 0? This is what I'm going to find out now. But I first wanted to 
share these findings first. (and also hoping that the above triggers a bell 
or an AHA-Erlebnis (don't know the English word, don't even know the Dutch 

   / __|__
  / /  |_/     Groetjes, Ruud
  \ \__|_\

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.