forked from OldSkoolCoder/TEXTScrollers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHiResTextScroller.asm
246 lines (215 loc) · 5.32 KB
/
HiResTextScroller.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
ifdef TGT_C64
; 10 SYS (2064)
*=$0801
BYTE $0E, $08, $0A, $00, $9E, $20, $28, $32, $30, $36, $34, $29, $00, $00, $00
*=$0810
Endif
ifdef TGT_VIC20
; 10 SYS (4112)
*=$1001
BYTE $0E, $10, $0A, $00, $9E, $20, $28, $34, $31, $31, $32, $29, $00, $00, $00
*=$1010
endif
jmp StartScroller
ifdef TGT_C64
ChrArea = $3200 ; User Definded Character Area
ChrRom = $D000 ; ChrSet Rom Area
ScreenStart = $0400 ; Screen
LineSize = 40
endif
ifdef TGT_VIC20
ChrArea = $1A00 ; User Definded Character Area
ChrRom = $8000 ; ChrSet Rom Area
ScreenStart = $1E00 ; Screen
LineSize = 22
endif
; 40 character mapping table
ChrAreaLo
BYTE $00,$08,$10,$18,$20,$28,$30,$38,$40,$48
BYTE $50,$58,$60,$68,$70,$78,$80,$88,$90,$98
BYTE $A0,$A8,$B0,$B8,$C0,$C8,$D0,$D8,$E0,$E8,$F0,$F8
BYTE $00,$08,$10,$18,$20,$28,$30,$38,$40,$48
ChrAreaHi
BYTE >ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea
BYTE >ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea
BYTE >ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea,>ChrArea, >ChrArea,>ChrArea
BYTE >ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1,>ChrArea+1
; Text to Scroll
TEXTToScroll
TEXT 'this was a film from oldskoolcoder (c) jun 2019. '
TEXT 'github : https://github.com/oldskoolcoder/ '
TEXT 'twitter : @oldskoolcoder email : [email protected] '
TEXT 'please support me on patreon @ https://www.patreon.com/'
TEXT 'oldskoolcoder thank you ;-)'
BYTE 255
; Main Routine
StartScroller
jsr InitCharacterArea
jsr InitScreen
jsr TextScroller
rts
; Initialise the User Defined Character Area
InitCharacterArea
ldy #0
lda #0
@Inner
sta ChrArea,y ; Set First Bank
sta ChrArea+$100,y ; Set Second Bank
iny
cpy #0
bne @Inner
rts
; Initialise the Screen
InitScreen
lda #$93 ; Clear Screen
jsr $FFD2 ; Output Character
ldy #0
@Looper
tya
ora #64 ; Add 64 to Character
sta ScreenStart,y
iny
cpy #LineSize ; xx Characters in 1 Line
bne @looper
ifdef TGT_C64
lda #28 ; Set VIC Chip To Right Charater Mapping Memory
sta $d018 ;
endif
ifdef TGT_VIC20
lda #$FE
sta $9005 ; Set VIC Chip
lda #0
sta $900F ; Set Background to black
endif
rts
; Initialise The Text Scroller Pointers
InitTextScroller
ldy #<TEXTToScroll
sty TextLoader + 1
ldy #>TEXTToScroll
sty TextLoader + 2
rts
; Grab the Character Definition From CHR Rom
GrabCharacter
; Register Y has Character Code to Copy
lda #0
sta CharacterLoc + 1
sta CharacterLoc + 2
tya
asl ; x2
rol CharacterLoc + 2
asl ; x4
rol CharacterLoc + 2
asl ; x8
rol CharacterLoc + 2
sta CharacterLoc + 1
clc
lda #>ChrRom
adc CharacterLoc + 2
sta CharacterLoc + 2
ifdef TGT_C64
sei ; disable interrupts while we copy
lda #$33 ; make the CPU see the Character Generator ROM...
sta $01 ; ...at $D000 by storing %00110011 into location $01
endif
ldy #$00
GCLoop
CharacterLoc
lda ChrRom,y
ifdef TGT_C64
sta ChrArea + $0140,y ; write to the RAM Charcter 40
endif
ifdef TGT_VIC20
sta ChrArea + $B0,y
endif
iny
cpy #8
bne GCLoop ; ..for low byte $00 to $FF
lda #$37 ; switch in I/O mapped registers again...
ifdef TGT_C64
sta $01 ; ... with %00110111 so CPU can see them
cli ; turn off interrupt disable flag
endif
rts
; Get the Next Charater in the Message
GetCharacterInMessage
TextLoader
lda TEXTToScroll
pha
cmp #255
beq @EndOfText
clc
lda TextLoader + 1
adc #1
sta TextLoader + 1
lda TextLoader + 2
adc #0
sta TextLoader + 2
@EndOfText
pla
rts
; The Main Text Smooth Scrolling Routine
TextScroller
jsr GetCharacterInMessage
cmp #255
bne @StillGoing
rts
@StillGoing
tay
jsr GrabCharacter
lda #0
@DoNextPixel
pha
jsr ScrollOverOnePixel
@loop
ifdef TGT_C64
lda #200 ; Scanline -> A
cmp $D012 ; Compare A to current raster line
bne @loop ; Loop if raster line not reached 255
endif
ifdef TGT_VIC20
lda #100 ; Scanline/2 -> A
cmp $9004 ; Compare A to current raster line
bne @loop ; Loop if raster line not reached 255
endif
pla
clc
adc #1
cmp #8
bne @DoNextPixel
jmp TextScroller
ScrollOverOnePixel
ldy #LineSize
lda ChrAreaLo,y
sta ChrByteLoc + 1
lda ChrAreaHi,y
sta ChrByteLoc + 2
lda #0
clc
RotateTheNextCharacter
ldx #0
Rotatethe8Bytes
pha
rol
ChrByteLoc
rol ChrByteLoc,x
pla
rol
inx
cpx #8
bne Rotatethe8Bytes
; Accumultor now contains the vertical pixel pattern
; now to apply to previous 8 bytes
pha
sec
lda ChrByteLoc + 1
sbc #8
sta ChrByteLoc + 1
lda ChrByteLoc + 2
sbc #0
sta ChrByteLoc + 2
pla
dey
cpy #255
bne RotateTheNextCharacter
rts