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