[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New firmware for PseudoDisk / some problems



The good news is I have new firmware that allows writing images to an SD
card
on top of the FAT16.

The bad news is that there is a bug I can't figure out yet.

The new scheme works like this. Volume images are copied as files under
FAT16
to the (BLANK!) media. Can be done on just about any computer: Windos, MAC
or Linux.
The images are contiguous.
Depending on the DIP switch on the board one of 3 boot methods is used:
1. Revert to old raw images (no FAT).
2. Get the first file on the card and boot it as a ProDOS volume.
3. Boot a tiny program that displays a directory and lets select one image.

Method 2 works great. I have a 32 MB image that boots ProDOS in about a
second on a 2e.
The problem is with method 3. The boot sector contains a program that loads
one by one
blocks that contain the FAT root directory at $a00 and lists 16 at a time
with a letter in front.
If the letter is pressed on the keyboard, a command is sent to the AVR to
use an image by that
number.

It works fine if I start it from the monitor. But not as a part of a boot
process.
If I have another disk card in a higher slot, I can do a reset and get to
basic.
My card is in the slot 4. I type "C400G" and everything works fine.
However if I type 4^P or PR #4 or just let it  boot with no other disk
cards,
it hangs.
Must be something stupid. Any ideas, anyone? What is so different between
C400G and 4-ctrl-P ?

Here's the source.
-------------------

pd_command =     $42     ;ProDOS command
unit    =     $43     ;7=drive 6-4=slot 3-0=not used
buflo   =     $44     ;low address of buffer
bufhi   =     $45     ;hi address of buffer
blklo   =     $46     ;low block
blkhi   =     $47     ;hi block
ioerr   =     $27     ;I/O error code
nodev   =     $28     ;no device connected
wperr   =     $2B     ;write protect error

;############## Apple ROM useful routines

home = $FC58 ;Clear screen
crout = $FD8B ;Outputs a CR/LF
prlf = $FC66   ;Outputs a LF
cout = $FDED ;Outputs reg. A as char
clrscr = $F832
strout = $DB3A ;Outputs AY-pointed null-terminated string
prax = $F941 ;Outputs AX as 4 hex digits
pra = $FDDA ;Outputs A as 2 hex digits
prspc = $DB57 ;Outputs 1 space char
prblnk = $F948  ;  print 3 spaces
keyin = $FD1B
rdkey = $FD0C

;############## Macros

.macro pr addr  ;Outputs string without CR/LF
 ldy #>addr
 lda #<addr
 jsr strout
.endmacro

.macro prln addr ;Outputs string with CR/LF
 pr addr
 jsr crout
.endmacro



 .org $800

 .byt 1
 txa
 lsr
 lsr
 lsr
 lsr
 ora #$c0  ;  a=c4 for slot 4
 sta $49
 ldy #$ff
 sty $48
 iny
 lda ($48),Y  ;  a points to driver entry
 sta $48

 lda #$8  ;  change origin command
 ldx $43  ;  slot*16
 sta $C08D,x
 lda #$55  ;  set to FAT root directory
 sta $C08D,x

again:
 lda #0
 sta blklo
next:
 lda #0
 sta blkhi
 sta buflo
 lda #$0a
 sta bufhi

 lda #1
 sta pd_command ; read command

 jsr do_call  ;  read directory block into $0A00
 bcs error

  ;;  jsr home
 prln fat_str
 jsr prlf


 lda #$41  ; first letter
 sta $fe

 ldy #$0A
 sty $fd
 lda #0
 sta $fc  ; FC points to entry
more:
 ldy #0
 lda ($fc),y
 beq done
 lda $fe
 jsr $FDED
 jsr prblnk
 ldy #12  ;  point after the name
 lda #0
 sta ($FC),y
 lda $fc
 ldy $fd
 jsr strout
 jsr crout
 inc $fe
 lda $fc
 clc
 adc #32
 sta $fc
 bcc more
 inc $fd
 bne more

 brk

error:
 pr err_str
 brk


done:
 jsr prlf
 jsr prlf
 prln sel_str

select:
 jsr rdkey
 and #$7f
 cmp #$31
 bne not_again
 jmp again

not_again:
 cmp #$20
 bne not_next
 inc blklo
 jmp next
not_next:
 cmp #$41
 bcs not_under
 jsr $FF3A  ; bell
 jmp select

not_under:
 cmp $fe
 bcc not_over
 jsr $FF3A  ; bell
 jmp select

not_over:
 ldx $43  ;  slot*16
 sta $C08D,x
 pr ok_str
 lda #0
 sta $48  ;  49-48 now points to Cx00
 ;; and fall through to boot

do_call:
 jmp ($48)
 rts


err_str:
 .byt    "error", $0D, $00


ok_str:
 .byt    "OK", $0D, $00

fat_str:
 .byt "FAT DIRECTORY: ",$0D,$0D, $00

sel_str: .byt "SELECT. SPACE FOR MORE", $0D, $00



-- 
-Alex.