1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-24 14:32:08 +00:00
Commit Graph

393 Commits

Author SHA1 Message Date
Peter Evans
ac5d532a7f Fix length bug with s_bytes (one too short)
This also fixes tests for disassembly so that they account for changed
output. Finally this also exits if we have to perror in the setup
function.
2018-02-23 21:35:53 -06:00
Peter Evans
395ac4a841 Disassembler now outputs more idiomatic code
It also no longer prints out register and address state
2018-02-23 20:46:24 -06:00
Peter Evans
0d1e22a348 Add support for decimal mode ADC/SBC.
This also corrects a bug where SBC set carry incorrectly in binary mode.
2018-02-23 00:46:07 -06:00
Peter Evans
2669460c6d Resolve potential bad dereference on sectab 2018-02-22 14:11:54 -06:00
Peter Evans
bee2a0e86a Add missing docblocks for NP2 and NP3 2018-02-22 14:10:19 -06:00
Peter Evans
978ad1faaf Formerly "BAD" instructions are now forms of NOPs
But weird forms. In most cases they basically are NOPs, except with
different opcodes. In other cases, we call them NP2 and NP3s, and do so
because they consume 2 or 3 bytes respectively (vs. just 1 with NOP).

We had to teach some arcane magic to the emulator for this to work. We
may want to refactor to decouple the number of bytes consumed from the
address mode.
2018-02-22 14:07:05 -06:00
Peter Evans
691387894a ASL, LSR, ROL, ROR in ABX now consume only 6 cycles
(Down from 7 cycles.)
2018-02-22 13:45:36 -06:00
Peter Evans
e35ff91fa7 Clear the decimal bit in BRK; also improve test logic for BRK 2018-02-22 13:44:13 -06:00
Peter Evans
90892c32e4 Add TSB (Test and Set Bits) instruction
This commit also moves the TRB code from loadstor to bits, which is
where it should have been all along.
2018-02-22 13:39:48 -06:00
Peter Evans
a4c3d1c4ef Implement the TRB (Test and Reset Bits) instruction 2018-02-22 00:39:33 -06:00
Peter Evans
807362e871 Add STZ instruction (to store zero) 2018-02-22 00:02:57 -06:00
Peter Evans
7363547608 Add PHX/Y and PLX/Y to the opcode, addr mode, cycle tables 2018-02-21 23:35:36 -06:00
Peter Evans
8e1ab0e950 Add support for PHX, PHY, PLX, PLY
These instructions allow you to push and pull (pop) the X and Y
registers via the stack.
2018-02-21 23:32:57 -06:00
Peter Evans
f9a277e7bc Add new Branch Always instruction 2018-02-21 21:57:21 -06:00
Peter Evans
58a1e31f58 Allow JMP to work with ABX address mode 2018-02-21 21:46:41 -06:00
Peter Evans
8623945bbf Add the ability to INC or DEC the accumulator
This is an oversight from the 6502 processor that was rectified in the
65c02 model.
2018-02-21 21:20:05 -06:00
Peter Evans
7b65dc1657 Add new BIM instruction (BIt imMediate mode)
This is not a real instruction in the 65c02 processor; I invented it for
the sole purpose of handling the specialized logic that is performed by
BIT in IMM mode. To be fair--I can imagine this really _was_ implemented
as a "separate" instruction on the chip! But I don't know that for sure.
2018-02-21 21:01:46 -06:00
Peter Evans
5ba5f91442 Add new address modes for BIT 2018-02-21 20:46:28 -06:00
Peter Evans
e1f11fc266 Add cycle counts 2018-02-21 20:43:04 -06:00
Peter Evans
739451366f Add zero-page instructions 2018-02-21 20:42:05 -06:00
Peter Evans
48872cf8d1 Add docblock comment for apple2_dd_sector_num 2018-02-21 11:23:25 -06:00
Peter Evans
61eb880f49 Refactor code to pass image type in 2018-02-21 00:23:12 -06:00
Peter Evans
1091ec6e2a Pass image type into enc_dos; use sector_num instead of a table pointer 2018-02-20 15:36:23 -06:00
Peter Evans
508be6458a Pass in sector table for logical-physical orders
We were not encoding data properly, because in DOS 3.3 and ProDOS,
sectors must be interleaved on disk media (whereas in the original image
form, data is laid out in a linear fashion).

This solves a bug where we erroneously encountered a "bad" opcode (a7)
in the program code.
2018-02-19 18:49:37 -06:00
Peter Evans
015104bd57 Self-sync bytes should be written after a sector header
Not after the data field marker, where the controller/RWTS don't expect
to find them.
2018-02-18 23:46:48 -06:00
Peter Evans
0d1e949d13 Mask the result so it's never more than a byte
This is because the eff_addr variable is a 16bit one, and adding addr +
X or addr + Y can possibly result in a 9-bit value, which is not what we
want. (You'd be pulling data from the stack instead of the zero page.)
2018-02-16 00:44:55 -06:00
Peter Evans
e9164d9872 Very minor changes to make the code simpler 2018-02-16 00:19:14 -06:00
Peter Evans
058b45e7d1 Use 9-bit rotation, not 8-bit 2018-02-15 19:32:01 -06:00
Peter Evans
067c0cea2f Also check the N flag (i.e. set it to zero) 2018-02-15 13:01:58 -06:00
Peter Evans
e415b3e490 We should check only the first byte for zero
We need to accept values for result that are greater than a byte so that
we can determine if carry is set, but this causes an issue when an app
uses addition to force an overflow that would set the zero bit. Masking
result for only the LSB fixes that problem.
2018-02-15 00:26:21 -06:00
Peter Evans
08b0e2e648 Show effective address 2018-02-14 22:19:35 -06:00
Peter Evans
fe70cd1f71 Remove debugging, use ENC_ETRACK for sector pos max
Also, there's no need for a while statement; we can just reset to zero.
2018-02-14 22:09:21 -06:00
Peter Evans
9a5c94bbbb The 49 opcode is EOR, not ADC.
Excuse me, I just need to scream now.

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

Thank you for your indulgence. Please carry on.
2018-02-14 21:37:02 -06:00
Peter Evans
64b9cbefcb Several changes to phase and writes
1. The phaser algorithm was reworked, and it should be more accurate in
choosing when to step forward or backward.
2. Writes should be committed when the latch has bit 7 high. This hasn't
actually been a problem yet, since other things are broken! But we might
as well fix it now that we've seen it.
2018-02-14 16:49:20 -06:00
Peter Evans
100621a6c6 Show second-digit row mappings for gcr62 2018-02-12 21:20:09 -06:00
Peter Evans
5b1298bded Document the gcr62 table 2018-02-12 21:19:47 -06:00
Peter Evans
ec522f259e Add block comments to describe source files 2018-02-12 21:15:20 -06:00
Peter Evans
0822b2f4ba Use the correct file name 2018-02-12 21:11:50 -06:00
Peter Evans
5c0f65215b Use the correct file name 2018-02-12 20:18:17 -06:00
Peter Evans
1e3f2e5781 Use the correct name of the source file 2018-02-12 19:28:37 -06:00
Peter Evans
e63d7e5d72 The file is apple2.dd.c 2018-02-12 18:24:35 -06:00
Peter Evans
ba387c004f We should be dividing, not using modulus 2018-02-11 20:36:41 -06:00
Peter Evans
3e2d8acacf The same track/sector method works for all images
Particularly so as the data segment is now the 6-and-2 encoded form,
which we either encode from DOS 3.3/ProDOS, or use literally from NIB
files.
2018-02-11 20:25:44 -06:00
Peter Evans
9f60e61cfb Add missing docblock comments 2018-02-09 23:14:05 -06:00
Peter Evans
3223fe6110 Enable disassembly toggle (ALT+D) 2018-02-07 15:24:02 -06:00
Peter Evans
c1cbdb4a43 ALT+P will pause 2018-02-07 14:44:26 -06:00
Peter Evans
308a1070ae Add paused field, pause execution 2018-02-07 14:44:04 -06:00
Peter Evans
433d9a436f Add pause function, flesh out machine_info 2018-02-07 14:43:20 -06:00
Peter Evans
a84b4c12e9 Treat pause and disasm as toggle functions
This allows us to remove the resume and disasm_off functions. (The
disasm_on function is simply renamed to disasm.)
2018-02-07 14:41:44 -06:00
Peter Evans
91d2267625 Really print out something useful for cpu_info 2018-02-07 00:14:38 -06:00
Peter Evans
3c1709c9b1 Add alt+i (info) option 2018-02-07 00:02:53 -06:00
Peter Evans
97846f5c1a Configure the DI with all of the standard stuff 2018-02-07 00:02:35 -06:00
Peter Evans
360e9243f8 Use the DI container to get machine/cpu/etc 2018-02-07 00:02:20 -06:00
Peter Evans
09017aa171 Use DI to obtain the reflect struct 2018-02-07 00:01:27 -06:00
Peter Evans
5e7492abdf Allow mutability if in testing 2018-02-06 23:37:20 -06:00
Peter Evans
4e0892dc86 Add dependency injection container for vm 2018-02-06 23:24:48 -06:00
Peter Evans
524412039a Implement a dumb stub for cpu_info 2018-02-06 21:10:08 -06:00
Peter Evans
608b2259e5 Break keyboard event logic out into normal/special 2018-02-06 16:29:15 -06:00
Peter Evans
fa5bfe09ae Add better handling if selected_drive is NULL
(Discovered from static analysis)
2018-02-06 14:58:00 -06:00
Peter Evans
0dce7dbc58 Remove unnecessary assignment 2018-02-06 14:37:04 -06:00
Peter Evans
fbee851daf Add apple2 reflect code 2018-02-06 00:30:46 -06:00
Peter Evans
318107d18f Change macro name to REFLECT_HANDLER 2018-02-05 21:54:38 -06:00
Peter Evans
8c0b69668c Add docblocks for vm_event functions 2018-02-05 21:43:02 -06:00
Peter Evans
c6bbb46dfe Add ignores for docblocks 2018-02-05 20:44:11 -06:00
Peter Evans
c1c42834ed Add reflect system to virtual machine 2018-02-05 20:31:05 -06:00
Peter Evans
4ce79c785c Only read or write if a disk is in the drive 2018-02-05 12:42:19 -06:00
Peter Evans
a13be6c413 Disable opcode output 2018-02-05 12:29:00 -06:00
Peter Evans
92ee67c8d8 Allow us to signal that we should exit 2018-02-05 00:35:04 -06:00
Peter Evans
72c4111458 Add event system; move event code into vm_event.c 2018-02-05 00:28:22 -06:00
Peter Evans
247bafbcce We also need to move beyond the sector header 2018-02-04 15:44:41 -06:00
Peter Evans
e23a3e4b63 Use macro definitions for track/sector length 2018-02-04 14:19:40 -06:00
Peter Evans
64364d91ad Remove unnecessary for loop 2018-02-04 14:15:24 -06:00
Peter Evans
463a9ba268 Handle all phase cases (zero and non-zero) 2018-02-04 01:11:30 -06:00
Peter Evans
1245ddec55 Make encode/decode more testable with return codes 2018-02-04 00:21:39 -06:00
Peter Evans
8009a33bd4 Use int return for error code 2018-02-04 00:06:22 -06:00
Peter Evans
2bdc921b76 Add missing docblocks 2018-02-03 21:56:27 -06:00
Peter Evans
67f943d891 When encoded, the track size is larger than 4k 2018-02-03 21:18:07 -06:00
Peter Evans
a6c1564747 Add fwrite function, support for streams and types 2018-02-03 20:50:08 -06:00
Peter Evans
2dd21f1487 Add image type, image segment 2018-02-03 18:10:29 -06:00
Peter Evans
c010c10ce2 Add missing docblocks 2018-02-03 17:46:56 -06:00
Peter Evans
10d13f755c Document the pseudo-instruction "bad" 2018-02-03 17:44:41 -06:00
Peter Evans
5ac2fbdbee Add new decode functions, flesh out sector code 2018-02-03 00:23:57 -06:00
Peter Evans
d2e21b55c4 Implement the sector decode function
This was a bear to do, and the product being committed is probably my
third (or fourth?) try.
2018-02-02 17:19:38 -06:00
Peter Evans
fadf5a9782 Add decode...code 2018-02-01 18:41:01 -06:00
Peter Evans
323803866a Include better documentation of otherwise grumpy functions 2018-01-31 15:58:32 -06:00
Peter Evans
98c2ef16cc Add encode function for nib 2018-01-31 15:40:39 -06:00
Peter Evans
4943d66e8c Correct typo so it's clear this is a get OOB 2018-01-31 15:40:06 -06:00
Peter Evans
c031822063 Use nibbilized size for dest; allow offset to overflow 2018-01-31 14:28:29 -06:00
Peter Evans
8a53e02f00 Rename to enc.c, add header file 2018-01-31 00:09:07 -06:00
Peter Evans
b09ca2dae5 Reword comment 2018-01-30 18:55:23 -06:00
Peter Evans
5c7dbb4cfe My first crack at some code for nibblization 2018-01-30 16:30:23 -06:00
Peter Evans
b2bfee7f96 The SLOTCXROM switch seems to work opposite
Which seems weird, but I've verified this in some other places.
2018-01-29 00:30:12 -06:00
Peter Evans
418688cd15 Lock disk drives during disassembly 2018-01-28 18:06:14 -06:00
Peter Evans
33b44d1a70 selected_drive will now have a default value (of drive1) 2018-01-27 21:53:12 -06:00
Peter Evans
2c3d6a4dfa Reimplement idx and idy to use 16-bit addresses
While I have found some conflicting details on how this should be done,
it seems pretty clear to me that IDX and IDY work with 16-bit addresses,
not 8-bit. The inability to do so was preventing us from probing
peripheral ROM (e.g. at $C705, for the disk controller).
2018-01-27 19:54:55 -06:00
Peter Evans
4165c1cefc Make idx, idy clearer
I'm still not confident this is how it _should_ work, but I have found
conflicting accounts online for the behavior of these two modes. The
current code is what allows the Apple II to bootstrap as it should.
2018-01-27 13:04:19 -06:00
Peter Evans
76e4d3797f By default SLOTCXROM should be high 2018-01-26 22:01:46 -06:00
Peter Evans
ca5276cb6b It turns out we don't use carry for addr modes.
This fix actually corrects a rather irritating bug where the Apple ][
logo was displaying one-off--e.g., as "pple ][D".
2018-01-26 21:18:42 -06:00
Peter Evans
9c0e01ecd2 Add drive phases, switches for control and i/o 2018-01-26 19:49:19 -06:00
Peter Evans
e901bcf54d Add docblock comments 2018-01-25 14:12:49 -06:00