mirror of
https://github.com/pevans/erc-c.git
synced 2025-03-06 13:29:19 +00:00
Add flash memory, disassemble options
This commit is contained in:
parent
ead5f28e79
commit
f70f21789b
@ -122,6 +122,7 @@ extern vm_16bit mos6502_pop_stack(mos6502 *);
|
|||||||
extern vm_8bit mos6502_next_byte(mos6502 *);
|
extern vm_8bit mos6502_next_byte(mos6502 *);
|
||||||
extern vm_8bit mos6502_read_byte(mos6502 *);
|
extern vm_8bit mos6502_read_byte(mos6502 *);
|
||||||
extern void mos6502_execute(mos6502 *, vm_8bit);
|
extern void mos6502_execute(mos6502 *, vm_8bit);
|
||||||
|
extern void mos6502_flash_memory(mos6502 *, vm_segment *);
|
||||||
extern void mos6502_free(mos6502 *);
|
extern void mos6502_free(mos6502 *);
|
||||||
extern void mos6502_modify_status(mos6502 *, vm_8bit, vm_8bit);
|
extern void mos6502_modify_status(mos6502 *, vm_8bit, vm_8bit);
|
||||||
extern void mos6502_push_stack(mos6502 *, vm_16bit);
|
extern void mos6502_push_stack(mos6502 *, vm_16bit);
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
#ifndef _OPTIONS_H_
|
#ifndef _OPTIONS_H_
|
||||||
#define _OPTIONS_H_
|
#define _OPTIONS_H_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
enum option_flags {
|
||||||
|
OPTION_FLASH = 1,
|
||||||
|
OPTION_DISASSEMBLE = 2,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are the most possible number of disk inputs we can accept
|
* These are the most possible number of disk inputs we can accept
|
||||||
*/
|
*/
|
||||||
#define OPTION_MAX_DISKS 2
|
#define OPTION_MAX_DISKS 2
|
||||||
|
|
||||||
|
extern bool option_flag(int);
|
||||||
extern FILE *option_get_input(int);
|
extern FILE *option_get_input(int);
|
||||||
extern const char *option_get_error();
|
extern const char *option_get_error();
|
||||||
extern int option_get_height();
|
extern int option_get_height();
|
||||||
|
13
src/apple2.c
13
src/apple2.c
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "apple2.h"
|
#include "apple2.h"
|
||||||
#include "apple2.draw.h"
|
#include "apple2.draw.h"
|
||||||
|
#include "mos6502.dis.h"
|
||||||
#include "option.h"
|
#include "option.h"
|
||||||
#include "vm_segment.h"
|
#include "vm_segment.h"
|
||||||
|
|
||||||
@ -121,6 +122,14 @@ apple2_boot(apple2 *mach)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (option_flag(OPTION_FLASH)) {
|
||||||
|
mos6502_flash_memory(mach->cpu, mach->drive1->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option_flag(OPTION_DISASSEMBLE)) {
|
||||||
|
mos6502_dis_scan(mach->cpu, stdout, 0, mach->cpu->memory->size);
|
||||||
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +204,10 @@ apple2_release_key(apple2 *mach)
|
|||||||
void
|
void
|
||||||
apple2_run_loop(apple2 *mach)
|
apple2_run_loop(apple2 *mach)
|
||||||
{
|
{
|
||||||
|
if (option_flag(OPTION_DISASSEMBLE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (vm_screen_active(mach->screen)) {
|
while (vm_screen_active(mach->screen)) {
|
||||||
vm_screen_refresh(mach->screen);
|
vm_screen_refresh(mach->screen);
|
||||||
}
|
}
|
||||||
|
@ -423,3 +423,9 @@ mos6502_would_jump(int inst_code)
|
|||||||
inst_code == JMP ||
|
inst_code == JMP ||
|
||||||
inst_code == JSR;
|
inst_code == JSR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mos6502_flash_memory(mos6502 *cpu, vm_segment *segment)
|
||||||
|
{
|
||||||
|
vm_segment_copy(cpu->memory, segment, 0, 0, cpu->memory->size - 1);
|
||||||
|
}
|
||||||
|
22
src/option.c
22
src/option.c
@ -41,6 +41,8 @@ static char error_buffer[ERRBUF_SIZE] = "";
|
|||||||
static int width = 700;
|
static int width = 700;
|
||||||
static int height = 480;
|
static int height = 480;
|
||||||
|
|
||||||
|
static int flags = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are all of the options we allow in our long-form options. It's
|
* These are all of the options we allow in our long-form options. It's
|
||||||
* a bit faster to identify them by integer symbols than to do string
|
* a bit faster to identify them by integer symbols than to do string
|
||||||
@ -51,14 +53,18 @@ enum options {
|
|||||||
DISK2,
|
DISK2,
|
||||||
HELP,
|
HELP,
|
||||||
SIZE,
|
SIZE,
|
||||||
|
FLASH,
|
||||||
|
DISASSEMBLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here are the options we support for program execution.
|
* Here are the options we support for program execution.
|
||||||
*/
|
*/
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
{ "disassemble", 0, NULL, DISASSEMBLE },
|
||||||
{ "disk1", 1, NULL, DISK1 },
|
{ "disk1", 1, NULL, DISK1 },
|
||||||
{ "disk2", 1, NULL, DISK2 },
|
{ "disk2", 1, NULL, DISK2 },
|
||||||
|
{ "flash", 0, NULL, FLASH },
|
||||||
{ "help", 0, NULL, HELP },
|
{ "help", 0, NULL, HELP },
|
||||||
{ "size", 1, NULL, SIZE },
|
{ "size", 1, NULL, SIZE },
|
||||||
};
|
};
|
||||||
@ -111,6 +117,10 @@ option_parse(int argc, char **argv)
|
|||||||
opt = getopt_long_only(argc, argv, "", long_options, &index);
|
opt = getopt_long_only(argc, argv, "", long_options, &index);
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case DISASSEMBLE:
|
||||||
|
flags |= OPTION_DISASSEMBLE;
|
||||||
|
break;
|
||||||
|
|
||||||
case DISK1:
|
case DISK1:
|
||||||
input_source = 1;
|
input_source = 1;
|
||||||
break;
|
break;
|
||||||
@ -119,6 +129,10 @@ option_parse(int argc, char **argv)
|
|||||||
input_source = 2;
|
input_source = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FLASH:
|
||||||
|
flags |= OPTION_FLASH;
|
||||||
|
break;
|
||||||
|
|
||||||
case HELP:
|
case HELP:
|
||||||
option_print_help();
|
option_print_help();
|
||||||
|
|
||||||
@ -216,8 +230,10 @@ option_print_help()
|
|||||||
fprintf(stderr, "Usage: erc [options...]\n");
|
fprintf(stderr, "Usage: erc [options...]\n");
|
||||||
fprintf(stderr, "Options:\n");
|
fprintf(stderr, "Options:\n");
|
||||||
fprintf(stderr, "\
|
fprintf(stderr, "\
|
||||||
|
--disassemble Print assembly notation from CPU memory\n\
|
||||||
--disk1=FILE Load FILE into disk drive 1\n\
|
--disk1=FILE Load FILE into disk drive 1\n\
|
||||||
--disk2=FILE Load FILE into disk drive 2\n\
|
--disk2=FILE Load FILE into disk drive 2\n\
|
||||||
|
--flash Flash CPU memory with contents of drive 1\n\
|
||||||
--help Print this help message\n\
|
--help Print this help message\n\
|
||||||
--size=WIDTHxHEIGHT Use WIDTH and HEIGHT for window size\n\
|
--size=WIDTHxHEIGHT Use WIDTH and HEIGHT for window size\n\
|
||||||
(only 700x480 and 875x600 are supported)\n");
|
(only 700x480 and 875x600 are supported)\n");
|
||||||
@ -263,3 +279,9 @@ option_get_height()
|
|||||||
{
|
{
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
option_flag(int flag)
|
||||||
|
{
|
||||||
|
return flags & flag;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user