Jump to content
IGNORED

A CC65 binding for Diamond GOS.


Recommended Posts

I almost have ready, a binding to call and utilize Diamond GOS 3.0 functions from the CC65 C compiler (and potentially others like llvm-mos, it is all pointer accesses.)

 

You can get a copy here: 

https://github.com/tschak909/diamond-gos-cc65

 

I wanted to solve one particular issue that I haven't been able to fully extrapolate from existing code and the documentation: The EVENTTYPE structure. This is a very critical area of RAM where the most recent event winds up, to be decoded, and to make anything useful, it needs to be derived. 

 

Does anyone have any documentation on this, before I literally start disassembling the ROM? (such as @areeve?)

Edited by tschak909
Edited to add Github link.
Link to comment
Share on other sites

All of Alan's source disks were dumped and uploaded long ago. I'm assuming you've already looked through the 3.0 Develop manual (which has some info about it) for what you need -- and the 3.0 Develop disks (I haven't looked in these yet).

 

I guess I'd start here first, after that...

 

EVENT.M65

 

Edited by MrFish
Link to comment
Share on other sites

37 minutes ago, MrFish said:

All of Alan's source disks were dumped and uploaded long ago. I'm assuming you've already looked through the 3.0 Develop manual (which has some info about it) for what you need -- and the 3.0 Develop disks (I haven't looked in these yet).

 

I guess I'd start here first, after that...

 

EVENT.M65 14.27 kB · 1 download

 

Yes I have.

-Thom

Link to comment
Share on other sites

It works, just need to fully break the events down into a union of structures.

 

595416015_Screenshotfrom2022-11-1821-03-43.thumb.png.6675a916ebfb6fa4a494973767e20aaf.png

Generated from the following code:

/**
 * Create a single window
 */

#include <gos.h>

void main(void)
{
  gos_init(0);
  gos_windopen(SIZER|HORIZONTAL|VERTICAL|DRAG|FULLER,
	       0,8,
	       39,183,
	       0,
	       "Hello World\xFF",
	       "CC65 Bindings\xFF",
	       0,0,0);

  while (1)
    {
      gos_event();

      if ( EVENTTYPE == 2 ) // window
	{
	  if ( EVENTTYPE2 == 1 ) // closed
	    {
	      gos_windclose();
	      break;
	    }
	}
    }

  gos_exit();
}

 

  • Like 6
Link to comment
Share on other sites

By digging into the Diamond GOS source code, I was able to decode the event structure, and create a union structure that encapsulates the different event types and their parameters.

 

/**                                                                                                               
 * @var EVENTTYPE - Last Event                                                                                     
 */

typedef enum _event_type
  {
    EVENT_NOP,
    ICON,
    WINDOW,
    MENU,
    KEY,
    BACKGROUND
  } EventType;

#define EVENTTYPE (*(EventType *)0x9A93)
  
/**                                                                                                               
 * @var The event structure                                                                                       
 */

typedef union _event
{
  struct _Icon
  {
    unsigned char number; /* Icon Number 0-31 */
    unsigned char rsvd1;  /* not used */
    unsigned char rsvd2;
    unsigned char rsvd3;
    unsigned char rsvd4;
  } Icon;

  struct _Window
  {
    enum _window_event_type
      {
        NONE,
        CLOSER,
        FULLER,
        DRAGGED,
        SIZED,
        SLIDE_X,
        SLIDE_Y,
        IN_WINDOW,
        NEW_WINDOW
      } type;
    unsigned char x; /* X (0-39) */
    unsigned char y; /* Y (0-191) */
    unsigned char rsvd1;
    unsigned char rsvd2;
  } Window;

  struct _Menu
  {
    unsigned char menu; /* Menu # */
    unsigned char item; /* Item # */
    unsigned char rsvd1;
    unsigned char rsvd2;
  } Menu;

  struct _Keypress
  {
    unsigned char key; /* key pressed # */
    unsigned char rsvd1;
    unsigned char rsvd2;
    unsigned char rsvd3;
  } Keypress;

  struct _Background /* Background clicked */
  {
    unsigned char x;
    unsigned char y;
    unsigned char rsvd1;
    unsigned char rsvd2;
  } Background;
} Event;

#define EVENT (*(Event *)0x9A94)

 

This makes the example hello2 program, a lot more readable.

 

/**                                                                                                                   
 * Create a single window                                                                                             
 */

#include <gos.h>

void main(void)
{
  gos_init(0);
  gos_windopen(ADD_SIZER|ADD_HORIZONTAL|ADD_VERTICAL|ADD_DRAG|ADD_FULLER,
               0,8,
               39,183,
               0,
               "Hello World\xFF",
               "CC65 Bindings\xFF",
               0,0,0);

  while (1)
    {
      gos_event();

      if ( EVENTTYPE == WINDOW ) // window                                                                            
        {
          if ( EVENT.Window.type == CLOSER ) // closed                                                                
            {
              gos_windclose();
              break;
            }
        }
    }

  gos_exit();
}

 

Everything checked into GitHub.

 

With this, I can call the bindings done, and this can be used to write Diamond programs in C. 

 

Enjoy,

-Thom

  • Like 7
Link to comment
Share on other sites

I think it's already in a state that the fujinet stuff could be servicable... and since you are working on multiple platforms (Atari 8,Apple,C64, etc etc.....) geos could bridge the apple/atari/commodore fujinet space...

Edited by _The Doctor__
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...