-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdraw.asm
152 lines (138 loc) · 3.29 KB
/
draw.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
; marcel timm, rhinodevel, 2020mar18
; --------------
; --- macros ---
; --------------
; *************************
; *** clear the screen. ***
; *************************
; ***
; *** don't use this, if interrupt service routine is disabled (etc.).
; ***
; *** output:
; *** -------
; *** a = garbage.
; ***
;
defm clrscr$
lda #chr_clr$
jsr chrout$
endm
; -----------------
; --- functions ---
; -----------------
; *************************
; *** clear the screen. ***
; *************************
; ***
; *** to be used, if interrupt service routine is already disabled.
; ***
;
clrscr_own$
lda #<screen_ram$
sta zero_word_buf1$
lda #>screen_ram$
sta zero_word_buf1$ + 1
lda #chr_spc$
; ok, because screen ram starts at $??00 (in fact always at $8000):
;
ldx #8 ; ok (because of mirroring in 40 column machines),
; but overdone, if 40 column machine.
@nextx ldy #0
@nexty sta (zero_word_buf1$),y ; from $??00 to $??ff.
iny
bne @nexty
inc zero_word_buf1$ + 1 ; increment high byte.
dex
bne @nextx
rts
; *** input:
; *** ------
; *** y = char row / line nr. (0 - 24).
; *** zero_word_buf1$ = char column / pos. in line (0 - 39 or 0 - 79).
; ***
; *** output:
; *** -------
; *** a = low byte of screen mem. addr.
; *** x = high byte of screen mem. addr.
; *** y = 0.
; *** zero_word_buf1$ = screen mem. addr.
; ***
;
get_mem_addr$
; init. to screen ram start addr.:
;
lda #<screen_ram$
ldx #>screen_ram$
; calculate address:
;
get_mem_addr_loop
cpy #0
beq get_mem_addr_add_col
dey
clc
linelen$ adc #0 ; value to-be-set in-place during initialization!
bcc get_mem_addr_loop
inx
bcs get_mem_addr_loop ; (always loops)
get_mem_addr_add_col
clc
adc zero_word_buf1$
bcc @copy
inx
; copy addr. to output buffer:
;
@copy sta zero_word_buf1$
stx zero_word_buf1$ + 1
rts
; ****************
; *** pos_draw ***
; ****************
; ***
; *** input:
; *** ------
; *** a = screen mem. code char.
; *** y = char row / line nr. (0 - 24).
; *** zero_word_buf1$ = char column / pos. in line (0 - 39 or 0 - 79).
; ***
; *** output:
; *** -------
; *** x = high byte of screen mem. addr.
; *** y = 0
; *** zero_word_buf1$ = screen mem. addr.
; ***
;
pos_draw$
pha
jsr get_mem_addr$
pla
sta (zero_word_buf1$),y ; (y is 0)
rts
; ***
;
conv_hd and #$0f ; ignore left 4 bits.
cmp #$0a
bcc @digit
sec ; more or equal $0a - a to f.
sbc #$0a
clc
adc #'a'
rts
@digit ;clc ; less than $0a - 0 to 9
adc #'0'
rts
; ******************************************************
; *** print byte in accumulator as hexadecimal value ***
; ******************************************************
;
printby$ pha
lsr a
lsr a
lsr a
lsr a
jsr conv_hd
jsr pos_draw$
pla
jsr conv_hd
inc zero_word_buf1$ ; hard-coded, does not support line break.
sta (zero_word_buf1$),y ; (y is 0).
rts