dirkwhoffmann / virtualc64

VirtualC64 is a cycle-accurate C64 emulator for macOS
https://dirkwhoffmann.github.io/virtualc64
Other
342 stars 33 forks source link

Maintain the CPU as a separate open-source project #741

Closed dirkwhoffmann closed 1 year ago

dirkwhoffmann commented 1 year ago

In vAmiga, the Motorola 680x0 CPU is maintained as a separate project (Moira) which makes it easy to integrate the CPU in third-party applications. Also, licensing is different. Moira is published under the terms of the MIT license whereas the rest of vAmiga is licensed under the terms of the GPL.

I am planning to do the same for the MOS 6510 CPU in VirtualC64.

First steps:

dirkwhoffmann commented 1 year ago

Update: CPU code has been decoupled and moved to a separate repo.

GitHub actions have been configured to build a simple test app. It runs a tiny 6502 program computing the first 10 Fibonacci numbers. The program is run every night as a unit test:

Peddle - A MOS Technology 65xx CPU emulator

Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
Published under the terms of the MIT License

Test program:

0600: A2 01      LDX #01
0602: 8E 00 02   STX 0200
0605: 8E 01 02   STX 0201
0608: CA         DEX
0609: BD 00 02   LDA 0200,X
060C: 7D 01 02   ADC 0201,X
060F: 9D 02 02   STA 0202,X
0612: E8         INX
0613: E0 08      CPX #08
0615: D0 F2      BNE 0609
0617: 00         BRK

Instruction trace:

 PC  SR AC XR YR SP  NV-BDIZC
0602 34 00 01 00 00  00110100 STX 0200         0   0   0   0   0   0   0   0   0   0 
0605 34 00 01 00 00  00110100 STX 0201         1   0   0   0   0   0   0   0   0   0 
0608 34 00 01 00 00  00110100 DEX              1   1   0   0   0   0   0   0   0   0 
0609 36 00 00 00 00  00110110 LDA 0200,X       1   1   0   0   0   0   0   0   0   0 
060C 34 01 00 00 00  00110100 ADC 0201,X       1   1   0   0   0   0   0   0   0   0 
060F 34 02 00 00 00  00110100 STA 0202,X       1   1   0   0   0   0   0   0   0   0 
0612 34 02 00 00 00  00110100 INX              1   1   2   0   0   0   0   0   0   0 
0613 34 02 01 00 00  00110100 CPX #08          1   1   2   0   0   0   0   0   0   0 
0615 B4 02 01 00 00  10110100 BNE 0609         1   1   2   0   0   0   0   0   0   0 
0609 B4 02 01 00 00  10110100 LDA 0200,X       1   1   2   0   0   0   0   0   0   0 
060C 34 01 01 00 00  00110100 ADC 0201,X       1   1   2   0   0   0   0   0   0   0 
060F 34 03 01 00 00  00110100 STA 0202,X       1   1   2   0   0   0   0   0   0   0 
0612 34 03 01 00 00  00110100 INX              1   1   2   3   0   0   0   0   0   0 
0613 34 03 02 00 00  00110100 CPX #08          1   1   2   3   0   0   0   0   0   0 
0615 B4 03 02 00 00  10110100 BNE 0609         1   1   2   3   0   0   0   0   0   0 
0609 B4 03 02 00 00  10110100 LDA 0200,X       1   1   2   3   0   0   0   0   0   0 
060C 34 02 02 00 00  00110100 ADC 0201,X       1   1   2   3   0   0   0   0   0   0 
060F 34 05 02 00 00  00110100 STA 0202,X       1   1   2   3   0   0   0   0   0   0 
0612 34 05 02 00 00  00110100 INX              1   1   2   3   5   0   0   0   0   0 
0613 34 05 03 00 00  00110100 CPX #08          1   1   2   3   5   0   0   0   0   0 
0615 B4 05 03 00 00  10110100 BNE 0609         1   1   2   3   5   0   0   0   0   0 
0609 B4 05 03 00 00  10110100 LDA 0200,X       1   1   2   3   5   0   0   0   0   0 
060C 34 03 03 00 00  00110100 ADC 0201,X       1   1   2   3   5   0   0   0   0   0 
060F 34 08 03 00 00  00110100 STA 0202,X       1   1   2   3   5   0   0   0   0   0 
0612 34 08 03 00 00  00110100 INX              1   1   2   3   5   8   0   0   0   0 
0613 34 08 04 00 00  00110100 CPX #08          1   1   2   3   5   8   0   0   0   0 
0615 B4 08 04 00 00  10110100 BNE 0609         1   1   2   3   5   8   0   0   0   0 
0609 B4 08 04 00 00  10110100 LDA 0200,X       1   1   2   3   5   8   0   0   0   0 
060C 34 05 04 00 00  00110100 ADC 0201,X       1   1   2   3   5   8   0   0   0   0 
060F 34 0D 04 00 00  00110100 STA 0202,X       1   1   2   3   5   8   0   0   0   0 
0612 34 0D 04 00 00  00110100 INX              1   1   2   3   5   8  13   0   0   0 
0613 34 0D 05 00 00  00110100 CPX #08          1   1   2   3   5   8  13   0   0   0 
0615 B4 0D 05 00 00  10110100 BNE 0609         1   1   2   3   5   8  13   0   0   0 
0609 B4 0D 05 00 00  10110100 LDA 0200,X       1   1   2   3   5   8  13   0   0   0 
060C 34 08 05 00 00  00110100 ADC 0201,X       1   1   2   3   5   8  13   0   0   0 
060F 34 15 05 00 00  00110100 STA 0202,X       1   1   2   3   5   8  13   0   0   0 
0612 34 15 05 00 00  00110100 INX              1   1   2   3   5   8  13  21   0   0 
0613 34 15 06 00 00  00110100 CPX #08          1   1   2   3   5   8  13  21   0   0 
0615 B4 15 06 00 00  10110100 BNE 0609         1   1   2   3   5   8  13  21   0   0 
0609 B4 15 06 00 00  10110100 LDA 0200,X       1   1   2   3   5   8  13  21   0   0 
060C 34 0D 06 00 00  00110100 ADC 0201,X       1   1   2   3   5   8  13  21   0   0 
060F 34 22 06 00 00  00110100 STA 0202,X       1   1   2   3   5   8  13  21   0   0 
0612 34 22 06 00 00  00110100 INX              1   1   2   3   5   8  13  21  34   0 
0613 34 22 07 00 00  00110100 CPX #08          1   1   2   3   5   8  13  21  34   0 
0615 B4 22 07 00 00  10110100 BNE 0609         1   1   2   3   5   8  13  21  34   0 
0609 B4 22 07 00 00  10110100 LDA 0200,X       1   1   2   3   5   8  13  21  34   0 
060C 34 15 07 00 00  00110100 ADC 0201,X       1   1   2   3   5   8  13  21  34   0 
060F 34 37 07 00 00  00110100 STA 0202,X       1   1   2   3   5   8  13  21  34   0 
0612 34 37 07 00 00  00110100 INX              1   1   2   3   5   8  13  21  34  55 
0613 34 37 08 00 00  00110100 CPX #08          1   1   2   3   5   8  13  21  34  55 
0615 37 37 08 00 00  00110111 BNE 0609         1   1   2   3   5   8  13  21  34  55 
0617 37 37 08 00 00  00110111 BRK              1   1   2   3   5   8  13  21  34  55 

SUCCESS
dirkwhoffmann commented 1 year ago

It all went much faster than expected. Originally, I anticipated that I would be busy for a few weeks. Project-specific web-site is also online at https://dirkwhoffmann.github.io/Peddle/index.html