ca65 V2.17 - Raspbian 2.17-1 Main file : Shell.asm Current file: Shell.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 ; hard code slot to 7 for now, will make it auto-detect later 000000r 1 SLOT = 7 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 ShellCommand = $09 000000r 1 000000r 1 InputString = $fd6a 000000r 1 StringBuffer = $0200 000000r 1 PrintChar = $fded 000000r 1 Keyboard = $c000 000000r 1 ClearKeyboard = $c010 000000r 1 Home = $fc58 000000r 1 Wait = $fca8 000000r 1 PromptChar = $33 000000r 1 htab = $24 000000r 1 vtab = $25 000000r 1 000000r 1 ESC = $9b 000000r 1 000000r 1 .org $2000 002000 1 Start: 002000 1 20 00 C3 jsr $c300 ; force 80 columns 002003 1 2C 10 C0 bit ClearKeyboard 002006 1 A9 09 lda #ShellCommand 002008 1 20 74 20 jsr SendByte 00200B 1 20 0F 20 jsr DumpOutput 00200E 1 60 rts 00200F 1 00200F 1 DumpOutput: 00200F 1 20 92 20 jsr GetByte 002012 1 B0 1E bcs checkInput 002014 1 C9 00 cmp #$00 002016 1 F0 2D beq endOutput 002018 1 C9 48 cmp #'H' 00201A 1 F0 30 beq setColumn 00201C 1 C9 56 cmp #'V' 00201E 1 F0 37 beq setRow 002020 1 C9 43 cmp #'C' 002022 1 F0 22 beq clearScreen 002024 1 C9 54 cmp #'T' 002026 1 F0 3C beq setTop 002028 1 C9 42 cmp #'B' 00202A 1 F0 40 beq setBottom 00202C 1 20 ED FD jsr PrintChar 00202F 1 4C 0F 20 jmp DumpOutput 002032 1 checkInput: 002032 1 2C 00 C0 bit Keyboard ;check for keypress 002035 1 10 D8 bpl DumpOutput ;keep dumping output if no keypress 002037 1 AD 00 C0 lda Keyboard ;send keypress to RPi 00203A 1 29 7F and #$7f 00203C 1 20 74 20 jsr SendByte 00203F 1 2C 10 C0 bit ClearKeyboard 002042 1 4C 0F 20 jmp DumpOutput 002045 1 endOutput: 002045 1 60 rts 002046 1 clearScreen: 002046 1 20 58 FC jsr Home 002049 1 4C 0F 20 jmp DumpOutput 00204C 1 setColumn: 00204C 1 20 92 20 jsr GetByte 00204F 1 85 24 sta htab 002051 1 8D 7B 05 sta $057B 002054 1 4C 0F 20 jmp DumpOutput 002057 1 setRow: 002057 1 20 92 20 jsr GetByte 00205A 1 85 25 sta vtab 00205C 1 20 C1 FB jsr $fbc1 ; bascalc 00205F 1 85 28 sta $28 ;basl 002061 1 4C 0F 20 jmp DumpOutput 002064 1 setTop: 002064 1 20 92 20 jsr GetByte 002067 1 85 22 sta $22 002069 1 4C 0F 20 jmp DumpOutput 00206C 1 setBottom: 00206C 1 20 92 20 jsr GetByte 00206F 1 85 23 sta $23 002071 1 4C 0F 20 jmp DumpOutput 002074 1 002074 1 SendByte: 002074 1 48 pha 002075 1 waitWrite: 002075 1 AD FB C0 lda InputFlags 002078 1 2A rol 002079 1 2A rol 00207A 1 B0 F9 bcs waitWrite 00207C 1 68 pla 00207D 1 8D FD C0 sta OutputByte 002080 1 A9 1E lda #$1e ; set bit 0 low to indicate write started 002082 1 8D F7 C0 sta OutputFlags 002085 1 finishWrite: 002085 1 AD FB C0 lda InputFlags 002088 1 2A rol 002089 1 2A rol 00208A 1 90 F9 bcc finishWrite 00208C 1 A9 1F lda #$1f 00208E 1 8D F7 C0 sta OutputFlags 002091 1 60 rts 002092 1 002092 1 GetByte: 002092 1 A9 1D lda #$1d ;set read flag low 002094 1 8D F7 C0 sta OutputFlags 002097 1 waitRead: 002097 1 AD FB C0 lda InputFlags 00209A 1 2A rol 00209B 1 90 0C bcc readByte 00209D 1 2C 00 C0 bit Keyboard ;keypress will abort waiting to read 0020A0 1 10 F5 bpl waitRead 0020A2 1 A9 1F lda #$1f ;set all flags high and exit 0020A4 1 8D F7 C0 sta OutputFlags 0020A7 1 38 sec ;failure 0020A8 1 60 rts 0020A9 1 readByte: 0020A9 1 AD FE C0 lda InputByte 0020AC 1 48 pha 0020AD 1 A9 1F lda #$1f ;set all flags high 0020AF 1 8D F7 C0 sta OutputFlags 0020B2 1 finishRead: 0020B2 1 AD FB C0 lda InputFlags 0020B5 1 2A rol 0020B6 1 90 FA bcc finishRead 0020B8 1 68 pla 0020B9 1 18 clc ;success 0020BA 1 end: 0020BA 1 60 rts 0020BB 1 0020BB 1 HelpCommand: 0020BB 1 61 32 68 65 .byte "a2help",$00 0020BF 1 6C 70 00 0020C2 1 PromptCommand: 0020C2 1 61 32 70 72 .byte "a2prompt",$00 0020C6 1 6F 6D 70 74 0020CA 1 00 0020CB 1 OldPromptChar: 0020CB 1 5D .byte "]" 0020CC 1