Skip to navigation

Elite on the BBC Micro and NES

Bank 2 (Part 4 of 4)

[NES version]

Name: QQ18_FR [Show more] Type: Variable Category: Text Summary: The recursive token table for tokens 0-148 (French) Deep dive: Printing text tokens Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * tokensHi uses QQ18_FR * tokensLo uses QQ18_FR
.QQ18_FR RTOK 105 ; Token 0: "LE FUEL {beep}" CHAR ' ' ; CONT 7 ; Encoded as: "[105] {7}" EQUB 0 CHAR ' ' ; Token 1: " CARTE" CHAR 'C' ; TWOK 'A', 'R' ; Encoded as: " C<138><156>" TWOK 'T', 'E' EQUB 0 CHAR 'G' ; Token 2: "GOUVERNEMENT" CHAR 'O' ; CHAR 'U' ; Encoded as: "GOUV<144>NEM<146>T" CHAR 'V' TWOK 'E', 'R' CHAR 'N' CHAR 'E' CHAR 'M' TWOK 'E', 'N' CHAR 'T' EQUB 0 CHAR 'D' ; Token 3: "DONNÉES SUR {selected system name}" TWOK 'O', 'N' ; CHAR 'N' ; Encoded as: "D<159>N<<137>[131]{3}" CHAR '<' TWOK 'E', 'S' RTOK 131 CONT 3 EQUB 0 TWOK 'I', 'N' ; Token 4: "INVENTAIRE{cr} CHAR 'V' ; " TWOK 'E', 'N' ; CHAR 'T' ; Encoded as: "<140>V<146>TAI<142>{12}" CHAR 'A' CHAR 'I' TWOK 'R', 'E' CONT 12 EQUB 0 CHAR 'S' ; Token 5: "SYSTÈME" CHAR 'Y' ; RTOK 43 ; Encoded as: "SY[43]=ME" CHAR '=' CHAR 'M' CHAR 'E' EQUB 0 CHAR 'P' ; Token 6: "PRIX" TWOK 'R', 'I' ; CHAR 'X' ; Encoded as: "P<158>X" EQUB 0 CONT 2 ; Token 7: "{current system name} PRIX DU MARCHÉ " CHAR ' ' ; RTOK 6 ; Encoded as: "{2} [6] DU M<138>CH< " CHAR ' ' CHAR 'D' CHAR 'U' CHAR ' ' CHAR 'M' TWOK 'A', 'R' CHAR 'C' CHAR 'H' CHAR '<' CHAR ' ' EQUB 0 TWOK 'I', 'N' ; Token 8: "INDUSTRIELLE" CHAR 'D' ; TWOK 'U', 'S' ; Encoded as: "<140>D<136>T<158>EL<129>" CHAR 'T' TWOK 'R', 'I' CHAR 'E' CHAR 'L' TWOK 'L', 'E' EQUB 0 CHAR 'A' ; Token 9: "AGRICOLE" CHAR 'G' ; TWOK 'R', 'I' ; Encoded as: "AG<158>CO<129>) CHAR 'C' CHAR 'O' TWOK 'L', 'E' EQUB 0 TWOK 'R', 'I' ; Token 10: "RICHE " CHAR 'C' ; CHAR 'H' ; Encoded as: "<158>CHE " CHAR 'E' CHAR ' ' EQUB 0 RTOK 139 ; Token 11: "MOYENNE " CHAR 'N' ; CHAR 'E' ; Encoded as: "[139]NE ) CHAR ' ' EQUB 0 CHAR 'P' ; Token 12: "PAUVRE " CHAR 'A' ; CHAR 'U' ; Encoded as: "PAUV<142> " CHAR 'V' TWOK 'R', 'E' CHAR ' ' EQUB 0 CHAR 'S' ; Token 13: "SURTOUT " CHAR 'U' ; CHAR 'R' ; Encoded as: "SUR[124] " RTOK 124 CHAR ' ' EQUB 0 CHAR 'U' ; Token 14: "UNITE" CHAR 'N' ; CHAR 'I' ; Encoded as: "UNI<156>" TWOK 'T', 'E' EQUB 0 CHAR ' ' ; Token 15: " " EQUB 0 ; ; Encoded as: " " CHAR 'P' ; Token 16: "PLEIN" TWOK 'L', 'E' ; TWOK 'I', 'N' ; Encoded as: "P<129><140>" EQUB 0 TWOK 'A', 'N' ; Token 17: "ANARCHIE" TWOK 'A', 'R' ; CHAR 'C' ; Encoded as: "<155><138>CHIE" CHAR 'H' CHAR 'I' CHAR 'E' EQUB 0 CHAR 'F' ; Token 18: "FÉODAL" CHAR '<' ; CHAR 'O' ; Encoded as: "F<ODAL" CHAR 'D' CHAR 'A' CHAR 'L' EQUB 0 CHAR 'P' ; Token 19: "PLURI-GOUVER." CHAR 'L' ; CHAR 'U' ; Encoded as: "PLU<158>-GOUV<144>." TWOK 'R', 'I' CHAR '-' CHAR 'G' CHAR 'O' CHAR 'U' CHAR 'V' TWOK 'E', 'R' CHAR '.' EQUB 0 TWOK 'D', 'I' ; Token 20: "DICTATURE" CHAR 'C' ; CHAR 'T' ; Encoded as: "<141>CT<145>U<142>" TWOK 'A', 'T' CHAR 'U' TWOK 'R', 'E' EQUB 0 RTOK 91 ; Token 21: "COMMUNISTE" CHAR 'M' ; CHAR 'U' ; Encoded as: "[91]MUN<157><156>" CHAR 'N' TWOK 'I', 'S' TWOK 'T', 'E' EQUB 0 CHAR 'C' ; Token 22: "CONFÉDÉRATION" TWOK 'O', 'N' ; CHAR 'F' ; Encoded as: "C<159>F<D<R<145>I<159>" CHAR '<' CHAR 'D' CHAR '<' CHAR 'R' TWOK 'A', 'T' CHAR 'I' TWOK 'O', 'N' EQUB 0 CHAR 'D' ; Token 23: "DÉMOCRATIE" CHAR '<' ; CHAR 'M' ; Encoded as: "D<MOCR<145>IE" CHAR 'O' CHAR 'C' CHAR 'R' TWOK 'A', 'T' CHAR 'I' CHAR 'E' EQUB 0 CHAR '<' ; Token 24: "ÉTAT CORPORATISTE" CHAR 'T' ; TWOK 'A', 'T' ; Encoded as: "<T<145> C<153>P<153><145><157><156>" CHAR ' ' CHAR 'C' TWOK 'O', 'R' CHAR 'P' TWOK 'O', 'R' TWOK 'A', 'T' TWOK 'I', 'S' TWOK 'T', 'E' EQUB 0 CHAR 'N' ; Token 25: "NAVIRE" CHAR 'A' ; CHAR 'V' ; Encoded as: "NAVI<142>" CHAR 'I' TWOK 'R', 'E' EQUB 0 CHAR 'P' ; Token 26: "PRODUIT" CHAR 'R' ; CHAR 'O' ; Encoded as: "PRODUIT" CHAR 'D' CHAR 'U' CHAR 'I' CHAR 'T' EQUB 0 TWOK 'L', 'A' ; Token 27: "LASER" CHAR 'S' ; TWOK 'E', 'R' ; Encoded as: "<149>S<144>" EQUB 0 CHAR 'H' ; Token 28: "HUMAINS COLONIAUX" CHAR 'U' ; TWOK 'M', 'A' ; Encoded as: "HU<139><140>S COL<159>IAUX" TWOK 'I', 'N' CHAR 'S' CHAR ' ' CHAR 'C' CHAR 'O' CHAR 'L' TWOK 'O', 'N' CHAR 'I' CHAR 'A' CHAR 'U' CHAR 'X' EQUB 0 RTOK 116 ; Token 29: "INTERGALACTIQUE " CHAR ' ' ; EQUB 0 ; Encoded as: "[116] " CHAR 'C' ; Token 30: "CARTE LOCALE" TWOK 'A', 'R' ; TWOK 'T', 'E' ; Encoded as: "C<138><156> LOCA<129>" CHAR ' ' CHAR 'L' CHAR 'O' CHAR 'C' CHAR 'A' TWOK 'L', 'E' EQUB 0 TWOK 'D', 'I' ; Token 31: "DISTANCE RTOK 43 ; TWOK 'A', 'N' ; Encoded as: "<141>[43]<155><133>" TWOK 'C', 'E' EQUB 0 CHAR 'P' ; Token 32: "POPULATION" CHAR 'O' ; CHAR 'P' ; Encoded as: "POPUL<145>I<159>" CHAR 'U' CHAR 'L' TWOK 'A', 'T' CHAR 'I' TWOK 'O', 'N' EQUB 0 CONT 6 ; Token 33: "{sentence case}C.{sentence case}A." CHAR 'C' ; CHAR '.' ; Encoded as: "{6}C.{6}A." CONT 6 CHAR 'A' CHAR '.' EQUB 0 CHAR '<' ; Token 34: "ÉCONOMIE" CHAR 'C' ; TWOK 'O', 'N' ; Encoded as: "<C<159>OMIE" CHAR 'O' CHAR 'M' CHAR 'I' CHAR 'E' EQUB 0 CHAR ' ' ; Token 35: " {sentence case}A.{sentence case}LUM." CONT 6 ; CHAR 'A' ; Encoded as: " {6}A.{6}LUM." CHAR '.' CONT 6 CHAR 'L' CHAR 'U' CHAR 'M' CHAR '.' EQUB 0 CHAR 'N' ; Token 36: "NIVEAU TECH." CHAR 'I' ; TWOK 'V', 'E' ; Encoded as: "NI<150>AU <156>CH." CHAR 'A' CHAR 'U' CHAR ' ' TWOK 'T', 'E' CHAR 'C' CHAR 'H' CHAR '.' EQUB 0 TWOK 'A', 'R' ; Token 37: "ARGENT" TWOK 'G', 'E' ; CHAR 'N' ; Encoded as: "<138><131>NT" CHAR 'T' EQUB 0 CHAR ' ' ; Token 38: " BILLION" TWOK 'B', 'I' ; CHAR 'L' ; Encoded as: " <134>LLI<159>" CHAR 'L' CHAR 'I' TWOK 'O', 'N' EQUB 0 CHAR 'C' ; Token 39: "CARTE GALACTIQUE{galaxy number}" TWOK 'A', 'R' ; TWOK 'T', 'E' ; Encoded as: "C<138><156> [122]{1}" CHAR ' ' RTOK 122 CONT 1 EQUB 0 CHAR 'C' ; Token 40: "CIBLE PERDUE " CHAR 'I' ; CHAR 'B' ; Encoded as: "CIB[94]P<144>DUE " RTOK 94 CHAR 'P' TWOK 'E', 'R' CHAR 'D' CHAR 'U' CHAR 'E' CHAR ' ' EQUB 0 RTOK 106 ; Token 41: "MISSILE ENVOYEÉ " CHAR ' ' ; TWOK 'E', 'N' ; Encoded as: "[106] <146>VOYE< " CHAR 'V' CHAR 'O' CHAR 'Y' CHAR 'E' CHAR '<' CHAR ' ' EQUB 0 CHAR 'P' ; Token 42: "PORTÉE" TWOK 'O', 'R' ; CHAR 'T' ; Encoded as: "P<153>T<E" CHAR '<' CHAR 'E' EQUB 0 CHAR 'S' ; Token 43: "ST" CHAR 'T' ; EQUB 0 ; Encoded as: "ST" RTOK 16 ; Token 44: "PLEIN DE " CHAR ' ' ; CHAR 'D' ; Encoded as: "[16] DE " CHAR 'E' CHAR ' ' EQUB 0 CHAR 'S' ; Token 45: "SE" CHAR 'E' ; EQUB 0 ; Encoded as: "SE" CHAR ' ' ; Token 46: " CARGAISON{sentence case}" CHAR 'C' ; TWOK 'A', 'R' ; Encoded as: " C<138>GAI<135>N{6}" CHAR 'G' CHAR 'A' CHAR 'I' TWOK 'S', 'O' CHAR 'N' CONT 6 EQUB 0 CHAR 'E' ; Token 47: "EQUIPEMENT" TWOK 'Q', 'U' ; CHAR 'I' ; Encoded as: "E<154>IPEM<146>T" CHAR 'P' CHAR 'E' CHAR 'M' TWOK 'E', 'N' CHAR 'T' EQUB 0 CHAR 'N' ; Token 48: "NOURRITURE" CHAR 'O' ; CHAR 'U' ; Encoded as: "NOUR<158>TU<142>" CHAR 'R' TWOK 'R', 'I' CHAR 'T' CHAR 'U' TWOK 'R', 'E' EQUB 0 TWOK 'T', 'E' ; Token 49: "TEXTILES" CHAR 'X' ; TWOK 'T', 'I' ; Encoded as: "<156>X<151><129>S" TWOK 'L', 'E' CHAR 'S' EQUB 0 TWOK 'R', 'A' ; Token 50: "RADIOACTIFS" TWOK 'D', 'I' ; CHAR 'O' ; Encoded as: "<148><141>OAC<151>FS" CHAR 'A' CHAR 'C' TWOK 'T', 'I' CHAR 'F' CHAR 'S' EQUB 0 TWOK 'E', 'S' ; Token 51: "ESCLAVE-ROBT" CHAR 'C' ; TWOK 'L', 'A' ; Encoded as: "<137>C<149><150>-ROBT" TWOK 'V', 'E' CHAR '-' CHAR 'R' CHAR 'O' CHAR 'B' CHAR 'T' EQUB 0 CHAR 'B' ; Token 52: "BOISSONS" CHAR 'O' ; TWOK 'I', 'S' ; Encoded as: "BO<157><135>NS" TWOK 'S', 'O' CHAR 'N' CHAR 'S' EQUB 0 CHAR 'P' ; Token 53: "PDTS DE LUXE" CHAR 'D' ; CHAR 'T' ; Encoded as: "PDTS DE LU<130>" CHAR 'S' CHAR ' ' CHAR 'D' CHAR 'E' CHAR ' ' CHAR 'L' CHAR 'U' TWOK 'X', 'E' EQUB 0 TWOK 'E', 'S' ; Token 54: "ESPÈCE RARE" CHAR 'P' ; CHAR '=' ; Encoded as: "<137>P=<133> R<138>E" TWOK 'C', 'E' CHAR ' ' CHAR 'R' TWOK 'A', 'R' CHAR 'E' EQUB 0 TWOK 'O', 'R' ; Token 55: "ORDINATEUR" CHAR 'D' ; TWOK 'I', 'N' ; Encoded as: "<153>D<140><145>EUR" TWOK 'A', 'T' CHAR 'E' CHAR 'U' CHAR 'R' EQUB 0 TWOK 'M', 'A' ; Token 56: "MACHINES" CHAR 'C' ; CHAR 'H' ; Encoded as: "<139>CH<140><137>" TWOK 'I', 'N' TWOK 'E', 'S' EQUB 0 CHAR 'A' ; Token 57: "ALLIAGES" CHAR 'L' ; CHAR 'L' ; Encoded as: "ALLIA<131>S" CHAR 'I' CHAR 'A' TWOK 'G', 'E' CHAR 'S' EQUB 0 TWOK 'A', 'R' ; Token 58: "ARMES" CHAR 'M' ; TWOK 'E', 'S' ; Encoded as: "<138>M<137>" EQUB 0 CHAR 'F' ; Token 59: "FOURRURES" CHAR 'O' ; CHAR 'U' ; Encoded as: "FOURRUR<137>" CHAR 'R' CHAR 'R' CHAR 'U' CHAR 'R' TWOK 'E', 'S' EQUB 0 CHAR 'M' ; Token 60: "MINÉRAUX" TWOK 'I', 'N' ; CHAR '<' ; Encoded as: "M<140><<148>UX" TWOK 'R', 'A' CHAR 'U' CHAR 'X' EQUB 0 TWOK 'O', 'R' ; Token 61: "OR" EQUB 0 ; ; Encoded as: "<153>" CHAR 'P' ; Token 62: "PLATINE" CHAR 'L' ; TWOK 'A', 'T' ; Encoded as: "PL<145><140>E" TWOK 'I', 'N' CHAR 'E' EQUB 0 TWOK 'G', 'E' ; Token 63: "GEMMES" CHAR 'M' ; CHAR 'M' ; Encoded as: "<131>MM<137>" TWOK 'E', 'S' EQUB 0 RTOK 127 ; Token 64: "OBJET E.T." CHAR ' ' ; CHAR 'E' ; Encoded as: "[127] E.T." CHAR '.' CHAR 'T' CHAR '.' EQUB 0 EQUB 0 ; Token 65: "" ; ; Encoded as: "" CHAR ' ' ; Token 66: " CR" CHAR 'C' ; CHAR 'R' ; Encoded as: " CR" EQUB 0 CHAR 'L' ; Token 67: "LARGES" TWOK 'A', 'R' ; TWOK 'G', 'E' ; Encoded as: "L<138><131>S" CHAR 'S' EQUB 0 CHAR 'F' ; Token 68: "FÉROCES" CHAR '<' ; CHAR 'R' ; Encoded as: "F<RO<133>S" CHAR 'O' TWOK 'C', 'E' CHAR 'S' EQUB 0 CHAR 'P' ; Token 69: "PETITS" CHAR 'E' ; TWOK 'T', 'I' ; Encoded as: "PE<151>TS" CHAR 'T' CHAR 'S' EQUB 0 CHAR 'V' ; Token 70: "VERTS" TWOK 'E', 'R' ; CHAR 'T' ; Encoded as: "V<144>TS" CHAR 'S' EQUB 0 CHAR 'R' ; Token 71: "ROUGES" CHAR 'O' ; CHAR 'U' ; Encoded as: "ROU<131>S" TWOK 'G', 'E' CHAR 'S' EQUB 0 CHAR 'J' ; Token 72: "JAUNES" CHAR 'A' ; CHAR 'U' ; Encoded as: "JAUN<137>" CHAR 'N' TWOK 'E', 'S' EQUB 0 CHAR 'B' ; Token 73: "BLEUS" TWOK 'L', 'E' ; TWOK 'U', 'S' ; Encoded as: "B<129><136>" EQUB 0 CHAR 'N' ; Token 74: "NOIRS" CHAR 'O' ; CHAR 'I' ; Encoded as: "NOIRS" CHAR 'R' CHAR 'S' EQUB 0 RTOK 136 ; Token 75: "INOFFENSIFS" CHAR 'S' ; EQUB 0 ; Encoded as: "[136]S" CHAR 'V' ; Token 76: "VISQUEUX" TWOK 'I', 'S' ; TWOK 'Q', 'U' ; Encoded as: "V<157><154>EUX" CHAR 'E' CHAR 'U' CHAR 'X' EQUB 0 CHAR 'Y' ; Token 77: "YEUX EXORBITÉS" CHAR 'E' ; CHAR 'U' ; Encoded as: "YEUX EX<153><134>T<S" CHAR 'X' CHAR ' ' CHAR 'E' CHAR 'X' TWOK 'O', 'R' TWOK 'B', 'I' CHAR 'T' CHAR '<' CHAR 'S' EQUB 0 CHAR '"' ; Token 78: "À CORNES" CHAR ' ' ; CHAR 'C' ; Encoded as: "" C<153>N<137>" TWOK 'O', 'R' CHAR 'N' TWOK 'E', 'S' EQUB 0 TWOK 'A', 'N' ; Token 79: "ANGULEUX" CHAR 'G' ; CHAR 'U' ; Encoded as: "<155>GU<129>UX" TWOK 'L', 'E' CHAR 'U' CHAR 'X' EQUB 0 CHAR 'G' ; Token 80: "GRAS" TWOK 'R', 'A' ; CHAR 'S' ; Encoded as: "G<148>S" EQUB 0 CHAR '"' ; Token 81: "À FOURRURE" CHAR ' ' ; CHAR 'F' ; Encoded as: "" FOURRU<142>" CHAR 'O' CHAR 'U' CHAR 'R' CHAR 'R' CHAR 'U' TWOK 'R', 'E' EQUB 0 CHAR 'R' ; Token 82: "RONGEURS" TWOK 'O', 'N' ; TWOK 'G', 'E' ; Encoded as: "R<159><131>URS) CHAR 'U' CHAR 'R' CHAR 'S' EQUB 0 CHAR 'G' ; Token 83: "GRENOUILLES" TWOK 'R', 'E' ; CHAR 'N' ; Encoded as: "G<142>NOUIL<129>S" CHAR 'O' CHAR 'U' CHAR 'I' CHAR 'L' TWOK 'L', 'E' CHAR 'S' EQUB 0 CHAR 'L' ; Token 84: "LÉZARDS" CHAR '<' ; TWOK 'Z', 'A' ; Encoded as: "L<<132>RDS" CHAR 'R' CHAR 'D' CHAR 'S' EQUB 0 CHAR 'H' ; Token 85: "HOMARDS" CHAR 'O' ; CHAR 'M' ; Encoded as: "HOM<138>DS" TWOK 'A', 'R' CHAR 'D' CHAR 'S' EQUB 0 CHAR 'O' ; Token 86: "OISEAUX" TWOK 'I', 'S' ; CHAR 'E' ; Encoded as: "O<157>EAUX" CHAR 'A' CHAR 'U' CHAR 'X' EQUB 0 CHAR 'H' ; Token 87: "HUMANOIDES" CHAR 'U' ; TWOK 'M', 'A' ; Encoded as: "HU<139>NOID<137>" CHAR 'N' CHAR 'O' CHAR 'I' CHAR 'D' TWOK 'E', 'S' EQUB 0 CHAR 'F' ; Token 88: "FÉLINS" CHAR '<' ; CHAR 'L' ; Encoded as: "F<L<140>S" TWOK 'I', 'N' CHAR 'S' EQUB 0 TWOK 'I', 'N' ; Token 89: "INSECTES" RTOK 45 ; CHAR 'C' ; Encoded as: "<140>[45]CT<137>" CHAR 'T' TWOK 'E', 'S' EQUB 0 TWOK 'R', 'A' ; Token 90: "RAYON" CHAR 'Y' ; TWOK 'O', 'N' ; Encoded as: "<148>Y<159>" EQUB 0 CHAR 'C' ; Token 91: "COM" CHAR 'O' ; CHAR 'M' ; Encoded as: "COM" EQUB 0 RTOK 91 ; Token 92: "COMMANDANT" TWOK 'M', 'A' ; CHAR 'N' ; Encoded as: "[91]<139>ND<155>T" CHAR 'D' TWOK 'A', 'N' CHAR 'T' EQUB 0 CHAR ' ' ; Token 93: " DÉTRUIT" CHAR 'D' ; CHAR '<' ; Encoded as: " DÉTRUIT" CHAR 'T' CHAR 'R' CHAR 'U' CHAR 'I' CHAR 'T' EQUB 0 TWOK 'L', 'E' ; Token 94: "LE " CHAR ' ' ; EQUB 0 ; Encoded as: "LE " RTOK 26 ; Token 95: "PRODUIT QTÉ PRIX UNITAIRE" CHAR ' ' ; CHAR ' ' ; Encoded as: "[26] QT< [6] UNITAI<142>" CHAR ' ' CHAR ' ' CHAR ' ' CHAR 'Q' CHAR 'T' CHAR '<' CHAR ' ' RTOK 6 CHAR ' ' CHAR 'U' CHAR 'N' CHAR 'I' CHAR 'T' CHAR 'A' CHAR 'I' TWOK 'R', 'E' EQUB 0 CHAR 'A' ; Token 96: "AVANT" CHAR 'V' ; TWOK 'A', 'N' ; Encoded as: "AV<155>T" CHAR 'T' EQUB 0 TWOK 'A', 'R' ; Token 97: "ARRIÈRE" TWOK 'R', 'I' ; CHAR '=' ; Encoded as: "<138><158>=<142>" TWOK 'R', 'E' EQUB 0 CHAR 'G' ; Token 98: "GAUCHE" CHAR 'A' ; CHAR 'U' ; Encoded as: "GAUCHE" CHAR 'C' CHAR 'H' CHAR 'E' EQUB 0 CHAR 'D' ; Token 99: "DROITE" CHAR 'R' ; CHAR 'O' ; Encoded as: "DROI<156>" CHAR 'I' TWOK 'T', 'E' EQUB 0 RTOK 121 ; Token 100: "ÉNERGIEFAIBLE{beep}" RTOK 138 ; CONT 7 ; Encoded as: "[121][138]{7}" EQUB 0 CHAR 'B' ; Token 101: "BRAVO COMMANDANT!" TWOK 'R', 'A' ; CHAR 'V' ; Encoded as: "B<148>VO [92]!" CHAR 'O' CHAR ' ' RTOK 92 CHAR '!' EQUB 0 TWOK 'E', 'N' ; Token 102: "EN PLUS " CHAR ' ' ; CHAR 'P' ; Encoded as: "<146> PL<136> " CHAR 'L' TWOK 'U', 'S' CHAR ' ' EQUB 0 CHAR 'C' ; Token 103: "CANNON LASER" TWOK 'A', 'N' ; CHAR 'N' ; Encoded as: "C<155>N<159> [27]" TWOK 'O', 'N' CHAR ' ' RTOK 27 EQUB 0 RTOK 90 ; Token 104: "RAYON LASER" CHAR ' ' ; RTOK 27 ; Encoded as: "[90] [27]" EQUB 0 RTOK 94 ; Token 105: "LE FUEL" CHAR 'F' ; CHAR 'U' ; Encoded as: "[94]FUEL" CHAR 'E' CHAR 'L' EQUB 0 CHAR 'M' ; Token 106: "MISSILE" TWOK 'I', 'S' ; CHAR 'S' ; Encoded as: "M<157>SI<129>" CHAR 'I' TWOK 'L', 'E' EQUB 0 CHAR 'G' ; Token 107: "GRANDE SOUTE" TWOK 'R', 'A' ; CHAR 'N' ; Encoded as: "G<148>NDE <135>U<156>" CHAR 'D' CHAR 'E' CHAR ' ' TWOK 'S', 'O' CHAR 'U' TWOK 'T', 'E' EQUB 0 RTOK 5 ; Token 108: "SYSTÈME E.C.M." CHAR ' ' ; CHAR 'E' ; Encoded as: "[5] E.C.M." CHAR '.' CHAR 'C' CHAR '.' CHAR 'M' CHAR '.' EQUB 0 CHAR 'C' ; Token 109: "CANON LASER" TWOK 'A', 'N' ; TWOK 'O', 'N' ; Encoded as: "C<155><159> [27]" CHAR ' ' RTOK 27 EQUB 0 RTOK 104 ; Token 110: "RAYON LASER" EQUB 0 ; ; Encoded as: "[104]" CHAR 'R' ; Token 111: "RÉCOLTEUR DE FUEL" CHAR '<' ; CHAR 'C' ; Encoded as: "R<COL<156>UR DE FUEL" CHAR 'O' CHAR 'L' TWOK 'T', 'E' CHAR 'U' CHAR 'R' CHAR ' ' CHAR 'D' CHAR 'E' CHAR ' ' CHAR 'F' CHAR 'U' CHAR 'E' CHAR 'L' EQUB 0 CHAR 'C' ; Token 112: "CAPSULE DE SAUVETAGE" CHAR 'A' ; CHAR 'P' ; Encoded as: "CAPSU[94]DE SAU<150>TA<131>" CHAR 'S' CHAR 'U' RTOK 94 CHAR 'D' CHAR 'E' CHAR ' ' CHAR 'S' CHAR 'A' CHAR 'U' TWOK 'V', 'E' CHAR 'T' CHAR 'A' TWOK 'G', 'E' EQUB 0 CHAR 'B' ; Token 113: "BOMBE D'ÉNERGIE" CHAR 'O' ; CHAR 'M' ; Encoded as: "BOM<147> D'<N<144>GIE" TWOK 'B', 'E' CHAR ' ' CHAR 'D' CHAR '`' CHAR '<' CHAR 'N' TWOK 'E', 'R' CHAR 'G' CHAR 'I' CHAR 'E' EQUB 0 CHAR 'U' ; Token 114: "UNITÉ D'ÉNERGIE" CHAR 'N' ; CHAR 'I' ; Encoded as: "UNIT< D'<N<144>GIE" CHAR 'T' CHAR '<' CHAR ' ' CHAR 'D' CHAR '`' CHAR '<' CHAR 'N' TWOK 'E', 'R' CHAR 'G' CHAR 'I' CHAR 'E' EQUB 0 TWOK 'O', 'R' ; Token 115: "ORD. D'ARRIMAGE" CHAR 'D' ; CHAR '.' ; Encoded as: "<153>D. D'<138><158><139><131>" CHAR ' ' CHAR 'D' CHAR '`' TWOK 'A', 'R' TWOK 'R', 'I' TWOK 'M', 'A' TWOK 'G', 'E' EQUB 0 TWOK 'I', 'N' ; Token 116: "INTERGALACTIQUE" CHAR 'T' ; TWOK 'E', 'R' ; Encoded as: "<140>T<144>[122]" RTOK 122 EQUB 0 RTOK 27 ; Token 117: "LASER MILITAIRE" CHAR ' ' ; CHAR 'M' ; Encoded as: "[27] MILITAI<142>" CHAR 'I' CHAR 'L' CHAR 'I' CHAR 'T' CHAR 'A' CHAR 'I' TWOK 'R', 'E' EQUB 0 RTOK 27 ; Token 118: "LASER {sentence case}MINEUR" CHAR ' ' ; CONT 6 ; Encoded as: "[27] {6}M<140>EUR" CHAR 'M' TWOK 'I', 'N' CHAR 'E' CHAR 'U' CHAR 'R' EQUB 0 RTOK 37 ; Token 119: "ARGENT:{cash} CR{cr}) CHAR ':' ; CONT 0 ; Encoded as: "[37]:{0}" EQUB 0 RTOK 106 ; Token 120: "MISSILE EN VUE" CHAR ' ' ; TWOK 'E', 'N' ; Encoded as: "[106] <146> VUE" CHAR ' ' CHAR 'V' CHAR 'U' CHAR 'E' EQUB 0 CHAR '<' ; Token 121: "ÉNERGIE " CHAR 'N' ; TWOK 'E', 'R' ; Encoded as: "<N<144>GIE " CHAR 'G' CHAR 'I' CHAR 'E' CHAR ' ' EQUB 0 CHAR 'G' ; Token 122: "GALACTIQUE" CHAR 'A' ; TWOK 'L', 'A' ; Encoded as: "GA<149>C<151><154>E" CHAR 'C' TWOK 'T', 'I' TWOK 'Q', 'U' CHAR 'E' EQUB 0 RTOK 115 ; Token 123: "ORD. D'ARRIMAGE EN MARCHE" CHAR ' ' ; TWOK 'E', 'N' ; Encoded as: "[115] <146> M<138>CHE" CHAR ' ' CHAR 'M' TWOK 'A', 'R' CHAR 'C' CHAR 'H' CHAR 'E' EQUB 0 CHAR 'T' ; Token 124: "TOUT" CHAR 'O' ; CHAR 'U' ; Encoded as: "TOUT" CHAR 'T' EQUB 0 RTOK 43 ; Token 125: "STATUT LÉGAL:" TWOK 'A', 'T' ; CHAR 'U' ; Encoded as: "[43]<145>UT L<GAL:" CHAR 'T' CHAR ' ' CHAR 'L' CHAR '<' CHAR 'G' CHAR 'A' CHAR 'L' CHAR ':' EQUB 0 RTOK 92 ; Token 126: "COMMANDANT {commander name}{cr} CHAR ' ' ; {cr} CONT 4 ; {cr} CONT 12 ; {sentence case}SYSTÈME ACTUEL{tab CONT 12 ; to column 22}:{current system name}{cr} CONT 12 ; SYSTÈME INTERGALACT{tab to column 22}: CONT 6 ; {selected system name}{cr}CONDITION{tab RTOK 5 ; to column 22}:" CHAR ' ' ; CHAR 'A' ; Encoded as: "[92] {4}{12}{12}{12}{6}[5] ACTUEL{9}{2} CHAR 'C' ; {12}[5] <140>T<144>GA<149>CT{9}{3}{12}C CHAR 'T' ; <159><141><151><159>{9}" CHAR 'U' CHAR 'E' CHAR 'L' CONT 9 CONT 2 CONT 12 RTOK 5 CHAR ' ' TWOK 'I', 'N' CHAR 'T' TWOK 'E', 'R' CHAR 'G' CHAR 'A' TWOK 'L', 'A' CHAR 'C' CHAR 'T' CONT 9 CONT 3 CONT 12 CHAR 'C' TWOK 'O', 'N' TWOK 'D', 'I' TWOK 'T', 'I' TWOK 'O', 'N' CONT 9 EQUB 0 CHAR 'O' ; Token 127: "OBJET" CHAR 'B' ; CHAR 'J' ; Encoded as: "OBJET" CHAR 'E' CHAR 'T' EQUB 0 EQUB 0 ; Token 128: "" ; ; Encoded as: "" CHAR '"' ; Token 129: "À " CHAR ' ' ; EQUB 0 ; Encoded as: "" " CHAR '<' ; Token 130: "ÉVALUATION" CHAR 'V' ; CHAR 'A' ; Encoded as: "<VALU<145>I<159>" CHAR 'L' CHAR 'U' TWOK 'A', 'T' CHAR 'I' TWOK 'O', 'N' EQUB 0 CHAR ' ' ; Token 131: " SUR " CHAR 'S' ; CHAR 'U' ; Encoded as: " SUR " CHAR 'R' CHAR ' ' EQUB 0 CONT 12 ; Token 132: "{cr}ÉQUIPEMENT:" CHAR '<' ; TWOK 'Q', 'U' ; Encoded as: "{12}<<154>IPEM<146>T:" CHAR 'I' CHAR 'P' CHAR 'E' CHAR 'M' TWOK 'E', 'N' CHAR 'T' CHAR ':' EQUB 0 CHAR 'P' ; Token 133: "PROPRE" CHAR 'R' ; CHAR 'O' ; Encoded as: "PROP<142>" CHAR 'P' TWOK 'R', 'E' EQUB 0 CHAR 'D' ; Token 134: "DÉLINQUANT" CHAR '<' ; CHAR 'L' ; Encoded as: "D<L<140><154><155>T" TWOK 'I', 'N' TWOK 'Q', 'U' TWOK 'A', 'N' CHAR 'T' EQUB 0 CHAR 'F' ; Token 135: "FUGITIF" CHAR 'U' ; CHAR 'G' ; Encoded as: "FUGI<151>F" CHAR 'I' TWOK 'T', 'I' CHAR 'F' EQUB 0 TWOK 'I', 'N' ; Token 136: "INOFFENSIF" CHAR 'O' ; CHAR 'F' ; Encoded as: "<140>OFF<146>SIF" CHAR 'F' TWOK 'E', 'N' CHAR 'S' CHAR 'I' CHAR 'F' EQUB 0 TWOK 'Q', 'U' ; Token 137: "QUASI INOFFENSIF" CHAR 'A' ; CHAR 'S' ; Encoded as: "<154>ASI [136]" CHAR 'I' CHAR ' ' RTOK 136 EQUB 0 CHAR 'F' ; Token 138: "FAIBLE" CHAR 'A' ; CHAR 'I' ; Encoded as: "FAIB<129>" CHAR 'B' TWOK 'L', 'E' EQUB 0 CHAR 'M' ; Token 139: "MOYEN" CHAR 'O' ; CHAR 'Y' ; Encoded as: "MOY<146>" TWOK 'E', 'N' EQUB 0 TWOK 'I', 'N' ; Token 140: "INTERMÉDIAIRE" CHAR 'T' ; TWOK 'E', 'R' ; Encoded as: "<140>T<144>M<<141>AI<142>" CHAR 'M' CHAR '<' TWOK 'D', 'I' CHAR 'A' CHAR 'I' TWOK 'R', 'E' EQUB 0 RTOK 91 ; Token 141: "COMPÉTENT" CHAR 'P' ; CHAR '<' ; Encoded as: "[91]P<T<146>T" CHAR 'T' TWOK 'E', 'N' CHAR 'T' EQUB 0 CHAR 'D' ; Token 142: "DANGEREUX" TWOK 'A', 'N' ; TWOK 'G', 'E' ; Encoded as: "D<155><131><142>UX" TWOK 'R', 'E' CHAR 'U' CHAR 'X' EQUB 0 CHAR 'M' ; Token 143: "MORTELLEMENT" TWOK 'O', 'R' ; TWOK 'T', 'E' ; Encoded as: "M<153><156>L<129>M<146>T" CHAR 'L' TWOK 'L', 'E' CHAR 'M' TWOK 'E', 'N' CHAR 'T' EQUB 0 CHAR '-' ; Token 144: "--- E L I T E ---" CHAR '-' ; CHAR '-' ; Encoded as: "--- E L I T E ---" CHAR ' ' CHAR 'E' CHAR ' ' CHAR 'L' CHAR ' ' CHAR 'I' CHAR ' ' CHAR 'T' CHAR ' ' CHAR 'E' CHAR ' ' CHAR '-' CHAR '-' CHAR '-' EQUB 0 CHAR 'P' ; Token 145: "PRÉSENT" CHAR 'R' ; CHAR '<' ; Encoded as: "PR<S<146>T" CHAR 'S' TWOK 'E', 'N' CHAR 'T' EQUB 0 CONT 8 ; Token 146: "{all caps}JEU TERMINÉ" CHAR 'J' ; CHAR 'E' ; Encoded as: "{8}JEU T<144>M<140><" CHAR 'U' CHAR ' ' CHAR 'T' TWOK 'E', 'R' CHAR 'M' TWOK 'I', 'N' CHAR '<' EQUB 0 CHAR 'P' ; Token 147: "PÉNALITÉ DE 60 SEC" CHAR '<' ; CHAR 'N' ; Encoded as: "P<NALIT< DE 60 [45]C" CHAR 'A' CHAR 'L' CHAR 'I' CHAR 'T' CHAR '<' CHAR ' ' CHAR 'D' CHAR 'E' CHAR ' ' CHAR '6' CHAR '0' CHAR ' ' RTOK 45 CHAR 'C' EQUB 0 EQUB 0 ; Token 148: "" ; ; Encoded as: "" EQUB $00, $00, $00 ; These bytes appear to be unused EQUB $00, $00, $00 EQUB $00
Name: rutokLo [Show more] Type: Variable Category: Text Summary: Address lookup table for the RUTOK text token table in three different languages (low byte) Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * DETOK3 uses rutokLo
.rutokLo EQUB LO(RUTOK) ; English EQUB LO(RUTOK_DE) ; German EQUB LO(RUTOK_FR) ; French EQUB $72 ; There is no fourth language, so this byte is ignored
Name: rutokHi [Show more] Type: Variable Category: Text Summary: Address lookup table for the RUTOK text token table in three different languages (high byte) Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * DETOK3 uses rutokHi
.rutokHi EQUB HI(RUTOK) ; English EQUB HI(RUTOK_DE) ; German EQUB HI(RUTOK_FR) ; French EQUB $AB ; There is no fourth language, so this byte is ignored
Name: DETOK3 [Show more] Type: Subroutine Category: Text Summary: Print an extended recursive token from the RUTOK token table Deep dive: Extended system descriptions Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * PDESC calls DETOK3

Arguments: A The recursive token to be printed, in the range 0-255
Returns: A A is preserved Y Y is preserved V(1 0) V(1 0) is preserved
.DETOK3 PHA ; Store A on the stack, so we can retrieve it later TAX ; Copy the token number from A into X TYA ; Store Y on the stack PHA LDA V ; Store V(1 0) on the stack PHA LDA V+1 PHA LDY languageIndex ; Set Y to the chosen language LDA rutokLo,Y ; Set V(1 0) to the address of the RUTOK table for the STA V ; chosen language LDA rutokHi,Y STA V+1 BNE DTEN ; Call DTEN to print token number X from the RUTOK ; table and restore the values of A, Y and V(1 0) from ; the stack, returning from the subroutine using a tail ; call (this BNE is effectively a JMP as A is never ; zero)
Name: DETOK [Show more] Type: Subroutine Category: Text Summary: Print an extended recursive token from the TKN1 token table Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * BRIS calls DETOK * DETOK2 calls DETOK * DETOK_b2 calls DETOK * PDESC calls DETOK * DETOK3 calls via DTEN

Arguments: A The recursive token to be printed, in the range 1-255
Returns: A A is preserved Y Y is preserved V(1 0) V(1 0) is preserved
Other entry points: DTEN Print recursive token number X from the token table pointed to by (A V), used to print tokens from the RUTOK table via calls to DETOK3
.DETOK TAX ; Copy the token number from A into X SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 TXA ; Copy the token number from X into A PHA ; Store A on the stack, so we can retrieve it later TYA ; Store Y on the stack PHA LDA V ; Store V(1 0) on the stack PHA LDA V+1 PHA LDA TKN1Lo ; Set V(1 0) to the address of the TKN1 table for the STA V ; chosen language LDA TKN1Hi STA V+1 .DTEN LDY #0 ; First, we need to work our way through the table until ; we get to the token that we want to print. Tokens are ; delimited by #VE, and VE EOR VE = 0, so we work our ; way through the table in, counting #VE delimiters ; until we have passed X of them, at which point we jump ; down to DTL2 to do the actual printing. So first, we ; set a counter Y to point to the character offset as we ; scan through the table .DTL1 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA (V),Y ; Load the character at offset Y in the token table, ; which is the next character from the token table EOR #VE ; Tokens are stored in memory having been EOR'd with ; #VE, so we repeat the EOR to get the actual character ; in this token BNE DT1 ; If the result is non-zero, then this is a character ; in a token rather than the delimiter (which is #VE), ; so jump to DT1 DEX ; We have just scanned the end of a token, so decrement ; X, which contains the token number we are looking for BEQ DTL2 ; If X has now reached zero then we have found the token ; we are looking for, so jump down to DTL2 to print it .DT1 INY ; Otherwise this isn't the token we are looking for, so ; increment the character pointer BNE DTL1 ; If Y hasn't just wrapped around to 0, loop back to ; DTL1 to process the next character INC V+1 ; We have just crossed into a new page, so increment ; V+1 so that V points to the start of the new page BNE DTL1 ; Jump back to DTL1 to process the next character (this ; BNE is effectively a JMP as V+1 won't reach zero ; before we reach the end of the token table) .DTL2 INY ; We just detected the delimiter byte before the token ; that we want to print, so increment the character ; pointer to point to the first character of the token, ; rather than the delimiter BNE P%+4 ; If Y hasn't just wrapped around to 0, skip the next ; instruction INC V+1 ; We have just crossed into a new page, so increment ; V+1 so that V points to the start of the new page LDA (V),Y ; Load the character at offset Y in the token table, ; which is the next character from the token we want to ; print EOR #VE ; Tokens are stored in memory having been EOR'd with ; #VE, so we repeat the EOR to get the actual character ; in this token BEQ DTEX ; If the result is zero, then this is the delimiter at ; the end of the token to print (which is #VE), so jump ; to DTEX to return from the subroutine, as we are done ; printing JSR DETOK2 ; Otherwise call DETOK2 to print this part of the token JMP DTL2 ; Jump back to DTL2 to process the next character .DTEX PLA ; Restore V(1 0) from the stack, so it is preserved STA V+1 ; through calls to this routine PLA STA V PLA ; Restore Y from the stack, so it is preserved through TAY ; calls to this routine PLA ; Restore A from the stack, so it is preserved through ; calls to this routine RTS ; Return from the subroutine
Name: DETOK2 [Show more] Type: Subroutine Category: Text Summary: Print an extended text token (1-255) Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * DETOK calls DETOK2 * PDESC calls DETOK2 * DTS_b2 calls via DTS

Arguments: A The token to be printed (1-255)
Returns: A A is preserved Y Y is preserved V(1 0) V(1 0) is preserved
Other entry points: DTS Print a single letter in the correct case
.DETOK2 CMP #32 ; If A < 32 then this is a jump token, so skip to DT3 to BCC DT3 ; process it BIT DTW3 ; If bit 7 of DTW3 is clear, then extended tokens are BPL DT8 ; enabled, so jump to DT8 to process them ; If we get there then this is not a jump token and ; extended tokens are not enabled, so we can call the ; standard text token routine at TT27 to print the token TAX ; Copy the token number from A into X TYA ; Store Y on the stack PHA LDA V ; Store V(1 0) on the stack PHA LDA V+1 PHA TXA ; Copy the token number from X back into A JSR TT27 ; Call TT27 to print the text token JMP DT7 ; Jump to DT7 to restore V(1 0) and Y from the stack and ; return from the subroutine .DT8 ; If we get here then this is not a jump token and ; extended tokens are enabled CMP characterEnd ; If A < characterEnd then this is a printable character BCC DTS ; in the chosen language, so jump down to DTS to print ; it CMP #129 ; If A < 129, so A is in the range 91-128, jump down to BCC DT6 ; DT6 to print a randomised token from the MTIN table CMP #215 ; If A < 215, so A is in the range 129-214, jump to BCS P%+5 ; DETOK as this is a recursive token, returning from the JMP DETOK ; subroutine using a tail call ; If we get here then A >= 215, so this is a two-letter ; token from the extended TKN2/QQ16 table SBC #215 ; Subtract 215 to get a token number in the range 0-12 ; (the C flag is set as we passed through the BCC above, ; so this subtraction is correct) ASL A ; Set A = A * 2, so it can be used as a pointer into the ; two-letter token tables at TKN2 and QQ16 PHA ; Store A on the stack, so we can restore it for the ; second letter below TAX ; Fetch the first letter of the two-letter token from LDA TKN2,X ; TKN2, which is at TKN2 + X JSR DTS ; Call DTS to print it PLA ; Restore A from the stack and transfer it into X TAX LDA TKN2+1,X ; Fetch the second letter of the two-letter token from ; TKN2, which is at TKN2 + X + 1, and fall through into ; DTS to print it CMP #'?' ; If the second letter of the token is a question mark BEQ DTM-1 ; then this is a one-letter token, so just return from ; the subroutine without printing (as DTM-1 contains an ; RTS) .DTS BIT DTW1 ; If bit 7 of DTW1 is clear then DTW1 must be %00000000, BPL DT5 ; so we do not change the character to lower case, so ; jump to DT5 to print the character in upper case BIT DTW6 ; If bit 7 of DTW6 is set, then lower case has been BMI DT10 ; enabled by jump token 13, {lower case}, so jump to ; DT10 to apply the lower case and single cap masks BIT DTW2 ; If bit 7 of DTW2 is set, then we are not currently BMI DT5 ; printing a word, so jump to DT5 so we skip the setting ; of lower case in Sentence Case (which we only want to ; do when we are already printing a word) .DT10 BIT DTW8 ; If bit 7 of DTW8 is clear then DTW8 must be %0000000 BPL DT5 ; (capitalise the next letter), so jump to DT5 to print ; the character in upper case ; If we get here then we know DTW8 is %11111111 (do not ; change case, so we now convert the character to lower ; case STX SC ; Store X in SC so we can retrieve it below TAX ; Convert the character in A into lower case by looking LDA lowerCase,X ; up the lower case ASCII value from the lowerCase table LDX SC ; Restore the value of X that we stored in SC AND DTW8 ; This instruction has no effect, because we know that ; DTW8 is %11111111 ; ; The code is left over from the BBC Micro version, in ; which DTW8 is used as a bitmask to convert a character ; to upper case .DT5 JMP DASC ; Jump to DASC to print the ASCII character in A, ; returning from the routine using a tail call .DT3 ; If we get here then the token number in A is in the ; range 1 to 32, so this is a jump token that should ; call the corresponding address in the jump table at ; JMTB TAX ; Copy the token number from A into X TYA ; Store Y on the stack PHA LDA V ; Store V(1 0) on the stack PHA LDA V+1 PHA TXA ; Copy the token number from X back into A ASL A ; Set A = A * 2, so it can be used as a pointer into the ; jump table at JMTB, though because the original range ; of values is 1-32, so the doubled range is 2-64, we ; need to take the offset into the jump table from ; JMTB-2 rather than JMTB TAX ; Copy the doubled token number from A into X LDA JMTB-2,X ; Set V(1 0) to the X-th address from the table at STA V ; JTM-2, so the JMP (V) instruction at label DTM below LDA JMTB-1,X ; calls the subroutine at the relevant address from the STA V+1 ; JMTB table TXA ; Copy the doubled token number from X back into A LSR A ; Halve A to get the original token number JSR DTM ; Call DTM to call the relevant JMTB subroutine in ; V(1 0) .DT7 PLA ; Restore V(1 0) from the stack, so it is preserved STA V+1 ; through calls to this routine PLA STA V PLA ; Restore Y from the stack, so it is preserved through TAY ; calls to this routine RTS ; Return from the subroutine .DTM JMP (V) ; Call the relevant JMTB subroutine, as V(1 0) points ; to the relevant address .DT6 ; If we get here then the token number in A is in the ; range 91-128, which means we print a randomly picked ; token from the token range given in the corresponding ; entry in the MTIN table STA SC ; Store the token number in SC SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 TYA ; Store Y on the stack PHA LDA V ; Store V(1 0) on the stack PHA LDA V+1 PHA JSR DORND ; Set X to a random number TAX LDA #0 ; Set A to 0, so we can build a random number from 0 to ; 4 in A plus the C flag, with each number being equally ; likely CPX #51 ; Add 1 to A if X >= 51 ADC #0 CPX #102 ; Add 1 to A if X >= 102 ADC #0 CPX #153 ; Add 1 to A if X >= 153 ADC #0 CPX #204 ; Set the C flag if X >= 204 LDX SC ; Fetch the token number from SC into X, so X is now in ; the range 91-128 ADC MTIN-91,X ; Set A = MTIN-91 + token number (91-128) + random (0-4) ; = MTIN + token number (0-37) + random (0-4) JSR DETOK ; Call DETOK to print the extended recursive token in A JMP DT7 ; Jump to DT7 to restore V(1 0) and Y from the stack and ; return from the subroutine using a tail call
Name: JMTB [Show more] Type: Variable Category: Text Summary: The extended token table for jump tokens 1-32 (DETOK) Deep dive: Extended text tokens
Context: See this variable on its own page References: This variable is used as follows: * DETOK2 uses JMTB
.JMTB EQUW MT1 ; Token 1: Switch to ALL CAPS EQUW MT2 ; Token 2: Switch to Sentence Case EQUW TT27 ; Token 3: Print the selected system name EQUW TT27 ; Token 4: Print the commander's name EQUW MT5 ; Token 5: Switch to extended tokens EQUW MT6 ; Token 6: Switch to standard tokens, in Sentence Case EQUW DASC ; Token 7: Beep EQUW MT8 ; Token 8: Tab to column 6 EQUW MT9 ; Token 9: Clear screen, tab to column 1, view type = 1 EQUW DASC ; Token 10: Line feed EQUW NLIN4 ; Token 11: Draw box around title (line at pixel row 19) EQUW DASC ; Token 12: Carriage return EQUW MT13 ; Token 13: Switch to lower case EQUW MT14 ; Token 14: Switch to justified text EQUW MT15 ; Token 15: Switch to left-aligned text EQUW MT16 ; Token 16: Print the character in DTW7 (drive number) EQUW MT17 ; Token 17: Print system name adjective in Sentence Case EQUW MT18 ; Token 18: Randomly print 1 to 4 two-letter tokens EQUW MT19 ; Token 19: Capitalise first letter of next word only EQUW DASC ; Token 20: Unused EQUW CLYNS ; Token 21: Clear the bottom few lines of the space view EQUW PAUSE ; Token 22: Display ship and wait for key press EQUW MT23 ; Token 23: Move to row 10, white text, set lower case EQUW PAUSE2 ; Token 24: Wait for a key press EQUW BRIS ; Token 25: Show incoming message screen, wait 2 seconds EQUW MT26 ; Token 26: Print a space and capitalise the next letter EQUW MT27 ; Token 27: Print mission captain's name (217-219) EQUW MT28 ; Token 28: Print mission 1 location hint (220-221) EQUW MT29 ; Token 29: Column 6, white text, lower case in words EQUW FILEPR ; Token 30: Display currently selected media (disc/tape) EQUW OTHERFILEPR ; Token 31: Display the non-selected media (disc/tape) EQUW DASC ; Token 32: Unused
Name: MTIN [Show more] Type: Variable Category: Text Summary: Lookup table for random tokens in the extended token table (0-37) Deep dive: Extended text tokens
Context: See this variable on its own page References: This variable is used as follows: * DETOK2 uses MTIN

The ERND token type, which is part of the extended token system, takes an argument between 0 and 37, and returns a randomly chosen token in the range specified in this table. This is used to generate the extended description of each system. For example, the entry at position 13 in this table (counting from 0) is 66, so ERND 14 will expand into a random token in the range 66-70, i.e. one of "JUICE", "BRANDY", "WATER", "BREW" and "GARGLE BLASTERS".
.MTIN EQUB 16 ; Token 0: a random extended token between 16 and 20 EQUB 21 ; Token 1: a random extended token between 21 and 25 EQUB 26 ; Token 2: a random extended token between 26 and 30 EQUB 31 ; Token 3: a random extended token between 31 and 35 EQUB 155 ; Token 4: a random extended token between 155 and 159 EQUB 160 ; Token 5: a random extended token between 160 and 164 EQUB 46 ; Token 6: a random extended token between 46 and 50 EQUB 165 ; Token 7: a random extended token between 165 and 169 EQUB 36 ; Token 8: a random extended token between 36 and 40 EQUB 41 ; Token 9: a random extended token between 41 and 45 EQUB 61 ; Token 10: a random extended token between 61 and 65 EQUB 51 ; Token 11: a random extended token between 51 and 55 EQUB 56 ; Token 12: a random extended token between 56 and 60 EQUB 170 ; Token 13: a random extended token between 170 and 174 EQUB 66 ; Token 14: a random extended token between 66 and 70 EQUB 71 ; Token 15: a random extended token between 71 and 75 EQUB 76 ; Token 16: a random extended token between 76 and 80 EQUB 81 ; Token 17: a random extended token between 81 and 85 EQUB 86 ; Token 18: a random extended token between 86 and 90 EQUB 140 ; Token 19: a random extended token between 140 and 144 EQUB 96 ; Token 20: a random extended token between 96 and 100 EQUB 101 ; Token 21: a random extended token between 101 and 105 EQUB 135 ; Token 22: a random extended token between 135 and 139 EQUB 130 ; Token 23: a random extended token between 130 and 134 EQUB 91 ; Token 24: a random extended token between 91 and 95 EQUB 106 ; Token 25: a random extended token between 106 and 110 EQUB 180 ; Token 26: a random extended token between 180 and 184 EQUB 185 ; Token 27: a random extended token between 185 and 189 EQUB 190 ; Token 28: a random extended token between 190 and 194 EQUB 225 ; Token 29: a random extended token between 225 and 229 EQUB 230 ; Token 30: a random extended token between 230 and 234 EQUB 235 ; Token 31: a random extended token between 235 and 239 EQUB 240 ; Token 32: a random extended token between 240 and 244 EQUB 245 ; Token 33: a random extended token between 245 and 249 EQUB 250 ; Token 34: a random extended token between 250 and 254 EQUB 115 ; Token 35: a random extended token between 115 and 119 EQUB 120 ; Token 36: a random extended token between 120 and 124 EQUB 125 ; Token 37: a random extended token between 125 and 129
Name: MT27 [Show more] Type: Subroutine Category: Text Summary: Print the captain's name during mission briefings Deep dive: Extended text tokens The Constrictor mission
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT27

This routine prints the following tokens, depending on the galaxy number: * Token 217 ("CURRUTHERS") in galaxy 0 * Token 218 ("FOSDYKE SMYTHE") in galaxy 1 * Token 219 ("FORTESQUE") in galaxy 2 This is used when printing extended token 213 as part of the mission briefings, which looks like this when printed: Commander {commander name}, I am Captain {mission captain's name} of Her Majesty's Space Navy where {mission captain's name} is replaced by one of the names above.
.MT27 LDA #217 ; Set A = 217, so when we fall through into MT28, the ; 217 gets added to the current galaxy number, so the ; extended token that is printed is 217-219 (as this is ; only called in galaxies 0 through 2) BNE P%+4 ; Skip the next instruction
Name: MT28 [Show more] Type: Subroutine Category: Text Summary: Print the location hint during the mission 1 briefing Deep dive: Extended text tokens The Constrictor mission
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT28

This routine prints the following tokens, depending on the galaxy number: * Token 220 ("WAS LAST SEEN AT {single cap}REESDICE") in galaxy 0 * Token 221 ("IS BELIEVED TO HAVE JUMPED TO THIS GALAXY") in galaxy 1 This is used when printing extended token 10 as part of the mission 1 briefing, which looks like this when printed: It went missing from our ship yard on Xeer five months ago and {mission 1 location hint} where {mission 1 location hint} is replaced by one of the names above.
.MT28 LDA #220 ; Set A = galaxy number in GCNT + 220, which is in the CLC ; range 220-221, as this is only called in galaxies 0 ADC GCNT ; and 1 JMP DETOK_b2 ; Jump to DETOK to print extended token 220-221, ; returning from the subroutine using a tail call (this ; BNE is effectively a JMP as A is never zero)
Name: MT1 [Show more] Type: Subroutine Category: Text Summary: Switch to ALL CAPS when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT1

This routine sets the following: * DTW1 = %00000000 (do not change case to lower case) * DTW6 = %00000000 (lower case is not enabled)
.MT1 LDA #%00000000 ; Set A = %00000000, so when we fall through into MT2, ; both DTW1 and DTW6 get set to %00000000 EQUB $2C ; Skip the next instruction by turning it into ; $2C $A9 $20, or BIT $20A9, which does nothing apart ; from affect the flags
Name: MT2 [Show more] Type: Subroutine Category: Text Summary: Switch to Sentence Case when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT2

This routine sets the following: * DTW1 = %10000000 (apply lower case to the second letter of a word onwards) * DTW6 = %00000000 (lower case is not enabled)
.MT2 LDA #%10000000 ; Set DTW1 = %10000000 STA DTW1 LDA #00000000 ; Set DTW6 = %00000000 STA DTW6 RTS ; Return from the subroutine
Name: MT8 [Show more] Type: Subroutine Category: Text Summary: Tab to column 6 and start a new word when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT8

This routine sets the following: * XC = 6 (tab to column 6) * DTW2 = %11111111 (we are not currently printing a word)
.MT8 LDA #6 ; Move the text cursor to column 6 STA XC LDA #%11111111 ; Set all the bits in DTW2 STA DTW2 RTS ; Return from the subroutine
Name: MT16 [Show more] Type: Subroutine Category: Text Summary: Print the character in variable DTW7 Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT16
.MT16 ; Fall through into FILEPR to return from the ; subroutine, as MT16 does nothing in the NES version
Name: FILEPR [Show more] Type: Subroutine Category: Save and load Summary: Display the currently selected media (disc or tape) Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls FILEPR
.FILEPR ; Fall through into OTHERFILEPR to return from the ; subroutine, as FILEPR does nothing in the NES version
Name: OTHERFILEPR [Show more] Type: Subroutine Category: Save and load Summary: Display the non-selected media (disc or tape) Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls OTHERFILEPR
.OTHERFILEPR RTS ; Return from the subroutine, as OTHERFILEPR does ; nothing in the NES version
Name: MT9 [Show more] Type: Subroutine Category: Text Summary: Clear the screen and set the view type for a text-based mission briefing Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT9

This routine sets the following: * XC = 1 (tab to column 1) before calling TT66 to clear the screen and set the view type to $95.
.MT9 LDA #1 ; Move the text cursor to column 1 STA XC LDA #$95 ; Clear the screen and set the view type in QQ11 to $95 JMP TT66_b0 ; (Text-based mission briefing), returning from the ; subroutine using a tail call
Name: MT6 [Show more] Type: Subroutine Category: Text Summary: Switch to standard tokens in Sentence Case Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT6

This routine sets the following: * QQ17 = %10000000 (set Sentence Case for standard tokens) * DTW3 = %11111111 (print standard tokens)
.MT6 LDA #%10000000 ; Set bit 7 of QQ17 to switch standard tokens to STA QQ17 ; Sentence Case LDA #%11111111 ; Set A = %11111111, so when we fall through into MT5, ; DTW3 gets set to %11111111 and calls to DETOK print ; standard tokens EQUB $2C ; Skip the next instruction by turning it into ; $2C $A9 $00, or BIT $00A9, which does nothing apart ; from affect the flags
Name: MT5 [Show more] Type: Subroutine Category: Text Summary: Switch to extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT5

This routine sets the following: * DTW3 = %00000000 (print extended tokens)
.MT5 LDA #%00000000 ; Set DTW3 = %00000000, so that calls to DETOK print STA DTW3 ; extended tokens RTS ; Return from the subroutine
Name: MT14 [Show more] Type: Subroutine Category: Text Summary: Switch to justified text when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT14 * PDESC calls MT14

This routine sets the following: * DTW4 = %10000000 (justify text, print buffer on carriage return) * DTW5 = 0 (reset line buffer size)
.MT14 LDA #%10000000 ; Set A = %10000000, so when we fall through into MT15, ; DTW4 gets set to %10000000 EQUB $2C ; Skip the next instruction by turning it into ; $2C $A9 $00, or BIT $00A9, which does nothing apart ; from affect the flags
Name: MT15 [Show more] Type: Subroutine Category: Text Summary: Switch to left-aligned text when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT15

This routine sets the following: * DTW4 = %00000000 (do not justify text, print buffer on carriage return) * DTW5 = 0 (reset line buffer size)
.MT15 LDA #0 ; Set DTW4 = %00000000 STA DTW4 ASL A ; Set DTW5 = 0 (even when we fall through from MT14 with STA DTW5 ; A set to %10000000) RTS ; Return from the subroutine
Name: MT17 [Show more] Type: Subroutine Category: Text Summary: Print the selected system's adjective, e.g. Lavian for Lave Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT17

The adjective for the current system is generated by taking the system name, removing the last character if it is a vowel, and adding "-ian" to the end, so: * Lave gives Lavian (as in "Lavian tree grub") * Leesti gives Leestian (as in "Leestian Evil Juice") This routine is called by jump token 17, {system name adjective}, and it can only be used when justified text is being printed - i.e. following jump token 14, {justify} - because the routine needs to use the line buffer to work.
.MT17 LDA QQ17 ; Set QQ17 = %10111111 to switch to Sentence Case AND #%10111111 STA QQ17 LDA #3 ; Print control code 3 (selected system name) into the JSR TT27 ; line buffer LDX DTW5 ; Load the last character of the line buffer BUF into A LDA BUF-1,X ; (as DTW5 contains the buffer size, so character DTW5-1 ; is the last character in the buffer BUF) JSR VOWEL ; Test whether the character is a vowel, in which case ; this will set the C flag BCC MT171 ; If the character is not a vowel, skip the following ; instruction DEC DTW5 ; The character is a vowel, so decrement DTW5, which ; removes the last character from the line buffer (i.e. ; it removes the trailing vowel from the system name) .MT171 LDA #153 ; Print extended token 153 ("IAN"), returning from the JMP DETOK_b2 ; subroutine using a tail call
Name: MT18 [Show more] Type: Subroutine Category: Text Summary: Print a random 1-8 letter word in Sentence Case Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT18
.MT18 JSR MT19 ; Call MT19 to capitalise the next letter (i.e. set ; Sentence Case for this word only) JSR DORND ; Set A and X to random numbers and reduce A to a AND #3 ; random number in the range 0-3 TAY ; Copy the random number into Y, so we can use Y as a ; loop counter to print 1-4 words (i.e. Y+1 words) .MT18L JSR DORND ; Set A and X to random numbers and reduce A to an even AND #62 ; random number in the range 0-62 (as bit 0 of 62 is 0) TAX ; Copy the random number into X, so X contains the table ; offset of a random extended two-letter token from 0-31 ; which we can now use to pick a token from the combined ; tables at TKN2+2 and QQ16 (we intentionally exclude ; the first token in TKN2, which contains a newline) LDA TKN2+2,X ; Print the first letter of the token at TKN2+2 + X JSR DTS_b2 LDA TKN2+3,X ; Fetch the second letter of the token from TKN2+2 + X CMP #'?' ; If the second letter is a question mark, skip the BEQ P%+5 ; following instruction (as ? indicates a single-letter ; token) JSR DTS_b2 ; Print the second letter of the token at TKN2+2 + X DEY ; Decrement the loop counter BPL MT18L ; Loop back to MT18L to print another two-letter token ; until we have printed Y+1 of them RTS ; Return from the subroutine
Name: MT26 [Show more] Type: Subroutine Category: Text Summary: Print a space and capitalise the next letter Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT26
.MT26 LDA #' ' ; Print a space JSR DASC ; Fall through into MT19 to capitalise the next letter
Name: MT19 [Show more] Type: Subroutine Category: Text Summary: Capitalise the next letter Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT19 * MT18 calls MT19

This routine sets the following: * DTW8 = %00000000 (capitalise the next letter)
.MT19 LDA #%00000000 ; Set DTW8 = %00000000 STA DTW8 RTS ; Return from the subroutine
Name: VOWEL [Show more] Type: Subroutine Category: Text Summary: Test whether a character is a vowel
Context: See this subroutine on its own page References: This subroutine is called as follows: * MT17 calls VOWEL

Arguments: A The character to be tested
Returns: C flag The C flag is set if the character is a vowel, otherwise it is clear
.VOWEL ORA #%00100000 ; Set bit 5 of the character to make it lower case CMP #'a' ; If the letter is a vowel, jump to VRTS to return from BEQ VRTS ; the subroutine with the C flag set (as the CMP will CMP #'e' ; set the C flag if the comparison is equal) BEQ VRTS CMP #'i' BEQ VRTS CMP #'o' BEQ VRTS CMP #'u' BEQ VRTS CLC ; The character is not a vowel, so clear the C flag .VRTS RTS ; Return from the subroutine
Name: TKN2 [Show more] Type: Variable Category: Text Summary: The extended two-letter token lookup table Deep dive: Extended text tokens
Context: See this variable on its own page References: This variable is used as follows: * DETOK2 uses TKN2 * MT18 uses TKN2

Two-letter token lookup table for extended tokens 215-227.
.TKN2 EQUB 12, 10 ; Token 215 = {crlf} EQUS "AB" ; Token 216 EQUS "OU" ; Token 217 EQUS "SE" ; Token 218 EQUS "IT" ; Token 219 EQUS "IL" ; Token 220 EQUS "ET" ; Token 221 EQUS "ST" ; Token 222 EQUS "ON" ; Token 223 EQUS "LO" ; Token 224 EQUS "NU" ; Token 225 EQUS "TH" ; Token 226 EQUS "NO" ; Token 227
Name: QQ16 [Show more] Type: Variable Category: Text Summary: The two-letter token lookup table Deep dive: Printing text tokens
Context: See this variable on its own page References: This variable is used as follows: * TT43 uses QQ16

Two-letter token lookup table for tokens 128-159. See the deep dive on "Printing text tokens" for details of how the two-letter token system works.
.QQ16 EQUS "AL" ; Token 128 EQUS "LE" ; Token 129 EQUS "XE" ; Token 130 EQUS "GE" ; Token 131 EQUS "ZA" ; Token 132 EQUS "CE" ; Token 133 EQUS "BI" ; Token 134 EQUS "SO" ; Token 135 EQUS "US" ; Token 136 EQUS "ES" ; Token 137 EQUS "AR" ; Token 138 EQUS "MA" ; Token 139 EQUS "IN" ; Token 140 EQUS "DI" ; Token 141 EQUS "RE" ; Token 142 EQUS "A?" ; Token 143 EQUS "ER" ; Token 144 EQUS "AT" ; Token 145 EQUS "EN" ; Token 146 EQUS "BE" ; Token 147 EQUS "RA" ; Token 148 EQUS "LA" ; Token 149 EQUS "VE" ; Token 150 EQUS "TI" ; Token 151 EQUS "ED" ; Token 152 EQUS "OR" ; Token 153 EQUS "QU" ; Token 154 EQUS "AN" ; Token 155 EQUS "TE" ; Token 156 EQUS "IS" ; Token 157 EQUS "RI" ; Token 158 EQUS "ON" ; Token 159
Name: BRIS [Show more] Type: Subroutine Category: Missions Summary: Clear the screen, display "INCOMING MESSAGE" and wait for 2 seconds
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls BRIS
.BRIS LDA #216 ; Print extended token 216 ("{clear screen}{tab 6}{move JSR DETOK ; to row 10, white, lower case}{white}{all caps}INCOMING ; MESSAGE" JSR UpdateViewWithFade ; Update the view, fading the screen to black first if ; required LDY #100 ; Delay for 100 vertical syncs (100/50 = 2 seconds) and JMP DELAY ; return from the subroutine using a tail call
Name: PAUSE [Show more] Type: Subroutine Category: Missions Summary: Display a rotating ship, waiting until a key is pressed, then remove the ship from the screen
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls PAUSE
.PAUSE JSR DrawScreenInNMI_b0 ; Configure the NMI handler to draw the screen JSR WaitForPPUToFinish ; Wait until both bitplanes of the screen have been ; sent to the PPU, so the screen is fully updated and ; there is no more data waiting to be sent to the PPU LDA firstFreePattern ; Tell the NMI handler to send pattern entries from the STA firstPattern ; first free pattern onwards, so we don't waste time ; resending the static patterns we have already sent LDA #40 ; Tell the NMI handler to only clear nametable entries STA maxNameTileToClear ; up to tile 40 * 8 = 320 (i.e. up to the end of tile ; row 10) LDX #8 ; Tell the NMI handler to send nametable entries from STX firstNameTile ; tile 8 * 8 = 64 onwards (i.e. from the start of tile ; row 2) .paus1 JSR PAS1_b0 ; Call PAS1 to display the rotating ship at space ; coordinates (0, 100, 256) and scan the controllers LDA controller1A ; Loop back to keep displaying the rotating ship until ORA controller1B ; both the A button and B button have been released on BPL paus1 ; controller 1 .paus2 JSR PAS1_b0 ; Call PAS1 to display the rotating ship at space ; coordinates (0, 100, 256) and scan the controllers LDA controller1A ; Loop back to keep displaying the rotating ship until ORA controller1B ; either the A button or B button has been pressed on BMI paus2 ; controller 1 LDA #0 ; Set the ship's AI flag to 0 (no AI) so it doesn't get STA INWK+31 ; any ideas of its own LDA #$93 ; Clear the screen and set the view type in QQ11 to $93 JSR TT66_b0 ; (Mission 1 briefing: ship and text) ; Fall through into MT23 to move to row 10, switch to ; white text, and switch to lower case when printing ; extended tokens
Name: MT23 [Show more] Type: Subroutine Category: Text Summary: Move to row 9 and switch to lower case when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT23
.MT23 LDA #9 ; Set A = 9, so when we fall through into MT29, the ; text cursor gets moved to row 9 EQUB $2C ; Skip the next instruction by turning it into ; $2C $A9 $06, or BIT $06A9, which does nothing apart ; from affect the flags ; Fall through into MT29 to move to the row in A and ; switch to lower case
Name: MT29 [Show more] Type: Subroutine Category: Text Summary: Move to row 7 and switch to lower case when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT29
.MT29 LDA #7 ; Move the text cursor to row 7 STA YC ; Fall through into MT13 to set bit 7 of DTW6 and bit 5 ; of DTW1
Name: MT13 [Show more] Type: Subroutine Category: Text Summary: Switch to lower case when printing extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls MT13

This routine sets the following: * DTW1 = %10000000 (apply lower case to the second letter of a word onwards) * DTW6 = %10000000 (lower case is enabled)
.MT13 LDA #%10000000 ; Set DTW1 = %10000000 STA DTW1 STA DTW6 ; Set DTW6 = %10000000 RTS ; Return from the subroutine
Name: PAUSE2 [Show more] Type: Subroutine Category: Controllers Summary: Wait until a key is pressed, ignoring any existing key press
Context: See this subroutine on its own page References: This subroutine is called as follows: * JMTB calls PAUSE2
.PAUSE2 JSR DrawScreenInNMI_b0 ; Configure the NMI handler to draw the screen .paws1 JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA controller1A ; Keep looping back to paws1 until either the A button ORA controller1B ; or the B button has been pressed and then released on AND #%11000000 ; controller 1 CMP #%01000000 BNE paws1 RTS ; Return from the subroutine
Name: ruplaLo [Show more] Type: Variable Category: Text Summary: Address lookup table for the RUPLA text token table in three different languages (low byte) Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * PDESC uses ruplaLo
.ruplaLo EQUB LO(RUPLA - 1) ; English EQUB LO(RUPLA_DE - 1) ; German EQUB LO(RUPLA_FR - 1) ; French EQUB $43 ; There is no fourth language, so this byte is ignored
Name: ruplaHi [Show more] Type: Variable Category: Text Summary: Address lookup table for the RUPLA text token table in three different languages (high byte) Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * PDESC uses ruplaHi
.ruplaHi EQUB HI(RUPLA - 1) ; English EQUB HI(RUPLA_DE - 1) ; German EQUB HI(RUPLA_FR - 1) ; French EQUB $AB ; There is no fourth language, so this byte is ignored
Name: rugalLo [Show more] Type: Variable Category: Text Summary: Address lookup table for the RUGAL text token table in three different languages (low byte) Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * PDESC uses rugalLo
.rugalLo EQUB LO(RUGAL - 1) ; English EQUB LO(RUGAL_DE - 1) ; German EQUB LO(RUGAL_FR - 1) ; French EQUB $5A ; There is no fourth language, so this byte is ignored
Name: rugalHi [Show more] Type: Variable Category: Text Summary: Address lookup table for the RUGAL text token table in three different languages (high byte) Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * PDESC uses rugalHi
.rugalHi EQUB HI(RUGAL - 1) ; English EQUB HI(RUGAL_DE - 1) ; German EQUB HI(RUGAL_FR - 1) ; French EQUB $AB ; There is no fourth language, so this byte is ignored
Name: NRU [Show more] Type: Variable Category: Text Summary: The number of planetary systems with extended system description overrides in the RUTOK table (NRU%) in three different languages Deep dive: Multi-language support in NES Elite
Context: See this variable on its own page References: This variable is used as follows: * PDESC uses NRU
.NRU EQUB 23 ; English EQUB 23 ; German EQUB 23 ; French EQUB 23 ; There is no fourth language, so this byte is ignored
Name: PDESC [Show more] Type: Subroutine Category: Universe Summary: Print the system's extended description or a mission 1 directive Deep dive: Extended system descriptions Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * PDESC_b2 calls PDESC

This prints a specific system's extended description. This is called the "pink volcanoes string" in a comment in the original source, and the "goat soup" recipe by Ian Bell on his website (where he also refers to the species string as the "pink felines" string). For some special systems, when you are docked at them, the procedurally generated extended description is overridden and a text token from the RUTOK table is shown instead. If mission 1 is in progress, then a number of systems along the route of that mission's story will show custom mission-related directives in place of that system's normal "goat soup" phrase.
Arguments: systemNumber The system number (0-255)
.PDESC LDA QQ8 ; If either byte in QQ18(1 0) is non-zero, meaning that ORA QQ8+1 ; the distance from the current system to the selected BNE PD1 ; is non-zero, jump to PD1 to show the standard "goat ; soup" description LDA QQ12 ; If QQ12 does not have bit 7 set, which means we are BPL PD1 ; not docked, jump to PD1 to show the standard "goat ; soup" description LDX languageIndex ; Set X to the index of the chosen language LDA ruplaLo,X ; Set SC(1 0) to the address of the RUPLA table for the STA SC ; chosen language, minus 1 (i.e. RUPLA-1, RUPLA_DE-1 LDA ruplaHi,X ; or RUPLA_FR-1) STA SC+1 LDA rugalLo,X ; Set SC2(1 0) to the address of the RUGAL table for the STA SC2 ; chosen language, minus 1 (i.e. RUGAL-1, RUGAL_DE-1 LDA rugalHi,X ; or RUGAL_FR-1) STA SC2+1 LDY NRU,X ; Set Y as a loop counter as we work our way through the ; system numbers in RUPLA, starting at the value of NRU ; for the chosen language (which is the number of ; entries in RUPLA) and working our way down to 1 .PDL1 LDA (SC),Y ; Fetch the Y-th byte from RUPLA-1 into A (we use ; RUPLA-1 because Y is looping from NRU to 1) CMP systemNumber ; If A doesn't match the system whose description we BNE PD2 ; are printing (in systemNumber), jump to PD2 to keep ; looping through the system numbers in RUPLA ; If we get here we have found a match for this system ; number in RUPLA LDA (SC2),Y ; Fetch the Y-th byte from RUGAL-1 into A AND #%01111111 ; Extract bits 0-6 of A CMP GCNT ; If the result does not equal the current galaxy BNE PD2 ; number, jump to PD2 to keep looping through the system ; numbers in RUPLA LDA (SC2),Y ; Fetch the Y-th byte from RUGAL-1 into A, once again BMI PD3 ; If bit 7 is set, jump to PD3 to print the extended ; token in A from the second table in RUTOK LDA TP ; Fetch bit 0 of TP into the C flag, and skip to PD1 if LSR A ; it is clear (i.e. if mission 1 is not in progress) to BCC PD1 ; print the "goat soup" extended description ; If we get here then mission 1 is in progress, so we ; print out the corresponding token from RUTOK JSR MT14 ; Call MT14 to switch to justified text LDA #1 ; Set A = 1 so that extended token 1 (an empty string) ; gets printed below instead of token 176, followed by ; the Y-th token in RUTOK EQUB $2C ; Skip the next instruction by turning it into ; $2C $A9 $B0, or BIT $B0A9, which does nothing apart ; from affect the flags .PD3 LDA #176 ; Print extended token 176 ("{lower case}{justify} JSR DETOK2 ; {single cap}") TYA ; Print the extended token in Y from the second table JSR DETOK3 ; in RUTOK LDA #177 ; Set A = 177 so when we jump to PD4 in the next ; instruction, we print token 177 (".{cr}{left align}") BNE PD4 ; Jump to PD4 to print the extended token in A and ; return from the subroutine using a tail call .PD2 DEY ; Decrement the byte counter in Y BNE PDL1 ; Loop back to check the next byte in RUPLA until we ; either find a match for the system in ZZ, or we fall ; through into the "goat soup" extended description ; routine .PD1 ; We now print the "goat soup" extended description LDX #3 ; We now want to seed the random number generator with ; the s1 and s2 16-bit seeds from the current system, so ; we get the same extended description for each system ; every time we call PDESC, so set a counter in X for ; copying 4 bytes { .PDL1 ; This label is a duplicate of the label above (which is ; why we need to surround it with braces, as BeebAsm ; doesn't allow us to redefine labels, unlike BBC BASIC) LDA QQ15+2,X ; Copy QQ15+2 to QQ15+5 (s1 and s2) to RAND to RAND+3 STA RAND,X DEX ; Decrement the loop counter BPL PDL1 ; Loop back to PDL1 until we have copied all LDA #5 ; Set A = 5, so we print extended token 5 in the next ; instruction ("{lower case}{justify}{single cap}[86-90] ; IS [140-144].{cr}{left align}" } .PD4 JMP DETOK ; Print the extended token given in A, and return from ; the subroutine using a tail call
Name: TT27 [Show more] Type: Subroutine Category: Text Summary: Print a text token Deep dive: Printing text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * DETOK2 calls TT27 * ex calls TT27 * JMTB calls TT27 * MT17 calls TT27 * TT27_b2 calls TT27 * TT43 calls TT27

Print a text token (i.e. a character, control code, two-letter token or recursive token).
Arguments: A The text token to be printed
.TT27S JMP PrintCtrlCode_b0 ; We jump here from below if the character to print is ; in the range 0 to 9, so jump to PrintCtrlCode to print ; the control code and return from the subroutine using ; a tail call .TT27 PHA ; Store A on the stack, so we can retrieve it below SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 PLA ; Restore A from the stack TAX ; Copy the token number from A to X. We can then keep ; decrementing X and testing it against zero, while ; keeping the original token number intact in A; this ; effectively implements a switch statement on the ; value of the token BMI TT43 ; If token > 127, this is either a two-letter token ; (128-159) or a recursive token (160-255), so jump ; to TT43 to process tokens CMP #10 ; If token < 10 then this is a control code, so jump to BCC TT27S ; PrintCtrlCode via TT27S to print it CMP #96 ; By this point, token is either 7, or in 10-127. BCS ex ; Check token number in A and if token >= 96, then the ; token is in 96-127, which is a recursive token, so ; jump to ex, which prints recursive tokens in this ; range (i.e. where the recursive token number is ; correct and doesn't need correcting) CMP #14 ; If token < 14, skip the following two instructions BCC P%+6 CMP #32 ; If token < 32, then this means token is in 14-31, so BCC qw ; this is a recursive token that needs 114 adding to it ; to get the recursive token number, so jump to qw ; which will do this ; By this point, token is either 7 (beep) or in 10-13 ; (line feeds and carriage returns), or in 32-95 ; (ASCII letters, numbers and punctuation) LDX QQ17 ; Fetch QQ17, which controls letter case, into X BEQ TT44 ; If QQ17 = 0, then ALL CAPS is set, so jump to TT44 ; to print this character as is (i.e. as a capital) BMI TT41 ; If QQ17 has bit 7 set, then we are using Sentence ; Case, so jump to TT41, which will print the ; character in upper or lower case, depending on ; whether this is the first letter in a word BIT QQ17 ; If we get here, QQ17 is not 0 and bit 7 is clear, so BVS TT44 ; either it is bit 6 that is set, or some other flag in ; QQ17 is set (bits 0-5). So check whether bit 6 is set. ; If it is, then ALL CAPS has been set (as bit 7 is ; clear), so jump to TT26 via TT44 to print the ; character in upper case ; If we get here, some other flag is set in QQ17 (one ; of bits 0-5 is set), which shouldn't happen in this ; version of Elite. If this were the case, then we ; would fall through into TT42 to print in lower case, ; which is how printing all words in lower case could ; be supported (by setting QQ17 to 1, say)
Name: TT42 [Show more] Type: Subroutine Category: Text Summary: Print a letter in lower case
Context: See this subroutine on its own page References: This subroutine is called as follows: * TT45 calls TT42 * TT27 calls via TT44

Arguments: A The character to be printed. Can be one of the following: * 7 (beep) * 10-13 (line feeds and carriage returns) * 32-95 (ASCII capital letters, numbers and punctuation)
Other entry points: TT44 Jumps to TT26 to print the character in A (used to enable us to use a branch instruction to jump to TT26)
.TT42 TAX ; Convert the character in A into lower case by looking LDA lowerCase,X ; up the lower case ASCII value from the lowerCase table .TT44 JMP TT26 ; Print the character in A
Name: TT41 [Show more] Type: Subroutine Category: Text Summary: Print a letter according to Sentence Case
Context: See this subroutine on its own page References: This subroutine is called as follows: * TT27 calls TT41

The rules for printing in Sentence Case are as follows: * If QQ17 bit 6 is set, print lower case (via TT45) * If QQ17 bit 6 is clear, then: * If character is punctuation, just print it * If character is a letter, set QQ17 bit 6 and print letter as a capital
Arguments: A The character to be printed. Can be one of the following: * 7 (beep) * 10-13 (line feeds and carriage returns) * 32-95 (ASCII capital letters, numbers and punctuation) X Contains the current value of QQ17 QQ17 Bit 7 is set
.TT41 ; If we get here, then QQ17 has bit 7 set, so we are in ; Sentence Case BIT QQ17 ; If QQ17 also has bit 6 set, jump to TT45 to print BVS TT45 ; this character in lower case ; If we get here, then QQ17 has bit 6 clear and bit 7 ; set, so we are in Sentence Case and we need to print ; the next letter in upper case JMP DASC ; Jump to DASC to print the character in A
Name: qw [Show more] Type: Subroutine Category: Text Summary: Print a recursive token in the range 128-145
Context: See this subroutine on its own page References: This subroutine is called as follows: * TT27 calls qw

Print a recursive token where the token number is in 128-145 (so the value passed to TT27 is in the range 14-31).
Arguments: A A value from 128-145, which refers to a recursive token in the range 14-31
.qw ADC #114 ; This is a recursive token in the range 0-95, so add BNE ex ; 114 to the argument to get the token number 128-145 ; and jump to ex to print it
Name: TT45 [Show more] Type: Subroutine Category: Text Summary: Print a letter in lower case
Context: See this subroutine on its own page References: This subroutine is called as follows: * TT41 calls TT45

This routine prints a letter in lower case. Specifically: * If QQ17 = 255, abort printing this character as printing is disabled * If this is a letter then print in lower case * Otherwise this is punctuation, so clear bit 6 in QQ17 and print
Arguments: A The character to be printed. Can be one of the following: * 7 (beep) * 10-13 (line feeds and carriage returns) * 32-95 (ASCII capital letters, numbers and punctuation) X Contains the current value of QQ17 QQ17 Bits 6 and 7 are set
.TT45 ; If we get here, then QQ17 has bit 6 and 7 set, so we ; are in Sentence Case and we need to print the next ; letter in lower case CPX #255 ; If QQ17 = 255 then printing is disabled, so if it BNE TT42 ; isn't disabled, jump to TT42 to print the character RTS ; Printing is disables, so return from the subroutine
Name: TT43 [Show more] Type: Subroutine Category: Text Summary: Print a two-letter token or recursive token 0-95
Context: See this subroutine on its own page References: This subroutine is called as follows: * TT27 calls TT43

Print a two-letter token, or a recursive token where the token number is in 0-95 (so the value passed to TT27 is in the range 160-255).
Arguments: A One of the following: * 128-159 (two-letter token) * 160-255 (the argument to TT27 that refers to a recursive token in the range 0-95)
.TT43 CMP #160 ; If token >= 160, then this is a recursive token, so BCS TT47 ; jump to TT47 below to process it AND #127 ; This is a two-letter token with number 128-159. The ASL A ; set of two-letter tokens is stored in a lookup table ; at QQ16, with each token taking up two bytes, so to ; convert this into the token's position in the table, ; we subtract 128 (or just clear bit 7) and multiply ; by 2 (or shift left) TAY ; Transfer the token's position into Y so we can look ; up the token using absolute indexed mode LDA QQ16,Y ; Get the first letter of the token and print it JSR TT27 LDA QQ16+1,Y ; Get the second letter of the token CMP #'?' ; If the second letter of the token is a question mark BNE TT27 ; then this is a one-letter token, so if it isn't a ; question mark, jump to TT27 to print the second letter RTS ; The second letter is a question mark, so return from ; the subroutine without printing it .TT47 SBC #160 ; This is a recursive token in the range 160-255, so ; subtract 160 from the argument to get the token ; number 0-95 and fall through into ex to print it
Name: ex [Show more] Type: Subroutine Category: Text Summary: Print a recursive token Deep dive: Printing text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * ex_b2 calls ex * qw calls ex * TT27 calls ex

This routine works its way through the recursive text tokens that are stored in tokenised form in the table at QQ18, and when it finds token number A, it prints it. Tokens are null-terminated in memory and fill three pages, but there is no lookup table as that would consume too much memory, so the only way to find the correct token is to start at the beginning and look through the table byte by byte, counting tokens as we go until we are in the right place. This approach might not be terribly speed efficient, but it is certainly memory-efficient.
Arguments: A The recursive token to be printed, in the range 0-148
Other entry points: TT48 Contains an RTS
.ex TAX ; Copy the token number into X LDA QQ18Lo ; Set V(1 0) to point to the recursive token table at STA V ; location QQ18 LDA QQ18Hi STA V+1 LDY #0 ; Set a counter Y to point to the character offset ; as we scan through the table TXA ; Copy the token number back into A, so both A and X ; now contain the token number we want to print BEQ TT50 ; If the token number we want is 0, then we have ; already found the token we are looking for, so jump ; to TT50, otherwise start working our way through the ; null-terminated token table until we find the X-th ; token .TT51 LDA (V),Y ; Fetch the Y-th character from the token table page ; we are currently scanning BEQ TT49 ; If the character is null, we've reached the end of ; this token, so jump to TT49 INY ; Increment character pointer and loop back around for BNE TT51 ; the next character in this token, assuming Y hasn't ; yet wrapped around to 0 INC V+1 ; If it has wrapped round to 0, we have just crossed BNE TT51 ; into a new page, so increment V+1 so that V points ; to the start of the new page .TT49 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 INY ; Increment the character pointer BNE TT59 ; If Y hasn't just wrapped around to 0, skip the next ; instruction INC V+1 ; We have just crossed into a new page, so increment ; V+1 so that V points to the start of the new page .TT59 DEX ; We have just reached a new token, so decrement the ; token number we are looking for BNE TT51 ; Assuming we haven't yet reached the token number in ; X, look back up to keep fetching characters .TT50 ; We have now reached the correct token in the token ; table, with Y pointing to the start of the token as ; an offset within the page pointed to by V, so let's ; print the recursive token. Because recursive tokens ; can contain other recursive tokens, we need to store ; our current state on the stack, so we can retrieve ; it after printing each character in this token TYA ; Store the offset in Y on the stack PHA LDA V+1 ; Store the high byte of V (the page containing the PHA ; token we have found) on the stack, so the stack now ; contains the address of the start of this token LDA (V),Y ; Load the character at offset Y in the token table, ; which is the next character of this token that we ; want to print EOR #RE ; Tokens are stored in memory having been EOR'd with the ; value of RE - which is 35 for all versions of Elite ; except for NES, where RE is 62 - so we repeat the ; EOR to get the actual character to print JSR TT27 ; Print the text token in A, which could be a letter, ; number, control code, two-letter token or another ; recursive token PLA ; Restore the high byte of V (the page containing the STA V+1 ; token we have found) into V+1 PLA ; Restore the offset into Y TAY INY ; Increment Y to point to the next character in the ; token we are printing BNE P%+4 ; If Y is zero then we have just crossed into a new INC V+1 ; page, so increment V+1 so that V points to the start ; of the new page LDA (V),Y ; Load the next character we want to print into A BNE TT50 ; If this is not the null character at the end of the ; token, jump back up to TT50 to print the next ; character, otherwise we are done printing .TT48 RTS ; Return from the subroutine
Name: TT26 [Show more] Type: Subroutine Category: Text Summary: Print a character at the text cursor, with support for verified text in extended tokens Deep dive: Extended text tokens
Context: See this subroutine on its own page References: This subroutine is called as follows: * TT42 calls TT26 * DASC_b2 calls via DASC * DETOK2 calls via DASC * JMTB calls via DASC * MT26 calls via DASC * TT41 calls via DASC

Arguments: A The character to print
Returns: X X is preserved C flag The C flag is cleared
Other entry points: DASC DASC does exactly the same as TT26 and prints a character at the text cursor, with support for verified text in extended tokens
.DASC .TT26 STA SC+1 ; Store A in SC+1, so we can retrieve it later SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA SC+1 ; Restore A from SC+1 STX SC ; Store X in SC, so we can retrieve it below LDX #%11111111 ; Set DTW8 = %11111111, to disable the effect of {19} if STX DTW8 ; it was set (as {19} capitalises one character only) CMP #' ' ; If the character in A is one of the following: BEQ DA8 ; CMP #'.' ; * Space BEQ DA8 ; * Full stop CMP #':' ; * Colon BEQ DA8 ; * Apostrophe (ASCII 39) CMP #39 ; * Open bracket BEQ DA8 ; * Line feed CMP #'(' ; * Carriage return BEQ DA8 ; * Hyphen CMP #10 ; BEQ DA8 ; then jump to DA8 to skip the following instructions CMP #12 ; and set bit 6 of QQ17 to print the next letter in BEQ DA8 ; upper case (so these characters don't act like the CMP #'-' ; initial capital letter in Sentence Case, for example) BEQ DA8 LDA QQ17 ; Set bit 6 of QQ17 so we print the next letter in ORA #%01000000 ; lower case STA QQ17 INX ; Increment X to 0, so DTW2 gets set to %00000000 below BEQ dasc1 ; Jump to dasc1 to skip the following (this BEQ is ; effectively a JMP as X is always zero) .DA8 LDA QQ17 ; Clear bit 6 of QQ17 so we print the next letter in AND #%10111111 ; upper case STA QQ17 .dasc1 STX DTW2 ; Store X in DTW2, so DTW2 is now: ; ; * %00000000 if this character is a word terminator ; ; * %11111111 if it isn't ; ; so DTW2 indicates whether or not we are currently ; printing a word LDX SC ; Retrieve the original value of X from SC LDA SC+1 ; Retrieve the original value of A from SC+1 (i.e. the ; character to print) BIT DTW4 ; If bit 7 of DTW4 is set then we are currently printing BMI P%+5 ; justified text, so skip the next instruction JMP CHPR ; Bit 7 of DTW4 is clear, so jump down to CHPR to print ; this character, as we are not printing justified text ; If we get here then we are printing justified text, so ; we need to buffer the text until we reach the end of ; the paragraph, so we can then pad it out with spaces BIT DTW4 ; If bit 6 of DTW4 is set, then this is an in-flight BVS P%+6 ; message and we should buffer the carriage return ; character {12}, so skip the following two instructions CMP #12 ; If the character in A is a carriage return, then we BEQ DA1 ; have reached the end of the paragraph, so jump down to ; DA1 to print out the contents of the buffer, ; justifying it as we go ; If we get here then we need to buffer this character ; in the line buffer at BUF LDX DTW5 ; DTW5 contains the current size of the buffer, so this STA BUF,X ; stores the character in A at BUF + DTW5, the next free ; space in the buffer LDX SC ; Retrieve the original value of X from SC so we can ; preserve it through this subroutine call INC DTW5 ; Increment the size of the BUF buffer that is stored in ; DTW5 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 CLC ; Clear the C flag RTS ; Return from the subroutine .DA63S JMP DA6+3 ; Jump down to DA6+3 (this is used by the branch ; instruction below as it's too far to branch directly) .DA6S JMP DA6 ; Jump down to DA6 (this is used by the branch ; instruction below as it's too far to branch directly) .DA1 ; If we get here then we are justifying text and we have ; reached the end of the paragraph, so we need to print ; out the contents of the buffer, justifying it as we go TXA ; Store X and Y on the stack PHA TYA PHA .DA5 LDX DTW5 ; Set X = DTW5, which contains the size of the buffer BEQ DA63S ; If X = 0 then the buffer is empty, so jump down to ; DA6+3 via DA63S to print a newline CPX #(LL+1) ; If X < LL+1, i.e. X <= LL, then the buffer contains BCC DA6S ; fewer than LL characters, which is less than a line ; length, so jump down to DA6 via DA6S to print the ; contents of BUF followed by a newline, as we don't ; justify the last line of the paragraph ; Otherwise X > LL, so the buffer does not fit into one ; line, and we therefore need to justify the text, which ; we do one line at a time LSR SC+1 ; Shift SC+1 to the right, which clears bit 7 of SC+1, ; so we pass through the following comparison on the ; first iteration of the loop and set SC+1 to %01000000 .DA11 LDA SC+1 ; If bit 7 of SC+1 is set, skip the following two BMI P%+6 ; instructions LDA #%01000000 ; Set SC+1 = %01000000 STA SC+1 LDY #(LL-1) ; Set Y = line length, so we can loop backwards from the ; end of the first line in the buffer using Y as the ; loop counter .DAL1 LDA BUF+LL ; If the LL-th byte in BUF is a space, jump down to DA2 CMP #' ' ; to print out the first line from the buffer, as it BEQ DA2 ; fits the line width exactly (i.e. it's justified) ; We now want to find the last space character in the ; first line in the buffer, so we loop through the line ; using Y as a counter .DAL2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 DEY ; Decrement the loop counter in Y BMI DA11 ; If Y <= 0, loop back to DA11, as we have now looped BEQ DA11 ; through the whole line LDA BUF,Y ; If the Y-th byte in BUF is not a space, loop back up CMP #' ' ; to DAL2 to check the next character BNE DAL2 ; Y now points to a space character in the line buffer ASL SC+1 ; Shift SC+1 to the left BMI DAL2 ; If bit 7 of SC+1 is set, jump to DAL2 to find the next ; space character ; We now want to insert a space into the line buffer at ; position Y, which we do by shifting every character ; after position Y along by 1, and then inserting the ; space STY SC ; Store Y in SC, so we want to insert the space at ; position SC LDY DTW5 ; Fetch the buffer size from DTW5 into Y, to act as a ; loop counter for moving the line buffer along by 1 .DAL6 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA BUF,Y ; Copy the Y-th character from BUF into the Y+1-th STA BUF+1,Y ; position DEY ; Decrement the loop counter in Y CPY SC ; Loop back to shift the next character along, until we BCS DAL6 ; have moved the SC-th character (i.e. Y < SC) INC DTW5 ; Increment the buffer size in DTW5 LDA #' ' ; Set A to the ASCII for space ; ; This instruction has no effect because A already ; contains ASCII " ". This is because the last character ; that is tested in the above loop is at position SC, ; which we know contains a space, so we know A contains ; a space character when the loop finishes ; We've now shifted the line to the right by 1 from ; position SC onwards, so SC and SC+1 both contain ; spaces, and Y is now SC-1 as we did a DEY just before ; the end of the loop - in other words, we have inserted ; a space at position SC, and Y points to the character ; before the newly inserted space ; We now want to move the pointer Y left to find the ; next space in the line buffer, before looping back to ; check whether we are done, and if not, insert another ; space .DAL3 CMP BUF,Y ; If the character at position Y is not a space, jump to BNE DAL1 ; DAL1 to see whether we have now justified the line DEY ; Decrement the loop counter in Y BPL DAL3 ; Loop back to check the next character to the left, ; until we have found a space BMI DA11 ; Jump back to DA11 (this BMI is effectively a JMP as ; we already passed through a BPL to get here) .DA2 ; This subroutine prints out a full line of characters ; from the start of the line buffer in BUF, followed by ; a newline. It then removes that line from the buffer, ; shuffling the rest of the buffer contents down LDX #LL ; Call DAS1 to print out the first LL characters from JSR DAS1 ; the line buffer in BUF LDA #12 ; Print a newline JSR CHPR LDA DTW5 ; Subtract #LL from the end-of-buffer pointer in DTW5 SBC #LL ; STA DTW5 ; The subtraction works as CHPR clears the C flag TAX ; Copy the new value of DTW5 into X BEQ DA6+3 ; If DTW5 = 0 then jump down to DA6+3 to print a newline ; as the buffer is now empty ; If we get here then we have printed our line but there ; is more in the buffer, so we now want to remove the ; line we just printed from the start of BUF LDY #0 ; Set Y = 0 to count through the characters in BUF INX ; Increment X, so it now contains the number of ; characters in the buffer (as DTW5 is a zero-based ; pointer and is therefore equal to the number of ; characters minus 1) JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 .DAL4 LDA BUF+LL+1,Y ; Copy the Y-th character from BUF+LL to BUF STA BUF,Y INY ; Increment the character pointer DEX ; Decrement the character count BNE DAL4 ; Loop back to copy the next character until we have ; shuffled down the whole buffer JMP DA5 ; Jump back to DA5 .DAS1 ; This subroutine prints out X characters from BUF, ; returning with X = 0 LDY #0 ; Set Y = 0 to point to the first character in BUF .DAL5 LDA BUF,Y ; Print the Y-th character in BUF using CHPR, which also JSR CHPR ; clears the C flag for when we return from the ; subroutine below INY ; Increment Y to point to the next character DEX ; Decrement the loop counter BNE DAL5 ; Loop back for the next character until we have printed ; X characters from BUF RTS ; Return from the subroutine .DA6 JSR DAS1 ; Call DAS1 to print X characters from BUF, returning ; with X = 0 STX DTW5 ; Set the buffer size in DTW5 to 0, as the buffer is now ; empty PLA ; Restore Y and X from the stack TAY PLA TAX LDA #12 ; Set A = 12, so when we skip BELL and fall through into ; CHPR, we print character 12, which is a newline .DA7 EQUB $2C ; Skip the next instruction by turning it into ; $2C $A9 $07, or BIT $07A9, which does nothing apart ; from affect the flags ; Fall through into CHPR (skipping BELL) to print the ; character and return with the C flag cleared
Name: BELL [Show more] Type: Subroutine Category: Sound Summary: Make a standard system beep
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file

This is the standard system beep, as made by the ASCII 7 "BELL" control code.
.BELL LDA #7 ; Control code 7 makes a beep, so load this into A JMP CHPR ; Call the CHPR print routine to actually make the sound
Name: CHPR (Part 1 of 6) [Show more] Type: Subroutine Category: Text Summary: Print a character at the text cursor by poking into screen memory Deep dive: Fonts in NES Elite
Context: See this subroutine on its own page References: This subroutine is called as follows: * BELL calls CHPR * CHPR_b2 calls CHPR * TT26 calls CHPR

Print a character at the text cursor (XC, YC), do a beep, print a newline, or delete left (backspace). If the relevant font is already loaded into the pattern buffers, then this is used as the pattern for the character, otherwise the pattern for the character being printed is extracted from the fontImage table and into the pattern buffer. For fontStyle = 3, the pattern is always extracted from the fontImage table, as it has different colour text (colour 3) than the normal font. This is used when printing characters into 2x2 attribute blocks where printing the normal font would result in the wrong colour text being shown.
Arguments: A The character to be printed. Can be one of the following: * 7 (beep) * 10-13 (line feeds and carriage returns) * 32-95 (ASCII capital letters, numbers and punctuation) * 127 (delete the character to the left of the text cursor and move the cursor to the left) XC Contains the text column to print at (the x-coordinate) YC Contains the line number to print on (the y-coordinate) fontStyle Determines the font style: * 1 = normal font * 2 = highlight font * 3 = green text on a black background (colour 3 on background colour 0)
Returns: A A is preserved X X is preserved Y Y is preserved C flag The C flag is cleared
.chpr1 JMP chpr17 ; Jump to chpr17 to restore the registers and return ; from the subroutine .chpr2 LDA #2 ; Move the text cursor to row 2 STA YC LDA K3 ; Set A to the character to be printed JMP chpr4 ; Jump to chpr4 to print the character in A .chpr3 JMP chpr17 ; Jump to chpr17 to restore the registers and return ; from the subroutine LDA #12 ; This instruction is never called, but it would set A ; to a carriage return character and fall through into ; CHPR to print the newline .CHPR STA K3 ; Store the A register in K3 so we can retrieve it below ; (so K3 contains the number of the character to print) SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA K3 ; Store the A, X and Y registers, so we can restore STY YSAV2 ; them at the end (so they don't get changed by this STX XSAV2 ; routine) LDY QQ17 ; Load the QQ17 flag, which contains the text printing ; flags CPY #255 ; If QQ17 = 255 then printing is disabled, so jump to BEQ chpr3 ; chpr17 (via the JMP in chpr3) to restore the registers ; and return from the subroutine using a tail call .chpr4 CMP #7 ; If this is a beep character (A = 7), jump to chpr1, BEQ chpr1 ; which will emit the beep, restore the registers and ; return from the subroutine CMP #32 ; If this is an ASCII character (A >= 32), jump to chpr6 BCS chpr6 ; below, which will print the character, restore the ; registers and return from the subroutine CMP #10 ; If this is control code 10 (line feed) then jump to BEQ chpr5 ; chpr5, which will move down a line, restore the ; registers and return from the subroutine LDX #1 ; If we get here, then this is control code 11-13, of STX XC ; which only 13 is used. This code prints a newline, ; which we can achieve by moving the text cursor ; to the start of the line (carriage return) and down ; one line (line feed). These two lines do the first ; bit by setting XC = 1, and we then fall through into ; the line feed routine that's used by control code 10 .chpr5 CMP #13 ; If this is control code 13 (carriage return) then jump BEQ chpr3 ; to chpr17 (via the JMP in chpr3) to restore the ; registers and return from the subroutine using a tail ; call INC YC ; Increment the text cursor y-coordinate to move it ; down one row BNE chpr3 ; Jump to chpr17 via chpr3 to restore the registers and ; return from the subroutine using a tail call (this BNE ; is effectively a JMP as Y will never be zero) .chpr6 ; If we get here, then the character to print is an ; ASCII character in the range 32-95 LDX XC ; If the text cursor is on a column of 30 or less, then CPX #31 ; we have space to print the character on the current BCC chpr7 ; row, so jump to chpr7 to skip the following LDX #1 ; The text cursor has moved off the right end of the STX XC ; current line, so move the cursor back to column 1 and INC YC ; down to the next row .chpr7 LDX YC ; If the text cursor is on row 26 or less, then the CPX #27 ; cursor is on-screen, so jump to chpr8 to skip the BCC chpr8 ; following instruction JMP chpr2 ; The cursor is off the bottom of the screen, so jump to ; chpr2 to move the cursor up to row 2 before printing ; the character .chpr8 CMP #127 ; If the character to print is not ASCII 127, then jump BNE chpr9 ; to chpr9 to skip the following instruction JMP chpr21 ; Jump to chpr21 to delete the character to the left of ; the text cursor
Name: CHPR (Part 2 of 6) [Show more] Type: Subroutine Category: Text Summary: Jump to the right part of the routine depending on whether the font pattern we need is already loaded Deep dive: Fonts in NES Elite
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.chpr9 INC XC ; Once we print the character, we want to move the text ; cursor to the right, so we do this by incrementing ; XC. Note that this doesn't have anything to do ; with the actual printing below, we're just updating ; the cursor so it's in the right position following ; the print ; Before printing, we need to work out whether the font ; we need is already loaded into the pattern buffers, ; which will depend on the view type LDA QQ11 ; If bits 4 and 5 of the view type are clear, then no AND #%00110000 ; fonts are loaded, so jump to chpr11 to print the BEQ chpr11 ; character by copying the relevant font pattern into ; the pattern buffers ; If we get here then we know that at least one of bits ; 4 and 5 is set in QQ11, which means the normal font is ; loaded LDY fontStyle ; If fontStyle = 1, then we want to print text using the CPY #1 ; normal font, so jump to chpr10 to use the normal font BEQ chpr10 ; in the pattern buffers, as we know the normal font is ; loaded ; If we get here we know that fontStyle is 2 or 3 AND #%00100000 ; If bit 5 of the view type in QQ11 is clear, then the BEQ chpr11 ; highlight font is not loaded, so jump to chpr11 to ; print the character by copying the relevant font ; pattern into the pattern buffers ; If we get here then bit 5 of the view type in QQ11 ; is set, so we know that both the normal and highlight ; fonts are loaded ; ; We also know that fontStyle = 2 or 3 CPY #2 ; If fontStyle = 3, then we want to print the character BNE chpr11 ; in green text on a black background (so we can't use ; the normal font as that's in colour 1 on black and we ; need to print in colour 3 on black), so jump to chpr11 ; to print the character by copying the relevant font ; pattern into the pattern buffers ; If we get here then fontStyle = 2, so we want to print ; text using the highlight font and we know it is ; loaded, so we can go ahead and use the loaded font for ; our character LDA K3 ; Set A to the character to be printed CLC ; Set A = A + 95 ADC #95 ; ; The highlight font is loaded into pattern 161, which ; is 95 more than the normal font at pattern 66, so this ; points A to the correct character number in the ; highlight font JMP chpr22 ; Jump to chpr22 to print the character using a font ; that has already been loaded .chpr10 ; If we get here then fontStyle = 1 and the highlight ; font is loaded, so we can use that for our character LDA K3 ; Set A to the character to be printed JMP chpr22 ; Jump to chpr22 to print the character using a font ; that has already been loaded
Name: CHPR (Part 3 of 6) [Show more] Type: Subroutine Category: Text Summary: Draw a character into the pattern buffers to show the character on-screen Deep dive: Fonts in NES Elite
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.chpr11 ; If we get here then at least one of these is true: ; ; * No font is loaded ; ; * fontStyle = 2 (so we want to print highlighted ; text) but the highlight font is not loaded ; ; * fontStyle = 3 (so we want to print text in colour ; 3 on background colour 0) ; ; In all cases, we need to draw the pattern for the ; character directly into the relevant pattern buffer, ; as it isn't already available in a loaded font LDA K3 ; If the character to print in K3 is not a space, jump CMP #' ' ; to chpr12 to skip the following instruction BNE chpr12 JMP chpr17 ; We are printing a space, so jump to chpr17 to return ; from the subroutine .chpr12 TAY ; Set Y to the character to print ; ; Let's call the character number chr ; We now want to calculate the address of the pattern ; data for this character in the fontImage table, which ; contains the font images in ASCII order, starting from ; the space character (which maps to ASCII 32) ; ; There are eight bytes in each character's pattern, so ; the address we are after is therefore: ; ; fontImage + (chr - 32) * 8 ; ; This calculation is optimised below to take advantage ; of the fact that LO(fontImage) = $E8 = 29 * 8, so: ; ; fontImage + (chr - 32) * 8 ; = HI(fontImage) * 256 + LO(fontImage) + (chr - 32) * 8 ; = HI(fontImage) * 256 + (29 * 8) + (chr - 32) * 8 ; = HI(fontImage) * 256 + (29 + chr - 32) * 8 ; = HI(fontImage) * 256 + (chr - 3) * 8 ; ; So that is what we calculate below CLC ; Set A = A - 3 ADC #$FD ; = chr - 3 ; ; This could also be done using SEC and SBC #3 LDX #0 ; Set P(2 1) = A * 8 STX P+2 ; = (chr - 3) * 8 ASL A ; = chr * 8 - 24 ROL P+2 ASL A ROL P+2 ASL A ROL P+2 ADC #0 STA P+1 LDA P+2 ; Set P(2 1) = P(2 1) + HI(fontImage) * 256 ADC #HI(fontImage) ; = HI(fontImage) * 256 + (chr - 3) * 8 STA P+2 ; ; ; So P(2 1) is the address of the pattern data for the ; character that we want to print LDA #0 ; Set SC+1 = 0 (though this is never used as SC+1 is STA SC+1 ; overwritten again before it is used) LDA YC ; If the text cursor is not on row 0, jump to chpr13 to BNE chpr13 ; skip the following instruction JMP chpr31 ; The text cursor is on row 0, so jump to chpr31 to set ; SC(1 0) to the correct address in the nametable buffer ; and return to chpr15 below to draw the character .chpr13 LDA QQ11 ; If this is not the space view (i.e. QQ11 is non-zero) BNE chpr14 ; then jump to chpr14 to skip the following instruction JMP chpr28 ; This is the space view with no fonts loaded, so jump ; to chpr28 to draw the character on-screen, merging the ; text with whatever is already there .chpr14 JSR GetRowNameAddress ; Get the addresses in the nametable buffers for the ; start of character row YC, as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 LDY XC ; Set Y to the column of the text cursor - 1 DEY LDA (SC),Y ; This has no effect, as chpr15 is the next label and BEQ chpr15 ; neither A nor the status flags are read before being ; overwritten, but it checks whether the nametable entry ; for the character we want to draw is empty (and then ; does nothing if it is) .chpr15 LDA firstFreePattern ; If firstFreePattern is zero then we have run out of BEQ chpr17 ; patterns to use for drawing characters, so jump to ; chpr17 to return from the subroutine without printing ; anything CMP #255 ; If firstFreePattern = 255 then we have run out of BEQ chpr17 ; patterns to use for drawing characters, so jump to ; chpr17 to return from the subroutine without printing ; anything STA (SC),Y ; Otherwise firstFreePattern contains the number of the STA (SC2),Y ; next available pattern for drawing, so allocate this ; pattern to cover the character that we want to draw by ; setting the nametable entry in both buffers to the ; pattern number we just fetched INC firstFreePattern ; Increment firstFreePattern to point to the next ; available pattern for drawing, so it can be added to ; the nametable the next time we need to draw into a ; pattern LDY fontStyle ; If fontStyle = 1, jump to chpr18 DEY BEQ chpr18 DEY ; If fontStyle = 3, jump to chpr16 BNE chpr16 JMP chpr19 ; Otherwise fontStyle = 2, so jump to chpr19 .chpr16 ; If we get here then fontStyle = 3 and we need to ; copy the pattern data for this character from the ; address in P(2 1) into both pattern buffers 0 and 1 TAY ; Set Y to the character to print LDX #HI(pattBuffer0)/8 ; Set SC2(1 0) = (pattBuffer0/8 A) * 8 STX SC2+1 ; = (pattBufferHi 0) + A * 8 ASL A ; ROL SC2+1 ; So SC2(1 0) is the address in the pattern buffer for ASL A ; pattern number A (as each pattern contains 8 bytes of ROL SC2+1 ; pattern data), which means SC2(1 0) points to the ASL A ; pattern data for the tile containing the character ROL SC2+1 ; we are drawing in pattern buffer 0 STA SC2 TYA ; Set A back to the character to print LDX #HI(pattBuffer1)/8 ; Set SC(1 0) = (pattBuffer1/8 A) * 8 STX SC+1 ; = (pattBufferHi 0) + A * 8 ASL A ; ROL SC+1 ; So SC(1 0) is the address in the pattern buffer for ASL A ; pattern number A (as each pattern contains 8 bytes of ROL SC+1 ; pattern data), which means SC(1 0) points to the ASL A ; pattern data for the tile containing the character ROL SC+1 ; we are drawing in pattern buffer 1 STA SC ; We now copy the pattern data for this character from ; the address in P(2 1) to the pattern buffer addresses ; in SC(1 0) and SC2(1 0) LDY #0 ; We want to copy eight bytes of pattern data, as each ; character has eight rows of eight pixels, so set a ; byte index counter in Y ; We repeat the following code eight times, so it copies ; one whole pattern of eight bytes LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0), STA (SC2),Y ; and increment the byte counter in Y INY LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC2),Y ; byte of the pattern buffers in SC(1 0) and SC2(1 0) STA (SC),Y .chpr17 LDY YSAV2 ; We're done printing, so restore the values of the LDX XSAV2 ; X and Y registers that we saved above SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA K3 ; Restore the value of the A register that we saved ; above CLC ; Clear the C flag, so everything is back to how it was RTS ; Return from the subroutine .chpr18 ; If we get here then fontStyle = 1 and we need to ; copy the pattern data for this character from the ; address in P(2 1) into pattern buffer 0 LDX #HI(pattBuffer0)/8 ; Set SC(1 0) = (pattBuffer0/8 A) * 8 STX SC+1 ; = (pattBufferHi 0) + A * 8 ASL A ; ROL SC+1 ; So SC(1 0) is the address in the pattern buffer for ASL A ; pattern number A (as each pattern contains 8 bytes of ROL SC+1 ; pattern data), which means SC(1 0) points to the ASL A ; pattern data for the tile containing the character ROL SC+1 ; we are drawing in pattern buffer 0 STA SC JMP chpr20 ; Jump to chpr20 to draw the pattern we need for our ; text character into the pattern buffer .chpr19 ; If we get here then fontStyle = 2 and we need to ; copy the pattern data for this character from the ; address in P(2 1) into pattern buffer 1 LDX #HI(pattBuffer1)/8 ; Set SC(1 0) = (pattBuffer1/8 A) * 8 STX SC+1 ; = (pattBufferHi 0) + A * 8 ASL A ; ROL SC+1 ; So SC(1 0) is the address in the pattern buffer for ASL A ; pattern number A (as each pattern contains 8 bytes of ROL SC+1 ; pattern data), which means SC(1 0) points to the ASL A ; pattern data for the tile containing the character ROL SC+1 ; we are drawing in pattern buffer 1 STA SC .chpr20 ; We now copy the pattern data for this character from ; the address in P(2 1) to the pattern buffer address ; in SC(1 0) LDY #0 ; We want to copy eight bytes of pattern data, as each ; character has eight rows of eight pixels, so set a ; byte index counter in Y ; We repeat the following code eight times, so it copies ; one whole pattern of eight bytes LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0) JMP chpr17 ; Jump to chpr17 to return from the subroutine, as we ; are done printing this character
Name: CHPR (Part 4 of 6) [Show more] Type: Subroutine Category: Text Summary: Process the delete character Deep dive: Fonts in NES Elite
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.chpr21 ; If we get here then we are printing ASCII 127, which ; is the delete character JSR GetRowNameAddress ; Get the addresses in the nametable buffers for the ; start of character row YC, as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 LDY XC ; Set Y to the text column of the text cursor, which ; points to the character we want to delete (as we are ; printing a delete character there) DEC XC ; Decrement XC to move the text cursor left by one ; place, as we are deleting a character LDA #0 ; Zero the Y-th nametable entry in nametable buffer 0 STA (SC),Y ; for the Y-th character on row YC, which deletes the ; character that was there STA (SC2),Y ; Zero the Y-th nametable entry in nametable buffer 1 ; for the Y-th character on row YC, which deletes the ; character that was there JMP chpr17 ; Jump to chpr17 to return from the subroutine, as we ; are done printing this character
Name: CHPR (Part 5 of 6) [Show more] Type: Subroutine Category: Text Summary: Print the character using a font that has already been loaded Deep dive: Fonts in NES Elite
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.chpr22 ; If we get here then one of these is true: ; ; * The normal and highlight fonts are loaded ; fontStyle = 2 ; A = character number + 95 ; ; * The normal font is loaded ; fontStyle = 1 ; A = character number PHA ; Store A on the stack to we can retrieve it after the ; call to GetRowNameAddress JSR GetRowNameAddress ; Get the addresses in the nametable buffers for the ; start of character row YC, as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 PLA ; Retrieve the character number we stored on the stack ; above CMP #' ' ; If we are printing a space, jump to chpr25 BEQ chpr25 .chpr23 CLC ; Convert the ASCII number in A to the pattern number in ADC asciiToPattern ; the PPU of the corresponding character image, by ; adding asciiToPattern (which gets set when the view ; is set up) .chpr24 LDY XC ; Set Y to the column of the text cursor - 1 DEY STA (SC),Y ; Set the Y-th nametable entry in nametable buffer 0 ; for the Y-th character on row YC, to the pattern ; number for our character from the loaded font STA (SC2),Y ; Set the Y-th nametable entry in nametable buffer 1 ; for the Y-th character on row YC, to the pattern ; number for our character from the loaded font JMP chpr17 ; Jump to chpr17 to return from the subroutine, as we ; are done printing this character .chpr25 ; If we get here then we are printing a space LDY QQ11 ; If the view type in QQ11 is $9D (Long-range Chart with CPY #$9D ; the normal font loaded), jump to chpr26 to use pattern BEQ chpr26 ; 0 as the space character CPY #$DF ; If the view type in QQ11 is not $DF (Start screen with BNE chpr23 ; the normal font loaded), jump to chpr23 to convert ; the ASCII number in A to the pattern number .chpr26 LDA #0 ; This is either view $9D (Long-range Chart) or $DF ; (Start screen), and in both these views the normal ; font is loaded directly into the PPU at a different ; pattern number to the other views, so we set A = 0 to ; use as the space character, as that is always a blank ; tile BEQ chpr24 ; Jump up to chpr24 to draw the character (this BEQ is ; effectively a JMP as A is always zero)
Name: CHPR (Part 6 of 6) [Show more] Type: Subroutine Category: Text Summary: Print a character in the space view when the relevant font is not loaded, merging the text with whatever is already on-screen Deep dive: Fonts in NES Elite
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.chpr27 ; We jump here from below when the tile we are drawing ; into is not empty LDX pattBufferHiDiv8 ; Set SC(1 0) = (pattBufferHiDiv8 A) * 8 STX SC+1 ; = (pattBufferHi 0) + A * 8 ASL A ; ROL SC+1 ; So SC(1 0) is the address in the pattern buffer for ASL A ; pattern number A (as each pattern contains 8 bytes of ROL SC+1 ; pattern data), which means SC(1 0) points to the ASL A ; pattern data for the tile containing the character ROL SC+1 ; we are drawing STA SC ; We now copy the pattern data for this character from ; the address in P(2 1) to the pattern buffer address ; in SC(1 0), using OR logic to merge the character with ; the existing contents of the tile LDY #0 ; We want to copy eight bytes of pattern data, as each ; character has eight rows of eight pixels, so set a ; byte index counter in Y ; We repeat the following code eight times, so it copies ; one whole pattern of eight bytes LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer, and INY ; increment the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th ORA (SC),Y ; byte of the pattern buffer in SC(1 0), OR'ing the byte STA (SC),Y ; with the existing contents of the pattern buffer JMP chpr17 ; Jump to chpr17 to return from the subroutine, as we ; are done printing this character .chpr28 ; If we get here then this is the space view with no ; font loaded, and we have set up P(2 1) to point to the ; pattern data for the character we want to draw LDA #0 ; Set SC+1 = 0 to act as the high byte of SC(1 0) in the STA SC+1 ; calculation below LDA YC ; Set A to the current text cursor row BNE chpr29 ; If the cursor is in row 0, set A = 255 so the value LDA #255 ; of A + 1 is 0 in the calculation below .chpr29 CLC ; Set (SC+1 A) = (A + 1) * 16 ADC #1 ASL A ASL A ASL A ASL A ROL SC+1 SEC ; Set SC(1 0) = (nameBufferHi 0) + (SC+1 A) * 2 + 1 ROL A ; = (nameBufferHi 0) + (A + 1) * 32 + 1 STA SC ; LDA SC+1 ; So SC(1 0) points to the entry in the nametable buffer ROL A ; for the start of the row below the text cursor, plus 1 ADC nameBufferHi STA SC+1 LDY XC ; Set Y to the column of the text cursor, minus one DEY ; So SC(1 0) + Y now points to the nametable entry of ; the tile where we want to draw our character LDA (SC),Y ; If the nametable entry for the tile is not empty, then BNE chpr27 ; jump up to chpr27 to draw our character into the ; existing pattern for this tile LDA firstFreePattern ; If firstFreePattern is zero then we have run out of BEQ chpr30 ; patterns to use for drawing characters, so jump to ; chpr30 to return from the subroutine without printing ; anything STA (SC),Y ; Otherwise firstFreePattern contains the number of the ; next available pattern for drawing, so allocate this ; pattern to cover the character that we want to draw by ; setting the nametable entry to the pattern number we ; just fetched INC firstFreePattern ; Increment firstFreePattern to point to the next ; available pattern for drawing, so it can be added to ; the nametable the next time we need to draw into a ; pattern LDX pattBufferHiDiv8 ; Set SC(1 0) = (pattBufferHiDiv8 A) * 8 STX SC+1 ; = (pattBufferHi 0) + A * 8 ASL A ; ROL SC+1 ; So SC(1 0) is the address in the pattern buffer for ASL A ; pattern number A (as each pattern contains 8 bytes of ROL SC+1 ; pattern data), which means SC(1 0) points to the ASL A ; pattern data for the tile containing the character ROL SC+1 ; we are drawing STA SC ; We now copy the pattern data for this character from ; the address in P(2 1) to the pattern buffer address ; in SC(1 0) LDY #0 ; We want to copy eight bytes of pattern data, as each ; character has eight rows of eight pixels, so set a ; byte index counter in Y ; We repeat the following code eight times, so it copies ; one whole pattern of eight bytes LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0), and increment INY ; the byte counter in Y LDA (P+1),Y ; Copy the Y-th pattern byte from P(2 1) to the Y-th STA (SC),Y ; byte of the pattern buffer in SC(1 0) .chpr30 JMP chpr17 ; Jump to chpr17 to return from the subroutine, as we ; are done printing this character .chpr31 ; If we get here then this is the space view and the ; text cursor is on row 0 LDA #33 ; Set SC(1 0) to the address of tile 33 in the nametable STA SC ; buffer, which is the first tile on row 1 LDA nameBufferHi STA SC+1 LDY XC ; Set Y to the column of the text cursor - 1 DEY JMP chpr15 ; Jump up to chpr15 to continue drawing the character
Name: lowerCase [Show more] Type: Variable Category: Text Summary: Lookup table for converting ASCII characters to lower case characters in the game's text font
Context: See this variable on its own page References: This variable is used as follows: * DETOK2 uses lowerCase * TT42 uses lowerCase
.lowerCase EQUB 0, 1, 2, 3 ; Control codes map to themselves EQUB 4, 5, 6, 7 EQUB 8, 9, 10, 11 EQUB 12, 13, 14, 15 EQUB 16, 17, 18, 19 EQUB 20, 21, 22, 23 EQUB 24, 25, 26, 27 EQUB 28, 29, 30, 31 EQUS " !$/$%&'()*+," ; These punctuation characters map to themselves apart EQUS "-./0123456789" ; from the following (ASCII on left, NES on right): EQUS ":;%*>?`" ; ; " to $ so that maps À to à in the game font ; # to / so that maps Ô to ô in the game font ; < to % so that maps É to é in the game font ; = to * so that maps È to è in the game font ; @ to ` so that maps Ç to ç in the game font EQUS "abcdefghijklm" ; Capital letters map to their lower case equivalents EQUS "nopqrstuvwxyz" EQUS "{|};+`" ; These punctuation characters map to themselves apart ; from the following (ASCII on left, NES on right): ; ; [ to { so that maps Ä to ä in the game font ; \ to | so that maps Ö to ö in the game font ; ] to } so that maps Ü to ü in the game font ; ^ to ; so that maps ß to ß in the game font ; _ to + so that maps Ê to ê in the game font EQUS "abcdefghijklm" ; Lower case characters map to themselves EQUS "nopqrstuvwxyz" EQUS "{|}~" ; These punctuation characters map to themselves EQUB 127 ; Control codes map to themselves
Name: Vectors_b2 [Show more] Type: Variable Category: Utility routines Summary: Vectors and padding at the end of ROM bank 2 Deep dive: Splitting NES Elite across multiple ROM banks
Context: See this variable on its own page References: No direct references to this variable in this source file
FOR I%, P%, $BFF9 EQUB $FF ; Pad out the rest of the ROM bank with $FF NEXT IF _NTSC EQUW Interrupts_b2+$4000 ; Vector to the NMI handler in case this bank is ; loaded into $C000 during start-up (the handler ; contains an RTI so the interrupt is processed but ; has no effect) EQUW ResetMMC1_b2+$4000 ; Vector to the RESET handler in case this bank is ; loaded into $C000 during start-up (the handler ; resets the MMC1 mapper to map bank 7 into $C000 ; instead) EQUW Interrupts_b2+$4000 ; Vector to the IRQ/BRK handler in case this bank is ; loaded into $C000 during start-up (the handler ; contains an RTI so the interrupt is processed but ; has no effect) ELIF _PAL EQUW NMI ; Vector to the NMI handler EQUW ResetMMC1_b2+$4000 ; Vector to the RESET handler in case this bank is ; loaded into $C000 during start-up (the handler ; resets the MMC1 mapper to map bank 7 into $C000 ; instead) EQUW IRQ ; Vector to the IRQ/BRK handler ENDIF
Save bank2.bin
PRINT "S.bank2.bin ", ~CODE%, " ", ~P%, " ", ~LOAD%, " ", ~LOAD% SAVE "3-assembled-output/bank2.bin", CODE%, P%, LOAD%