-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconst.z80
59 lines (56 loc) · 2.65 KB
/
const.z80
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
; changing these /too much/ may cause overflow assembly errors due to overflow
basefreq := 440 ; freq of A4, can be float
min_timer_speed := 176 ; fastest the timer can repeat
; lower yields better quality (less noise, higher parasite tone, more accurate tuning, less aliasing)
; higher leaves more CPU time to other tasks
; but will still pick a higher timer speed if required to avoid overflow
; if you get "can't complete driver in time" errors, your clock speed is too low, try setting this higher
; if you want higher quality, try setting it (slightly) lower (needs to be high enough for the interrupt to finish, of course, or else you get lock-ups)
semitone := 1.0594630943592952645618252949463417007792043174941856285592 ; 2^(1/12), you can edit this if you want microtonal music, i guess (though you're gonna need a lot more edits throughout the source for that, though)
bass_lowest := 8 ; midi code of the lowest note playable on bass channel (better tuning but possibly slower timer (= lower quality))
bass_lowest_octave_count := 12 - bass_lowest mod 12
; changing these may cause asserts to fail
waves_ram := $c000 ; bitbang wave generators
assert waves_ram + waves.size <= general_tuning
general_tuning := $c099 ; tunings of general-purpose channels
assert general_tuning + 2 * 12 = bass_tuning
bass_tuning := $c0b1 ; tunings of the bass channels
assert bass_tuning + 12 = appvar_start
appvar_start := $c0bd ; start of the appvar (for relative addressing inside it)
assert appvar_start + 2 = channels_playing
channels_playing := $c0bf ; the number of channels that are still playing (a $e0 command decrements this and exits if it hits 0)
assert channels_playing + 1 = interrupt_ram
interrupt_ram := $c0c0 ; start of the interrupt routine
save_sp := interrupt_ram ; only used in cpuspeed.z80
assert interrupt_ram + interrupt.size <= djnz_counters_ram
djnz_counters_ram := $c100 ; 256 counters for $a0 and $b0 commands
;font := $c200 ; 3x3 font, decompressed
;score := $c240 ; score stored as a 6-digit BCD number
;streak := $c243 ; streak counter as a 4-digit BCD number
interrupt_table_ram := $c200 ; 257 $c0 bytes
driver_ram := $c301 ; start of the drivers
ram2_safe := $da7e ; start of saferam on ram page 2 (writing before this will cause a reset if the user scrolls up on the homescreen on mathprint OSes)
; some instructions used for SMC purposes
virtual
load _adc:1 from $+1
adc hl,de
load _sbc:1 from $+1
sbc hl,de
load _jrc:1 from $
jr c,$
load _jrnc:1 from $
jr nc,$
assert _adc xor _jrnc = _sbc xor _jrc
load _ldhl:1 from $
ld hl,0
load _jp:1 from $
jp 0
load _jr:1 from $
jr $
load _cp:1 from $
cp 0
load _orc:1 from $
or c
load _andc:1 from $
and c
end virtual