forked from Apple-2-HW/Apple2-IO-RPi
182 lines
6.9 KiB
Plaintext
182 lines
6.9 KiB
Plaintext
ca65 V2.18 - N/A
|
|
Main file : CommandFirmware.asm
|
|
Current file: CommandFirmware.asm
|
|
|
|
000000r 1 ;ProDOS Zero Page
|
|
000000r 1 Command = $42 ;ProDOS Command
|
|
000000r 1 Unit = $43 ;ProDOS unit (SDDD0000)
|
|
000000r 1 BufferLo = $44
|
|
000000r 1 BufferHi = $45
|
|
000000r 1 BlockLo = $46
|
|
000000r 1 BlockHi = $47
|
|
000000r 1
|
|
000000r 1 ; ProDOS Error Codes
|
|
000000r 1 IOError = $27
|
|
000000r 1 NoDevice = $28
|
|
000000r 1 WriteProtect = $2B
|
|
000000r 1
|
|
000000r 1 InputByte = $c08e+SLOT*$10
|
|
000000r 1 OutputByte = $c08d+SLOT*$10
|
|
000000r 1 InputFlags = $c08b+SLOT*$10
|
|
000000r 1 OutputFlags = $c087+SLOT*$10
|
|
000000r 1
|
|
000000r 1 ReadBlockCommand = $01
|
|
000000r 1 WriteBlockCommand = $02
|
|
000000r 1 GetTimeCommand = $03
|
|
000000r 1 ChangeDriveCommand = $04
|
|
000000r 1 ExecCommand = $05
|
|
000000r 1 LoadFileCommand = $06
|
|
000000r 1 SaveFileCommand = $07
|
|
000000r 1 MenuCommand = $08
|
|
000000r 1
|
|
000000r 1 InputString = $fd67
|
|
000000r 1 PrintChar = $fded
|
|
000000r 1
|
|
000000r 1 .org SLOT*$100 + $C000
|
|
00C700 1 ;ID bytes for booting and drive detection
|
|
00C700 1 E0 20 cpx #$20 ;ID bytes for ProDOS and the
|
|
00C702 1 E0 00 cpx #$00 ; Apple Autostart ROM
|
|
00C704 1 E0 03 cpx #$03 ;
|
|
00C706 1
|
|
00C706 1 A2 70 ldx #SLOT*$10
|
|
00C708 1 86 2B stx $2b
|
|
00C70A 1 86 43 stx Unit
|
|
00C70C 1
|
|
00C70C 1 ;force EPROM to second page on boot
|
|
00C70C 1 A9 3F lda #$3f ;set all flags high and page 3 of EPROM for menu
|
|
00C70E 1 PageJump:
|
|
00C70E 1 8D F7 C0 sta OutputFlags
|
|
00C711 1 4C 19 C7 jmp Start ;this jump is only called if coming in from PageJump with A=$2f
|
|
00C714 1
|
|
00C714 1 ;entry points for ProDOS
|
|
00C714 1 DriverEntry:
|
|
00C714 1 A9 0F lda #$0f ;set all flags high and page 0 of EPROM
|
|
00C716 1 8D F7 C0 sta OutputFlags
|
|
00C719 1
|
|
00C719 1 Start:
|
|
00C719 1 20 00 C3 jsr $c300 ;enable 80 columns
|
|
00C71C 1 A9 05 lda #$05 ;execute command
|
|
00C71E 1 20 7D C7 jsr SendByte
|
|
00C721 1 A0 00 ldy #$00
|
|
00C723 1 sendHelp:
|
|
00C723 1 B9 76 C7 lda HelpCommand,y
|
|
00C726 1 F0 06 beq endSendHelp
|
|
00C728 1 20 7D C7 jsr SendByte
|
|
00C72B 1 C8 iny
|
|
00C72C 1 D0 F5 bne sendHelp
|
|
00C72E 1 endSendHelp:
|
|
00C72E 1 A9 00 lda #$00
|
|
00C730 1 20 7D C7 jsr SendByte
|
|
00C733 1 20 68 C7 jsr DumpOutput
|
|
00C736 1
|
|
00C736 1 A5 33 lda $33
|
|
00C738 1 48 pha
|
|
00C739 1 A9 A4 lda #$a4
|
|
00C73B 1 85 33 sta $33
|
|
00C73D 1 GetCommand:
|
|
00C73D 1 20 67 FD jsr InputString
|
|
00C740 1 AD 00 02 lda $0200
|
|
00C743 1 C9 8D cmp #$8d ;skip when return found
|
|
00C745 1 F0 F6 beq GetCommand
|
|
00C747 1 20 4D C7 jsr SendCommand
|
|
00C74A 1 18 clc
|
|
00C74B 1 90 F0 bcc GetCommand
|
|
00C74D 1
|
|
00C74D 1 SendCommand:
|
|
00C74D 1 A9 05 lda #$05 ;send command 5 = exec
|
|
00C74F 1 20 7D C7 jsr SendByte
|
|
00C752 1 A0 00 ldy #$00
|
|
00C754 1 getInput:
|
|
00C754 1 B9 00 02 lda $0200,y
|
|
00C757 1 C9 8D cmp #$8d
|
|
00C759 1 F0 08 beq sendNullTerminator
|
|
00C75B 1 29 7F and #$7f
|
|
00C75D 1 20 7D C7 jsr SendByte
|
|
00C760 1 C8 iny
|
|
00C761 1 D0 F1 bne getInput
|
|
00C763 1 sendNullTerminator:
|
|
00C763 1 A9 00 lda #$00
|
|
00C765 1 20 7D C7 jsr SendByte
|
|
00C768 1 DumpOutput:
|
|
00C768 1 20 9B C7 jsr GetByte
|
|
00C76B 1 C9 00 cmp #$00
|
|
00C76D 1 F0 06 beq endOutput
|
|
00C76F 1 20 ED FD jsr PrintChar
|
|
00C772 1 18 clc
|
|
00C773 1 90 F3 bcc DumpOutput
|
|
00C775 1 endOutput:
|
|
00C775 1 60 rts
|
|
00C776 1
|
|
00C776 1 HelpCommand:
|
|
00C776 1 61 32 68 65 .byte "a2help",$00
|
|
00C77A 1 6C 70 00
|
|
00C77D 1
|
|
00C77D 1 SendByte:
|
|
00C77D 1 48 pha
|
|
00C77E 1 waitWrite:
|
|
00C77E 1 AD FB C0 lda InputFlags
|
|
00C781 1 2A rol
|
|
00C782 1 2A rol
|
|
00C783 1 B0 F9 bcs waitWrite
|
|
00C785 1 68 pla
|
|
00C786 1 8D FD C0 sta OutputByte
|
|
00C789 1 A9 1E lda #$1e ; set bit 0 low to indicate write started
|
|
00C78B 1 8D F7 C0 sta OutputFlags
|
|
00C78E 1 finishWrite:
|
|
00C78E 1 AD FB C0 lda InputFlags
|
|
00C791 1 2A rol
|
|
00C792 1 2A rol
|
|
00C793 1 90 F9 bcc finishWrite
|
|
00C795 1 A9 1F lda #$1f
|
|
00C797 1 8D F7 C0 sta OutputFlags
|
|
00C79A 1 60 rts
|
|
00C79B 1
|
|
00C79B 1 GetByte:
|
|
00C79B 1 A9 1D lda #$1d ;set read flag low
|
|
00C79D 1 8D F7 C0 sta OutputFlags
|
|
00C7A0 1 waitRead:
|
|
00C7A0 1 AD FB C0 lda InputFlags
|
|
00C7A3 1 2A rol
|
|
00C7A4 1 B0 FA bcs waitRead
|
|
00C7A6 1 AD FE C0 lda InputByte
|
|
00C7A9 1 48 pha
|
|
00C7AA 1 A9 1F lda #$1f ;set all flags high
|
|
00C7AC 1 8D F7 C0 sta OutputFlags
|
|
00C7AF 1 finishRead:
|
|
00C7AF 1 AD FB C0 lda InputFlags
|
|
00C7B2 1 2A rol
|
|
00C7B3 1 90 FA bcc finishRead
|
|
00C7B5 1 68 pla
|
|
00C7B6 1 end:
|
|
00C7B6 1 60 rts
|
|
00C7B7 1
|
|
00C7B7 1 00 00 00 00 .repeat 247-<end
|
|
00C7BB 1 00 00 00 00
|
|
00C7BF 1 00 00 00 00
|
|
00C7C3 1 00 00 00 00
|
|
00C7C7 1 00 00 00 00
|
|
00C7CB 1 00 00 00 00
|
|
00C7CF 1 00 00 00 00
|
|
00C7D3 1 00 00 00 00
|
|
00C7D7 1 00 00 00 00
|
|
00C7DB 1 00 00 00 00
|
|
00C7DF 1 00 00 00 00
|
|
00C7E3 1 00 00 00 00
|
|
00C7E7 1 00 00 00 00
|
|
00C7EB 1 00 00 00 00
|
|
00C7EF 1 00 00 00 00
|
|
00C7F3 1 00 00 00 00
|
|
00C7F7 1 00
|
|
00C7F8 1 .byte 0
|
|
00C7F8 1 .endrepeat
|
|
00C7F8 1
|
|
00C7F8 1 9B .byte <GetByte ;all firmware pages have pointer to GetByte routine here
|
|
00C7F9 1 C7 .byte >GetByte
|
|
00C7FA 1 7D .byte <SendByte ;all firmware pages have pointer to SendByte routine here
|
|
00C7FB 1 C7 .byte >SendByte
|
|
00C7FC 1
|
|
00C7FC 1 00 00 .byte 0,0 ;0000 blocks = check status
|
|
00C7FE 1 07 .byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
|
|
00C7FF 1 14 .byte DriverEntry&$00FF ;low byte of entry
|
|
00C7FF 1
|