From: Shamus Hammons Date: Mon, 2 Jul 2007 16:13:08 +0000 (+0000) Subject: Changed types.h to use standard C99 types, misc. cleanups X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7916c0f9595cd43f880976e50cf81f3d9714b466;p=apple2 Changed types.h to use standard C99 types, misc. cleanups --- diff --git a/apple2.cfg b/apple2.cfg index ece7b9c..e494c0c 100755 --- a/apple2.cfg +++ b/apple2.cfg @@ -21,7 +21,7 @@ autoSaveState = 1 #floppyImage1 = ./disks/temp.nib #floppyImage1 = ./disks/temp.dsk # Yes -#floppyImage1 = ./disks/bt1_boot.dsk +floppyImage1 = ./disks/bt1_boot.dsk # Yes #floppyImage1 = ./disks/bt2_boot.dsk # No @@ -54,8 +54,8 @@ autoSaveState = 1 #floppyImage1 = ./disks/ultima_ii-1.dsk #floppyImage2 = ./disks/ultima_ii-2.dsk # Yes, autoloads! -floppyImage1 = ./disks/u2prog-patched.dsk -floppyImage2 = ./disks/u2player-jlh.dsk +#floppyImage1 = ./disks/u2prog-patched.dsk +#floppyImage2 = ./disks/u2player-jlh.dsk # OpenGL options: 1 - use OpenGL rendering, 0 - use old style rendering diff --git a/src/apple2.cpp b/src/apple2.cpp index dbdb619..1edce9f 100755 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -54,7 +54,7 @@ #include "gui/draggablewindow2.h" #include "gui/textedit.h" -using namespace std; +//using namespace std; // Global variables @@ -316,28 +316,20 @@ if (addr >= 0xC080 && addr <= 0xC08F) A-9 (Mockingboard) APPENDIX F Assembly Language Program Listings - 1 *PRIMARY ROUTINES - 2 *FOR SLOT 4 - 3 * - 4 ORG $9000 - 5 * ;ADDRESSES - FOR FIRST - 6522 - 6 ORB EQU $C400 ;PORT B - 7 ORA EQU $C401 ;PORT A - 8 DDRB EQU $C402 ;DATA DIRECTION - REGISTER (A) - 9 DDRA EQU $C403 ;DATA DIRECTION - REGISTER (B) - 10 * ;ADDRESSES - FOR SECOND - 6522 - 11 ORB2 EQU $C480 ;PORT B - 12 ORA2 EQU $C481 ;PORT A - 13 DDRB2 EQU $C482 ;DATA DIRECTION - REGISTER (B) - 14 DDRA2 EQU $C483 ;DATA DIRECTION - REGISTER (A) + 1 *PRIMARY ROUTINES + 2 *FOR SLOT 4 + 3 * + 4 ORG $9000 + 5 * ;ADDRESSES FOR FIRST 6522 + 6 ORB EQU $C400 ;PORT B + 7 ORA EQU $C401 ;PORT A + 8 DDRB EQU $C402 ;DATA DIRECTION REGISTER (A) + 9 DDRA EQU $C403 ;DATA DIRECTION REGISTER (B) + 10 * ;ADDRESSES FOR SECOND 6522 + 11 ORB2 EQU $C480 ;PORT B + 12 ORA2 EQU $C481 ;PORT A + 13 DDRB2 EQU $C482 ;DATA DIRECTION REGISTER (B) + 14 DDRA2 EQU $C483 ;DATA DIRECTION REGISTER (A) */ void WrMem(uint16 addr, uint8 b) { @@ -579,7 +571,7 @@ int main(int /*argc*/, char * /*argv*/[]) WriteLog("About to initialize video...\n"); if (!InitVideo()) { - cout << "Aborting!" << endl; + std::cout << "Aborting!" << std::endl; return -1; } @@ -803,6 +795,7 @@ else if (event.key.keysym.sym == SDLK_F10) RenderVideoFrame(); SetCallbackTime(FrameCallback, 16666.66666667); +//Instead of this, we should yield remaining time to other processes... !!! FIX !!! while (SDL_GetTicks() - startTicks < 16); // Wait for next frame... startTicks = SDL_GetTicks(); } diff --git a/src/applevideo.cpp b/src/applevideo.cpp index 2542052..436a42d 100755 --- a/src/applevideo.cpp +++ b/src/applevideo.cpp @@ -225,7 +225,8 @@ uint16 appleHiresToMono[0x200] = { 0x207F, 0x387F, 0x267F, 0x3E7F, 0x21FF, 0x39FF, 0x27FF, 0x3FFF // $Fx }; -static uint8 blurTable[0x800][8]; // Color TV blur table +//static uint8 blurTable[0x800][8]; // Color TV blur table +static uint8 blurTable[0x80][8]; // Color TV blur table static uint32 * palette = (uint32 *)altColors; enum { ST_FIRST_ENTRY = 0, ST_COLOR_TV = 0, ST_WHITE_MONO, ST_GREEN_MONO, ST_LAST_ENTRY }; static uint8 screenType = ST_COLOR_TV; @@ -243,12 +244,17 @@ void SetupBlurTable(void) // NOTE: This table only needs to be 7 bits wide instead of 11, since the // last four bits are copies of the previous four... - for(uint16 bitPat=0; bitPat<0x800; bitPat++) +// for(uint16 bitPat=0; bitPat<0x800; bitPat++) + for(uint16 bitPat=0; bitPat<0x80; bitPat++) { - uint16 w3 = bitPat & 0x888; +/* uint16 w3 = bitPat & 0x888; uint16 w2 = bitPat & 0x444; uint16 w1 = bitPat & 0x222; - uint16 w0 = bitPat & 0x111; + uint16 w0 = bitPat & 0x111;*/ + uint16 w3 = bitPat & 0x88; + uint16 w2 = bitPat & 0x44; + uint16 w1 = bitPat & 0x22; + uint16 w0 = bitPat & 0x11; uint16 blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF; uint16 blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF; @@ -434,6 +440,9 @@ static void Render40ColumnText(void) static void RenderLoRes(uint16 toLine/*= 24*/) { // NOTE: The green mono rendering doesn't skip every other line... !!! FIX !!! +// Also, we could set up three different Render functions depending on which +// render type was set and call it with a function pointer. Would be faster +// then the nested ifs we have now. /* Note that these colors correspond to the bit patterns generated by the numbers 0-F in order: Color #s correspond to the bit patterns in reverse... Interesting! @@ -600,6 +609,7 @@ fb fb fb -> 15 [1111] -> 15 WHITE static void RenderHiRes(uint16 toLine/*= 192*/) { +// NOTE: Not endian safe. !!! FIX !!! uint32 pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61); for(uint16 y=0; y // for memset() #include "ay8910.h" +#include // for memset() #define MAX_OUTPUT 0x7FFF @@ -49,13 +49,13 @@ struct AY8910 unsigned char Regs[16]; int lastEnable; unsigned int UpdateStep; - int PeriodA,PeriodB,PeriodC,PeriodN,PeriodE; - int CountA,CountB,CountC,CountN,CountE; - unsigned int VolA,VolB,VolC,VolE; - unsigned char EnvelopeA,EnvelopeB,EnvelopeC; - unsigned char OutputA,OutputB,OutputC,OutputN; + int PeriodA, PeriodB, PeriodC, PeriodN, PeriodE; + int CountA, CountB, CountC, CountN, CountE; + unsigned int VolA, VolB, VolC, VolE; + unsigned char EnvelopeA, EnvelopeB, EnvelopeC; + unsigned char OutputA, OutputB, OutputC, OutputN; signed char CountEnv; - unsigned char Hold,Alternate,Attack,Holding; + unsigned char Hold, Alternate, Attack, Holding; int RNG; unsigned int VolTable[32]; }; @@ -108,11 +108,13 @@ void _AYWriteReg(int n, int r, int v) old = PSG->PeriodA; PSG->PeriodA = (PSG->Regs[AY_AFINE] + 256 * PSG->Regs[AY_ACOARSE]) * PSG->UpdateStep; - if (PSG->PeriodA == 0) PSG->PeriodA = PSG->UpdateStep; + if (PSG->PeriodA == 0) + PSG->PeriodA = PSG->UpdateStep; PSG->CountA += PSG->PeriodA - old; - if (PSG->CountA <= 0) PSG->CountA = 1; + if (PSG->CountA <= 0) + PSG->CountA = 1; break; case AY_BFINE: case AY_BCOARSE: @@ -120,11 +122,13 @@ void _AYWriteReg(int n, int r, int v) old = PSG->PeriodB; PSG->PeriodB = (PSG->Regs[AY_BFINE] + 256 * PSG->Regs[AY_BCOARSE]) * PSG->UpdateStep; - if (PSG->PeriodB == 0) PSG->PeriodB = PSG->UpdateStep; + if (PSG->PeriodB == 0) + PSG->PeriodB = PSG->UpdateStep; PSG->CountB += PSG->PeriodB - old; - if (PSG->CountB <= 0) PSG->CountB = 1; + if (PSG->CountB <= 0) + PSG->CountB = 1; break; case AY_CFINE: case AY_CCOARSE: @@ -132,22 +136,26 @@ void _AYWriteReg(int n, int r, int v) old = PSG->PeriodC; PSG->PeriodC = (PSG->Regs[AY_CFINE] + 256 * PSG->Regs[AY_CCOARSE]) * PSG->UpdateStep; - if (PSG->PeriodC == 0) PSG->PeriodC = PSG->UpdateStep; + if (PSG->PeriodC == 0) + PSG->PeriodC = PSG->UpdateStep; PSG->CountC += PSG->PeriodC - old; - if (PSG->CountC <= 0) PSG->CountC = 1; + if (PSG->CountC <= 0) + PSG->CountC = 1; break; case AY_NOISEPER: PSG->Regs[AY_NOISEPER] &= 0x1F; old = PSG->PeriodN; PSG->PeriodN = PSG->Regs[AY_NOISEPER] * PSG->UpdateStep; - if (PSG->PeriodN == 0) PSG->PeriodN = PSG->UpdateStep; + if (PSG->PeriodN == 0) + PSG->PeriodN = PSG->UpdateStep; PSG->CountN += PSG->PeriodN - old; - if (PSG->CountN <= 0) PSG->CountN = 1; + if (PSG->CountN <= 0) + PSG->CountN = 1; break; case AY_ENABLE: if ((PSG->lastEnable == -1) || @@ -188,11 +196,13 @@ void _AYWriteReg(int n, int r, int v) old = PSG->PeriodE; PSG->PeriodE = ((PSG->Regs[AY_EFINE] + 256 * PSG->Regs[AY_ECOARSE])) * PSG->UpdateStep; - if (PSG->PeriodE == 0) PSG->PeriodE = PSG->UpdateStep / 2; + if (PSG->PeriodE == 0) + PSG->PeriodE = PSG->UpdateStep / 2; PSG->CountE += PSG->PeriodE - old; - if (PSG->CountE <= 0) PSG->CountE = 1; + if (PSG->CountE <= 0) + PSG->CountE = 1; break; case AY_ESHAPE: /* envelope shapes: @@ -241,9 +251,14 @@ void _AYWriteReg(int n, int r, int v) PSG->Holding = 0; PSG->VolE = PSG->VolTable[PSG->CountEnv ^ PSG->Attack]; - if (PSG->EnvelopeA) PSG->VolA = PSG->VolE; - if (PSG->EnvelopeB) PSG->VolB = PSG->VolE; - if (PSG->EnvelopeC) PSG->VolC = PSG->VolE; + if (PSG->EnvelopeA) + PSG->VolA = PSG->VolE; + + if (PSG->EnvelopeB) + PSG->VolB = PSG->VolE; + + if (PSG->EnvelopeC) + PSG->VolC = PSG->VolE; break; case AY_PORTA: if (PSG->Regs[AY_ENABLE] & 0x40) @@ -280,7 +295,7 @@ void _AYWriteReg(int n, int r, int v) void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] { struct AY8910 * PSG = &AYPSG[chip]; - INT16 * buf1, * buf2, * buf3; + int16 * buf1, * buf2, * buf3; int outn; buf1 = buffer[0]; @@ -301,7 +316,9 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] * If the volume is 0, increase the counter, but don't touch the output. */ if (PSG->Regs[AY_ENABLE] & 0x01) { - if (PSG->CountA <= length * STEP) PSG->CountA += length * STEP; + if (PSG->CountA <= length * STEP) + PSG->CountA += length * STEP; + PSG->OutputA = 1; } else if (PSG->Regs[AY_AVOL] == 0) @@ -309,33 +326,41 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] /* note that I do count += length, NOT count = length + 1. You might think * * it's the same since the volume is 0, but doing the latter could cause * * interferencies when the program is rapidly modulating the volume. */ - if (PSG->CountA <= length * STEP) PSG->CountA += length * STEP; + if (PSG->CountA <= length * STEP) + PSG->CountA += length * STEP; } if (PSG->Regs[AY_ENABLE] & 0x02) { - if (PSG->CountB <= length * STEP) PSG->CountB += length * STEP; + if (PSG->CountB <= length * STEP) + PSG->CountB += length * STEP; + PSG->OutputB = 1; } else if (PSG->Regs[AY_BVOL] == 0) { - if (PSG->CountB <= length * STEP) PSG->CountB += length * STEP; + if (PSG->CountB <= length * STEP) + PSG->CountB += length * STEP; } if (PSG->Regs[AY_ENABLE] & 0x04) { - if (PSG->CountC <= length * STEP) PSG->CountC += length * STEP; + if (PSG->CountC <= length * STEP) + PSG->CountC += length * STEP; + PSG->OutputC = 1; } else if (PSG->Regs[AY_CVOL] == 0) { - if (PSG->CountC <= length * STEP) PSG->CountC += length * STEP; + if (PSG->CountC <= length * STEP) + PSG->CountC += length * STEP; } /* for the noise channel we must not touch OutputN - it's also not necessary * * since we use outn. */ if ((PSG->Regs[AY_ENABLE] & 0x38) == 0x38) /* all off */ - if (PSG->CountN <= length * STEP) PSG->CountN += length * STEP; + if (PSG->CountN <= length * STEP) + PSG->CountN += length * STEP; outn = (PSG->OutputN | PSG->Regs[AY_ENABLE]); @@ -354,12 +379,15 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] { int nextevent; - if (PSG->CountN < left) nextevent = PSG->CountN; - else nextevent = left; + if (PSG->CountN < left) + nextevent = PSG->CountN; + else + nextevent = left; if (outn & 0x08) { - if (PSG->OutputA) vola += PSG->CountA; + if (PSG->OutputA) + vola += PSG->CountA; PSG->CountA -= nextevent; /* PeriodA is the half period of the square wave. Here, in each * @@ -378,7 +406,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] { PSG->OutputA ^= 1; - if (PSG->OutputA) vola += PSG->PeriodA; + if (PSG->OutputA) + vola += PSG->PeriodA; break; } @@ -386,7 +415,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] vola += PSG->PeriodA; } - if (PSG->OutputA) vola -= PSG->CountA; + if (PSG->OutputA) + vola -= PSG->CountA; } else { @@ -407,7 +437,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] if (outn & 0x10) { - if (PSG->OutputB) volb += PSG->CountB; + if (PSG->OutputB) + volb += PSG->CountB; PSG->CountB -= nextevent; @@ -419,7 +450,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] { PSG->OutputB ^= 1; - if (PSG->OutputB) volb += PSG->PeriodB; + if (PSG->OutputB) + volb += PSG->PeriodB; break; } @@ -427,7 +459,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] volb += PSG->PeriodB; } - if (PSG->OutputB) volb -= PSG->CountB; + if (PSG->OutputB) + volb -= PSG->CountB; } else { @@ -449,7 +482,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] if (outn & 0x20) { - if (PSG->OutputC) volc += PSG->CountC; + if (PSG->OutputC) + volc += PSG->CountC; PSG->CountC -= nextevent; @@ -461,7 +495,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] { PSG->OutputC ^= 1; - if (PSG->OutputC) volc += PSG->PeriodC; + if (PSG->OutputC) + volc += PSG->PeriodC; break; } @@ -469,7 +504,8 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] volc += PSG->PeriodC; } - if (PSG->OutputC) volc -= PSG->CountC; + if (PSG->OutputC) + volc -= PSG->CountC; } else { @@ -559,9 +595,14 @@ void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static] PSG->VolE = PSG->VolTable[PSG->CountEnv ^ PSG->Attack]; /* reload volume */ - if (PSG->EnvelopeA) PSG->VolA = PSG->VolE; - if (PSG->EnvelopeB) PSG->VolB = PSG->VolE; - if (PSG->EnvelopeC) PSG->VolC = PSG->VolE; + if (PSG->EnvelopeA) + PSG->VolA = PSG->VolE; + + if (PSG->EnvelopeB) + PSG->VolB = PSG->VolE; + + if (PSG->EnvelopeC) + PSG->VolC = PSG->VolE; } } diff --git a/src/ay8910.h b/src/ay8910.h index aa0925b..449e8c3 100755 --- a/src/ay8910.h +++ b/src/ay8910.h @@ -9,8 +9,8 @@ void _AYWriteReg(int n, int r, int v); void AY8910_reset(int chip); void AY8910Update(int chip, int16 ** buffer, int length); -void AY8910_InitAll(int nClock, int nSampleRate); -void AY8910_InitClock(int nClock); -uint8 * AY8910_GetRegsPtr(uint16 nAyNum); +void AY8910_InitAll(int clock, int sampleRate); +void AY8910_InitClock(int clock); +uint8 * AY8910_GetRegsPtr(uint16 chipNum); #endif diff --git a/src/dis65c02.cpp b/src/dis65c02.cpp index aa3981a..f8052e2 100755 --- a/src/dis65c02.cpp +++ b/src/dis65c02.cpp @@ -5,10 +5,10 @@ // (c) 2005 Underground Software // +#include "dis65c02.h" + #include #include -#include "dis65c02.h" -//#include "types.h" #include "v65c02.h" #include "log.h" @@ -16,7 +16,7 @@ using namespace std; // External shit -extern V65C02REGS mainCPU;//Hm. Shouldn't we pass this shit in? +extern V65C02REGS mainCPU;//Hm. Shouldn't we pass this shit in? ANSWER: YES. !!! FIX !!! // Private globals variables diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2841992..e9325c8 100755 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -215,7 +215,7 @@ We could do the following: than one is clicked on, take the one highest in the Z order (closer to the end of the list). -- If item is highest in Z order, pack click through to window and exit. +- If item is highest in Z order, pass click through to window and exit. - Otherwise, restore backing store on each window in reverse order. @@ -257,7 +257,7 @@ it overlaps and just do restore/redraw for those that overlap. To wit: // iterator to a regular iterator requires backing the iterator // up a position after grabbing it's base() OR going forward // one position with the reverse iterator before grabbing base(). - // Ugly, but it get the job done... + // Ugly, but it gets the job done... hit = (++ri).base(); // Put it back where we found it, so the tests following this // don't fail... diff --git a/src/types.h b/src/types.h index a1b9d09..13386d0 100755 --- a/src/types.h +++ b/src/types.h @@ -2,32 +2,21 @@ // Fundamental variable types // by James L. Hammons // -// Why these aren't a part of the C/C++ standard is beyond me. It seems to me that -// basic types where you know the width should be a no-brainer. -// #ifndef __TYPES_H__ #define __TYPES_H__ -// This is only good on certain intel 32-bit platforms... -// You may need to tweak to suit your specific platform. +// This should be portable, since it's part of the C99 standard...! -typedef unsigned char uint8; -typedef signed char int8; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned uint32; -typedef signed int32; -typedef unsigned long long uint64; -typedef signed long long int64; +#include -typedef uint8 UINT8; -typedef int8 INT8; -typedef uint16 UINT16; -typedef int16 INT16; -typedef uint32 UINT32; -typedef int32 INT32; -typedef uint64 UINT64; -typedef int64 INT64; +typedef uint8_t uint8; +typedef int8_t int8; +typedef uint16_t uint16; +typedef int16_t int16; +typedef uint32_t uint32; +typedef int32_t int32; +typedef uint64_t uint64; +typedef int64_t int64; #endif // __TYPES_H__