File tree 12 files changed +304
-75
lines changed
12 files changed +304
-75
lines changed Original file line number Diff line number Diff line change 3
3
* .map
4
4
* .swp
5
5
rom.bin
6
+ librt.a
Original file line number Diff line number Diff line change 1
1
CC65 =cc65/bin
2
2
AS =$(CC65 ) /ca65
3
- ASFLAGS =--target sim65c02
3
+ ASFLAGS =-l $@ .lst
4
4
5
- rom.bin : main.o ramtest.o
5
+ rom.bin : main.o ramtest.o librt.a
6
6
$(CC65 ) /ld65 --config eater.cfg -m rom.map -o $@ $^
7
7
8
+ librt.a : reg.o via.o led.o lcd.o lfsr.o
9
+ $(CC65 ) /ar65 r $@ $^
10
+
11
+ .PHONY : test
12
+ test : rom.bin
13
+ make -C test
14
+
15
+ .PHONY : program
16
+ program : rom.bin
17
+ minipro -p AT28C256 -w rom.bin
18
+
8
19
.PHONY : hexdump
9
20
hexdump : rom.bin
10
21
hexdump -C $<
15
26
16
27
.PHONY : clean
17
28
clean :
18
- rm -f rom.bin * .o
29
+ rm -f rom.bin librt.a * .o
30
+ make -C test clean
Original file line number Diff line number Diff line change 1
1
.PC02
2
2
3
+ ; main.s
4
+ .globalzp r0 , r1 , r2 , r3
5
+
6
+ ; lfsr.s
3
7
. global srand
4
8
. global rand
5
9
10
+ ; via.s
11
+ . global via_init
12
+
13
+ ; lcd.s
6
14
. global lcd_init
7
15
. global lcd_home
16
+ . global lcd_clear
8
17
. global lcd_puthex
18
+ . global lcd_putc
19
+ . global lcd_puts
20
+
21
+ ; led.s
22
+ . global led_on
23
+ . global led_off
24
+ . global led_blink
25
+ . global led_code
9
26
27
+ ; ramtest.s
10
28
. global ramtest
11
29
. global ramtest_success
Original file line number Diff line number Diff line change 1
1
.include "defs.inc"
2
-
3
- PORTB = $6000
4
- PORTA = $6001
5
- DDRB = $6002
6
- DDRA = $6003
7
-
8
- E = %10000000
9
- RW = %01000000
10
- RS = %00100000
2
+ .include "via.inc"
11
3
12
4
.proc lcd_wait
13
5
lda #%00000000 ; Set all pins on port B to input
48
40
rts
49
41
.endproc
50
42
51
- .proc lcd_data
43
+ .proc lcd_putc
52
44
sta PORTB
53
45
54
46
jsr lcd_wait
@@ -81,21 +73,29 @@ skip:
81
73
lsr
82
74
lsr
83
75
TO_ASCII
84
- jsr lcd_data
76
+ jsr lcd_putc
85
77
pla
86
78
and #$f
87
79
TO_ASCII
88
- jsr lcd_data
80
+ jsr lcd_putc
89
81
rts
90
82
.endproc
91
83
92
- .proc lcd_init
93
- lda #%11111111 ; Set all pins on port B to output
94
- sta DDRB
95
-
96
- lda #%11100000 ; Set top 3 pins on port A to output
97
- sta DDRA
84
+ .proc lcd_puts
85
+ sty r0
86
+ sta r0+1
87
+ ldy #0
88
+ loop:
89
+ lda (r0),y
90
+ beq done
91
+ jsr lcd_putc
92
+ iny
93
+ jmp loop
94
+ done:
95
+ rts
96
+ .endproc
98
97
98
+ .proc lcd_init
99
99
lda #%00111000 ; Set 8-bit mode; 2-line display; 5x8 font
100
100
jsr lcd_cmd
101
101
lda #%00000001 ; Clear display
@@ -110,3 +110,8 @@ skip:
110
110
lda #%00000010 ; Return home
111
111
jmp lcd_cmd
112
112
.endproc
113
+
114
+ .proc lcd_clear
115
+ lda #%00000001 ; Clear display
116
+ jmp lcd_cmd
117
+ .endproc
Original file line number Diff line number Diff line change
1
+ .include "defs.inc"
2
+ .include "via.inc"
3
+
4
+ .proc led_on
5
+ lda #LED
6
+ sta PORTA
7
+ rts
8
+ .endproc
9
+
10
+ .proc led_off
11
+ lda #0
12
+ sta PORTA
13
+ rts
14
+ .endproc
15
+
16
+ .macro DELAY
17
+ .local outer_loop
18
+ .local inner_loop
19
+ sty 0
20
+ ;lsl 0
21
+ ;lsl 0
22
+ ;lsl 0
23
+ outer_loop:
24
+ ldy #$ff
25
+ inner_loop:
26
+ dey
27
+ bne inner_loop
28
+ dec 0
29
+ bne outer_loop
30
+ .endmacro
31
+
32
+ .proc led_blink
33
+ tay
34
+ lda #LED
35
+ sta PORTA
36
+ DELAY
37
+ lda #0
38
+ sta PORTA
39
+ rts
40
+ .endproc
41
+
42
+ .proc led_code
43
+ sec
44
+ nextbit:
45
+ ldy #$A0
46
+ rol
47
+ beq done
48
+ bcc blink
49
+ ldy #$50
50
+ blink:
51
+ tax
52
+ tya
53
+ jsr led_blink
54
+ txa
55
+ DELAY
56
+ clc
57
+ jmp nextbit
58
+ done:
59
+ rts
60
+ .endproc
Original file line number Diff line number Diff line change 1
1
.include "defs.inc"
2
2
3
+ RAMTEST_START = $01
4
+
3
5
main:
6
+ ldx #$ff
7
+ txs
8
+
9
+ jsr via_init
10
+ jsr led_on
11
+ jsr lcd_init
12
+ lda #>testing
13
+ ldy #<testing
14
+ jsr lcd_puts
15
+
16
+ lda #RAMTEST_START
4
17
jmp ramtest
5
18
6
19
ramtest_success:
7
- jmp ramtest_success
20
+ jsr lcd_clear
21
+ lda #>test_complete
22
+ ldy #<test_complete
23
+ jsr lcd_puts
24
+ jsr led_off
25
+ loop:
26
+ jmp loop
27
+
28
+ .rodata
29
+ testing:
30
+ .asciiz "testing"
31
+ test_complete:
32
+ .asciiz "test complete"
8
33
9
34
.segment "VECTORS"
10
35
nmi:
You can’t perform that action at this time.
0 commit comments