-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bd7b5c
commit e1606ab
Showing
8 changed files
with
534 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include "bank1.h" | ||
#include "mmu.h" | ||
#include <string.h> | ||
|
||
void bnk1_init(void) | ||
{ | ||
mmu.cr = 0x3e; | ||
memcpy((char *)0xfc00, (char *)0xf000, 0x0300); | ||
xmmu.rcr |= 0x0c; | ||
mmu.cr = 0x3f; | ||
} | ||
|
||
#pragma code(bnk1code) | ||
|
||
char bnk1_readb(volatile char * p) | ||
{ | ||
mmu.bank1 = 0; | ||
char c = *p; | ||
mmu.bank0 = 0; | ||
return c; | ||
} | ||
|
||
unsigned bnk1_readw(volatile unsigned * p) | ||
{ | ||
mmu.bank1 = 0; | ||
unsigned w = *p; | ||
mmu.bank0 = 1; | ||
return w; | ||
} | ||
|
||
unsigned long bnk1_readl(volatile unsigned long * p) | ||
{ | ||
mmu.bank1 = 0; | ||
unsigned long l = *p; | ||
mmu.bank0 = 3; | ||
return l; | ||
} | ||
|
||
void bnk1_readm(char * dp, volatile char * sp, unsigned size) | ||
{ | ||
while (size > 0) | ||
{ | ||
mmu.bank1 = 0; | ||
char c = * sp++; | ||
mmu.bank0 = c; | ||
*dp++ = c; | ||
size--; | ||
} | ||
} | ||
|
||
void bnk1_writeb(volatile char * p, char b) | ||
{ | ||
mmu.bank1 = b; | ||
*p = b; | ||
mmu.bank0 = b; | ||
} | ||
|
||
void bnk1_writew(volatile unsigned * p, unsigned w) | ||
{ | ||
mmu.bank1 = w; | ||
*p = w; | ||
mmu.bank0 = w; | ||
} | ||
|
||
void bnk1_writel(volatile unsigned long * p, unsigned long l) | ||
{ | ||
mmu.bank1 = l; | ||
*p = l; | ||
mmu.bank0 = l; | ||
} | ||
|
||
void bnk1_writem(volatile char * dp, const char * sp, unsigned size) | ||
{ | ||
while (size > 0) | ||
{ | ||
char c = * sp++; | ||
mmu.bank1 = c; | ||
*dp++ = c; | ||
mmu.bank0 = c; | ||
size--; | ||
} | ||
} | ||
|
||
#pragma code(code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef C128_BANK1_H | ||
#define C128_BANK1_H | ||
|
||
|
||
#pragma section( bnk1code, 0) | ||
|
||
#pragma region( bnk1code, 0xf000, 0xf300, , , {bnk1code}, 0xfc00 ) | ||
|
||
void bnk1_init(void); | ||
|
||
#pragma code(bnk1code) | ||
|
||
char bnk1_readb(volatile char * p); | ||
|
||
unsigned bnk1_readw(volatile unsigned * p); | ||
|
||
unsigned long bnk1_readl(volatile unsigned long * p); | ||
|
||
void bnk1_readm(char * dp, volatile char * sp, unsigned size); | ||
|
||
|
||
void bnk1_writeb(volatile char * p, char b); | ||
|
||
void bnk1_writew(volatile unsigned * p, unsigned w); | ||
|
||
void bnk1_writel(volatile unsigned long * p, unsigned long l); | ||
|
||
void bnk1_writem(volatile char * dp, const char * sp, unsigned size); | ||
|
||
#pragma code(code) | ||
|
||
#pragma compile("bank1.c") | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "mmu.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef C128_MMU_H | ||
#define C128_MMU_H | ||
|
||
#include <c64/types.h> | ||
|
||
struct MMU | ||
{ | ||
volatile byte cr; | ||
volatile byte bank0; | ||
volatile byte bank1; | ||
volatile byte bank14; | ||
volatile byte bankx; | ||
}; | ||
|
||
struct XMMU | ||
{ | ||
volatile byte cr; | ||
volatile byte pcr[4]; | ||
volatile byte mcr; | ||
volatile byte rcr; | ||
volatile word page0; | ||
volatile word page1; | ||
volatile byte vr; | ||
}; | ||
|
||
#define mmu (*((struct MMU *)0xff00)) | ||
|
||
#define xmmu (*((struct XMMU *)0xd500)) | ||
|
||
|
||
#pragma compile("mmu.c") | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.