-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreen.asm
136 lines (124 loc) · 2.83 KB
/
screen.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
#import "pottendos_utils.asm"
.macro init_screen(l1, l2, mode_fun, rest_fun) {
poke16_(screen.cb_mf + 1, mode_fun) // modify operand
poke16_(screen.cb_rf + 1, rest_fun) // modify operand
poke8_(screen.line2, l2)
poke8_(screen.line1, l1)
//jsr screen.init_raster
}
.macro close_screen() {
jsr screen.close
}
// .segment _screen
screen: {
line1: .byte $00
line2: .byte $00
scrstate: .byte $00
// init / close screen
toggle_screen:
lda scrstate
eor #$ff
sta scrstate
beq !+
poke8_(VIC.BgC, BLACK)
sprite(0, "on", -1)
sprite(7, "on", -1)
//init_screen(49, 153, noop, noop)
jsr mode
rts
!:
//close_screen()
sprite(0, "off", -1)
sprite(7, "off", -1)
jsr rest
poke8_(VIC.BgC, BLUE)
rts
toggle_mc:
lda scrstate
beq !+
lda VIC.CR2
eor #%00010000 // bit 4 -> MC/HR
sta VIC.CR2
and #%00010000 // bit 4 -> MC/HR
beq hr
memset_(gl.vic_videoram, $b2, $3f8)
lda #1
jsr gfx.toggle_mc
rts
hr:
memset_(gl.vic_videoram, $10, $3f8)
lda #0
jsr gfx.toggle_mc
!: rts
init_raster:
sei
sta VIC.RASTER // acc still has l1 8bit
clearbits(VIC.RASTER - 1, %01111111)// clear 9'th bit for line >255
poke8_(VIC.IMR, %10000001)
poke16_(STD.IRQ_VEC, raster_isr)
cli
rts
raster_isr:
lda VIC.IRR
sta VIC.IRR
and #%00000001
bne !+
jmp STD.IRQ
!:
lda VIC.RASTER
cmp line2
bcs l2
cb_mf:
jsr $beef // operand modified during initialization
lda line2
sta VIC.RASTER
out:
restore_regs()
rti
l2:
cb_rf:
jsr $beef // operand modified during initialization
lda line1
sta VIC.RASTER
jmp out
tmp1: .byte $00
/* callbacks to set vic mode */
mode:
clearbits(CIA2.base, %11111100) // select VIC bank $4000-$7FFF
setbits(CIA2.base, %00000001)
lda VIC.MEM // move VIC screen to base + $0000
sta tmp1
and #%00000111
ora #%00001000 // screen to base + $3C00
sta VIC.MEM
setbits(VIC.CR1, %00100000) // bit 5 -> HiRes
setbits(VIC.CR2, %00010000) // bit 4 -> MC
poke8_(VIC.BoC, 0)
sprite(0, "color", WHITE)
sprite(7, "color", WHITE)
sprite(0, "expx", "on")
sprite(0, "expy", "on")
sprite(7, "expx", "on")
sprite(7, "expy", "on")
rts
rest:
poke8_(VIC.BoC, 14)
setbits(CIA2.base, %00000011)
lda tmp1
//and #%11110000
//ora VIC.MEM
sta VIC.MEM
clearbits(VIC.CR1, %11011111)
clearbits(VIC.CR2, %11101111)
rts
close:
!:
lda VIC.RASTER
cmp #$ff
bne !-
poke8_(VIC.IMR, $00)
sei
poke16_(STD.IRQ_VEC, STD.IRQ)
cli
rts
} /* scope screen */