125 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			125 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
 | 
						|
{-----------------------------------------------------------------------+
 | 
						|
|                                                                       |
 | 
						|
|       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`v3y #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!!
 | 
						|
 | 
						|
{-----------------------------------------------------------------------+
 | 
						|
|                                                                       |
 | 
						|
+-----------------------------------------------------------------------}
 | 
						|
 |