static void load_foo() { cbm_open(8, 8, 8, "foo"); cbm_read(8, (char*)0x7ff, 0x801 + 0x1800); // Low-code + music. cbm_read(8, HEAP_START, 0x1000); // Code - throw it away... cbm_read(8, HEAP_START, (char*)0xd000u - HEAP_START); // Animation! cbm_close(8); }
int ssReadRELFile(ST_FILE *pstFile, void *pvBuffer, unsigned int uiBuffSize, unsigned int uiRecNo) { char command[40]; char cbm_filename[40]; int siRet=0; int channel, hi, lo; channel=3+96; sprintf(cbm_filename,"0:%s,l,%c", pstFile->szFileName, uiBuffSize); siRet = cbm_open( 15, pstFile->ucDeviceNo, 15, NULL); siRet = cbm_open( 2, pstFile->ucDeviceNo, 3, cbm_filename); hi=(uiRecNo/256); lo=uiRecNo-(hi*256); sprintf(command, "p%c%c%c", channel, lo, hi); siRet=cbm_write( 15, command, strlen(command)); siRet = cbm_read( 2, pvBuffer, uiBuffSize); cbm_close(15); cbm_close(2); return siRet; }
int siFileExists(ST_FILE *pstFile) { unsigned char ucBuff[128]; unsigned char szTmp[15]; unsigned char msg[40]; unsigned char e, t, s; int siRet=0; strcpy(szTmp,"@:"); strcat(szTmp, pstFile->szFileName); strcat(szTmp, ",p,r"); cbm_open( 15, pstFile->ucDeviceNo, 15, NULL); cbm_open( 2, pstFile->ucDeviceNo, 3, pstFile->szFileName); if ( cbm_read(15, ucBuff, sizeof(ucBuff)) < 0) { return -1; } cbm_close(15); if (sscanf(ucBuff, "%hhu, %[^,], %hhu, %hhu", &e, msg, &t, &s) != 4) { puts("parse error"); puts(ucBuff); return -1; } cbm_close(2); cbm_close(15); return (int) e; }
int siDriveStatus(ST_FILE *pstFile) { unsigned char ucBuff[128]; unsigned char msg[40]; unsigned char e, t, s; if (cbm_open(1, pstFile->ucDeviceNo, 15, "") == 0) { if ( cbm_read(1, ucBuff, sizeof(ucBuff)) < 0) { return -1; } cbm_close(1); } if (sscanf(ucBuff, "%hhu, %[^,], %hhu, %hhu", &e, msg, &t, &s) != 4) { printf("\nparse error\n"); puts(ucBuff); return -1; } /*printf("\n%hhu,%s,%hhu,%hhu\n", (int) e, msg, (int) t, (int) s);*/ return (int) e; }
void dir() { CBM_Sector s; int track=40,sector=3; cbm_read(&s,40,0); printdiskname(&s.h); do { cbm_read(&s,track,sector); printfile(&s.f.f1); printfile(&s.f.f2); printfile(&s.f.f3); printfile(&s.f.f4); printfile(&s.f.f5); printfile(&s.f.f6); printfile(&s.f.f7); printfile(&s.f.f8); track=s.next_track; sector=s.next_sector; } while(track!=0); }
unsigned char getData() { bordercolor(2); //Make sure all devices are closed before opening again cbm_close( 2 ); //If its a local file, use device 8 if(url[0]=='/'){ //remove leading '/' and add a ',s' to allow openning of a seq file memmove(url, url+1, strlen(url)); strcat(url,",s"); cbm_close( 8 ); cbm_open( 2, 8, 2, url ); } //Get local data for an already formated URL else if(url[strlen(url)-2]==',' && url[strlen(url)-1]=='s'){ cbm_close( 8 ); cbm_open( 2, 8, 2, url ); } //For remote files use device 7 (Flyer) else{ cbm_close( 7 ); // if( cbm_open( 7, 7, 15, "" ) != 0 ) { cputs("Flyer not connected!"); } cbm_open( 2, 7, 2, url ); cbm_write( 7, "http-transact:2",15); } //Clear the input buffer: memset(&sRecvBuf[0], 0, sizeof(sRecvBuf)); //Read a chunk (or all if small) of the file: cbm_read( 2, sRecvBuf, sizeof(sRecvBuf)); bordercolor(0); return(1); }
/*---------------------------------------------------------------------------*/ static int s_read(int f, char *b, unsigned int l) { return cbm_read(f, b, l); }
int main( void ) { int i = 0; int bufIndx; int bufPage; int charCnt; char cursorx; char cursory; memcpy ((void*) SPRITE0_DATA, MouseSprite, sizeof (MouseSprite)); /* Load and install the mouse driver */ mouse_load_driver (&mouse_def_callbacks, DRIVER); /* Set the VIC sprite pointer */ *(unsigned char*)SPRITE0_PTR = SPRITE0_DATA / 64; VIC.spr0_color = COLOR_WHITE; bgcolor (0); bordercolor (0); clrscr (); while( showAddrsBar()<1){bufPage=1;} bufPage=1; bufIndx=0; charCnt = screenRender(bufIndx); cursorx=20; cursory=11; mouse_show(); mouse_move (cursorx , cursory); while( sRunning ) { if( kbhit() ) { //uint8_t pet = cgetc(); char pet = cgetc(); switch( pet ) { //Move cursor down case PETSCII_DOWN: if(cursory < screenPixH){ cursory++; mouse_move (cursorx , cursory); } break; //Move cursor up case PETSCII_UP: if(cursory > 0){ cursory--; mouse_move (cursorx , cursory); } break; //Move cursor left case PETSCII_LEFT: if(cursorx > 0){ cursorx--; mouse_move (cursorx , cursory); } break; //Move cursor right case PETSCII_RIGHT: if(cursorx < screenPixW-1){ cursorx++; mouse_move (cursorx , cursory); } break; //Scroll UP case PETSCII_F1: bufIndx = bufIndx - charCnt; if(bufIndx <0){ if(bufPage>1){ getData(); bufIndx=bufSize - charCnt; bufPage--; textcolor(bufPage); } else{bufIndx=0;} } charCnt = screenRender(bufIndx); break; //Scroll DOWN case PETSCII_F7: bufIndx = bufIndx + charCnt; if(bufIndx > bufSize){ cbm_read( 2, sRecvBuf, sizeof(sRecvBuf)); bufIndx=0; bufPage++; textcolor(bufPage); } charCnt = screenRender(bufIndx); break; //Show URL address entry bar case PETSCII_STOP: if(showAddrsBar() >0){ bufPage=1; bufIndx=0; charCnt = screenRender(bufIndx); } break; } } } cbm_close( 2 ); cbm_close( 7 ); cbm_close( 8 ); return(0); }