git @ Cat's Eye Technologies linapple / 5c79f41
Cleanup several build warnings, bringing some code into line with modern compiler standards; Remove some redundant files. ghedger 4 years ago
16 changed file(s) with 100 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
0
1
02 *** LINAPPLE 2.0***
3
4 Copyright (C) 1994-1996, Michael O'Brien
5 Copyright (C) 1999-2001, Oliver Schmidt
6 Copyright (C) 2002-2005, Tom Charlesworth
7 Copyright (C) 2006-2007, Tom Charlesworth, Michael Pohoreski
8 Copyright (C) 2015,2017, Greg Hedger
19
210 [INTRO]
311 What is linapple?
2222 #define RAMWORKS // 8MB RamWorks III support
2323
2424 #define MOCKINGBOARD // Mockingboard support
25 //#define MB_SPEECH
2526
2627 // Use a base freq so that DirectX (or sound h/w) doesn't have to up/down-sample
2728 // Assume base freqs are 44.1KHz & 48KHz
6364 //#define MAXIMAGES 16
6465
6566 // TODO: Move to StringTable.h
66 #define TITLE_APPLE_2 TEXT("Apple ][ Emulator")
67 #define TITLE_APPLE_2 ("Apple ][ Emulator")
6768 #define TITLE_APPLE_2_PLUS TEXT("Apple ][+ Emulator")
6869 #define TITLE_APPLE_2E TEXT("Apple //e Emulator")
6970 #define TITLE_APPLE_2E_ENHANCED TEXT("Enhanced Apple //e Emulator")
33
44 #define MAKE_VERSION(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | (d))
55
6 #define AW_SS_TAG 'SSWA' // 'AWSS' = AppleWin SnapShot
6 #define AW_SS_TAG (('S'<<24)|('S'<<16)|('W'<<8)|'A') // 'AWSS' = AppleWin SnapShot
77
88 typedef struct
99 {
Binary diff not shown
4646
4747 //char VERSIONSTRING[] = "xx.yy.zz.ww";
4848
49 TCHAR *g_pAppTitle = TITLE_APPLE_2E_ENHANCED;
49 // Satisfy modern compiler standards
50 static char TITLE_APPLE_2_[] = TITLE_APPLE_2;
51 static char TITLE_APPLE_2_PLUS_[] = TITLE_APPLE_2_PLUS;
52 static char TITLE_APPLE_2E_[] = TITLE_APPLE_2E;
53 static char TITLE_APPLE_2E_ENHANCED_[] = TITLE_APPLE_2E_ENHANCED;
54
55 TCHAR *g_pAppTitle = TITLE_APPLE_2E_ENHANCED_;
5056
5157 eApple2Type g_Apple2Type = A2TYPE_APPLE2EEHANCED;
5258
207213 VideoUpdateFlash();
208214
209215 static BOOL anyupdates = 0;
210 static DWORD lastcycles = 0;
216 //static DWORD lastcycles = 0;
211217 static BOOL lastupdates[2] = {0,0};
212218
213219 anyupdates |= screenupdated;
214220
215221 //
216222
217 lastcycles = cumulativecycles;
223 //lastcycles = cumulativecycles;
218224 if ((!anyupdates) && (!lastupdates[0]) && (!lastupdates[1]) && VideoApparentlyDirty())
219225 {
220226 VideoCheckPage(1);
390396 if (dir && *dir) {
391397 struct stat st;
392398 if(stat("/tmp",&st) == 0)
393 if(st.st_mode & S_IFDIR != 0)
399 if((st.st_mode & S_IFDIR) != 0)
394400 ret = true;
395401 }
396402 printf("%s is dir? %d\n", dir, ret);
440446 // determine Apple type and set appropriate caption -- should be in (F9)switching modes?
441447 switch (g_Apple2Type)
442448 {
443 case A2TYPE_APPLE2: g_pAppTitle = TITLE_APPLE_2; break;
444 case A2TYPE_APPLE2PLUS: g_pAppTitle = TITLE_APPLE_2_PLUS; break;
445 case A2TYPE_APPLE2E: g_pAppTitle = TITLE_APPLE_2E; break;
446 case A2TYPE_APPLE2EEHANCED: g_pAppTitle = TITLE_APPLE_2E_ENHANCED; break;
449 case A2TYPE_APPLE2: g_pAppTitle = TITLE_APPLE_2_; break;
450 case A2TYPE_APPLE2PLUS: g_pAppTitle = TITLE_APPLE_2_PLUS_; break;
451 case A2TYPE_APPLE2E: g_pAppTitle = TITLE_APPLE_2E_; break;
452 case A2TYPE_APPLE2EEHANCED: g_pAppTitle = TITLE_APPLE_2E_ENHANCED_; break;
453 default:
454 break;
447455 }
448456
449457 LOAD(TEXT("Joystick 0"),&joytype[0]);
517525 LOAD(TEXT("Slot 6 Autoload") ,&dwTmp); // load autoinsert for Slot 6 flag
518526 if(dwTmp) {
519527 // Load floppy disk images and insert it automatically in slot 6 drive 1 and 2
520 SetDiskImageDirectory(REGVALUE_DISK_IMAGE1, 0);
521 SetDiskImageDirectory(REGVALUE_DISK_IMAGE1, 1);
528 static char szDiskImage1[] = REGVALUE_DISK_IMAGE1;
529 SetDiskImageDirectory(szDiskImage1, 0);
530 SetDiskImageDirectory(szDiskImage1, 1);
522531 }
523532 else {
524533 #define MASTER_DISK "Master.dsk"
525 DoDiskInsert(0, MASTER_DISK);
534 static char szMasterDisk[] = MASTER_DISK;
535 DoDiskInsert(0, szMasterDisk);
526536 }
527537
528538 // Load hard disk images and insert it automatically in slot 7
819819
820820 view = (LPBYTE)MapViewOfFile(mapping,FILE_MAP_READ,0,0,0);*/
821821 view = (LPBYTE)malloc(size);
822 fread(view, 1, size, (FILE*)file);
823 fseek((FILE*)file, 0, FILE_BEGIN); // I just got accustomed to mrsftish FILE_BEGIN, FILE_END, etc. Hmm. ^_^
822 size_t bytesRead = fread(view, 1, size, (FILE*)file);
823 if( bytesRead > 0 ) {
824 fseek((FILE*)file, 0, FILE_BEGIN); // I just got accustomed to mrsftish FILE_BEGIN, FILE_END, etc. Hmm. ^_^
825 }
824826 pImage = view;
825827
826828 if (pImage)
385385 SDL_Rect srect;
386386
387387 Uint32 mybluez = SDL_MapRGB(screen->format, 10, 10, 255); // bluez color, know that?
388 Uint32 myyell = SDL_MapRGB(screen->format, 255, 255, 0); // yellow color?
389388
390389 SDL_SetColors(g_hStatusSurface, screen->format->palette->colors,
391390 0, 256);
702701 case MODE_STEPPING:
703702 DebuggerInputConsoleChar( DEBUG_EXIT_KEY );
704703 break;
704 case MODE_LOGO:
705 case MODE_DEBUG:
706 default:
707 break;
705708 }
706709 DrawStatusArea(/*(HDC)0,*/DRAW_TITLE);
707710 if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
11651168 // if (!RegLoadValue(TEXT("Preferences"),TEXT("Window Y-Position"),1,(DWORD *)&ypos))
11661169 // ypos = (GetSystemMetrics(SM_CYSCREEN)-height) >> 1;
11671170
1168 SDL_putenv("SDL_VIDEO_CENTERED=center"); //center our window
1171 static char sdlCmd[] = "SDL_VIDEO_CENTERED=center";
1172 SDL_putenv(sdlCmd); //center our window
11691173
11701174 bIamFullScreened = false; // at startup not in fullscreen mode
11711175 screen = SDL_SetVideoMode(g_ScreenWidth, g_ScreenHeight, SCREEN_BPP, SDL_SWSURFACE | SDL_HWPALETTE);
246246 return g_HardDrive[nDrive].hd_imageloaded;
247247 }
248248
249 #if 0
249250 static LPCTSTR HD_DiskGetName (int nDrive)
250251 {
251252 return g_HardDrive[nDrive].hd_imagename;
252253 }
254 #endif
253255
254256 //===========================================================================
255257
685687 break;
686688 case 0xF4:
687689 {
688 pHDD->hd_memblock = pHDD->hd_memblock & 0xFF00 | d;
690 pHDD->hd_memblock = (pHDD->hd_memblock & 0xFF00) | d;
689691 }
690692 break;
691693 case 0xF5:
692694 {
693 pHDD->hd_memblock = pHDD->hd_memblock & 0x00FF | (d << 8);
695 pHDD->hd_memblock = (pHDD->hd_memblock & 0x00FF) | (d << 8);
694696 }
695697 break;
696698 case 0xF6:
697699 {
698 pHDD->hd_diskblock = pHDD->hd_diskblock & 0xFF00 | d;
700 pHDD->hd_diskblock = (pHDD->hd_diskblock & 0xFF00) | d;
699701 }
700702 break;
701703 case 0xF7:
702704 {
703 pHDD->hd_diskblock = pHDD->hd_diskblock & 0x00FF | (d << 8);
705 pHDD->hd_diskblock = (pHDD->hd_diskblock & 0x00FF) | (d << 8);
704706 }
705707 break;
706708 default:
3131 #include "stdafx.h"
3232 //#pragma hdrstop
3333
34 static bool g_bKeybBufferEnable = false;
34 //static bool g_bKeybBufferEnable = false;
3535
3636 #define KEY_OLD
3737
970970 case A2TYPE_APPLE2E:RomFileName = Apple2e_rom; ROM_SIZE = Apple2eRomSize; break;
971971 case A2TYPE_APPLE2EEHANCED:RomFileName = Apple2eEnhanced_rom; ROM_SIZE = Apple2eRomSize; break;
972972 /*case A2TYPE_PRAVEC8C:RomFileName = IDR_PRAVEC_8C; ROM_SIZE = Apple2Pravec8CSize;break;*/
973 default:
974 break;
973975 }
974976
975977 if(RomFileName == NULL)
8888 #include "AY8910.h"
8989 #include "SSI263Phonemes.h"
9090
91
9291 #define SY6522_DEVICE_A 0
9392 #define SY6522_DEVICE_B 1
9493
151150 static USHORT g_nMBTimerDevice = 0; // SY6522 device# which is generating timer IRQ
152151 static unsigned __int64 g_uLastCumulativeCycles = 0;
153152
153 #ifdef MB_SPEECH
154154 // SSI263 vars:
155155 static USHORT g_nSSI263Device = 0; // SSI263 device# which is generating phoneme-complete IRQ
156156 static int g_nCurrentActivePhoneme = -1;
157157 static bool g_bStopPhoneme = false;
158158 static bool g_bVotraxPhoneme = false;
159 static HANDLE g_hThread = NULL;
160 #endif
159161
160162 // sample rate defined in Common.h
161163 //static const DWORD SAMPLE_RATE = 44100; // Use a base freq so that DirectX (or sound h/w) doesn't have to up/down-sample
166168 static bool g_bMB_RegAccessedFlag = false;
167169 static bool g_bMB_Active = true;
168170
169 static HANDLE g_hThread = NULL;
170
171171 static bool g_bMBAvailable = false;
172172
173173 //
188188 static short g_nMixBuffer[g_dwDSBufferSize / sizeof(short)];
189189
190190
191 #ifdef MB_SPEECH
191192 // do not have voices anymore??? --bb ^_^ 0_0
192 //static VOICE MockingboardVoice = {0};
193 //static VOICE SSI263Voice[64] = {0};
193 static VOICE MockingboardVoice = {0};
194 static VOICE SSI263Voice[64] = {0};
195 #endif
194196
195197 static const int g_nNumEvents = 2;
198 #ifdef MB_SPEECH
196199 static HANDLE g_hSSI263Event[g_nNumEvents] = {NULL}; // 1: Phoneme finished playing, 2: Exit thread
197200 static DWORD g_dwMaxPhonemeLen = 0;
201 #endif
198202
199203 // When 6522 IRQ is *not* active use 60Hz update freq for MB voices
200204 static const double g_f6522TimerPeriod_NoIRQ = CLK_6502 / 60.0; // Constant whatever the CLK is set to
208212 //---------------------------------------------------------------------------
209213
210214 // Forward refs:
215 #ifdef MB_SPEECH
211216 static DWORD SSI263Thread(LPVOID);
212217 static void Votrax_Write(BYTE nDevice, BYTE nValue);
218 #endif
213219
214220 //---------------------------------------------------------------------------
215221
341347 nValue &= pMB->sy6522.DDRB;
342348 pMB->sy6522.ORB = nValue;
343349
350 #ifdef MB_SPEECH
344351 if( (pMB->sy6522.DDRB == 0xFF) && (pMB->sy6522.PCR == 0xB0) )
345352 {
346353 // Votrax speech data
347354 Votrax_Write(nDevice, nValue);
348355 break;
349356 }
357 #endif
350358
351359 if(g_bPhasorEnable)
352360 {
527535
528536 //---------------------------------------------------------------------------
529537
538 #ifdef MB_SPEECH
530539 static void SSI263_Play(unsigned int nPhoneme);
531540
532541 #if 0
544553
545554 //static SSI263A nSpeechChip;
546555
556 #endif // MB_SPEECH
557
547558 // Duration/Phonome
548559 const BYTE DURATION_MODE_MASK = 0xC0;
549560 const BYTE PHONEME_MASK = 0x3F;
561
550562
551563 const BYTE MODE_PHONEME_TRANSITIONED_INFLECTION = 0xC0; // IRQ active
552564 const BYTE MODE_PHONEME_IMMEDIATE_INFLECTION = 0x80; // IRQ active
580592 switch(nReg)
581593 {
582594 case SSI_DURPHON:
595 #ifdef MB_SPEECH
583596 #if LOG_SSI263
584597 if(g_fh) fprintf(g_fh, "DUR = 0x%02X, PHON = 0x%02X\n\n", nValue>>6, nValue&PHONEME_MASK);
585598 #endif
610623 {
611624 SSI263_Play(nValue & PHONEME_MASK);
612625 }
626 #endif
613627 break;
614628 case SSI_INFLECT:
615629 #if LOG_SSI263
644658
645659 //-------------------------------------
646660
661 #ifdef MB_SPEECH
647662 static BYTE Votrax2SSI263[64] =
648663 {
649664 0x02, // 00: EH3 jackEt -> E1 bEnt
728743
729744 SSI263_Play(Votrax2SSI263[nValue & PHONEME_MASK]);
730745 }
746 #endif
731747
732748 //===========================================================================
733749
760776 //
761777
762778 #ifdef MOCKINGBOARD
763 static DWORD dwByteOffset = (DWORD)-1;
764779 static int nNumSamplesError = 0;
765780
766781
895910
896911 //-----------------------------------------------------------------------------
897912
913 #ifdef MB_SPEECH
898914 static DWORD SSI263Thread(LPVOID lpParameter)
899915 {
900 #if 0
901916 while(1)
902917 {
903918 DWORD dwWaitResult = WaitForMultipleObjects(
926941 //if(g_fh) fprintf(g_fh, "IRQ: Phoneme complete (0x%02X)\n\n", g_nCurrentActivePhoneme);
927942 #endif
928943
944 #ifdef MB_SPEECH
929945 SSI263Voice[g_nCurrentActivePhoneme].bActive = false;
930946 g_nCurrentActivePhoneme = -1;
947 #endif
931948
932949 // Phoneme complete, so generate IRQ if necessary
933950 SY6522_AY8910* pMB = &g_MB[g_nSSI263Device];
966983 }
967984
968985 return 0;
969 #endif
970986 return 0;
971987 }
972
973 //-----------------------------------------------------------------------------
974
988 #endif
989
990 //-----------------------------------------------------------------------------
991
992 #ifdef MB_SPEECH
975993 static void SSI263_Play(unsigned int nPhoneme)
976994 {
977995 #if 0
9981016
9991017 #endif
10001018 }
1019 #endif
10011020
10021021 //-----------------------------------------------------------------------------
10031022
10141033 // Create SSI263 voice
10151034 //
10161035
1017 #if 0
1036 #if MB_SPEECH
10181037
10191038 g_hSSI263Event[0] = CreateEvent(NULL, // lpEventAttributes
10201039 FALSE, // bManualReset (FALSE = auto-reset)
12841303 if(g_SoundcardType == SC_NONE)
12851304 return 0;
12861305
1287 BYTE nMB = (nAddr>>8)&0xf - SLOT4;
1306 BYTE nMB = ((nAddr>>8)&0xf) - SLOT4;
12881307 BYTE nOffset = nAddr&0xff;
12891308
12901309 if(g_bPhasorEnable)
13341353 if(g_SoundcardType == SC_NONE)
13351354 return 0;
13361355
1337 BYTE nMB = (nAddr>>8)&0xf - SLOT4;
1356 BYTE nMB = ((nAddr>>8)&0xf) - SLOT4;
13381357 BYTE nOffset = nAddr&0xff;
13391358
13401359 if(g_bPhasorEnable)
14631482 SY6522_AY8910* pMB = &g_MB[i];
14641483
14651484 USHORT OldTimer1 = pMB->sy6522.TIMER1_COUNTER.w;
1466 USHORT OldTimer2 = pMB->sy6522.TIMER2_COUNTER.w;
1485 //USHORT OldTimer2 = pMB->sy6522.TIMER2_COUNTER.w;
14671486
14681487 pMB->sy6522.TIMER1_COUNTER.w -= nClocks;
14691488 pMB->sy6522.TIMER2_COUNTER.w -= nClocks;
14701489
14711490 // Check for counter underflow
14721491 bool bTimer1Underflow = (!(OldTimer1 & 0x8000) && (pMB->sy6522.TIMER1_COUNTER.w & 0x8000));
1473 bool bTimer2Underflow = (!(OldTimer2 & 0x8000) && (pMB->sy6522.TIMER2_COUNTER.w & 0x8000));
1492 //bool bTimer2Underflow = (!(OldTimer2 & 0x8000) && (pMB->sy6522.TIMER2_COUNTER.w & 0x8000));
14741493
14751494 if( bTimer1Underflow && (g_nMBTimerDevice == i) && g_bMBTimerIrqActive )
14761495 {
15901609 UINT nDeviceNum = nMbCardNum*2;
15911610 SY6522_AY8910* pMB = &g_MB[nDeviceNum];
15921611
1612 #ifdef MB_SPEECH
15931613 g_nSSI263Device = 0;
15941614 g_nCurrentActivePhoneme = -1;
1595
1615 #endif
15961616 for(UINT i=0; i<MB_UNITS_PER_CARD; i++)
15971617 {
15981618 memcpy(&pMB->sy6522, &pSS->Unit[i].RegsSY6522, sizeof(SY6522));
15991619 memcpy(AY8910_GetRegsPtr(nDeviceNum), &pSS->Unit[i].RegsAY8910, 16);
1620 #ifdef MB_SPEECH
16001621 memcpy(&pMB->SpeechChip, &pSS->Unit[i].RegsSSI263, sizeof(SSI263A));
1622 #endif
16011623 pMB->nAYCurrentRegister = pSS->Unit[i].nAYCurrentRegister;
16021624
16031625 StartTimer(pMB); // Attempt to start timer
16041626
16051627 //
16061628
1629 #ifdef MB_SPEECH
16071630 // Crude - currently only support a single speech chip
16081631 // FIX THIS:
16091632 // . Speech chip could be Votrax instead
16191642 pMB->SpeechChip.CurrentMode |= 1; // Set SSI263's D7 pin
16201643 }
16211644 }
1622
1645 #endif
16231646 nDeviceNum++;
16241647 pMB++;
16251648 }
4242 memset(mask, 0, 256);
4343 for (end = input+len; input < end; input++) {
4444 c=*input;
45 mask[c]=1;
45 mask[(unsigned int)c]=1;
4646 }
4747
4848 }
6565 register int i;
6666 int trimmed = 0;
6767 char mask[256];
68
69 php_charmask(" \n\r\t\v\0", 6, mask);
68 static char maskVal[] = " \n\r\t\v\0";
69
70
71 php_charmask(maskVal, 6, mask);
7072
7173 // trim chars from beginning of the line
7274 for (i = 0; i < len; i++) {
129129
130130 DWORD dwNumberOfBytesWritten;
131131
132 BOOL bRes = WriteFile(
132 WriteFile(
133133 g_hRiffFile,
134134 buf,
135135 uSamples * sizeof(short) * g_NumChannels,
2929
3030 #include "stdafx.h"
3131 #include "wwrapper.h"
32 #pragma hdrstop
3332
3433 #define DEFAULT_SNAPSHOT_NAME "SaveState.aws"
3534
101100 throw(0);
102101 }
103102
104 if(pSS->Hdr.dwTag != AW_SS_TAG)
103 if(pSS->Hdr.dwTag != (DWORD) AW_SS_TAG)
105104 {
106105 strcpy(szMessage, "File corrupt");
107106 throw(0);
265265 //
266266 void audioCallback(short* stream, unsigned len)
267267 {
268 int i;
268 unsigned int i;
269269 static short lastvalue = 0;
270270 assert((len & 1) == 0); // stereo
271271
114114 int src_locked;
115115 int dst_locked;
116116 int pos, inc;
117 int dst_width;
118117 int dst_maxrow;
119118 int src_row, dst_row;
120119 Uint8 *srcp = NULL;
166165 inc = (srcrect->h << 16) / dstrect->h;
167166 src_row = srcrect->y;
168167 dst_row = dstrect->y;
169 dst_width = dstrect->w*bpp;
170168
171169
172170 /* Perform the stretch blit */
240238 int src_locked;
241239 int dst_locked;
242240 int pos, inc;
243 int dst_width;
244241 int dst_maxrow;
245242 int src_row, dst_row;
246243 Uint8 *srcp = NULL;
287284 inc = (srcrect->h << 16) / dstrect->h;
288285 src_row = srcrect->y;
289286 dst_row = dstrect->y;
290 dst_width = dstrect->w*bpp;
291287
292288
293289 /* Perform the stretch blit */
343339 int src_locked;
344340 int dst_locked;
345341 int pos, inc;
346 int dst_width;
347342 int dst_maxrow;
348343 int src_row, dst_row;
349344 Uint8 *srcp = NULL;
395390 inc = (srcrect->h << 16) / dstrect->h;
396391 src_row = srcrect->y;
397392 dst_row = dstrect->y;
398 dst_width = dstrect->w*bpp;
399393
400394
401395 /* Perform the stretch blit */