1 /*
2
3 SG C Tools 1.7
4
5 (C) 1994 Steve Goldsmith
6 All Rights Reserved
7
8 SG C Tools Demo shows how to use most of the features available with SG C Tools.
9
10 Originally Compiled with HI-TECH C 3.09 (CP/M-80).
11 Now ported to Z88DK by Stefano Bodrato
12
13 To compile for a minimal C128 without CP/M:
14 zcc +c128 -lndos -lmalloc sgdemo.c
15 bin3000 a.bin z80mc (then use c1541 to put 'z80mc' in a disk image)
16 The BASIC loader making the Z80 Jump at address $3000:
17 10 BANK0
18 12 BLOAD"Z80MC",B0
19 20 POKE 65518,195:POKE 65519,0:POKE 65520,48
20 30 POKE 4532,88:POKE 4353,96
21 40 SYS 65488:END
22
23 To compile for CP/M:
24 zcc +cpm -lc128cpm -lndos sgdemo.c
25
26 */
27
28 #include <conio.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <ctype.h>
32 //#include <conio.h>
33 //#include <sys.h>
34 #include <sys/stat.h>
35 #include <cpm.h>
36 //#include <hitech.h>
37 #include <c128/vdc.h>
38 #include <c128/cia.h>
39 #include <c128/sid.h>
40 #include <c128/pcx.h>
41
42 #define getch() getk()
43
44 /* RAW sound block */
45 extern char rawsound[];
46 #define rawsoundlen 6144
47 #asm
48 ._rawsound
49 BINARY "bugle.raw"
50 #endasm
51
52 /* Added for "malloc" with z88dk */
53 long heap;
54
55 /* 64k vdc locations */
56
57 #define appBitMapMem 0x4000
58 #define appAttrMem 0x0800
59
60 /* colors used by this app */
61
62 #define appClockCo vdcAltChrSet+vdcRvsVid+vdcLightCyan
63 #define appMenuScrCo vdcBlack
64 #define appDeskCo vdcAltChrSet+vdcMediumGray
65 #define appMenuTxtCo vdcAltChrSet+vdcLightCyan
66 #define appMenuWinCo vdcAltChrSet+vdcLightBlue
67 #define appIScrCo vdcBlack
68 #define appIDeskCo vdcAltChrSet+vdcMediumGray
69 #define appIWinTxtCo vdcAltChrSet+vdcDarkBlue
70 #define appIWinCo vdcAltChrSet+vdcDarkBlue
71 #define appGrTextCo (vdcDarkGray << 4) | vdcWhite
72 #define appSoundWinCo vdcAltChrSet+vdcWhite
73 #define appSoundTxt1Co vdcAltChrSet+vdcLightGreen+vdcBlink
74 #define appSoundTxt2Co vdcAltChrSet+vdcDarkGreen
75 #define appCtrlTxt1Co vdcAltChrSet+vdcRvsVid+vdcLightYellow
76 #define appCtrlTxt2Co vdcAltChrSet+vdcWhite
77 #define appCtrlWinCo vdcAltChrSet+vdcLightCyan
78
79 extern uchar vdcScrHorz;
80 extern ushort vdcDispMem;
81 extern ushort vdcAttrMem;
82 extern ushort vdcCharMem;
83 extern ushort vdcCharMemSize;
84 extern ushort vdcBitMapMemSize;
85
86 extern uchar sidPot1X;
87 extern uchar sidPot1Y;
88 extern uchar sidPot2X;
89 extern uchar sidPot2Y;
90 extern uchar sidMouse1X;
91 extern uchar sidMouse1Y;
92 extern uchar sidMouse2X;
93 extern uchar sidMouse2Y;
94
95 extern uchar ciaJoy1;
96 extern uchar ciaJoy2;
97 extern ciaKeyRec ciaKeyScan;
98 //extern unsigned char ciaKeyScan[];
99
100 extern ushort pcxXSize;
101 extern ushort pcxYSize;
102
103 void initbitmapi64k(void);
104 void initbitmap64k(void);
105 void initbitmap16k(void);
106 uchar savechrsets(void);
107 void restorechrsets(void);
108 void draw16khelp(uchar Rect[]);
109 void drawmenu(uchar Rect[]);
110 void graphicsview(void);
111 void set64kmode(void);
112 void ilace80x50text(void);
113 void graphics640x200(void);
114 void pcx640x200(char * FileName);
115 void graphics640x480(void);
116 void pcx640x480(char * FileName);
117
118 void delay(ushort D);
119 void planesound(void);
120 void shotssound(void);
121 void explodesound(void);
122 void bombdropsound(void);
123 void soundseq(uchar Rect[], uchar Seq);
124 void soundwin(uchar Rect[]);
125 void playraw(char * FileName, ulong Hz);
126
127 void controlswin(uchar Rect[]);
128 void dispclock(void);
129
130 void init(void);
131 void run(void);
132 void done(void);
133
134 uchar *appChSetBufPtr; /* char set buffer pointer */
135 uchar appColors[] = /* colors for 64k graphics */
136 {
137 vdcDarkGray,
138 vdcDarkBlue,
139 vdcLightBlue,
140 vdcLightBlue,
141 vdcDarkCyan,
142 vdcDarkCyan,
143 vdcDarkCyan,
144 vdcLightCyan,
145 vdcLightCyan,
146 vdcLightCyan,
147 vdcMediumGray,
148 vdcMediumGray,
149 vdcWhite,
150 vdcMediumGray,
151 vdcMediumGray,
152 vdcLightCyan,
153 vdcLightCyan,
154 vdcLightCyan,
155 vdcDarkCyan,
156 vdcDarkCyan,
157 vdcDarkCyan,
158 vdcLightBlue,
159 vdcLightBlue,
160 vdcDarkBlue,
161 vdcDarkGray
162 };
163
164 char *appMenuItems[6] = /* text used by this app */
165 {
166 "<A> KEYBOARD, JOY STICK, PADDLE AND MOUSE CONTROLS",
167 "<B> SID SOUND EFFECTS",
168 "<C> PLAY 4 BIT DIGITIZED SOUND",
169 "<D> 80 X 50 INTERLACED TEXT",
170 "<E> 640 X 200 GRAPHICS",
171 "<F> 640 X 200 PCX IMAGE, (CONTROL) & (RUN STOP) STATUS",
172 };
173
174 char *app16KHelp[3] =
175 {
176 "DO NOT SELECT [S] OPTION IF YOUR C128 HAS A 16K VDC!",
177 "If YOU HAVE A 64K VDC USE [S] TO GET COLOR, TEXT AND",
178 "INTERLACE IN GRAPHICS MODE!"
179 };
180
181 char *appSoundSeq[4] =
182 {
183 "PLANE",
184 "SHOTS",
185 "BOMB DROPPING",
186 "EXPLOSION"
187 };
188
189 uchar appMenuRect[] = {10,2,69,13}; /* menu window location */
190 uchar app16KRect[] = {10,16,69,21}; /* 16k help window location */
191 uchar appSoundRect[] = {19,7,59,17}; /* sound window location */
192 uchar appControlRect[] = {10,2,69,14}; /* control window location */
193
194 //ciaTODRec appTOD = {0,0,0,0}; /* used to set tod clock to 12 am */
195 //uchar appTOD[] = {0,0,0,0}; /* used to set tod clock to 12 am */
196 unsigned char appTOD[4]; // = {0,0,0,0}; /* used to set tod clock to 12 am */
197
198 char appRawName[] = {"DEMO.RAW"};
199 ulong appHz = 8000;
200
201 char appPcxName1[] = {"DEMO1.PCX"};
202 char appPcxName2[] = {"DEMO2.PCX"};
203
main()204 main()
205 {
206 mallinit();
207 init();
208 run();
209 done();
210 }
211
initbitmapi64k(void)212 void initbitmapi64k(void)
213 {
214 if(is64kvdc())
215 {
216 vdcBitMapMemSize = 49152;
217 setcursorvdc(0,0,vdcCurNone); /* turn cursor off */
218 outvdc(vdcFgBgColor,vdcBlack); /* black screen */
219 attrsoffvdc();
220 setbitmapintvdc(appBitMapMem,appAttrMem,vdcDarkBlue,vdcBlack);
221 mapvdc();
222 clrbitmapvdc(0);
223 }
224 }
225
initbitmap64k(void)226 void initbitmap64k(void)
227 {
228 vdcBitMapMemSize = 16000;
229 setcursorvdc(0,0,vdcCurNone); /* turn cursor off */
230 outvdc(vdcFgBgColor,vdcBlack); /* black screen */
231 attrsoffvdc(); /* disable attrs */
232 setbitmapvdc(appBitMapMem,appAttrMem,vdcBlack,vdcBlack); /* black fg bg */
233 mapvdc(); /* set global vdc vars to reflect changes */
234 clrattrvdc(vdcBlack);
235 clrbitmapvdc(0); /* clear bit map */
236 attrsonvdc(); /* enable attrs */
237 }
238
initbitmap16k(void)239 void initbitmap16k(void)
240 {
241 vdcBitMapMemSize = 16000;
242 setcursorvdc(0,0,vdcCurNone); /* turn cursor off */
243 outvdc(vdcFgBgColor,vdcBlack); /* black screen */
244 attrsoffvdc(); /* disable attrs to work on 16k vdc */
245 setbitmapvdc(vdcDispMem,vdcAttrMem,vdcWhite,vdcBlack);
246 clrbitmapvdc(0); /* clear bit map */
247 }
248
savechrsets(void)249 uchar savechrsets(void)
250 {
251 if(is64kvdc())
252 return(1);
253 else
254 {
255 appChSetBufPtr = memtobufvdc(vdcCharMem,vdcCharMemSize);
256 if (appChSetBufPtr != NULL)
257 return(1);
258 else
259 return(0);
260 }
261 }
262
restorechrsets(void)263 void restorechrsets(void)
264 {
265 if(appChSetBufPtr != NULL)
266 {
267 outvdc(vdcFgBgColor,vdcBlack); /* set foreground-background to black */
268 attrsoffvdc(); /* disable attrs */
269 buftomemvdc(appChSetBufPtr,vdcCharMem,vdcCharMemSize);
270 }
271 }
272
draw16khelp(uchar Rect[])273 void draw16khelp(uchar Rect[])
274 {
275 uchar I;
276
277 winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appMenuWinCo,"VDC HELP");
278 for(I=0; I < 3; I++)
279 printstrvdc(Rect[0]+2,Rect[1]+I+2,appMenuTxtCo,app16KHelp[I]);
280 }
281
drawmenu(uchar Rect[])282 void drawmenu(uchar Rect[])
283 {
284 uchar I;
285
286 outvdc(vdcFgBgColor,appMenuScrCo); /* set new screen color */
287 setcursorvdc(0,0,vdcCurNone); /* turn cursor off */
288 clrattrvdc(appDeskCo); /* draw desk top */
289 clrscrvdc(0xe6);
290 filldspvdc(0,0,vdcScrHorz,32);
291 fillattrvdc(0,0,vdcScrHorz,appClockCo);
292 printstrvdc(1,0,appClockCo,"CP/M");
293 printstrvdc(67,0,appClockCo,"RUN");
294 //winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appMenuWinCo,"SG C Tools 1.7 Demo (C) 1994");
295 winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appMenuWinCo,"SG C TOOLS 1.7 DEMO (C) 1994");
296 for(I=0; I < 6; I++)
297 printstrvdc(Rect[0]+2,Rect[1]+I+2,appMenuTxtCo,appMenuItems[I]);
298 if(is64kvdc())
299 {
300 printstrvdc(Rect[0]+2,Rect[3]-3,appMenuTxtCo,"<G> 640 X 480 GRAPHICS");
301 printstrvdc(Rect[0]+2,Rect[3]-2,appMenuTxtCo,"<H> 640 X 480 INTERLACE PCX IMAGE");
302 }
303 else
304 {
305 printstrvdc(Rect[0]+2,Rect[3]-2,appMenuTxtCo,"<S> SET 64K MODE");
306 draw16khelp(app16KRect);
307 }
308 printstrvdc(Rect[0]+2,Rect[3]-1,appMenuTxtCo,"<X> EXIT TO CP/M");
309 }
310
graphicsview(void)311 void graphicsview(void) /* view graphics until key pressed */
312 {
313 getch();
314 while (!(kbhit()));
315 getch();
316 outvdc(vdcFgBgColor,vdcBlack);
317 attrsoffvdc();
318 restorechrsets();
319 restorevdc();
320 mapvdc();
321 drawmenu(appMenuRect);
322 }
323
set64kmode(void)324 void set64kmode(void)
325 {
326 if(!(is64kvdc()) && appChSetBufPtr != NULL)
327 {
328 restorevdc(); /* make sure all registers are default value */
329 set64kvdc(); /* set 64k mode */
330 savevdc(); /* reflect change to reg 28 */
331 restorechrsets(); /* restore char sets destroyed by setting 64k mode */
332 free(appChSetBufPtr); /* dispose buffer */
333 appChSetBufPtr = NULL;
334 restorevdc();
335 mapvdc();
336 drawmenu(appMenuRect);
337 }
338 }
339
ilace80x50text(void)340 void ilace80x50text(void)
341 {
342 uchar I;
343
344 outvdc(vdcFgBgColor,appIScrCo); /* set new screen color */
345 setdsppagevdc(vdcDispMem,vdcAttrMem << 1);
346 set80x50textvdc();
347 mapvdc(); /* map changes */
348 clrattrvdc(appIDeskCo);
349 clrscrvdc(233);
350 winvdc(10,5,69,44,appIWinCo,"INTERLACE 80 X 50 MODE");
351 printstrvdc(11,43,appIWinTxtCo,
352 "ALL FUNCTIONS THAT OPERATE IN 80 X 25 WORK IN 80 X 50 TOO!");
353 for (I = 1; I <= 36; I++) /* scroll window */
354 scrollupvdc(11,7,68,43);
355 while (!(kbhit()));
356 getch();
357 clrattrvdc(vdcAltChrSet);
358 clrscrvdc(32);
359 restorevdc();
360 mapvdc();
361 drawmenu(appMenuRect);
362 }
363
graphics640x200(void)364 void graphics640x200(void)
365 {
366 int I;
367 uchar X, Y;
368
369 if(is64kvdc())
370 {
371 initbitmap64k();
372 for(I = 0; I <= sizeof(appColors); I++)
373 fillattrvdc(0,I,vdcScrHorz,appColors[I]);
374 }
375 else
376 initbitmap16k();
377
378 for(I = 0; I <= 639; I += 80)
379 {
380 linevdc(319,0,I,199);
381 linevdc(I,0,319,199);
382 }
383 for(I = 32; I <= 319; I += 32)
384 {
385 ellipsevdc(319,99,I,I/4);
386 }
387 if(is64kvdc())
388 {
389 printbmvdc(12,1,appGrTextCo,
390 "SG C TOOLS MAKES IT EASY TO USE TEXT IN GRAPHICS MODE!");
391 printbmvdc(32,3,appGrTextCo,"BIT MAP COLORS");
392 for (Y = 0; Y < 16; Y++)
393 for (X = 0; X < 16; X++)
394 printbmvdc(X+31,Y+5,(Y << 4) | X,"*");
395 }
396 graphicsview();
397 }
398
pcx640x200(char * FileName)399 void pcx640x200(char * FileName)
400 {
401 //bdos(45,0x0FE);
402 if (initpcx(FileName) == pcxErrNone)
403 {
404 if (pcxXSize < 641 && pcxYSize < 201)
405 {
406 if(is64kvdc())
407 {
408 initbitmap64k();
409 clrattrvdc(vdcWhite);
410 }
411 else
412 initbitmap16k();
413 decodefilepcx(0,0);
414 donepcx();
415 graphicsview();
416 }
417 else
418 donepcx();
419 }
420 }
421
graphics640x480(void)422 void graphics640x480(void)
423 {
424 int I;
425
426 if(is64kvdc())
427 {
428 initbitmapi64k();
429 for(I = 0; I <= 639; I += 80)
430 {
431 lineivdc(319,0,I,479);
432 lineivdc(I,0,319,479);
433 }
434 for(I = 32; I <= 319; I += 32)
435 {
436 ellipseivdc(319,239,I,I/2);
437 }
438 printbmivdc(10,11,
439 "SG C TOOLS MAKES IT EASY TO USE TEXT IN INTERLACE GRAPHICS TOO!");
440 graphicsview();
441 }
442 }
443
pcx640x480(char * FileName)444 void pcx640x480(char * FileName)
445 {
446 if(is64kvdc())
447 {
448 //bdos(45,0x0FE);
449 if (initpcx(FileName) == pcxErrNone)
450 {
451 if (pcxXSize < 641 && pcxYSize < 481)
452 {
453 initbitmapi64k();
454 decodefileintpcx(0,0);
455 donepcx();
456 graphicsview();
457 }
458 else
459 donepcx();
460 }
461 }
462 }
463
delay(ushort D)464 void delay(ushort D) /* delay in milliseconds (1/1000 sec) */
465 {
466 setintctrlcia(cia2,ciaClearIcr); /* disable all cia 2 interrupts */
467 settimerbcia(cia2,D,ciaCountA); /* timer b counts timer a underflows */
468 settimeracia(cia2,timervalcia(1000),ciaCPUCont); /* set timer a 1/1000 sec */
469 while ((inp(cia2+ciaIntCtrl) & 0x02) == 0); /* wait for count down */
470 }
471
planesound(void)472 void planesound(void)
473 {
474 ushort Pulse;
475 ushort Freq = 2047;
476
477 volumesid(15,0);
478 envelopesid(sidVoice1,12,10,0,0);
479 attacksid(sidVoice1,sidWaveSqu);
480 for(Pulse = 0; Pulse < 3840; Pulse += 10)
481 {
482 pulsewavesid(sidVoice1,Pulse);
483 freqsid(sidVoice1,Freq);
484 Freq -= 5;
485 delay(2);
486 }
487 releasesid(sidVoice1,sidWaveSqu);
488 delay(6);
489 freqsid(sidVoice1,0);
490 }
491
shotssound(void)492 void shotssound(void)
493 {
494 uchar I;
495
496 volumesid(15,0);
497 for(I = 0; I < 20; I++)
498 {
499 envelopesid(sidVoice1,0,3,0,0);
500 freqsid(sidVoice1,5360);
501 attacksid(sidVoice1,sidWaveNoi);
502 delay(100);
503 releasesid(sidVoice1,sidWaveNoi);
504 delay(6);
505 }
506 freqsid(sidVoice1,0);
507 }
508
explodesound(void)509 void explodesound(void)
510 {
511 volumesid(15,0);
512 envelopesid(sidVoice1,0,0,15,11);
513 freqsid(sidVoice1,200);
514 attacksid(sidVoice1,sidWaveNoi);
515 delay(8);
516 releasesid(sidVoice1,sidWaveNoi);
517 delay(2400);
518 freqsid(sidVoice1,0);
519 }
520
bombdropsound(void)521 void bombdropsound(void)
522 {
523 ushort I;
524
525 volumesid(15,0);
526 envelopesid(sidVoice3,13,0,15,0);
527 freqsid(sidVoice3,0);
528 attacksid(sidVoice3,sidWaveTri);
529 for(I = 32000; I > 200; I -= 200)
530 {
531 freqsid(sidVoice3,I);
532 delay(18);
533 }
534 releasesid(sidVoice3,sidWaveTri);
535 delay(6);
536 freqsid(sidVoice3,0);
537 }
538
soundseq(uchar Rect[],uchar Seq)539 void soundseq(uchar Rect[], uchar Seq)
540 {
541 scrollupvdc(Rect[0]+1,Rect[1]+2,Rect[2]-1,Rect[3]-1);
542 fillattrvdc(Rect[0]+2,Rect[3]-3,Rect[2]-Rect[0]-2,appSoundTxt2Co);
543 printstrvdc(Rect[0]+2,Rect[3]-2,appSoundTxt1Co,appSoundSeq[Seq]);
544 }
545
soundwin(uchar Rect[])546 void soundwin(uchar Rect[])
547 {
548 uchar I;
549
550 winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appSoundWinCo,"SID SOUND EFFECTS");
551 for(I = 0; I < 4; I++)
552 {
553 soundseq(Rect,I);
554 switch (I)
555 {
556 case 0 :
557 planesound();
558 break;
559 case 1 :
560 shotssound();
561 break;
562 case 2 :
563 bombdropsound();
564 break;
565 case 3 :
566 explodesound();
567 break;
568 }
569 }
570 drawmenu(appMenuRect);
571 }
572
playraw(char * FileName,ulong Hz)573 void playraw(char * FileName, ulong Hz)
574 {
575 /*
576 uchar *RawBufPtr;
577 FILE *RawFile;
578 ulong RawSize;
579 struct stat StatRec;
580
581 RawBufPtr = NULL;
582 //bdos(45,0x0FE);
583 if (stat(FileName,&StatRec) == 0)
584 RawSize = StatRec.st_size;
585 else
586 RawSize = 0;
587 if (RawSize > 0)
588 {
589 RawBufPtr = (uchar *) malloc(RawSize);
590 if (RawBufPtr != NULL)
591 {
592 if ((RawFile = fopen(FileName,"rb")) != NULL)
593 {
594 fread(RawBufPtr,sizeof(uchar),RawSize,RawFile);
595 fclose(RawFile);
596 #asm
597 di
598 #endasm
599 */
600 setintctrlcia(cia2,ciaClearIcr);
601 settimeracia(cia2,timervalcia(Hz),ciaCPUCont);
602 //playzb4sid(RawBufPtr,RawSize);
603 playzb4sid(rawsound,rawsoundlen);
604 /*
605 #asm
606 ei
607 #endasm
608 }
609 free(RawBufPtr);
610 }
611 }
612 */
613 }
614
615
controlswin(uchar Rect[])616 void controlswin(uchar Rect[])
617 {
618 char StrBuf[45];
619
620 winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appCtrlWinCo,"CONTROLS");
621 printstrvdc(Rect[0]+2,Rect[1]+2,appCtrlTxt1Co,"KEYBOARD 0 1 2 3 4 5 6 7 8 9 10 ");
622 printstrvdc(Rect[0]+2,Rect[1]+4,appCtrlTxt1Co,"JOYSTICK 1 2 ");
623 printstrvdc(Rect[0]+2,Rect[1]+6,appCtrlTxt1Co,"PADDLE 1 2 3 4 ");
624 printstrvdc(Rect[0]+2,Rect[1]+8,appCtrlTxt1Co,"1351 MOUSE X1 Y1 X2 Y2 ");
625 printstrvdc(Rect[0]+21,Rect[1]+11,appCtrlTxt2Co | vdcBlink,
626 " <RUN STOP> TO EXIT ");
627 //#asm
628 // di
629 //#endasm
630 do
631 {
632 getpotssid(); /* read controls */
633 getmousesid();
634 getjoyscia();
635 getkeyscia();
636
637 //sprintf(StrBuf,"%4u%4u%4u%4u%4u%4u%4u%4u%4u%4u%4u",
638 sprintf(StrBuf," %u %u %u %u %u %u %u %u %u %u %u ",
639 ciaKeyScan[0],ciaKeyScan[1],ciaKeyScan[2],ciaKeyScan[3],
640 ciaKeyScan[4],ciaKeyScan[5],ciaKeyScan[6],ciaKeyScan[7],
641 ciaKeyScan[8],ciaKeyScan[9],ciaKeyScan[10]);
642 printstrvdc(Rect[0]+12,Rect[1]+3,appCtrlTxt2Co,StrBuf);
643
644 //sprintf(StrBuf,"%4u%4u",ciaJoy1,ciaJoy2);
645 sprintf(StrBuf," %u %u ",ciaJoy1,ciaJoy2);
646 printstrvdc(Rect[0]+12,Rect[1]+5,appCtrlTxt2Co,StrBuf);
647
648 //sprintf(StrBuf,"%4u%4u%4u%4u",sidPot1X,sidPot1Y,sidPot2X,sidPot2Y);
649 sprintf(StrBuf," %u %u %u %u ",sidPot1X,sidPot1Y,sidPot2X,sidPot2Y);
650 printstrvdc(Rect[0]+12,Rect[1]+7,appCtrlTxt2Co,StrBuf);
651
652 //sprintf(StrBuf,"%4u%4u%4u%4u",sidMouse1X,sidMouse1Y,sidMouse2X,sidMouse2Y);
653 sprintf(StrBuf," %u %u %u %u ",sidMouse1X,sidMouse1Y,sidMouse2X,sidMouse2Y);
654 printstrvdc(Rect[0]+12,Rect[1]+9,appCtrlTxt2Co,StrBuf);
655 }
656 while(ciaKeyScan[7] != 127);
657 //#asm
658 // ei
659 //#endasm
660 drawmenu(appMenuRect);
661 }
662
dispclock(void)663 void dispclock(void)
664 {
665 //ciaTODStr TODStr;
666 char TODStr[12];
667
668 gettodcia(cia1,appTOD);
669 todstrcia(appTOD,TODStr);
670 printstrvdc(6,0,appClockCo,TODStr);
671 gettodcia(cia2,appTOD);
672 todstrcia(appTOD,TODStr);
673 TODStr[8] = 0; /* get rid of am/pm extension */
674 printstrvdc(71,0,appClockCo,TODStr);
675 }
676
init(void)677 void init(void)
678 {
679 settodcia(cia2,appTOD);
680 clearsid();
681 savevdc();
682 mapvdc();
683 appChSetBufPtr = NULL;
684 }
685
run(void)686 void run(void)
687 {
688 char InKey;
689
690 winvdc(21,5,58,10,vdcAltChrSet+vdcDarkGreen,"INFO");
691 printstrvdc(23,7,vdcAltChrSet+vdcBlink+vdcLightGreen,
692 "SAVING CHARACTER SETS TO BUFFER");
693 if(savechrsets()) /* check if vdc in 16k mode */
694 //if(1) /* check if vdc in 16k mode */
695 {
696 drawmenu(appMenuRect);
697 do
698 {
699 //while (!(kbhit()))
700 dispclock();
701 InKey = toupper(getch());
702 switch (InKey)
703 {
704 case 'A':
705 controlswin(appControlRect);
706 break;
707 case 'B':
708 soundwin(appSoundRect);
709 break;
710 case 'C':
711 playraw(appRawName,appHz);
712 break;
713 case 'D':
714 ilace80x50text();
715 break;
716 case 'E':
717 graphics640x200();
718 break;
719 case 'F':
720 pcx640x200(appPcxName1);
721 break;
722 case 'G':
723 graphics640x480();
724 break;
725 case 'H':
726 pcx640x480(appPcxName2);
727 break;
728 case 'S':
729 set64kmode();
730 break;
731 }
732 }
733 while (InKey != 'X');
734 }
735 }
736
done(void)737 void done(void)
738 {
739 clearsid();
740 if(appChSetBufPtr != NULL)
741 free(appChSetBufPtr);
742 restorevdc(); /* restore registers saved by savevdc() */
743 //putchar(0x1A); /* adm-3a clear-home cursor */
744 putchar(0x12); /* Z88DK CLS */
745 }
746
747