gigatron/rom/Apps/Loader/Loader_v3.gcl
2025-01-28 19:17:01 +03:00

134 lines
5.0 KiB
Plaintext

{-----------------------------------------------------------------------+
| |
| Loading of programs over the serial port (with Arduino) |
| |
+-----------------------------------------------------------------------}
gcl0x
{ Setup }
{ Print ASCII character (32..127) on screen using the 5x8 pixel built-in font }
[def
82- {Map ASCII code to offset in font table}
[if<0 50+ i= \font32up {First page for ASCII 32..81}
else i= \font82up] j= {Second page is ASCII 82..127}
i 2<< i+ {Multiply by 5}
j+ j= {Add page address to reach bitmap data}
Pos \sysArgs4: {Position of character}
6+ Pos= {Advance position by 6 pixels for next call}
5 [do i= {Loop to draw 5 vertical slices of 8 pixels}
j 0? \sysArgs2. {Get byte from ROM using `LUP 0' instruction}
134!! {Invoke SYS function to draw 8 vertical pixels}
<j++ <\sysArgs4++ {Advance to next slice in ROM and on screen}
i 1- if>0loop] {Looping}
\sysArgs2. 134!! {Render 6th slice}
ret
] PrintChar=
{ Display ready to load text }
\SYS_VDrawBits_134 \sysFn: {Prepare SYS calls}
$0f20 \sysArgs0: {Yellow on blue}
$5006 Pos= {Overwrite the text that MainMenu left behind}
[def ``Ready`to`load #0] Text=
[do Text, if<>0 Text<++ PrintChar! loop]
{ Put these in variable to save some code space below }
\SYS_LoaderNextByteIn_32 NextByteIn_32=
\SYS_LoaderPayloadCopy_34 PayloadCopy_34=
\channelMask_v4, $f8& {Clear channelMask bits to allow safe}
\channelMask_v4. { loading into sound channels 2-4}
$02fe i= 0 i: {And place canaries to detect that}
>i++ i:
>i++ i:
\sysArgs4. {Clears the copy counter}
$590c A= {Activity indicator}
$5b0c B= {Buffer}
103 {'g'} \sysArgs2. {Reset checksum}
\Loop \vLR: ret {Start main loop that's in the screen area}
{-----------------------------------------------------------------------+
| Inside screen area |
+-----------------------------------------------------------------------}
*=$5a0c
_Loop=*
[do
{Receive the next transmission frame}
B \sysArgs0: {Input buffer}
207 \sysArgs3. NextByteIn_32 \sysFn: 32!! {Protocol byte}
219 \sysArgs3. 32!! {Length, 6 new bits}
235 \sysArgs3. 32!! {Low address}
251 \sysArgs3. 32!! {High address}
PayloadCopy_34 \sysFn: 34!! {Copy previous bytes}
2 \sysArgs3. NextByteIn_32 \sysFn: 32!! {Payload 0}
6 \sysArgs3.
[do PayloadCopy_34 \sysFn: 34!! {Copy previous bytes}
NextByteIn_32 \sysFn: 32!! {Payload 1-59}
\sysArgs3, 4+ \sysArgs3.
242^ if<>0loop]
185 \sysArgs3. 32!! {Checksum byte}
{Plot green or red indicator}
\sysArgs2, [if=0 12 else 3] A.
{Advance indicator and wrap around}
A<, 11- 127& 12+ A<.
{White indicator}
63 A.
{Check checksum and command, and execute if OK. Also reset checksum.}
\SYS_LoaderProcessInput_64 \sysFn: 64!!
loop]
{
vgaY nextVideo videoY vCPU Comment
---- --------- ------ ---- -------
0 videoE 179 Yes First vBlank
1 videoE 181 Yes
2 videoE 183 Yes
3 videoE 185 Yes Byte 65 Checksum
.. ... ... Yes
14 videoE 207 Yes Byte 0 Protocol ('L')
.. ... ... Yes
20 videoE 219 Yes Byte 1 Length (6 bits)
.. ... ... Yes
28 videoE 235 Yes Byte 2 Address L
.. ... ... Yes
36 videoE 251 Yes Byte 3 Address H
37 videoE 253 Yes
38 videoE 255 Yes
39 videoE 1 Yes
40 videoE 1 Yes Last vBlank
41 videoA->B 0 No Pixel
42 videoB->C 0 No Pixel
43 videoC->F 0 No Pixel
44 videoF->A 2 Yes Byte 4 Payload 0
45 videoA->B 2 No Pixel
46 videoB->C 2 No Pixel
47 videoC->F 2 No Pixel
48 vidoeF->A 4 Yes
49 videoA->B 4 No Pixel
50 videoB->C 4 No Pixel
51 videoC->F 4 No Pixel
52 videoF->A 6 Yes Byte 5 Payload 1
.. ... ... ...
513 videoA->B 236 No Pixel
514 videoB->C 236 No Pixel
515 videoC->F 236 No Pixel
516 videoF->A 238 Yes Byte 64 Payload 59
517 videoA->B 238 No Pixel
518 videoB->C 238 No Pixel
519 videoC->F 238 No Pixel
520 videoF->E 238 Yes
}
{-----------------------------------------------------------------------+
| |
+-----------------------------------------------------------------------}