OK, I decided to put on hold my project of getting EhBASIC running on an LCD screen.
The good news is that my LCD screen still works as a "secondary" display and I built a simple 65C51 board and now I have serial working.
I know the 65C51 is a bad word around here. But it's all I had/have at the moment. I don't plan on sticking with it long term.
Anyway, I have it working and now I can enter BASIC programs. However, I have to press the ENTER key twice on everything.
For example, if I type "LIST" and press ENTER, I get a new line and that's all. Pressing it a second time actually executes the LIST.
Also, I have the following test program:
Code:
10 FOR A=1 to 10
20 PRINT A
30 NEXT A
This works. BUT...I have to press ENTER each iteration of A! It's like I have to "ENTER" each line of BASIC before it works as it's running.
Here is what I have running so far...any pointers is more than appreciated.
MON.ASM
Code:
.debuginfo +
.setcpu "65C02"
VIA := $6000
PB := VIA
PA := VIA + 1
DDRB := VIA + 2
DDRA := VIA + 3
ESC = $1B ; Escape character
CR = $0D ; Return character
LF = $0A ; Line feed character
IRQ_vec = VEC_SV + 2 ; IRQ code vector
NMI_vec = IRQ_vec + $0A ; NMI code vector
.include "EhBASIC.asm"
.include "lcd.asm"
.include "pckybd.asm"
.include "acia.asm"
.include "utils.asm"
;-------------------------------------------------------------------------------
; Main RESET Vector (ROM Startup)
;-------------------------------------------------------------------------------
.segment "CODE"
.org $8000
RES_vec:
CLD ; clear decimal mode
LDX #$FF ; empty stack
TXS ; set the stack
JSR INITS
LDY #END_CODE - LAB_vec ; set index/count
LAB_stlp:
LDA LAB_vec - 1, Y ; get byte from interrupt code
STA VEC_IN - 1, Y ; save to RAM
DEY ; decrement index/count
BNE LAB_stlp ; loop if more to do
LAB_signon:
LDA LAB_mess, Y ; get byte from sign on message
BEQ LAB_nokey ; exit loop if done
JSR V_OUTP ; output character
INY ; increment index
BNE LAB_signon ; loop, branch always
LAB_nokey:
JSR V_INPT ; call scan input device
BCC LAB_nokey ; loop if no key
AND #$DF ; mask xx0x xxxx, ensure upper case
CMP #'W' ; compare with [W]arm start
BEQ LAB_dowarm ; branch if [W]arm start
CMP #'C' ; compare with [C]old start
BNE RES_vec ; loop if not [C]old start
JMP LAB_COLD ; do EhBASIC cold start
LAB_dowarm:
JMP LAB_WARM ; do EhBASIC warm start
ACIAout:
CMP #LF ; Ignore line feed character
BEQ Ignore
WaitForReady:
BIT RXDATA
BMI WaitForReady
JSR ECHO
Ignore:
RTS
ACIAin:
JSR GetKey
BEQ LAB_nobyw
AND #$7F ; clear high bit
SEC ; flag byte received
RTS
LAB_nobyw
CLC ; flag no byte received
RTS
LOAD:
SAVE:
RTS
MAIN:
JMP MAIN
;-------------------------------------------------------------------------------
; System Initializations
;-------------------------------------------------------------------------------
INITS:
; Set on-board VIA data direction registers
LDA #$FF
STA DDRA ; PORT A is all output
STA DDRB ; PORT B is all output
JSR LCD_INIT ; Initialize the LCD module
LDX #<LINE1 ; Print the 4 line startup message
LDY #>LINE1
JSR PrintString
LDX #<LINE3
LDY #>LINE3
JSR PrintString
LDA #$40
JSR LCD_SET_DRAM_ADDRESS
LDX #<LINE2
LDY #>LINE2
JSR PrintString
LDX #<LINE4
LDY #>LINE4
JSR PrintString
; JSR kbinit ; Initialize the keyboard
JSR INIT_ACIA
RTS
;-------------------------------------------------------------------------------
; PRINT CHAR TO LCD FROM KEYBOARD INPUT
;-------------------------------------------------------------------------------
DISPout:
STA PA
JSR LCD_WRITE
RTS
;-------------------------------------------------------------------------------
; Print a string
;-------------------------------------------------------------------------------
; Pass address of string in X (low) and Y (high).
; String must be terminated with a null.
; Cannot be longer than 256 characters.
; Registers changed: A, Y
;-------------------------------------------------------------------------------
PrintString:
STX LCDpl
STY LCDpl + 1
LDY #0
@loop: LDA (LCDpl), Y
BEQ done
JSR DISPout
INY
BNE @loop ; if doesn't branch, string is too long
done: RTS
;-------------------------------------------------------------------------------
; Sends A to LCD screen at current cursor position
;-------------------------------------------------------------------------------
WriteLCD:
STA PA
JSR LCD_WRITE
RTS
LAB_vec
.word ACIAin ; byte in from simulated ACIA
.word ACIAout ; byte out to simulated ACIA
.word LOAD ; load vector for EhBASIC
.word SAVE ; save vector for EhBASI
END_CODE
;-------------------------------------------------------------------------------
; MESSAGES
;-------------------------------------------------------------------------------
LAB_mess
.byte $0D,$0A,"6502 EhBASIC [C]old/[W]arm ?", $00
LINE1:
.byte "********************", $00
LINE2:
.byte " Potpourri6502 ", $00
LINE3:
.byte " ", $00
LINE4:
.byte "********************", $00
;NMI_vec:
;IRQ_vec:
; RTS
;-------------------------------------------------------------------------------
; Startup Vectors
;-------------------------------------------------------------------------------
.segment "VECTORS"
.word NMI_vec ; NMI Vector
.word RES_vec ; RESET Vector
.word IRQ_vec ; IRQ Vector
;-------------------------------------------------------------------------------
; EOF
;-------------------------------------------------------------------------------
ACIA.ASM
Code:
.segment "SERIAL"
MSGL = $ED
MSGH = $EE
ACIA := $5800
ACIA_CTRL := ACIA + 3
ACIA_CMD := ACIA + 2
ACIA_SR := ACIA + 1
ACIA_DAT := ACIA
TXDATA := ACIA
RXDATA := ACIA
INIT_ACIA:
CLD ; Clear decimal arithmetic mode.
CLI
PHA ; Push A to stack
LDA #$1F ; ACIA to 19200 Baud.
STA ACIA_CTRL
LDA #$0B ; No Parity.
STA ACIA_CMD
LDA #$0D
JSR ECHO ; New line.
LDA #<MSG1 ; Setup and print welcome message
STA MSGL
LDA #>MSG1
STA MSGH
JSR SHWMSG ; Show Welcome.
LDA #$0D
JSR ECHO ; New line.
PLA ; Restore A
RTS
ECHO:
PHA ;*Save A
AND #$7F ;*Change to "standard ASCII"
STA ACIA_DAT ;*Send it.
JSR DELAY1
PLA ; Restore A
RTS
; Read character from serial port and return in A
GetKey:
LDA #$08
RXFULL: BIT ACIA_SR
BEQ RXFULL
LDA RXDATA
AND #%01111111
RTS
SHWMSG:
LDY #0
@PRINT:
LDA (MSGL), Y
BEQ @DONE
JSR ECHO
INY
BNE @PRINT
@DONE
RTS
MSG1:
.byte "Welcome to Potpourri6502...", 0