Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ FreeIntv requires two Intellivision BIOS files to be placed in the libretro 'sys

* BIOS filenames are case-sensitive

## Entertainment Computer System and Intellivoice
FreeIntv does not currently support Entertainment Computer System (ECS) and Intellivoice functionality. Contributions to the code are welcome!
## Entertainment Computer System
FreeIntv does not currently support Entertainment Computer System (ECS) functionality. Contributions to the code are welcome!

## Controller overlays
Mattel Intellivision games were often meant to be played with game-specific cards overlaid on the numeric keypad. These overlays convey information which can be very useful in gameplay. Images of a limited selection of Intellivision titles are available at: http://www.intellivisionlives.com/bluesky/games/instructions.shtml
Expand Down
21 changes: 18 additions & 3 deletions src/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void retro_unload_game(void)

void retro_run(void)
{
int i = 0;
int c, i, j, k, l;
int showKeypad0 = false;
int showKeypad1 = false;

Expand Down Expand Up @@ -291,13 +291,28 @@ void retro_run(void)
audioInc = 3733.5 / audioSamples;
ivoiceInc = 1.0;

j = 0;
for(i=0; i<audioSamples; i++)
{
int c = (PSGBuffer[(int) audioBufferPos] + ivoiceBuffer[(int) ivoiceBufferPos]) / 2;
// Sound interpolator:
// The PSG module generates audio at 224010 hz (3733.5 samples per frame)
// Very high frequencies like 0x0001 would generate chirps on output
// (For example, Lock&Chase) so this code interpolates audio, making
// these silent as in real hardware.
audioBufferPos += audioInc;
k = audioBufferPos;
l = k - j;

c = 0;
while (j < k)
c += PSGBuffer[j++];
c = c / l;
// Finally it adds the Intellivoice output (properly generated at the
// same frequency as output)
c = (c + ivoiceBuffer[(int) ivoiceBufferPos]) / 2;

Audio(c, c); // Audio(left, right)

audioBufferPos += audioInc;
ivoiceBufferPos += ivoiceInc;

if (ivoiceBufferPos >= ivoiceBufferSize)
Expand Down
6 changes: 6 additions & 0 deletions src/psg.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
along with FreeIntv. If not, see http://www.gnu.org/licenses/
*/

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "psg.h"
Expand Down Expand Up @@ -182,6 +183,11 @@ void PSGInit()
void PSGFrame()
{
PSGBufferPos = 0;
#if 0 // Debugging
{
fprintf(stderr, "%04x %04x %04x %02x %02x %02x\n", ChA, ChB, ChC, VolA, VolB, VolC);
}
#endif
}

int psg_masks[16] = {
Expand Down
47 changes: 39 additions & 8 deletions src/stic.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ void drawBorder(int scanline)
int color = colors[Memory[0x2C] & 0x0f]; // border color

if(scanline>=112) { return; }
if (scanline == delayV - 1 || scanline == 104) { // Collision border is 1 pixel thick
if (scanline == delayV - 1 || scanline == 104 || extendTop != 0 && scanline >= 7 && scanline < 16) { // Collision border is 1 pixel thick, or 9 if extendTop is set
for(i=1 * 2; i < (8 + 160) * 2; i += 2) // It extends from column -7 to 159
{
collBuffer[i] |= cbit;
collBuffer[i+384] |= cbit;
}
} else if (scanline > delayV - 1 && scanline < 104) { // Left and right side collision border
for(i=1 * 2; i < 8 * 2; i += 2) // Left side from column -7 to -1
for(i=1 * 2; i < 16+(16*extendLeft); i += 2) // Left side from column -7 to -1 (or 7 if extendLeft is set)
{
collBuffer[i] |= cbit;
collBuffer[i+384] |= cbit;
Expand Down Expand Up @@ -532,7 +532,7 @@ void drawSprites(int scanline) // MOBs
void STICDrawFrame(int enabled)
{
int row, offset;
int i, j;
int i;

offset = 0;
if (enabled == 0) {
Expand Down Expand Up @@ -587,11 +587,42 @@ void STICDrawFrame(int enabled)
for (i = 1 * 2; i < 168 * 2; i += 2) {
if (collBuffer[i] == 0)
continue;
for (j = 0; j < 8; j++) {
if (((collBuffer[i] >> j) & 1) != 0) {
Memory[0x18 + j] |= collBuffer[i] & ~(1 << j);
}
}
if (collBuffer[i] & 0x01)
Memory[0x18] |= collBuffer[i];
if (collBuffer[i] & 0x02)
Memory[0x19] |= collBuffer[i];
if (collBuffer[i] & 0x04)
Memory[0x1a] |= collBuffer[i];
if (collBuffer[i] & 0x08)
Memory[0x1b] |= collBuffer[i];
if (collBuffer[i] & 0x10)
Memory[0x1c] |= collBuffer[i];
if (collBuffer[i] & 0x20)
Memory[0x1d] |= collBuffer[i];
if (collBuffer[i] & 0x40)
Memory[0x1e] |= collBuffer[i];
if (collBuffer[i] & 0x80)
Memory[0x1f] |= collBuffer[i];
}
for (i = 1 * 2 + 384; i < 168 * 2 + 384; i += 2) {
if (collBuffer[i] == 0)
continue;
if (collBuffer[i] & 0x01)
Memory[0x18] |= collBuffer[i];
if (collBuffer[i] & 0x02)
Memory[0x19] |= collBuffer[i];
if (collBuffer[i] & 0x04)
Memory[0x1a] |= collBuffer[i];
if (collBuffer[i] & 0x08)
Memory[0x1b] |= collBuffer[i];
if (collBuffer[i] & 0x10)
Memory[0x1c] |= collBuffer[i];
if (collBuffer[i] & 0x20)
Memory[0x1d] |= collBuffer[i];
if (collBuffer[i] & 0x40)
Memory[0x1e] |= collBuffer[i];
if (collBuffer[i] & 0x80)
Memory[0x1f] |= collBuffer[i];
}
memcpy(&frame[offset], &scanBuffer[0], 352 * sizeof(unsigned int));
memcpy(&frame[offset + 352], &scanBuffer[384], 352 * sizeof(unsigned int));
Expand Down