Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ But if you're following along with earlier videos, the "code" link below will ta
| | Video | Code |
|--------------------------------|----------------------------------------------------------|--------------------|
| ![Video thumbnail][thumbnail1] | [Running MSBASIC on my breadboard 6502 computer][video1] | [a15c8e0][commit1] |
| ![Video thumbnail][thumbnail2] | [How input buffering works][video2] | [54ef9ac][commit2] |
| ![Video thumbnail][thumbnail3] | [RS232 flow control][video3] | [master][commit3] |
| ![Video thumbnail][thumbnail2] | [How input buffering works][video2] | [54ef9ac][commit2] |
| ![Video thumbnail][thumbnail2] | [RS232 flow control][video3] | [c21542e][commit3] |
| ![Video thumbnail][thumbnail4] | [Hacking Microsoft BASIC][video4] | [master][commit4] |

[thumbnail1]: https://i.ytimg.com/vi/XlbPnihCM0E/mqdefault.jpg
[video1]: https://youtu.be/XlbPnihCM0E
Expand All @@ -22,7 +23,11 @@ But if you're following along with earlier videos, the "code" link below will ta

[thumbnail3]: https://i.ytimg.com/vi/LuKMVXWD7FY/mqdefault.jpg
[video3]: https://youtu.be/LuKMVXWD7FY
[commit3]: https://github.com/beneater/msbasic/tree/master
[commit3]: https://github.com/beneater/msbasic/tree/c21542e724b3da45ba3790405c2cf85e77bc1ad4

[thumbnail4]: https://i.ytimg.com/vi/gOwi2p1pzVM/mqdefault.jpg
[video4]: https://youtu.be/gOwi2p1pzVM
[commit4]: https://github.com/beneater/msbasic/tree/master

Below is the original README:

Expand Down
3 changes: 3 additions & 0 deletions init.s
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ COLD_START:
lda #WIDTH2
sta Z18
.endif
.ifdef EATER
jsr LCDINIT
.endif
.endif

; All non-CONFIG_SMALL versions of BASIC have
Expand Down
149 changes: 149 additions & 0 deletions lcd.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
.segment "CODE"
.ifdef EATER
PORTB = $6000
DDRB = $6002
E = %01000000
RW = %00100000
RS = %00010000

lcd_wait:
pha
lda #%11110000 ; LCD data is input
sta DDRB
lcdbusy:
lda #RW
sta PORTB
lda #(RW | E)
sta PORTB
lda PORTB ; Read high nibble
pha ; and put on stack since it has the busy flag
lda #RW
sta PORTB
lda #(RW | E)
sta PORTB
lda PORTB ; Read low nibble
pla ; Get high nibble off stack
and #%00001000
bne lcdbusy

lda #RW
sta PORTB
lda #%11111111 ; LCD data is output
sta DDRB
pla
rts

LCDINIT:
lda #$ff ; Set all pins on port B to output
sta DDRB

lda #%00000011 ; Set 8-bit mode
sta PORTB
ora #E
sta PORTB
and #%00001111
sta PORTB

lda #%00000011 ; Set 8-bit mode
sta PORTB
ora #E
sta PORTB
and #%00001111
sta PORTB

lda #%00000011 ; Set 8-bit mode
sta PORTB
ora #E
sta PORTB
and #%00001111
sta PORTB

; Okay, now we're really in 8-bit mode.
; Command to get to 4-bit mode ought to work now
lda #%00000010 ; Set 4-bit mode
sta PORTB
ora #E
sta PORTB
and #%00001111
sta PORTB

lda #%00101000 ; Set 4-bit mode; 2-line display; 5x8 font
jsr lcd_instruction
lda #%00001110 ; Display on; cursor on; blink off
jsr lcd_instruction
lda #%00000110 ; Increment and shift cursor; don't shift display
jsr lcd_instruction
lda #%00000001 ; Clear display
jsr lcd_instruction
rts


LCDCMD:
jsr GETBYT
txa
lcd_instruction:
jsr lcd_wait
pha
lsr
lsr
lsr
lsr ; Send high 4 bits
sta PORTB
ora #E ; Set E bit to send instruction
sta PORTB
eor #E ; Clear E bit
sta PORTB
pla
and #%00001111 ; Send low 4 bits
sta PORTB
ora #E ; Set E bit to send instruction
sta PORTB
eor #E ; Clear E bit
sta PORTB
rts

LCDPRINT:
jsr FRMEVL ; Evaluate formular
bit VALTYP ; Is it a string?
bmi lcd_print_string ; Yes
jsr FOUT ; Format floating point output
jsr STRLIT ; Build string descriptor
lcd_print_string:
jsr FREFAC ; Returns temp pointer to string
tax ; Put count to counter
ldy #0
inx ; Move one ahead
lcd_print_next:
dex
beq lcd_print_end ; All done
lda (INDEX),y ; Load char of string
jsr lcd_print_char ; Output to lcd
iny
bne lcd_print_next ; Go on with next char
lcd_print_end:
rts

lcd_print_char:
jsr lcd_wait
pha
lsr
lsr
lsr
lsr ; Send high 4 bits
ora #RS ; Set RS
sta PORTB
ora #E ; Set E bit to send instruction
sta PORTB
eor #E ; Clear E bit
sta PORTB
pla
and #%00001111 ; Send low 4 bits
ora #RS ; Set RS
sta PORTB
ora #E ; Set E bit to send instruction
sta PORTB
eor #E ; Clear E bit
sta PORTB
rts

.endif
10 changes: 10 additions & 0 deletions make.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
if not exist tmp (
mkdir tmp
)

for %%i in (cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan aim65 sym1 eater) do (
echo %%i
C:\CC65\bin\ca65 -D %%i msbasic.s -o tmp\%%i.o
C:\CC65\bin\ld65 -C %%i.cfg tmp\%%i.o -o tmp\%%i.bin -Ln tmp\%%i.lbl
)
1 change: 1 addition & 0 deletions msbasic.s
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
.include "trig.s"
.include "init.s"
.include "extra.s"
.include "lcd.s"
4 changes: 4 additions & 0 deletions token.s
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
keyword_rts "PRT", PRT
.endif
keyword_rts "NEW", NEW
.ifdef EATER
keyword_rts "LCDCMD", LCDCMD
keyword_rts "LCDPRINT", LCDPRINT
.endif

count_tokens

Expand Down