Jump to content

Recommended Posts

I'm looking for advices to make games bigger than 32k.

 

Any source codes will be fine.

Share this post


Link to post
Share on other sites

This thread here helped me get Megacart working:


The gamopat link that nanochess helped me out.  It's in French, and I had to use Google tran- I think you know French, so you should be ok.  Be sure to grab cvmkcart.exe and the example.

 

I had to install cygwin, PkK have a tutorial on how to use cygwin and what file to download.  http://www.colecovision.eu/ColecoVision/development/tutorial0.shtml

You may already have sdcc installed if you're using windows.  After getting Cygwin working, you can check if it is installed by typing sdcc -v.  I have no idea how to do Linux stuff and how to untar and install.  Just make sure to use slash and not backslash to type in the path like in Microsoft DOS.  I used window Run dialog box to make the ROM using cvmkcart.exe. 

I was only successful making 128KB and 256KB ROMs.  I tried 64KB but didn't really work.  I split my game up into 8 source code, 1 per bank. 

  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, Kiwi said:

This thread here helped me get Megacart working:


The gamopat link that nanochess helped me out.  It's in French, and I had to use Google tran- I think you know French, so you should be ok.  Be sure to grab cvmkcart.exe and the example.

 

I had to install cygwin, PkK have a tutorial on how to use cygwin and what file to download.  http://www.colecovision.eu/ColecoVision/development/tutorial0.shtml

You may already have sdcc installed if you're using windows.  After getting Cygwin working, you can check if it is installed by typing sdcc -v.  I have no idea how to do Linux stuff and how to untar and install.  Just make sure to use slash and not backslash to type in the path like in Microsoft DOS.  I used window Run dialog box to make the ROM using cvmkcart.exe. 

I was only successful making 128KB and 256KB ROMs.  I tried 64KB but didn't really work.  I split my game up into 8 source code, 1 per bank. 

Thanks Kiwi. I will take a look at it.

 

Yeah. French is my native language.

 

Share this post


Link to post
Share on other sites

I don't tend to follow the trends, but you can also take a look at my tutorial. It's a bit old, I don't know if my modified linker works with the current version of SDCC. It's the technique used for Mario Bros and (eventually) Super Space Acer. ;)

 

https://www.harmlesslion.com/software/switching

 

Share this post


Link to post
Share on other sites

I use sdldz80 included with makemegacart.exe. I put original sdldz80 in backup directory.

 

I get error when compiling and nothing happens when using makemegacart.exe

 

 

Share this post


Link to post
Share on other sites

Well... your CRT0 failed to assemble. You can't ignore the error messages. If you look, the crt0.ihx is not in the folder at all as a result.

 

The error is that there is an unknown symbol on lines 77 and 78. If it's still the same crt0 I provided, then those are the calls to _vdpinit, and _main. However, they shouldn't be failing until the link stage... is your IDE there trying to build a full program from the one file?

 

I don't recognize the IDE there, but it's possible something has changed in the SDCC assembler since I released my package. In my example I'm using assembler flags -plosgff, I don't see any flags on your command line. p is just disable listing pagination, l is create .lst file, o is create object (rel) file, s is create symbol (sym) file, g is make undefined symbols global, and ff is flag relocatable references by mode in the listing. At the very least, it's probably the absence of g that is causing the error.

 

While I appreciate that you set up the command line nicely in the shortcut, if you want to see error messages from console applications you should run them in the console. The shortcut is a neat idea for when it's all working, but not helpful for troubleshooting. It would likely outright tell you that the input file is missing.

 

 

 

Share this post


Link to post
Share on other sites

I don't think you can make a Megacart using CCI2 or CCI3.  You'll need a command-line program that lets you type in command how to compile the source code.  The main source code is fine, but you'll need to split up source code into 8 source codes if you're using 128KB. 

 

CCI3 is fine for 32KB program, I still use it.  If I'm going Megacart, I use Cygwin.  I'm not sure if there's any other command-line program that can interface with SDCC. 

CCI3 fine with, sdcc -c -p -mz80 --vc --no-std-crt0 vanguardmain.c  
 

The problem is defining the code/graphic to specific bank, the command,
sdcc -c -mz80 --vc --no-std-crt0 --constseg bank1 --codeseg bank1 vnbank1.c
which CCI3 can't do.

Once you get all 8 source code compiled, you need to link them like,
sdcc -mz80 --no-std-crt0 -Wl-b_bank1=0xc000 -Wl-b_bank2=0xc000 -Wl -b_bank3=0xc000 -Wl -b_bank4=0xc000 -Wl -b_bank5=0xc000 -Wl -b_bank6=0xc000 -Wl -b_bank7=0xc000 --code-loc 0x8048 --data-loc 0x7000 ../crtcv.rel ../cvlib.lib ../getput.lib ../comp.lib vanguardmain.rel vnbank1.rel vnbank2.rel vnbank3.rel vnbank4.rel vnbank5.rel vnbank6.rel vnbank7.rel

Lot's of typing yes, but Cygwin saves your most recent entries, I think it's capped at 50 entries.  CCI3 can't link them automatically.  Also, you can copy and paste from Cygwin, which msdos command line I don't think can do.

 

And you need to make a ROM, cvmkcart.exe I use to generate 128KB ROM,
C:\sdcctest\Vanguard2\cvmkcart.exe -icrtcv.ihx -b6 Vanguard.rom
I type this in Window's Run box.  It remembers about 20-30 entries, so you can type it only once.  I have Run command pinned to my taskbar. 

Keep in mind on switching bank.  Select the correct bank before jumping to the data/code. 

Here's the definition to add to your main source code.
 

unsigned char dummy;
#define SWITCH_IN_BANK0		{ dummy=(*(volatile unsigned char*)0xFFF8); } 
#define SWITCH_IN_BANK1		{ dummy=(*(volatile unsigned char*)0xFFF9); } 
#define SWITCH_IN_BANK2		{ dummy=(*(volatile unsigned char*)0xFFFa); } 
#define SWITCH_IN_BANK3		{ dummy=(*(volatile unsigned char*)0xFFFb); } 
#define SWITCH_IN_BANK4		{ dummy=(*(volatile unsigned char*)0xFFFc); } 
#define SWITCH_IN_BANK5		{ dummy=(*(volatile unsigned char*)0xFFFd); } 
#define SWITCH_IN_BANK6		{ dummy=(*(volatile unsigned char*)0xFFFe); } 
#define SWITCH_IN_BANK7		{ dummy=(*(volatile unsigned char*)0xFFFf); } 

Good luck.
 

Share this post


Link to post
Share on other sites

It's a lot of typing, but a simple makefile or even a batch file will save you from doing it more than once. ;)

 

  • Like 1

Share this post


Link to post
Share on other sites
On 5/18/2020 at 4:00 PM, Tursi said:

It's a lot of typing, but a simple makefile or even a batch file will save you from doing it more than once. ;)

 

I don't know computer enough to makefile or make a batch file.  ;)

4 hours ago, alekmaul said:

or just use my lib ;) :P !

Hard for this old dog(me) to learn new tricks, even though I'm not in my 40s yet. ;)  I will look into it and have F18A material ready. :)

Share this post


Link to post
Share on other sites
11 hours ago, Kiwi said:

I don't know computer enough to makefile or make a batch file.  ;)

Nonsense.

 

You type the exact same commands you are typing into the command prompt into a text file, save it with a ".bat" extension, and you just made a batch file. ;)

 

  • Like 1

Share this post


Link to post
Share on other sites
On 5/21/2020 at 11:36 PM, Kiwi said:

I don't know computer enough to makefile or make a batch file.  ;)

Hard for this old dog(me) to learn new tricks, even though I'm not in my 40s yet. ;)  I will look into it and have F18A material ready. :)

You know, I'm 53 years old man :P :D !

  • Haha 1

Share this post


Link to post
Share on other sites
14 hours ago, alekmaul said:

You know, I'm 53 years old man :P :D !

48 here! Gotta pass on the tricks to the young'uns! ;)

 

@kiwi No shame in sticking to what you know, but little things like that will make life easier when you go away and come back the next day, and don't have to type the commands again. I used batch files for years before finally learning enough Makefile to make use of them - the primary advantage driving me there being that make will skip files it doesn't need to rebuild. Sometimes I still write batch files instead of a Makefile. I'm still skeptical of a lot of build systems - for instance we use cmake at work which looks incredibly complex on the surface. I can see it has some value for large projects but I doubt I'll ever use it personally. ;)

 

Share this post


Link to post
Share on other sites
Posted (edited)

Ok. I give it another try today.

 

main.c

Spoiler

// example 1 - a simple Hello World with banked data

// bank switching helpers! To switch banks, we just read the magic address
// bank0 (which is the fixed bank) can be selected with 0xffff
// bank1 can be selected with 0xfffe
// bank2 can be selected with 0xfffd
// ... and so on!
#define SWITCH_IN_BANK1    (*(volatile unsigned char*)0)=(*(volatile unsigned char*)0xfffe);
#define SWITCH_IN_BANK2    (*(volatile unsigned char*)0)=(*(volatile unsigned char*)0xfffd);

// sound access (for initialization)
volatile __sfr __at 0xff SOUND;

inline void MUTE_SOUND() { 
    SOUND=0x9f;        // mute chan 1 
    SOUND=0xbf;        // mute chan 2
    SOUND=0xdf;        // mute chan 3
    SOUND=0xff;        // mute noise 
}

// VDP access
// Read Data
volatile __sfr __at 0xbe VDPRD;
// Read Status
volatile __sfr __at 0xbf VDPST;
// Write Address/Register
volatile __sfr __at 0xbf VDPWA;
// Write Data
volatile __sfr __at 0xbe VDPWD;

// helper for VDP delay between accesses
inline void VDP_SAFE_DELAY() {    
__asm
    nop
    nop
    nop
    nop
    nop
__endasm;
}

// helper for register writes
inline void VDP_SET_REGISTER(unsigned char r, unsigned char v) {
    VDPWA=(v); 
    VDP_SAFE_DELAY();
    VDPWA=(0x80|(r)); 
    VDP_SAFE_DELAY();
}
inline void VDP_SET_ADDRESS_WRITE(unsigned int x) {    
    VDPWA=((x)&0xff); 
    VDP_SAFE_DELAY();
    VDPWA=(((x)>>8)|0x40); 
    VDP_SAFE_DELAY();
}

// now that we are printing multiple strings, just a helper function for that
void writeString(unsigned int adr, const char *p) {
    // Note: this example is not meant to teach Coleco programming, but
    // it is critical that an NMI does not access the VDP while a loop like
    // this executes. This sample is safe because the NMI function is a nop
    // which never clears the VDP status byte. As a result the interrupt
    // fires once and then never again, and even if it did, the NMI handler
    // doesn't touch the VDP, so this remains safe.
    VDP_SET_ADDRESS_WRITE(adr);
    while (*p) {
        VDPWD = *(p++);
        VDP_SAFE_DELAY();
    }
}

// references to the data (which is stored in separate banks!)
extern const char * const strBank1;
extern const char * const strBank2;

// ** Main entry point **
void main() {
    // on entry, the VDP is set up, the audio is muted, so all we need to do is
    // write our strings

    // since the data is in another switched bank, but we are in the fixed bank,
    // all we need to do is select the correct bank before we access the data
    SWITCH_IN_BANK1;
    writeString(0x1800+80+4, strBank1);

    // and same for the other string
    SWITCH_IN_BANK2;
    writeString(0x1800+120+4, strBank2);

    // loop forever, or till reset
    for (;;) { }
}

// the crt0 calls this function to initialize the VDP and sound
// we use it to set up a simple 40 column text mode- setting match 
// the BIOS setup so we don't need to load a character set - if 
// you don't have a BIOS this example won't likely work.
void vdpinit() {
    unsigned int idx;
    const char *p = (const char*)0x15A3;            // address of BIOS character set (assumed)

    // mute the sound chip
    MUTE_SOUND();

    // set up the VDP 
    VDP_SET_REGISTER(0x00, 0);
    VDP_SET_REGISTER(0x01, 0xf0);    // VDP_MODE1_16K | VDP_MODE1_UNBLANK | VDP_MODE1_TEXT | VDP_MODE1_INT
    VDP_SET_REGISTER(0x02, 0x06);    // screen image table at 0x1800
    VDP_SET_REGISTER(0x04, 0x00);    // pattern table at 0x0000
    VDP_SET_REGISTER(0x07, 0xf4);    // white text on dark blue

    // copy in the character set
    VDP_SET_ADDRESS_WRITE(0x0000+0x0100);        // the character set starts with space, 32 chars in
    for (idx = 0; idx < 96*8; idx++) {            // 96 characters to copy
        VDPWD = *(p++);
        VDP_SAFE_DELAY();
    }

    // clear the screen
    VDP_SET_ADDRESS_WRITE(0x1800);
    for (idx = 0; idx<960; idx++) {
        VDPWD = ' ';
        VDP_SAFE_DELAY();
    }
}

 

text1.c

Spoiler

// define a static string in ROM
const char * const strBank1 = "Hello from Bank1";

 

text2.c

Spoiler

const char * const strBank2 = "Hello from Bank2";

 

The directory

compile2.thumb.png.7802d0cfa76a73868dfd8f598bdb8b97.png

 

Here the result

compile1.thumb.png.3ea5dea08a37f3153d0ab4f99c1cc961.png

 

After take a look, I noted crt0.lhx is missing.

 

I tried with crtcv.lhx. It compiled but with a 32k rom instead.

 

I checked the package but I can't find crt0.lhx either.

Edited by Serguei2
typo

Share this post


Link to post
Share on other sites

Does the bank itself need these flags?  --constseg bank1 --codeseg bank1

Share this post


Link to post
Share on other sites
Posted (edited)

Kiwi's comment about the flags is correct. Also, you need to assemble crt0.s -- that's a separate source file and a separate step that generates the crt0.rel

 

The examples you are trying to run come with a Makefile -- did I miss why are you not using that and just typing "make"?

 

Anyway, it looks like you are trying to build either example1 or example2...

 

If you don't have make and don't want to install one, you can read the Makefile to learn how to manually build the tool. It's a worthwhile skill to pick up (although installing make is too ;) ).

 

Here's the breakdown from example1 - it's going to be long:

 

# example1 -- this builds a simple project with three banks
# (fixed, and two data banks) and displays a string from each

CC = sdcc
CFLAGS = -mz80 -c --std-sdcc99 --opt-code-speed
AS = sdasz80
AFLAGS = -plosgff

 

This just defines some variables which are used later in a simplified manner. Anytime you see, for instance, $(AS), you come back up here and replace it with the value set here for "AS". And that's true for all the others too.

 

.PHONY: all clean

 

This just tells make that the commands "all" and "clean" don't need any checks, and should always run when asked for. Other commands will check the input list to see if anything has changed and if not, they will be skipped.

 

# crt0 must be first! (note this is also why the output is named crt0.ihx)
# list all your object files in this variable
# note that the order of the banks is not important in this line
objs = crt0.rel main.rel text1.rel text2.rel

 

This is just another assignment to "objs", with some comments prefaced by #. In this case, it's defining the list of object files which much be built -- an object file is the output of the compiler or the assembler (and the input is source code). In this case we can see 4 files are expected to be built.

 

# this rule calls makemegacart to do the final build of the ROM
all: buildcoleco
    makemegacart.exe -map crt0.s crt0.ihx example1.rom

 

A makefile "rule" is a name followed by a colon. The colon is followed by a list of source requirements - which can be files to check for changes, or other rules to build first. On the following lines, indented by a tab, are the commands to run.

 

This is a special rule called "all", which is what runs if you type make with no command. It requires 'buildcoleco' to be run first, and it has a single command, the "makemegacart.exe" line.

 

# this rule links the files into the ihx
buildcoleco: $(objs)
    $(CC) -mz80 --no-std-crt0 $(BANKS) --code-loc 0x8100 --data-loc 0x7000 $(objs)

 

This defines the "buildcoleco" rule, and it is dependent upon everything listed in the "objs" variable above. So for each of those files, make will look for a rule to create it, all of which DO exist in this file.

 

# banks - all defined the same way, we just need to declare them
BANKS = "-Wl -b_bank1=0xc000" "-Wl -b_bank2=0xc000"

 

This should really be at the top of the file, but I guess it works even late. It just defines a variable named 'BANKS' with the text you see there. It's used in the buildcoleco rule just to simplify the line.

 

# clean up the build
clean:
    -rm *.rel *.map *.lst *.sym *.asm *.ihx *.rom

 

This defines a rule named 'clean', so you can do a "make clean" and it will delete all the temporary and output files.

 

# build the crt0 startup code
crt0.rel: crt0.s
    $(AS) $(AFLAGS) crt0.rel crt0.s

 

This tells make how to build "crt0.rel", and tells it to check "crt0.s" as the input file (make knows its a file because there is no matching rule). It uses the "AS" variable to run the assembler with the switches in "AFLAGS".

 

# build the source files
main.rel: main.c
    $(CC) $(CFLAGS) -o main.rel main.c --codeseg main --constseg main

text1.rel: text1.c
    $(CC) $(CFLAGS) -o text1.rel text1.c --codeseg text1 --constseg text1

text2.rel: text2.c
    $(CC) $(CFLAGS) -o text2.rel text2.c --codeseg text2 --constseg text2

 

And this builds the three source files.

 

Now, there are lots of switches involved in these commands for getting the addresses right - but the examples should have come with a PDF - it's a tutorial - that covers all of them.

 

Anyway, from this we can sort of walk backwards through the Makefile to see what your commands needed to build are.

 

crt0.rel : (this is the one you missed)

sdasz80 -plosgff crt0.rel crt0.s

 

the three C files (you are missing the segment name flags and C switches, although the two you missed are optional)

sdcc -mz80 -c --std-sdcc99 --opt-code-speed -o main.rel main.c --codeseg main --constseg main

sdcc -mz80 -c --std-sdcc99 --opt-code-speed -o text1.rel text1.c --codeseg text1 --constseg text1

sdcc -mz80 -c --std-sdcc99 --opt-code-speed -o text2.rel text2.c --codeseg text2 --constseg text2

 

Then you need this final step to link it all together - this creates the ihx file.

sdcc -mz80 --no-std-crt0 "-Wl -b_bank1=0xc000" "-Wl -b_bank2=0xc000" --code-loc 0x8100 --data-loc 0x7000 crt0.rel main.rel text1.rel text2.rel

 

Finally, the makemegacart call:

makemegacart.exe -map crt0.s crt0.ihx example1.rom

 

So, you could make your batch file just those 6 lines:

 

sdasz80 -plosgff crt0.rel crt0.s

sdcc -mz80 -c --std-sdcc99 --opt-code-speed -o main.rel main.c --codeseg main --constseg main
sdcc -mz80 -c --std-sdcc99 --opt-code-speed -o text1.rel text1.c --codeseg text1 --constseg text1
sdcc -mz80 -c --std-sdcc99 --opt-code-speed -o text2.rel text2.c --codeseg text2 --constseg text2

sdcc -mz80 --no-std-crt0 "-Wl -b_bank1=0xc000" "-Wl -b_bank2=0xc000" --code-loc 0x8100 --data-loc 0x7000 crt0.rel main.rel text1.rel text2.rel

makemegacart.exe -map crt0.s crt0.ihx example1.rom

 

I'm a little confused, though... are you trying to follow my tutorial without following my tutorial? makemegacart will only work if you successfully replaced the SDCC linker (sdldz80.exe), and I haven't tested if the newest versions work with that one...

 

ColecoVisionMegacartBanking.pdf

 

http://harmlesslion.com/software/coleco

 

 

Edited by Tursi
  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...