Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #4458 > unrolled thread
| Started by | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| First post | 2018-03-25 15:14 -0500 |
| Last post | 2018-03-30 03:09 -0500 |
| Articles | 8 — 2 participants |
Back to article view | Back to comp.sys.apple2.programmer
Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) "Bill Buckels" <bbuckels@mts.net> - 2018-03-25 15:14 -0500
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) ol.sc@web.de (Oliver Schmidt) - 2018-03-26 22:18 +0000
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) "Bill Buckels" <bbuckels@mts.net> - 2018-03-26 18:34 -0500
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) ol.sc@web.de (Oliver Schmidt) - 2018-03-27 21:08 +0000
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) "Bill Buckels" <bbuckels@mts.net> - 2018-03-27 19:41 -0500
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) ol.sc@web.de (Oliver Schmidt) - 2018-03-29 22:21 +0000
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) "Bill Buckels" <bbuckels@mts.net> - 2018-03-30 02:51 -0500
Re: Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) "Bill Buckels" <bbuckels@mts.net> - 2018-03-30 03:09 -0500
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2018-03-25 15:14 -0500 |
| Subject | Solutions for extending cc65 with Double-Resolution Apple II Graphics (links included) |
| Message-ID | <p98vu5$tob$1@gioia.aioe.org> |
Since cc65 for the Apple II directly supports only two Apple II Graphics modes (LGR and HGR) through cc65 tgi drivers (as far as I know), and since cc65's direct support for Apple II bit-mapped graphics does not exist, my overall project of extending cc65 support for Additional Apple II Graphics is quite large and extensive. The following documents discuss what I did a few years back towards the above-stated goals with regards to Double-Resolution modes and the accompanying demos provide cc65 source code and working disk images: DLGR Bit-Mapped Graphics Demo http://www.appleoldies.ca/cc65/programs/dlgr/dloshow.zip Doc http://www.appleoldies.ca/cc65/docs/dlgr/dloshow.pdf DLGR Pixel Graphics Demo http://www.appleoldies.ca/cc65/programs/dlgr/dlodemo.zip Doc http://www.appleoldies.ca/cc65/docs/dlgr/dlodemo.pdf DHGR Bit-Mapped Graphics Demo http://www.appleoldies.ca/cc65/programs/dhgr/dhishow.zip Doc http://www.appleoldies.ca/cc65/docs/dhgr/dhishow.pdf DHGR Pixel Graphics Demo http://www.appleoldies.ca/cc65/programs/dhgr/dhiworld.zip Doc http://www.appleoldies.ca/cc65/docs/dhgr/dhiworld.pdf Recently, there have been some negative (undeserved) comments regarding the cc65 toolchain. I realize that some people don't care about my opinion on this topic despite the fact that I have one heck of a long history with the development of cross-compiled C/C++ programs in general and on a variety of platforms and graphics displays. My "recreational" focus (since the 1980's) has always included providing the average C programmer with useful documentation and demos as I learned and refined these things myself. This would exclude those who are hopelessly incapable of configuring a cross-compiler or who are not versatile enough to understand the classic relationship between the C programming language and assembly language, or indeed of not writing a line of original code on a blank screen. But to those of you who are not at an average level of competency... you still have much to gain both by reviewing my work and working with cross-compilers like cc65. Practice makes perfect, but complaining just makes enemies. To those of you who can write detailed complaints, I would also commend that you would instead write detailed instructions to help overcome the perceived shortfalls of the cc65 toolchain. Enjoy! Regards, Bill Buckels
[toc] | [next] | [standalone]
| From | ol.sc@web.de (Oliver Schmidt) |
|---|---|
| Date | 2018-03-26 22:18 +0000 |
| Message-ID | <p9brk3$m7g$1@news.albasani.net> |
| In reply to | #4458 |
Hi Bill,
>Since cc65 for the Apple II directly supports only two Apple II Graphics
>modes (LGR and HGR) through cc65 tgi drivers (as far as I know),
That's still true.
I'm afraid that you wouldn't want to conform to cc65 code guidelines
etc. but in general it would be great if you would contribute DHGR
(and HLGR) TGI drivers to cc65. I explicitly invited you several years
ago to do so - and that continues to apply.
Apart from that there's a still very primitive sprite and bitmap
utility: http://cc65.github.io/doc/sp65.html
Enhancing that program with
- Support for BMP/PNG input files beside PCX input files
- Support for Apple II (D)HGR output files
- Some of your advanced dithering algorithms
would be another very welcome contribution from you to cc65.
I guess getting those contributions into cc65 wouldn't be exactly fun
for both of us ;-)) but it would make your work surely much more
accessible to the average cc65 user than your current extensions - and
might therefore very well be worth the trouble!
>and since
>cc65's direct support for Apple II bit-mapped graphics does not exist,
I'm not sure what you refer to here. I presume it's the missing
ability to have segments automatically "flow" around the hires
screen(s).
Recently, I added
https://github.com/cc65/cc65/blob/master/cfg/apple2-hgr.cfg which aims
to help users to workaround that missing ability.
There's a simple program in
https://github.com/cc65/cc65/tree/master/testcode/lib/apple2 that
shows how to make use of that new linker config file:
- #pragma code-name ("LOWCODE") allows to place code between the
startup code at (by default) $803 and the hires screen at $2000.
- A two-line asm file allows to load a hires screen as part of loading
the program.
https://github.com/cc65/cc65/commit/855aceaba8f78f66cf5134ae707b4cee11c6e9e9
contains a pretty lenghty comment with some background info.
Regards,
Oliver
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2018-03-26 18:34 -0500 |
| Message-ID | <p9c01p$1r5g$1@gioia.aioe.org> |
| In reply to | #4462 |
"Oliver Schmidt" <ol.sc@web.de> wrote: >I'm afraid that you wouldn't want to conform to cc65 code guidelines etc. >but in general it would be great if you would contribute DHGR (and HLGR) >TGI drivers to cc65. I explicitly invited you several years ago to do so - >and that continues to apply. I am quite lazy when it comes to writing code in recent years and that continues to apply :) >Apart from that there's a still very primitive sprite and bitmap utility: >http://cc65.github.io/doc/sp65.html I'll take a look at that as time permits... >Enhancing that program... would be another very welcome contribution from >you to cc65. Is there really any interest? Besides you and I... I wonder and I hope so. >>and since cc65's direct support for Apple II bit-mapped graphics does not >>exist, All I mean by this is there are no cc65 link libraries that provide loader code for Apple II disk files in standard Apple II graphics file formats that I am aware of. If I am mistaken then I have missed something... You've been busy... I'll check-out your improvements. It's been a few years... but I certainly did have some fun with cc65 and I certainly would like to see folks use it. Regards, Bill
[toc] | [prev] | [next] | [standalone]
| From | ol.sc@web.de (Oliver Schmidt) |
|---|---|
| Date | 2018-03-27 21:08 +0000 |
| Message-ID | <p9ebrp$gor$1@news.albasani.net> |
| In reply to | #4463 |
Hi Bill,
>>Enhancing that program... would be another very welcome contribution from
>>you to cc65.
>
>Is there really any interest? Besides you and I... I wonder and I hope so.
I tend to be again and again surprised about the interest in cc65 when
looking at
https://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip/stats/timeline
>>>and since cc65's direct support for Apple II bit-mapped graphics does not
>>>exist,
>
>All I mean by this is there are no cc65 link libraries that provide loader
>code for Apple II disk files in standard Apple II graphics file formats that
>I am aware of. If I am mistaken then I have missed something...
Talking about DOS 3.3 there's still no support whatsoever in cc65 -
and I don't see it coming. But talking about ProODS 8 loading a HGR
file is as easy as:
int file = open("mypic.hgr", O_RDONLY);
read(file, (void*)0x2000, 0x2000);
close(file);
And loading a DHGR file means:
int file = open("mypic.dhgr", O_RDONLY);
read(file, (void*)0x2000, 0x2000);
// call into auxmove
read(file, (void*)0x2000, 0x2000);
close(file);
Do I miss the point or are you asking to have the code above
encapsulated?
Regards,
Oliver
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2018-03-27 19:41 -0500 |
| Message-ID | <p9eobo$gqg$1@gioia.aioe.org> |
| In reply to | #4466 |
"Oliver Schmidt" <ol.sc@web.de> wrote: >Do I miss the point or are you asking to have the code above encapsulated? Either that, or documented clearly so that programmers who are not necessarily familiar with the Apple II understand the steps required to load a single graphics image, or to display the images in a directory in a slideshow, or to do sprite animation etc. When you consider that to us simple folk displaying graphics on a computer is fun and somewhat of a challenge then you can see that we would want simple library routines to link to our own programs to give us this sexy super-power... or something similar to the scenario that I offer... But then I may be a special case that is still in awe of vintage computers displaying graphics... Regards, Bill
[toc] | [prev] | [next] | [standalone]
| From | ol.sc@web.de (Oliver Schmidt) |
|---|---|
| Date | 2018-03-29 22:21 +0000 |
| Message-ID | <p9jotq$q8a$1@news.albasani.net> |
| In reply to | #4467 |
Hi Bill, >Either that, or documented clearly so that programmers who are not >necessarily familiar with the Apple II understand the steps required to load >a single graphics image, or to display the images in a directory in a >slideshow, or to do sprite animation etc. I hope that short but complete, fully functional programs count as documentation ;-) An Apple ][+ program displaying all *.hgr images in a directory: https://github.com/cc65/cc65/blob/master/testcode/lib/apple2/hgrshow.c An Apple //e program displaying all *.dhgr images in a directory: https://github.com/cc65/cc65/blob/master/testcode/lib/apple2/dhgrshow.c A Makefile to build complete disk images with some hgr/dhgr sample images to display: https://github.com/cc65/cc65/blob/master/testcode/lib/apple2/Makefile Rregards, Oliver
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2018-03-30 02:51 -0500 |
| Message-ID | <p9kqa6$e12$1@gioia.aioe.org> |
| In reply to | #4476 |
"Oliver Schmidt" <ol.sc@web.de> wrote: >I hope that short but complete, fully functional programs count as >documentation ;-) In this case, absolutely... Bill
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2018-03-30 03:09 -0500 |
| Message-ID | <p9krav$g0m$1@gioia.aioe.org> |
| In reply to | #4476 |
"Oliver Schmidt" <ol.sc@web.de> wrote:
>An Apple ][+ program displaying all *.hgr images in a directory:
> https://github.com/cc65/cc65/blob/master/testcode/lib/apple2/hgrshow.c
Here's one that uses a timing loop and a script, and filetype. And does not
use tgi. Uses buffered I/O and inline assembly.
http://www.appleoldies.ca/cc65/programs/hgr/
/* ------------------------------------------------------------------------
System : cc65 cross-development environment
Platform : Apple IIe 128K PRODOS 8
Program : hishow(C) Copyright Bill Buckels 2014.
All rights reserved.
Description : Apple //e ProDOS 8 HGR Slideshow Program
HGR formats supported - BIN files only.
This program builds two executables based on conditional
compilation. The code for either is almost exactly the
same, but they use two different memory configurations
based on whether they use HGR Screen One or Screen Two.
The hishow variation that uses Screen One runs at $4000
directly above Screen One at $2000 and has a good deal more
memory than the hishow variation that uses Screen Two which
runs at $0803 under Screen Two (at $4000).
Either can be launched using Oliver Schmidt's loader.system
or from BASIC.SYSTEM with the BRUN command.
Date Written : November 2014
Revision : 1.0 First Release
Licence : You may use this program for whatever you wish as long
as you agree that Bill Buckels has no warranty or
liability obligations whatsoever from said use.
------------------------------------------------------------------------ */
#ifndef HGR_SCREEN_ADDRESS
#define HGR_SCREEN_ADDRESS 0x2000
#else
#if HGR_SCREEN_ADDRESS != 0x4000
#define HGR_SCREEN_ADDRESS 0x2000
#endif
#endif
#ifndef __APPLE2__
#define __APPLE2__
#endif
#include <stdio.h>
#include <errno.h>
#include "_file.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
/* http://www.unix.com/man-page/posix/3/opendir/ */
/* files in current directory */
#include <dirent.h>
#include <apple2enh.h>
unsigned delay = 5;
#pragma optimize (push,off)
void hireson(void)
{
asm("sta $c057"); /* HI-RES */
#if HGR_SCREEN_ADDRESS == 0x4000
asm("sta $c055"); /* PAGE TWO */
#else
asm("sta $c054"); /* PAGE ONE */
#endif
asm("sta $c050"); /* GRAPHICS */
asm("sta $c052"); /* GRAPHICS ONLY, NOT MIXED */
}
#pragma optimize (pop)
void hiresclear(void)
{
/* clear main screen memory */
memset((char *)HGR_SCREEN_ADDRESS,0,8192);
}
#pragma optimize (push,off)
void hiresoff(void)
{
asm("sta $c051"); /* TEXT - HIDE GRAPHICS */
asm("sta $c054"); /* PAGE ONE */
}
#pragma optimize (pop)
/* The following loads a non-compressed
BSaved BIN Image Format hi-res graphics image.
*/
int bload(char *name)
{
FILE *fp;
int status=0;
fp = fopen(name,"rb"); /* open a binary file */
if (fp == NULL)return -1;
if (fread((char *)HGR_SCREEN_ADDRESS,1,8192,fp) < 8184) status = -2;
fclose(fp);
return status;
}
/* 1MHZ timing loop settings - increase for faster machines */
#define YTIME 60L
#define XTIME 32L
char wait(unsigned duration)
{
char c = 0;
long y, x;
while (duration > 0) {
for (y=0;y<YTIME;y++) {
for (x=0;x<XTIME;x++) {
if (kbhit()) {
c = cgetc();
if (c > 47 && c < 58) {
delay = (c-48) * 5;
}
/* clear keyboard buffer */
while (kbhit())cgetc();
return c;
}
}
}
duration--;
}
return c;
}
/* the following function creates a list of the hi-res
files in the current directory, in Apple sequential text format. */
FILE *makepiclist()
{
FILE *fp = NULL;
int err, cnt = 0, idx, jdx, found;
DIR *dir;
struct dirent *dp;
extern unsigned char _filetype;
extern unsigned _auxtype;
/* read files in current directory */
if ((dir = opendir (".")) == NULL) return NULL;
/* remove piclist if it already exists */
if((fp=fopen("PICLIST","r"))!=NULL) {
fclose(fp);
remove("PICLIST");
}
/* set file to sequential text */
_filetype = 0x04;
_auxtype = 0x0000;
if((fp=fopen("PICLIST","w"))==NULL) {
closedir(dir);
return NULL;
}
/* write the list to disk */
while ((dp = readdir (dir)) != NULL) {
/* check for bin files */
if (dp->d_type != 0x06) continue;
/* load address 0x2000 or 0x4000 */
if (dp->d_auxtype != 0x2000 && dp->d_auxtype != 0x4000) continue;
/* check file size */
/* there is no way to tell the difference between a
hi-res bsaved image and a double hi-res bin or aux image */
found = 0;
if (dp->d_size > 8183 && dp->d_size < 8193) found = 1;
if (found == 0) continue;
/* get extension if any */
jdx = 999;
for (idx = 0; dp->d_name[idx] != 0; idx++) {
if (dp->d_name[idx] == '.') {
jdx = idx+1;
}
}
if (jdx != 999) {
found = 0;
for (;;) {
/* bypass AUX files - I only want BIN files in my list */
if (toupper(dp->d_name[jdx]) != 'A') break;
if (toupper(dp->d_name[jdx+1]) != 'U') break;
if (toupper(dp->d_name[jdx+2]) != 'X') break;
found = 1;
break;
}
if (found == 1) continue;
}
/* if out of disk space quit writing to piclist */
err = fprintf(fp,"%s%c",dp->d_name, (char)13);
if (err < 0) break;
cnt++;
}
fclose(fp);
closedir(dir);
if (cnt == 0) {
/* if no files found or no filenames written remove empty piclist */
remove("PICLIST");
fp = NULL;
}
else {
/* otherwise open and return the piclist */
fp = fopen("PICLIST","r");
}
return fp;
}
/* fgets for Apple II text files - read native apple II text files properly!
the cc65 version doesn't! Which means that you need to use unix text
files
unless you roll your own fgets like this one which does both... */
char* __fastcall__ fgets (char* s, unsigned size, register FILE* f)
{
register char* p = s;
unsigned i;
int c;
if (size == 0) {
/* Invalid size */
return (char*) _seterrno (EINVAL);
}
/* Read input */
i = 0;
while (--size) {
/* Get next character */
if ((c = fgetc (f)) == EOF) {
/* Error or EOF */
if ((f->f_flags & _FERROR) != 0 || i == 0) {
/* ERROR or EOF on first char */
*p = '\0';
return 0;
} else {
/* EOF with data already read */
break;
}
}
/* One char more */
*p = c;
++p;
++i;
/* Stop at end of Apple II or Unix Text File line */
if ((char)c == (char)13 || (char)c == (char)10) {
break;
}
}
/* Terminate the string */
*p = '\0';
/* Done */
return s;
}
int main(void)
{
FILE *fp;
int status = 0, i;
char picname[66], c;
unsigned cnt = 0;
/* allow delay change from file if found */
if((fp=fopen("delay.txt","r"))!=NULL) {
if (fgets(picname,66,fp) != NULL) delay = (unsigned)atoi(picname);
fclose(fp);
printf("Delay Over-ride %d. Press any key...\n",delay);
cgetc();
}
/* try to create a piclist if it does not exist */
if((fp=fopen("PICLIST","r"))==NULL) {
fp = makepiclist();
if (fp == NULL) {
printf("Can't open PICLIST! Press any key...");
cgetc();
return 0;
}
}
fclose(fp);
clrscr();
/* turn-on hi-res and clear the hgr screen */
hireson();
hiresclear();
/* default */
/* display each hgr pic for 5 seconds (default) or advance on
a key press. If ESC is pressed, exit */
for (;;) {
while (fgets(picname,66,fp) != NULL) {
/* load picture */
/* skip line-feeds in MS-DOS text */
/* skip comment lines and blank lines if any */
if (picname[0] < (char)47) continue;
/* remove trailing eol or unwanted characters */
for (i=0;picname[i]!=0;i++) {
if (picname[i] < (char)32 || picname[i] > (char)122) {
picname[i] = 0;
break;
}
}
if (bload(picname) < 0) continue;
if (cnt++ > 100) cnt = 1;
if (delay == 0) {
/* if delay == 0 advance on keypress only */
/* if ESC is pressed then quit */
c = cgetc();
if (c == 27) {
status = -1; break;
}
if (c > 48 && c < 58) {
delay = (c-48) * 5;
while (kbhit())cgetc();
continue;
}
}
else {
/* flush keyboard buffer */
if (kbhit()) c = cgetc();
else c = 0;
if (c == 27) {
status = -1; break;
}
if (c > 47 && c < 58) {
delay = (c-48) * 5;
}
}
while (kbhit())cgetc();
if (delay == 0) continue;
/* advance on timeout or advance on keypress */
/* if ESC is pressed then quit */
if (wait(delay)==27) {
status = -1;
break;
}
}
fclose(fp);
if (status != 0) break;
if (cnt < 1) {
fp = makepiclist();
if (fp == NULL) break;
continue;
}
/* no rewind in cc65, so we must
close and re-open the piclist when we
reach the end */
if((fp=fopen("PICLIST","r"))==NULL) break;
}
hiresclear();
hiresoff();
clrscr();
if (status == 0 && cnt == 0) {
printf("Can't create PICLIST! Press any key...");
cgetc();
}
return 0;
}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.apple2.programmer
csiph-web