{-----------------------------------------------------------------------+ | | | 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 } $800 p= $8801 i= \SYS_VDrawBits_134 _sysFn= 32 \sysArgs0. \sysArgs1. {Blue} [do p [do _sysArgs4= 134!! {Clears 8 pixels vertically} $800 p+ p= if>0loop] i+ p= 255& 160^ if<>0loop] ret ] SetupVideo= [def {PrintStartupMessage} push { Startup message: +--------------------------+ | *** Gigatron ??K *** | | TTL microcomputer ROM v1 | } [def {Line 1} $2a# $2a# $2a# $20# $47# $69# $67# $61# $74# $72# $6f# $6e# $20# $3f# $3f# $4b# $20# $2a# $2a# $2a# 10# {Line 2} $20# $54# $54# $4c# $20# $6d# $69# $63# $72# $6f# $63# $6f# $6d# $70# $75# $74# $65# $72# $20# $52# $4f# $4d# $20# $76# $31# 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 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} 63 \sysArgs1. {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! $812 Pos= PrintStartupMessage! { Load and start main program } \Main _sysArgs0= $200 _vLR= \SYS_Exec_88 _sysFn= 88!! {-----------------------------------------------------------------------+ | | +-----------------------------------------------------------------------}