mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-30 08:51:53 +00:00
Add init functions for disk2, sys rom
Also move the defines for bank offset, rom size, etc. into apple2.mem.h which makes a little more sense.
This commit is contained in:
parent
5b2c376abc
commit
e7a404508e
@ -6,21 +6,6 @@
|
||||
#include "vm_bitfont.h"
|
||||
#include "vm_screen.h"
|
||||
|
||||
/*
|
||||
* The size of our block of ROM is 12k
|
||||
*/
|
||||
#define APPLE2_ROM_SIZE 0x3000
|
||||
|
||||
/*
|
||||
* Whereas the second bank of RAM is a mere 4k
|
||||
*/
|
||||
#define APPLE2_RAM2_SIZE 0x1000
|
||||
|
||||
/*
|
||||
* This is the base address (or offset) for all bank-switched memory
|
||||
*/
|
||||
#define APPLE2_BANK_OFFSET 0xD000
|
||||
|
||||
enum video_modes {
|
||||
VIDEO_40COL_TEXT,
|
||||
VIDEO_LORES,
|
||||
|
@ -4,8 +4,29 @@
|
||||
#include "apple2.h"
|
||||
#include "vm_segment.h"
|
||||
|
||||
#define APPLE2_DISK2_ROM_OFFSET 0xC600
|
||||
#define APPLE2_DISK2_ROM_SIZE 0x100
|
||||
|
||||
/*
|
||||
* The size of our block of ROM is 12k
|
||||
*/
|
||||
#define APPLE2_ROM_SIZE 0x3000
|
||||
|
||||
/*
|
||||
* Whereas the second bank of RAM is a mere 4k
|
||||
*/
|
||||
#define APPLE2_RAM2_SIZE 0x1000
|
||||
|
||||
/*
|
||||
* This is the base address (or offset) for all bank-switched memory
|
||||
*/
|
||||
#define APPLE2_BANK_OFFSET 0xD000
|
||||
|
||||
|
||||
extern vm_8bit apple2_mem_read_bank(vm_segment *, size_t, void *);
|
||||
extern void apple2_mem_write_bank(vm_segment *, size_t, vm_8bit, void *);
|
||||
extern void apple2_mem_map(apple2 *);
|
||||
extern int apple2_mem_init_disk2_rom(apple2 *);
|
||||
extern int apple2_mem_init_sys_rom(apple2 *);
|
||||
|
||||
#endif
|
||||
|
@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "apple2.h"
|
||||
#include "apple2.mem.h"
|
||||
|
||||
/*
|
||||
* Return a byte of memory from a bank-switchable address. This may be
|
||||
@ -93,3 +94,52 @@ apple2_mem_map(apple2 *mach)
|
||||
vm_segment_write_map(mach->memory, addr, apple2_mem_write_bank);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Since we can't write into ROM normally, we need a separate function
|
||||
* we can call which will do the writing for us.
|
||||
*/
|
||||
int
|
||||
apple2_mem_init_disk2_rom(apple2 *mach)
|
||||
{
|
||||
FILE *stream;
|
||||
int err;
|
||||
|
||||
stream = fopen("./disk2.rom", "r");
|
||||
if (stream == NULL) {
|
||||
log_critical("Could not read disk2.rom");
|
||||
return ERR_BADFILE;
|
||||
}
|
||||
|
||||
err = vm_segment_fread(mach->memory, stream,
|
||||
APPLE2_DISK2_ROM_OFFSET, APPLE2_DISK2_ROM_SIZE);
|
||||
if (err != OK) {
|
||||
fclose(stream);
|
||||
log_critical("Could not read disk2.rom");
|
||||
return ERR_BADFILE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
apple2_mem_init_sys_rom(apple2 *mach)
|
||||
{
|
||||
FILE *stream;
|
||||
int err;
|
||||
|
||||
stream = fopen("./apple2.rom", "r");
|
||||
if (stream == NULL) {
|
||||
log_critical("Could not read apple2.rom");
|
||||
return ERR_BADFILE;
|
||||
}
|
||||
|
||||
err = vm_segment_fread(mach->rom, stream, 0, APPLE2_ROM_SIZE);
|
||||
if (err != OK) {
|
||||
fclose(stream);
|
||||
log_critical("Could not read apple2.rom");
|
||||
return ERR_BADFILE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user