-
Notifications
You must be signed in to change notification settings - Fork 0
/
house.asm
171 lines (153 loc) · 3.51 KB
/
house.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
;----------------------------------------------
; HOUSEKEEPING ROUTINES
curr_palette: dw house.palette+15
;----------------------------------------------
house.set_paletteHL:
; Set current palette to HL but don't update outputted palette yet
push bc
ld bc,15
add hl,bc
ld (curr_palette),hl
pop bc
ret
house.set_curr_palette:
; Output current palette
ld bc,&10f8
ld hl,(curr_palette)
otdr
ret
house.palette: db 8,64,32,0,127,91,52,87,99,74,102,98,114,44,28,124
house.restore_background_palette:
; Reset background colour to level 0
ld a,99
ld (house.palette+8),a
ret
house.palette_off:
ld bc,4344
ld a,8
@loop:
out (c),a
djnz @-loop
ret
;----------------------------------------------
house.border_up:
ld a,0
inc a
and &07
ld (house.border_up+1),a
out (BorderReg),a
ret
;----------------------------------------------
house.clear_screens:
; Clear both screens
call @+clear
call house.swap_screens
call @+clear
ret
@clear:
; Clear one screen, slow version
ld hl,0 ; Mode 4 is 192 rows of 128 bytes, each with 2 nibbles for a pixel of colour info.
ld de,1
ld (hl),dark_grey*&11 ; Fill both nibbles with same colour
ld bc,24576-1
ldir
ret
;----------------------------------------------
house.auto_swap:
; Swap screens if auto_swap.on is Yes
ld a,(auto_swap.on)
cp On
ret nz
house.swap_screens:
; Swap displayed and buffer screens
in a,(LMPR)
xor 2
out (LMPR),a
in a,(VMPR)
xor 2
out (VMPR),a
ret
house.wait_B_frames:
; Wait for B frames
@loop:
push bc
call house.wait_frame
call keys.input
pop bc
djnz @-loop
ret
house.wait_B_frames_im2:
; Wait for B frames, use IM2 tallies
@loop:
push bc
call house.wait_frame_im2
pop bc
djnz @-loop
ret
;----------------------------------------------
house.wait_frame:
; Wait until frame interrupt occurred - this sets it to 50fps
in a,(StatusReg)
bit 3,a
ret z
jp house.wait_frame
house.wait_lineA:
out (StatusReg),a
@loop:
in a,(StatusReg)
bit 0,a
ret z
jp @-loop
;----------------------------------------------
house.wait_frame_im2:
; If IM2 is running, check flag for new frame
@loop:
ld a,(frame.elapsed)
cp No
jp z,@-loop
@reset_frame_flag:
ld a,No
ld (frame.elapsed),a
ret
house.wait_int_im2:
; If IM2 is running, check flag for new interrupt
@loop:
ld a,(interrupt.elapsed)
cp No
jp z,@-loop
@reset_int_flag:
ld a,No
ld (interrupt.elapsed),a
ret
;----------------------------------------------
house.double_buffer.off:
house.double_buffer.on:
; Toggle double buffering. Labelled both ways for clarity of intent.
in a,(LMPR)
xor 2
out (LMPR),a
ret
;----------------------------------------------
house.pal_up:
; Output vague progess in decompression to palette 0
nop ; Changed to RET after decompressing, so outline will still work when running
push af
push bc
@pal: ld a,0
inc a
and %01111111
ld (@-pal+1),a
ld bc,PaletteBaseReg
out (c),a
pop bc
pop af
ret
house.pal_up.set.off:
; Update house.pal_up to quit immediately, set palette 0 back to standard dark grey
ld a,ret_
ld (house.pal_up),a
@reset_palette:
ld a,8
ld bc,PaletteBaseReg
out (c),a
ret