PIA input and output both work now

git-svn-id: svn+ssh://svn.phoenixbox.net/svn/apple1/trunk@12 64f78de7-aa59-e511-a0e8-0002a5492df0
This commit is contained in:
Daniel Loffgren 2015-09-14 07:18:02 +00:00
parent 4509c00cb1
commit 73ea7d164b
4 changed files with 77 additions and 10 deletions

View File

@ -10,6 +10,9 @@
E668389E1BA4F51E008F0F06 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = E668389D1BA4F51E008F0F06 /* main.c */; };
E66839001BA4F75C008F0F06 /* liblibv6502.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E66838F61BA4F705008F0F06 /* liblibv6502.a */; };
E66839061BA53A82008F0F06 /* pia.c in Sources */ = {isa = PBXBuildFile; fileRef = E66839041BA53A82008F0F06 /* pia.c */; };
E668391B1BA64C5B008F0F06 /* liblibdis6502.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E66838FC1BA4F705008F0F06 /* liblibdis6502.a */; };
E668391E1BA64C61008F0F06 /* liblibas6502.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E66838F81BA4F705008F0F06 /* liblibas6502.a */; };
E66839201BA659A6008F0F06 /* libcurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E668391F1BA659A6008F0F06 /* libcurses.dylib */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -97,6 +100,20 @@
remoteGlobalIDString = E638A4901B8AAA2300B71420;
remoteInfo = libv6502;
};
E66839191BA64C56008F0F06 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E66838D31BA4F705008F0F06 /* v6502.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = E638A4C71B8AAABC00B71420;
remoteInfo = libdis6502;
};
E668391C1BA64C5E008F0F06 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E66838D31BA4F705008F0F06 /* v6502.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = E638A49D1B8AAA6300B71420;
remoteInfo = libas6502;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@ -117,6 +134,7 @@
E66838D31BA4F705008F0F06 /* v6502.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = v6502.xcodeproj; path = v6502/v6502.xcodeproj; sourceTree = SOURCE_ROOT; };
E66839041BA53A82008F0F06 /* pia.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pia.c; sourceTree = "<group>"; };
E66839051BA53A82008F0F06 /* pia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pia.h; sourceTree = "<group>"; };
E668391F1BA659A6008F0F06 /* libcurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurses.dylib; path = usr/lib/libcurses.dylib; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -124,6 +142,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E66839201BA659A6008F0F06 /* libcurses.dylib in Frameworks */,
E668391E1BA64C61008F0F06 /* liblibas6502.a in Frameworks */,
E668391B1BA64C5B008F0F06 /* liblibdis6502.a in Frameworks */,
E66839001BA4F75C008F0F06 /* liblibv6502.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -152,8 +173,8 @@
isa = PBXGroup;
children = (
E668389D1BA4F51E008F0F06 /* main.c */,
E66839041BA53A82008F0F06 /* pia.c */,
E66839051BA53A82008F0F06 /* pia.h */,
E66839041BA53A82008F0F06 /* pia.c */,
);
path = apple1;
sourceTree = "<group>";
@ -161,6 +182,7 @@
E66838D21BA4F6F8008F0F06 /* Frameworks */ = {
isa = PBXGroup;
children = (
E668391F1BA659A6008F0F06 /* libcurses.dylib */,
E66838D31BA4F705008F0F06 /* v6502.xcodeproj */,
);
name = Frameworks;
@ -198,6 +220,8 @@
buildRules = (
);
dependencies = (
E668391D1BA64C5E008F0F06 /* PBXTargetDependency */,
E668391A1BA64C56008F0F06 /* PBXTargetDependency */,
E66838FF1BA4F753008F0F06 /* PBXTargetDependency */,
);
name = apple1;
@ -340,6 +364,16 @@
name = libv6502;
targetProxy = E66838FE1BA4F753008F0F06 /* PBXContainerItemProxy */;
};
E668391A1BA64C56008F0F06 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = libdis6502;
targetProxy = E66839191BA64C56008F0F06 /* PBXContainerItemProxy */;
};
E668391D1BA64C5E008F0F06 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = libas6502;
targetProxy = E668391C1BA64C5E008F0F06 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */

View File

@ -100,9 +100,10 @@ int main(int argc, const char * argv[])
v6502_reset(cpu);
// printSingleInstruction(cpu, cpu->pc);
while (!faulted) {
//printSingleInstruction(cpu, cpu->pc);
v6502_step(cpu);
// printSingleInstruction(cpu, cpu->pc);
}
pia_destroy(pia);

View File

@ -18,26 +18,54 @@ char asciiCharFromA1Char(uint8_t c) {
case 0xDC: return '\\';
case 0x8D: return '\n';
}
return (char)c & ~0x20;
}
uint8_t a1CharFromAsciiChar(char c) {
switch (c) {
case '\\': return 0xDC;
case '\n': return 0x8D;
}
return (char)c;
}
void videoWriteCharCallback(struct _v6502_memory *memory, uint16_t offset, uint8_t value, void *context) {
if (value) {
fprintf(stdout, ANSI_COLOR_BRIGHT_GREEN "%c" ANSI_COLOR_RESET, asciiCharFromA1Char(value));
//fprintf(stderr, "I was asked to print (0x%02x)\n", value);
// fprintf(stderr, "I was asked to print (0x%02x)\n", value);
//memory->bytes[offset] = value;
fflush(stdout);
}
}
void videoWriteNewlineCallback(struct _v6502_memory *memory, uint16_t offset, uint8_t value, void *context) {
fprintf(stdout, ANSI_COLOR_BRIGHT_GREEN "\n" ANSI_COLOR_RESET);
fprintf(stdout, ANSI_COLOR_BRIGHT_GREEN "\r\n" ANSI_COLOR_RESET);
fflush(stdout);
}
uint8_t keyboardReadNewlineCallback(struct _v6502_memory *memory, uint16_t offset, int trap, void *context) {
// FIXME: this is just to satiate the woz monitor until real input is hooked up
return 1;
uint8_t keyboardReadReadyCallback(struct _v6502_memory *memory, uint16_t offset, int trap, a1pia *context) {
if (context->buf) {
return 0xFF;
}
int c = getch();
if (c != ERR) {
context->buf = c;
return 0xFF;
}
return 0;
}
uint8_t keyboardReadCharacterCallback(struct _v6502_memory *memory, uint16_t offset, int trap, a1pia *context) {
if (context->buf) {
uint8_t a = a1CharFromAsciiChar(context->buf);
context->buf = '\0';
return a;
}
return 0;
}
static void _doCoolVideoStart(a1pia *pia) {
@ -48,9 +76,12 @@ a1pia *pia_create(v6502_memory *mem) {
a1pia *pia = malloc(sizeof(a1pia));
pia->memory = mem;
pia->screen = initscr();
v6502_map(mem, A1PIA_KEYBOARD_INPUT, 1, FIXME_I_SHOULDNT_BE_NULL, NULL, pia);
v6502_map(mem, A1PIA_KEYBOARD_CRLF_REG, 1, keyboardReadNewlineCallback, NULL, pia);
//nodelay(stdscr, true);
raw();
noecho();
v6502_map(mem, A1PIA_KEYBOARD_INPUT, 1, (v6502_readFunction *)keyboardReadCharacterCallback, NULL, pia);
v6502_map(mem, A1PIA_KEYBOARD_CRLF_REG, 1, (v6502_readFunction *)keyboardReadReadyCallback, NULL, pia);
v6502_map(mem, A1PIA_VIDEO_OUTPUT, 1, FIXME_I_SHOULDNT_BE_NULL, videoWriteCharCallback, pia);
v6502_map(mem, A1PIA_VIDEO_CRLF_REG, 1, FIXME_I_SHOULDNT_BE_NULL, videoWriteNewlineCallback, pia);

View File

@ -22,6 +22,7 @@ typedef struct {
WINDOW *screen;
/** @brief Hardwired memory used to trap video activity and report keyboard input */
v6502_memory *memory;
char buf;
} a1pia;
a1pia *pia_create(v6502_memory *mem);