@@ -28,6 +28,10 @@ int tallspritecount = 0;
2828
2929int currentdmahole = 0 ;
3030
31+ int banksetrom = 0 ;
32+
33+ #define BANKSETASM "banksetrom.asm"
34+
3135int deprecatedframeheight = 0 ;
3236int deprecated160bindexes = 0 ;
3337
@@ -856,13 +860,13 @@ void bank(char **statement)
856860 // 2.issue ORG,RORG
857861 currentbank = requestedbank ;
858862 if (romat4k == 1 )
859- printf (" ORG $%04X,0\n" , (currentbank + 1 ) * 0x4000 );
863+ orgprintf (" ORG $%04X,0\n" , (currentbank + 1 ) * 0x4000 );
860864 else
861- printf (" ORG $%04X,0\n" , (currentbank + 2 ) * 0x4000 );
865+ orgprintf (" ORG $%04X,0\n" , (currentbank + 2 ) * 0x4000 );
862866 if (currentbank == (bankcount - 1 )) //last bank
863- printf (" RORG $C000\n" );
867+ orgprintf (" RORG $C000\n" );
864868 else
865- printf (" RORG $8000\n" );
869+ orgprintf (" RORG $8000\n" );
866870}
867871
868872void dmahole (char * * statement )
@@ -875,6 +879,12 @@ void dmahole(char **statement)
875879
876880 assertminimumargs (statement , "dmahole" , 1 );
877881
882+ if (banksetrom == 1 )
883+ {
884+ prwarn ("the dmahole command was ignored. dmahole isn't supported with banksets." );
885+ return ;
886+ }
887+
878888 removeCR (statement [2 ]);
879889 removeCR (statement [3 ]);
880890
@@ -2797,7 +2807,7 @@ void fixfilename(char *filename)
27972807
27982808 if ((filename [0 ] != '/' ) && (filename [0 ] != '\\' ) && (incbasepath [0 ] != 0 ))
27992809 {
2800- char temppath [500 ];
2810+ char temppath [1024 ];
28012811
28022812 //the path is relative, and basepath is defined. We'll add on the basepath
28032813
@@ -3258,7 +3268,7 @@ void add_graphic(char **statement, int incbanner)
32583268 {
32593269 for (t = 0 ; t < (height / zoneheight ); t ++ )
32603270 {
3261- char indexstr [1024 ];
3271+ char indexstr [1124 ];
32623272
32633273 // Now read the png into memory...
32643274 incgraphic (statement [2 ], offset );
@@ -4213,7 +4223,7 @@ void barf_graphic_file(void)
42134223
42144224 if (bankcount == 0 ) // non-banked
42154225 {
4216- if ((graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) //calculate from graphics area...
4226+ if ((( graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) && ( banksetrom == 0 )) //calculate from graphics area...
42174227 {
42184228 printf (" echo \" \",[($%04X - gameend)]d , \"bytes of ROM space left in the main area.\"\n" , ADDRBASE );
42194229 printf (" if ($%04X - gameend) < 0\n" , ADDRBASE );
@@ -4231,7 +4241,7 @@ void barf_graphic_file(void)
42314241 else if ((currentbank + 1 ) == bankcount ) // 0xC000
42324242 {
42334243
4234- if ((graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) //calculate from graphics area...
4244+ if ((( graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) && ( banksetrom == 0 )) //calculate from graphics area...
42354245 {
42364246 printf (" echo \" \",[($%04X - .)]d , \"bytes of ROM space left in the main area of bank %d.\"\n" , ADDRBASE ,
42374247 currentbank + 1 );
@@ -4251,7 +4261,7 @@ void barf_graphic_file(void)
42514261 else if ((romat4k == 1 ) && (currentbank == 0 )) // 0x4000
42524262 {
42534263
4254- if ((graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) //calculate from graphics area...
4264+ if ((( graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) && ( banksetrom == 0 )) //calculate from graphics area...
42554265 {
42564266 printf (" echo \" \",[($%04X - .)]d , \"bytes of ROM space left in the main area of bank %d.\"\n" , ADDRBASE ,
42574267 currentbank + 1 );
@@ -4270,7 +4280,7 @@ void barf_graphic_file(void)
42704280 }
42714281 else
42724282 {
4273- if ((graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) //calculate from graphics area...
4283+ if ((( graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) && ( banksetrom == 0 )) //calculate from graphics area...
42744284 {
42754285 printf (" echo \" \",[($%04X - .)]d , \"bytes of ROM space left in the main area of bank %d.\"\n" , ADDRBASE ,
42764286 currentbank + 1 );
@@ -4288,8 +4298,6 @@ void barf_graphic_file(void)
42884298 }
42894299 }
42904300
4291-
4292-
42934301 if ((graphicsdatawidth [dmaplain ] > 0 ) || (dmaplain > 0 )) //only process if the incgraphic command was encountered.
42944302 {
42954303 if (((bankcount > 0 ) && (zoneheight == 16 ) && (dmaplain > 1 )) ||
@@ -4322,11 +4330,11 @@ void barf_graphic_file(void)
43224330 for (s = zoneheight - 1 ; s >= 0 ; s -- )
43234331 {
43244332 if (bankcount == 0 )
4325- printf ("\n ORG $%04X,0 ; *************\n" , ADDRBASE );
4333+ gfxprintf ("\n ORG $%04X,0 ; *************\n" , ADDRBASE );
43264334 else
43274335 {
4328- printf ("\n ORG $%04X,0 ; *************\n" , ABADDRBASE );
4329- printf ("\n RORG $%04X ; *************\n" , ADDRBASE );
4336+ gfxprintf ("\n ORG $%04X,0 ; *************\n" , ABADDRBASE );
4337+ gfxprintf ("\n RORG $%04X ; *************\n" , ADDRBASE );
43304338 }
43314339
43324340 for (t = 0 ; t < graphicsdatawidth [currentplain ]; t ++ )
@@ -4336,7 +4344,8 @@ void barf_graphic_file(void)
43364344 runi = 0 ;
43374345 if (s == (zoneheight - 1 ))
43384346 {
4339- printf ("\n%s\n HEX " , graphicslabels [currentplain ][t ]);
4347+ printf ("\n%s = $%X\n" ,graphicslabels [currentplain ][t ],t + ADDRBASE );
4348+ gfxprintf ("\n%s\n HEX " , graphicslabels [currentplain ][t ]);
43404349 if ((linewidth + strlen (graphicslabels [currentplain ][t ])) > 60 )
43414350 {
43424351 linewidth = 0 ;
@@ -4346,14 +4355,14 @@ void barf_graphic_file(void)
43464355 linewidth = linewidth + strlen (graphicslabels [currentplain ][t ]);
43474356 }
43484357 else
4349- printf ("\n;%s\n HEX " , graphicslabels [currentplain ][t ]);
4358+ gfxprintf ("\n;%s\n HEX " , graphicslabels [currentplain ][t ]);
43504359 }
4351- printf ("%02x" , graphicsdata [currentplain ][t ][s ]);
4360+ gfxprintf ("%02x" , graphicsdata [currentplain ][t ][s ]);
43524361 runi ++ ;
43534362 if ((runi % 32 == 0 ) && ((t + 1 ) < graphicsdatawidth [currentplain ]))
4354- printf ("\n HEX " );
4363+ gfxprintf ("\n HEX " );
43554364 }
4356- printf ("\n" );
4365+ gfxprintf ("\n" );
43574366 ADDRBASE = ADDRBASE + 256 ;
43584367 if (bankcount > 0 )
43594368 ABADDRBASE = ABADDRBASE + 256 ;
@@ -4394,11 +4403,11 @@ void barf_graphic_file(void)
43944403 prinfo ("bank #%d, DMA hole #%d starts @ $%04X" , currentbank + 1 , currentplain , ADDRBASE );
43954404
43964405 if (bankcount == 0 )
4397- printf ("\n ORG $%04X,0 ; *************\n" , ADDRBASE );
4406+ gfxprintf ("\n ORG $%04X,0 ; *************\n" , ADDRBASE );
43984407 else
43994408 {
4400- printf ("\n ORG $%04X,0 ; *************\n" , ABADDRBASE );
4401- printf ("\n RORG $%04X ; *************\n" , ADDRBASE );
4409+ gfxprintf ("\n ORG $%04X,0 ; *************\n" , ABADDRBASE );
4410+ gfxprintf ("\n RORG $%04X ; *************\n" , ADDRBASE );
44024411 }
44034412
44044413 FILE * holefilepointer ;
@@ -5570,7 +5579,7 @@ int getpatternloops(char *patternname)
55705579void songdata (char * * statement )
55715580{
55725581 char data [1001 ]; // allow for long lines
5573- char savepatternname [100 ];
5582+ char savepatternname [200 ];
55745583 char songstatements [200 ][100 ];
55755584 char * wordstart ;
55765585 int s ;
@@ -9530,6 +9539,15 @@ void set(char **statement)
95309539 {
95319540 set_romsize (statement [3 ]);
95329541 }
9542+ else if (!strncmp (statement [2 ], "bankset\0" , 7 ))
9543+ {
9544+ if (!strncmp (statement [3 ], "on" , 2 ))
9545+ {
9546+ strcpy (redefined_variables [numredefvars ++ ], "BANKSETROM = 1" );
9547+ banksetrom = 1 ;
9548+ append_a78info ("set bankset" );
9549+ }
9550+ }
95339551 else if (!strncmp (statement [2 ], "softresetpause\0" , 15 ))
95349552 {
95359553 if (!strncmp (statement [3 ], "off" , 3 ))
@@ -10442,6 +10460,59 @@ void restorescreen(void)
1044210460 jsr ("restorescreen" );
1044310461}
1044410462
10463+ void orgprintf (char * format , ...)
10464+ {
10465+ // orgprintf()
10466+ // printf to stdout. If the bankset format is selected,
10467+ // then *also* printf to the bankset asm file.
10468+
10469+ char buffer [4096 ];
10470+ va_list args ;
10471+ va_start (args , format );
10472+ vsnprintf (buffer , 4095 , format , args );
10473+ va_end (args );
10474+
10475+ printf ("%s" ,buffer );
10476+
10477+ if (banksetrom == 0 )
10478+ return ;
10479+
10480+ FILE * banksetout ;
10481+ banksetout = fopen (BANKSETASM ,"ab" );
10482+ if (banksetout == NULL )
10483+ prerror ("Couldn't open bankset assembly file %s for update\n" ,BANKSETASM );
10484+ fprintf (banksetout , "%s" , buffer );
10485+ fclose (banksetout );
10486+ }
10487+
10488+ void gfxprintf (char * format , ...)
10489+ {
10490+ // gfxprintf()
10491+ // print the gfx assembly code to *either* stdout or the bankset assembly file,
10492+ // (depending if banksets are selected or not)
10493+
10494+ char buffer [4096 ];
10495+ va_list args ;
10496+ va_start (args , format );
10497+ vsnprintf (buffer , 4095 , format , args );
10498+ va_end (args );
10499+
10500+ if (banksetrom == 0 )
10501+ {
10502+ printf ("%s" ,buffer );
10503+ return ;
10504+ }
10505+
10506+ FILE * banksetout ;
10507+ banksetout = fopen (BANKSETASM ,"ab" );
10508+ if (banksetout == NULL )
10509+ prerror ("Couldn't open bankset assembly file %s for update\n" ,BANKSETASM );
10510+ fprintf (banksetout , "%s" , buffer );
10511+ fclose (banksetout );
10512+ }
10513+
10514+
10515+
1044510516void prinfo (char * format , ...)
1044610517{
1044710518 char buffer [1024 ];
0 commit comments