@@ -153,18 +153,23 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
153153 sb . AppendLine ( "!MMU./sysvars.inc,10,$1C00" ) ;
154154 }
155155 // Origin
156- {
157- int org = settings . Origin == null ? 32768 : settings . Origin . Value ;
158- sb . AppendLine ( string . Format ( "!PCSP${0:X2},${1:X2}" , org , org - 2 ) ) ;
159- }
156+ int org = settings . Origin == null ? 32768 : settings . Origin . Value ;
157+ sb . AppendLine ( string . Format ( "!PCSP${0:X2},${1:X2}" , org , org - 2 ) ) ;
160158 // Main file
161159 {
162- var bank = 5 ;
163- var address = 0x2000 ;
160+ int [ ] nextBank16K = { 255 , 5 , 2 , 0 } ;
161+ int bank = org / 16384 ;
162+ int offset = org - ( bank * 16384 ) ;
163+ if ( bank < 0 || bank > 3 )
164+ {
165+ outputLogWritter . WriteLine ( "Error: Invalid ORG direction, must be >0 and <65535" ) ;
166+ return false ;
167+ }
168+ bank = nextBank16K [ bank ] ;
164169 sb . AppendLine ( string . Format ( ".\\ {0},{1},${2:X2}" ,
165170 Path . Combine ( Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".bin" ) ,
166171 bank ,
167- address ) ) ;
172+ offset ) ) ;
168173 }
169174 // Save nex.cfg file
170175 {
@@ -200,16 +205,27 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
200205
201206 outputLogWritter . WriteLine ( "Building .nex file..." ) ;
202207 Process process = new Process ( ) ;
203- process . StartInfo . FileName = "python.exe" ;
204- process . StartInfo . Arguments = string . Format ( "{0} nex.cfg {1}" ,
205- Path . Combine ( Path . GetDirectoryName ( ZXOptions . Current . ZxbcPath ) , "tools" , "nextcreator.py" ) ,
206- Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ;
207- process . StartInfo . WorkingDirectory = project . ProjectPath ;
208- process . StartInfo . UseShellExecute = false ;
209- process . StartInfo . CreateNoWindow = true ;
210- process . StartInfo . RedirectStandardOutput = true ;
208+ if ( Environment . OSVersion . Platform == PlatformID . Win32NT )
209+ {
210+ process . StartInfo . FileName = "python" ;
211+ process . StartInfo . Arguments = string . Format ( "{0} nex.cfg {1}" ,
212+ Path . Combine ( Path . GetDirectoryName ( ZXOptions . Current . ZxbcPath ) , "tools" , "nextcreator.py" ) ,
213+ Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ;
214+ process . StartInfo . WorkingDirectory = project . ProjectPath ;
215+ process . StartInfo . UseShellExecute = false ;
216+ process . StartInfo . CreateNoWindow = true ;
217+ process . StartInfo . RedirectStandardOutput = true ;
218+ }
219+ else
220+ {
221+ process . StartInfo . FileName = Path . Combine ( Path . GetDirectoryName ( ZXOptions . Current . ZxbcPath ) , "tools" , "nextcreator.py" ) ;
222+ process . StartInfo . Arguments = "nex.cfg " + Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ;
223+ process . StartInfo . WorkingDirectory = project . ProjectPath ;
224+ process . StartInfo . UseShellExecute = false ;
225+ process . StartInfo . CreateNoWindow = true ;
226+ process . StartInfo . RedirectStandardOutput = true ;
227+ }
211228 process . Start ( ) ;
212-
213229 process . WaitForExit ( ) ;
214230
215231 if ( ! File . Exists ( nexFile ) )
0 commit comments