]> git.sur5r.net Git - cc65/blob - testcode/lib/apple2/dhgrshow.c
Add translation from PETSCII to screen codes.
[cc65] / testcode / lib / apple2 / dhgrshow.c
1 // cl65 -t apple2enh --start-addr 0x4000 dhgrshow.c
2
3 #include <tgi.h>
4 #include <conio.h>
5 #include <fcntl.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include <dirent.h>
9 #include <peekpoke.h>
10
11 void main (void)
12 {
13     unsigned old;
14     DIR *dir;
15     struct dirent *ent;
16
17     old = videomode (VIDEOMODE_80x24);
18     tgi_install (a2e_hi_tgi);
19     tgi_init ();
20     POKE (0xC05E, 0);
21
22     dir = opendir (".");
23     while (ent = readdir (dir)) {
24         char *ext;
25         int hgr;
26
27         ext = strrchr (ent->d_name, '.');
28         if (!ext || strcasecmp (ext, ".dhgr"))
29             continue;
30
31         hgr = open (ent->d_name, O_RDONLY);
32         POKE (0xC055, 0);
33         read (hgr, (void*)0x2000, 0x2000);
34         POKE (0xC054, 0);
35         read (hgr, (void*)0x2000, 0x2000);
36         close (hgr);
37
38         if (cgetc () == '\r')
39             break;
40     }
41     closedir (dir);
42
43     tgi_uninstall ();
44     videomode (old);
45 }