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(); }
int write_file(void) { static unsigned pos,size; ozcls(); ozputs0(0,"Writing..."); if(open1(filename,O_WRONLY)<0) { ozcls(); ozputs0(0,"Error opening file!"); ozgetch(); return -1; } pos=0; clear_wrap_to_end(0); while(pos<file_length) { if(pos+LINE_BUF_LEN<=file_length) size=LINE_BUF_LEN; else size=file_length-pos; ozreadauxmem(pos,line_buf,size); if(write1(line_buf,size)<size) { ozcls(); ozputs0(0,"Error writing!"); close1(); return -1; } pos+=size; } close1(); }
saveconfig() { ozcls(); ozputs(0,70,"Saving Configuration..."); if(makenewconfigfile()==-1) return; ozcls(); ozputs(0,70,"Done. Press any key to continue."); ozngetch(); }
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 reset_term(void) { static byte i; ozcls(); curcol=currow=0; LNM=0; xorcursor(); }
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 read_file(void) { static int r; static byte i; static byte b; ozcls(); ozputs0(0,"Reading..."); file_length=0; if(open1(filename,O_RDONLY)<0) { ozputs0(20,"Cannot open! Create new? [Y/n]"); if(ozgetch()=='n') exit(0); return; } do { r=read1(line_buf,LINE_BUF_LEN); if(file_length+r>MAX_FILE_LENGTH) { ozcls(); ozputs0(0,"File too long!"); ozputs0(10,"Truncate? [y/N]"); if(ozgetch()!='y') exit(0); r=MAX_FILE_LENGTH-file_length; } for(i=0;i<r;i++) { b=line_buf[i]; b&=0x7f; if(b<32) b='*'; line_buf[i]=b; } if(r>0) { ozwriteauxmem(file_length,line_buf,r); file_length+=r; } } while(r==LINE_BUF_LEN && file_length<MAX_FILE_LENGTH); /* note: LINE_BUF_LEN does not divide MAX_FILE_LENGTH, and this is important for truncate message to work */ close1(); }
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; } }
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; }
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; } } }
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(); }
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(); }
void clrscr(void) { extern uchar curcol,currow; ozcls(); curcol=currow=0; }
void load_headers(void) { static char hdr[8]; static unsigned i,n; static byte j,c; static struct ozfontheader fheader; bookmarksmod=0; backandforth=0; numbookmarks=last=0; show_bar=1; ozcls(); x=0; if(!strncmp(directory,filename,3)) { x=ozputs(0,x,"[bookmarks]"); filename[0]='b'; filename[1]='m'; if(open1(filename,O_RDONLY)>=0) { if(read1(hdr,8)==8 && !strncmp(hdr,"BookMrkA",8) && read1(&last,4)==4 && read1(&numbookmarks,1)==1 && read1(bookmarks,sizeof bookmarks)==sizeof bookmarks ) { if(numbookmarks) bookmarkptr=numbookmarks-1; read1(&line_height,1); if(line_height<8 || line_height>10) line_height=8; if(line_height!=9) num_lines=80/line_height; else num_lines=9; if(read1(&show_bar,1)<1 || show_bar>1) { show_bar=1; } if(read1(&positionptr,1)<1 || positionptr>MAX_POSITIONS || read1(&numpositions,1)<1 || numpositions>MAX_POSITIONS || read1(positions,sizeof positions)<sizeof positions) { numpositions=positionptr=0; } else backandforth=1; } else { numbookmarks=last=0; show_bar=1; none(); } close1(); } else { none(); } filename[0]='w'; filename[1]='b'; } else { none(); } x=ozputs(x,0,"[header]"); if(open1(filename,O_RDONLY)<0) err("Cannot open!"); if(read1(hdr,8)<8 || strncmp(hdr,"WizBookA",8) || read1(&header_length,2)<2 || read1(&length,4)<4 || read1(&numwords,2)<2 || read1(&dictionary_length,2)<2 || header_length>16384 || header_length<dictionary_length+10) err(error_header); header_length+=10; if(last==0) last=header_length; x=ozputs(x,0,"[dictionary]"); for(i=0;i<dictionary_length;i+=n) { n=dictionary_length-i; if(n>FILEBUF_LEN) n=FILEBUF_LEN; if(read1(filebuf,n)<n) err(error_dict); ozwriteauxmem(i,filebuf,n); } if(read1(&index_length,1)<1 || read1(&indentnum,1)<1) err(error_header); myfont=0xFF; if(indentnum&0x80) myfont=FONT_CUSTOM0; else if(indentnum&0x40) { x=ozputs(x,0,"[font]"); if(read1(&fheader,sizeof fheader)<sizeof fheader) err(error_font); for(i=0;i<sizeof fheader;i++) ozwritecustomfontbyte(0,i,((byte*)&fheader)[i]); for(i=sizeof fheader;i<fheader.length;i++) { if(read1(&c,1)<1) err(error_font); ozwritecustomfontbyte(0,i,c); } myfont=FONT_CUSTOM0; } if(myfont!=0xFF) { ozscancustomfonts(); line_height=ozgetfontheight(myfont); num_lines=80/line_height; } else { num_lines=line_height=9; myfont=FONT_OZ_NORMAL; } indentnum&=0x3f; for(n=i=0;i<numwords;i++) { j=0; while(!(0x80 & (c=ozreadauxbyte(n+j))) && j<MAX_WORD_LENGTH) j++; if(j==MAX_WORD_LENGTH) err(error_dict); ozwriteauxbyte(n+j,c&0x7f); j++; dict_idx[i]=n; dict_lens[i]=j; n+=j; } buffer_offset=header_length; ozputs(x,0,"[file]"); }
void view(void) { static byte mod; static unsigned k; static unsigned long delta; static byte i; load_headers(); in_buf=0; ateof=0; atstart=1; scrollbar_pos=0xa000+29; if(last==0) last=header_length; goto_pos(last); mod=1; ozcls(); while(1) { if(mod) { if(!backandforth)position_save(); show(); unbar(); scrollbar(); backandforth=mod=0; } switch(k=ozgetchblank()) { case KEY_LEFT: case KEY_BACKSPACE: #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif if(positionptr<=1) break; goto_pos(positions[(--positionptr)-1]); if(!positionptr) positionptr=1; backandforth=mod=1; #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif break; case KEY_RIGHT: #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif if(positionptr>=numpositions) break; goto_pos(positions[positionptr]); positionptr++; backandforth=mod=1; #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif break; case 'm': /* mark position */ if(numbookmarks>=MAX_BOOKMARKS) { for(i=0;i<MAX_BOOKMARKS-1;i++) { bookmarks[i]=bookmarks[i+1]; } numbookmarks--; } bookmarkptr=numbookmarks; bookmarks[numbookmarks++]=screen_offset+buffer_offset; bookmarksmod=1; break; case 'b': if(numbookmarks) { goto_pos(bookmarks[bookmarkptr]); if(bookmarkptr) bookmarkptr--; else bookmarkptr=numbookmarks-1; mod=1; } break; case 'r': show_bar=!show_bar; bookmarksmod=1; unbar(); scrollbar(); break; case 'h': case KEY_UPPER_MENU: case KEY_LOWER_MENU: dohelp(); ozcls(); mod=1; break; case 'i': _ozfilledbox(0,0,WIDTH,line_height,0); delta=screen_offset+buffer_offset-header_length; putformatted(0,0,"$ : ^/^=|%",filename, delta,length-header_length, (unsigned int)(delta*100/(length-header_length)) ); _ozfilledbox(0,0,WIDTH,line_height,XOR); ozgetchblank(); mod=1; ozcls(); break; case 'c': if(numbookmarks && ozwarn("Delete all bookmarks?",yn)==KEY_LOWER_ENTER ) { bookmarksmod=1; numbookmarks=0; } mod=1; ozcls(); break; case '-': case KEY_PAGEUP: for(i=0;i<num_lines-1;i++) { checkshiftup(); backline(); } mod=1; break; case 's': if(myfont) break; line_height++; if(line_height==11) line_height=8; if(line_height!=9) num_lines=80/line_height; else num_lines=9; bookmarksmod=1; mod=1; ozcls(); break; case KEY_PAGEDOWN: case KEY_LOWER_ENTER: case KEY_UPPER_ENTER: case KEY_RETURN: case ' ': for(i=0;i<num_lines-1;i++) { checkshiftdown(); forwardline(); } mod=1; break; case KEY_UP: checkshiftup(); if(!backline()) break; unbar(); ozscrolldown(line_height*30); dcompline(filebuf+screen_offset); puttextline(0); position_save(); scrollbar(); break; case KEY_DOWN: checkshiftdown(); if(forwardline()) { mod=1; showbot=1; unbar(); ozscroll(line_height*30); } break; case KEY_LEFT_SHIFT | MASKSHIFT: case KEY_RIGHT_SHIFT | MASKSHIFT: switch(ozgetch() & 0xF0FF) { case '-': ozclick(!ozgetclick()); ozsavekeysettings(); break; case KEY_PAGEUP: case KEY_UP: tenpercent(-1); mod=1; break; case KEY_PAGEDOWN: case KEY_DOWN: tenpercent(1); mod=1; break; } break; case KEY_UP | MASKSHIFT: case KEY_PAGEUP | MASKSHIFT: tenpercent(-1); mod=1; break; case KEY_PAGEDOWN | MASKSHIFT: case KEY_DOWN | MASKSHIFT: tenpercent(1); mod=1; break; case KEY_2ND: switch(ozgetch() & 0xF0FF ) { case '-': ozclick(!ozgetclick()); ozsavekeysettings(); break; case KEY_PAGEUP: case KEY_UP: goto_pos(header_length); mod=1; break; case KEY_PAGEDOWN: case KEY_DOWN: goto_pos(length); mod=1; break; } break; case KEY_LOWER_ESC: case KEY_UPPER_ESC: case KEY_MYPROGRAMS: exit(0); case KEY_MAIN: case KEY_CALENDAR: case KEY_TELEPHONE: case KEY_MEMO: ozexitto(k); case KEY_BACKLIGHT: oztogglelight(); break; } } }
pull() { ozsetactivepage(1); ozcls(); if(speed==0) { srand(ozmin()+60*ozsec()); switch(rand()%3) { case 0: speed=1; break; case 1: speed=2501; break; case 2: speed=5001; break; } } srand(ozsec()+60*ozmin()); switch(rand()%4) { case 0: house=LEFT; break; case 1: house=RIGHT; break; case 2: house=RIGHT; break; case 3: house=LEFT; break; } if(house==LEFT) { for(x=0, y=79 ; y>0 ; x++, y--) { if(ozkeyhit()) { switch(ozngetch()) { case KEY_LEFT: gunpos=LEFT; break; case KEY_RIGHT: gunpos=RIGHT; break; case 32: { if(shots>=1) { fire(gunpos); } break; } case KEY_LOWER_MENU: case 'h': { help(); break; } } } ozcls(); drawgun(); ozdelay(speed); ozcircle(x,y,2,4|1); ozswapactivedisplay(); } } if(house==RIGHT) { for(x=238, y=79 ; y>0 ; x--, y--) { if(ozkeyhit()) { switch(ozngetch()) { case KEY_LEFT: gunpos=LEFT; break; case KEY_RIGHT: gunpos=RIGHT; break; case 32: { if(shots>=1) { fire(gunpos); } break; } case KEY_LOWER_MENU: case 'h': { help(); break; } } } ozcls(); drawgun(); ozdelay(speed); ozcircle(x,y,2,4|1); ozswapactivedisplay(); } } if(random==1) { speed=0; } }
void nofiles(void) { ozcls(); ozwarn("No files!",anykey); exit(0); }
char *selectname(void) { static fname files[9]; static byte refresh; static byte pos; static unsigned i; static unsigned i1; static unsigned k; static unsigned curpos; static unsigned cursorloc; register char *f; cursorloc=curpos=0; ozfont(FONT_OZ_NORMAL); f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); if(f==NULL) nofiles(); do { background(); for(pos=i=0;i<9;i++,pos+=8) { if(i && NULL==(f=ozgetnextfilename0(FIND_OWNED))) break; strcpy(files[i],f); putformatted(0,pos,"|. $",i+1,f); /* ozputch(0,pos,i+'1'); ozputch(5,pos,'.'); ozputs(9,pos,f); */ } curpos+=9; if(cursorloc>=i) cursorloc=i-1; /* ozputs(0,72,"\x0A/\x0B:choose \x0D/1-9:load Del:del. C:clear bkmrks A:del. all"); */ if(NULL!=f) f=ozgetnextfilename0(FIND_OWNED); refresh=0; do { _ozfilledbox(0,8*cursorloc,150,8,XOR); k=ozgetchblank(); _ozfilledbox(0,8*cursorloc,150,8,XOR); switch(k) { case KEY_LOWER_ESC: case KEY_UPPER_ESC: exit(0); case KEY_MAIN: case KEY_TELEPHONE: case KEY_SCHEDULE: case KEY_MEMO: case KEY_MYPROGRAMS: ozexitto(k); case KEY_BACKLIGHT: oztogglelight(); break; case 'a': if(ozwarn("Are you sure you want to delete all?",yn)!= KEY_LOWER_ENTER) { refresh=1; f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); cursorloc=curpos=0; break; } ozunlinkallowned(); exit(0); case KEY_BACKSPACE: case 'c': ozcls(); f=files[cursorloc]; ozputs(ozputs(0,0,k==KEY_BACKSPACE?"Deleting: ":"Clearing bookmarks for: "),0,f); if(ozwarn("Are you sure?",yn)==KEY_LOWER_ENTER) { if(k==KEY_BACKSPACE) unlink(f); if(!strncmp(f,directory,3)) { f[0]='b'; f[1]='m'; unlink(f); } } refresh=1; f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); if(f==NULL) nofiles(); cursorloc=curpos=0; break; case KEY_LOWER_ENTER: case KEY_UPPER_ENTER: case KEY_RETURN: return files[cursorloc]; case KEY_UP: if(cursorloc) cursorloc--; else if(curpos>=18) { cursorloc=8; k=KEY_PAGEUP; } break; case KEY_DOWN: if(cursorloc<i-1) cursorloc++; else if(f!=NULL) { cursorloc=0; k=KEY_PAGEDOWN; } break; } switch(k) { case KEY_PAGEUP: if(curpos>=18) { curpos-=18; f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); for(i1=0;i1<curpos;i1++) ozgetnextfilename0(FIND_OWNED); refresh=1; } else cursorloc=0; break; case KEY_PAGEDOWN: refresh=1; if(f==NULL) { cursorloc=i-1; refresh=0; } break; } if(k>='1' && k<'1'+i) refresh=1; } while(!refresh); } while(k<'1' || k>='1'+i); return files[k-'1']; }