[{"data":1,"prerenderedAt":4878},["ShallowReactive",2],{"blog-tags-Z80":3},[4],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"date":11,"tags":12,"category":16,"excerpt":17,"body":37,"_type":4869,"_id":4870,"_source":4871,"_file":4872,"_stem":4873,"_extension":4874,"url":4875,"wordCount":4876,"minutes":1217,"commentCount":4877},"/blog/2026/2026-05-06-vtx5000-part-4-comms-routines","2026",false,"en","VTX5000: Part 4 - Communications ","In part 3 we saw how the VTX5000's 8K ROM is structured and how the BASIC program drives the terminal. ","2026-05-06T10:19:24.727Z",[13,14,15],"ZX Spectrum","vintage computing","Z80","Technology",{"type":18,"children":19},"root",[20,32],{"type":21,"tag":22,"props":23,"children":24},"element","p",{},[25,28,30],{"type":26,"value":27},"text","In ",{"type":26,"value":29},"part 3",{"type":26,"value":31}," we saw how the VTX5000's 8K ROM is structured and how the BASIC program drives the terminal. ",{"type":21,"tag":22,"props":33,"children":34},{},[35],{"type":26,"value":36},"Now we'll look at the Z80 machine code that handles the real-time work: talking to the 8251 USART, managing the buffers, and scanning the keyboard with its Prestel-specific remapping.",{"type":18,"children":38,"toc":4857},[39,50,54,61,66,73,354,360,639,645,874,880,901,1254,1259,1264,1270,1275,2448,2454,2459,2759,2780,2785,2791,2796,3122,3164,3170,3175,3630,3635,3657,3670,3676,3681,3692,3879,3889,4189,4194,4214,4220,4225,4242,4276,4681,4687,4700,4712,4827,4840,4846,4851],{"type":21,"tag":22,"props":40,"children":41},{},[42,43,49],{"type":26,"value":27},{"type":21,"tag":44,"props":45,"children":47},"a",{"href":46},"/blog/2026/04/16/vtx5000-part-3-software-rom/",[48],{"type":26,"value":29},{"type":26,"value":31},{"type":21,"tag":22,"props":51,"children":52},{},[53],{"type":26,"value":36},{"type":21,"tag":55,"props":56,"children":58},"h3",{"id":57},"the-intel-8251",[59],{"type":26,"value":60},"The Intel 8251",{"type":21,"tag":22,"props":62,"children":63},{},[64],{"type":26,"value":65},"The 8251 has a bunch of bits that can be set for commands and configuration:",{"type":21,"tag":67,"props":68,"children":70},"h4",{"id":69},"command-flags",[71],{"type":26,"value":72},"Command flags",{"type":21,"tag":74,"props":75,"children":76},"table",{},[77,107],{"type":21,"tag":78,"props":79,"children":80},"thead",{},[81],{"type":21,"tag":82,"props":83,"children":84},"tr",{},[85,92,97,102],{"type":21,"tag":86,"props":87,"children":89},"th",{"align":88},"left",[90],{"type":26,"value":91},"Bit",{"type":21,"tag":86,"props":93,"children":94},{"align":88},[95],{"type":26,"value":96},"Mask",{"type":21,"tag":86,"props":98,"children":99},{"align":88},[100],{"type":26,"value":101},"Name",{"type":21,"tag":86,"props":103,"children":104},{"align":88},[105],{"type":26,"value":106},"Meaning when set",{"type":21,"tag":108,"props":109,"children":110},"tbody",{},[111,148,175,207,234,269,296,327],{"type":21,"tag":82,"props":112,"children":113},{},[114,120,130,135],{"type":21,"tag":115,"props":116,"children":117},"td",{"align":88},[118],{"type":26,"value":119},"7",{"type":21,"tag":115,"props":121,"children":122},{"align":88},[123],{"type":21,"tag":124,"props":125,"children":127},"code",{"className":126},[],[128],{"type":26,"value":129},"$80",{"type":21,"tag":115,"props":131,"children":132},{"align":88},[133],{"type":26,"value":134},"Hunt mode",{"type":21,"tag":115,"props":136,"children":137},{"align":88},[138,140,146],{"type":26,"value":139},"In synchronous mode, enter hunt for ",{"type":21,"tag":124,"props":141,"children":143},{"className":142},[],[144],{"type":26,"value":145},"SYN",{"type":26,"value":147}," characters",{"type":21,"tag":82,"props":149,"children":150},{},[151,156,165,170],{"type":21,"tag":115,"props":152,"children":153},{"align":88},[154],{"type":26,"value":155},"6",{"type":21,"tag":115,"props":157,"children":158},{"align":88},[159],{"type":21,"tag":124,"props":160,"children":162},{"className":161},[],[163],{"type":26,"value":164},"$40",{"type":21,"tag":115,"props":166,"children":167},{"align":88},[168],{"type":26,"value":169},"Internal reset",{"type":21,"tag":115,"props":171,"children":172},{"align":88},[173],{"type":26,"value":174},"Reset the 8251 state machine; the next byte is configuration mode",{"type":21,"tag":82,"props":176,"children":177},{},[178,183,192,197],{"type":21,"tag":115,"props":179,"children":180},{"align":88},[181],{"type":26,"value":182},"5",{"type":21,"tag":115,"props":184,"children":185},{"align":88},[186],{"type":21,"tag":124,"props":187,"children":189},{"className":188},[],[190],{"type":26,"value":191},"$20",{"type":21,"tag":115,"props":193,"children":194},{"align":88},[195],{"type":26,"value":196},"RTS",{"type":21,"tag":115,"props":198,"children":199},{"align":88},[200,202],{"type":26,"value":201},"Assert ",{"type":21,"tag":124,"props":203,"children":205},{"className":204},[],[206],{"type":26,"value":196},{"type":21,"tag":82,"props":208,"children":209},{},[210,215,224,229],{"type":21,"tag":115,"props":211,"children":212},{"align":88},[213],{"type":26,"value":214},"4",{"type":21,"tag":115,"props":216,"children":217},{"align":88},[218],{"type":21,"tag":124,"props":219,"children":221},{"className":220},[],[222],{"type":26,"value":223},"$10",{"type":21,"tag":115,"props":225,"children":226},{"align":88},[227],{"type":26,"value":228},"Error reset",{"type":21,"tag":115,"props":230,"children":231},{"align":88},[232],{"type":26,"value":233},"Clear parity, overrun and framing error flags",{"type":21,"tag":82,"props":235,"children":236},{},[237,242,251,256],{"type":21,"tag":115,"props":238,"children":239},{"align":88},[240],{"type":26,"value":241},"3",{"type":21,"tag":115,"props":243,"children":244},{"align":88},[245],{"type":21,"tag":124,"props":246,"children":248},{"className":247},[],[249],{"type":26,"value":250},"$08",{"type":21,"tag":115,"props":252,"children":253},{"align":88},[254],{"type":26,"value":255},"Send break",{"type":21,"tag":115,"props":257,"children":258},{"align":88},[259,261,267],{"type":26,"value":260},"Force the ",{"type":21,"tag":124,"props":262,"children":264},{"className":263},[],[265],{"type":26,"value":266},"TxD",{"type":26,"value":268}," line low",{"type":21,"tag":82,"props":270,"children":271},{},[272,277,286,291],{"type":21,"tag":115,"props":273,"children":274},{"align":88},[275],{"type":26,"value":276},"2",{"type":21,"tag":115,"props":278,"children":279},{"align":88},[280],{"type":21,"tag":124,"props":281,"children":283},{"className":282},[],[284],{"type":26,"value":285},"$04",{"type":21,"tag":115,"props":287,"children":288},{"align":88},[289],{"type":26,"value":290},"Rx enable",{"type":21,"tag":115,"props":292,"children":293},{"align":88},[294],{"type":26,"value":295},"Enable the receiver",{"type":21,"tag":82,"props":297,"children":298},{},[299,304,313,318],{"type":21,"tag":115,"props":300,"children":301},{"align":88},[302],{"type":26,"value":303},"1",{"type":21,"tag":115,"props":305,"children":306},{"align":88},[307],{"type":21,"tag":124,"props":308,"children":310},{"className":309},[],[311],{"type":26,"value":312},"$02",{"type":21,"tag":115,"props":314,"children":315},{"align":88},[316],{"type":26,"value":317},"DTR",{"type":21,"tag":115,"props":319,"children":320},{"align":88},[321,322],{"type":26,"value":201},{"type":21,"tag":124,"props":323,"children":325},{"className":324},[],[326],{"type":26,"value":317},{"type":21,"tag":82,"props":328,"children":329},{},[330,335,344,349],{"type":21,"tag":115,"props":331,"children":332},{"align":88},[333],{"type":26,"value":334},"0",{"type":21,"tag":115,"props":336,"children":337},{"align":88},[338],{"type":21,"tag":124,"props":339,"children":341},{"className":340},[],[342],{"type":26,"value":343},"$01",{"type":21,"tag":115,"props":345,"children":346},{"align":88},[347],{"type":26,"value":348},"Tx enable",{"type":21,"tag":115,"props":350,"children":351},{"align":88},[352],{"type":26,"value":353},"Enable the transmitter",{"type":21,"tag":67,"props":355,"children":357},{"id":356},"configuration-mode-flags",[358],{"type":26,"value":359},"Configuration mode flags",{"type":21,"tag":74,"props":361,"children":362},{},[363,387],{"type":21,"tag":78,"props":364,"children":365},{},[366],{"type":21,"tag":82,"props":367,"children":368},{},[369,374,378,382],{"type":21,"tag":86,"props":370,"children":371},{"align":88},[372],{"type":26,"value":373},"Bit(s)",{"type":21,"tag":86,"props":375,"children":376},{"align":88},[377],{"type":26,"value":96},{"type":21,"tag":86,"props":379,"children":380},{"align":88},[381],{"type":26,"value":101},{"type":21,"tag":86,"props":383,"children":384},{"align":88},[385],{"type":26,"value":386},"Values",{"type":21,"tag":108,"props":388,"children":389},{},[390,447,477,514,567],{"type":21,"tag":82,"props":391,"children":392},{},[393,398,407,412],{"type":21,"tag":115,"props":394,"children":395},{"align":88},[396],{"type":26,"value":397},"7-6",{"type":21,"tag":115,"props":399,"children":400},{"align":88},[401],{"type":21,"tag":124,"props":402,"children":404},{"className":403},[],[405],{"type":26,"value":406},"$C0",{"type":21,"tag":115,"props":408,"children":409},{"align":88},[410],{"type":26,"value":411},"Stop bit length",{"type":21,"tag":115,"props":413,"children":414},{"align":88},[415,421,423,429,431,437,439,445],{"type":21,"tag":124,"props":416,"children":418},{"className":417},[],[419],{"type":26,"value":420},"00",{"type":26,"value":422}," = invalid, ",{"type":21,"tag":124,"props":424,"children":426},{"className":425},[],[427],{"type":26,"value":428},"01",{"type":26,"value":430}," = 1 stop bit, ",{"type":21,"tag":124,"props":432,"children":434},{"className":433},[],[435],{"type":26,"value":436},"10",{"type":26,"value":438}," = 1.5 stop bits, ",{"type":21,"tag":124,"props":440,"children":442},{"className":441},[],[443],{"type":26,"value":444},"11",{"type":26,"value":446}," = 2 stop bits",{"type":21,"tag":82,"props":448,"children":449},{},[450,454,462,467],{"type":21,"tag":115,"props":451,"children":452},{"align":88},[453],{"type":26,"value":182},{"type":21,"tag":115,"props":455,"children":456},{"align":88},[457],{"type":21,"tag":124,"props":458,"children":460},{"className":459},[],[461],{"type":26,"value":191},{"type":21,"tag":115,"props":463,"children":464},{"align":88},[465],{"type":26,"value":466},"Parity enable",{"type":21,"tag":115,"props":468,"children":469},{"align":88},[470,475],{"type":21,"tag":124,"props":471,"children":473},{"className":472},[],[474],{"type":26,"value":303},{"type":26,"value":476}," = parity enabled",{"type":21,"tag":82,"props":478,"children":479},{},[480,484,492,497],{"type":21,"tag":115,"props":481,"children":482},{"align":88},[483],{"type":26,"value":214},{"type":21,"tag":115,"props":485,"children":486},{"align":88},[487],{"type":21,"tag":124,"props":488,"children":490},{"className":489},[],[491],{"type":26,"value":223},{"type":21,"tag":115,"props":493,"children":494},{"align":88},[495],{"type":26,"value":496},"Even parity select",{"type":21,"tag":115,"props":498,"children":499},{"align":88},[500,505,507,512],{"type":21,"tag":124,"props":501,"children":503},{"className":502},[],[504],{"type":26,"value":303},{"type":26,"value":506}," = even parity, ",{"type":21,"tag":124,"props":508,"children":510},{"className":509},[],[511],{"type":26,"value":334},{"type":26,"value":513}," = odd parity",{"type":21,"tag":82,"props":515,"children":516},{},[517,522,531,536],{"type":21,"tag":115,"props":518,"children":519},{"align":88},[520],{"type":26,"value":521},"3-2",{"type":21,"tag":115,"props":523,"children":524},{"align":88},[525],{"type":21,"tag":124,"props":526,"children":528},{"className":527},[],[529],{"type":26,"value":530},"$0C",{"type":21,"tag":115,"props":532,"children":533},{"align":88},[534],{"type":26,"value":535},"Character length",{"type":21,"tag":115,"props":537,"children":538},{"align":88},[539,544,546,551,553,558,560,565],{"type":21,"tag":124,"props":540,"children":542},{"className":541},[],[543],{"type":26,"value":420},{"type":26,"value":545}," = 5 bits, ",{"type":21,"tag":124,"props":547,"children":549},{"className":548},[],[550],{"type":26,"value":428},{"type":26,"value":552}," = 6 bits, ",{"type":21,"tag":124,"props":554,"children":556},{"className":555},[],[557],{"type":26,"value":436},{"type":26,"value":559}," = 7 bits, ",{"type":21,"tag":124,"props":561,"children":563},{"className":562},[],[564],{"type":26,"value":444},{"type":26,"value":566}," = 8 bits",{"type":21,"tag":82,"props":568,"children":569},{},[570,575,584,589],{"type":21,"tag":115,"props":571,"children":572},{"align":88},[573],{"type":26,"value":574},"1-0",{"type":21,"tag":115,"props":576,"children":577},{"align":88},[578],{"type":21,"tag":124,"props":579,"children":581},{"className":580},[],[582],{"type":26,"value":583},"$03",{"type":21,"tag":115,"props":585,"children":586},{"align":88},[587],{"type":26,"value":588},"Baud rate factor",{"type":21,"tag":115,"props":590,"children":591},{"align":88},[592,597,599,604,606,612,614,619,620,626,627,632,633],{"type":21,"tag":124,"props":593,"children":595},{"className":594},[],[596],{"type":26,"value":420},{"type":26,"value":598}," = sync mode, ",{"type":21,"tag":124,"props":600,"children":602},{"className":601},[],[603],{"type":26,"value":428},{"type":26,"value":605}," = ",{"type":21,"tag":124,"props":607,"children":609},{"className":608},[],[610],{"type":26,"value":611},"1x",{"type":26,"value":613},", ",{"type":21,"tag":124,"props":615,"children":617},{"className":616},[],[618],{"type":26,"value":436},{"type":26,"value":605},{"type":21,"tag":124,"props":621,"children":623},{"className":622},[],[624],{"type":26,"value":625},"16x",{"type":26,"value":613},{"type":21,"tag":124,"props":628,"children":630},{"className":629},[],[631],{"type":26,"value":444},{"type":26,"value":605},{"type":21,"tag":124,"props":634,"children":636},{"className":635},[],[637],{"type":26,"value":638},"64x",{"type":21,"tag":67,"props":640,"children":642},{"id":641},"status-register-flags",[643],{"type":26,"value":644},"Status register flags",{"type":21,"tag":74,"props":646,"children":647},{},[648,671],{"type":21,"tag":78,"props":649,"children":650},{},[651],{"type":21,"tag":82,"props":652,"children":653},{},[654,658,662,666],{"type":21,"tag":86,"props":655,"children":656},{"align":88},[657],{"type":26,"value":91},{"type":21,"tag":86,"props":659,"children":660},{"align":88},[661],{"type":26,"value":96},{"type":21,"tag":86,"props":663,"children":664},{"align":88},[665],{"type":26,"value":101},{"type":21,"tag":86,"props":667,"children":668},{"align":88},[669],{"type":26,"value":670},"Function",{"type":21,"tag":108,"props":672,"children":673},{},[674,699,724,749,774,799,824,849],{"type":21,"tag":82,"props":675,"children":676},{},[677,681,689,694],{"type":21,"tag":115,"props":678,"children":679},{"align":88},[680],{"type":26,"value":334},{"type":21,"tag":115,"props":682,"children":683},{"align":88},[684],{"type":21,"tag":124,"props":685,"children":687},{"className":686},[],[688],{"type":26,"value":343},{"type":21,"tag":115,"props":690,"children":691},{"align":88},[692],{"type":26,"value":693},"Transmit Ready",{"type":21,"tag":115,"props":695,"children":696},{"align":88},[697],{"type":26,"value":698},"High when the transmit buffer/register is empty and ready to accept the next data character from the CPU.",{"type":21,"tag":82,"props":700,"children":701},{},[702,706,714,719],{"type":21,"tag":115,"props":703,"children":704},{"align":88},[705],{"type":26,"value":303},{"type":21,"tag":115,"props":707,"children":708},{"align":88},[709],{"type":21,"tag":124,"props":710,"children":712},{"className":711},[],[713],{"type":26,"value":312},{"type":21,"tag":115,"props":715,"children":716},{"align":88},[717],{"type":26,"value":718},"Receive Ready",{"type":21,"tag":115,"props":720,"children":721},{"align":88},[722],{"type":26,"value":723},"High when the receiver has a character assembled and ready to be read by the CPU.",{"type":21,"tag":82,"props":725,"children":726},{},[727,731,739,744],{"type":21,"tag":115,"props":728,"children":729},{"align":88},[730],{"type":26,"value":276},{"type":21,"tag":115,"props":732,"children":733},{"align":88},[734],{"type":21,"tag":124,"props":735,"children":737},{"className":736},[],[738],{"type":26,"value":285},{"type":21,"tag":115,"props":740,"children":741},{"align":88},[742],{"type":26,"value":743},"Transmit Empty",{"type":21,"tag":115,"props":745,"children":746},{"align":88},[747],{"type":26,"value":748},"High in synchronous mode when the transmitter has no characters to send and the USART is sending sync characters. In asynchronous mode, it indicates the line has returned to the mark state.",{"type":21,"tag":82,"props":750,"children":751},{},[752,756,764,769],{"type":21,"tag":115,"props":753,"children":754},{"align":88},[755],{"type":26,"value":241},{"type":21,"tag":115,"props":757,"children":758},{"align":88},[759],{"type":21,"tag":124,"props":760,"children":762},{"className":761},[],[763],{"type":26,"value":250},{"type":21,"tag":115,"props":765,"children":766},{"align":88},[767],{"type":26,"value":768},"Parity Error",{"type":21,"tag":115,"props":770,"children":771},{"align":88},[772],{"type":26,"value":773},"High if the received data character does not match the parity selected by the mode instruction.",{"type":21,"tag":82,"props":775,"children":776},{},[777,781,789,794],{"type":21,"tag":115,"props":778,"children":779},{"align":88},[780],{"type":26,"value":214},{"type":21,"tag":115,"props":782,"children":783},{"align":88},[784],{"type":21,"tag":124,"props":785,"children":787},{"className":786},[],[788],{"type":26,"value":223},{"type":21,"tag":115,"props":790,"children":791},{"align":88},[792],{"type":26,"value":793},"Overrun Error",{"type":21,"tag":115,"props":795,"children":796},{"align":88},[797],{"type":26,"value":798},"High if the CPU does not read the previous character before the next one is received, causing data loss.",{"type":21,"tag":82,"props":800,"children":801},{},[802,806,814,819],{"type":21,"tag":115,"props":803,"children":804},{"align":88},[805],{"type":26,"value":182},{"type":21,"tag":115,"props":807,"children":808},{"align":88},[809],{"type":21,"tag":124,"props":810,"children":812},{"className":811},[],[813],{"type":26,"value":191},{"type":21,"tag":115,"props":815,"children":816},{"align":88},[817],{"type":26,"value":818},"Framing Error",{"type":21,"tag":115,"props":820,"children":821},{"align":88},[822],{"type":26,"value":823},"High in asynchronous mode if the stop bit of a received character is missing or invalid.",{"type":21,"tag":82,"props":825,"children":826},{},[827,831,839,844],{"type":21,"tag":115,"props":828,"children":829},{"align":88},[830],{"type":26,"value":155},{"type":21,"tag":115,"props":832,"children":833},{"align":88},[834],{"type":21,"tag":124,"props":835,"children":837},{"className":836},[],[838],{"type":26,"value":164},{"type":21,"tag":115,"props":840,"children":841},{"align":88},[842],{"type":26,"value":843},"Sync/Break Detect",{"type":21,"tag":115,"props":845,"children":846},{"align":88},[847],{"type":26,"value":848},"Indicates the detection of the sync character in synchronous mode, or a break condition in asynchronous mode.",{"type":21,"tag":82,"props":850,"children":851},{},[852,856,864,869],{"type":21,"tag":115,"props":853,"children":854},{"align":88},[855],{"type":26,"value":119},{"type":21,"tag":115,"props":857,"children":858},{"align":88},[859],{"type":21,"tag":124,"props":860,"children":862},{"className":861},[],[863],{"type":26,"value":129},{"type":21,"tag":115,"props":865,"children":866},{"align":88},[867],{"type":26,"value":868},"Data Set Ready",{"type":21,"tag":115,"props":870,"children":871},{"align":88},[872],{"type":26,"value":873},"Reflects the inverted status of the active-low DSR input pin from the modem or peripheral device.",{"type":21,"tag":55,"props":875,"children":877},{"id":876},"hardware-initialisation",[878],{"type":26,"value":879},"Hardware Initialisation",{"type":21,"tag":22,"props":881,"children":882},{},[883,885,891,893,899],{"type":26,"value":884},"Before the modem can do anything, the 8251 needs to be initialized and the ",{"type":21,"tag":124,"props":886,"children":888},{"className":887},[],[889],{"type":26,"value":890},"HW_INIT",{"type":26,"value":892}," routine at ",{"type":21,"tag":124,"props":894,"children":896},{"className":895},[],[897],{"type":26,"value":898},"$1424",{"type":26,"value":900}," does just that:",{"type":21,"tag":902,"props":903,"children":908},"pre",{"className":904,"code":905,"language":906,"meta":907,"style":907},"language-z80 shiki shiki-themes everforest-light dracula","HW_INIT:\n    LD A,$82            ; Hunt mode + DTR asserted\n    OUT ($FF),A         ; Write to 8251 command register\n    RES 5,(IY+$01)      ; Clear Spectrum's \"new key\" flag\n    LD A,$40            ; Internal reset command \n    OUT ($FF),A         ; Reset the 8251\n    ; ... timing NOPs ...\n    XOR A\n    OUT ($FE),A         ; Set border to black\n    LD A,(IX+$07)       ; Load configured mode register value\n    OUT ($FF),A         ; Write mode to 8251\n    LD (IX+$1B),$64     ; Set idle timeout to 100 (decimal)\n","z80","",[909],{"type":21,"tag":124,"props":910,"children":911},{"__ignoreMap":907},[912,929,962,996,1039,1064,1093,1102,1116,1146,1186,1215],{"type":21,"tag":913,"props":914,"children":917},"span",{"class":915,"line":916},"line",1,[918,923],{"type":21,"tag":913,"props":919,"children":921},{"style":920},"--shiki-default:#35A77C;--shiki-dark:#F8F8F2",[922],{"type":26,"value":890},{"type":21,"tag":913,"props":924,"children":926},{"style":925},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[927],{"type":26,"value":928},":\n",{"type":21,"tag":913,"props":930,"children":932},{"class":915,"line":931},2,[933,939,945,950,956],{"type":21,"tag":913,"props":934,"children":936},{"style":935},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[937],{"type":26,"value":938},"    LD",{"type":21,"tag":913,"props":940,"children":942},{"style":941},"--shiki-default:#5C6A72;--shiki-default-font-style:inherit;--shiki-dark:#BD93F9;--shiki-dark-font-style:italic",[943],{"type":26,"value":944}," A",{"type":21,"tag":913,"props":946,"children":947},{"style":925},[948],{"type":26,"value":949},",",{"type":21,"tag":913,"props":951,"children":953},{"style":952},"--shiki-default:#DF69BA;--shiki-dark:#BD93F9",[954],{"type":26,"value":955},"$82",{"type":21,"tag":913,"props":957,"children":959},{"style":958},"--shiki-default:#939F91;--shiki-default-font-style:italic;--shiki-dark:#6272A4;--shiki-dark-font-style:inherit",[960],{"type":26,"value":961},"            ; Hunt mode + DTR asserted\n",{"type":21,"tag":913,"props":963,"children":965},{"class":915,"line":964},3,[966,971,976,981,986,991],{"type":21,"tag":913,"props":967,"children":968},{"style":935},[969],{"type":26,"value":970},"    OUT",{"type":21,"tag":913,"props":972,"children":973},{"style":925},[974],{"type":26,"value":975}," (",{"type":21,"tag":913,"props":977,"children":978},{"style":952},[979],{"type":26,"value":980},"$FF",{"type":21,"tag":913,"props":982,"children":983},{"style":925},[984],{"type":26,"value":985},"),",{"type":21,"tag":913,"props":987,"children":988},{"style":941},[989],{"type":26,"value":990},"A",{"type":21,"tag":913,"props":992,"children":993},{"style":958},[994],{"type":26,"value":995},"         ; Write to 8251 command register\n",{"type":21,"tag":913,"props":997,"children":999},{"class":915,"line":998},4,[1000,1005,1010,1015,1020,1025,1029,1034],{"type":21,"tag":913,"props":1001,"children":1002},{"style":935},[1003],{"type":26,"value":1004},"    RES",{"type":21,"tag":913,"props":1006,"children":1007},{"style":952},[1008],{"type":26,"value":1009}," 5",{"type":21,"tag":913,"props":1011,"children":1012},{"style":925},[1013],{"type":26,"value":1014},",(",{"type":21,"tag":913,"props":1016,"children":1017},{"style":941},[1018],{"type":26,"value":1019},"IY",{"type":21,"tag":913,"props":1021,"children":1022},{"style":925},[1023],{"type":26,"value":1024},"+",{"type":21,"tag":913,"props":1026,"children":1027},{"style":952},[1028],{"type":26,"value":343},{"type":21,"tag":913,"props":1030,"children":1031},{"style":925},[1032],{"type":26,"value":1033},")      ",{"type":21,"tag":913,"props":1035,"children":1036},{"style":958},[1037],{"type":26,"value":1038},"; Clear Spectrum's \"new key\" flag\n",{"type":21,"tag":913,"props":1040,"children":1042},{"class":915,"line":1041},5,[1043,1047,1051,1055,1059],{"type":21,"tag":913,"props":1044,"children":1045},{"style":935},[1046],{"type":26,"value":938},{"type":21,"tag":913,"props":1048,"children":1049},{"style":941},[1050],{"type":26,"value":944},{"type":21,"tag":913,"props":1052,"children":1053},{"style":925},[1054],{"type":26,"value":949},{"type":21,"tag":913,"props":1056,"children":1057},{"style":952},[1058],{"type":26,"value":164},{"type":21,"tag":913,"props":1060,"children":1061},{"style":958},[1062],{"type":26,"value":1063},"            ; Internal reset command \n",{"type":21,"tag":913,"props":1065,"children":1067},{"class":915,"line":1066},6,[1068,1072,1076,1080,1084,1088],{"type":21,"tag":913,"props":1069,"children":1070},{"style":935},[1071],{"type":26,"value":970},{"type":21,"tag":913,"props":1073,"children":1074},{"style":925},[1075],{"type":26,"value":975},{"type":21,"tag":913,"props":1077,"children":1078},{"style":952},[1079],{"type":26,"value":980},{"type":21,"tag":913,"props":1081,"children":1082},{"style":925},[1083],{"type":26,"value":985},{"type":21,"tag":913,"props":1085,"children":1086},{"style":941},[1087],{"type":26,"value":990},{"type":21,"tag":913,"props":1089,"children":1090},{"style":958},[1091],{"type":26,"value":1092},"         ; Reset the 8251\n",{"type":21,"tag":913,"props":1094,"children":1096},{"class":915,"line":1095},7,[1097],{"type":21,"tag":913,"props":1098,"children":1099},{"style":958},[1100],{"type":26,"value":1101},"    ; ... timing NOPs ...\n",{"type":21,"tag":913,"props":1103,"children":1105},{"class":915,"line":1104},8,[1106,1111],{"type":21,"tag":913,"props":1107,"children":1108},{"style":935},[1109],{"type":26,"value":1110},"    XOR",{"type":21,"tag":913,"props":1112,"children":1113},{"style":941},[1114],{"type":26,"value":1115}," A\n",{"type":21,"tag":913,"props":1117,"children":1119},{"class":915,"line":1118},9,[1120,1124,1128,1133,1137,1141],{"type":21,"tag":913,"props":1121,"children":1122},{"style":935},[1123],{"type":26,"value":970},{"type":21,"tag":913,"props":1125,"children":1126},{"style":925},[1127],{"type":26,"value":975},{"type":21,"tag":913,"props":1129,"children":1130},{"style":952},[1131],{"type":26,"value":1132},"$FE",{"type":21,"tag":913,"props":1134,"children":1135},{"style":925},[1136],{"type":26,"value":985},{"type":21,"tag":913,"props":1138,"children":1139},{"style":941},[1140],{"type":26,"value":990},{"type":21,"tag":913,"props":1142,"children":1143},{"style":958},[1144],{"type":26,"value":1145},"         ; Set border to black\n",{"type":21,"tag":913,"props":1147,"children":1149},{"class":915,"line":1148},10,[1150,1154,1158,1162,1167,1171,1176,1181],{"type":21,"tag":913,"props":1151,"children":1152},{"style":935},[1153],{"type":26,"value":938},{"type":21,"tag":913,"props":1155,"children":1156},{"style":941},[1157],{"type":26,"value":944},{"type":21,"tag":913,"props":1159,"children":1160},{"style":925},[1161],{"type":26,"value":1014},{"type":21,"tag":913,"props":1163,"children":1164},{"style":941},[1165],{"type":26,"value":1166},"IX",{"type":21,"tag":913,"props":1168,"children":1169},{"style":925},[1170],{"type":26,"value":1024},{"type":21,"tag":913,"props":1172,"children":1173},{"style":952},[1174],{"type":26,"value":1175},"$07",{"type":21,"tag":913,"props":1177,"children":1178},{"style":925},[1179],{"type":26,"value":1180},")       ",{"type":21,"tag":913,"props":1182,"children":1183},{"style":958},[1184],{"type":26,"value":1185},"; Load configured mode register value\n",{"type":21,"tag":913,"props":1187,"children":1189},{"class":915,"line":1188},11,[1190,1194,1198,1202,1206,1210],{"type":21,"tag":913,"props":1191,"children":1192},{"style":935},[1193],{"type":26,"value":970},{"type":21,"tag":913,"props":1195,"children":1196},{"style":925},[1197],{"type":26,"value":975},{"type":21,"tag":913,"props":1199,"children":1200},{"style":952},[1201],{"type":26,"value":980},{"type":21,"tag":913,"props":1203,"children":1204},{"style":925},[1205],{"type":26,"value":985},{"type":21,"tag":913,"props":1207,"children":1208},{"style":941},[1209],{"type":26,"value":990},{"type":21,"tag":913,"props":1211,"children":1212},{"style":958},[1213],{"type":26,"value":1214},"         ; Write mode to 8251\n",{"type":21,"tag":913,"props":1216,"children":1218},{"class":915,"line":1217},12,[1219,1223,1227,1231,1235,1240,1244,1249],{"type":21,"tag":913,"props":1220,"children":1221},{"style":935},[1222],{"type":26,"value":938},{"type":21,"tag":913,"props":1224,"children":1225},{"style":925},[1226],{"type":26,"value":975},{"type":21,"tag":913,"props":1228,"children":1229},{"style":941},[1230],{"type":26,"value":1166},{"type":21,"tag":913,"props":1232,"children":1233},{"style":925},[1234],{"type":26,"value":1024},{"type":21,"tag":913,"props":1236,"children":1237},{"style":952},[1238],{"type":26,"value":1239},"$1B",{"type":21,"tag":913,"props":1241,"children":1242},{"style":925},[1243],{"type":26,"value":985},{"type":21,"tag":913,"props":1245,"children":1246},{"style":952},[1247],{"type":26,"value":1248},"$64",{"type":21,"tag":913,"props":1250,"children":1251},{"style":958},[1252],{"type":26,"value":1253},"     ; Set idle timeout to 100 (decimal)\n",{"type":21,"tag":22,"props":1255,"children":1256},{},[1257],{"type":26,"value":1258},"At first glance this looks like it sets the 8251 into \"hunt mode\" via $82 which would use the shift register to find SYN bytes... BUT we're actually going to be using async so why do this? To flip the 8251 out of any pending state so that the $40 reset command that follows will work.",{"type":21,"tag":22,"props":1260,"children":1261},{},[1262],{"type":26,"value":1263},"Once it sees that reset it knows the next byte will be the actual configuration from IX+$07 which is $7B for our async 7-bit data, even parity, 1 stop bit, 64× clock mode.",{"type":21,"tag":55,"props":1265,"children":1267},{"id":1266},"the-ix-table",[1268],{"type":26,"value":1269},"The IX Table",{"type":21,"tag":22,"props":1271,"children":1272},{},[1273],{"type":26,"value":1274},"The IX register points to a table full of state and configuration the ROM uses extensively to save swapping registers a bunch.",{"type":21,"tag":74,"props":1276,"children":1277},{},[1278,1300],{"type":21,"tag":78,"props":1279,"children":1280},{},[1281],{"type":21,"tag":82,"props":1282,"children":1283},{},[1284,1290,1295],{"type":21,"tag":86,"props":1285,"children":1287},{"align":1286},"center",[1288],{"type":26,"value":1289},"Offset",{"type":21,"tag":86,"props":1291,"children":1292},{"align":1286},[1293],{"type":26,"value":1294},"Default",{"type":21,"tag":86,"props":1296,"children":1297},{},[1298],{"type":26,"value":1299},"Purpose",{"type":21,"tag":108,"props":1301,"children":1302},{},[1303,1328,1353,1387,1412,1437,1463,1489,1515,1541,1566,1591,1616,1641,1666,1691,1716,1741,1766,1792,1817,1842,1867,1891,1916,1941,1966,1991,2029,2054,2079,2104,2130,2156,2181,2206,2231,2256,2281,2312,2337,2367,2392,2423],{"type":21,"tag":82,"props":1304,"children":1305},{},[1306,1315,1323],{"type":21,"tag":115,"props":1307,"children":1308},{"align":1286},[1309],{"type":21,"tag":124,"props":1310,"children":1312},{"className":1311},[],[1313],{"type":26,"value":1314},"+$00",{"type":21,"tag":115,"props":1316,"children":1317},{"align":1286},[1318],{"type":21,"tag":124,"props":1319,"children":1321},{"className":1320},[],[1322],{"type":26,"value":406},{"type":21,"tag":115,"props":1324,"children":1325},{},[1326],{"type":26,"value":1327},"Splash-screen tail byte (not used as IX data)",{"type":21,"tag":82,"props":1329,"children":1330},{},[1331,1340,1348],{"type":21,"tag":115,"props":1332,"children":1333},{"align":1286},[1334],{"type":21,"tag":124,"props":1335,"children":1337},{"className":1336},[],[1338],{"type":26,"value":1339},"+$01",{"type":21,"tag":115,"props":1341,"children":1342},{"align":1286},[1343],{"type":21,"tag":124,"props":1344,"children":1346},{"className":1345},[],[1347],{"type":26,"value":583},{"type":21,"tag":115,"props":1349,"children":1350},{},[1351],{"type":26,"value":1352},"Splash-screen tail byte",{"type":21,"tag":82,"props":1354,"children":1355},{},[1356,1365,1374],{"type":21,"tag":115,"props":1357,"children":1358},{"align":1286},[1359],{"type":21,"tag":124,"props":1360,"children":1362},{"className":1361},[],[1363],{"type":26,"value":1364},"+$02",{"type":21,"tag":115,"props":1366,"children":1367},{"align":1286},[1368],{"type":21,"tag":124,"props":1369,"children":1371},{"className":1370},[],[1372],{"type":26,"value":1373},"$58",{"type":21,"tag":115,"props":1375,"children":1376},{},[1377,1379,1385],{"type":26,"value":1378},"Splash-screen tail byte (",{"type":21,"tag":124,"props":1380,"children":1382},{"className":1381},[],[1383],{"type":26,"value":1384},"'X'",{"type":26,"value":1386},")",{"type":21,"tag":82,"props":1388,"children":1389},{},[1390,1399,1407],{"type":21,"tag":115,"props":1391,"children":1392},{"align":1286},[1393],{"type":21,"tag":124,"props":1394,"children":1396},{"className":1395},[],[1397],{"type":26,"value":1398},"+$03",{"type":21,"tag":115,"props":1400,"children":1401},{"align":1286},[1402],{"type":21,"tag":124,"props":1403,"children":1405},{"className":1404},[],[1406],{"type":26,"value":312},{"type":21,"tag":115,"props":1408,"children":1409},{},[1410],{"type":26,"value":1411},"Buffer countdown (high byte)",{"type":21,"tag":82,"props":1413,"children":1414},{},[1415,1424,1432],{"type":21,"tag":115,"props":1416,"children":1417},{"align":1286},[1418],{"type":21,"tag":124,"props":1419,"children":1421},{"className":1420},[],[1422],{"type":26,"value":1423},"+$04",{"type":21,"tag":115,"props":1425,"children":1426},{"align":1286},[1427],{"type":21,"tag":124,"props":1428,"children":1430},{"className":1429},[],[1431],{"type":26,"value":980},{"type":21,"tag":115,"props":1433,"children":1434},{},[1435],{"type":26,"value":1436},"Buffer size (255)",{"type":21,"tag":82,"props":1438,"children":1439},{},[1440,1449,1458],{"type":21,"tag":115,"props":1441,"children":1442},{"align":1286},[1443],{"type":21,"tag":124,"props":1444,"children":1446},{"className":1445},[],[1447],{"type":26,"value":1448},"+$05",{"type":21,"tag":115,"props":1450,"children":1451},{"align":1286},[1452],{"type":21,"tag":124,"props":1453,"children":1455},{"className":1454},[],[1456],{"type":26,"value":1457},"$00",{"type":21,"tag":115,"props":1459,"children":1460},{},[1461],{"type":26,"value":1462},"Unused / reserved",{"type":21,"tag":82,"props":1464,"children":1465},{},[1466,1475,1484],{"type":21,"tag":115,"props":1467,"children":1468},{"align":1286},[1469],{"type":21,"tag":124,"props":1470,"children":1472},{"className":1471},[],[1473],{"type":26,"value":1474},"+$06",{"type":21,"tag":115,"props":1476,"children":1477},{"align":1286},[1478],{"type":21,"tag":124,"props":1479,"children":1481},{"className":1480},[],[1482],{"type":26,"value":1483},"$60",{"type":21,"tag":115,"props":1485,"children":1486},{},[1487],{"type":26,"value":1488},"Device flags (bits 5+6 set at boot: TX busy + b6)",{"type":21,"tag":82,"props":1490,"children":1491},{},[1492,1501,1510],{"type":21,"tag":115,"props":1493,"children":1494},{"align":1286},[1495],{"type":21,"tag":124,"props":1496,"children":1498},{"className":1497},[],[1499],{"type":26,"value":1500},"+$07",{"type":21,"tag":115,"props":1502,"children":1503},{"align":1286},[1504],{"type":21,"tag":124,"props":1505,"children":1507},{"className":1506},[],[1508],{"type":26,"value":1509},"$7B",{"type":21,"tag":115,"props":1511,"children":1512},{},[1513],{"type":26,"value":1514},"8251 mode register: 7-bit data, even parity, 1 stop bit, 64× clock",{"type":21,"tag":82,"props":1516,"children":1517},{},[1518,1527,1536],{"type":21,"tag":115,"props":1519,"children":1520},{"align":1286},[1521],{"type":21,"tag":124,"props":1522,"children":1524},{"className":1523},[],[1525],{"type":26,"value":1526},"+$08",{"type":21,"tag":115,"props":1528,"children":1529},{"align":1286},[1530],{"type":21,"tag":124,"props":1531,"children":1533},{"className":1532},[],[1534],{"type":26,"value":1535},"$15",{"type":21,"tag":115,"props":1537,"children":1538},{},[1539],{"type":26,"value":1540},"8251 command register: RxEn/TxEn/DTR, RTS=0 (VTX ROM paged in)",{"type":21,"tag":82,"props":1542,"children":1543},{},[1544,1553,1561],{"type":21,"tag":115,"props":1545,"children":1546},{"align":1286},[1547],{"type":21,"tag":124,"props":1548,"children":1550},{"className":1549},[],[1551],{"type":26,"value":1552},"+$09",{"type":21,"tag":115,"props":1554,"children":1555},{"align":1286},[1556],{"type":21,"tag":124,"props":1557,"children":1559},{"className":1558},[],[1560],{"type":26,"value":1457},{"type":21,"tag":115,"props":1562,"children":1563},{},[1564],{"type":26,"value":1565},"Keyboard / input state flags",{"type":21,"tag":82,"props":1567,"children":1568},{},[1569,1578,1586],{"type":21,"tag":115,"props":1570,"children":1571},{"align":1286},[1572],{"type":21,"tag":124,"props":1573,"children":1575},{"className":1574},[],[1576],{"type":26,"value":1577},"+$0A",{"type":21,"tag":115,"props":1579,"children":1580},{"align":1286},[1581],{"type":21,"tag":124,"props":1582,"children":1584},{"className":1583},[],[1585],{"type":26,"value":1457},{"type":21,"tag":115,"props":1587,"children":1588},{},[1589],{"type":26,"value":1590},"Prestel frame parser state",{"type":21,"tag":82,"props":1592,"children":1593},{},[1594,1603,1611],{"type":21,"tag":115,"props":1595,"children":1596},{"align":1286},[1597],{"type":21,"tag":124,"props":1598,"children":1600},{"className":1599},[],[1601],{"type":26,"value":1602},"+$0B",{"type":21,"tag":115,"props":1604,"children":1605},{"align":1286},[1606],{"type":21,"tag":124,"props":1607,"children":1609},{"className":1608},[],[1610],{"type":26,"value":1457},{"type":21,"tag":115,"props":1612,"children":1613},{},[1614],{"type":26,"value":1615},"Return code (0 = continue, 1 = BREAK, 2 = timeout, 3 = carrier lost, 4 = error, 5 = frame complete, 6 = retry, 7 = specific)",{"type":21,"tag":82,"props":1617,"children":1618},{},[1619,1628,1636],{"type":21,"tag":115,"props":1620,"children":1621},{"align":1286},[1622],{"type":21,"tag":124,"props":1623,"children":1625},{"className":1624},[],[1626],{"type":26,"value":1627},"+$0C",{"type":21,"tag":115,"props":1629,"children":1630},{"align":1286},[1631],{"type":21,"tag":124,"props":1632,"children":1634},{"className":1633},[],[1635],{"type":26,"value":1457},{"type":21,"tag":115,"props":1637,"children":1638},{},[1639],{"type":26,"value":1640},"Cursor row",{"type":21,"tag":82,"props":1642,"children":1643},{},[1644,1653,1661],{"type":21,"tag":115,"props":1645,"children":1646},{"align":1286},[1647],{"type":21,"tag":124,"props":1648,"children":1650},{"className":1649},[],[1651],{"type":26,"value":1652},"+$0D",{"type":21,"tag":115,"props":1654,"children":1655},{"align":1286},[1656],{"type":21,"tag":124,"props":1657,"children":1659},{"className":1658},[],[1660],{"type":26,"value":1457},{"type":21,"tag":115,"props":1662,"children":1663},{},[1664],{"type":26,"value":1665},"Cursor column",{"type":21,"tag":82,"props":1667,"children":1668},{},[1669,1678,1686],{"type":21,"tag":115,"props":1670,"children":1671},{"align":1286},[1672],{"type":21,"tag":124,"props":1673,"children":1675},{"className":1674},[],[1676],{"type":26,"value":1677},"+$0E",{"type":21,"tag":115,"props":1679,"children":1680},{"align":1286},[1681],{"type":21,"tag":124,"props":1682,"children":1684},{"className":1683},[],[1685],{"type":26,"value":1457},{"type":21,"tag":115,"props":1687,"children":1688},{},[1689],{"type":26,"value":1690},"Last row rendered",{"type":21,"tag":82,"props":1692,"children":1693},{},[1694,1703,1711],{"type":21,"tag":115,"props":1695,"children":1696},{"align":1286},[1697],{"type":21,"tag":124,"props":1698,"children":1700},{"className":1699},[],[1701],{"type":26,"value":1702},"+$0F",{"type":21,"tag":115,"props":1704,"children":1705},{"align":1286},[1706],{"type":21,"tag":124,"props":1707,"children":1709},{"className":1708},[],[1710],{"type":26,"value":1457},{"type":21,"tag":115,"props":1712,"children":1713},{},[1714],{"type":26,"value":1715},"Last column rendered",{"type":21,"tag":82,"props":1717,"children":1718},{},[1719,1728,1736],{"type":21,"tag":115,"props":1720,"children":1721},{"align":1286},[1722],{"type":21,"tag":124,"props":1723,"children":1725},{"className":1724},[],[1726],{"type":26,"value":1727},"+$10",{"type":21,"tag":115,"props":1729,"children":1730},{"align":1286},[1731],{"type":21,"tag":124,"props":1732,"children":1734},{"className":1733},[],[1735],{"type":26,"value":1457},{"type":21,"tag":115,"props":1737,"children":1738},{},[1739],{"type":26,"value":1740},"Previous line number (dirty-line tracking)",{"type":21,"tag":82,"props":1742,"children":1743},{},[1744,1753,1761],{"type":21,"tag":115,"props":1745,"children":1746},{"align":1286},[1747],{"type":21,"tag":124,"props":1748,"children":1750},{"className":1749},[],[1751],{"type":26,"value":1752},"+$11",{"type":21,"tag":115,"props":1754,"children":1755},{"align":1286},[1756],{"type":21,"tag":124,"props":1757,"children":1759},{"className":1758},[],[1760],{"type":26,"value":1457},{"type":21,"tag":115,"props":1762,"children":1763},{},[1764],{"type":26,"value":1765},"Display attribute state (low byte - EXX pair)",{"type":21,"tag":82,"props":1767,"children":1768},{},[1769,1778,1787],{"type":21,"tag":115,"props":1770,"children":1771},{"align":1286},[1772],{"type":21,"tag":124,"props":1773,"children":1775},{"className":1774},[],[1776],{"type":26,"value":1777},"+$12",{"type":21,"tag":115,"props":1779,"children":1780},{"align":1286},[1781],{"type":21,"tag":124,"props":1782,"children":1784},{"className":1783},[],[1785],{"type":26,"value":1786},"$47",{"type":21,"tag":115,"props":1788,"children":1789},{},[1790],{"type":26,"value":1791},"Display attribute state (high): bright white ink on black paper",{"type":21,"tag":82,"props":1793,"children":1794},{},[1795,1804,1812],{"type":21,"tag":115,"props":1796,"children":1797},{"align":1286},[1798],{"type":21,"tag":124,"props":1799,"children":1801},{"className":1800},[],[1802],{"type":26,"value":1803},"+$13",{"type":21,"tag":115,"props":1805,"children":1806},{"align":1286},[1807],{"type":21,"tag":124,"props":1808,"children":1810},{"className":1809},[],[1811],{"type":26,"value":1457},{"type":21,"tag":115,"props":1813,"children":1814},{},[1815],{"type":26,"value":1816},"Saved attribute state (low)",{"type":21,"tag":82,"props":1818,"children":1819},{},[1820,1829,1837],{"type":21,"tag":115,"props":1821,"children":1822},{"align":1286},[1823],{"type":21,"tag":124,"props":1824,"children":1826},{"className":1825},[],[1827],{"type":26,"value":1828},"+$14",{"type":21,"tag":115,"props":1830,"children":1831},{"align":1286},[1832],{"type":21,"tag":124,"props":1833,"children":1835},{"className":1834},[],[1836],{"type":26,"value":1457},{"type":21,"tag":115,"props":1838,"children":1839},{},[1840],{"type":26,"value":1841},"Saved attribute state (high)",{"type":21,"tag":82,"props":1843,"children":1844},{},[1845,1854,1862],{"type":21,"tag":115,"props":1846,"children":1847},{"align":1286},[1848],{"type":21,"tag":124,"props":1849,"children":1851},{"className":1850},[],[1852],{"type":26,"value":1853},"+$15",{"type":21,"tag":115,"props":1855,"children":1856},{"align":1286},[1857],{"type":21,"tag":124,"props":1858,"children":1860},{"className":1859},[],[1861],{"type":26,"value":1457},{"type":21,"tag":115,"props":1863,"children":1864},{},[1865],{"type":26,"value":1866},"Current display attribute",{"type":21,"tag":82,"props":1868,"children":1869},{},[1870,1879,1887],{"type":21,"tag":115,"props":1871,"children":1872},{"align":1286},[1873],{"type":21,"tag":124,"props":1874,"children":1876},{"className":1875},[],[1877],{"type":26,"value":1878},"+$16",{"type":21,"tag":115,"props":1880,"children":1881},{"align":1286},[1882],{"type":21,"tag":124,"props":1883,"children":1885},{"className":1884},[],[1886],{"type":26,"value":1457},{"type":21,"tag":115,"props":1888,"children":1889},{},[1890],{"type":26,"value":1462},{"type":21,"tag":82,"props":1892,"children":1893},{},[1894,1903,1911],{"type":21,"tag":115,"props":1895,"children":1896},{"align":1286},[1897],{"type":21,"tag":124,"props":1898,"children":1900},{"className":1899},[],[1901],{"type":26,"value":1902},"+$17",{"type":21,"tag":115,"props":1904,"children":1905},{"align":1286},[1906],{"type":21,"tag":124,"props":1907,"children":1909},{"className":1908},[],[1910],{"type":26,"value":1457},{"type":21,"tag":115,"props":1912,"children":1913},{},[1914],{"type":26,"value":1915},"Saved attribute for restore",{"type":21,"tag":82,"props":1917,"children":1918},{},[1919,1928,1936],{"type":21,"tag":115,"props":1920,"children":1921},{"align":1286},[1922],{"type":21,"tag":124,"props":1923,"children":1925},{"className":1924},[],[1926],{"type":26,"value":1927},"+$18",{"type":21,"tag":115,"props":1929,"children":1930},{"align":1286},[1931],{"type":21,"tag":124,"props":1932,"children":1934},{"className":1933},[],[1935],{"type":26,"value":1457},{"type":21,"tag":115,"props":1937,"children":1938},{},[1939],{"type":26,"value":1940},"Previous keyboard scan result",{"type":21,"tag":82,"props":1942,"children":1943},{},[1944,1953,1961],{"type":21,"tag":115,"props":1945,"children":1946},{"align":1286},[1947],{"type":21,"tag":124,"props":1948,"children":1950},{"className":1949},[],[1951],{"type":26,"value":1952},"+$19",{"type":21,"tag":115,"props":1954,"children":1955},{"align":1286},[1956],{"type":21,"tag":124,"props":1957,"children":1959},{"className":1958},[],[1960],{"type":26,"value":1457},{"type":21,"tag":115,"props":1962,"children":1963},{},[1964],{"type":26,"value":1965},"Carrier-detect timeout (low)",{"type":21,"tag":82,"props":1967,"children":1968},{},[1969,1978,1986],{"type":21,"tag":115,"props":1970,"children":1971},{"align":1286},[1972],{"type":21,"tag":124,"props":1973,"children":1975},{"className":1974},[],[1976],{"type":26,"value":1977},"+$1A",{"type":21,"tag":115,"props":1979,"children":1980},{"align":1286},[1981],{"type":21,"tag":124,"props":1982,"children":1984},{"className":1983},[],[1985],{"type":26,"value":1457},{"type":21,"tag":115,"props":1987,"children":1988},{},[1989],{"type":26,"value":1990},"Carrier-detect timeout (high)",{"type":21,"tag":82,"props":1992,"children":1993},{},[1994,2003,2011],{"type":21,"tag":115,"props":1995,"children":1996},{"align":1286},[1997],{"type":21,"tag":124,"props":1998,"children":2000},{"className":1999},[],[2001],{"type":26,"value":2002},"+$1B",{"type":21,"tag":115,"props":2004,"children":2005},{"align":1286},[2006],{"type":21,"tag":124,"props":2007,"children":2009},{"className":2008},[],[2010],{"type":26,"value":1457},{"type":21,"tag":115,"props":2012,"children":2013},{},[2014,2016,2021,2023,2028],{"type":26,"value":2015},"Idle timeout counter (set to ",{"type":21,"tag":124,"props":2017,"children":2019},{"className":2018},[],[2020],{"type":26,"value":1248},{"type":26,"value":2022}," by ",{"type":21,"tag":124,"props":2024,"children":2026},{"className":2025},[],[2027],{"type":26,"value":890},{"type":26,"value":1386},{"type":21,"tag":82,"props":2030,"children":2031},{},[2032,2041,2049],{"type":21,"tag":115,"props":2033,"children":2034},{"align":1286},[2035],{"type":21,"tag":124,"props":2036,"children":2038},{"className":2037},[],[2039],{"type":26,"value":2040},"+$1C",{"type":21,"tag":115,"props":2042,"children":2043},{"align":1286},[2044],{"type":21,"tag":124,"props":2045,"children":2047},{"className":2046},[],[2048],{"type":26,"value":980},{"type":21,"tag":115,"props":2050,"children":2051},{},[2052],{"type":26,"value":2053},"Prestel session scratchpad start",{"type":21,"tag":82,"props":2055,"children":2056},{},[2057,2066,2074],{"type":21,"tag":115,"props":2058,"children":2059},{"align":1286},[2060],{"type":21,"tag":124,"props":2061,"children":2063},{"className":2062},[],[2064],{"type":26,"value":2065},"+$2B",{"type":21,"tag":115,"props":2067,"children":2068},{"align":1286},[2069],{"type":21,"tag":124,"props":2070,"children":2072},{"className":2071},[],[2073],{"type":26,"value":980},{"type":21,"tag":115,"props":2075,"children":2076},{},[2077],{"type":26,"value":2078},"Prestel session scratchpad end",{"type":21,"tag":82,"props":2080,"children":2081},{},[2082,2091,2099],{"type":21,"tag":115,"props":2083,"children":2084},{"align":1286},[2085],{"type":21,"tag":124,"props":2086,"children":2088},{"className":2087},[],[2089],{"type":26,"value":2090},"+$2C",{"type":21,"tag":115,"props":2092,"children":2093},{"align":1286},[2094],{"type":21,"tag":124,"props":2095,"children":2097},{"className":2096},[],[2098],{"type":26,"value":1457},{"type":21,"tag":115,"props":2100,"children":2101},{},[2102],{"type":26,"value":2103},"Prestel frame repeat count",{"type":21,"tag":82,"props":2105,"children":2106},{},[2107,2116,2125],{"type":21,"tag":115,"props":2108,"children":2109},{"align":1286},[2110],{"type":21,"tag":124,"props":2111,"children":2113},{"className":2112},[],[2114],{"type":26,"value":2115},"+$2D",{"type":21,"tag":115,"props":2117,"children":2118},{"align":1286},[2119],{"type":21,"tag":124,"props":2120,"children":2122},{"className":2121},[],[2123],{"type":26,"value":2124},"$17",{"type":21,"tag":115,"props":2126,"children":2127},{},[2128],{"type":26,"value":2129},"Prestel line retry count (23)",{"type":21,"tag":82,"props":2131,"children":2132},{},[2133,2142,2151],{"type":21,"tag":115,"props":2134,"children":2135},{"align":1286},[2136],{"type":21,"tag":124,"props":2137,"children":2139},{"className":2138},[],[2140],{"type":26,"value":2141},"+$2E",{"type":21,"tag":115,"props":2143,"children":2144},{"align":1286},[2145],{"type":21,"tag":124,"props":2146,"children":2148},{"className":2147},[],[2149],{"type":26,"value":2150},"$05",{"type":21,"tag":115,"props":2152,"children":2153},{},[2154],{"type":26,"value":2155},"Prestel attempt counter",{"type":21,"tag":82,"props":2157,"children":2158},{},[2159,2168,2176],{"type":21,"tag":115,"props":2160,"children":2161},{"align":1286},[2162],{"type":21,"tag":124,"props":2163,"children":2165},{"className":2164},[],[2166],{"type":26,"value":2167},"+$2F",{"type":21,"tag":115,"props":2169,"children":2170},{"align":1286},[2171],{"type":21,"tag":124,"props":2172,"children":2174},{"className":2173},[],[2175],{"type":26,"value":1457},{"type":21,"tag":115,"props":2177,"children":2178},{},[2179],{"type":26,"value":2180},"Prestel data pointer (low)",{"type":21,"tag":82,"props":2182,"children":2183},{},[2184,2193,2201],{"type":21,"tag":115,"props":2185,"children":2186},{"align":1286},[2187],{"type":21,"tag":124,"props":2188,"children":2190},{"className":2189},[],[2191],{"type":26,"value":2192},"+$30",{"type":21,"tag":115,"props":2194,"children":2195},{"align":1286},[2196],{"type":21,"tag":124,"props":2197,"children":2199},{"className":2198},[],[2200],{"type":26,"value":1457},{"type":21,"tag":115,"props":2202,"children":2203},{},[2204],{"type":26,"value":2205},"Prestel data pointer (high)",{"type":21,"tag":82,"props":2207,"children":2208},{},[2209,2218,2226],{"type":21,"tag":115,"props":2210,"children":2211},{"align":1286},[2212],{"type":21,"tag":124,"props":2213,"children":2215},{"className":2214},[],[2216],{"type":26,"value":2217},"+$31",{"type":21,"tag":115,"props":2219,"children":2220},{"align":1286},[2221],{"type":21,"tag":124,"props":2222,"children":2224},{"className":2223},[],[2225],{"type":26,"value":1457},{"type":21,"tag":115,"props":2227,"children":2228},{},[2229],{"type":26,"value":2230},"Prestel shift state",{"type":21,"tag":82,"props":2232,"children":2233},{},[2234,2243,2251],{"type":21,"tag":115,"props":2235,"children":2236},{"align":1286},[2237],{"type":21,"tag":124,"props":2238,"children":2240},{"className":2239},[],[2241],{"type":26,"value":2242},"+$32",{"type":21,"tag":115,"props":2244,"children":2245},{"align":1286},[2246],{"type":21,"tag":124,"props":2247,"children":2249},{"className":2248},[],[2250],{"type":26,"value":1457},{"type":21,"tag":115,"props":2252,"children":2253},{},[2254],{"type":26,"value":2255},"Prestel parser flags",{"type":21,"tag":82,"props":2257,"children":2258},{},[2259,2268,2276],{"type":21,"tag":115,"props":2260,"children":2261},{"align":1286},[2262],{"type":21,"tag":124,"props":2263,"children":2265},{"className":2264},[],[2266],{"type":26,"value":2267},"+$41",{"type":21,"tag":115,"props":2269,"children":2270},{"align":1286},[2271],{"type":21,"tag":124,"props":2272,"children":2274},{"className":2273},[],[2275],{"type":26,"value":2150},{"type":21,"tag":115,"props":2277,"children":2278},{},[2279],{"type":26,"value":2280},"Prestel max attempts (5)",{"type":21,"tag":82,"props":2282,"children":2283},{},[2284,2293,2301],{"type":21,"tag":115,"props":2285,"children":2286},{"align":1286},[2287],{"type":21,"tag":124,"props":2288,"children":2290},{"className":2289},[],[2291],{"type":26,"value":2292},"+$42",{"type":21,"tag":115,"props":2294,"children":2295},{"align":1286},[2296],{"type":21,"tag":124,"props":2297,"children":2299},{"className":2298},[],[2300],{"type":26,"value":1248},{"type":21,"tag":115,"props":2302,"children":2303},{},[2304,2306],{"type":26,"value":2305},"Online timeout (low) - ",{"type":21,"tag":124,"props":2307,"children":2309},{"className":2308},[],[2310],{"type":26,"value":2311},"$0064 = 100",{"type":21,"tag":82,"props":2313,"children":2314},{},[2315,2324,2332],{"type":21,"tag":115,"props":2316,"children":2317},{"align":1286},[2318],{"type":21,"tag":124,"props":2319,"children":2321},{"className":2320},[],[2322],{"type":26,"value":2323},"+$43",{"type":21,"tag":115,"props":2325,"children":2326},{"align":1286},[2327],{"type":21,"tag":124,"props":2328,"children":2330},{"className":2329},[],[2331],{"type":26,"value":1457},{"type":21,"tag":115,"props":2333,"children":2334},{},[2335],{"type":26,"value":2336},"Online timeout (high)",{"type":21,"tag":82,"props":2338,"children":2339},{},[2340,2349,2357],{"type":21,"tag":115,"props":2341,"children":2342},{"align":1286},[2343],{"type":21,"tag":124,"props":2344,"children":2346},{"className":2345},[],[2347],{"type":26,"value":2348},"+$44",{"type":21,"tag":115,"props":2350,"children":2351},{"align":1286},[2352],{"type":21,"tag":124,"props":2353,"children":2355},{"className":2354},[],[2356],{"type":26,"value":1248},{"type":21,"tag":115,"props":2358,"children":2359},{},[2360,2362],{"type":26,"value":2361},"Offline timeout (low) - ",{"type":21,"tag":124,"props":2363,"children":2365},{"className":2364},[],[2366],{"type":26,"value":2311},{"type":21,"tag":82,"props":2368,"children":2369},{},[2370,2379,2387],{"type":21,"tag":115,"props":2371,"children":2372},{"align":1286},[2373],{"type":21,"tag":124,"props":2374,"children":2376},{"className":2375},[],[2377],{"type":26,"value":2378},"+$45",{"type":21,"tag":115,"props":2380,"children":2381},{"align":1286},[2382],{"type":21,"tag":124,"props":2383,"children":2385},{"className":2384},[],[2386],{"type":26,"value":1457},{"type":21,"tag":115,"props":2388,"children":2389},{},[2390],{"type":26,"value":2391},"Offline timeout (high)",{"type":21,"tag":82,"props":2393,"children":2394},{},[2395,2404,2412],{"type":21,"tag":115,"props":2396,"children":2397},{"align":1286},[2398],{"type":21,"tag":124,"props":2399,"children":2401},{"className":2400},[],[2402],{"type":26,"value":2403},"+$46",{"type":21,"tag":115,"props":2405,"children":2406},{"align":1286},[2407],{"type":21,"tag":124,"props":2408,"children":2410},{"className":2409},[],[2411],{"type":26,"value":191},{"type":21,"tag":115,"props":2413,"children":2414},{},[2415,2417],{"type":26,"value":2416},"Character font base (low) - together = ",{"type":21,"tag":124,"props":2418,"children":2420},{"className":2419},[],[2421],{"type":26,"value":2422},"$1B20",{"type":21,"tag":82,"props":2424,"children":2425},{},[2426,2435,2443],{"type":21,"tag":115,"props":2427,"children":2428},{"align":1286},[2429],{"type":21,"tag":124,"props":2430,"children":2432},{"className":2431},[],[2433],{"type":26,"value":2434},"+$47",{"type":21,"tag":115,"props":2436,"children":2437},{"align":1286},[2438],{"type":21,"tag":124,"props":2439,"children":2441},{"className":2440},[],[2442],{"type":26,"value":1239},{"type":21,"tag":115,"props":2444,"children":2445},{},[2446],{"type":26,"value":2447},"Character font base (high) - points at ROM font",{"type":21,"tag":55,"props":2449,"children":2451},{"id":2450},"the-main-modem-loop",[2452],{"type":26,"value":2453},"The Main Modem Loop",{"type":21,"tag":22,"props":2455,"children":2456},{},[2457],{"type":26,"value":2458},"This is where the VTX5000 spends most of its time. It's a straightforward poll-and-dispatch cycle:",{"type":21,"tag":902,"props":2460,"children":2462},{"className":904,"code":2461,"language":906,"meta":907,"style":907},"MODEM_MAIN_LOOP:\n    LD (IX+$0B),$00      ; Clear return code\n    CALL CHECK_TX_READY  ; Send a byte if transmitter is free\n    CALL CHECK_RX_DATA   ; Read a byte if receiver has data\n    LD B,$04\n    CALL BUF_READ        ; Pull from RX buffer\n    JR Z,.no_rx_data     ; Nothing? Skip processing\n    CALL PRESTEL_DETECT  ; Check for Prestel frame markers\n    CALL PROCESS_RX_CHAR ; Handle the received character\n.no_rx_data:\n    CALL SCAN_KEYBOARD   ; Check keyboard\n    LD C,(IX+$0B)        ; Read return code\n    LD A,C\n    OR A\n    JR Z,MODEM_MAIN_LOOP ; Code 0: keep looping\n",[2463],{"type":21,"tag":124,"props":2464,"children":2465},{"__ignoreMap":907},[2466,2478,2515,2533,2550,2571,2588,2606,2623,2640,2652,2669,2707,2728,2741],{"type":21,"tag":913,"props":2467,"children":2468},{"class":915,"line":916},[2469,2474],{"type":21,"tag":913,"props":2470,"children":2471},{"style":920},[2472],{"type":26,"value":2473},"MODEM_MAIN_LOOP",{"type":21,"tag":913,"props":2475,"children":2476},{"style":925},[2477],{"type":26,"value":928},{"type":21,"tag":913,"props":2479,"children":2480},{"class":915,"line":931},[2481,2485,2489,2493,2497,2502,2506,2510],{"type":21,"tag":913,"props":2482,"children":2483},{"style":935},[2484],{"type":26,"value":938},{"type":21,"tag":913,"props":2486,"children":2487},{"style":925},[2488],{"type":26,"value":975},{"type":21,"tag":913,"props":2490,"children":2491},{"style":941},[2492],{"type":26,"value":1166},{"type":21,"tag":913,"props":2494,"children":2495},{"style":925},[2496],{"type":26,"value":1024},{"type":21,"tag":913,"props":2498,"children":2499},{"style":952},[2500],{"type":26,"value":2501},"$0B",{"type":21,"tag":913,"props":2503,"children":2504},{"style":925},[2505],{"type":26,"value":985},{"type":21,"tag":913,"props":2507,"children":2508},{"style":952},[2509],{"type":26,"value":1457},{"type":21,"tag":913,"props":2511,"children":2512},{"style":958},[2513],{"type":26,"value":2514},"      ; Clear return code\n",{"type":21,"tag":913,"props":2516,"children":2517},{"class":915,"line":964},[2518,2523,2528],{"type":21,"tag":913,"props":2519,"children":2520},{"style":935},[2521],{"type":26,"value":2522},"    CALL",{"type":21,"tag":913,"props":2524,"children":2525},{"style":925},[2526],{"type":26,"value":2527}," CHECK_TX_READY  ",{"type":21,"tag":913,"props":2529,"children":2530},{"style":958},[2531],{"type":26,"value":2532},"; Send a byte if transmitter is free\n",{"type":21,"tag":913,"props":2534,"children":2535},{"class":915,"line":998},[2536,2540,2545],{"type":21,"tag":913,"props":2537,"children":2538},{"style":935},[2539],{"type":26,"value":2522},{"type":21,"tag":913,"props":2541,"children":2542},{"style":925},[2543],{"type":26,"value":2544}," CHECK_RX_DATA   ",{"type":21,"tag":913,"props":2546,"children":2547},{"style":958},[2548],{"type":26,"value":2549},"; Read a byte if receiver has data\n",{"type":21,"tag":913,"props":2551,"children":2552},{"class":915,"line":1041},[2553,2557,2562,2566],{"type":21,"tag":913,"props":2554,"children":2555},{"style":935},[2556],{"type":26,"value":938},{"type":21,"tag":913,"props":2558,"children":2559},{"style":941},[2560],{"type":26,"value":2561}," B",{"type":21,"tag":913,"props":2563,"children":2564},{"style":925},[2565],{"type":26,"value":949},{"type":21,"tag":913,"props":2567,"children":2568},{"style":952},[2569],{"type":26,"value":2570},"$04\n",{"type":21,"tag":913,"props":2572,"children":2573},{"class":915,"line":1066},[2574,2578,2583],{"type":21,"tag":913,"props":2575,"children":2576},{"style":935},[2577],{"type":26,"value":2522},{"type":21,"tag":913,"props":2579,"children":2580},{"style":925},[2581],{"type":26,"value":2582}," BUF_READ        ",{"type":21,"tag":913,"props":2584,"children":2585},{"style":958},[2586],{"type":26,"value":2587},"; Pull from RX buffer\n",{"type":21,"tag":913,"props":2589,"children":2590},{"class":915,"line":1095},[2591,2596,2601],{"type":21,"tag":913,"props":2592,"children":2593},{"style":935},[2594],{"type":26,"value":2595},"    JR",{"type":21,"tag":913,"props":2597,"children":2598},{"style":925},[2599],{"type":26,"value":2600}," Z,.no_rx_data     ",{"type":21,"tag":913,"props":2602,"children":2603},{"style":958},[2604],{"type":26,"value":2605},"; Nothing? Skip processing\n",{"type":21,"tag":913,"props":2607,"children":2608},{"class":915,"line":1104},[2609,2613,2618],{"type":21,"tag":913,"props":2610,"children":2611},{"style":935},[2612],{"type":26,"value":2522},{"type":21,"tag":913,"props":2614,"children":2615},{"style":925},[2616],{"type":26,"value":2617}," PRESTEL_DETECT  ",{"type":21,"tag":913,"props":2619,"children":2620},{"style":958},[2621],{"type":26,"value":2622},"; Check for Prestel frame markers\n",{"type":21,"tag":913,"props":2624,"children":2625},{"class":915,"line":1118},[2626,2630,2635],{"type":21,"tag":913,"props":2627,"children":2628},{"style":935},[2629],{"type":26,"value":2522},{"type":21,"tag":913,"props":2631,"children":2632},{"style":925},[2633],{"type":26,"value":2634}," PROCESS_RX_CHAR ",{"type":21,"tag":913,"props":2636,"children":2637},{"style":958},[2638],{"type":26,"value":2639},"; Handle the received character\n",{"type":21,"tag":913,"props":2641,"children":2642},{"class":915,"line":1148},[2643,2648],{"type":21,"tag":913,"props":2644,"children":2645},{"style":920},[2646],{"type":26,"value":2647},".no_rx_data",{"type":21,"tag":913,"props":2649,"children":2650},{"style":925},[2651],{"type":26,"value":928},{"type":21,"tag":913,"props":2653,"children":2654},{"class":915,"line":1188},[2655,2659,2664],{"type":21,"tag":913,"props":2656,"children":2657},{"style":935},[2658],{"type":26,"value":2522},{"type":21,"tag":913,"props":2660,"children":2661},{"style":925},[2662],{"type":26,"value":2663}," SCAN_KEYBOARD   ",{"type":21,"tag":913,"props":2665,"children":2666},{"style":958},[2667],{"type":26,"value":2668},"; Check keyboard\n",{"type":21,"tag":913,"props":2670,"children":2671},{"class":915,"line":1217},[2672,2676,2681,2685,2689,2693,2697,2702],{"type":21,"tag":913,"props":2673,"children":2674},{"style":935},[2675],{"type":26,"value":938},{"type":21,"tag":913,"props":2677,"children":2678},{"style":941},[2679],{"type":26,"value":2680}," C",{"type":21,"tag":913,"props":2682,"children":2683},{"style":925},[2684],{"type":26,"value":1014},{"type":21,"tag":913,"props":2686,"children":2687},{"style":941},[2688],{"type":26,"value":1166},{"type":21,"tag":913,"props":2690,"children":2691},{"style":925},[2692],{"type":26,"value":1024},{"type":21,"tag":913,"props":2694,"children":2695},{"style":952},[2696],{"type":26,"value":2501},{"type":21,"tag":913,"props":2698,"children":2699},{"style":925},[2700],{"type":26,"value":2701},")        ",{"type":21,"tag":913,"props":2703,"children":2704},{"style":958},[2705],{"type":26,"value":2706},"; Read return code\n",{"type":21,"tag":913,"props":2708,"children":2710},{"class":915,"line":2709},13,[2711,2715,2719,2723],{"type":21,"tag":913,"props":2712,"children":2713},{"style":935},[2714],{"type":26,"value":938},{"type":21,"tag":913,"props":2716,"children":2717},{"style":941},[2718],{"type":26,"value":944},{"type":21,"tag":913,"props":2720,"children":2721},{"style":925},[2722],{"type":26,"value":949},{"type":21,"tag":913,"props":2724,"children":2725},{"style":941},[2726],{"type":26,"value":2727},"C\n",{"type":21,"tag":913,"props":2729,"children":2731},{"class":915,"line":2730},14,[2732,2737],{"type":21,"tag":913,"props":2733,"children":2734},{"style":935},[2735],{"type":26,"value":2736},"    OR",{"type":21,"tag":913,"props":2738,"children":2739},{"style":941},[2740],{"type":26,"value":1115},{"type":21,"tag":913,"props":2742,"children":2744},{"class":915,"line":2743},15,[2745,2749,2754],{"type":21,"tag":913,"props":2746,"children":2747},{"style":935},[2748],{"type":26,"value":2595},{"type":21,"tag":913,"props":2750,"children":2751},{"style":925},[2752],{"type":26,"value":2753}," Z,MODEM_MAIN_LOOP ",{"type":21,"tag":913,"props":2755,"children":2756},{"style":958},[2757],{"type":26,"value":2758},"; Code 0: keep looping\n",{"type":21,"tag":22,"props":2760,"children":2761},{},[2762,2764,2770,2772,2778],{"type":26,"value":2763},"Every iteration, it checks for outgoing data, incoming data, and keyboard input. If a return code gets set anywhere (BREAK pressed, timeout, carrier lost, frame complete), the loop exits and returns to the BASIC program via ",{"type":21,"tag":124,"props":2765,"children":2767},{"className":2766},[],[2768],{"type":26,"value":2769},"USR",{"type":26,"value":2771},". The return code in ",{"type":21,"tag":124,"props":2773,"children":2775},{"className":2774},[],[2776],{"type":26,"value":2777},"IX+$0B",{"type":26,"value":2779}," tells BASIC what happened - 0 means keep going, 1 is BREAK, 2 is idle timeout, 3 is carrier lost, and so on.",{"type":21,"tag":22,"props":2781,"children":2782},{},[2783],{"type":26,"value":2784},"This cooperative polling design means nothing ever blocks. There's no interrupt-driven receive, no DMA - just a tight loop checking everything in turn, fast enough at 3.5MHz that nothing gets missed at 1200 baud.",{"type":21,"tag":55,"props":2786,"children":2788},{"id":2787},"transmit",[2789],{"type":26,"value":2790},"Transmit",{"type":21,"tag":22,"props":2792,"children":2793},{},[2794],{"type":26,"value":2795},"The transmit path is simple - check if the 8251's TxRDY flag is set, and if there's data in the TX buffer, send it:",{"type":21,"tag":902,"props":2797,"children":2799},{"className":904,"code":2798,"language":906,"meta":907,"style":907},"CHECK_TX_READY:\n    LD A,(IX+$06)\n    AND $42              ; TX enabled?\n    RET NZ               ; No: return\n    IN A,($FF)           ; Read 8251 status\n    BIT 0,A              ; TxRDY?\n    RET Z                ; Not ready: return\n    LD B,$02             ; Buffer type 2 (TX)\n    CALL BUF_READ        ; Read from TX buffer\n    RET Z                ; Empty: return\n    CP $23               ; '#' hash?\n    JR NZ,.not_hash\n    LD A,$5F             ; Replace with underscore\n.not_hash:\n    OUT ($7F),A          ; Transmit byte\n    RET\n",[2800],{"type":21,"tag":124,"props":2801,"children":2802},{"__ignoreMap":907},[2803,2815,2848,2866,2884,2914,2940,2957,2981,2997,3013,3031,3047,3072,3084,3113],{"type":21,"tag":913,"props":2804,"children":2805},{"class":915,"line":916},[2806,2811],{"type":21,"tag":913,"props":2807,"children":2808},{"style":920},[2809],{"type":26,"value":2810},"CHECK_TX_READY",{"type":21,"tag":913,"props":2812,"children":2813},{"style":925},[2814],{"type":26,"value":928},{"type":21,"tag":913,"props":2816,"children":2817},{"class":915,"line":931},[2818,2822,2826,2830,2834,2838,2843],{"type":21,"tag":913,"props":2819,"children":2820},{"style":935},[2821],{"type":26,"value":938},{"type":21,"tag":913,"props":2823,"children":2824},{"style":941},[2825],{"type":26,"value":944},{"type":21,"tag":913,"props":2827,"children":2828},{"style":925},[2829],{"type":26,"value":1014},{"type":21,"tag":913,"props":2831,"children":2832},{"style":941},[2833],{"type":26,"value":1166},{"type":21,"tag":913,"props":2835,"children":2836},{"style":925},[2837],{"type":26,"value":1024},{"type":21,"tag":913,"props":2839,"children":2840},{"style":952},[2841],{"type":26,"value":2842},"$06",{"type":21,"tag":913,"props":2844,"children":2845},{"style":925},[2846],{"type":26,"value":2847},")\n",{"type":21,"tag":913,"props":2849,"children":2850},{"class":915,"line":964},[2851,2856,2861],{"type":21,"tag":913,"props":2852,"children":2853},{"style":935},[2854],{"type":26,"value":2855},"    AND",{"type":21,"tag":913,"props":2857,"children":2858},{"style":952},[2859],{"type":26,"value":2860}," $42",{"type":21,"tag":913,"props":2862,"children":2863},{"style":958},[2864],{"type":26,"value":2865},"              ; TX enabled?\n",{"type":21,"tag":913,"props":2867,"children":2868},{"class":915,"line":998},[2869,2874,2879],{"type":21,"tag":913,"props":2870,"children":2871},{"style":935},[2872],{"type":26,"value":2873},"    RET",{"type":21,"tag":913,"props":2875,"children":2876},{"style":941},[2877],{"type":26,"value":2878}," NZ",{"type":21,"tag":913,"props":2880,"children":2881},{"style":958},[2882],{"type":26,"value":2883},"               ; No: return\n",{"type":21,"tag":913,"props":2885,"children":2886},{"class":915,"line":1041},[2887,2892,2896,2900,2904,2909],{"type":21,"tag":913,"props":2888,"children":2889},{"style":935},[2890],{"type":26,"value":2891},"    IN",{"type":21,"tag":913,"props":2893,"children":2894},{"style":941},[2895],{"type":26,"value":944},{"type":21,"tag":913,"props":2897,"children":2898},{"style":925},[2899],{"type":26,"value":1014},{"type":21,"tag":913,"props":2901,"children":2902},{"style":952},[2903],{"type":26,"value":980},{"type":21,"tag":913,"props":2905,"children":2906},{"style":925},[2907],{"type":26,"value":2908},")           ",{"type":21,"tag":913,"props":2910,"children":2911},{"style":958},[2912],{"type":26,"value":2913},"; Read 8251 status\n",{"type":21,"tag":913,"props":2915,"children":2916},{"class":915,"line":1066},[2917,2922,2927,2931,2935],{"type":21,"tag":913,"props":2918,"children":2919},{"style":935},[2920],{"type":26,"value":2921},"    BIT",{"type":21,"tag":913,"props":2923,"children":2924},{"style":952},[2925],{"type":26,"value":2926}," 0",{"type":21,"tag":913,"props":2928,"children":2929},{"style":925},[2930],{"type":26,"value":949},{"type":21,"tag":913,"props":2932,"children":2933},{"style":941},[2934],{"type":26,"value":990},{"type":21,"tag":913,"props":2936,"children":2937},{"style":958},[2938],{"type":26,"value":2939},"              ; TxRDY?\n",{"type":21,"tag":913,"props":2941,"children":2942},{"class":915,"line":1095},[2943,2947,2952],{"type":21,"tag":913,"props":2944,"children":2945},{"style":935},[2946],{"type":26,"value":2873},{"type":21,"tag":913,"props":2948,"children":2949},{"style":925},[2950],{"type":26,"value":2951}," Z                ",{"type":21,"tag":913,"props":2953,"children":2954},{"style":958},[2955],{"type":26,"value":2956},"; Not ready: return\n",{"type":21,"tag":913,"props":2958,"children":2959},{"class":915,"line":1104},[2960,2964,2968,2972,2976],{"type":21,"tag":913,"props":2961,"children":2962},{"style":935},[2963],{"type":26,"value":938},{"type":21,"tag":913,"props":2965,"children":2966},{"style":941},[2967],{"type":26,"value":2561},{"type":21,"tag":913,"props":2969,"children":2970},{"style":925},[2971],{"type":26,"value":949},{"type":21,"tag":913,"props":2973,"children":2974},{"style":952},[2975],{"type":26,"value":312},{"type":21,"tag":913,"props":2977,"children":2978},{"style":958},[2979],{"type":26,"value":2980},"             ; Buffer type 2 (TX)\n",{"type":21,"tag":913,"props":2982,"children":2983},{"class":915,"line":1118},[2984,2988,2992],{"type":21,"tag":913,"props":2985,"children":2986},{"style":935},[2987],{"type":26,"value":2522},{"type":21,"tag":913,"props":2989,"children":2990},{"style":925},[2991],{"type":26,"value":2582},{"type":21,"tag":913,"props":2993,"children":2994},{"style":958},[2995],{"type":26,"value":2996},"; Read from TX buffer\n",{"type":21,"tag":913,"props":2998,"children":2999},{"class":915,"line":1148},[3000,3004,3008],{"type":21,"tag":913,"props":3001,"children":3002},{"style":935},[3003],{"type":26,"value":2873},{"type":21,"tag":913,"props":3005,"children":3006},{"style":925},[3007],{"type":26,"value":2951},{"type":21,"tag":913,"props":3009,"children":3010},{"style":958},[3011],{"type":26,"value":3012},"; Empty: return\n",{"type":21,"tag":913,"props":3014,"children":3015},{"class":915,"line":1188},[3016,3021,3026],{"type":21,"tag":913,"props":3017,"children":3018},{"style":935},[3019],{"type":26,"value":3020},"    CP",{"type":21,"tag":913,"props":3022,"children":3023},{"style":952},[3024],{"type":26,"value":3025}," $23",{"type":21,"tag":913,"props":3027,"children":3028},{"style":958},[3029],{"type":26,"value":3030},"               ; '#' hash?\n",{"type":21,"tag":913,"props":3032,"children":3033},{"class":915,"line":1217},[3034,3038,3042],{"type":21,"tag":913,"props":3035,"children":3036},{"style":935},[3037],{"type":26,"value":2595},{"type":21,"tag":913,"props":3039,"children":3040},{"style":941},[3041],{"type":26,"value":2878},{"type":21,"tag":913,"props":3043,"children":3044},{"style":925},[3045],{"type":26,"value":3046},",.not_hash\n",{"type":21,"tag":913,"props":3048,"children":3049},{"class":915,"line":2709},[3050,3054,3058,3062,3067],{"type":21,"tag":913,"props":3051,"children":3052},{"style":935},[3053],{"type":26,"value":938},{"type":21,"tag":913,"props":3055,"children":3056},{"style":941},[3057],{"type":26,"value":944},{"type":21,"tag":913,"props":3059,"children":3060},{"style":925},[3061],{"type":26,"value":949},{"type":21,"tag":913,"props":3063,"children":3064},{"style":952},[3065],{"type":26,"value":3066},"$5F",{"type":21,"tag":913,"props":3068,"children":3069},{"style":958},[3070],{"type":26,"value":3071},"             ; Replace with underscore\n",{"type":21,"tag":913,"props":3073,"children":3074},{"class":915,"line":2730},[3075,3080],{"type":21,"tag":913,"props":3076,"children":3077},{"style":920},[3078],{"type":26,"value":3079},".not_hash",{"type":21,"tag":913,"props":3081,"children":3082},{"style":925},[3083],{"type":26,"value":928},{"type":21,"tag":913,"props":3085,"children":3086},{"class":915,"line":2743},[3087,3091,3095,3100,3104,3108],{"type":21,"tag":913,"props":3088,"children":3089},{"style":935},[3090],{"type":26,"value":970},{"type":21,"tag":913,"props":3092,"children":3093},{"style":925},[3094],{"type":26,"value":975},{"type":21,"tag":913,"props":3096,"children":3097},{"style":952},[3098],{"type":26,"value":3099},"$7F",{"type":21,"tag":913,"props":3101,"children":3102},{"style":925},[3103],{"type":26,"value":985},{"type":21,"tag":913,"props":3105,"children":3106},{"style":941},[3107],{"type":26,"value":990},{"type":21,"tag":913,"props":3109,"children":3110},{"style":958},[3111],{"type":26,"value":3112},"          ; Transmit byte\n",{"type":21,"tag":913,"props":3114,"children":3116},{"class":915,"line":3115},16,[3117],{"type":21,"tag":913,"props":3118,"children":3119},{"style":935},[3120],{"type":26,"value":3121},"    RET\n",{"type":21,"tag":22,"props":3123,"children":3124},{},[3125,3127,3133,3135,3140,3142,3147,3149,3155,3157,3162],{"type":26,"value":3126},"There's a character substitution here: the ",{"type":21,"tag":124,"props":3128,"children":3130},{"className":3129},[],[3131],{"type":26,"value":3132},"#",{"type":26,"value":3134}," key gets replaced with ",{"type":21,"tag":124,"props":3136,"children":3138},{"className":3137},[],[3139],{"type":26,"value":3066},{"type":26,"value":3141}," (underscore) on transmit. This is a UK keyboard mapping artifact - on the Spectrum keyboard, what you'd think of as ",{"type":21,"tag":124,"props":3143,"children":3145},{"className":3144},[],[3146],{"type":26,"value":3132},{"type":26,"value":3148}," needed to be sent as ",{"type":21,"tag":124,"props":3150,"children":3152},{"className":3151},[],[3153],{"type":26,"value":3154},"_",{"type":26,"value":3156}," for Prestel's character set, where ",{"type":21,"tag":124,"props":3158,"children":3160},{"className":3159},[],[3161],{"type":26,"value":3132},{"type":26,"value":3163}," has a different meaning (it's the \"send\" key in Prestel navigation, like pressing Enter on a form).",{"type":21,"tag":55,"props":3165,"children":3167},{"id":3166},"receive",[3168],{"type":26,"value":3169},"Receive",{"type":21,"tag":22,"props":3171,"children":3172},{},[3173],{"type":26,"value":3174},"The receive side reads from the 8251 data register and writes into the RX buffer:",{"type":21,"tag":902,"props":3176,"children":3178},{"className":904,"code":3177,"language":906,"meta":907,"style":907},"CHECK_RX_DATA:\n    BIT 5,(IX+$06)       ; TX busy?\n    RET NZ               ; Yes: skip RX\n    IN A,($FF)           ; Read 8251 status\n    BIT 7,A              ; DSR (Data Set Ready)?\n    RET Z                ; No DSR: modem not connected\n    LD (IX+$1B),$64      ; Reset idle timeout (modem is alive)\n    BIT 1,A              ; RxRDY?\n    RET Z                ; No data: return\n    BIT 3,A              ; Parity error?\n    IN A,($7F)           ; Read received byte\n    JR Z,.no_parity_err  ; No error: use as-is\n    LD A,(IX+$08)        ; Parity error: rewrite command register\n    OUT ($FF),A          ;   (clears error flags)\n    LD A,$FF             ;   Replace byte with $FF (error marker)\n.no_parity_err:\n    LD B,$04             ; Buffer type 4 (RX)\n    CALL BUF_WRITE       ; Write to buffer\n    CALL SET_CARRIER_TIMEOUT  ; Reset carrier timeout\n    RET\n",[3179],{"type":21,"tag":124,"props":3180,"children":3181},{"__ignoreMap":907},[3182,3194,3230,3246,3273,3298,3314,3350,3375,3391,3416,3444,3461,3497,3525,3549,3561,3586,3604,3622],{"type":21,"tag":913,"props":3183,"children":3184},{"class":915,"line":916},[3185,3190],{"type":21,"tag":913,"props":3186,"children":3187},{"style":920},[3188],{"type":26,"value":3189},"CHECK_RX_DATA",{"type":21,"tag":913,"props":3191,"children":3192},{"style":925},[3193],{"type":26,"value":928},{"type":21,"tag":913,"props":3195,"children":3196},{"class":915,"line":931},[3197,3201,3205,3209,3213,3217,3221,3225],{"type":21,"tag":913,"props":3198,"children":3199},{"style":935},[3200],{"type":26,"value":2921},{"type":21,"tag":913,"props":3202,"children":3203},{"style":952},[3204],{"type":26,"value":1009},{"type":21,"tag":913,"props":3206,"children":3207},{"style":925},[3208],{"type":26,"value":1014},{"type":21,"tag":913,"props":3210,"children":3211},{"style":941},[3212],{"type":26,"value":1166},{"type":21,"tag":913,"props":3214,"children":3215},{"style":925},[3216],{"type":26,"value":1024},{"type":21,"tag":913,"props":3218,"children":3219},{"style":952},[3220],{"type":26,"value":2842},{"type":21,"tag":913,"props":3222,"children":3223},{"style":925},[3224],{"type":26,"value":1180},{"type":21,"tag":913,"props":3226,"children":3227},{"style":958},[3228],{"type":26,"value":3229},"; TX busy?\n",{"type":21,"tag":913,"props":3231,"children":3232},{"class":915,"line":964},[3233,3237,3241],{"type":21,"tag":913,"props":3234,"children":3235},{"style":935},[3236],{"type":26,"value":2873},{"type":21,"tag":913,"props":3238,"children":3239},{"style":941},[3240],{"type":26,"value":2878},{"type":21,"tag":913,"props":3242,"children":3243},{"style":958},[3244],{"type":26,"value":3245},"               ; Yes: skip RX\n",{"type":21,"tag":913,"props":3247,"children":3248},{"class":915,"line":998},[3249,3253,3257,3261,3265,3269],{"type":21,"tag":913,"props":3250,"children":3251},{"style":935},[3252],{"type":26,"value":2891},{"type":21,"tag":913,"props":3254,"children":3255},{"style":941},[3256],{"type":26,"value":944},{"type":21,"tag":913,"props":3258,"children":3259},{"style":925},[3260],{"type":26,"value":1014},{"type":21,"tag":913,"props":3262,"children":3263},{"style":952},[3264],{"type":26,"value":980},{"type":21,"tag":913,"props":3266,"children":3267},{"style":925},[3268],{"type":26,"value":2908},{"type":21,"tag":913,"props":3270,"children":3271},{"style":958},[3272],{"type":26,"value":2913},{"type":21,"tag":913,"props":3274,"children":3275},{"class":915,"line":1041},[3276,3280,3285,3289,3293],{"type":21,"tag":913,"props":3277,"children":3278},{"style":935},[3279],{"type":26,"value":2921},{"type":21,"tag":913,"props":3281,"children":3282},{"style":952},[3283],{"type":26,"value":3284}," 7",{"type":21,"tag":913,"props":3286,"children":3287},{"style":925},[3288],{"type":26,"value":949},{"type":21,"tag":913,"props":3290,"children":3291},{"style":941},[3292],{"type":26,"value":990},{"type":21,"tag":913,"props":3294,"children":3295},{"style":958},[3296],{"type":26,"value":3297},"              ; DSR (Data Set Ready)?\n",{"type":21,"tag":913,"props":3299,"children":3300},{"class":915,"line":1066},[3301,3305,3309],{"type":21,"tag":913,"props":3302,"children":3303},{"style":935},[3304],{"type":26,"value":2873},{"type":21,"tag":913,"props":3306,"children":3307},{"style":925},[3308],{"type":26,"value":2951},{"type":21,"tag":913,"props":3310,"children":3311},{"style":958},[3312],{"type":26,"value":3313},"; No DSR: modem not connected\n",{"type":21,"tag":913,"props":3315,"children":3316},{"class":915,"line":1095},[3317,3321,3325,3329,3333,3337,3341,3345],{"type":21,"tag":913,"props":3318,"children":3319},{"style":935},[3320],{"type":26,"value":938},{"type":21,"tag":913,"props":3322,"children":3323},{"style":925},[3324],{"type":26,"value":975},{"type":21,"tag":913,"props":3326,"children":3327},{"style":941},[3328],{"type":26,"value":1166},{"type":21,"tag":913,"props":3330,"children":3331},{"style":925},[3332],{"type":26,"value":1024},{"type":21,"tag":913,"props":3334,"children":3335},{"style":952},[3336],{"type":26,"value":1239},{"type":21,"tag":913,"props":3338,"children":3339},{"style":925},[3340],{"type":26,"value":985},{"type":21,"tag":913,"props":3342,"children":3343},{"style":952},[3344],{"type":26,"value":1248},{"type":21,"tag":913,"props":3346,"children":3347},{"style":958},[3348],{"type":26,"value":3349},"      ; Reset idle timeout (modem is alive)\n",{"type":21,"tag":913,"props":3351,"children":3352},{"class":915,"line":1104},[3353,3357,3362,3366,3370],{"type":21,"tag":913,"props":3354,"children":3355},{"style":935},[3356],{"type":26,"value":2921},{"type":21,"tag":913,"props":3358,"children":3359},{"style":952},[3360],{"type":26,"value":3361}," 1",{"type":21,"tag":913,"props":3363,"children":3364},{"style":925},[3365],{"type":26,"value":949},{"type":21,"tag":913,"props":3367,"children":3368},{"style":941},[3369],{"type":26,"value":990},{"type":21,"tag":913,"props":3371,"children":3372},{"style":958},[3373],{"type":26,"value":3374},"              ; RxRDY?\n",{"type":21,"tag":913,"props":3376,"children":3377},{"class":915,"line":1118},[3378,3382,3386],{"type":21,"tag":913,"props":3379,"children":3380},{"style":935},[3381],{"type":26,"value":2873},{"type":21,"tag":913,"props":3383,"children":3384},{"style":925},[3385],{"type":26,"value":2951},{"type":21,"tag":913,"props":3387,"children":3388},{"style":958},[3389],{"type":26,"value":3390},"; No data: return\n",{"type":21,"tag":913,"props":3392,"children":3393},{"class":915,"line":1148},[3394,3398,3403,3407,3411],{"type":21,"tag":913,"props":3395,"children":3396},{"style":935},[3397],{"type":26,"value":2921},{"type":21,"tag":913,"props":3399,"children":3400},{"style":952},[3401],{"type":26,"value":3402}," 3",{"type":21,"tag":913,"props":3404,"children":3405},{"style":925},[3406],{"type":26,"value":949},{"type":21,"tag":913,"props":3408,"children":3409},{"style":941},[3410],{"type":26,"value":990},{"type":21,"tag":913,"props":3412,"children":3413},{"style":958},[3414],{"type":26,"value":3415},"              ; Parity error?\n",{"type":21,"tag":913,"props":3417,"children":3418},{"class":915,"line":1188},[3419,3423,3427,3431,3435,3439],{"type":21,"tag":913,"props":3420,"children":3421},{"style":935},[3422],{"type":26,"value":2891},{"type":21,"tag":913,"props":3424,"children":3425},{"style":941},[3426],{"type":26,"value":944},{"type":21,"tag":913,"props":3428,"children":3429},{"style":925},[3430],{"type":26,"value":1014},{"type":21,"tag":913,"props":3432,"children":3433},{"style":952},[3434],{"type":26,"value":3099},{"type":21,"tag":913,"props":3436,"children":3437},{"style":925},[3438],{"type":26,"value":2908},{"type":21,"tag":913,"props":3440,"children":3441},{"style":958},[3442],{"type":26,"value":3443},"; Read received byte\n",{"type":21,"tag":913,"props":3445,"children":3446},{"class":915,"line":1217},[3447,3451,3456],{"type":21,"tag":913,"props":3448,"children":3449},{"style":935},[3450],{"type":26,"value":2595},{"type":21,"tag":913,"props":3452,"children":3453},{"style":925},[3454],{"type":26,"value":3455}," Z,.no_parity_err  ",{"type":21,"tag":913,"props":3457,"children":3458},{"style":958},[3459],{"type":26,"value":3460},"; No error: use as-is\n",{"type":21,"tag":913,"props":3462,"children":3463},{"class":915,"line":2709},[3464,3468,3472,3476,3480,3484,3488,3492],{"type":21,"tag":913,"props":3465,"children":3466},{"style":935},[3467],{"type":26,"value":938},{"type":21,"tag":913,"props":3469,"children":3470},{"style":941},[3471],{"type":26,"value":944},{"type":21,"tag":913,"props":3473,"children":3474},{"style":925},[3475],{"type":26,"value":1014},{"type":21,"tag":913,"props":3477,"children":3478},{"style":941},[3479],{"type":26,"value":1166},{"type":21,"tag":913,"props":3481,"children":3482},{"style":925},[3483],{"type":26,"value":1024},{"type":21,"tag":913,"props":3485,"children":3486},{"style":952},[3487],{"type":26,"value":250},{"type":21,"tag":913,"props":3489,"children":3490},{"style":925},[3491],{"type":26,"value":2701},{"type":21,"tag":913,"props":3493,"children":3494},{"style":958},[3495],{"type":26,"value":3496},"; Parity error: rewrite command register\n",{"type":21,"tag":913,"props":3498,"children":3499},{"class":915,"line":2730},[3500,3504,3508,3512,3516,3520],{"type":21,"tag":913,"props":3501,"children":3502},{"style":935},[3503],{"type":26,"value":970},{"type":21,"tag":913,"props":3505,"children":3506},{"style":925},[3507],{"type":26,"value":975},{"type":21,"tag":913,"props":3509,"children":3510},{"style":952},[3511],{"type":26,"value":980},{"type":21,"tag":913,"props":3513,"children":3514},{"style":925},[3515],{"type":26,"value":985},{"type":21,"tag":913,"props":3517,"children":3518},{"style":941},[3519],{"type":26,"value":990},{"type":21,"tag":913,"props":3521,"children":3522},{"style":958},[3523],{"type":26,"value":3524},"          ;   (clears error flags)\n",{"type":21,"tag":913,"props":3526,"children":3527},{"class":915,"line":2743},[3528,3532,3536,3540,3544],{"type":21,"tag":913,"props":3529,"children":3530},{"style":935},[3531],{"type":26,"value":938},{"type":21,"tag":913,"props":3533,"children":3534},{"style":941},[3535],{"type":26,"value":944},{"type":21,"tag":913,"props":3537,"children":3538},{"style":925},[3539],{"type":26,"value":949},{"type":21,"tag":913,"props":3541,"children":3542},{"style":952},[3543],{"type":26,"value":980},{"type":21,"tag":913,"props":3545,"children":3546},{"style":958},[3547],{"type":26,"value":3548},"             ;   Replace byte with $FF (error marker)\n",{"type":21,"tag":913,"props":3550,"children":3551},{"class":915,"line":3115},[3552,3557],{"type":21,"tag":913,"props":3553,"children":3554},{"style":920},[3555],{"type":26,"value":3556},".no_parity_err",{"type":21,"tag":913,"props":3558,"children":3559},{"style":925},[3560],{"type":26,"value":928},{"type":21,"tag":913,"props":3562,"children":3564},{"class":915,"line":3563},17,[3565,3569,3573,3577,3581],{"type":21,"tag":913,"props":3566,"children":3567},{"style":935},[3568],{"type":26,"value":938},{"type":21,"tag":913,"props":3570,"children":3571},{"style":941},[3572],{"type":26,"value":2561},{"type":21,"tag":913,"props":3574,"children":3575},{"style":925},[3576],{"type":26,"value":949},{"type":21,"tag":913,"props":3578,"children":3579},{"style":952},[3580],{"type":26,"value":285},{"type":21,"tag":913,"props":3582,"children":3583},{"style":958},[3584],{"type":26,"value":3585},"             ; Buffer type 4 (RX)\n",{"type":21,"tag":913,"props":3587,"children":3589},{"class":915,"line":3588},18,[3590,3594,3599],{"type":21,"tag":913,"props":3591,"children":3592},{"style":935},[3593],{"type":26,"value":2522},{"type":21,"tag":913,"props":3595,"children":3596},{"style":925},[3597],{"type":26,"value":3598}," BUF_WRITE       ",{"type":21,"tag":913,"props":3600,"children":3601},{"style":958},[3602],{"type":26,"value":3603},"; Write to buffer\n",{"type":21,"tag":913,"props":3605,"children":3607},{"class":915,"line":3606},19,[3608,3612,3617],{"type":21,"tag":913,"props":3609,"children":3610},{"style":935},[3611],{"type":26,"value":2522},{"type":21,"tag":913,"props":3613,"children":3614},{"style":925},[3615],{"type":26,"value":3616}," SET_CARRIER_TIMEOUT  ",{"type":21,"tag":913,"props":3618,"children":3619},{"style":958},[3620],{"type":26,"value":3621},"; Reset carrier timeout\n",{"type":21,"tag":913,"props":3623,"children":3625},{"class":915,"line":3624},20,[3626],{"type":21,"tag":913,"props":3627,"children":3628},{"style":935},[3629],{"type":26,"value":3121},{"type":21,"tag":22,"props":3631,"children":3632},{},[3633],{"type":26,"value":3634},"A few things are worth noting.",{"type":21,"tag":3636,"props":3637,"children":3638},"ol",{},[3639,3645],{"type":21,"tag":3640,"props":3641,"children":3642},"li",{},[3643],{"type":26,"value":3644},"If the modem isn't reporting Data Set Ready, we don't even try to read. This is the VTX5000's carrier detect mechanism.",{"type":21,"tag":3640,"props":3646,"children":3647},{},[3648,3650,3655],{"type":26,"value":3649},"Parity errors don't cause a crash or a disconnect - the errored byte is simply replaced with ",{"type":21,"tag":124,"props":3651,"children":3653},{"className":3652},[],[3654],{"type":26,"value":980},{"type":26,"value":3656}," and passed on. The rendering engine will display something garbled, but the connection stays up. At 1200 baud over a phone line, occasional parity errors are a fact of life.",{"type":21,"tag":22,"props":3658,"children":3659},{},[3660,3662,3668],{"type":26,"value":3661},"The idle timeout at ",{"type":21,"tag":124,"props":3663,"children":3665},{"className":3664},[],[3666],{"type":26,"value":3667},"IX+$1B",{"type":26,"value":3669}," is reset to 100 ($64) every time valid data arrives. It's decremented by the keyboard scan routine, and if it ever reaches zero, the return code is set to 2 (timeout). This is how the VTX5000 detects that the remote end has stopped sending.",{"type":21,"tag":55,"props":3671,"children":3673},{"id":3672},"the-buffers",[3674],{"type":26,"value":3675},"The Buffers",{"type":21,"tag":22,"props":3677,"children":3678},{},[3679],{"type":26,"value":3680},"There are two small buffers - type 2 for transmit, type 4 for receive - both embedded within the IX state block. Each buffer has a 2-byte count at its head, followed by the data bytes.",{"type":21,"tag":22,"props":3682,"children":3683},{},[3684,3690],{"type":21,"tag":3685,"props":3686,"children":3687},"strong",{},[3688],{"type":26,"value":3689},"Write",{"type":26,"value":3691}," is trivial - increment the count, calculate the write position by adding count to the base pointer, and store the byte - this is basically a ring buffer:",{"type":21,"tag":902,"props":3693,"children":3695},{"className":904,"code":3694,"language":906,"meta":907,"style":907},"BUF_WRITE:\n    CALL BUF_GETPTR      ; Get buffer base and current count\n    INC BC               ; Increment count\n    LD (HL),C            ; Store count low\n    INC HL\n    LD (HL),B            ; Store count high\n    ADD HL,BC            ; Point to write position\n    LD (HL),A            ; Write byte\n    RET\n",[3696],{"type":21,"tag":124,"props":3697,"children":3698},{"__ignoreMap":907},[3699,3711,3728,3746,3776,3788,3817,3844,3872],{"type":21,"tag":913,"props":3700,"children":3701},{"class":915,"line":916},[3702,3707],{"type":21,"tag":913,"props":3703,"children":3704},{"style":920},[3705],{"type":26,"value":3706},"BUF_WRITE",{"type":21,"tag":913,"props":3708,"children":3709},{"style":925},[3710],{"type":26,"value":928},{"type":21,"tag":913,"props":3712,"children":3713},{"class":915,"line":931},[3714,3718,3723],{"type":21,"tag":913,"props":3715,"children":3716},{"style":935},[3717],{"type":26,"value":2522},{"type":21,"tag":913,"props":3719,"children":3720},{"style":925},[3721],{"type":26,"value":3722}," BUF_GETPTR      ",{"type":21,"tag":913,"props":3724,"children":3725},{"style":958},[3726],{"type":26,"value":3727},"; Get buffer base and current count\n",{"type":21,"tag":913,"props":3729,"children":3730},{"class":915,"line":964},[3731,3736,3741],{"type":21,"tag":913,"props":3732,"children":3733},{"style":935},[3734],{"type":26,"value":3735},"    INC",{"type":21,"tag":913,"props":3737,"children":3738},{"style":941},[3739],{"type":26,"value":3740}," BC",{"type":21,"tag":913,"props":3742,"children":3743},{"style":958},[3744],{"type":26,"value":3745},"               ; Increment count\n",{"type":21,"tag":913,"props":3747,"children":3748},{"class":915,"line":998},[3749,3753,3757,3762,3766,3771],{"type":21,"tag":913,"props":3750,"children":3751},{"style":935},[3752],{"type":26,"value":938},{"type":21,"tag":913,"props":3754,"children":3755},{"style":925},[3756],{"type":26,"value":975},{"type":21,"tag":913,"props":3758,"children":3759},{"style":941},[3760],{"type":26,"value":3761},"HL",{"type":21,"tag":913,"props":3763,"children":3764},{"style":925},[3765],{"type":26,"value":985},{"type":21,"tag":913,"props":3767,"children":3768},{"style":941},[3769],{"type":26,"value":3770},"C",{"type":21,"tag":913,"props":3772,"children":3773},{"style":958},[3774],{"type":26,"value":3775},"            ; Store count low\n",{"type":21,"tag":913,"props":3777,"children":3778},{"class":915,"line":1041},[3779,3783],{"type":21,"tag":913,"props":3780,"children":3781},{"style":935},[3782],{"type":26,"value":3735},{"type":21,"tag":913,"props":3784,"children":3785},{"style":941},[3786],{"type":26,"value":3787}," HL\n",{"type":21,"tag":913,"props":3789,"children":3790},{"class":915,"line":1066},[3791,3795,3799,3803,3807,3812],{"type":21,"tag":913,"props":3792,"children":3793},{"style":935},[3794],{"type":26,"value":938},{"type":21,"tag":913,"props":3796,"children":3797},{"style":925},[3798],{"type":26,"value":975},{"type":21,"tag":913,"props":3800,"children":3801},{"style":941},[3802],{"type":26,"value":3761},{"type":21,"tag":913,"props":3804,"children":3805},{"style":925},[3806],{"type":26,"value":985},{"type":21,"tag":913,"props":3808,"children":3809},{"style":941},[3810],{"type":26,"value":3811},"B",{"type":21,"tag":913,"props":3813,"children":3814},{"style":958},[3815],{"type":26,"value":3816},"            ; Store count high\n",{"type":21,"tag":913,"props":3818,"children":3819},{"class":915,"line":1095},[3820,3825,3830,3834,3839],{"type":21,"tag":913,"props":3821,"children":3822},{"style":935},[3823],{"type":26,"value":3824},"    ADD",{"type":21,"tag":913,"props":3826,"children":3827},{"style":941},[3828],{"type":26,"value":3829}," HL",{"type":21,"tag":913,"props":3831,"children":3832},{"style":925},[3833],{"type":26,"value":949},{"type":21,"tag":913,"props":3835,"children":3836},{"style":941},[3837],{"type":26,"value":3838},"BC",{"type":21,"tag":913,"props":3840,"children":3841},{"style":958},[3842],{"type":26,"value":3843},"            ; Point to write position\n",{"type":21,"tag":913,"props":3845,"children":3846},{"class":915,"line":1104},[3847,3851,3855,3859,3863,3867],{"type":21,"tag":913,"props":3848,"children":3849},{"style":935},[3850],{"type":26,"value":938},{"type":21,"tag":913,"props":3852,"children":3853},{"style":925},[3854],{"type":26,"value":975},{"type":21,"tag":913,"props":3856,"children":3857},{"style":941},[3858],{"type":26,"value":3761},{"type":21,"tag":913,"props":3860,"children":3861},{"style":925},[3862],{"type":26,"value":985},{"type":21,"tag":913,"props":3864,"children":3865},{"style":941},[3866],{"type":26,"value":990},{"type":21,"tag":913,"props":3868,"children":3869},{"style":958},[3870],{"type":26,"value":3871},"            ; Write byte\n",{"type":21,"tag":913,"props":3873,"children":3874},{"class":915,"line":1118},[3875],{"type":21,"tag":913,"props":3876,"children":3877},{"style":935},[3878],{"type":26,"value":3121},{"type":21,"tag":22,"props":3880,"children":3881},{},[3882,3887],{"type":21,"tag":3685,"props":3883,"children":3884},{},[3885],{"type":26,"value":3886},"Read",{"type":26,"value":3888}," is more interesting - after reading the first byte, it shifts the entire remaining buffer down by one position using LDIR:",{"type":21,"tag":902,"props":3890,"children":3892},{"className":904,"code":3891,"language":906,"meta":907,"style":907},"BUF_READ:\n    CALL BUF_GETPTR      ; Get buffer base and count\n    LD A,B\n    OR C                 ; Empty?\n    RET Z                ; Yes: return Z flag\n    DEC BC               ; Decrement count\n    LD (HL),C            ; Store new count\n    INC HL\n    LD (HL),B\n    INC HL\n    LD A,(HL)            ; Read first byte\n    INC BC               ; Restore count for shift\n    LD E,L               ; Set up LDIR (shift buffer down by 1)\n    LD D,H\n    INC HL\n    LDIR                 ; Shift remaining bytes\n    RET\n",[3893],{"type":21,"tag":124,"props":3894,"children":3895},{"__ignoreMap":907},[3896,3908,3924,3944,3960,3976,3993,4021,4032,4055,4066,4095,4111,4137,4158,4169,4182],{"type":21,"tag":913,"props":3897,"children":3898},{"class":915,"line":916},[3899,3904],{"type":21,"tag":913,"props":3900,"children":3901},{"style":920},[3902],{"type":26,"value":3903},"BUF_READ",{"type":21,"tag":913,"props":3905,"children":3906},{"style":925},[3907],{"type":26,"value":928},{"type":21,"tag":913,"props":3909,"children":3910},{"class":915,"line":931},[3911,3915,3919],{"type":21,"tag":913,"props":3912,"children":3913},{"style":935},[3914],{"type":26,"value":2522},{"type":21,"tag":913,"props":3916,"children":3917},{"style":925},[3918],{"type":26,"value":3722},{"type":21,"tag":913,"props":3920,"children":3921},{"style":958},[3922],{"type":26,"value":3923},"; Get buffer base and count\n",{"type":21,"tag":913,"props":3925,"children":3926},{"class":915,"line":964},[3927,3931,3935,3939],{"type":21,"tag":913,"props":3928,"children":3929},{"style":935},[3930],{"type":26,"value":938},{"type":21,"tag":913,"props":3932,"children":3933},{"style":941},[3934],{"type":26,"value":944},{"type":21,"tag":913,"props":3936,"children":3937},{"style":925},[3938],{"type":26,"value":949},{"type":21,"tag":913,"props":3940,"children":3941},{"style":941},[3942],{"type":26,"value":3943},"B\n",{"type":21,"tag":913,"props":3945,"children":3946},{"class":915,"line":998},[3947,3951,3955],{"type":21,"tag":913,"props":3948,"children":3949},{"style":935},[3950],{"type":26,"value":2736},{"type":21,"tag":913,"props":3952,"children":3953},{"style":941},[3954],{"type":26,"value":2680},{"type":21,"tag":913,"props":3956,"children":3957},{"style":958},[3958],{"type":26,"value":3959},"                 ; Empty?\n",{"type":21,"tag":913,"props":3961,"children":3962},{"class":915,"line":1041},[3963,3967,3971],{"type":21,"tag":913,"props":3964,"children":3965},{"style":935},[3966],{"type":26,"value":2873},{"type":21,"tag":913,"props":3968,"children":3969},{"style":925},[3970],{"type":26,"value":2951},{"type":21,"tag":913,"props":3972,"children":3973},{"style":958},[3974],{"type":26,"value":3975},"; Yes: return Z flag\n",{"type":21,"tag":913,"props":3977,"children":3978},{"class":915,"line":1066},[3979,3984,3988],{"type":21,"tag":913,"props":3980,"children":3981},{"style":935},[3982],{"type":26,"value":3983},"    DEC",{"type":21,"tag":913,"props":3985,"children":3986},{"style":941},[3987],{"type":26,"value":3740},{"type":21,"tag":913,"props":3989,"children":3990},{"style":958},[3991],{"type":26,"value":3992},"               ; Decrement count\n",{"type":21,"tag":913,"props":3994,"children":3995},{"class":915,"line":1095},[3996,4000,4004,4008,4012,4016],{"type":21,"tag":913,"props":3997,"children":3998},{"style":935},[3999],{"type":26,"value":938},{"type":21,"tag":913,"props":4001,"children":4002},{"style":925},[4003],{"type":26,"value":975},{"type":21,"tag":913,"props":4005,"children":4006},{"style":941},[4007],{"type":26,"value":3761},{"type":21,"tag":913,"props":4009,"children":4010},{"style":925},[4011],{"type":26,"value":985},{"type":21,"tag":913,"props":4013,"children":4014},{"style":941},[4015],{"type":26,"value":3770},{"type":21,"tag":913,"props":4017,"children":4018},{"style":958},[4019],{"type":26,"value":4020},"            ; Store new count\n",{"type":21,"tag":913,"props":4022,"children":4023},{"class":915,"line":1104},[4024,4028],{"type":21,"tag":913,"props":4025,"children":4026},{"style":935},[4027],{"type":26,"value":3735},{"type":21,"tag":913,"props":4029,"children":4030},{"style":941},[4031],{"type":26,"value":3787},{"type":21,"tag":913,"props":4033,"children":4034},{"class":915,"line":1118},[4035,4039,4043,4047,4051],{"type":21,"tag":913,"props":4036,"children":4037},{"style":935},[4038],{"type":26,"value":938},{"type":21,"tag":913,"props":4040,"children":4041},{"style":925},[4042],{"type":26,"value":975},{"type":21,"tag":913,"props":4044,"children":4045},{"style":941},[4046],{"type":26,"value":3761},{"type":21,"tag":913,"props":4048,"children":4049},{"style":925},[4050],{"type":26,"value":985},{"type":21,"tag":913,"props":4052,"children":4053},{"style":941},[4054],{"type":26,"value":3943},{"type":21,"tag":913,"props":4056,"children":4057},{"class":915,"line":1148},[4058,4062],{"type":21,"tag":913,"props":4059,"children":4060},{"style":935},[4061],{"type":26,"value":3735},{"type":21,"tag":913,"props":4063,"children":4064},{"style":941},[4065],{"type":26,"value":3787},{"type":21,"tag":913,"props":4067,"children":4068},{"class":915,"line":1188},[4069,4073,4077,4081,4085,4090],{"type":21,"tag":913,"props":4070,"children":4071},{"style":935},[4072],{"type":26,"value":938},{"type":21,"tag":913,"props":4074,"children":4075},{"style":941},[4076],{"type":26,"value":944},{"type":21,"tag":913,"props":4078,"children":4079},{"style":925},[4080],{"type":26,"value":1014},{"type":21,"tag":913,"props":4082,"children":4083},{"style":941},[4084],{"type":26,"value":3761},{"type":21,"tag":913,"props":4086,"children":4087},{"style":925},[4088],{"type":26,"value":4089},")            ",{"type":21,"tag":913,"props":4091,"children":4092},{"style":958},[4093],{"type":26,"value":4094},"; Read first byte\n",{"type":21,"tag":913,"props":4096,"children":4097},{"class":915,"line":1217},[4098,4102,4106],{"type":21,"tag":913,"props":4099,"children":4100},{"style":935},[4101],{"type":26,"value":3735},{"type":21,"tag":913,"props":4103,"children":4104},{"style":941},[4105],{"type":26,"value":3740},{"type":21,"tag":913,"props":4107,"children":4108},{"style":958},[4109],{"type":26,"value":4110},"               ; Restore count for shift\n",{"type":21,"tag":913,"props":4112,"children":4113},{"class":915,"line":2709},[4114,4118,4123,4127,4132],{"type":21,"tag":913,"props":4115,"children":4116},{"style":935},[4117],{"type":26,"value":938},{"type":21,"tag":913,"props":4119,"children":4120},{"style":941},[4121],{"type":26,"value":4122}," E",{"type":21,"tag":913,"props":4124,"children":4125},{"style":925},[4126],{"type":26,"value":949},{"type":21,"tag":913,"props":4128,"children":4129},{"style":941},[4130],{"type":26,"value":4131},"L",{"type":21,"tag":913,"props":4133,"children":4134},{"style":958},[4135],{"type":26,"value":4136},"               ; Set up LDIR (shift buffer down by 1)\n",{"type":21,"tag":913,"props":4138,"children":4139},{"class":915,"line":2730},[4140,4144,4149,4153],{"type":21,"tag":913,"props":4141,"children":4142},{"style":935},[4143],{"type":26,"value":938},{"type":21,"tag":913,"props":4145,"children":4146},{"style":941},[4147],{"type":26,"value":4148}," D",{"type":21,"tag":913,"props":4150,"children":4151},{"style":925},[4152],{"type":26,"value":949},{"type":21,"tag":913,"props":4154,"children":4155},{"style":941},[4156],{"type":26,"value":4157},"H\n",{"type":21,"tag":913,"props":4159,"children":4160},{"class":915,"line":2743},[4161,4165],{"type":21,"tag":913,"props":4162,"children":4163},{"style":935},[4164],{"type":26,"value":3735},{"type":21,"tag":913,"props":4166,"children":4167},{"style":941},[4168],{"type":26,"value":3787},{"type":21,"tag":913,"props":4170,"children":4171},{"class":915,"line":3115},[4172,4177],{"type":21,"tag":913,"props":4173,"children":4174},{"style":935},[4175],{"type":26,"value":4176},"    LDIR",{"type":21,"tag":913,"props":4178,"children":4179},{"style":958},[4180],{"type":26,"value":4181},"                 ; Shift remaining bytes\n",{"type":21,"tag":913,"props":4183,"children":4184},{"class":915,"line":3563},[4185],{"type":21,"tag":913,"props":4186,"children":4187},{"style":935},[4188],{"type":26,"value":3121},{"type":21,"tag":22,"props":4190,"children":4191},{},[4192],{"type":26,"value":4193},"This is technically a FIFO queue as there's no wrap-around, just a linear shift on every read. At 1200 baud with a buffer size of 16 bytes (when online) or 255 bytes (when offline), the LDIR is never shifting more than a few bytes, so the performance cost is negligible. It's a simpler implementation than a proper circular buffer with head/tail pointers, and on a system where RAM is scarce, every byte counts.",{"type":21,"tag":22,"props":4195,"children":4196},{},[4197,4199,4205,4206,4212],{"type":26,"value":4198},"The ",{"type":21,"tag":124,"props":4200,"children":4202},{"className":4201},[],[4203],{"type":26,"value":4204},"BUF_GETPTR",{"type":26,"value":892},{"type":21,"tag":124,"props":4207,"children":4209},{"className":4208},[],[4210],{"type":26,"value":4211},"$15F3",{"type":26,"value":4213}," finds the right buffer by walking through the chain. Buffer type is passed in the B register, and the routine skips forward through the count/data pairs until it reaches the right one. It's a linked-list walk through what's essentially a stack of variably-sized buffers inside the IX state block.",{"type":21,"tag":55,"props":4215,"children":4217},{"id":4216},"timeouts",[4218],{"type":26,"value":4219},"Timeouts",{"type":21,"tag":22,"props":4221,"children":4222},{},[4223],{"type":26,"value":4224},"Two separate timeout mechanisms protect against connection problems:",{"type":21,"tag":22,"props":4226,"children":4227},{},[4228,4229,4234,4235,4240],{"type":26,"value":4198},{"type":21,"tag":3685,"props":4230,"children":4231},{},[4232],{"type":26,"value":4233},"idle timeout",{"type":26,"value":975},{"type":21,"tag":124,"props":4236,"children":4238},{"className":4237},[],[4239],{"type":26,"value":3667},{"type":26,"value":4241},", initialised to 100) counts down on each keyboard scan. Any received data resets it. If it hits zero, the return code is set to 2 (\"Line Break\" in BASIC). This catches the case where the remote end goes silent - no data, no carrier drop, just silence.",{"type":21,"tag":22,"props":4243,"children":4244},{},[4245,4246,4251,4252,4258,4260,4266,4268,4274],{"type":26,"value":4198},{"type":21,"tag":3685,"props":4247,"children":4248},{},[4249],{"type":26,"value":4250},"carrier timeout",{"type":26,"value":975},{"type":21,"tag":124,"props":4253,"children":4255},{"className":4254},[],[4256],{"type":26,"value":4257},"IX+$19",{"type":26,"value":4259},"/",{"type":21,"tag":124,"props":4261,"children":4263},{"className":4262},[],[4264],{"type":26,"value":4265},"$1A",{"type":26,"value":4267},", a 16-bit counter) uses different values depending on mode: 25000 cycles when offline and waiting for a connection, or a configured value when online. It's decremented on each keyboard scan, and if both bytes reach zero, the return code is set to 3 (\"Carrier lost\"). The ",{"type":21,"tag":124,"props":4269,"children":4271},{"className":4270},[],[4272],{"type":26,"value":4273},"SET_CARRIER_TIMEOUT",{"type":26,"value":4275}," routine picks the right values:",{"type":21,"tag":902,"props":4277,"children":4279},{"className":904,"code":4278,"language":906,"meta":907,"style":907},"SET_CARRIER_TIMEOUT:\n    LD L,(IX+$42)        ; Online timeout low\n    LD H,(IX+$43)        ; Online timeout high\n    BIT 0,(IX+$06)       ; Online?\n    JR NZ,.set_timeout   ; Yes\n    LD L,(IX+$44)        ; Offline timeout low\n    LD H,(IX+$45)        ; Offline timeout high\n    BIT 4,(IX+$06)       ; Auto-answer?\n    JR NZ,.set_timeout   ; Yes\n    LD HL,$61A8          ; Default: 25000\n.set_timeout:\n    LD (IX+$19),L\n    INC H                ; Add 256 to high byte\n    LD (IX+$1A),H\n    RET\n",[4280],{"type":21,"tag":124,"props":4281,"children":4282},{"__ignoreMap":907},[4283,4294,4332,4370,4406,4427,4464,4501,4538,4557,4582,4594,4627,4643,4674],{"type":21,"tag":913,"props":4284,"children":4285},{"class":915,"line":916},[4286,4290],{"type":21,"tag":913,"props":4287,"children":4288},{"style":920},[4289],{"type":26,"value":4273},{"type":21,"tag":913,"props":4291,"children":4292},{"style":925},[4293],{"type":26,"value":928},{"type":21,"tag":913,"props":4295,"children":4296},{"class":915,"line":931},[4297,4301,4306,4310,4314,4318,4323,4327],{"type":21,"tag":913,"props":4298,"children":4299},{"style":935},[4300],{"type":26,"value":938},{"type":21,"tag":913,"props":4302,"children":4303},{"style":941},[4304],{"type":26,"value":4305}," L",{"type":21,"tag":913,"props":4307,"children":4308},{"style":925},[4309],{"type":26,"value":1014},{"type":21,"tag":913,"props":4311,"children":4312},{"style":941},[4313],{"type":26,"value":1166},{"type":21,"tag":913,"props":4315,"children":4316},{"style":925},[4317],{"type":26,"value":1024},{"type":21,"tag":913,"props":4319,"children":4320},{"style":952},[4321],{"type":26,"value":4322},"$42",{"type":21,"tag":913,"props":4324,"children":4325},{"style":925},[4326],{"type":26,"value":2701},{"type":21,"tag":913,"props":4328,"children":4329},{"style":958},[4330],{"type":26,"value":4331},"; Online timeout low\n",{"type":21,"tag":913,"props":4333,"children":4334},{"class":915,"line":964},[4335,4339,4344,4348,4352,4356,4361,4365],{"type":21,"tag":913,"props":4336,"children":4337},{"style":935},[4338],{"type":26,"value":938},{"type":21,"tag":913,"props":4340,"children":4341},{"style":941},[4342],{"type":26,"value":4343}," H",{"type":21,"tag":913,"props":4345,"children":4346},{"style":925},[4347],{"type":26,"value":1014},{"type":21,"tag":913,"props":4349,"children":4350},{"style":941},[4351],{"type":26,"value":1166},{"type":21,"tag":913,"props":4353,"children":4354},{"style":925},[4355],{"type":26,"value":1024},{"type":21,"tag":913,"props":4357,"children":4358},{"style":952},[4359],{"type":26,"value":4360},"$43",{"type":21,"tag":913,"props":4362,"children":4363},{"style":925},[4364],{"type":26,"value":2701},{"type":21,"tag":913,"props":4366,"children":4367},{"style":958},[4368],{"type":26,"value":4369},"; Online timeout high\n",{"type":21,"tag":913,"props":4371,"children":4372},{"class":915,"line":998},[4373,4377,4381,4385,4389,4393,4397,4401],{"type":21,"tag":913,"props":4374,"children":4375},{"style":935},[4376],{"type":26,"value":2921},{"type":21,"tag":913,"props":4378,"children":4379},{"style":952},[4380],{"type":26,"value":2926},{"type":21,"tag":913,"props":4382,"children":4383},{"style":925},[4384],{"type":26,"value":1014},{"type":21,"tag":913,"props":4386,"children":4387},{"style":941},[4388],{"type":26,"value":1166},{"type":21,"tag":913,"props":4390,"children":4391},{"style":925},[4392],{"type":26,"value":1024},{"type":21,"tag":913,"props":4394,"children":4395},{"style":952},[4396],{"type":26,"value":2842},{"type":21,"tag":913,"props":4398,"children":4399},{"style":925},[4400],{"type":26,"value":1180},{"type":21,"tag":913,"props":4402,"children":4403},{"style":958},[4404],{"type":26,"value":4405},"; Online?\n",{"type":21,"tag":913,"props":4407,"children":4408},{"class":915,"line":1041},[4409,4413,4417,4422],{"type":21,"tag":913,"props":4410,"children":4411},{"style":935},[4412],{"type":26,"value":2595},{"type":21,"tag":913,"props":4414,"children":4415},{"style":941},[4416],{"type":26,"value":2878},{"type":21,"tag":913,"props":4418,"children":4419},{"style":925},[4420],{"type":26,"value":4421},",.set_timeout   ",{"type":21,"tag":913,"props":4423,"children":4424},{"style":958},[4425],{"type":26,"value":4426},"; Yes\n",{"type":21,"tag":913,"props":4428,"children":4429},{"class":915,"line":1066},[4430,4434,4438,4442,4446,4450,4455,4459],{"type":21,"tag":913,"props":4431,"children":4432},{"style":935},[4433],{"type":26,"value":938},{"type":21,"tag":913,"props":4435,"children":4436},{"style":941},[4437],{"type":26,"value":4305},{"type":21,"tag":913,"props":4439,"children":4440},{"style":925},[4441],{"type":26,"value":1014},{"type":21,"tag":913,"props":4443,"children":4444},{"style":941},[4445],{"type":26,"value":1166},{"type":21,"tag":913,"props":4447,"children":4448},{"style":925},[4449],{"type":26,"value":1024},{"type":21,"tag":913,"props":4451,"children":4452},{"style":952},[4453],{"type":26,"value":4454},"$44",{"type":21,"tag":913,"props":4456,"children":4457},{"style":925},[4458],{"type":26,"value":2701},{"type":21,"tag":913,"props":4460,"children":4461},{"style":958},[4462],{"type":26,"value":4463},"; Offline timeout low\n",{"type":21,"tag":913,"props":4465,"children":4466},{"class":915,"line":1095},[4467,4471,4475,4479,4483,4487,4492,4496],{"type":21,"tag":913,"props":4468,"children":4469},{"style":935},[4470],{"type":26,"value":938},{"type":21,"tag":913,"props":4472,"children":4473},{"style":941},[4474],{"type":26,"value":4343},{"type":21,"tag":913,"props":4476,"children":4477},{"style":925},[4478],{"type":26,"value":1014},{"type":21,"tag":913,"props":4480,"children":4481},{"style":941},[4482],{"type":26,"value":1166},{"type":21,"tag":913,"props":4484,"children":4485},{"style":925},[4486],{"type":26,"value":1024},{"type":21,"tag":913,"props":4488,"children":4489},{"style":952},[4490],{"type":26,"value":4491},"$45",{"type":21,"tag":913,"props":4493,"children":4494},{"style":925},[4495],{"type":26,"value":2701},{"type":21,"tag":913,"props":4497,"children":4498},{"style":958},[4499],{"type":26,"value":4500},"; Offline timeout high\n",{"type":21,"tag":913,"props":4502,"children":4503},{"class":915,"line":1104},[4504,4508,4513,4517,4521,4525,4529,4533],{"type":21,"tag":913,"props":4505,"children":4506},{"style":935},[4507],{"type":26,"value":2921},{"type":21,"tag":913,"props":4509,"children":4510},{"style":952},[4511],{"type":26,"value":4512}," 4",{"type":21,"tag":913,"props":4514,"children":4515},{"style":925},[4516],{"type":26,"value":1014},{"type":21,"tag":913,"props":4518,"children":4519},{"style":941},[4520],{"type":26,"value":1166},{"type":21,"tag":913,"props":4522,"children":4523},{"style":925},[4524],{"type":26,"value":1024},{"type":21,"tag":913,"props":4526,"children":4527},{"style":952},[4528],{"type":26,"value":2842},{"type":21,"tag":913,"props":4530,"children":4531},{"style":925},[4532],{"type":26,"value":1180},{"type":21,"tag":913,"props":4534,"children":4535},{"style":958},[4536],{"type":26,"value":4537},"; Auto-answer?\n",{"type":21,"tag":913,"props":4539,"children":4540},{"class":915,"line":1118},[4541,4545,4549,4553],{"type":21,"tag":913,"props":4542,"children":4543},{"style":935},[4544],{"type":26,"value":2595},{"type":21,"tag":913,"props":4546,"children":4547},{"style":941},[4548],{"type":26,"value":2878},{"type":21,"tag":913,"props":4550,"children":4551},{"style":925},[4552],{"type":26,"value":4421},{"type":21,"tag":913,"props":4554,"children":4555},{"style":958},[4556],{"type":26,"value":4426},{"type":21,"tag":913,"props":4558,"children":4559},{"class":915,"line":1148},[4560,4564,4568,4572,4577],{"type":21,"tag":913,"props":4561,"children":4562},{"style":935},[4563],{"type":26,"value":938},{"type":21,"tag":913,"props":4565,"children":4566},{"style":941},[4567],{"type":26,"value":3829},{"type":21,"tag":913,"props":4569,"children":4570},{"style":925},[4571],{"type":26,"value":949},{"type":21,"tag":913,"props":4573,"children":4574},{"style":952},[4575],{"type":26,"value":4576},"$61A8",{"type":21,"tag":913,"props":4578,"children":4579},{"style":958},[4580],{"type":26,"value":4581},"          ; Default: 25000\n",{"type":21,"tag":913,"props":4583,"children":4584},{"class":915,"line":1188},[4585,4590],{"type":21,"tag":913,"props":4586,"children":4587},{"style":920},[4588],{"type":26,"value":4589},".set_timeout",{"type":21,"tag":913,"props":4591,"children":4592},{"style":925},[4593],{"type":26,"value":928},{"type":21,"tag":913,"props":4595,"children":4596},{"class":915,"line":1217},[4597,4601,4605,4609,4613,4618,4622],{"type":21,"tag":913,"props":4598,"children":4599},{"style":935},[4600],{"type":26,"value":938},{"type":21,"tag":913,"props":4602,"children":4603},{"style":925},[4604],{"type":26,"value":975},{"type":21,"tag":913,"props":4606,"children":4607},{"style":941},[4608],{"type":26,"value":1166},{"type":21,"tag":913,"props":4610,"children":4611},{"style":925},[4612],{"type":26,"value":1024},{"type":21,"tag":913,"props":4614,"children":4615},{"style":952},[4616],{"type":26,"value":4617},"$19",{"type":21,"tag":913,"props":4619,"children":4620},{"style":925},[4621],{"type":26,"value":985},{"type":21,"tag":913,"props":4623,"children":4624},{"style":941},[4625],{"type":26,"value":4626},"L\n",{"type":21,"tag":913,"props":4628,"children":4629},{"class":915,"line":2709},[4630,4634,4638],{"type":21,"tag":913,"props":4631,"children":4632},{"style":935},[4633],{"type":26,"value":3735},{"type":21,"tag":913,"props":4635,"children":4636},{"style":941},[4637],{"type":26,"value":4343},{"type":21,"tag":913,"props":4639,"children":4640},{"style":958},[4641],{"type":26,"value":4642},"                ; Add 256 to high byte\n",{"type":21,"tag":913,"props":4644,"children":4645},{"class":915,"line":2730},[4646,4650,4654,4658,4662,4666,4670],{"type":21,"tag":913,"props":4647,"children":4648},{"style":935},[4649],{"type":26,"value":938},{"type":21,"tag":913,"props":4651,"children":4652},{"style":925},[4653],{"type":26,"value":975},{"type":21,"tag":913,"props":4655,"children":4656},{"style":941},[4657],{"type":26,"value":1166},{"type":21,"tag":913,"props":4659,"children":4660},{"style":925},[4661],{"type":26,"value":1024},{"type":21,"tag":913,"props":4663,"children":4664},{"style":952},[4665],{"type":26,"value":4265},{"type":21,"tag":913,"props":4667,"children":4668},{"style":925},[4669],{"type":26,"value":985},{"type":21,"tag":913,"props":4671,"children":4672},{"style":941},[4673],{"type":26,"value":4157},{"type":21,"tag":913,"props":4675,"children":4676},{"class":915,"line":2743},[4677],{"type":21,"tag":913,"props":4678,"children":4679},{"style":935},[4680],{"type":26,"value":3121},{"type":21,"tag":55,"props":4682,"children":4684},{"id":4683},"keyboard-scanning",[4685],{"type":26,"value":4686},"Keyboard Scanning",{"type":21,"tag":22,"props":4688,"children":4689},{},[4690,4692,4698],{"type":26,"value":4691},"The keyboard scanner at ",{"type":21,"tag":124,"props":4693,"children":4695},{"className":4694},[],[4696],{"type":26,"value":4697},"$1550",{"type":26,"value":4699}," does more than just read keys - it handles the translation from Spectrum's keyboard layout to Prestel's expectations.",{"type":21,"tag":22,"props":4701,"children":4702},{},[4703,4705,4710],{"type":26,"value":4704},"The Spectrum keyboard uses a matrix read via port ",{"type":21,"tag":124,"props":4706,"children":4708},{"className":4707},[],[4709],{"type":26,"value":1132},{"type":26,"value":4711},". The scanner first checks for BREAK (CAPS SHIFT + SPACE), which sets return code 1 for an immediate exit. Then it reads the key value from the Spectrum's system variables (the ROM's interrupt handler has already decoded the matrix) and applies several transformations:",{"type":21,"tag":4713,"props":4714,"children":4715},"ul",{},[4716,4749,4765,4781,4805],{"type":21,"tag":3640,"props":4717,"children":4718},{},[4719,4725,4726,4732,4734,4740,4742,4747],{"type":21,"tag":4720,"props":4721,"children":4722},"kbd",{},[4723],{"type":26,"value":4724},"Symbol Shift",{"type":26,"value":975},{"type":21,"tag":124,"props":4727,"children":4729},{"className":4728},[],[4730],{"type":26,"value":4731},"$0E",{"type":26,"value":4733},") sets internal shift state flags - Prestel uses ",{"type":21,"tag":124,"props":4735,"children":4737},{"className":4736},[],[4738],{"type":26,"value":4739},"*",{"type":26,"value":4741}," (star) as a modifier key, so Symbol Shift is remapped to ",{"type":21,"tag":124,"props":4743,"children":4745},{"className":4744},[],[4746],{"type":26,"value":4739},{"type":26,"value":4748}," for Prestel navigation",{"type":21,"tag":3640,"props":4750,"children":4751},{},[4752,4757,4758,4763],{"type":21,"tag":4720,"props":4753,"children":4754},{},[4755],{"type":26,"value":4756},"CAPS LOCK",{"type":26,"value":975},{"type":21,"tag":124,"props":4759,"children":4761},{"className":4760},[],[4762],{"type":26,"value":2842},{"type":26,"value":4764},") toggles bit 3 of the border colour attribute - this gives visual feedback (bright/dim border) to show caps lock state, since Viewdata doesn't have a separate caps indicator",{"type":21,"tag":3640,"props":4766,"children":4767},{},[4768,4773,4774,4779],{"type":21,"tag":4720,"props":4769,"children":4770},{},[4771],{"type":26,"value":4772},"EDIT",{"type":26,"value":975},{"type":21,"tag":124,"props":4775,"children":4777},{"className":4776},[],[4778],{"type":26,"value":1175},{"type":26,"value":4780},") toggles a display mode flag and triggers a full screen refresh",{"type":21,"tag":3640,"props":4782,"children":4783},{},[4784,4789,4790,4796,4798,4803],{"type":21,"tag":4720,"props":4785,"children":4786},{},[4787],{"type":26,"value":4788},"ENTER",{"type":26,"value":975},{"type":21,"tag":124,"props":4791,"children":4793},{"className":4792},[],[4794],{"type":26,"value":4795},"$0D",{"type":26,"value":4797},") becomes ",{"type":21,"tag":124,"props":4799,"children":4801},{"className":4800},[],[4802],{"type":26,"value":3066},{"type":26,"value":4804}," (underscore) - in Prestel, underscore is the \"send\" character",{"type":21,"tag":3640,"props":4806,"children":4807},{},[4808,4813,4814,4819,4820,4825],{"type":21,"tag":4720,"props":4809,"children":4810},{},[4811],{"type":26,"value":4812},"DELETE",{"type":26,"value":975},{"type":21,"tag":124,"props":4815,"children":4817},{"className":4816},[],[4818],{"type":26,"value":530},{"type":26,"value":4797},{"type":21,"tag":124,"props":4821,"children":4823},{"className":4822},[],[4824],{"type":26,"value":250},{"type":26,"value":4826}," (backspace)",{"type":21,"tag":22,"props":4828,"children":4829},{},[4830,4832,4838],{"type":26,"value":4831},"The keyboard lock feature (bit 2 of ",{"type":21,"tag":124,"props":4833,"children":4835},{"className":4834},[],[4836],{"type":26,"value":4837},"IX+$06",{"type":26,"value":4839},") suppresses all key output when set. This is used during data reception - Prestel doesn't support type-ahead, so keys pressed while a frame is loading should be discarded.",{"type":21,"tag":55,"props":4841,"children":4843},{"id":4842},"whats-next",[4844],{"type":26,"value":4845},"What's Next",{"type":21,"tag":22,"props":4847,"children":4848},{},[4849],{"type":26,"value":4850},"In part 5 we'll tackle the Viewdata rendering engine and how it renders that 40x24 display with a 5-pixel font, mosaic block graphics and Prestel frames onto the Speccy's display.",{"type":21,"tag":4852,"props":4853,"children":4854},"style",{},[4855],{"type":26,"value":4856},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":907,"searchDepth":931,"depth":931,"links":4858},[4859,4860,4861,4862,4863,4864,4865,4866,4867,4868],{"id":57,"depth":964,"text":60},{"id":876,"depth":964,"text":879},{"id":1266,"depth":964,"text":1269},{"id":2450,"depth":964,"text":2453},{"id":2787,"depth":964,"text":2790},{"id":3166,"depth":964,"text":3169},{"id":3672,"depth":964,"text":3675},{"id":4216,"depth":964,"text":4219},{"id":4683,"depth":964,"text":4686},{"id":4842,"depth":964,"text":4845},"markdown","content:blog:2026:2026-05-06-vtx5000-part-4-comms-routines.md","content","blog/2026/2026-05-06-vtx5000-part-4-comms-routines.md","blog/2026/2026-05-06-vtx5000-part-4-comms-routines","md","/blog/2026/05/06/vtx5000-part-4-comms-routines/",2552,0,1778147686400]