#include "gui/draggablewindow2.h"
#include "gui/textedit.h"
-using namespace std;
+//using namespace std;
// Global variables
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)
{
WriteLog("About to initialize video...\n");
if (!InitVideo())
{
- cout << "Aborting!" << endl;
+ std::cout << "Aborting!" << std::endl;
return -1;
}
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();
}
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;
// 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;
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!
static void RenderHiRes(uint16 toLine/*= 192*/)
{
+// NOTE: Not endian safe. !!! FIX !!!
uint32 pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
for(uint16 y=0; y<toLine; y++)
***************************************************************************/
-//
+//
// From mame.txt (http://www.mame.net/readme.html)
-//
+//
// VI. Reuse of Source Code
// --------------------------
// This chapter might not apply to specific portions of MAME (e.g. CPU
// However, given the amount of time and energy it took to collect this
// information, if you find new information we would appreciate if you made it
// freely available as well.
-//
+//
// JLH: Commented out MAME specific crap
-#include <string.h> // for memset()
#include "ay8910.h"
+#include <string.h> // for memset()
#define MAX_OUTPUT 0x7FFF
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];
};
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:
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:
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) ||
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:
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)
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];
* 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)
/* 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]);
{
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 *
{
PSG->OutputA ^= 1;
- if (PSG->OutputA) vola += PSG->PeriodA;
+ if (PSG->OutputA)
+ vola += PSG->PeriodA;
break;
}
vola += PSG->PeriodA;
}
- if (PSG->OutputA) vola -= PSG->CountA;
+ if (PSG->OutputA)
+ vola -= PSG->CountA;
}
else
{
if (outn & 0x10)
{
- if (PSG->OutputB) volb += PSG->CountB;
+ if (PSG->OutputB)
+ volb += PSG->CountB;
PSG->CountB -= nextevent;
{
PSG->OutputB ^= 1;
- if (PSG->OutputB) volb += PSG->PeriodB;
+ if (PSG->OutputB)
+ volb += PSG->PeriodB;
break;
}
volb += PSG->PeriodB;
}
- if (PSG->OutputB) volb -= PSG->CountB;
+ if (PSG->OutputB)
+ volb -= PSG->CountB;
}
else
{
if (outn & 0x20)
{
- if (PSG->OutputC) volc += PSG->CountC;
+ if (PSG->OutputC)
+ volc += PSG->CountC;
PSG->CountC -= nextevent;
{
PSG->OutputC ^= 1;
- if (PSG->OutputC) volc += PSG->PeriodC;
+ if (PSG->OutputC)
+ volc += PSG->PeriodC;
break;
}
volc += PSG->PeriodC;
}
- if (PSG->OutputC) volc -= PSG->CountC;
+ if (PSG->OutputC)
+ volc -= PSG->CountC;
}
else
{
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;
}
}