Author Topic: CC65 and the PCE  (Read 5411 times)

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: CC65 and the PCE
« Reply #90 on: December 04, 2015, 06:12:10 PM »
[uldecimal][li]To properly make use of the already existing sound engine built into the CD hardware since they were nice enough to put the damn thing there for us.[/li][/ul]
I've been wondering about this. Is it a sound engine from the CD cards that can be used by CD games, and stripped down so that HuCard games can use it too? Or is it from some kind of devkit library?
The Squirrel readme mentions Hu7/Develo.

Yeah.  The PSG thing is already present if you have the CD hardware (System Card).   When we originally did this, we were making Insanity for PCE CD.   So, it made alot of sense to just use what was there instead of wasting time trying to make our own stuff.

Initially, we had this sort of "on the fly" parse/play thing for MML that at least demonstrated that the idea worked.   It wasn't perfect.  I remember spending alot of time trying to get intervals to work right.   


and yeah, Squirrel simply turns an MML file into the bytecode expected by the PSG driver. 
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

Pokun

  • Full Member
  • ***
  • Posts: 153
Re: CC65 and the PCE
« Reply #91 on: December 04, 2015, 08:39:35 PM »
I see, thanks!

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: CC65 and the PCE
« Reply #92 on: February 04, 2016, 12:10:09 AM »
I've put up another new Windows build of Mednafen (with my changes) for anyone that wants it ...

https://www.dropbox.com/s/9kmh6wiscv411ni/mednafen-0.9.38.7-x86-elmer.zip?dl=0

Just to remind any newcomers to this thread, the modifications are in Mednafen's PCE and PC-FX debugger displays in order to make them a bit more pleasant to look at, and more readable.

This is still a 32-bit version that only supports the PCE and PC-FX.

New features are ...

    Built with the recent Mednafen 0.9.38.7 release.
    Built with latest msys2 GCC compiler in the hope that this might run on Windows 10.


The patch files and a build script are available at ...

https://www.dropbox.com/s/2g6xwo4w4owwkuc/build-msys2-mednafen-0.9.38.7-x86-elmer.zip?dl=0

touko

  • Hero Member
  • *****
  • Posts: 953
Re: CC65 and the PCE
« Reply #93 on: February 04, 2016, 05:56:32 AM »
Downloaded, thanks .

tonma

  • Newbie
  • *
  • Posts: 13
Re: CC65 and the PCE
« Reply #94 on: February 04, 2016, 07:33:38 PM »
Downloaded too. Thanks, I'll try it soon.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: CC65 and the PCE
« Reply #95 on: February 21, 2016, 04:36:37 PM »
I've put up yet-another new Windows build of Mednafen (with my changes) for anyone that wants it ...

https://www.dropbox.com/s/6rpkviyhgihw4gt/mednafen-0.9.38.7-x86-elmer-2.zip?dl=0

Just to remind any newcomers to this thread, the modifications are in Mednafen's PCE and PC-FX debugger displays in order to make them a bit more pleasant to look at, and more readable.

This is still a 32-bit version that only supports the PCE and PC-FX.

New features are ...

    PCE now has 480KB of SCD RAM (banks $44-$7F), plus the 2MB ACD RAM (banks $40-$43).
    PC-FX now has 8MB RAM.

    The extra RAM can be useful during homebrew development as a place to store debugging-info.

    It might also be useful for someone that needs the extra memory for a translation.

    N.B. This is a 32-bit build, but 64-bit Windows builds are now working if someone wants to build it from source.

The patch files and a build script are available at ...

https://www.dropbox.com/s/i3mor256dhrddef/build-msys2-mednafen-0.9.38.7-x86-elmer-2.zip?dl=0

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: CC65 and the PCE
« Reply #96 on: February 21, 2016, 08:26:52 PM »
Rather than sift through this and try to figure out what the hell was going on:

Where's CC65 at with regards to using it instead of HuC for making games?

[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: CC65 and the PCE
« Reply #97 on: February 22, 2016, 04:17:22 AM »
Where's CC65 at with regards to using it instead of HuC for making games?

Short Answer:

It just requires the desire to use it, and the willingness to copy over any HuC library routines that you want to use.

From my POV, that makes it perfectly usable, but I suspect that you've got a different POV.  :wink:

------------------------

Long Answer:

The workflow is definitely going to be different to HuC, because of it is the more-traditional compile/assemble/link style, and because it doesn't have HuC's PCE-specific #incpal/#inctile/#incspr functions.

CC65/CA65 are working perfectly fine as a compiler/assembler.

I've built a test-rom with it to confirm that it compiles standard C code (a FAT32 library for reading the Everdrive's SD card).

It was easy to use and incredibly flexible once you've got your head around the power of its code-layout and startup options.

The point is that it's all configurable and you get to decide where the linker puts the startup-code/library-code/game-code/data.

The guy that was working on the PCE-port hasn't committed anything new in about 4 months. But that's not really a problem since he was definitely a novice on the PCE and was doing some things in a very strange (and wrong) way.

Because it's all "linked", we can just use the bits of his CC65-specific code that we like, and override anything else with new code.

Then, if you want to make a CD, you have to piece-together the .iso binary with something like 'bincat' and then modify the 2nd-sector with your particular

------------------------

Here's my batch file for compiling the test code ...

Code: [Select]
# C files.

cc65 -O -t pce hello.c
cc65 -O -t pce fatfs/ff.c
cc65 -O -t pce fatfs/diskio.c
cc65 -O -t pce fatfs/option/unicode.c

ca65 -t pce -v hello.s
ca65 -t pce -v fatfs/ff.s
ca65 -t pce -v fatfs/diskio.s
ca65 -t pce -v fatfs/option/unicode.s

# ASM files.

ca65 -t pce -v crt0.s
ca65 -t pce -v text.s
ca65 -t pce -v sd.s

# Link

ld65 -o hello.pce -m hello.map -C pce.cfg hello.o text.o sd.o fatfs/ff.o fatfs/diskio.o fatfs/option/unicode.o crt0.o pce.lib

------------------------

I decided to use the following layout for the HuCard ...

The STARTUP & library CODE go in bank $00 that lives at $E000-$FFFF.

The INIT code and the 'initialized' DATA (that get copied to RAM) goes in bank $01 that lives (temporarily) at $C000-$DFFF.

Once the HuCard starts up and my customized crt0.s runs the INIT code, and copies the 'initialized' DATA to RAM, then I map banks $02-$05 into $4000-$DFFF for my main code, and leave $C000-$DFFF for paging code/data as I need to.

Now I'm not saying that this is a particularly great way to lay out a HuCard, but I needed an uninterrupted 32KB for the FAT32 code, and the big point is that I was easily able to do that with CC65.

And here's my customized CC65 configuration file for that layout ...

Code: [Select]
SYMBOLS {
        __STACKSIZE__: type = weak, value = $0300; # 3 pages stack
}

MEMORY {
        # Preserve System Card standard ZP locations.
        ZP: start = $00, size = $ec, type = rw, define = yes;

        # reset-bank and hardware vectors
        ROM0: start = $E000, size = $1FF6, file = %O, fill = yes, define = yes;
        ROMV: start = $FFF6, size = $000A, file = %O, fill = yes;

        ROM1: start = $C000, size = $2000, file = %O, fill = yes, define = yes;
        ROM2: start = $4000, size = $8000, file = %O, fill = yes, define = yes;
        ROM6: start = $C000, size = $2000, file = %O, fill = yes, define = yes;
        ROM7: start = $C000, size = $2000, file = %O, fill = yes, define = yes;

        # First RAM page (also contains stack and zeropage)
        RAM: start = $2200, size = $1E00, define = yes;
}

SEGMENTS {
        STARTUP:  load = ROM0, type = ro,  define = yes;
        INIT:     load = ROM1, type = ro,  define = yes, optional = yes;
        CODE:     load = ROM0, type = ro,  define = yes;
        RODATA:   load = ROM0, type = ro,  define = yes;
        DATA:     load = ROM1, type = rw,  define = yes, run = RAM;
        SDCODE:   load = ROM2, type = ro,  define = yes;
        SDDATA:   load = ROM2, type = ro,  define = yes;
        BSS:      load = RAM,  type = bss, define = yes;
        VECTORS:  load = ROMV, type = rw,  define = yes;
        ZEROPAGE: load = ZP,   type = zp,  define = yes;
        EXTZP:    load = ZP,   type = zp,  define = yes, optional = yes;
        APPZP:    load = ZP,   type = zp,  define = yes, optional = yes;
}

FEATURES {
    CONDES: type    = constructor,
            label   = __CONSTRUCTOR_TABLE__,
            count   = __CONSTRUCTOR_COUNT__,
            segment = INIT;
    CONDES: type    = destructor,
            label   = __DESTRUCTOR_TABLE__,
            count   = __DESTRUCTOR_COUNT__,
            segment = RODATA;
    CONDES: type    = interruptor,
            label   = __INTERRUPTOR_TABLE__,
            count   = __INTERRUPTOR_COUNT__,
            segment = RODATA,
            import  = __CALLIRQ__;
}

EDIT:

I guess that it would help to explain a couple of things in the configuration file (it's for the "LD65" linker).

The "MEMORY" section is basically just a list of areas (and their sizes) that get written to the output file ... in this case I'm having it create an 8 bank HuCard ROM image.

The actual names of the different sections in "MEMORY" can be anything ... I'm just using the name "ROM" + bank-offset for my own convenience.

The "SEGMENTS" section defines the names of the different segments in the C and ASM code (user-defined, but with a few defaults like CODE/DATA/RODATA/RAM), and it shows where in the output file those segments should be put.

That's it ... you have total flexibility to map your code/data into the output HuCard/ISO image in any way that you like.

------------------------
« Last Edit: February 22, 2016, 05:07:37 AM by elmer »

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: CC65 and the PCE
« Reply #98 on: February 22, 2016, 07:02:15 PM »
Ah.  Well, that's straightforwardish. 

And I guess really, the real dilemma for me is the whole Squirrel thing.   lack of chiptunes = how do I games.

Though, I don't think dealing with the CD BIOS to feed Squirrel in would be too hard.

Mapping in all the HuCard version crap might not really be that hard either.   

I'd look, but I don't want to distract myself from finishing this MSX game.

I tend to work serially on things. 
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: CC65 and the PCE
« Reply #99 on: February 22, 2016, 07:28:58 PM »
Quote
And I guess really, the real dilemma for me is the whole Squirrel thing.

Don't worry about it. From what I've seen, we can put the player in whatever page we want, and fix the startup/irq code to handle it. It shouldn't be any worse than the Huc modifications.

My worry is getting the Huc functions to work. Guess I'll install this, and see what I can do..

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: CC65 and the PCE
« Reply #100 on: February 23, 2016, 03:39:53 AM »
Quote
And I guess really, the real dilemma for me is the whole Squirrel thing.

Don't worry about it. From what I've seen, we can put the player in whatever page we want, and fix the startup/irq code to handle it. It shouldn't be any worse than the Huc modifications.

My worry is getting the Huc functions to work. Guess I'll install this, and see what I can do..

It really shouldn't be too hard to get any ASM source transferred over.

It's the subtle changes in syntax that'll annoy you.

Like "TAM #$40" instead of "TAM #6", or the horrible old original "LDA (<$F8),Y" instead of "LDA [$F8],Y".

I might see if I can hack it to accept the square bracket syntax (the TAM syntax doesn't bother me, since that's what Mednafen displays ... although I could always hack that, too).

EDIT:

They do allow "TAM6" instead of "TAM #6".

Looks like it should be easy to change the '(' to a '[', but that will probably kill the assembler's ability to properly deal with the SNES's 65816 24-bit "far" addresses.

I suspect that we don't really care too deeply about that!  :wink:

Oh ... one last thing, the MACRO syntax is totally different.
« Last Edit: February 23, 2016, 04:35:28 AM by elmer »

Gredler

  • Guest
Re: CC65 and the PCE
« Reply #101 on: February 23, 2016, 05:33:02 AM »
Let me just say thank you guys for furthering the tool progression, for non-programmer types like myself it's endlessly helpful to read through your opinions and documentation! Bravo, I owe you guys some beers or sodas!

MooZ

  • Newbie
  • *
  • Posts: 34
Re: CC65 and the PCE
« Reply #102 on: February 23, 2016, 09:09:23 AM »
I started working on a pceas/ca65 stuffs.
The macro syntax is different but you can get something close but not enough to avoid doing the job twice.
Example :
https://github.com/BlockoS/HuDK/blob/master/include/pceas/word.inc
vs
https://github.com/BlockoS/HuDK/blob/master/include/ca65/word.inc

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: CC65 and the PCE
« Reply #103 on: February 23, 2016, 11:21:08 AM »
It's the subtle changes in syntax that'll annoy you.

Like "TAM #$40" instead of "TAM #6", or the horrible old original "LDA (<$F8),Y" instead of "LDA [$F8],Y".

I might see if I can hack it to accept the square bracket syntax (the TAM syntax doesn't bother me, since that's what Mednafen displays ... although I could always hack that, too).

...

They do allow "TAM6" instead of "TAM #6".

Looks like it should be easy to change the '(' to a '[', but that will probably kill the assembler's ability to properly deal with the SNES's 65816 24-bit "far" addresses.

I guess that I should really ask the programmers here ... do you care about this stuff?

In some ways, I don't like the idea of changing CC65 "just-for-the-sake-of-it".

As it is now, it's using the offical syntax for both the HuC6280 and the 65816.

It's pceas that's got the "TAM" wrong, and while I personally find the '[' indirection easier to read than the '(' version, and while there are lots of 6502 assemblers use it ... it's not the "official" syntax.

I think that I can make CA65 accept either syntax (on everything except the 65816) ... but is that an "ugly" hack that just shouldn't be done?

How do you guys feel about it?

MooZ

  • Newbie
  • *
  • Posts: 34
Re: CC65 and the PCE
« Reply #104 on: February 23, 2016, 05:41:35 PM »
I would fix the non standard compiler instead.