Peter Evans
3738d70a43
Switch bank code into its own file
2018-01-12 22:06:49 -06:00
Peter Evans
208c909fc2
Memory is determined solely by BANK_ALTZP.
...
Previously, we just used whatever the segment was that got passed in.
But aside from switching the stack and zero page, ALTZP also changes
where bank-switchable memory is read from and written to; it's either
always aux memory (ALTZP is on) or always main memory (ALTZP is off).
2018-01-12 21:21:08 -06:00
Peter Evans
c953616a71
Finish refactor to separate bank_switch and memory_mode
...
There is one failing test, which I expect to fail at this point; that's
because we need to write a read/write map function for the stack and
zero page so that they use aux memory when BANK_ALTZP is on, and main
memory when not.
2018-01-12 21:04:21 -06:00
Peter Evans
ceccacfbc8
Rework bank switch and memory mode into their own fields.
...
This is to better define and respect the various modes that you can have
in Apple II memory access. This is a work in progress at the moment.
2018-01-12 16:21:49 -06:00
Peter Evans
f69454c965
Some soft switches now require consecutive reads
...
To allow this to work, we had to allow the CPU struct to record what the
last opcode/operand/address were, although in truth we only needed the
last address.
2018-01-12 14:49:27 -06:00
Peter Evans
7d6886a3a8
Change last_addr field to eff_addr
2018-01-12 13:57:48 -06:00
Peter Evans
e56ed9ea43
Add missing docblocks
2018-01-11 22:48:40 -06:00
Peter Evans
21040898b3
Return, don't break in write mapper; log if we get to the end
2018-01-11 22:23:53 -06:00
Peter Evans
d79bcba5ec
Add missing docblocks
2018-01-11 21:58:05 -06:00
Peter Evans
9564f86a57
Remove flash_memory function
2018-01-11 21:57:52 -06:00
Peter Evans
578e0b291c
Allow us to switch main/aux; write bank switch mappers
2018-01-11 19:52:13 -06:00
Peter Evans
a17ad0596b
Initialize cpu as NULL
...
Static analysis in clang caught this; we might try to free memory from a
garbage pointer value if the main segment malloc fails.
2018-01-11 13:25:22 -06:00
Peter Evans
9d2f9b6f60
Refactor to remove ram2
...
Both main and auxiliary memory need to keep an extra 4k of memory that
is bank-switchable, so we have changed to store that memory literally
within the main and aux segments.
2018-01-11 13:19:17 -06:00
Peter Evans
81b07361fb
Wait less time for instructions
2018-01-10 21:49:52 -06:00
Peter Evans
fe0ed815a9
Move bank switch set up for the mem init functions.
...
This also changes bank_switch to mirror at boot what the reset function
does later on. Without doing so, our init memory routines will fail.
2018-01-10 21:48:55 -06:00
Peter Evans
24e6e0fd25
Properly free main/aux memory
2018-01-10 21:29:25 -06:00
Peter Evans
8d9b48912e
Add memory injection to 6502; main memory in apple2
...
Note that memory _is_ now managed in apple2, and _not_ in mos6502.
2018-01-10 21:28:05 -06:00
Peter Evans
04854d903c
Add aux memory field
2018-01-10 20:36:44 -06:00
Peter Evans
8898c3e59d
Use macros to define segment read/write map functions
2018-01-10 20:12:48 -06:00
Peter Evans
3db536a83d
Change memory_mode -> bank_switch
...
This also changes the concept of the field; bank_switch is a collection
of bit flags now.
2018-01-10 19:59:33 -06:00
Peter Evans
343d870399
Add missing mach parameter to set_video/set_memory
2018-01-10 16:59:02 -06:00
Peter Evans
aa486656b3
Set the reset vector to the applesoft interpreter address
2018-01-10 16:47:18 -06:00
Peter Evans
cb53c70cda
We missed a doc-block for the new set16 func
2018-01-10 16:46:55 -06:00
Peter Evans
fcba14f91b
Add set16 function
2018-01-10 16:43:14 -06:00
Peter Evans
6af0ae85a4
Also force bank switch mode back to ROM
2018-01-10 15:16:12 -06:00
Peter Evans
c9188a288d
Reset should change the video mode to 40 column text
2018-01-10 15:14:07 -06:00
Peter Evans
7f6b8d3587
We can no longer assume PC increments during address handling
...
This change required a number of consequent changes to assumptions we'd
made, and I'm not 100% confident we have things right at this point in
time.
2018-01-09 20:59:14 -06:00
Peter Evans
e3ab043aee
We no longer need to pass the opcode here
2018-01-09 20:58:53 -06:00
Peter Evans
80a7671a19
Remove next_byte, read_byte; execute works without an opcode arg
...
This also adds RTS and RTI as instructions that "would jump".
2018-01-09 20:58:19 -06:00
Peter Evans
de859bcea8
We were not obeying little-endianness here
2018-01-09 16:24:25 -06:00
Peter Evans
d7148b88bf
Relative address was not being calculated correctly.
...
The disassembler is using the correct approach, so I adapted it to the
execution code.
2018-01-09 15:57:37 -06:00
Peter Evans
a267065059
Include cycle information
2018-01-09 15:57:20 -06:00
Peter Evans
8201117223
Change init routine to use peripheral function
2018-01-09 15:56:48 -06:00
Peter Evans
0e0244162f
Change objstore structure to contain all peripheral ROM
2018-01-09 15:56:21 -06:00
Peter Evans
3c46a41351
Fix little-endian issue with IND output
...
Also change the ADDR label to emit a hex code, not a decimal code.
2018-01-08 23:36:11 -06:00
Peter Evans
1abf0223c8
The value of PC by that point is correct.
...
Adding 2 skips us ahead farther than we should be going.
2018-01-08 22:25:37 -06:00
Peter Evans
f7b8740c2e
Let the CPU run for longer before it dies
2018-01-08 22:24:30 -06:00
Peter Evans
b21b48cac0
Fix a couple of issues...
...
1. The execute function should not be incrementing the PC register, as
this happens in other places.
2. The push_ and pop_stack functions were not considering that the data
should be in little-endian order.
2018-01-08 21:22:29 -06:00
Peter Evans
e4049a6a11
Better info on each opcode sequence
...
Plus fix a display bug that showed the operand in the wrong order.
2018-01-08 21:21:09 -06:00
Peter Evans
7c899122ad
We should advance to the next byte in execution
2018-01-08 21:15:56 -06:00
Peter Evans
a8bba409c3
Change 16-bit references to respect little-endianness
...
As the Apple II (or rather the 6502 chip) is little-endian, meaning the
least significant byte is the first byte you read going forward, rather
than the last byte.
2018-01-08 17:10:26 -06:00
Peter Evans
3f59db311b
Allow us to ignore some docblock errors
2018-01-07 20:08:46 -06:00
Peter Evans
b2add9c3de
Move vm_area logic into its own file
2018-01-07 20:05:02 -06:00
Peter Evans
95e57a8e19
Add get_map_machine function.
...
Mostly useless except for testing.
2018-01-07 20:00:09 -06:00
Peter Evans
ba47de0e4b
Add objstore_clear(), tests for objstore
2018-01-07 16:30:33 -06:00
Peter Evans
1c36c4ea4d
Add missing docblock comments
2018-01-07 16:07:29 -06:00
Peter Evans
cccf6df354
Move address resolver
2018-01-07 15:47:57 -06:00
Peter Evans
888eb25797
Refactor a bit for easier testing; add log_stream()
2018-01-07 15:05:20 -06:00
Peter Evans
5da65e0a9e
Change apple2dd -> apple2_dd
2018-01-07 14:46:54 -06:00
Peter Evans
665f7de37c
Rename apple2dd_ to apple2_dd_
...
Except for the struct object (apple2dd).
2018-01-07 13:44:07 -06:00
Peter Evans
8ad1311536
Add set_memory function
2018-01-06 21:37:15 -06:00
Peter Evans
d9527db033
Retrieve the 16-bit PC address.
...
This fixes a bug where we only got an 8-bit address from $FFFC and
ignored the LSB at $FFFD.
2018-01-05 16:15:13 -06:00
Peter Evans
70516a7f91
Add function to return 16-bit value from a segment address
2018-01-05 16:14:51 -06:00
Peter Evans
c6799db689
Separate reset logic from boot function
2018-01-05 16:04:01 -06:00
Peter Evans
af7dae6924
Advance PC by # of bytes consumed
2018-01-05 15:52:20 -06:00
Peter Evans
7ceee608b3
Stop delaying by 2 seconds
2018-01-05 15:52:04 -06:00
Peter Evans
c7aa9e9fc3
Resolver may be NULL; don't call if so
...
This change also registers a default value for operand (0).
2018-01-05 14:57:38 -06:00
Peter Evans
d5b6205713
Actually execute some opcodes
2018-01-05 14:55:33 -06:00
Peter Evans
fd8f36b34e
We need to use the mach cpu
2018-01-05 14:19:13 -06:00
Peter Evans
1de1e7788a
Rename status flags to MOS_
2018-01-05 14:18:39 -06:00
Peter Evans
2da613f7aa
Provisional state upon reboot
2018-01-04 20:09:53 -06:00
Peter Evans
3f0a091520
Use const pointers; fix function name typo
2018-01-04 19:59:04 -06:00
Peter Evans
700bc31465
Copy system rom into $C800..$CFFF; document.
...
Things are getting a little hairy...at least, as to my own
comprehension. Documentation is a must.
2018-01-04 19:53:12 -06:00
Peter Evans
e184304ec5
A little more documentation post-rwops changes
2018-01-04 14:21:05 -06:00
Peter Evans
171ff62551
Change create to use objstore vm_8bit data
2018-01-03 21:50:30 -06:00
Peter Evans
565dd1b34b
Make sure the object store got built
2018-01-03 21:50:01 -06:00
Peter Evans
06d37d24d7
Allow us to call objstore_init more than once.
...
This also separates some code into objstore_ready().
2018-01-03 21:49:26 -06:00
Peter Evans
7182608473
Copy vm_8bit buffer into rom/memory directly
2018-01-03 21:10:46 -06:00
Peter Evans
90d6c637c5
Add function to copy a buffer into a segment
2018-01-03 21:10:25 -06:00
Peter Evans
4d07bd7640
Add objstore code, tests
2018-01-03 20:51:20 -06:00
Peter Evans
b1c2a2109e
Just use stdout if we never opened a log file
2018-01-03 20:47:41 -06:00
Peter Evans
484a11e976
Pass in zero for an offset
2018-01-03 15:21:00 -06:00
Peter Evans
fac6b4f574
Initialize system and disk2 rom
2018-01-03 15:20:48 -06:00
Peter Evans
86dad129b6
Let us fread into a segment offset
2018-01-03 15:16:30 -06:00
Peter Evans
e7a404508e
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.
2018-01-03 15:07:19 -06:00
Peter Evans
5b2c376abc
Prevent writes to the ROM bank
2018-01-03 14:27:55 -06:00
Peter Evans
9a1e51fec3
We need to pass the machine, not memory
2018-01-02 23:49:29 -06:00
Peter Evans
cb9a7d0fce
Let the segment vm know about the machine
2018-01-02 21:12:21 -06:00
Peter Evans
ee7b5f66b0
Add support for a map machine pointer
...
To be sent to the read/write functions that are implemented by said
machine.
2018-01-02 21:11:43 -06:00
Peter Evans
3fe7a4e0bb
Use explicit memory size of MOS6502
2018-01-02 20:48:42 -06:00
Peter Evans
73f7d8f63a
Actually map memory when we create an apple2
2018-01-02 16:30:21 -06:00
Peter Evans
33c8f0de9d
Add memory map functions
2018-01-02 16:26:51 -06:00
Peter Evans
834959c10a
Add rom, ram2 bank memory; modify read/write sig
...
The signature for read/write map functions now accepts a void pointer so
that we can pass in the machine that those functions may need to know
about. This is a bit hairy, but allows us to avoid the need for a
yet-uglier global variable.
2018-01-02 16:24:51 -06:00
Peter Evans
49d475d534
Documentation
2018-01-01 17:41:15 -06:00
Peter Evans
d53b6df7a4
Add documentation; plus set sector/track pos to 0 on eject
2018-01-01 17:26:29 -06:00
Peter Evans
2aeef09f97
Remove unused msb variable
2018-01-01 17:12:41 -06:00
Peter Evans
8f04deb642
Comment out unused cycles variable
2018-01-01 17:12:25 -06:00
Peter Evans
78aab1bd13
Fix potential memory leaks in create()
2018-01-01 17:11:03 -06:00
Peter Evans
a2b4fe1466
Write an fread function for segments; use in apple2.dd
2017-12-31 20:28:11 -06:00
Peter Evans
e14e22a596
Uh, so we forgot to read data into the disk
2017-12-31 15:54:30 -06:00
Peter Evans
f70f21789b
Add flash memory, disassemble options
2017-12-31 15:50:59 -06:00
Peter Evans
ead5f28e79
Refactor to use cpu, not literal segments
2017-12-30 23:02:30 -06:00
Peter Evans
b42d5370aa
Small bug in the jump label code for IND
...
This also required a rethink on some core functions which now needed to
know about the memory segment; and further changes in the unit-testing
code on the disassembly suite was also necessary.
2017-12-30 22:50:23 -06:00
Peter Evans
7e142e2736
Properly handle indirect addresses
2017-12-30 21:48:16 -06:00
Peter Evans
26529f77ab
Implement jump table, labels in code
2017-12-29 17:08:25 -06:00
Peter Evans
927d03ebbe
Add scan function (rename original scan -> opcode); test
2017-12-29 15:31:05 -06:00
Peter Evans
f98e2f65ee
Add disassembly scan function, tests
2017-12-28 23:47:36 -06:00
Peter Evans
491b3c0c38
Add scan function for disassembly
2017-12-28 21:47:35 -06:00
Peter Evans
d95572bd4a
Move instruction strings to mos6502.dis.c
2017-12-27 21:21:33 -06:00
Peter Evans
32d08fbbc5
Add new file for opcode disassembly
2017-12-27 21:21:11 -06:00