Skip to content

Commit defb9e4

Browse files
Add low-res Apple II graphics functions
1 parent c1807f6 commit defb9e4

2 files changed

Lines changed: 79 additions & 8 deletions

File tree

apple2/apple2.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
;
33
; SPDX-License-Identifier: MIT
44

5+
H2 := $2C
6+
V2 := $2D
57
PROMPT := $33 ; GETLN prompt character
68
COUTMASK := $50
79
HIMEM := $73 ; Highest available memory address+1
@@ -16,6 +18,13 @@ LCROM := $C081 ; Select ROM
1618
LCROMWP := $C082 ; Select ROM + write protect RAM
1719
LCRAM := $C083 ; Select RAM (read twice to write-enable RAM)
1820

21+
PLOT := $F800
22+
HLINE := $F819
23+
VLINE := $F828
24+
CLRSCR := $F832
25+
CLRTOP := $F836
26+
SETCOL := $F864
27+
SCRN := $F871
1928
SETTXT := $FB39
2029
PREAD := $FB1E
2130
SETGR := $FB40

apple2/apple2_extension_lc.s

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,100 @@
77
ex_statement_name_table:
88
name_table_entry "GR"
99
: name_table_entry "TEXT"
10+
: name_table_entry "HOME"
11+
: name_table_entry "COLOR"
12+
JUMP pvm_expression
13+
: name_table_entry "PLOT"
14+
JUMP pvm_arg_2
15+
: name_table_entry "HLIN"
16+
CALL pvm_arg_2
17+
MATCH "AT"
18+
JUMP pvm_expression
19+
: name_table_entry "VLIN"
20+
CALL pvm_arg_2
21+
MATCH "AT"
22+
JUMP pvm_expression
1023
: name_table_end
1124

1225
ex_function_name_table:
1326
name_table_entry "PDL"
27+
: name_table_entry "SCRN"
1428
: name_table_end
1529

1630
.segment "XVEC"
1731

1832
ex_statement_vectors:
19-
.word exec_gr-1
20-
.word exec_text-1
21-
33+
.word SETGR-1
34+
.word SETTXT-1
35+
.word HOME-1
36+
.word exec_color-1
37+
.word exec_plot-1
38+
.word exec_hlin-1
39+
.word exec_vlin-1
40+
2241
.code
2342

24-
exec_gr:
25-
jsr SETGR
26-
rts
43+
exec_color:
44+
jsr evaluate_expression
45+
jsr pop_int_fp0 ; Pop the color value
46+
jmp SETCOL
47+
48+
exec_plot:
49+
jsr evaluate_argument_list
50+
jsr pop_int_fp0 ; Pop the Y value
51+
pha ; We'll move it into A later
52+
jsr pop_int_fp0 ; Pop the X value
53+
tay ; Move X into Y for PLOT
54+
pla ; Get back Y from stack into A
55+
jmp PLOT
56+
57+
exec_hlin:
58+
jsr get_hlin_vlin_arguments
59+
jmp HLINE
2760

28-
exec_text:
29-
jsr SETTXT
61+
exec_vlin:
62+
jsr get_hlin_vlin_arguments
63+
jmp VLINE
64+
65+
get_hlin_vlin_arguments:
66+
jsr evaluate_argument_list ; Evaluate start and end
67+
inc line_pos ; Skip "AT"
68+
inc line_pos
69+
jsr evaluate_expression
70+
jsr pop_int_fp0 ; Get coordinate (Row for HLIN, Column for VLIN)
71+
pha ; Save on hardware stack
72+
jsr pop_int_fp0 ; Get end point (H2/V2)
73+
sta H2
74+
sta V2
75+
jsr pop_int_fp0 ; Get start point
76+
tay ; Start point into Y
77+
pla ; Coordinate into A
3078
rts
3179

3280
.segment "XFUNC"
3381

3482
ex_function_table:
3583
.word fun_pdl-1
3684
.byte 1 | PROLOG_POP_INT | EPILOG_PUSH_INT
85+
.word fun_scrn-1
86+
.byte 2 | PROLOG_POP_INT | EPILOG_PUSH_INT
3787

3888
.code
3989

4090
fun_pdl:
91+
jsr pop_int_fp0 ; Get paddle index
92+
tax
4193
jsr PREAD ; Returns result in Y
4294
tya
4395
ldx #0
4496
rts
97+
98+
fun_scrn:
99+
jsr pop_int_fp0 ; Pop the Y value (second arg)
100+
pha ; Save it
101+
jsr pop_int_fp0 ; Pop the X value (first arg)
102+
tay ; Move X into Y
103+
pla ; Get back Y into A
104+
jsr SCRN
105+
ldx #0 ; Make sure high byte is 0
106+
rts

0 commit comments

Comments
 (0)