Added some PIA lifecycle code, and curses action

git-svn-id: svn+ssh://svn.phoenixbox.net/svn/apple1/trunk@11 64f78de7-aa59-e511-a0e8-0002a5492df0
This commit is contained in:
Daniel Loffgren 2015-09-14 01:33:42 +00:00
parent 6241f39bd0
commit 4509c00cb1
3 changed files with 36 additions and 10 deletions

View File

@ -96,7 +96,7 @@ int main(int argc, const char * argv[])
v6502_write(cpu->memory, v6502_memoryVectorResetHigh, RESET_VECTOR >> 8);
// Attach PIA
pia_map(cpu->memory);
a1pia *pia = pia_create(cpu->memory);
v6502_reset(cpu);
@ -105,6 +105,7 @@ int main(int argc, const char * argv[])
v6502_step(cpu);
}
pia_destroy(pia);
v6502_destroyMemory(cpu->memory);
v6502_destroyCPU(cpu);
}

View File

@ -9,6 +9,7 @@
#include "pia.h"
#include <stdio.h>
#include <as6502/color.h>
#include <stdlib.h>
#define FIXME_I_SHOULDNT_BE_NULL NULL
@ -35,13 +36,29 @@ void videoWriteNewlineCallback(struct _v6502_memory *memory, uint16_t offset, ui
}
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
// FIXME: this is just to satiate the woz monitor until real input is hooked up
return 1;
}
void pia_map(v6502_memory *mem) {
v6502_map(mem, A1PIA_KEYBOARD_INPUT, 1, FIXME_I_SHOULDNT_BE_NULL, NULL, NULL);
v6502_map(mem, A1PIA_KEYBOARD_CRLF_REG, 1, keyboardReadNewlineCallback, NULL, NULL);
v6502_map(mem, A1PIA_VIDEO_OUTPUT, 1, FIXME_I_SHOULDNT_BE_NULL, videoWriteCharCallback, NULL);
v6502_map(mem, A1PIA_VIDEO_CRLF_REG, 1, FIXME_I_SHOULDNT_BE_NULL, videoWriteNewlineCallback, NULL);
}
static void _doCoolVideoStart(a1pia *pia) {
}
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);
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);
_doCoolVideoStart(pia);
return pia;
}
void pia_destroy(a1pia *pia) {
endwin();
free(pia);
}

View File

@ -10,13 +10,21 @@
#define __apple1__pia__
#include <v6502/mem.h>
#include <curses.h>
#define A1PIA_KEYBOARD_INPUT 0xD010
#define A1PIA_KEYBOARD_CRLF_REG 0xD011
#define A1PIA_VIDEO_OUTPUT 0xD012
#define A1PIA_VIDEO_CRLF_REG 0xD013
// Assumes stdin/stdout
void pia_map(v6502_memory *mem);
typedef struct {
/** @brief Curses output object */
WINDOW *screen;
/** @brief Hardwired memory used to trap video activity and report keyboard input */
v6502_memory *memory;
} a1pia;
a1pia *pia_create(v6502_memory *mem);
void pia_destroy(a1pia *pia);
#endif /* defined(__apple1__pia__) */