Discussion:
CC65 and apple II specific I/O
(too old to reply)
Rich J.
2003-09-04 02:55:20 UTC
Permalink
After much frustration and headaches I got CC65 (C compiler for 6502
systems, including apple II) up and running.

I set up a batch file with the commands to compile, assemble, link,
and then store the object code on a DSK image. It is a nice way to
write Apple II code! Maybe this CC65 will work on PCtransporter?

Is there a way to access HGR, HPLOT,HCOLOR from within a C program? I
am also curious about XDRAW, LOAD, SAVE, OPEN, READ, WRITE. Is there
a document somewhere in which I can read about this stuff? I see
references to Apple I/O in Apple2.o file in CC65 /include directory.

Rich
aiiadict AT hotmail DOT com
http://rich12345.tripod.com
Chris Morse
2003-09-04 19:02:43 UTC
Permalink
Post by Rich J.
After much frustration and headaches I got CC65 (C compiler for 6502
systems, including apple II) up and running.
I set up a batch file with the commands to compile, assemble, link,
and then store the object code on a DSK image. It is a nice way to
write Apple II code! Maybe this CC65 will work on PCtransporter?
Is there a way to access HGR, HPLOT,HCOLOR from within a C program? I
am also curious about XDRAW, LOAD, SAVE, OPEN, READ, WRITE. Is there
a document somewhere in which I can read about this stuff? I see
references to Apple I/O in Apple2.o file in CC65 /include directory.
Rich
aiiadict AT hotmail DOT com
http://rich12345.tripod.com
Hiya,

Yes, you can access those functions. If you are writing under DOS
3.3, I am not sure exactly (yet) how to access (easily) the LOAD,
SAVE, OPEN, READ, WRITE functions. Under ProDOS, use the MLI
interface. I plan on writing a library for ProDOS file I/O using the
MLI calls.

As for the other functions, what you really should do is find a good
source for technical information on the Apple //e. For example, the
Apple //e Technical Reference Manual. Though not easy to find, a lot
of the information in the Apple //c (Yes, "C" not "E") 2nd Edition is
still very applicable, and you can get a copy from www.A2Central.com

Knowing the Monitor entry points for various functions is pretty
important. Actually, I'm looking at my //c Tech Ref Manual, 2nd
Edition, and I don't see any of the firmware entry points for Hi-Res
graphics. Seems to only list the Lo-Res routines. Hmm.. Well, the
following examples I figured out from looking in the book "Apple
Graphics & Arcade Game Design" by Jeffrey Stanton.

Hope this helps! Eventually, I'd like to write a nice little library
for CC65 with all these functions ready to go.

// CHRIS



EXAMPLES:

HGR is at $F3E2

In CC65, you can call this with this code:

__asm__ ("JSR $F3E2"); /* HGR : Set Graphics Mode */


HCOLOR is at $F6F0

To call this, you load the X register with the color you want.
In CC65, you can call this with this code:

__asm__ ("LDX #3"); /* COLOR=WHITE */
__asm__ ("JSR $F6F0"); /* HCOLOR */

HPLOT is at $F457

Register Y = HORIZONTAL Position (HI BYTE)
Register X = HORIZONTAL Position (LO BYTE)
Register A = VERTICAL Position

HLINE is at $F53A

Register X = HORIZONTAL Position (HI BYTE)
Register A = HORIZONTAL Position (LO BYTE)
Register Y = VERTICAL Position

HOME is at $FC58

In CC65, you can call this with this code:

__asm__ ("JSR $FC58"); /* HOME: Clear Text Window, Cursor Top */

TEXT is at $FB39

In CC65, you can call this with this code:

__asm__ ("JSR $FB39"); /* Init Text Screen (Don't Force Page 1) */
Roger Johnstone
2003-09-05 07:46:50 UTC
Permalink
Post by Chris Morse
Knowing the Monitor entry points for various functions is pretty
important. Actually, I'm looking at my //c Tech Ref Manual, 2nd
Edition, and I don't see any of the firmware entry points for Hi-Res
graphics. Seems to only list the Lo-Res routines. Hmm.. Well, the
following examples I figured out from looking in the book "Apple
Graphics & Arcade Game Design" by Jeffrey Stanton.
The lo-res and text stuff is all in the $F800-$FFFF "Monitor" ROM area,
which was originally written by Apple, so they were free to publish the
source. The hi-res stuff is part of Applesoft BASIC, which was written
by Microsoft. Even if Apple were ever given the source code for it they
weren't allowed to show it to anyone else.

They did publish the entry points for the various BASIC routines though,
I think they're in the Applesoft BASIC Programmer's Reference.
--
Roger Johnstone, Invercargill, New Zealand

PS/2 Mouse Adapter for vintage Apple II or Mac
order at http://vintageware.orcon.net.nz
Chris Morse
2003-09-05 13:53:10 UTC
Permalink
On Fri, 5 Sep 2003 07:46:50 +0000 (UTC), Roger Johnstone
Post by Roger Johnstone
Post by Chris Morse
Knowing the Monitor entry points for various functions is pretty
important. Actually, I'm looking at my //c Tech Ref Manual, 2nd
Edition, and I don't see any of the firmware entry points for Hi-Res
graphics. Seems to only list the Lo-Res routines. Hmm.. Well, the
following examples I figured out from looking in the book "Apple
Graphics & Arcade Game Design" by Jeffrey Stanton.
The lo-res and text stuff is all in the $F800-$FFFF "Monitor" ROM area,
which was originally written by Apple, so they were free to publish the
source. The hi-res stuff is part of Applesoft BASIC, which was written
by Microsoft. Even if Apple were ever given the source code for it they
weren't allowed to show it to anyone else.
They did publish the entry points for the various BASIC routines though,
I think they're in the Applesoft BASIC Programmer's Reference.
Thanks! Now it makes sense why the reference manual doesn't show
those entry points. I was beginning to wonder why; you've just
answered it!

// CHRIS
Andy McFadden
2003-09-05 16:07:18 UTC
Permalink
Post by Roger Johnstone
The lo-res and text stuff is all in the $F800-$FFFF "Monitor" ROM area,
which was originally written by Apple, so they were free to publish the
source. The hi-res stuff is part of Applesoft BASIC, which was written
by Microsoft. Even if Apple were ever given the source code for it they
weren't allowed to show it to anyone else.
Actually, the hi-res stuff was found in the Programmer's Assistant #1 ROM
chip, along with a bunch of other useful stuff. Somewhat commented source
code can be found in the PA#1 manual. I believe the code in Applesoft
is identical.

FWIW, those functions are optimized for code size, not speed. Depending
on your intended use, it might make sense to write your own.
--
Send mail to ***@fadden.com (Andy McFadden) - http://www.fadden.com/
CD-Recordable FAQ - http://www.cdrfaq.org/
CiderPress Apple II archive utility for Windows - http://www.faddensoft.com/
Fight Internet Spam - http://spam.abuse.net/spam/ & http://spamcop.net/
Rich J.
2003-09-06 23:10:21 UTC
Permalink
Post by Rich J.
Is there a way to access HGR, HPLOT,HCOLOR from within a C program? I
am also curious about XDRAW, LOAD, SAVE, OPEN, READ, WRITE.
I have HGR, etc. working with inline assembly in a C program. Now I
am having trouble trying to pass local variables to inline assembly:

asm ("lda #%?", fy); /* Y coordinate */
asm ("ldx #%?", fxlo); /* X coord low byte */
asm ("ldy #%?", fxhi); /* x coord high byte */

asm ("jsr $f457"); /* hplot x,y */


The documentation for CC65 says to use %b for ?constant? 8 bit
numbers, %v for global variables, and %o for "stack offset to local
variable"

I want to load A,X, and Y with values to hplot on the screen. How can
I get the %o to load the registers with the appropriate C variable?

Rich
aiiadict AT hotmail DOT com
http://rich12345.tripod.com
Ullrich von Bassewitz
2003-09-07 11:33:01 UTC
Permalink
Post by Rich J.
I want to load A,X, and Y with values to hplot on the screen. How can
I get the %o to load the registers with the appropriate C variable?
void foo (void)
{
unsigned bar;
...

/* Load bar into a/x */
asm ("ldy #%o+1", bar);
asm ("lda (sp),y");
asm ("tax");
asm ("dey");
asm ("lda (sp),y");

/* Easier, if just a/x is needed: */
__AX__ = bar;

...
}

Regards


Uz
--
Ullrich von Bassewitz ***@remove-to-reply.musoftware.de
1:27pm up 213 days, 20:11, 70 users, load average: 0.03, 0.05, 0.11
Loading...