uc65, a Mid-Level Language Compiler READY FOR USE!

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
infiniteneslives
Posts: 2100
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by infiniteneslives » Mon Nov 25, 2013 8:15 pm

lidnariq wrote:
qbradq wrote:As of this post you can order Color Dreams (#11)
To be fair, he says he can make any of the discrete mappers. He's just only had demand so far for the color dreams board. And there's only 50¢ difference between what he charges for the MMC1 and discrete logic reproductions.
TL;DR: I'm working to make NROM and discrete mapper fully assembled flash boards more efficiently than my current means. I can make any of these on request, just send me a PM email of what you'd like and we can discuss specifics of that board/mapper.

Yeah I haven't focused a lot on getting the discrete mappers to market a whole lot up to this point. The colordreams was requested by several people so I put it up even though I hadn't specifically designed support for it with my v1 eprom boards. After completing my v2 flash boards I recognized I kind of neglected the idea of a simple flashable discrete mapper board. I just ordered another batch of my smaller v2 full flash boards that'll be available in ~month. I added jumpers for cutting the flash down to NROM size and also have BNROM support. I've had a lot of requests for a simple flashable boards for discrete mappers and NROM as of late with more people becoming aware of my projects. Today I've come to realize it would make things simpler to just have a dedicated NROM/Discrete mapper flash board. That'll keep things cleaner from a manufacturing standpoint and allow for significantly fewer jumpers. Not sure when I'll have those ready, but I'm hoping for early next year. I can make any of these boards today fully assembled with flash or in a eprom version. The flash versions just wouldn't be as efficient as I'd like in the end. Sorry I'm realizing that may have made things even more complicated... ;)
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by qbradq » Tue Nov 26, 2013 6:45 am

I do try to be fair to INL. I'm a big cheer-leader for him :) But when folks ask me "what do I buy", I try to only talk about what's available for order on the site today.

slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by slobu » Tue Nov 26, 2013 8:15 am

I know not what I speak of so please forgive me.

It sounds like mapper 11 + uc65 is the way to go. Some of the examples mentioned use MMC3 though. Is there going to be a difference to the end user (me)? For instance, when I have to switch banks will I have to implement different code?

I may be spoiled because in batari BASIC switching banks is as easy as:

if hp = 0 then goto gameover bank2

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by qbradq » Tue Nov 26, 2013 9:41 am

In uc65 you'll have to implement different code to target different mappers. As of today I don't have any of the memory mappers implemented as libraries because I haven't quite gotten around to it yet :) Let me know which ones you want and I'll make them a priority.

Color Dreams has no fixed PRG bank, and I don't have any examples for that type of setup yet. That gets a bit interesting :)

So here's the basic pattern. First, declare the data or code you wish to bank swap in the swap-able bank. For instance, a 128KB UNROM board would have bank 7 as the fixed upper bank, and banks 0-6 swap-able.

Code: Select all

rom 0
export sub level1BossAI
end sub
rom 1
export sub level2BossAI
end sub
Then you'd need to call a bank swap routine for the memory mapper from the fixed bank and call the banked sub.

Code: Select all

rom 7
export sub main
  if level == 1
    uxromBank 0
    level1BossAI
  else if level == 2
    uxromBank 1
    level2BossAI
  end if
end sub
There's better ways of doing the above, but it serves as a hello world type of example.

So now, I suppose I'd better get on the stick with implementing mapper support, examples and tutorials :) Thanks for the push Slobu!

slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by slobu » Tue Nov 26, 2013 11:16 am

I think you're on a roll. Infinitelives too. This could be the one-two punch that gets many more game makers to express themselves on the NES.

One suggestion: can "export" be changed to "declare"? It's a little more expressive and alot more friendly to people coming from BASIC :)

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by qbradq » Tue Nov 26, 2013 1:18 pm

Well, for the same reasons I didn't want to model the language too closely to C, I'm trying not to make it too close to BASIC so folks won't get freaked out when things like for and multiply don't work. Changing the compiler would be a lot easier than changing the examples and documentation though :)

Also, please understand that uc65 is not targeted at novice users. It's really an assembler on steroids, and requires a deep understanding of the hardware and underlying cc65 tool-chain to use effectively. If you want something that's more friendly, there's cc65 itself which implements a fairly complete C implementation, and has been used successfully on several projects.

Here's Shiru's article on the subject which links to basic texts to get you going, and then dives into the finer points of how to make things more efficient.

The only down sides to cc65 are that 1) with great power comes great complexity, and code that isn't as fast or small as it could be, and 2) it doesn't deal with banking at all. But those are the trade-offs you make for the ease of development. This project was started in response to these issues, to explore if it was possible to eliminate the trade-offs while keeping the ease of development. As it turns out, no, no it's not. uc65 is much harder to develop in than C, but much easier than assembly (once you know it anyway). The generated code is faster and smaller than what comes out of cc65, but not quite as good as what you can do by hand.

I think uc65 may be a useful tool because it tightly integrates with inline assembly, handles banked data, code and variables and is well documented.

These may or may not fit your needs or use cases.

slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by slobu » Tue Nov 26, 2013 2:29 pm

I appreciate the fair warning about my own expectations. I've read this topic enough to realize you had some of your own internal struggles as to what uc65 is.

From what I've seen of your code here and in the main.uc examples it's almost exactly like batari BASIC for the Atari 2600. BASIC is about clarity - functionality without getting bogged down in syntax and form. I think you've got a great start.

Maybe I just don't get what the key word "export" means in C and asm. Now that I take a closer look it seems that it's used to do more than declare a sub-routine?

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by qbradq » Tue Nov 26, 2013 5:10 pm

The export keyword makes whatever it applies to, be that a type, variable or subroutine, visible from other source files that use the import statement to reference the source file that defines them. This is how uc65 supports splitting your code into multiple files as well as encapsulation.

At the lower level, variables and subroutines defined with the export keyword also receive exports in the generated assembly files, which makes them visible to other assembly files at link-time without having to reference the source code. This is how C implements static libraries.

User avatar
infiniteneslives
Posts: 2100
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by infiniteneslives » Tue Dec 03, 2013 2:26 am

So I'm writing up a "Getting started with uc65 for Dummies" doc. I've found the simple setup stuff can be daunting/near impossible for someone who's never compiled anything before or has limited experience with this stuff. So hopefully my guide will help out the average dude running on ~windows7.

I've been able to create .nes files on my windows machine using shiru's .bat files after using uc65 to compile the .s files and everything. But I'm trying to see if I can get bash running on my windows machine in order to use the provided (or similar) make.sh file.

I'm giving this guy a try: http://win-bash.sourceforge.net/

I got bash running but the initial problem was due to the double brackets? My bash scripting is a little rusty here... So I figured I'd just toss out what I've got and see if you can help me out here getting things going.

Code: Select all

C:\Users\Paul\Dropbox\nesdev\uc65-release-0.5-rc3>bash make.sh
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: : command not found
make.sh: : command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
make.sh: [[: command not found
C:\PROGRA~2\SHELLW~1\find.exe: /lib/: No such file or directory
C:\PROGRA~2\SHELLW~1\find.exe: /lib/: No such file or directory
Error: Unable to access jarfile /uc65.jar
make.sh: option not availible on this NT BASH release
make.sh: fork: No such file or directory
I replaced all double brackets with single brackets, and looks a little better:

Code: Select all

C:\Users\Paul\Dropbox\nesdev\uc65-release-0.5-rc3>bash make_paul.sh
make_paul.sh: ${BASH_SOURCE[0]}: bad substitution
make_paul.sh: [: missing `]'
make_paul.sh: : command not found
make_paul.sh: : command not found
make_paul.sh: 10075696: No such file or directory
But now I'm having trouble with referencing the UC65_HOME...

Code: Select all

if [ -z "$UC65_HOME" ]; then
	UC65_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
Any suggestions? Perhaps it's a lost cause trying to get a bash makefile up and running on windows?
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers

lidnariq
Posts: 9506
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by lidnariq » Tue Dec 03, 2013 2:51 am

UC65_HOME should be set to the path of the directory containing uc65.jar

I'd probably recommend using the bash that's part of mingw; it's comparatively modern (while win-bash is bash 1.14 !) I'm not certain how to go about debugging the differences.

tepples
Posts: 22017
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by tepples » Tue Dec 03, 2013 6:57 am

infiniteneslives wrote:I'm giving this guy a try: http://win-bash.sourceforge.net/
Have you tried MSYS bash?

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by cpow » Tue Dec 03, 2013 7:23 am

infiniteneslives wrote:So I'm writing up a "Getting started with uc65 for Dummies" doc. I've found the simple setup stuff can be daunting/near impossible for someone who's never compiled anything before or has limited experience with this stuff. So hopefully my guide will help out the average dude running on ~windows7.

...

Any suggestions? Perhaps it's a lost cause trying to get a bash makefile up and running on windows?
I thought the whole point of this topic was uc65 was to make it easier for people to get into NESdev than jumping in with the cc65 toolchain. But now 8 pages into this thread we're talking about how it's "daunting/near impossible for someone who's never compiled anything before"? :roll:

I offered to integrate uc65 into NESICIDE, which would give people a platform that would have large amounts of the setup already done and tied up in easy-to-get-started "template projects" that are already available in the tool for ca65- and cc65-based projects. NESICIDE's Windows installers already come with cc65 toolchain and GNU Make for Windows, and it builds/exports its own makefiles for projects, and invokes them. There wasn't any response, though, so I forgot all about it. As I said in that post, I'm all for providing alternatives and trying to make things easier for people...but I myself likely won't be a "user" of uc65 [unless and until I actually get to the point of trying to create something for the NES] so I'd need help/feedback to make sure the integration of NESICIDE and uc65 is useful and "user friendly" -- to address the "daunting/near impossible" concern.

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by qbradq » Tue Dec 03, 2013 8:42 am

There's been a lot of misconceptions about the goals of uc65. The intent was never to provide a user-friendly development environment, it was to provide a more efficient, in terms of development effort, development tool that was reasonably efficient in terms of resource utilization on the target platform. And as I've said countless times, uc65 is a drop-in replacement for cc65 in the tool chain. If you don't know how to compile C sources with cc65, you won't be able to compile uc sources with uc65.

On the subject of make.sh in the recent source release, this requires a recent version of Bash (version 2 at least, preferably version 3+). This was never intended as a full-on build solution, it was just a quickie I threw together for testing purposes because I haven't settled on a build management solution to adopt yet. It will not be supported in the near future.

On the subject of NESICIDE integration, you are free to do as you wish with the sources of uc65. It's all open source. But until I get more of the build management details nailed down it's going to be a moving target.

So there's something to learn here: a lot of folks have the expectation that uc65 should be user-friendly, and a key sore spot on the user-friendliness aspect is the lack of a "go button". As I have said before, I do not want to get into the business of maintaining a build management system, but I will work to include official support for an existing build manager.

Thank you all for your input!

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by cpow » Tue Dec 03, 2013 9:39 am

qbradq wrote:There's been a lot of misconceptions about the goals of uc65.
Mine included. I apologize. MY goal [I have "tool guy disease"] is to try to make it easier for [myself/]people to dev. If uc65 in a NESICIDE environment achieves that, cool.
qbradq wrote:On the subject of NESICIDE integration, you are free to do as you wish with the sources of uc65. It's all open source. But until I get more of the build management details nailed down it's going to be a moving target.
If I understand properly, uc65 is just a JAR that can be invoked by a makefile. Thus, integrating it into NESICIDE isn't really integrating two sources together, just adding a bit of "build manager" infrastructure into that which already exists in NESICIDE's ability to create/execute makefiles to build projects out of assembly-, C-, or [using uc65.jar] uc-source files.
qbradq wrote:So there's something to learn here: a lot of folks have the expectation that uc65 should be user-friendly, and a key sore spot on the user-friendliness aspect is the lack of a "go button". As I have said before, I do not want to get into the business of maintaining a build management system, but I will work to include official support for an existing build manager.
I guess I don't follow what additional work you'd have to do. I just downloaded the package and compiled the example/simple/src/main.uc to see what would happen. I think that should be fairly straightforward to integrate. Guess I'll go give it a try... I might be able to give you that "go button" pert quick. :beer:

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Re: uc65, a Mid-Level Language Compiler READY FOR USE!

Post by qbradq » Tue Dec 03, 2013 10:28 am

That'd be awesome cpow! :) But yea, if you have an existing makefile for cc65, you can define another rule that builds .s files from .uc files and that's that. There's even a make-style dependency generation flag for uc65.

Post Reply