-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncfuncs.asm
More file actions
153 lines (147 loc) · 2.96 KB
/
Copy pathfuncfuncs.asm
File metadata and controls
153 lines (147 loc) · 2.96 KB
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
;--------------------------------------------------
InitZEquations:
ld b,MAX_EQS
InitZEquations_Loop:
push bc
ld hl,BaseZVarName
rst 20h
pop af
push af
add a,tZ1-1 ;-1 because b goes from 6 to 1, not 5 to 0
ld (OP1+2),a
rst 10h
jr nc,InitZEquations_Loop_Exists
ld hl,0
bcall(_CreateEqu)
InitZEquations_Loop_Exists:
pop bc
djnz InitZEquations_Loop
ret
;--------------------------------------------------
CheckEnabled_Setup:
xor a
ld (counteqs),a
ld a,SETTINGS_AVOFF_MAXEQS
call LTS_GetByte
ld b,a
ld c,tZ1
ld hl,eq_en_cache
CheckEnabled_Setup_Loop:
push bc
push hl
push bc
ld hl,BaseZVarName
rst 20h
pop bc
ld a,c
ld (OP1+2),a
rst 10h
ld a,0 ; xor a would disturb flags
jr c,CheckEnabled_Setup_Loop_Store
bit 5,(hl)
jr z,CheckEnabled_Setup_Loop_Store
push hl
push bc
ld a,SETTINGS_AVOFF_ZEQUVALID ; Used to prevent splitscreen infinite loop
call LTS_GetByte
pop bc
pop hl
or a
jr z,CheckEnabled_Setup_Loop_Store
ld a,1
ld hl,counteqs
inc (hl)
CheckEnabled_Setup_Loop_Store:
pop hl
ld (hl),a
pop bc
inc hl
inc c
djnz CheckEnabled_Setup_Loop
ret
CheckEnabledA:
sub tZ1
ld e,a
ld d,0
ld hl,eq_en_cache
add hl,de
ld a,(hl)
or a
ret
;--------------------------------------------------
SetFunctionMode:
; Set Function mode - can only touch a!
ld a,(iy+grfModeFlags)
and $ff^((1 << grfPolarM) | (1 << grfParamM) | (1 << grfRecurM))
or 0+(1 << grfFuncM)
ld (iy+grfModeFlags),a
ret
;--------------------------------------------------
; These functions swap the Y1..Y[2 or 5]
; functions into Z1..Z[2 or 5], and vice versa
; They work by directly modifying the VAT.
SwapZYFuncs_In:
call SwapZYFuncs_IsSwapped
ret nz ; Already swapped
ld (hl),1
jp SwapZYFuncs
SwapZYFuncs_IsSwapped:
ld a,SETTINGS_AVOFF_EQSWAPPED
call LTS_GetPtr
ld a,(hl)
or a
ret
SwapZYFuncs_Out:
ld a,SETTINGS_AVOFF_EQSWAPPED
call LTS_GetPtr
ld a,(hl)
or a
ret z ; Not swapped
ld (hl),0
SwapZYFuncs:
ld a,SETTINGS_AVOFF_MAXEQS
call LTS_GetByte
ld b,a ; Maximum equations to process
SwapZYFuncs_Loop:
push bc
ld a,b
add a,tY1 - 1 ; Save a dec a here
ld hl,OP1
ld (hl),EquObj
inc hl
ld (hl),tVarEqu
inc hl
ld (hl),a
inc hl
ld (hl),0
rst 10h ; Find Yx
jr c,SwapZYFuncs_Loop_Skip ; But this should never happen!!
pop bc
push bc
ld de,-7
add hl,de
push hl ; Save offset to VAT for swapping
ld a,b
add a,tZ1 - 1 ; Save a dec a here
ld hl,OP1
ld (hl),EquObj
inc hl
ld (hl),tVarEqu
inc hl
ld (hl),a
inc hl
ld (hl),0
rst 10h ; Find Zx
pop de
jr c,SwapZYFuncs_Loop_Skip ; But this should never happen!!
ld bc,-7
add hl,bc
ld b,(hl)
ld a,(de)
ex de,hl
ld (de),a
ld (hl),b
SwapZYFuncs_Loop_Skip:
pop bc
djnz SwapZYFuncs_Loop
ret