[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using Apple Graphics in CP/M Questions



Does anyone know what needs to be done to write a program using the Softcard 
which sets the Apple II into graphics screen mode and provides an 8K display 
window at $2000 similar to what GBASIC does and sets the Apple II back to 
text mode when done. The following Aztec C CP/M 80 program doesn't work and 
the code is loaded above an 8K memory hole above HGR1 so it doesn't crash 
either.

See the function setcrtmode() in the listing below.

The Softcard manual says CP/M relocates some of the Apple $C000 but it isn't 
specific what these might be or how one might use them.

If GBASIC can do this I can do too. But obviously not without help.

This seems to be a simple problem. Using a graphics library doesn't seem 
needed. Switching to 6502 mode and then back again doesn't seem needed. But 
perhaps I am minimizing this.

Code below:

BEWARE! DOES NOT WORK!

x--- snip ---x

/* gload.c (C) Copyright 2008 Bill Buckels */

/* Written in Aztec C */

/* Apple CP/M 80 program to load
   Apple II 8K HIRES screens
   assume the  DOS 3.3 4-byte header
   has been removed.*/

/* You have a royalty free right to use
   this program for any purpose whatsoever
   provided you agree that Bill Buckels
   has no liability whatsoever from its use. */

#include <fcntl.h>



main(argc, argv)
int argc;
char **argv;
{
    if (argc > 1) {
  setcrtmode(1);
  bload(argv[1]);
  getch();
  setcrtmode(0);
 }
 exit(0);
}

bload(name)
char *name;
{
   int fh, c=-1;

   fh = open(name,O_RDONLY,0);
   if (fh == -1)return -1;
   c = read(fh,(char *)0x2000,0x2000);
   close(fh);
   if (c == 0x2000)c=0;
   else c=-2;
   return c;

}

getch()
{
  /* return the last key press */
  int ch;

  while((ch=bdos(6,0xff))==0);

  return ch;
}

char poke=(char *)0xE000;


/* The apple II DOS 3.3 slot region $c000-$cfff appears at
   0xe000-0xefff in the Z80 address space.

   Note that this is for 56k CP/M only. */



setcrtmode(crtmode)
int crtmode;
{
 /* use the usual offset addresses
    from $C000 DOS 3.3 for reference
    to access the slot region */
 switch(crtmode)
 {
 case 0:
  poke[0x51] = 0; /* text */
  poke[0x54] = 0; /* page one */
  break;
 default  :
  poke[0x57] = 0;   /* hi res */
  poke[0x54] = 0;   /* page one */
  poke[0x50] = 0;   /* set graphics */
  poke[0x52] = 0;   /* full graphics */

 }
}