Skip to content

Commit c48f706

Browse files
committed
initial bankset support for graphics
1 parent 5a8661c commit c48f706

6 files changed

Lines changed: 140 additions & 24 deletions

File tree

7800bas.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ int main(int argc, char *argv[])
124124

125125
printf("SPACEOVERFLOW SET 0\n");
126126

127+
// these asm files are produced dynamically, so as to allow out-of-order
128+
// assembly with dasm. Their mere presence will affect the compile process
129+
// so we start off by wiping them, if they exist from a previous compile.
127130
remove("7800hole.0.asm");
128131
remove("7800hole.1.asm");
129132
remove("7800hole.2.asm");
133+
remove("banksetrom.asm");
130134

131135
create_a78info(); //wipe/create a78 parameter file
132136

7800basic.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@ if [ "$2" = "-O" ]
6767
7800postprocess$EXT -i "$bas7800dir" > "$1.asm"
6868
fi
6969

70+
7071
dasm$DASMEXT $1.asm -I"$bas7800dir/includes" -f3 -l"$1.list.txt" -s"$1.symbol.txt" -o"$1.bin" | 7800filter$EXT
72+
7173
7800sign$EXT -w "$1.bin"
74+
75+
if [ -r banksetrom.asm ] ; then
76+
dasm$DASMEXT "$bas7800dir/includes/banksetskeleton.asm" -I"$bas7800dir/includes" -f3 -l"banksetrom.list.txt" -s"banksetrom.symbol.txt" -o"banksetrom.bin" | 7800filter$EXT
77+
cat "banksetrom.bin" >> "$1.bin"
78+
fi
79+
7280
7800header$EXT -o -f a78info.cfg "$1.bin"
7381
7800makecc2$EXT "$1.bin"
7482

filter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ char *filterterm[] = {
8383
"^0.topscreenroutine",
8484
"^0.bottomscreenroutine",
8585
"^0.altgamestart",
86+
"^interrupthold",
8687
"_main2 ",
8788
"_main3 ",
8889
"_main4 ",
@@ -132,6 +133,7 @@ char *filterterm[] = {
132133
"^DLMEMSTART",
133134
"^DLMEMEND",
134135
"^pokeysound.asm",
136+
"^pokeyaddress",
135137
"^rmtplayer.asm",
136138
"^fourbitfade.asm",
137139
"^BEADHEADER",

includes/banksetskeleton.asm

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; Provided under the CC0 license. See the included LICENSE.txt for details.
2+
3+
4+
; banksetskeleton.asm
5+
;
6+
; This is the file we assemble to build the second "maria" bankset binary,
7+
; which gets combined with the regular 7800basic generated bin.
8+
9+
#include "7800basic.h" ; brings in 7800.h and 7800basic_variable_redefs.h
10+
11+
ifconst BANKSETROM
12+
13+
#include "7800basicheader.asm"
14+
15+
ROMSTART = .
16+
.byte 0
17+
ORG ROMSTART
18+
19+
NMI = 0
20+
START = 0
21+
IRQ = 0
22+
23+
; this is the dynamic file generated by 7800basic incgraphic and bankswitch
24+
; commands...
25+
#include "banksetrom.asm"
26+
27+
#include "7800basicfooter.asm"
28+
29+
endif ; BANKSETROM

statements.c

Lines changed: 95 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ int tallspritecount = 0;
2828

2929
int currentdmahole = 0;
3030

31+
int banksetrom = 0;
32+
33+
#define BANKSETASM "banksetrom.asm"
34+
3135
int deprecatedframeheight = 0;
3236
int 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

868872
void 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)
55705579
void 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+
1044510516
void prinfo(char *format, ...)
1044610517
{
1044710518
char buffer[1024];

statements.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ void characterset(char **statement);
122122
void savescreen(void);
123123
void restorescreen(void);
124124
void barf_graphic_file(void);
125+
void gfxprintf(char *format, ...);
126+
void orgprintf(char *format, ...);
125127
void barfmultiplicationtables(void);
126128
void append_a78info(char *);
127129
void create_a78info(void);

0 commit comments

Comments
 (0)