@@ -1688,7 +1688,7 @@ CpcVm.prototype = {
16881688 inp : function ( iPort ) {
16891689 var byte ;
16901690
1691- iPort = this . vmRound2Complement ( iPort , "INP" ) ; // 2nd complement of 16 bit address
1691+ iPort = this . vmRound2Complement ( iPort , "INP" ) ; // two's complement of 16 bit address
16921692 // eslint-disable-next-line no-bitwise
16931693 byte = ( iPort & 0xff ) ;
16941694
@@ -1765,7 +1765,7 @@ CpcVm.prototype = {
17651765 aFileData . shift ( ) ; // remove line
17661766 sLine += "\n" + aFileData [ 0 ] ; // combine lines
17671767 } else {
1768- throw that . vmComposeError ( Error ( ) , 13 , "INPUT #9: no closing quotes" + value ) ; // TTT
1768+ throw that . vmComposeError ( Error ( ) , 13 , "INPUT #9: no closing quotes" + value ) ;
17691769 }
17701770 } else { // unquoted string
17711771 iIndex = sLine . indexOf ( "," ) ; // multiple args?
@@ -1809,7 +1809,7 @@ CpcVm.prototype = {
18091809 sLine = sLine . replace ( / ^ \s + / , "" ) ; // remove preceding whitespace
18101810 if ( sType === "$" ) {
18111811 value = fnGetString ( ) ;
1812- } else { // number type sLine.length TTT
1812+ } else { // number type sLine.length
18131813 value = fnGetNumber ( ) ;
18141814 }
18151815
@@ -2264,7 +2264,7 @@ CpcVm.prototype = {
22642264 if ( sInput !== null ) {
22652265 sInput = sInput . replace ( / \r \n / g, "\n" ) ; // remove CR (maybe from ASCII file in "binary" form)
22662266 if ( sInput . endsWith ( "\n" ) ) {
2267- sInput = sInput . substr ( 0 , sInput . length - 1 ) ; // remove last "\n" (TTT : also for data files?)
2267+ sInput = sInput . substr ( 0 , sInput . length - 1 ) ; // remove last "\n" (TODO : also for data files?)
22682268 }
22692269 oInFile . aFileData = sInput . split ( "\n" ) ;
22702270 } else {
@@ -3346,7 +3346,7 @@ CpcVm.prototype = {
33463346 this . oCanvas . resetCustomChars ( ) ;
33473347 if ( iChar === 256 ) { // maybe move up again
33483348 iMinCharHimem = this . iMaxHimem ;
3349- this . iMaxCharHimem = iMinCharHimem ; //TTT corrected
3349+ this . iMaxCharHimem = iMinCharHimem ;
33503350 }
33513351 // TODO: Copy char data to screen memory, if screen starts at 0x4000 and chardata is in that range (and ram 0 is selected)
33523352 this . iMinCustomChar = iChar ;
@@ -3512,9 +3512,15 @@ CpcVm.prototype = {
35123512 } else if ( s . startsWith ( "&h" ) ) { // hex &h
35133513 s = s . slice ( 2 ) ;
35143514 iNum = parseInt ( s , 16 ) ;
3515+ if ( iNum > 32767 ) { // two's complement
3516+ iNum -= 65536 ;
3517+ }
35153518 } else if ( s . startsWith ( "&" ) ) { // hex &
35163519 s = s . slice ( 1 ) ;
35173520 iNum = parseInt ( s , 16 ) ;
3521+ if ( iNum > 32767 ) { // two's complement
3522+ iNum -= 65536 ;
3523+ }
35183524 } else if ( s !== "" ) { // not empty string?
35193525 iNum = parseFloat ( s ) ;
35203526 }
0 commit comments