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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ build-test.ps1
*.temp
*.log
Assets/Thumbs.db
screenshots/Thumbs.db
2 changes: 1 addition & 1 deletion src/cart.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void load3()
void load4()
{
loadRange(0x5000, 0x6FFF);
// [memattr] $D000 - $D3FF = RAM 8 // automatic
d000_ram = 1; /* $D000-$D3FF = RAM 8 */
}

void load5()
Expand Down
18 changes: 15 additions & 3 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

unsigned int Memory[0x10000];

int d000_ram = 0; /* 1 = $D000-$D3FF is 8-bit RAM (e.g. USCF Chess) */

int stic_and[64] = {
0x07ff, 0x07ff, 0x07ff, 0x07ff, 0x07ff, 0x07ff, 0x07ff, 0x07ff,
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
Expand Down Expand Up @@ -66,6 +68,10 @@ void writeMem(int adr, int val) // Write (should handle hooks/alias)
case 0x15: /* A800-AFFF */
case 0x16: /* B000-B7FF */
case 0x1a: /* D000-D7FF */
if (d000_ram && adr <= 0xD3FF) {
Memory[adr] = val & 0xFF; /* RAM 8 */
}
return;
case 0x1b: /* D800-DFFF */
case 0x1c: /* E000-E7FF */
case 0x1d: /* E800-EFFF */
Expand Down Expand Up @@ -146,13 +152,19 @@ int readMem(int adr) // Read (should handle hooks/alias)
val = val & 0xFF;
}

if(d000_ram && adr>=0xD000 && adr<=0xD3FF)
{
val = val & 0xFF; /* RAM 8 */
}

return val;
}

void MemoryInit()
{
int i;
for(i=0x0000; i<=0x0007; i++) { Memory[i] = 0x3800; } // STIC Registers
d000_ram = 0; /* reset per-cart flags before loading new cart */
for(i=0x0000; i<=0x0007; i++) { Memory[i] = 0x3800; } /* STIC Registers */
for(i=0x0008; i<=0x000F; i++) { Memory[i] = 0x3000; }
for(i=0x0010; i<=0x0017; i++) { Memory[i] = 0x0000; }
for(i=0x0018; i<=0x001F; i++) { Memory[i] = 0x3C00; }
Expand All @@ -171,6 +183,6 @@ void MemoryInit()
for(i=0x4000; i<=0x4FFF; i++) { Memory[i] = 0xFFFF; }
for(i=0x5000; i<=0x5FFF; i++) { Memory[i] = 0x0000; }
for(i=0x6000; i<=0xFFFF; i++) { Memory[i] = 0xFFFF; }
Memory[0x1FE] = 0xFF; // Controller R
Memory[0x1FF] = 0xFF; // Controller L
Memory[0x1FE] = 0xFF; /* Controller R */
Memory[0x1FF] = 0xFF; /* Controller L */
}
2 changes: 2 additions & 0 deletions src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

extern unsigned int Memory[0x10000];

extern int d000_ram; /* 1 = $D000-$D3FF is 8-bit RAM (e.g. USCF Chess) */

void MemoryInit(void);

int readMem(int adr);
Expand Down
4 changes: 2 additions & 2 deletions src/stic.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ void drawBackgroundColorStack(int scanline)
fgcolor = fgcard[col];
bgcolor = bgcard[col];

if (((card >> 11) & 0x01) != 0) // Limit GRAM to 64 cards
if (((card >> 11) & 0x01) != 0) /* Card is from GRAM - limit to 64 cards */
gaddress = 0x3000 + (card & 0x09f8);
else
else /* Card is from GROM */
gaddress = 0x3000 + (card & 0x0ff8);

gdata = Memory[gaddress + cardrow]; // fetch current line of current card graphic
Expand Down
Loading