@@ -156,18 +156,23 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
156156 sb . AppendLine ( "!MMU./sysvars.inc,10,$1C00" ) ;
157157 }
158158 // Origin
159- {
160- int org = settings . Origin == null ? 32768 : settings . Origin . Value ;
161- sb . AppendLine ( string . Format ( "!PCSP${0:X2},${1:X2}" , org , org - 2 ) ) ;
162- }
159+ int org = settings . Origin == null ? 32768 : settings . Origin . Value ;
160+ sb . AppendLine ( string . Format ( "!PCSP${0:X2},${1:X2}" , org , org - 2 ) ) ;
163161 // Main file
164162 {
165- var bank = 5 ;
166- var address = 0x2000 ;
163+ int [ ] nextBank16K = { 255 , 5 , 2 , 0 } ;
164+ int bank = org / 16384 ;
165+ int offset = org - ( bank * 16384 ) ;
166+ if ( bank < 0 || bank > 3 )
167+ {
168+ outputLogWritter . WriteLine ( "Error: Invalid ORG direction, must be >0 and <65535" ) ;
169+ return false ;
170+ }
171+ bank = nextBank16K [ bank ] ;
167172 sb . AppendLine ( string . Format ( ".\\ {0},{1},${2:X2}" ,
168173 Path . Combine ( Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".bin" ) ,
169174 bank ,
170- address ) ) ;
175+ offset ) ) ;
171176 }
172177 // Save nex.cfg file
173178 {
@@ -203,16 +208,27 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
203208
204209 outputLogWritter . WriteLine ( "Building .nex file..." ) ;
205210 Process process = new Process ( ) ;
206- process . StartInfo . FileName = "python.exe" ;
207- process . StartInfo . Arguments = string . Format ( "{0} nex.cfg {1}" ,
208- Path . Combine ( Path . GetDirectoryName ( ZXOptions . Current . ZxbcPath ) , "tools" , "nextcreator.py" ) ,
209- Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ;
210- process . StartInfo . WorkingDirectory = project . ProjectPath ;
211- process . StartInfo . UseShellExecute = false ;
212- process . StartInfo . CreateNoWindow = true ;
213- process . StartInfo . RedirectStandardOutput = true ;
211+ if ( Environment . OSVersion . Platform == PlatformID . Win32NT )
212+ {
213+ process . StartInfo . FileName = "python" ;
214+ process . StartInfo . Arguments = string . Format ( "{0} nex.cfg {1}" ,
215+ Path . Combine ( Path . GetDirectoryName ( ZXOptions . Current . ZxbcPath ) , "tools" , "nextcreator.py" ) ,
216+ Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ;
217+ process . StartInfo . WorkingDirectory = project . ProjectPath ;
218+ process . StartInfo . UseShellExecute = false ;
219+ process . StartInfo . CreateNoWindow = true ;
220+ process . StartInfo . RedirectStandardOutput = true ;
221+ }
222+ else
223+ {
224+ process . StartInfo . FileName = Path . Combine ( Path . GetDirectoryName ( ZXOptions . Current . ZxbcPath ) , "tools" , "nextcreator.py" ) ;
225+ process . StartInfo . Arguments = "nex.cfg " + Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ;
226+ process . StartInfo . WorkingDirectory = project . ProjectPath ;
227+ process . StartInfo . UseShellExecute = false ;
228+ process . StartInfo . CreateNoWindow = true ;
229+ process . StartInfo . RedirectStandardOutput = true ;
230+ }
214231 process . Start ( ) ;
215-
216232 process . WaitForExit ( ) ;
217233
218234 if ( ! File . Exists ( nexFile ) )
0 commit comments