Jump to content
IGNORED

atari7800 target is now officially in cc65


karri

Recommended Posts

There is now an official cc65 target for atari7800 in the main repository (cc65/cc65: cc65 - a freeware C compiler for 6502 based systems (github.com)).

 

When time permits I plan to add some basic useful stuff like a joystick driver and a clock().

 

There is still no samples of how to use it in the repo.

 

The fact is that a real game will probably want to modify the DLL lists all the time. So there is not much point in creating a demo game in the cc65.

 

What could be nice is to create a conio target automatically if you start outputting text on the screen. At least this would make a "Hello World!" example to work without any need to understand DLL's.

#include <atari7800.h>
#include <conio.h>

void main() {
    cprintf("Hello World!");
    while (1)
        ;
}

 

  • Like 9
  • Thanks 3
Link to comment
Share on other sites

  • 2 weeks later...

Currently I also have the interruptor logic and the clock() function in the official cc65 repo.

 

I am planning to add a standard joystick driver that would default to 7800 two button joysticks but if it detects a 2600 joystick it reverts to 2600 mode.

 

I wonder if someone could test this rfk stuff with a real 7800 joystick and a 2600 joystick?

 

rfk.a78

  • Like 4
Link to comment
Share on other sites

The new functions available for cc65 programs are:

 

unsigned char get_tv()

 

It returns 0 for NTSC and 1 for PAL.

 

clock_t clock()

 

returns number of frames since start of the program.

 

clock_t _clocks_per_sec()

 

returns either 60 or 50.

 

In order for the clock() to work this way you need to have 2 NMI interrupts per frame. One when the display to screen starts and another when it ends.

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, karri said:

Currently I also have the interruptor logic and the clock() function in the official cc65 repo.

 

I am planning to add a standard joystick driver that would default to 7800 two button joysticks but if it detects a 2600 joystick it reverts to 2600 mode.

 

I wonder if someone could test this rfk stuff with a real 7800 joystick and a 2600 joystick?
32.13 kB · 1 download

Now I have a dual joystick driver. This one should work with two joysticks plugged in at the same time. But both joysticks need to be of same type.

 

You can press right button on the main menu. On other levels only left button works.

rfk.a78

  • Like 2
Link to comment
Share on other sites

On 3/31/2022 at 8:28 PM, gambler172 said:

Hi Karri

checked with a two button controller.

Left button can be pressed one time....when press again left button, it returns to the titlescreen again.

Right button can be pressed only one time.....if press right button again, nothing happens.p

Hope this is helpful.

Yep! That is how I coded it. The Right button only works on the main menu screen. I already made a pull request to cc65.

  • Like 1
Link to comment
Share on other sites

The stdjoy is now part of cc65. So you can use it by:

#include <atari7800.h>
#include <joystick.h>

joy_install(joy_static_stddrv);

joy = joy_read(JOY_1);
joy = joy_read(JOY_2);

if (JOY_UP(joy)) {}
if (JOY_BTN_1(joy)) {}
if (JOY_BTN_2(joy)) {}

There is also a new pull request for conio for the Atari 7800. After some discussions in the cc65 forum we decided to make a little too primitive implementation. The desire was to allow you to change colours of every individual letter on the screen. As 4k of RAM is so little so I went with the 160A mode and a fixed palette. The downside is that the font looks like this:

testconio.thumb.png.2ec924d14a168249816d76fd8ae6c51e.png

 

So there is just the numbers, capital letters and a few special characters. The font is made of 2 bit per pixel sprites that allows us to present 3 colours.

This is not usable for games but at least you can run tests and sample programs in a simple way. The conio supports lots of primitives like cputc('H'), gotoxy(X,Y), cursor(on).

 

A working program could look like:

#import <atari7800.h>
#import <conio.h>

void main() {
    clrscr();
    gotoxy(4,10);
    cputc('H');    cputc('e');    cputc('l');    cputc('l');    cputc('o');
    while (1) ;
}

 

PS. The reason I am trying to get C to work is that my Wizzy is written in C and I need to get enough primitives to work in order to share code between the Atari Lynx and the Atari 7800 implementations. Slowly getting there...

 

The next thing is the keyboard buttons. SELECT and PAUSE. The difficulty switches are a bit of a mystery to me. Perhaps I just ignore them as they don't fit in any framework.

  • Like 2
Link to comment
Share on other sites

43 minutes ago, Karl G said:

This makes me want to make a tiny ASCII-based C roguelike for the 7800, as silly as that may be.  ?

Lol. I am currently compiling Douglas Adams "Pirate Cove" on it just to find the bugs. The conio part works fairly well already.

 

I might include a flashing cursor also...

 

It may take a week before the final conio is in the main repo.

  • Like 2
Link to comment
Share on other sites

On 4/6/2022 at 9:44 AM, karri said:

Lol. I am currently compiling Douglas Adams "Pirate Cove" on it just to find the bugs. The conio part works fairly well already.

 

I might include a flashing cursor also...

 

It may take a week before the final conio is in the main repo.

Btw, is there a reason that you are not using a characterset with more characters, like the atascii font included with 7800basic?

 

atascii.thumb.png.46cbd4ba39443156564bb2e5b3e93bd9.png

Link to comment
Share on other sites

I just tried to do 2 small changes in the application.

 

Change the palette in the application:

void main(void)
{
        MARIA.bkgrnd = 0x17;
        MARIA.p0c1 = 0x00;
        MARIA.p0c2 = 0xb2;
        MARIA.p0c3 = 0x05;
        joy_install(joy_static_stddrv);

And add lower case characters instead of the red font to the fontmap. You can always link in your own font to replace the stock font in cc65.

The result looks completely different.


1391316018_venure1.thumb.png.03274c969dbc291ece661de2cd198c80.png

  • Like 1
Link to comment
Share on other sites

I am still waiting for the maintainers to merge the atari7800conio branch into cc65. Meanwhile I was playing around with Pirate Cove. One pretty nice feature of making your own drop-in font is the possibility to add lower case characters and also to use multicolour characters (the green/red characters I planned for user inputs).

piratecovefont.png.c360f3806f77a697b43b453774262f6b.png

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

The cc65 maintainers just merged the Atari 7800 conio pull request! So now you can write text using cc65.

 

An example:

#include <atari7800.h>
#include <conio.h>

void main()
{
        clrscr();
        textcolor(0);
        cputs("Hello World.");
        gotoxy(0,1);
        textcolor(1);
        cputs("Hello World.");
        gotoxy(0,2);
        textcolor(2);
        cputs("Hello World.");
        while (1) ;
}

Here we type "Hello World." using three different text colours.

 

If we compile it as:

 

cl65 -t atari7800 --force-import __EXEHDR__ main.c -o hello.a78
sign7800 -w hello.a78

 

the result looks like this:

ColourFont.thumb.png.591c34cd12a8b59a96cf7094ffde1863.png

 

This implementation has only upper case letters. But it has 3 colours and only 20 characters per line.

 

If you decide to compile it as a 320A mode conio you can add a file called atari7800-mono.o that will choose a full font but has no colours and 40 characters per line.

 

cl65 -t atari7800 --force-import __EXEHDR__ atari7800-mono.o main.c -o mono.a78
sign7800 -w mono.a78

 

The result looks like this:

 

MonoFont.png.2f7c85e068ff206f99a843d19d6a56a6.png

 

The cc65 can by downloaded from cc65/cc65: cc65 - a freeware C compiler for 6502 based systems (github.com)

 

You can also link in your own font to replace the font provided by atari7800 conio. In this way you can create game graphics in either mode.

 

There is no keyboard driver for reading the push buttons and difficulty switches. But you can do it like this:

 

static unsigned char readselect()
{
        if ((RIOT.swchb & 0x02) == 0) {
                return 1;
        }
        return 0;
}

 

Oh, there is also a blinking cursor that can be toggled on/off with the command.

cursor(0); // off
cursor(1); // on

 

The conio does not do scrolling of text. You need to do that by using memcpy(). The screen is available a

 

extern char screen[];

You can also use '\n' characters to change to the next line. But conio wraps to the start of the screen instead of scrolling.

 

There is another device called stdio that scrolls. But I see no point in implementing it as there is no keyboard.

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...
3 hours ago, Stechmann said:

hi, i have used cc65 for NES coding (using 8bitworkshop ide) and would now like to try some sweet 7800. can someone point me to any tutorials or ebook? i know nothing about atari hardware

The most useful resource I got from @Pat Brady was 7800 Software Guide - 8BitDev.org - Atari 7800 Development Wiki

 

It explains pretty much everything I know about the 7800 today.

 

I have two 7800 public games. One is an text adventure I wrote when I created the cc65 target. The source is pretty messy because I got it from Scott Adams a long time ago. This was called Pirate Cove when I released it.

karri / adventureland — Bitbucket

piratecove.a78

Nyttkuva2023-10-01212236.thumb.png.7c6fde7e073de32e0ebb9bb8e0dbcd5c.png

 

The other is a small really stupid bartender game that I wrote both for the Lynx and the 7800 at the same time.

karri / drunkwitch — Bitbucket

DrunkWitch.a78

Nyttkuva2023-10-01212639.thumb.png.202dc256023c2fd8e41204cb0cb2894f.png

 

If you compile the code in the main directory it will create the game for Atari Lynx. If you do it in the 7800 subdirectory it will create it for the 7800.

 

  • Like 2
  • Thanks 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...