-
Notifications
You must be signed in to change notification settings - Fork 1
/
v99.asm
113 lines (92 loc) · 2.42 KB
/
v99.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
; v9938 (and 58) - low level routines
; stores whats in a in the constant register, register
.include 'v99.inc'
; save into the registers, starting from the register in a. the values
; pointed by x and counted by y are copied in
vindirect: ora #0x80 ; auto incmreneting mode
loadareg VINDIRECTREG ; set up the indirect reg
vindirectnext: lda ,x+ ; get the value
sta VINDIRECTPORT ; save it in the register
leay -1,y ; dec the counter
bne vindirectnext ; see if there is more
rts
; sets the colour in a to the r g b poited to by x
vsetcolour: pshs a ; save the current colour
loadareg VPALETTEREG ; we are writing to the colour reg
lda ,x+ ; get red
lsla ; move it to the high nibble
lsla ; ..
lsla ; ..
lsla ; ..
ldb ,x+ ; next, put green in b
ora ,x+ ; or in blue over red
sta VPALETTEPORT ; output red and blue
stb VPALETTEPORT ; output green
puls a ; get the colour back
rts
; set the colours - x points at r g b list, y sets the number of colours to
; set
vsetcolours: clra ; start from col 0
vsetcoloursn: bsr vsetcolour ; sets this colour
inca ; next colour
leay -1,y ; dec the count of colours
bne vsetcoloursn ; more?
rts
; sets up "core" registers
vinit: loadconstreg VBANKREG, 0x00
loadconstreg VDISPLAYPOSREG, 0x08
loadconstreg VDISPLAYOFFREG, 0x00
loadconstreg VINTLINEREG, 0x00
lbsr vclearvram
rts
vclearvram: ldy #0x0000
lbsr vseekcommon
lbsr vseekwrite
ldx #0x0000
clra
vclearnext: sta VPORT0
leax -1,x
bne vclearnext ; 64kbytes
rts
; writes to y in vram, count u bytes, from x in mpu ram
vwrite: pshs y
lbsr vseekcommon
lbsr vseekwrite
tfr u,y ; leau does not set z, so need y
vwritenext: lda ,x+
sta VPORT0
leay -1,y
bne vwritenext
puls y
rts
; reads into x in mpu, count u bytes, from y in vram
vread: pshs y
lbsr vseekcommon ; setup for writing using y
lbsr vseekread
tfr u,y ; leau does not set z, so need y
vreadnext: lda VPORT0
sta ,x+
leay -1,y
bne vreadnext
puls y
rts
; prepare the vdc for reading or writing from y in vram
vseekcommon: tfr y,d
lsra
lsra
lsra
lsra
lsra
lsra ; six shifts put a15 at bit 1
loadareg VADDRREG
tfr y,d ; retore original address
stb VADDRPORT ; the low 8 bits of address (easy)
anda #0b00111111 ; mask out the high two bits
rts
vseekwrite: ora #0b01000000 ; set writing mode
sta VADDRPORT
sleep
rts
vseekread: sta VADDRPORT
sleep
rts