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 cout1 = $FDF0 ;Outputs reg. A as char to screen ;strout = $DB3A ;Outputs AY-pointed null-terminated string keyin = $FD1B ;; rdkey = $FD0C str_hi = $F1 str_lo = $F0 ;############## Macros .macro pr addr ;Outputs string without CR/LF ;; ldy #>addr lda #addr sta str_hi jsr my_puts ;; jsr strout .endmacro .org $800 .byt 1 ; ldx #$40 ; stx $43 ; x is slot*16 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 ldx $43 ; slot*16 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 pr 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 ora #$80 jsr cout1 lda #$A0 jsr cout1 jsr cout1 ldy #12 ; point after the name lda #0 sta ($FC),y lda $fc sta str_lo lda $fd sta str_hi jsr my_puts lda #$8d jsr cout1 inc $fe lda $fc clc adc #32 sta $fc bcc more inc $fd ; second half lda #$0C cmp $fd ; if more than $0B bne more ; then done beq done error: pr err_str brk done: pr 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 my_puts: ldy #0 L1: lda (str_lo),y beq eol ora #$80 jsr cout1 inc str_lo bne L1 inc str_hi bne L1 eol: rts err_str: .byt "error", $0D, $00 ok_str: .byt "OK", $0D, $00 fat_str: .byt "FAT DIRECTORY: ",$0D,$0D, $00 sel_str: .byt $0D, "SELECT. SPACE FOR MORE", $0D, $00