forked from kervinck/gigatron-rom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReset_v3.gcl
124 lines (105 loc) · 3.97 KB
/
Reset_v3.gcl
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
{-----------------------------------------------------------------------+
| |
| Reset Gigatron (pseudo) hardware |
| |
+-----------------------------------------------------------------------}
gcl0x
{ Setup video }
[def
{ Setup video indirection table }
$100 p= {videoTable}
$800 q= {frame}
[do
q>, p. p<++ { Y[i] = 8..127}
0 p. p<++ {dX[i] = 0}
q>++ q if>0loop]
{ Clear screen }
\SYS_SetMemory_v2_54 _sysFn= {!!! Not in ROM v1 !!!}
32 \sysArgs1. {Color blue}
$800 [do
p= _sysArgs2= {Destination}
160 \sysArgs0. {Count}
54!! {SYS call}
$100 p+ if>0loop]
ret
] SetupVideo=
[def {PrintStartupMessage}
push
[def
`***`Gigatron`??K`*** #10
``TTL`microcomputer`ROM`v3 #0
] Text=
{ Convert memory size into decimal text }
{StartupMessage} 13+ p= {Position within StartupMessage for memory size}
$2f2f Char= {Two ASCII counters, both starting at '0'-1}
\memSize, 1- 255& 1+ {Number of pages as counted at boot}
[do Char>++ 40- if>=0loop] 40+ {Count number of 10K chunks}
[do Char<++ 4- if>=0loop] {Count number of 1K chunks}
Char>, p. p<++ Char p. {Put decimals into StartupMessage}
[do
Text, if<>0 Char= Text<++ {while((Char=*Text++)!=0)...}
10^ [if=0 2 Pos<. Pos>, 8+ Pos>. else PrintChar!]
loop]
pop ret
] PrintStartupMessage=
{-----------------------------------------------------------------------+
|}\vLR>++ ret{ RAM page 3 |
+-----------------------------------------------------------------------}
$0300:
{ Print a 5x8 character on screen with the built-in font
Char must be in the 32-127 range (this is not checked) }
[def {PrintChar}
{Map ASCII code to offset in font table}
Char 82- [if<0 50+ i= \font32up
else i= \font82up] fontData= {Select low or high page}
i 2<< i+ {Multiply by 5}
fontData+ fontData= {Add to page address to reach bitmap data for Char}
{Draw 5 vertical slices: 5 using font data}
$3f20 \sysArgs0: {Blue/White}
Pos \sysArgs4:
6+ Pos=
\SYS_VDrawBits_134 _sysFn=
$fb i= [do
fontData 0?? fontData<++ \sysArgs2. 134!!
\sysArgs4<++
i<++ i if<>0loop]
ret
] PrintChar=
{ Play a note on one channel
High byte is channel, low byte is note (should be even)
Reset the oscillators and channel variables }
[def {SetupChannel}
i= 255| 255^ $fa| p= {Pointer to channel struct}
i<, i= {Extract note}
0 p. p<++ {.wavA}
3 p. p<++ {.wavX, 3=Sawtooth}
\notesTable i+ 0?? p. p<++ {.keyL}
\notesTable i+ 1?? p. p<++ {.keyH}
p. p<++ {.oscL}
p. {.oscH}
ret
] SetupChannel=
{ Setup a G-major chord with 4 channels but don't play it yet }
[def {SetupAudio}
push
$158 {1: G-3} SetupChannel!
$270 {2: G-4} SetupChannel!
$378 {3: B-4} SetupChannel!
$47e {4: D-5} SetupChannel!
pop ret
] SetupAudio=
{ Now it is safe to call functions }
SetupAudio!
SetupVideo!
$814 Pos= PrintStartupMessage! {Returns 0}
{ Start blinkenlights }
\ledState_v2, 128& {Check if sequencer still running}
[if=0 \ledState_v2. \ledTimer.] {For continuity only restart when paused}
9 \ledTempo. {6.0 Hz ( = 60/(9+1)), was 5.5 Hz}
\SYS_SetMode_v2_80 _sysFn= {!!! Not in ROM v1 !!!}
1 80!! {Mode 1 -> "ABC-"}
{ Load and start main program }
\Main _sysArgs0= $200 _vLR= \SYS_Exec_88 _sysFn= 88!!
{-----------------------------------------------------------------------+
| |
+-----------------------------------------------------------------------}