movie() { speed=501; ozcls(); ozsetactivepage(1); ozsetdisplaypage(0); ozcls(); for(x=0, y=79 ; y>20 ; x++, y--) { ozcls(); drawgun(); ozcircle(x,y,2,4|1); ozdelay(speed); ozswapactivedisplay(); } ozsetactivepage(0); ozsetdisplaypage(0); ozline(97,60,37,0,1); shatter(); /* movietext();*/ ozsetfont(FONT_OZ_LARGE); ozputs(119,20,"OZ Clay Pigeons"); ozsetfont(FONT_OZ_NORMAL); ozputs(0,70,"Press Any Key..."); speed=2501; ozngetch(); }
saveconfig() { ozcls(); ozputs(0,70,"Saving Configuration..."); if(makenewconfigfile()==-1) return; ozcls(); ozputs(0,70,"Done. Press any key to continue."); ozngetch(); }
main() { ozputs(10,10,"Saving screen!"); ozsavescreen(); ozgetch(); ozputs(10,10,"Saved the screen!"); ozgetch(); ozrestorescreen(); ozgetch(); }
option() { ozcls(); getsound(); getmovie(); ozputs(0,0,"Options: (Press ENTER when done, MENU to save)"); ozputs(0,20,"PgUp/PgDn: Clay Pigeon Speed"); putspeed(); ozputs(135,20,slow); ozputs(0,30,"S: Toggle Sound"); ozputs(135,30,soundstat); ozputs(0,40,"M: Toggle Startup Movie"); ozputs(135,40,moviestat); ozputs(0,55,"(You should save after changing startup movie option)"); ozputs(0,70,"OZCP Concept by Danny Jackson, coded by Chris Daniel"); switch(ozngetch()) { case 's': changesound(); break; case 'm': changemovie(); break; case KEY_PAGEUP: { if(speed==5001|speed==2501) { speed-=2500; } else if(speed==1) { speed=0; } else if(speed==0) { speed=5001; } break; } case KEY_PAGEDOWN: { if(speed==2501|speed==1) { speed+=2500; } else if(speed==5001) { speed=0; } else if(speed==0) { speed=1; } break; } case KEY_LOWER_MENU: saveconfig(); break; case KEY_UPPER_MENU: saveconfig(); break; case KEY_LOWER_ENTER: main(); case KEY_NEWLINE: ozsnap(); break; } option(); }
void checkpage(byte line,unsigned page) { register unsigned *x=(void*)0xa000; unsigned i; setpage(page); for(i=0;i<4096;i++) { if(x[i]!=i*i+0x4221+i) { ozputs(0,line,"Error in readback!"); return; } } ozputs(0,line,"OK!"); }
addtoshots(int t) { static char bullets[24]; shots+=t; sprintf(bullets,"Bullets: %ld",shots); ozputs(189,0,bullets); }
addtoscore(int s) { static char thescore[22]; score+=s; sprintf(thescore,"Score: %ld",score); ozputs(0,0,thescore); }
getinitials(byte x3,byte y3) { static byte i; static unsigned k; i=0; while(i<3) { switch(k=ozgetch()) { /* case KEY_BACKSPACE: case 8: if(i) { i--; x3-=ozputs(x3,y3,initials+i); ozputs(x3,y3," "); } break;*/ case KEY_LOWER_ESC: case KEY_UPPER_ESC: exit(0); default: if(k<127 && (isalpha(k) || isdigit(k))) { initials[i]=toupper(k); initials[i+1]=0; x3=ozputs(x3,y3,initials+i); i++; } break; } } }
accuracy(int x2, int y2) { total=hits+misses; acc=hits/(total/100); if((hits==0)&&(misses==0)) acc=0; sprintf(accrate,"Accuracy: %fd",acc); ozputs(x2,y2,accrate); }
static void setcursor(void) { static byte c; c = s[pos]; s[pos] = 0; x = ozputs(x0, -1, s); s[pos] = c; }
main() { static char s[26]; s[0]=0; ozeditline(0,0,s,26,100); ozputs(10,10,s); ozgetch(); }
main() { char s1[80]; char *s; ozputs(0,0,"Starting..."); s=sbrk(2048); sprintf(s1,"sbrk(2048)=%x\n",s); ozputs(0,0,s1); s=malloc(2048); sprintf(s1,"malloc(2048)=%x\n",s); ozputs(0,10,s1); s=malloc(1024); sprintf(s1,"malloc(1024)=%x\n",s); ozputs(0,20,s1); s=malloc(14000); sprintf(s1,"malloc(14000)=%x\n",s); ozputs(0,30,s1); }
int dumpat(int y,long startdate, int loc, int num) { static int vh,ap,day,i; static byte putheader; vh=viewheaders && !repeatchooser; ap= -vh; day=0; putheader=!repeatchooser && mainheader; i=putheader; if(!found && !repeatchooser) { printheader(y+0,startdate); if(propfont) #ifndef ITALIAN ozputs(0,y+PROP_FONT_HEIGHT,"No appointments found."); #else /* ITALIAN */ ozputs(0,y+PROP_FONT_HEIGHT,"Non trovo appuntamenti."); #endif /* ITALIAN */ else
main() { static byte sides; srand(oztime()); ozfont(FONT_OZ_LARGE); ozputs(0,10,"Sides? (1-9)"); sides=ozgetch()-'0'; ozputch(115,30,'0'+(rand()%sides)); ozgetch(); }
main() { checkpage(0,0x404); checkpage(10,0x405); ozputs(0,20,"Fill?"); if(ozgetch()!='y') return; fillpage(0x404); fillpage(0x405); return; }
main() { ozgetauxsize(); ozclick(0); ozcls(); if(load==1) { loadconfig(); } if(mov==1) { if(watch==1) { movie(); watch=0; } } ozcls(); high=1; prevhigh=0; score=0; shots=25; hits=0; misses=0; acc=0; bullseyes=0; ozquiet(); ozsetfont(FONT_OZ_LARGE); ozputs(0,0,"OZ Clay Pigeons"); ozsetfont(FONT_OZ_NORMAL); ozputs(95,3,"Version 2.0"); ozputs(0,20,"(1) Play OZ Clay Pigeons"); ozputs(0,30,"(2) High Scores"); ozputs(0,40,"(3) Keys"); ozputs(0,50,"(4) Options"); ozputs(0,60,"(5) Quit OZ Clay Pigeons"); ozputs(130,20,"Made with Hi-Tech C;"); ozputs(130,30,"USE AT YOUR OWN RISK!"); ozputs(130,50,"Up/Dn arrows to select"); highlight(); main(); }
endgameswitch() { ozcopypage(0,1); ozcls(); ozputs(0,70,"Are you sure you want to leave this game? (Y/N)"); switch(ozngetch()) { case 'y': endgame(); break; case 'n': ozcopypage(1,0); play(); break; } }
int savehighscores(char *name) { if(open1(name,O_WRONLY)==-1) { ozputs(0,0,"Error opening file. Press any key."); ozngetch(); close1(); return -1; } sprintf(savechar,"%s %ld",initials,score); if(write1(savechar,14)==-1) { ozputs(0,0,"Error writing file. Press any key."); ozngetch(); close1(); return -1; } close1(); return 0; }
endgame() { ozcls(); configswitch(); loadhighscores(spd); if(score<=score0) return; else if(score>score0) { x=ozputs(0,70,"New high score! Enter your initials: "); getinitials(x,70); ozcls(); ozputs(0,70,"Saving Score..."); switch(spd) { case 0: savehighscores("ozcp20/highscore0"); break; case 1: savehighscores("ozcp20/highscore1"); break; case 2: savehighscores("ozcp20/highscore2"); break; case 3: savehighscores("ozcp20/highscore3"); break; } } }
int makenewconfigfile() { if(open1("ozcp20/config",O_WRONLY)==-1) { ozcls(); ozputs(0,70,"Error opening file. Press any key."); ozngetch(); return -1; } configswitch(); sprintf(config,"%d %d %d",mov,spd,sound); if(write1(config,6)==-1) { ozcls(); ozputs(0,70,"Error writing file. Press any key."); ozngetch(); return -1; } close1(); return 0; }
loadconfig() { ozputs(0,70,"Loading configuration..."); if(open1("ozcp20/config",O_RDONLY)==-1) { makenewconfigfile(); if(makenewconfigfile()==-1) return; } read1(config,5); close1(); loadconfigswitch(); load=0; }
keys() { ozcls(); ozsetfont(FONT_OZ_NORMAL); ozputs(0,0,"CONTROL KEYS:"); ozputs(0,10,"Left/Right Arrows: Switch gun positions"); ozputs(0,20,"Enter: Pull"); ozputs(0,30,"Space: Fire Gun"); ozputs(0,40,"H/Lower Menu Key: This screen"); ozputs(0,50,"MY PROGRAMS: Quit OZCP"); ozputs(0,60,"S: Toggle Sound"); ozputs(0,70,"ANY KEY TO CONTINUE..."); ozngetch(); main(); }
play() { ozcls(); ozsetactivepage(0); ozsetdisplaypage(0); ozcls(); if(shots<1) { ozcls(); ozputs(0,0,"Out of Bullets! Game Over!"); ozngetch(); exit(0); } ozsetfont(FONT_OZ_NORMAL); drawgun(); addtoscore(0); addtoshots(0); sprintf(bullseye,"Bullseyes: %ld",bullseyes); ozputs(170,60,bullseye); accuracy(170,70); getsound(); ozputs(0,70,soundstat); ozputs(0,30,"Press <ENTER> to pull, then <SPACE> to fire."); switch(ozgetch()) { case KEY_BACKLIGHT: oztogglelight(); break; case KEY_MYPROGRAMS: endgameswitch(); exit(0); case KEY_LOWER_ESC: endgameswitch(); main(); case KEY_LOWER_ENTER: pull(); break; case KEY_LEFT: gunpos=LEFT; break; case KEY_RIGHT: gunpos=RIGHT; break; case KEY_LOWER_MENU: help(); break; case 'h': help(); break; case 's': changesound(); break; case KEY_NEWLINE: ozsnap(); break; } play(); }
void main(void) { extern unsigned _ozautoofftime; _ozautoofftime=60*10/4; preparehelp(); ozrestorekeysettings(); ozcls(); ozputs(0,0,"Checking for new books..."); frommemo(); bookmarksmod=0; strcpy(filename,selectname()); ozcls(); atexit(savebookmarks); view(); return; }
void printheader(int y, long startdate) { static byte x; reverse=1; #ifndef OLDSTYLE if(propfont) x=ozputch(0,y,' '); else termputch(' '); #else x=0; #endif x=dumpdate(x,y,startdate,0,0); if(propfont) x=ozputs(x,y," - "); else termputs(" - "); x=dumpdate(x,y,startdate,NUMDAYS-1,0); if(!propfont) while(curcol<WIDTH) termputch(' '); else reverselines(y,PROP_FONT_HEIGHT); reverse=0; }
int dumpdate(int x, int y, long startdate, int index, int longform) { if(!propfont) { termputs(longform?days[(startdate+index) % 7]: shortdays[(startdate+index) % 7]); termputs(", "); #ifdef ITALIAN termputs(itoa(theday[index])); ttyprint(' '); #endif /* ITALIAN */ termputs(months[themonth[index]-1]); ttyprint(' '); #ifndef ITALIAN termputs(itoa(theday[index])); termputs(", "); #endif /* not ITALIAN */ termputs(itoa(theyear[index])); return 0; } else { x=ozputs(x,y,longform?days[(startdate+index) % 7]: shortdays[(startdate+index) % 7]); x=ozputs(x,y,", "); #ifdef ITALIAN x=ozputs(x,y,itoa(theday[index])); x=ozputs(x,y," "); #endif /* ITALIAN */ x=ozputs(x,y,months[themonth[index]-1]); x=ozputch(x,y,' '); #ifndef ITALIAN x=ozputs(x,y,itoa(theday[index])); x=ozputs(x,y,", "); #endif /* not ITALIAN */ x=ozputs(x,y,itoa(theyear[index])); return x; } }
void savebookmarks(void) { if(!bookmarksmod || strncmp(directory,filename,3)) return; close1(); /* just in case */ _ozfilledbox(0,0,WIDTH,line_height,0); ozputs(0,0,"Saving bookmarks..."); filename[0]='b'; filename[1]='m'; if(open1(filename,O_WRONLY)<0) return; write1("BookMrkA",8); last=screen_offset+buffer_offset; write1(&last,4); write1(&numbookmarks,1); write1(bookmarks,sizeof bookmarks); write1(&line_height,1); write1(&show_bar,1); write1(&positionptr,1); write1(&numpositions,1); write1(positions,sizeof positions); close1(); }
fire(int d) { ozsetactivepage(ozgetdisplaypage()); if(d==LEFT) { shots-=1; ozline(97,60,37,0,1); a=x-1; b=y+1; c=x+1; d=y-1; if((x==59&&y==20)|(a==59&&b==20)|(c==59&&d==20)) { hit=1; addtoscore(50); addtoshots(2); ozputs(0,70,"HIT!"); if(x==59&&y==20) { shatter(); addtoscore(50); addtoshots(2); bullseyes+=1; ozputs(20,70,"Bullseye!"); hitsound(); } } switch(ozngetch()) { case KEY_NEWLINE: ozsnap(); break; default: break; } } if(d==RIGHT) { shots-=1; ozline(141,60,201,0,1); a=x-1; b=y-1; c=x+1; d=y+1; if((x==179&&y==20)|(a==179&&b==20)|(c==179&&d==20)) { hit=1; addtoscore(50); addtoshots(2); ozputs(0,70,"HIT!"); if(x==179&&y==20) { ozpoint(183,10,1); ozpoint(185,12,1); ozpoint(182,14,1); ozpoint(182,15,1); ozpoint(180,17,1); ozpoint(186,18,1); ozpoint(185,20,1); ozpoint(186,20,1); ozpoint(181,19,0); ozpoint(180,20,0); ozpoint(182,20,0); ozpoint(179,21,0); ozpoint(181,21,0); ozpoint(178,22,0); ozpoint(180,22,0); ozpoint(179,23,0); addtoscore(50); addtoshots(2); bullseyes+=1; ozputs(20,70,"Bullseye!"); hitsound(); } } switch(ozngetch()) { case KEY_NEWLINE: ozsnap(); break; default: break; } } if(ozgetdisplaypage()==0) ozsetactivepage(1); else ozsetactivepage(0); if(hit==0) { misses+=1; } if(hit==1) { hits+=1; hit=0; y=0; } }
void frommemo(void) #endif { static unsigned loc,page,offset,recnum; register char *p; static char filename[32]; static char parthead[21]; static char continued; static unsigned int sum; static byte val; static byte version2; static int i; static unsigned j; static int c; static int partnumber; static char checksum[6]; page=0; offset=0; while(loc=ozfindnext(TYPE_MEMO,&page,&offset,&recnum)) { partnumber=0; p=ozloadcluster(loc); if(p[24]!='~' || p[25]!='~' || p[26]!='z' || strncmp(p+2+13+9+15,"00000",5) || strncmp(p+2+13+9+21,"**LIBOZ_UPLOAD*",15)) continue; do { strcpy(parthead,p+24); if(ozopenfile(loc)==-1) { ozwarn("Error opening memo!",anykey); return; } for(i=0;i<13+9+21+15;i++) ozreadfilebyte(); continued=ozreadfilebyte(); p=filename; while('\r'!=(c=ozreadfilebyte()) && '\n'!=c && p-filename<MAX_FILENAMELEN) { if(partnumber) { if(c!=*p) { ozputs(0,70,"You may have the remains of " "another download."); ozclosefile(); close1(); unlink(filename); ozgetch(); return; } } else *p=c; p++; } if(p-filename>MAX_FILENAMELEN) { ozwarn("Filename too long!",anykey); return; } *p=0; ozputs(0,10,filename); ozputs(0,20,parthead); if(!partnumber) { ozsetowner(atoi(parthead+3)); if(open1(filename,O_WRONLY)==-1) { ozwarn("Error opening file!",anykey); return; } } sum=0; p=filebuf; if(!partnumber) { c=ozreadfilebyte(); if(c==TOMEMO2_MARKER) { version2=1; for(j=0;j<NUMSPECIALS;j++) { c=ozreadfilebyte(); table[j]=(c-HEX)|((ozreadfilebyte()-HEX)<<4); } } else { version2=0; goto PROCESS_VERSION1; } } if(version2) { while(-1!=(c=ozreadfilebyte()) && (byte)c!=EOF_MARKER) { if((byte)c>=SPECIAL) val=table[c-SPECIAL]; else val=(c-HEX)|((ozreadfilebyte()-HEX)<<4); sum+=val; *p++=val; } if(c==EOF_MARKER) c='*'; } else { while(-1!=(c=ozreadfilebyte())) { PROCESS_VERSION1: if((byte)c=='*') break; if((byte)c=='~') { while(-1!=(c=ozreadfilebyte()) && '~'!=(byte)c) { sum+=(byte)c; *p++=c; } } else { if('0'<=(byte)c && (byte)c<='9') val=(c-'0')<<4; else val=(c+(10-'a'))<<4; c=ozreadfilebyte(); if('0'<=(byte)c && (byte)c<='9') val+=(c-'0'); else val+=(c+(10-'a')); *p++=val; sum+=(byte)val; } } c=ozreadfilebyte(); } if('*'==c) { for(i=0;i<5;i++) checksum[i]=ozreadfilebyte(); checksum[5]=0; } if('*'!=c || (unsigned)(atoi(checksum))!=sum) { ozclosefile(); close1(); unlink(filename); ozwarn("Error in memo!",anykey); return; } ozclosefile(); if(write1(filebuf,p-filebuf) < (p-filebuf) ) { close1(); unlink(filename); ozwarn("Error in writing!",anykey); return; } if(ozunlink(TYPENUM_MEMO,recnum)) { if(ozwarn("Error unlinking! Continue?",yn)!=KEY_LOWER_ENTER) return; } /* ozputch(0,0,continued); */ if(continued=='L') break; partnumber++; strcpy(parthead+15,utoa_0n(partnumber,5)); page=offset=0; while(loc=ozfindmemo(parthead,&page,&offset,&recnum)) { p=ozloadcluster(loc); if(strncmp(p+2+13+9+21,"**LIBOZ_UPLOAD*",15)) continue; break; } if(loc==0) { close1(); unlink(filename); ozwarn("Error: Cannot find next part!",anykey); return; } } while(loc); close1(); page=offset=0; } }
highscores() { sprintf(randspeed,""); sprintf(dreispeed,""); sprintf(zweispeed,""); sprintf(einspeed,""); ozcls(); ozputs(0,70,"Loading High Scores..."); if(loadhighscores(4)==-1) return; ozcls(); ozsetfont(FONT_OZ_LARGE); ozputs(0,0,"OZCP High Scores"); ozsetfont(FONT_OZ_NORMAL); ozputs(0,20,"Random Speed:"); ozputs(0,30,"3rd Speed:"); ozputs(0,40,"2nd Speed:"); ozputs(0,50,"1st Speed:"); ozputs(119,20,randspeed); ozputs(119,30,dreispeed); ozputs(119,40,zweispeed); ozputs(119,50,einspeed); ozputs(0,70,"R to reset scores, or any other key to continue."); switch(ozngetch()) { case 'r': { ozcls(); ozputs(0,70,"Deleting Highscores..."); unlink("ozcp20/highscore0"); unlink("ozcp20/highscore1"); unlink("ozcp20/highscore2"); unlink("ozcp20/highscore3"); sprintf(randspeed,""); sprintf(dreispeed,""); sprintf(zweispeed,""); sprintf(einspeed,""); break; } } }