├── 8008MC ├── .dep.inc ├── Makefile ├── __8008_mnemonics.h ├── __8008_opcodes.h ├── __8008_ports.h ├── __font7x9_mcmfont.h ├── framework │ ├── debugger.cpp │ ├── debugger.h │ ├── debugger.o │ ├── font.h │ ├── gfx.cpp │ ├── gfx.h │ ├── gfx.o │ ├── main.cpp │ └── main.o ├── hardware.cpp ├── nbproject │ ├── Makefile-Debug.mk │ ├── Makefile-Release.mk │ ├── Makefile-impl.mk │ ├── Makefile-variables.mk │ ├── Package-Debug.bash │ ├── Package-Release.bash │ ├── configurations.xml │ ├── private │ │ ├── Makefile-variables.mk │ │ ├── c_standard_headers_indexer.c │ │ ├── configurations.xml │ │ ├── cpp_standard_headers_indexer.cpp │ │ ├── launcher.properties │ │ └── private.xml │ └── project.xml ├── sys_debug_8008.cpp ├── sys_debug_system.h ├── sys_processor.cpp ├── sys_processor.h └── test.bin ├── LICENSE ├── README.md ├── basic ├── basic.asm ├── basic.bin ├── basic.lst └── go.sh ├── documentation ├── 8008datasheet.pdf └── machine.odt ├── documents ├── CDP1802.pdf └── Hardware.odt ├── emulator ├── .dep.inc ├── Makefile ├── __1802mnemonics.h ├── __1802opcodes.h ├── __1802ports.h ├── __1802support.h ├── a.out ├── build │ └── Debug │ │ └── GNU-Linux │ │ ├── framework │ │ ├── debugger.o │ │ ├── debugger.o.d │ │ ├── gfx.o │ │ ├── gfx.o.d │ │ ├── main.o │ │ └── main.o.d │ │ ├── hardware.o │ │ ├── hardware.o.d │ │ ├── sys_debug_vip.o │ │ ├── sys_debug_vip.o.d │ │ ├── sys_processor.o │ │ └── sys_processor.o.d ├── framework │ ├── debugger.cpp │ ├── debugger.h │ ├── debugger.o │ ├── font.h │ ├── gfx.cpp │ ├── gfx.h │ ├── gfx.o │ ├── main.cpp │ └── main.o ├── go.sh ├── hardware.cpp ├── hardware.h ├── monitor_rom.h ├── nbproject │ ├── Makefile-Debug.mk │ ├── Makefile-Release.mk │ ├── Makefile-impl.mk │ ├── Makefile-variables.mk │ ├── Package-Debug.bash │ ├── Package-Release.bash │ ├── configurations.xml │ ├── private │ │ ├── Makefile-variables.mk │ │ ├── c_standard_headers_indexer.c │ │ ├── configurations.xml │ │ ├── cpp_standard_headers_indexer.cpp │ │ ├── launcher.properties │ │ └── private.xml │ └── project.xml ├── sys_debug_system.h ├── sys_debug_vip.cpp ├── sys_processor.cpp ├── sys_processor.h ├── test.asm ├── test.bin └── test.lst ├── mcm6571-font ├── font.tiff ├── fontrip.py └── mcmfont.h └── processor ├── 8008.def ├── __8008_mnemonics.h ├── __8008_opcodes.h ├── __8008_ports.h ├── build.sh └── process.py /8008MC/.dep.inc: -------------------------------------------------------------------------------- 1 | # This code depends on make tool being used 2 | DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES})) 3 | ifneq (${DEPFILES},) 4 | include ${DEPFILES} 5 | endif 6 | -------------------------------------------------------------------------------- /8008MC/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # There exist several targets which are by default empty and which can be 3 | # used for execution of your targets. These targets are usually executed 4 | # before and after some main targets. They are: 5 | # 6 | # .build-pre: called before 'build' target 7 | # .build-post: called after 'build' target 8 | # .clean-pre: called before 'clean' target 9 | # .clean-post: called after 'clean' target 10 | # .clobber-pre: called before 'clobber' target 11 | # .clobber-post: called after 'clobber' target 12 | # .all-pre: called before 'all' target 13 | # .all-post: called after 'all' target 14 | # .help-pre: called before 'help' target 15 | # .help-post: called after 'help' target 16 | # 17 | # Targets beginning with '.' are not intended to be called on their own. 18 | # 19 | # Main targets can be executed directly, and they are: 20 | # 21 | # build build a specific configuration 22 | # clean remove built files from a configuration 23 | # clobber remove all built files 24 | # all build all configurations 25 | # help print help mesage 26 | # 27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and 28 | # .help-impl are implemented in nbproject/makefile-impl.mk. 29 | # 30 | # Available make variables: 31 | # 32 | # CND_BASEDIR base directory for relative paths 33 | # CND_DISTDIR default top distribution directory (build artifacts) 34 | # CND_BUILDDIR default top build directory (object files, ...) 35 | # CONF name of current configuration 36 | # CND_PLATFORM_${CONF} platform name (current configuration) 37 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) 38 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) 39 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) 40 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) 41 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration) 42 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration) 43 | # 44 | # NOCDDL 45 | 46 | 47 | # Environment 48 | MKDIR=mkdir 49 | CP=cp 50 | CCADMIN=CCadmin 51 | 52 | 53 | # build 54 | build: .build-post 55 | 56 | .build-pre: 57 | # Add your pre 'build' code here... 58 | 59 | .build-post: .build-impl 60 | # Add your post 'build' code here... 61 | 62 | 63 | # clean 64 | clean: .clean-post 65 | 66 | .clean-pre: 67 | # Add your pre 'clean' code here... 68 | 69 | .clean-post: .clean-impl 70 | # Add your post 'clean' code here... 71 | 72 | 73 | # clobber 74 | clobber: .clobber-post 75 | 76 | .clobber-pre: 77 | # Add your pre 'clobber' code here... 78 | 79 | .clobber-post: .clobber-impl 80 | # Add your post 'clobber' code here... 81 | 82 | 83 | # all 84 | all: .all-post 85 | 86 | .all-pre: 87 | # Add your pre 'all' code here... 88 | 89 | .all-post: .all-impl 90 | # Add your post 'all' code here... 91 | 92 | 93 | # build tests 94 | build-tests: .build-tests-post 95 | 96 | .build-tests-pre: 97 | # Add your pre 'build-tests' code here... 98 | 99 | .build-tests-post: .build-tests-impl 100 | # Add your post 'build-tests' code here... 101 | 102 | 103 | # run tests 104 | test: .test-post 105 | 106 | .test-pre: build-tests 107 | # Add your pre 'test' code here... 108 | 109 | .test-post: .test-impl 110 | # Add your post 'test' code here... 111 | 112 | 113 | # help 114 | help: .help-post 115 | 116 | .help-pre: 117 | # Add your pre 'help' code here... 118 | 119 | .help-post: .help-impl 120 | # Add your post 'help' code here... 121 | 122 | 123 | 124 | # include project implementation makefile 125 | include nbproject/Makefile-impl.mk 126 | 127 | # include project make variables 128 | include nbproject/Makefile-variables.mk 129 | -------------------------------------------------------------------------------- /8008MC/__8008_mnemonics.h: -------------------------------------------------------------------------------- 1 | "hlt","hlt","rlc","rnc","adi @1","rst 00","mvi a,@1","ret","inr b","dcr b","rrc","rnz","aci @1","rst 08","mvi b,@1","ret","inr c","dcr c","ral","rp","sui @1","rst 10","mvi c,@1","ret","inr d","dcr d","rar","rpo","sbi @1","rst 18","mvi d,@1","ret","inr e","dcr e","db 22","rc","ani @1","rst 20","mvi e,@1","ret","inr h","dcr h","db 2a","rz","xri @1","rst 28","mvi h,@1","ret","inr l","dcr l","db 32","rm","ori @1","rst 30","mvi l,@1","ret","db 38","db 39","db 3a","rpe","cpi @1","rst 38","mvi m,@1","ret","jnc @2","in 00","cnc @2","in 01","jmp @2","in 02","call @2","in 03","jnz @2","in 04","cnz @2","in 05","jmp @2","in 06","call @2","in 07","jp @2","out 08","cp @2","out 09","jmp @2","out 0a","call @2","out 0b","jpo @2","out 0c","cpo @2","out 0d","jmp @2","out 0e","call @2","out 0f","jc @2","out 10","cc @2","out 11","jmp @2","out 12","call @2","out 13","jz @2","out 14","cz @2","out 15","jmp @2","out 16","call @2","out 17","jm @2","out 18","cm @2","out 19","jmp @2","out 1a","call @2","out 1b","jpe @2","out 1c","cpe @2","out 1d","jmp @2","out 1e","call @2","out 1f","add a","add b","add c","add d","add e","add h","add l","add m","adc a","adc b","adc c","adc d","adc e","adc h","adc l","adc m","sub a","sub b","sub c","sub d","sub e","sub h","sub l","sub m","sbb a","sbb b","sbb c","sbb d","sbb e","sbb h","sbb l","sbb m","ana a","ana b","ana c","ana d","ana e","ana h","ana l","ana m","xra a","xra b","xra c","xra d","xra e","xra h","xra l","xra m","ora a","ora b","ora c","ora d","ora e","ora h","ora l","ora m","cmp a","cmp b","cmp c","cmp d","cmp e","cmp h","cmp l","cmp m","mov a,a","mov a,b","mov a,c","mov a,d","mov a,e","mov a,h","mov a,l","mov a,m","mov b,a","mov b,b","mov b,c","mov b,d","mov b,e","mov b,h","mov b,l","mov b,m","mov c,a","mov c,b","mov c,c","mov c,d","mov c,e","mov c,h","mov c,l","mov c,m","mov d,a","mov d,b","mov d,c","mov d,d","mov d,e","mov d,h","mov d,l","mov d,m","mov e,a","mov e,b","mov e,c","mov e,d","mov e,e","mov e,h","mov e,l","mov e,m","mov h,a","mov h,b","mov h,c","mov h,d","mov h,e","mov h,h","mov h,l","mov h,m","mov l,a","mov l,b","mov l,c","mov l,d","mov l,e","mov l,h","mov l,l","mov l,m","mov m,a","mov m,b","mov m,c","mov m,d","mov m,e","mov m,h","mov m,l","hlt" -------------------------------------------------------------------------------- /8008MC/__8008_ports.h: -------------------------------------------------------------------------------- 1 | #ifndef INPORT00 2 | #define INPORT00() {} 3 | #endif 4 | #ifndef INPORT01 5 | #define INPORT01() {} 6 | #endif 7 | #ifndef INPORT02 8 | #define INPORT02() {} 9 | #endif 10 | #ifndef INPORT03 11 | #define INPORT03() {} 12 | #endif 13 | #ifndef INPORT04 14 | #define INPORT04() {} 15 | #endif 16 | #ifndef INPORT05 17 | #define INPORT05() {} 18 | #endif 19 | #ifndef INPORT06 20 | #define INPORT06() {} 21 | #endif 22 | #ifndef INPORT07 23 | #define INPORT07() {} 24 | #endif 25 | #ifndef OUTPORT08 26 | #define OUTPORT08() {} 27 | #endif 28 | #ifndef OUTPORT09 29 | #define OUTPORT09() {} 30 | #endif 31 | #ifndef OUTPORT0A 32 | #define OUTPORT0A() {} 33 | #endif 34 | #ifndef OUTPORT0B 35 | #define OUTPORT0B() {} 36 | #endif 37 | #ifndef OUTPORT0C 38 | #define OUTPORT0C() {} 39 | #endif 40 | #ifndef OUTPORT0D 41 | #define OUTPORT0D() {} 42 | #endif 43 | #ifndef OUTPORT0E 44 | #define OUTPORT0E() {} 45 | #endif 46 | #ifndef OUTPORT0F 47 | #define OUTPORT0F() {} 48 | #endif 49 | #ifndef OUTPORT10 50 | #define OUTPORT10() {} 51 | #endif 52 | #ifndef OUTPORT11 53 | #define OUTPORT11() {} 54 | #endif 55 | #ifndef OUTPORT12 56 | #define OUTPORT12() {} 57 | #endif 58 | #ifndef OUTPORT13 59 | #define OUTPORT13() {} 60 | #endif 61 | #ifndef OUTPORT14 62 | #define OUTPORT14() {} 63 | #endif 64 | #ifndef OUTPORT15 65 | #define OUTPORT15() {} 66 | #endif 67 | #ifndef OUTPORT16 68 | #define OUTPORT16() {} 69 | #endif 70 | #ifndef OUTPORT17 71 | #define OUTPORT17() {} 72 | #endif 73 | #ifndef OUTPORT18 74 | #define OUTPORT18() {} 75 | #endif 76 | #ifndef OUTPORT19 77 | #define OUTPORT19() {} 78 | #endif 79 | #ifndef OUTPORT1A 80 | #define OUTPORT1A() {} 81 | #endif 82 | #ifndef OUTPORT1B 83 | #define OUTPORT1B() {} 84 | #endif 85 | #ifndef OUTPORT1C 86 | #define OUTPORT1C() {} 87 | #endif 88 | #ifndef OUTPORT1D 89 | #define OUTPORT1D() {} 90 | #endif 91 | #ifndef OUTPORT1E 92 | #define OUTPORT1E() {} 93 | #endif 94 | #ifndef OUTPORT1F 95 | #define OUTPORT1F() {} 96 | #endif -------------------------------------------------------------------------------- /8008MC/__font7x9_mcmfont.h: -------------------------------------------------------------------------------- 1 | 0,0,0,0,98,148,136,148,98,120,68,120,68,68,120,64,64,128,0,194,36,40,48,32,96,96,96,96,144,128,128,64,96,144,144,96,0,0,48,64,128,240,128,64,48,44,28,32,64,128,128,112,8,32,0,88,164,36,36,36,4,4,4,48,72,132,132,252,132,132,72,48,0,0,0,128,128,128,128,144,96,0,0,128,144,160,192,160,148,136,128,64,32,32,32,32,48,72,132,0,144,144,144,144,232,128,128,128,0,0,0,196,68,72,80,96,64,16,56,64,48,64,128,120,4,24,0,0,0,48,72,132,132,72,48,0,0,0,126,168,40,40,40,40,48,72,132,132,200,176,128,128,128,0,0,0,62,72,132,132,72,48,0,0,0,126,144,16,16,16,16,0,0,0,196,72,72,72,72,48,32,32,112,168,168,168,112,32,32,0,0,0,0,196,40,16,40,70,16,146,84,84,84,56,16,16,16,0,0,0,68,130,146,146,146,108,0,56,68,130,130,130,68,68,198,62,32,32,32,32,32,160,96,32,0,0,8,4,254,4,8,0,0,0,0,32,64,254,64,32,0,0,16,56,84,16,16,16,16,16,16,0,0,16,0,254,0,16,0,0,254,64,32,16,12,16,32,64,254,0,96,146,12,96,146,12,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,16,16,0,0,16,36,36,36,0,0,0,0,0,0,40,40,40,254,40,254,40,40,40,16,126,144,144,124,18,18,252,16,64,162,68,8,16,32,68,138,4,112,136,136,80,32,82,140,140,114,64,64,128,0,0,0,0,0,0,16,32,64,64,64,64,64,32,16,16,8,4,4,4,4,4,8,16,16,146,84,56,254,56,84,146,16,0,16,16,16,254,16,16,16,0,0,0,0,0,0,96,32,32,64,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,32,0,2,4,8,16,32,64,0,0,124,130,134,138,146,162,194,130,124,16,48,16,16,16,16,16,16,124,124,130,2,4,24,32,64,128,254,124,130,2,2,60,2,2,130,124,4,12,20,36,68,254,4,4,4,254,128,128,128,252,2,2,130,124,124,130,128,128,252,130,130,130,124,254,130,4,8,16,32,32,32,32,124,130,130,130,124,130,130,130,124,126,130,130,130,126,2,2,130,124,0,0,64,0,0,0,64,0,0,64,0,0,0,0,96,32,32,64,8,16,32,64,128,64,32,16,8,0,0,0,254,0,254,0,0,0,32,16,8,4,2,4,8,16,32,124,130,130,4,8,16,16,0,16,124,130,130,154,170,188,128,128,124,56,68,130,130,254,130,130,130,130,252,66,66,66,124,66,66,66,252,60,66,128,128,128,128,128,66,60,252,66,66,66,66,66,66,66,252,254,128,128,128,240,128,128,128,254,254,128,128,128,240,128,128,128,128,60,66,128,128,128,142,130,66,60,130,130,130,130,254,130,130,130,130,124,16,16,16,16,16,16,16,124,62,8,8,8,8,8,8,136,112,130,132,136,144,224,144,136,132,130,128,128,128,128,128,128,128,128,254,130,198,170,146,146,130,130,130,130,130,194,162,146,138,134,130,130,130,56,68,130,130,130,130,130,68,56,252,130,130,130,252,128,128,128,128,56,68,130,130,130,130,138,68,58,252,130,130,130,252,144,136,132,130,124,130,128,128,124,2,2,130,124,254,16,16,16,16,16,16,16,16,130,130,130,130,130,130,130,130,124,130,130,130,130,130,130,68,40,16,130,130,130,146,146,146,170,198,130,130,130,68,40,16,40,68,130,130,130,130,68,40,16,16,16,16,16,254,2,4,8,16,32,64,128,254,60,32,32,32,32,32,32,32,60,0,128,64,32,16,8,4,2,0,120,8,8,8,8,8,8,8,120,124,130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,4,4,2,0,0,0,0,0,0,0,0,0,60,68,132,132,140,116,128,128,128,184,196,132,132,196,184,0,0,0,120,132,128,128,132,120,4,4,4,116,140,132,132,140,116,0,0,0,120,132,132,252,128,124,24,36,32,32,248,32,32,32,32,116,140,132,132,140,116,4,4,120,128,128,128,176,200,132,132,132,132,0,16,0,48,16,16,16,16,16,4,4,4,4,4,4,4,132,120,128,128,128,136,144,224,144,136,132,32,32,32,32,32,32,32,32,32,0,0,0,236,146,146,146,146,146,0,0,0,184,196,132,132,132,132,0,0,0,120,132,132,132,132,120,184,196,132,132,196,184,128,128,128,116,140,132,132,140,116,4,4,4,0,0,0,184,196,128,128,128,128,0,0,0,120,132,96,24,132,120,0,32,32,248,32,32,32,36,24,0,0,0,132,132,132,132,132,120,0,0,0,136,136,136,136,80,32,0,0,0,130,146,146,146,146,108,0,0,0,132,72,48,48,72,132,132,132,132,132,140,116,4,132,120,0,0,0,252,8,16,32,64,252,28,32,32,32,64,32,32,32,28,16,16,16,0,0,16,16,16,0,112,8,8,8,4,8,8,8,112,96,146,12,0,0,0,0,0,0,254,254,254,254,254,254,254,254,254 2 | -------------------------------------------------------------------------------- /8008MC/framework/debugger.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: debugger.c 5 | // Purpose: Debugger Code (System Independent) 6 | // Created: 3rd December 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include 14 | #include "gfx.h" 15 | #include "debugger.h" 16 | 17 | static int isInitialised = 0; // Flag to initialise first time 18 | static int addressSettings[] = { 0,0,0,0xFFFF }; // Adjustable values : Code, Data, Other, Break. 19 | static int keyMapping[16]; // Mapping for control keys to key values 20 | static int inRunMode = 0; // Non zero when free Running 21 | static int lastKey,currentKey; // Last and Current key state 22 | static int stepBreakPoint; // Extra breakpoint used for step over. 23 | static Uint32 nextFrame = 0; // Time of next frame. 24 | 25 | // ******************************************************************************************************************************* 26 | // Handle one frame of rendering etc. for the debugger. 27 | // ******************************************************************************************************************************* 28 | 29 | void GFXXRender(SDL_Surface *surface) { 30 | 31 | if (isInitialised == 0) { // Check if first time 32 | isInitialised = 1; // Now initialised 33 | inRunMode = 0; // Now running 34 | addressSettings[0] = DEBUG_HOMEPC(); // Set default locations 35 | addressSettings[1] = DEBUG_RAMSTART; 36 | addressSettings[3] = 0xFFFF; 37 | DBGDefineKey(DBGKEY_RESET,GFXKEY_F1); // Assign default keys 38 | DBGDefineKey(DBGKEY_SHOW,GFXKEY_TAB); 39 | DBGDefineKey(DBGKEY_STEP,GFXKEY_F7); 40 | DBGDefineKey(DBGKEY_STEPOVER,GFXKEY_F8); 41 | DBGDefineKey(DBGKEY_RUN,GFXKEY_F5); 42 | DBGDefineKey(DBGKEY_BREAK,GFXKEY_F6); 43 | DBGDefineKey(DBGKEY_HOME,GFXKEY_F2); 44 | DBGDefineKey(DBGKEY_SETBREAK,GFXKEY_F9); 45 | lastKey = currentKey = -1; 46 | } 47 | 48 | if (inRunMode != 0 || GFXIsKeyPressed(keyMapping[DBGKEY_SHOW])) // Display system screen if Run or Sjhow 49 | DEBUG_VDURENDER(addressSettings); 50 | else // Otherwise show Debugger screen 51 | DEBUG_CPURENDER(addressSettings); 52 | 53 | currentKey = -1; // Identify which key is pressed. 54 | for (int i = 0;i < 128;i++) { 55 | if (!GFXISMODIFIERKEY(i)) { // Don't return SHIFT and CTRL as keypresses. 56 | if (GFXIsKeyPressed(i)) { 57 | currentKey = i; 58 | } 59 | } 60 | } 61 | if (currentKey != lastKey) { // Key changed 62 | lastKey = currentKey; // Update current key. 63 | currentKey = DEBUG_KEYMAP(currentKey,inRunMode != 0); // Pass keypress to called. 64 | if (currentKey >= 0) { // Key depressed ? 65 | currentKey = toupper(currentKey); // Make it capital. 66 | 67 | #define CMDKEY(n) GFXIsKeyPressed(keyMapping[n]) // Support Macro. 68 | 69 | if (CMDKEY(DBGKEY_RESET)) { // Reset processor (F1) 70 | DEBUG_RESET(); 71 | addressSettings[0] = DEBUG_HOMEPC(); 72 | GFXSetFrequency(0); 73 | } 74 | 75 | if (inRunMode == 0) { 76 | GFXSetFrequency(0); // Will drive us mental otherwise. 77 | if (isxdigit(currentKey)) { // Is it a hex digit 0-9 A-F. 78 | int digit = isdigit(currentKey)?currentKey:(currentKey-'A'+10); // Convert to a number. 79 | int setting = 0; // Which value is being changed ? 80 | if (GFXIsKeyPressed(GFXKEY_SHIFT)) setting = 1; 81 | if (GFXIsKeyPressed(GFXKEY_CONTROL)) setting = 2; 82 | addressSettings[setting] = // Shift it using this macro (so we could use Octal, say) 83 | DEBUG_SHIFT(addressSettings[setting],(digit & 0x0F)); 84 | } 85 | 86 | if (CMDKEY(DBGKEY_HOME)) { // Home pointer (F2) 87 | addressSettings[0] = DEBUG_HOMEPC(); 88 | } 89 | if (CMDKEY(DBGKEY_RUN)) { // Run program (F5) 90 | inRunMode = 1; 91 | stepBreakPoint = -1; 92 | } 93 | if (CMDKEY(DBGKEY_STEP)) { // Execute a single instruction (F7) 94 | DEBUG_SINGLESTEP(); 95 | addressSettings[0] = DEBUG_HOMEPC(); 96 | } 97 | if (CMDKEY(DBGKEY_STEPOVER)) { // Step over program calls (F8) 98 | stepBreakPoint = DEBUG_GETOVERBREAK(); // Where if anywhere should we break ? 99 | if (stepBreakPoint == 0) { // No step over, just single step. 100 | DEBUG_SINGLESTEP(); 101 | addressSettings[0] = DEBUG_HOMEPC(); 102 | } else { 103 | inRunMode = 1; // Run until step break or normal break. 104 | } 105 | } 106 | if (CMDKEY(DBGKEY_SETBREAK)) { // Set Breakpoint (F9) 107 | addressSettings[3] = addressSettings[0]; 108 | } 109 | } else { // In Run mode. 110 | if (CMDKEY(DBGKEY_BREAK)) { 111 | inRunMode = 0; 112 | addressSettings[0] = DEBUG_HOMEPC(); 113 | } 114 | } 115 | } 116 | } 117 | if (inRunMode != 0) { // Running a program. 118 | int frameRate = DEBUG_RUN(addressSettings[3],stepBreakPoint); // Run a frame, or try to. 119 | if (frameRate == 0) { // Run code with step breakpoint, maybe. 120 | inRunMode = 0; // Break has occurred. 121 | } else { 122 | while (SDL_GetTicks() < nextFrame) {}; // Wait for frame timer to elapse. 123 | nextFrame = SDL_GetTicks() + 1000 / frameRate; // And calculate the next sync time. 124 | 125 | } 126 | addressSettings[0] = DEBUG_HOMEPC(); 127 | } 128 | } 129 | 130 | // ******************************************************************************************************************************* 131 | // Redefine a key 132 | // ******************************************************************************************************************************* 133 | 134 | void DBGDefineKey(int keyID,int gfxKey) { 135 | keyMapping[keyID] = gfxKey; 136 | } 137 | 138 | // ******************************************************************************************************************************* 139 | // Draw a vertical set of labels (helper) 140 | // ******************************************************************************************************************************* 141 | 142 | void DBGVerticalLabel(int x,int y,const char *labels[],int fgr,int bgr) { 143 | int n = 0; 144 | while (labels[n] != NULL) { 145 | GFXString(GRID(x,y),labels[n],GRIDSIZE,fgr,bgr); 146 | y++;n++; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /8008MC/framework/debugger.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: debugger.h 5 | // Purpose: Debugger Code (System Independent) Header 6 | // Created: 3rd September 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _DEBUGGER_H 13 | #define _DEBUGGER_H 14 | 15 | void DBGVerticalLabel(int x,int y,const char *labels[],int fgr,int bgr); 16 | void DBGDefineKey(int keyID,int gfxKey); 17 | 18 | #include "sys_processor.h" 19 | #include "sys_debug_system.h" 20 | 21 | #define DBGKEY_RESET (0) // Debugger key IDs. 22 | #define DBGKEY_SHOW (1) 23 | #define DBGKEY_STEP (2) 24 | #define DBGKEY_STEPOVER (3) 25 | #define DBGKEY_RUN (4) 26 | #define DBGKEY_BREAK (5) 27 | #define DBGKEY_HOME (6) 28 | #define DBGKEY_SETBREAK (7) 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /8008MC/framework/debugger.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/8008MC/framework/debugger.o -------------------------------------------------------------------------------- /8008MC/framework/font.h: -------------------------------------------------------------------------------- 1 | static unsigned char fontdata[] = { 2 | 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 (space) 3 | 0x00, 0x00, 0x5F, 0x00, 0x00, // 0x21 '!' 4 | 0x00, 0x07, 0x00, 0x07, 0x00, // 0x22 '"' 5 | 0x14, 0x7F, 0x14, 0x7F, 0x14, // 0x23 '#' 6 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, // 0x24 '$' 7 | 0x23, 0x13, 0x08, 0x64, 0x62, // 0x25 '%' 8 | 0x36, 0x49, 0x55, 0x22, 0x50, // 0x26 '&' 9 | 0x00, 0x05, 0x03, 0x00, 0x00, // 0x27 ''' 10 | 0x00, 0x1C, 0x22, 0x41, 0x00, // 0x28 '(' 11 | 0x00, 0x41, 0x22, 0x1C, 0x00, // 0x29 ')' 12 | 0x08, 0x2A, 0x1C, 0x2A, 0x08, // 0x2A '*' 13 | 0x08, 0x08, 0x3E, 0x08, 0x08, // 0x2B '+' 14 | 0x00, 0x50, 0x30, 0x00, 0x00, // 0x2C ',' 15 | 0x08, 0x08, 0x08, 0x08, 0x08, // 0x2D '-' 16 | 0x00, 0x60, 0x60, 0x00, 0x00, // 0x2E '.' 17 | 0x20, 0x10, 0x08, 0x04, 0x02, // 0x2F '/' 18 | 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0x30 '0' 19 | 0x00, 0x42, 0x7F, 0x40, 0x00, // 0x31 '1' 20 | 0x42, 0x61, 0x51, 0x49, 0x46, // 0x32 '2' 21 | 0x21, 0x41, 0x45, 0x4B, 0x31, // 0x33 '3' 22 | 0x18, 0x14, 0x12, 0x7F, 0x10, // 0x34 '4' 23 | 0x27, 0x45, 0x45, 0x45, 0x39, // 0x35 '5' 24 | 0x3C, 0x4A, 0x49, 0x49, 0x30, // 0x36 '6' 25 | 0x01, 0x71, 0x09, 0x05, 0x03, // 0x37 '7' 26 | 0x36, 0x49, 0x49, 0x49, 0x36, // 0x38 '8' 27 | 0x06, 0x49, 0x49, 0x29, 0x1E, // 0x39 '9' 28 | 0x00, 0x36, 0x36, 0x00, 0x00, // 0x3A ':' 29 | 0x00, 0x56, 0x36, 0x00, 0x00, // 0x3B ';' 30 | 0x00, 0x08, 0x14, 0x22, 0x41, // 0x3C '<' 31 | 0x14, 0x14, 0x14, 0x14, 0x14, // 0x3D '=' 32 | 0x41, 0x22, 0x14, 0x08, 0x00, // 0x3E '>' 33 | 0x02, 0x01, 0x51, 0x09, 0x06, // 0x3F '?' 34 | 0x32, 0x49, 0x79, 0x41, 0x3E, // 0x40 '@' 35 | 0x7E, 0x11, 0x11, 0x11, 0x7E, // 0x41 'A' 36 | 0x7F, 0x49, 0x49, 0x49, 0x36, // 0x42 'B' 37 | 0x3E, 0x41, 0x41, 0x41, 0x22, // 0x43 'C' 38 | 0x7F, 0x41, 0x41, 0x22, 0x1C, // 0x44 'D' 39 | 0x7F, 0x49, 0x49, 0x49, 0x41, // 0x45 'E' 40 | 0x7F, 0x09, 0x09, 0x01, 0x01, // 0x46 'F' 41 | 0x3E, 0x41, 0x41, 0x51, 0x32, // 0x47 'G' 42 | 0x7F, 0x08, 0x08, 0x08, 0x7F, // 0x48 'H' 43 | 0x00, 0x41, 0x7F, 0x41, 0x00, // 0x49 'I' 44 | 0x20, 0x40, 0x41, 0x3F, 0x01, // 0x4A 'J' 45 | 0x7F, 0x08, 0x14, 0x22, 0x41, // 0x4B 'K' 46 | 0x7F, 0x40, 0x40, 0x40, 0x40, // 0x4C 'L' 47 | 0x7F, 0x02, 0x04, 0x02, 0x7F, // 0x4D 'M' 48 | 0x7F, 0x04, 0x08, 0x10, 0x7F, // 0x4E 'N' 49 | 0x3E, 0x41, 0x41, 0x41, 0x3E, // 0x4F 'O' 50 | 0x7F, 0x09, 0x09, 0x09, 0x06, // 0x50 'P' 51 | 0x3E, 0x41, 0x51, 0x21, 0x5E, // 0x51 'Q' 52 | 0x7F, 0x09, 0x19, 0x29, 0x46, // 0x52 'R' 53 | 0x46, 0x49, 0x49, 0x49, 0x31, // 0x53 'S' 54 | 0x01, 0x01, 0x7F, 0x01, 0x01, // 0x54 'T' 55 | 0x3F, 0x40, 0x40, 0x40, 0x3F, // 0x55 'U' 56 | 0x1F, 0x20, 0x40, 0x20, 0x1F, // 0x56 'V' 57 | 0x7F, 0x20, 0x18, 0x20, 0x7F, // 0x57 'W' 58 | 0x63, 0x14, 0x08, 0x14, 0x63, // 0x58 'X' 59 | 0x03, 0x04, 0x78, 0x04, 0x03, // 0x59 'Y' 60 | 0x61, 0x51, 0x49, 0x45, 0x43, // 0x5A 'Z' 61 | 0x00, 0x00, 0x7F, 0x41, 0x41, // 0x5B '[' 62 | 0x02, 0x04, 0x08, 0x10, 0x20, // 0x5C '\' 63 | 0x41, 0x41, 0x7F, 0x00, 0x00, // 0x5D ']' 64 | 0x04, 0x02, 0x01, 0x02, 0x04, // 0x5E '^' 65 | 0x40, 0x40, 0x40, 0x40, 0x40, // 0x5F '_' 66 | 0x00, 0x01, 0x02, 0x04, 0x00, // 0x60 '`' 67 | 0x20, 0x54, 0x54, 0x54, 0x78, // 0x61 'a' 68 | 0x7F, 0x48, 0x44, 0x44, 0x38, // 0x62 'b' 69 | 0x38, 0x44, 0x44, 0x44, 0x20, // 0x63 'c' 70 | 0x38, 0x44, 0x44, 0x48, 0x7F, // 0x64 'd' 71 | 0x38, 0x54, 0x54, 0x54, 0x18, // 0x65 'e' 72 | 0x08, 0x7E, 0x09, 0x01, 0x02, // 0x66 'f' 73 | 0x08, 0x14, 0x54, 0x54, 0x3C, // 0x67 'g' 74 | 0x7F, 0x08, 0x04, 0x04, 0x78, // 0x68 'h' 75 | 0x00, 0x44, 0x7D, 0x40, 0x00, // 0x69 'i' 76 | 0x20, 0x40, 0x44, 0x3D, 0x00, // 0x6A 'j' 77 | 0x00, 0x7F, 0x10, 0x28, 0x44, // 0x6B 'k' 78 | 0x00, 0x41, 0x7F, 0x40, 0x00, // 0x6C 'l' 79 | 0x7C, 0x04, 0x18, 0x04, 0x78, // 0x6D 'm' 80 | 0x7C, 0x08, 0x04, 0x04, 0x78, // 0x6E 'n' 81 | 0x38, 0x44, 0x44, 0x44, 0x38, // 0x6F 'o' 82 | 0x7C, 0x14, 0x14, 0x14, 0x08, // 0x70 'p' 83 | 0x08, 0x14, 0x14, 0x18, 0x7C, // 0x71 'q' 84 | 0x7C, 0x08, 0x04, 0x04, 0x08, // 0x72 'r' 85 | 0x48, 0x54, 0x54, 0x54, 0x20, // 0x73 's' 86 | 0x04, 0x3F, 0x44, 0x40, 0x20, // 0x74 't' 87 | 0x3C, 0x40, 0x40, 0x20, 0x7C, // 0x75 'u' 88 | 0x1C, 0x20, 0x40, 0x20, 0x1C, // 0x76 'v' 89 | 0x3C, 0x40, 0x30, 0x40, 0x3C, // 0x77 'w' 90 | 0x44, 0x28, 0x10, 0x28, 0x44, // 0x78 'x' 91 | 0x0C, 0x50, 0x50, 0x50, 0x3C, // 0x79 'y' 92 | 0x44, 0x64, 0x54, 0x4C, 0x44, // 0x7A 'z' 93 | 0x00, 0x08, 0x36, 0x41, 0x00, // 0x7B '{' 94 | 0x00, 0x00, 0x7F, 0x00, 0x00, // 0x7C '|' 95 | 0x00, 0x41, 0x36, 0x08, 0x00, // 0x7D '}' 96 | 0x08, 0x08, 0x2A, 0x1C, 0x08, // 0x7E ->' 97 | 0x08, 0x1C, 0x2A, 0x08, 0x08, // 0x7F <-' 98 | }; 99 | 100 | -------------------------------------------------------------------------------- /8008MC/framework/gfx.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: gfx.h 5 | // Purpose: Support library for SDL (Header) 6 | // Created: 3rd December 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _GFX_H 13 | #define _GFX_H 14 | 15 | #include 16 | #include 17 | 18 | #define GFXKEY_BASE (1) 19 | 20 | #define GFXKEY_UP (GFXKEY_BASE+1) 21 | #define GFXKEY_DOWN (GFXKEY_BASE+2) 22 | #define GFXKEY_LEFT (GFXKEY_BASE+3) 23 | #define GFXKEY_RIGHT (GFXKEY_BASE+4) 24 | #define GFXKEY_LSHIFT (GFXKEY_BASE+5) 25 | #define GFXKEY_CONTROL (GFXKEY_BASE+6) 26 | #define GFXKEY_F1 (GFXKEY_BASE+7) 27 | #define GFXKEY_F2 (GFXKEY_BASE+8) 28 | #define GFXKEY_F3 (GFXKEY_BASE+9) 29 | #define GFXKEY_F4 (GFXKEY_BASE+10) 30 | #define GFXKEY_F5 (GFXKEY_BASE+11) 31 | #define GFXKEY_F6 (GFXKEY_BASE+12) 32 | #define GFXKEY_F7 (GFXKEY_BASE+13) 33 | #define GFXKEY_F8 (GFXKEY_BASE+14) 34 | #define GFXKEY_F9 (GFXKEY_BASE+15) 35 | #define GFXKEY_F10 (GFXKEY_BASE+16) 36 | #define GFXKEY_RETURN (GFXKEY_BASE+17) 37 | #define GFXKEY_BACKSPACE (GFXKEY_BASE+18) 38 | #define GFXKEY_TAB (GFXKEY_BASE+19) 39 | #define GFXKEY_RSHIFT (GFXKEY_BASE+20) 40 | #define GFXKEY_SHIFT (GFXKEY_BASE+21) 41 | #define GFXKEY_F11 (GFXKEY_BASE+22) 42 | #define GFXKEY_F12 (GFXKEY_BASE+23) 43 | 44 | #define GFXISMODIFIERKEY(x) (GFXISCONTROLKEY(x) || GFXISSHIFTKEY(x)) 45 | #define GFXISSHIFTKEY(x) ((x) == GFXKEY_SHIFT || (x) == GFXKEY_RSHIFT || (x) == GFXKEY_LSHIFT) 46 | #define GFXISCONTROLKEY(x) ((x) == GFXKEY_CONTROL) 47 | 48 | #define GRID(x,y) _GFXX(x),_GFXY(y) 49 | #define GRIDSIZE _GFXS() 50 | 51 | int _GFXX(int x); 52 | int _GFXY(int y); 53 | int _GFXS(void); 54 | 55 | void GFXOpenWindow(const char *title,int width,int height,int colour); 56 | void GFXStart(void); 57 | void GFXCloseWindow(void); 58 | 59 | void GFXRectangle(SDL_Rect *rc,int colour); 60 | void GFXCharacter(int xc,int yc,int character,int size,int colour,int back); 61 | void GFXString(int xc,int yc,const char *text,int size,int colour,int back); 62 | void GFXNumber(int xc,int yc,int number,int base,int width,int size,int colour,int back); 63 | int GFXIsKeyPressed(int character); 64 | int GFXToASCII(int ch,int applyModifiers); 65 | int GFXTimer(void); 66 | void GFXSetCharacterSize(int xSize,int ySize); 67 | void GFXDefineCharacter(int nChar,int b1,int b2,int b3,int b4,int b5); 68 | 69 | void GFXXRender(SDL_Surface *surface); 70 | void GFXSetFrequency(int freq); 71 | 72 | class Beeper 73 | { 74 | private: 75 | double freq; 76 | double v; 77 | public: 78 | Beeper(); 79 | ~Beeper(); 80 | void setFrequency(double freq); 81 | void generateSamples(Sint16 *stream, int length); 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /8008MC/framework/gfx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/8008MC/framework/gfx.o -------------------------------------------------------------------------------- /8008MC/framework/main.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: main.c 5 | // Purpose: Main program 6 | // Created: 1st September 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include "gfx.h" 14 | #include "sys_processor.h" 15 | #include "sys_debug_system.h" 16 | #include "debugger.h" 17 | 18 | int main(int argc,char *argv[]) { 19 | DEBUG_RESET(); 20 | DEBUG_ARGUMENTS(argc,argv); 21 | GFXOpenWindow(WIN_TITLE,WIN_WIDTH,WIN_HEIGHT,WIN_BACKCOLOUR); 22 | GFXStart(); 23 | GFXCloseWindow(); 24 | return(0); 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /8008MC/framework/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/8008MC/framework/main.o -------------------------------------------------------------------------------- /8008MC/hardware.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: hardware.c 5 | // Purpose: Hardware handling routines 6 | // Created: 3rd December 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include "gfx.h" 14 | 15 | #include "sys_processor.h" 16 | 17 | #define DIRTY_GROUPING (4) // Char grouping dirty flags 18 | 19 | static BYTE8 videoRAM[512]; // 32 x 8 TVT Memory 20 | static BYTE8 isInitialised = 0; // Non zero when initialised 21 | static BYTE8 pendingKey = 0; // Key ready ? 22 | static BYTE8 x; // X Position. 23 | 24 | // The dirty flag being in character groups of 4 is because the STM7920, the original LCD target, 25 | // takes 16 bit horizontal words, which with a 3x5 font has 4 characters in it. If using a OLED 26 | // 128x64 this may incur a small time penalty. 27 | 28 | // ******************************************************************************************************************************* 29 | // Reset all hardware 30 | // ******************************************************************************************************************************* 31 | 32 | void HWIReset(void) { 33 | if (isInitialised == 0) { 34 | isInitialised = 1; 35 | for (WORD16 n = 0;n < 512;n++) videoRAM[n] = ' '; // Clear VRAM (wouldn't happen) 36 | videoRAM[15*32] = 127; 37 | pendingKey = 0; // Clear keyboard buffer 38 | x = 0; // Home cursor to bottom right. 39 | char *msg = "*** 8008 Simple Machine ***\r\r16384 bytes free\r\r"; 40 | while (*msg != '\0') HWIWriteVideoPort(*msg++); 41 | } 42 | } 43 | 44 | // ******************************************************************************************************************************* 45 | // Handle on end of frame. 46 | // ******************************************************************************************************************************* 47 | 48 | void HWIEndFrame(void) { 49 | } 50 | 51 | // ******************************************************************************************************************************* 52 | // Read video memory 53 | // ******************************************************************************************************************************* 54 | 55 | BYTE8 HWIReadVideoMemory(WORD16 offset) { 56 | return videoRAM[offset]; 57 | } 58 | 59 | // ******************************************************************************************************************************* 60 | // Debugger key intercept handler 61 | // ******************************************************************************************************************************* 62 | 63 | int HWIProcessKey(int key,int isRunTime) { 64 | if (key != 0 && isRunTime != 0) { // Running and key press 65 | BYTE8 newKey = GFXToASCII(key,1); // Convert to ASCII 66 | if (newKey != 0) pendingKey = newKey; // Put pending key in buffer 67 | } 68 | return key; 69 | } 70 | 71 | // ******************************************************************************************************************************* 72 | // Read keyboard 73 | // ******************************************************************************************************************************* 74 | 75 | BYTE8 HWIReadKeyboard(void) { 76 | BYTE8 rv = 0; 77 | if (pendingKey != 0) { // Key waiting. 78 | rv = pendingKey; // Return it. 79 | pendingKey = 0; // Clear buffer 80 | } 81 | return rv; 82 | } 83 | 84 | // Implemented so the strobe vanishes immediately on reading. While not technically correct, the 85 | // coder cannot know at IN 0 where it is in the strobe, it *might* finish in the next cycle. Coders 86 | // could read the keyboard and then re-read it to get the key again, but shouldn't ! 87 | 88 | // ******************************************************************************************************************************* 89 | // Write byte to video memory port 90 | // ******************************************************************************************************************************* 91 | 92 | void HWIWriteVideoPort(BYTE8 n) { 93 | n = n & 0x7F; 94 | if (x > 0 && n == 8) { 95 | videoRAM[15*32+x] = ' '; 96 | x--; 97 | videoRAM[15*32+x] = ' '; 98 | } 99 | if (n == 13) { 100 | while (x < 32) { 101 | videoRAM[15*32+x] = ' '; 102 | x++; 103 | } 104 | } 105 | if (n >= ' ') { 106 | videoRAM[15*32+x] = n; 107 | x++; 108 | } 109 | if (x == 32) { 110 | x = 0; 111 | for (WORD16 p = 0;p < 15*32;p++) videoRAM[p] = videoRAM[p+32]; 112 | for (WORD16 p = 0;p < 32;p++) videoRAM[p+15*32] = ' '; 113 | } 114 | videoRAM[15*32+x] = 127; 115 | } 116 | 117 | BYTE8 HWIGetXCursor(void) { 118 | return x; 119 | } -------------------------------------------------------------------------------- /8008MC/nbproject/Makefile-Debug.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a -pre and a -post target defined where you can add customized code. 6 | # 7 | # This makefile implements configuration specific macros and targets. 8 | 9 | 10 | # Environment 11 | MKDIR=mkdir 12 | CP=cp 13 | GREP=grep 14 | NM=nm 15 | CCADMIN=CCadmin 16 | RANLIB=ranlib 17 | CC=gcc 18 | CCC=g++ 19 | CXX=g++ 20 | FC=gfortran 21 | AS=as 22 | 23 | # Macros 24 | CND_PLATFORM=GNU-Linux 25 | CND_DLIB_EXT=so 26 | CND_CONF=Debug 27 | CND_DISTDIR=dist 28 | CND_BUILDDIR=build 29 | 30 | # Include project Makefile 31 | include Makefile 32 | 33 | # Object Directory 34 | OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} 35 | 36 | # Object Files 37 | OBJECTFILES= \ 38 | ${OBJECTDIR}/framework/debugger.o \ 39 | ${OBJECTDIR}/framework/gfx.o \ 40 | ${OBJECTDIR}/framework/main.o \ 41 | ${OBJECTDIR}/hardware.o \ 42 | ${OBJECTDIR}/sys_debug_8008.o \ 43 | ${OBJECTDIR}/sys_processor.o 44 | 45 | 46 | # C Compiler Flags 47 | CFLAGS= 48 | 49 | # CC Compiler Flags 50 | CCFLAGS= 51 | CXXFLAGS= 52 | 53 | # Fortran Compiler Flags 54 | FFLAGS= 55 | 56 | # Assembler Flags 57 | ASFLAGS= 58 | 59 | # Link Libraries and Options 60 | LDLIBSOPTIONS=-lSDL2 61 | 62 | # Build Targets 63 | .build-conf: ${BUILD_SUBPROJECTS} 64 | "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc 65 | 66 | ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc: ${OBJECTFILES} 67 | ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} 68 | ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc ${OBJECTFILES} ${LDLIBSOPTIONS} 69 | 70 | ${OBJECTDIR}/framework/debugger.o: framework/debugger.cpp 71 | ${MKDIR} -p ${OBJECTDIR}/framework 72 | ${RM} "$@.d" 73 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/debugger.o framework/debugger.cpp 74 | 75 | ${OBJECTDIR}/framework/gfx.o: framework/gfx.cpp 76 | ${MKDIR} -p ${OBJECTDIR}/framework 77 | ${RM} "$@.d" 78 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/gfx.o framework/gfx.cpp 79 | 80 | ${OBJECTDIR}/framework/main.o: framework/main.cpp 81 | ${MKDIR} -p ${OBJECTDIR}/framework 82 | ${RM} "$@.d" 83 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/main.o framework/main.cpp 84 | 85 | ${OBJECTDIR}/hardware.o: hardware.cpp 86 | ${MKDIR} -p ${OBJECTDIR} 87 | ${RM} "$@.d" 88 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/hardware.o hardware.cpp 89 | 90 | ${OBJECTDIR}/sys_debug_8008.o: sys_debug_8008.cpp 91 | ${MKDIR} -p ${OBJECTDIR} 92 | ${RM} "$@.d" 93 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_debug_8008.o sys_debug_8008.cpp 94 | 95 | ${OBJECTDIR}/sys_processor.o: sys_processor.cpp 96 | ${MKDIR} -p ${OBJECTDIR} 97 | ${RM} "$@.d" 98 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_processor.o sys_processor.cpp 99 | 100 | # Subprojects 101 | .build-subprojects: 102 | 103 | # Clean Targets 104 | .clean-conf: ${CLEAN_SUBPROJECTS} 105 | ${RM} -r ${CND_BUILDDIR}/${CND_CONF} 106 | 107 | # Subprojects 108 | .clean-subprojects: 109 | 110 | # Enable dependency checking 111 | .dep.inc: .depcheck-impl 112 | 113 | include .dep.inc 114 | -------------------------------------------------------------------------------- /8008MC/nbproject/Makefile-Release.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a -pre and a -post target defined where you can add customized code. 6 | # 7 | # This makefile implements configuration specific macros and targets. 8 | 9 | 10 | # Environment 11 | MKDIR=mkdir 12 | CP=cp 13 | GREP=grep 14 | NM=nm 15 | CCADMIN=CCadmin 16 | RANLIB=ranlib 17 | CC=gcc 18 | CCC=g++ 19 | CXX=g++ 20 | FC=gfortran 21 | AS=as 22 | 23 | # Macros 24 | CND_PLATFORM=GNU-Linux 25 | CND_DLIB_EXT=so 26 | CND_CONF=Release 27 | CND_DISTDIR=dist 28 | CND_BUILDDIR=build 29 | 30 | # Include project Makefile 31 | include Makefile 32 | 33 | # Object Directory 34 | OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} 35 | 36 | # Object Files 37 | OBJECTFILES= \ 38 | ${OBJECTDIR}/framework/debugger.o \ 39 | ${OBJECTDIR}/framework/gfx.o \ 40 | ${OBJECTDIR}/framework/main.o \ 41 | ${OBJECTDIR}/hardware.o \ 42 | ${OBJECTDIR}/sys_debug_8008.o \ 43 | ${OBJECTDIR}/sys_processor.o 44 | 45 | 46 | # C Compiler Flags 47 | CFLAGS= 48 | 49 | # CC Compiler Flags 50 | CCFLAGS= 51 | CXXFLAGS= 52 | 53 | # Fortran Compiler Flags 54 | FFLAGS= 55 | 56 | # Assembler Flags 57 | ASFLAGS= 58 | 59 | # Link Libraries and Options 60 | LDLIBSOPTIONS=-lSDL2 61 | 62 | # Build Targets 63 | .build-conf: ${BUILD_SUBPROJECTS} 64 | "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc 65 | 66 | ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc: ${OBJECTFILES} 67 | ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} 68 | ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc ${OBJECTFILES} ${LDLIBSOPTIONS} 69 | 70 | ${OBJECTDIR}/framework/debugger.o: framework/debugger.cpp 71 | ${MKDIR} -p ${OBJECTDIR}/framework 72 | ${RM} "$@.d" 73 | $(COMPILE.cc) -O2 -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/debugger.o framework/debugger.cpp 74 | 75 | ${OBJECTDIR}/framework/gfx.o: framework/gfx.cpp 76 | ${MKDIR} -p ${OBJECTDIR}/framework 77 | ${RM} "$@.d" 78 | $(COMPILE.cc) -O2 -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/gfx.o framework/gfx.cpp 79 | 80 | ${OBJECTDIR}/framework/main.o: framework/main.cpp 81 | ${MKDIR} -p ${OBJECTDIR}/framework 82 | ${RM} "$@.d" 83 | $(COMPILE.cc) -O2 -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/main.o framework/main.cpp 84 | 85 | ${OBJECTDIR}/hardware.o: hardware.cpp 86 | ${MKDIR} -p ${OBJECTDIR} 87 | ${RM} "$@.d" 88 | $(COMPILE.cc) -O2 -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/hardware.o hardware.cpp 89 | 90 | ${OBJECTDIR}/sys_debug_8008.o: sys_debug_8008.cpp 91 | ${MKDIR} -p ${OBJECTDIR} 92 | ${RM} "$@.d" 93 | $(COMPILE.cc) -O2 -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_debug_8008.o sys_debug_8008.cpp 94 | 95 | ${OBJECTDIR}/sys_processor.o: sys_processor.cpp 96 | ${MKDIR} -p ${OBJECTDIR} 97 | ${RM} "$@.d" 98 | $(COMPILE.cc) -O2 -I/usr/include/SDL2 -I. -Iframework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_processor.o sys_processor.cpp 99 | 100 | # Subprojects 101 | .build-subprojects: 102 | 103 | # Clean Targets 104 | .clean-conf: ${CLEAN_SUBPROJECTS} 105 | ${RM} -r ${CND_BUILDDIR}/${CND_CONF} 106 | 107 | # Subprojects 108 | .clean-subprojects: 109 | 110 | # Enable dependency checking 111 | .dep.inc: .depcheck-impl 112 | 113 | include .dep.inc 114 | -------------------------------------------------------------------------------- /8008MC/nbproject/Makefile-impl.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a pre- and a post- target defined where you can add customization code. 6 | # 7 | # This makefile implements macros and targets common to all configurations. 8 | # 9 | # NOCDDL 10 | 11 | 12 | # Building and Cleaning subprojects are done by default, but can be controlled with the SUB 13 | # macro. If SUB=no, subprojects will not be built or cleaned. The following macro 14 | # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf 15 | # and .clean-reqprojects-conf unless SUB has the value 'no' 16 | SUB_no=NO 17 | SUBPROJECTS=${SUB_${SUB}} 18 | BUILD_SUBPROJECTS_=.build-subprojects 19 | BUILD_SUBPROJECTS_NO= 20 | BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} 21 | CLEAN_SUBPROJECTS_=.clean-subprojects 22 | CLEAN_SUBPROJECTS_NO= 23 | CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} 24 | 25 | 26 | # Project Name 27 | PROJECTNAME=8008MC 28 | 29 | # Active Configuration 30 | DEFAULTCONF=Debug 31 | CONF=${DEFAULTCONF} 32 | 33 | # All Configurations 34 | ALLCONFS=Debug Release 35 | 36 | 37 | # build 38 | .build-impl: .build-pre .validate-impl .depcheck-impl 39 | @#echo "=> Running $@... Configuration=$(CONF)" 40 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf 41 | 42 | 43 | # clean 44 | .clean-impl: .clean-pre .validate-impl .depcheck-impl 45 | @#echo "=> Running $@... Configuration=$(CONF)" 46 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf 47 | 48 | 49 | # clobber 50 | .clobber-impl: .clobber-pre .depcheck-impl 51 | @#echo "=> Running $@..." 52 | for CONF in ${ALLCONFS}; \ 53 | do \ 54 | "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ 55 | done 56 | 57 | # all 58 | .all-impl: .all-pre .depcheck-impl 59 | @#echo "=> Running $@..." 60 | for CONF in ${ALLCONFS}; \ 61 | do \ 62 | "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ 63 | done 64 | 65 | # build tests 66 | .build-tests-impl: .build-impl .build-tests-pre 67 | @#echo "=> Running $@... Configuration=$(CONF)" 68 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf 69 | 70 | # run tests 71 | .test-impl: .build-tests-impl .test-pre 72 | @#echo "=> Running $@... Configuration=$(CONF)" 73 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf 74 | 75 | # dependency checking support 76 | .depcheck-impl: 77 | @echo "# This code depends on make tool being used" >.dep.inc 78 | @if [ -n "${MAKE_VERSION}" ]; then \ 79 | echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \ 80 | echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ 81 | echo "include \$${DEPFILES}" >>.dep.inc; \ 82 | echo "endif" >>.dep.inc; \ 83 | else \ 84 | echo ".KEEP_STATE:" >>.dep.inc; \ 85 | echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ 86 | fi 87 | 88 | # configuration validation 89 | .validate-impl: 90 | @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ 91 | then \ 92 | echo ""; \ 93 | echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ 94 | echo "See 'make help' for details."; \ 95 | echo "Current directory: " `pwd`; \ 96 | echo ""; \ 97 | fi 98 | @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ 99 | then \ 100 | exit 1; \ 101 | fi 102 | 103 | 104 | # help 105 | .help-impl: .help-pre 106 | @echo "This makefile supports the following configurations:" 107 | @echo " ${ALLCONFS}" 108 | @echo "" 109 | @echo "and the following targets:" 110 | @echo " build (default target)" 111 | @echo " clean" 112 | @echo " clobber" 113 | @echo " all" 114 | @echo " help" 115 | @echo "" 116 | @echo "Makefile Usage:" 117 | @echo " make [CONF=] [SUB=no] build" 118 | @echo " make [CONF=] [SUB=no] clean" 119 | @echo " make [SUB=no] clobber" 120 | @echo " make [SUB=no] all" 121 | @echo " make help" 122 | @echo "" 123 | @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," 124 | @echo " also build subprojects." 125 | @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," 126 | @echo " also clean subprojects." 127 | @echo "Target 'clobber' will remove all built files from all configurations and," 128 | @echo " unless 'SUB=no', also from subprojects." 129 | @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," 130 | @echo " also build subprojects." 131 | @echo "Target 'help' prints this message." 132 | @echo "" 133 | 134 | -------------------------------------------------------------------------------- /8008MC/nbproject/Makefile-variables.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated - do not edit! 3 | # 4 | # NOCDDL 5 | # 6 | CND_BASEDIR=`pwd` 7 | CND_BUILDDIR=build 8 | CND_DISTDIR=dist 9 | # Debug configuration 10 | CND_PLATFORM_Debug=GNU-Linux 11 | CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux 12 | CND_ARTIFACT_NAME_Debug=8008mc 13 | CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/8008mc 14 | CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package 15 | CND_PACKAGE_NAME_Debug=8008mc.tar 16 | CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/8008mc.tar 17 | # Release configuration 18 | CND_PLATFORM_Release=GNU-Linux 19 | CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux 20 | CND_ARTIFACT_NAME_Release=8008mc 21 | CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/8008mc 22 | CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package 23 | CND_PACKAGE_NAME_Release=8008mc.tar 24 | CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/8008mc.tar 25 | # 26 | # include compiler specific variables 27 | # 28 | # dmake command 29 | ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ 30 | (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) 31 | # 32 | # gmake command 33 | .PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) 34 | # 35 | include nbproject/private/Makefile-variables.mk 36 | -------------------------------------------------------------------------------- /8008MC/nbproject/Package-Debug.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # 4 | # Generated - do not edit! 5 | # 6 | 7 | # Macros 8 | TOP=`pwd` 9 | CND_PLATFORM=GNU-Linux 10 | CND_CONF=Debug 11 | CND_DISTDIR=dist 12 | CND_BUILDDIR=build 13 | CND_DLIB_EXT=so 14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging 15 | TMPDIRNAME=tmp-packaging 16 | OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc 17 | OUTPUT_BASENAME=8008mc 18 | PACKAGE_TOP_DIR=8008mc/ 19 | 20 | # Functions 21 | function checkReturnCode 22 | { 23 | rc=$? 24 | if [ $rc != 0 ] 25 | then 26 | exit $rc 27 | fi 28 | } 29 | function makeDirectory 30 | # $1 directory path 31 | # $2 permission (optional) 32 | { 33 | mkdir -p "$1" 34 | checkReturnCode 35 | if [ "$2" != "" ] 36 | then 37 | chmod $2 "$1" 38 | checkReturnCode 39 | fi 40 | } 41 | function copyFileToTmpDir 42 | # $1 from-file path 43 | # $2 to-file path 44 | # $3 permission 45 | { 46 | cp "$1" "$2" 47 | checkReturnCode 48 | if [ "$3" != "" ] 49 | then 50 | chmod $3 "$2" 51 | checkReturnCode 52 | fi 53 | } 54 | 55 | # Setup 56 | cd "${TOP}" 57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package 58 | rm -rf ${NBTMPDIR} 59 | mkdir -p ${NBTMPDIR} 60 | 61 | # Copy files and create directories and links 62 | cd "${TOP}" 63 | makeDirectory "${NBTMPDIR}/8008mc/bin" 64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 65 | 66 | 67 | # Generate tar file 68 | cd "${TOP}" 69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/8008mc.tar 70 | cd ${NBTMPDIR} 71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/8008mc.tar * 72 | checkReturnCode 73 | 74 | # Cleanup 75 | cd "${TOP}" 76 | rm -rf ${NBTMPDIR} 77 | -------------------------------------------------------------------------------- /8008MC/nbproject/Package-Release.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # 4 | # Generated - do not edit! 5 | # 6 | 7 | # Macros 8 | TOP=`pwd` 9 | CND_PLATFORM=GNU-Linux 10 | CND_CONF=Release 11 | CND_DISTDIR=dist 12 | CND_BUILDDIR=build 13 | CND_DLIB_EXT=so 14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging 15 | TMPDIRNAME=tmp-packaging 16 | OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/8008mc 17 | OUTPUT_BASENAME=8008mc 18 | PACKAGE_TOP_DIR=8008mc/ 19 | 20 | # Functions 21 | function checkReturnCode 22 | { 23 | rc=$? 24 | if [ $rc != 0 ] 25 | then 26 | exit $rc 27 | fi 28 | } 29 | function makeDirectory 30 | # $1 directory path 31 | # $2 permission (optional) 32 | { 33 | mkdir -p "$1" 34 | checkReturnCode 35 | if [ "$2" != "" ] 36 | then 37 | chmod $2 "$1" 38 | checkReturnCode 39 | fi 40 | } 41 | function copyFileToTmpDir 42 | # $1 from-file path 43 | # $2 to-file path 44 | # $3 permission 45 | { 46 | cp "$1" "$2" 47 | checkReturnCode 48 | if [ "$3" != "" ] 49 | then 50 | chmod $3 "$2" 51 | checkReturnCode 52 | fi 53 | } 54 | 55 | # Setup 56 | cd "${TOP}" 57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package 58 | rm -rf ${NBTMPDIR} 59 | mkdir -p ${NBTMPDIR} 60 | 61 | # Copy files and create directories and links 62 | cd "${TOP}" 63 | makeDirectory "${NBTMPDIR}/8008mc/bin" 64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 65 | 66 | 67 | # Generate tar file 68 | cd "${TOP}" 69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/8008mc.tar 70 | cd ${NBTMPDIR} 71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/8008mc.tar * 72 | checkReturnCode 73 | 74 | # Cleanup 75 | cd "${TOP}" 76 | rm -rf ${NBTMPDIR} 77 | -------------------------------------------------------------------------------- /8008MC/nbproject/configurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | __8008_mnemonics.h 9 | __8008_opcodes.h 10 | __8008_ports.h 11 | 12 | 13 | framework/debugger.h 14 | framework/font.h 15 | framework/gfx.h 16 | 17 | __font7x9_mcmfont.h 18 | sys_debug_system.h 19 | sys_processor.h 20 | 21 | 24 | 25 | 28 | 29 | framework/debugger.cpp 30 | framework/gfx.cpp 31 | framework/main.cpp 32 | 33 | hardware.cpp 34 | sys_debug_8008.cpp 35 | sys_processor.cpp 36 | 37 | 41 | 42 | 46 | Makefile 47 | 48 | 49 | Makefile 50 | 51 | 52 | 53 | default 54 | true 55 | false 56 | 57 | 58 | 59 | 60 | /usr/include/SDL2 61 | . 62 | framework 63 | 64 | 65 | INCLUDE_DEBUGGING_SUPPORT 66 | 67 | 68 | 69 | 70 | SDL2 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | default 108 | true 109 | false 110 | 111 | 112 | 113 | 5 114 | 115 | 116 | 5 117 | 118 | /usr/include/SDL2 119 | . 120 | framework 121 | 122 | 123 | 124 | 5 125 | 126 | 127 | 5 128 | 129 | 130 | 131 | SDL2 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /8008MC/nbproject/private/Makefile-variables.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated - do not edit! 3 | # 4 | # NOCDDL 5 | # 6 | # Debug configuration 7 | # Release configuration 8 | -------------------------------------------------------------------------------- /8008MC/nbproject/private/c_standard_headers_indexer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | */ 40 | 41 | // List of standard headers was taken in http://en.cppreference.com/w/c/header 42 | 43 | #include // Conditionally compiled macro that compares its argument to zero 44 | #include // Functions to determine the type contained in character data 45 | #include // Macros reporting error conditions 46 | #include // Limits of float types 47 | #include // Sizes of basic types 48 | #include // Localization utilities 49 | #include // Common mathematics functions 50 | #include // Nonlocal jumps 51 | #include // Signal handling 52 | #include // Variable arguments 53 | #include // Common macro definitions 54 | #include // Input/output 55 | #include // String handling 56 | #include // General utilities: memory management, program utilities, string conversions, random numbers 57 | #include // Time/date utilities 58 | #include // (since C95) Alternative operator spellings 59 | #include // (since C95) Extended multibyte and wide character utilities 60 | #include // (since C95) Wide character classification and mapping utilities 61 | #ifdef _STDC_C99 62 | #include // (since C99) Complex number arithmetic 63 | #include // (since C99) Floating-point environment 64 | #include // (since C99) Format conversion of integer types 65 | #include // (since C99) Boolean type 66 | #include // (since C99) Fixed-width integer types 67 | #include // (since C99) Type-generic math (macros wrapping math.h and complex.h) 68 | #endif 69 | #ifdef _STDC_C11 70 | #include // (since C11) alignas and alignof convenience macros 71 | #include // (since C11) Atomic types 72 | #include // (since C11) noreturn convenience macros 73 | #include // (since C11) Thread library 74 | #include // (since C11) UTF-16 and UTF-32 character utilities 75 | #endif 76 | -------------------------------------------------------------------------------- /8008MC/nbproject/private/configurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Makefile 4 | 5 | 6 | 7 | localhost 8 | 2 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | gdb 26 | 27 | 28 | 29 | "${OUTPUT_PATH}" 30 | "${OUTPUT_PATH}" test.bin 31 | 32 | "${OUTPUT_PATH}" test.bin 33 | 34 | true 35 | 0 36 | 0 37 | 38 | 39 | 40 | 41 | 42 | 43 | localhost 44 | 2 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | gdb 60 | 61 | 62 | 63 | "${OUTPUT_PATH}" 64 | "${OUTPUT_PATH}" test.bin 65 | 66 | "${OUTPUT_PATH}" test.bin 67 | 68 | true 69 | 0 70 | 0 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /8008MC/nbproject/private/launcher.properties: -------------------------------------------------------------------------------- 1 | # Launchers File syntax: 2 | # 3 | # [Must-have property line] 4 | # launcher1.runCommand= 5 | # [Optional extra properties] 6 | # launcher1.displayName= 7 | # launcher1.hide= 8 | # launcher1.buildCommand= 9 | # launcher1.runDir= 10 | # launcher1.runInOwnTab= 11 | # launcher1.symbolFiles= 12 | # launcher1.env.= 13 | # (If this value is quoted with ` it is handled as a native command which execution result will become the value) 14 | # [Common launcher properties] 15 | # common.runDir= 16 | # (This value is overwritten by a launcher specific runDir value if the latter exists) 17 | # common.env.= 18 | # (Environment variables from common launcher are merged with launcher specific variables) 19 | # common.symbolFiles= 20 | # (This value is overwritten by a launcher specific symbolFiles value if the latter exists) 21 | # 22 | # In runDir, symbolFiles and env fields you can use these macroses: 23 | # ${PROJECT_DIR} - project directory absolute path 24 | # ${OUTPUT_PATH} - linker output path (relative to project directory path) 25 | # ${OUTPUT_BASENAME}- linker output filename 26 | # ${TESTDIR} - test files directory (relative to project directory path) 27 | # ${OBJECTDIR} - object files directory (relative to project directory path) 28 | # ${CND_DISTDIR} - distribution directory (relative to project directory path) 29 | # ${CND_BUILDDIR} - build directory (relative to project directory path) 30 | # ${CND_PLATFORM} - platform name 31 | # ${CND_CONF} - configuration name 32 | # ${CND_DLIB_EXT} - dynamic library extension 33 | # 34 | # All the project launchers must be listed in the file! 35 | # 36 | # launcher1.runCommand=... 37 | # launcher2.runCommand=... 38 | # ... 39 | # common.runDir=... 40 | # common.env.KEY=VALUE 41 | 42 | # launcher1.runCommand= -------------------------------------------------------------------------------- /8008MC/nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 0 6 | 7 | 8 | 9 | 10 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/sys_debug_system.h 11 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/sys_processor.h 12 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/sys_debug_8008.cpp 13 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/framework/debugger.cpp 14 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/framework/gfx.h 15 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/__8008_opcodes.h 16 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/sys_processor.cpp 17 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/framework/main.cpp 18 | file:/home/paulr/Projects/1k-coding-challenge/8008MC/hardware.cpp 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8008MC/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.cnd.makeproject 4 | 5 | 6 | 8008MC 7 | 8 | cpp 9 | h 10 | UTF-8 11 | 12 | 13 | 14 | 15 | Debug 16 | 1 17 | 18 | 19 | Release 20 | 1 21 | 22 | 23 | 24 | false 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /8008MC/sys_debug_8008.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: sys_debug_8008.cpp 5 | // Purpose: Debugger Code (System Dependent) 6 | // Created: 23rd October 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include 14 | #include 15 | #include "gfx.h" 16 | #include "sys_processor.h" 17 | #include "sys_debug_system.h" 18 | #include "debugger.h" 19 | 20 | static const char *_mnemonics[] = { 21 | #include "__8008_mnemonics.h" // 8008 new style mnemonics 22 | }; 23 | 24 | static const BYTE8 _mcmFont[] = { // MCM6571 Font. 25 | #include "__font7x9_mcmfont.h" 26 | }; 27 | 28 | #define DBGC_ADDRESS (0x0F0) // Colour scheme. 29 | #define DBGC_DATA (0x0FF) // (Background is in main.c) 30 | #define DBGC_HIGHLIGHT (0xFF0) 31 | 32 | // ******************************************************************************************************************************* 33 | // Reset the 8008 34 | // ******************************************************************************************************************************* 35 | 36 | void DBGXReset(void) { 37 | CPUReset(); 38 | } 39 | 40 | // ******************************************************************************************************************************* 41 | // This renders the debug screen 42 | // ******************************************************************************************************************************* 43 | 44 | void DBGXRender(int *address,int showDisplay) { 45 | int n; 46 | char buffer[32]; 47 | GFXSetCharacterSize(32,27); 48 | 49 | CPUSTATUS *s = CPUGetStatus(); // Get the CPU Status 50 | 51 | const char *labels[] = { "A","B","C","D","E","H","L","M","C","Z","S","P","H","HL","BP","CY",NULL }; 52 | n = 0; 53 | while (labels[n] != NULL) { 54 | GFXString(GRID(15,n),labels[n],GRIDSIZE,DBGC_ADDRESS,-1); 55 | n++; 56 | } 57 | const char *labels2[] = { "PC","ST",NULL }; 58 | n = 0; 59 | while (labels2[n] != NULL) { 60 | GFXString(GRID(25,n),labels2[n],GRIDSIZE,DBGC_ADDRESS,-1); 61 | n++; 62 | } 63 | 64 | n = address[1]; // Dump memory. 65 | for (int row = 19;row < 26;row++) { 66 | GFXNumber(GRID(1,row),n & 0x3FFF,16,4,GRIDSIZE,DBGC_ADDRESS,-1); // Head of line 67 | GFXCharacter(GRID(6,row),':',GRIDSIZE,DBGC_HIGHLIGHT,-1); 68 | for (int col = 0;col < 8;col++) { // Data on line 69 | GFXNumber(GRID(8+col*3,row),CPURead(n & 0x3FFF),16,2,GRIDSIZE,DBGC_DATA,-1); 70 | n++; 71 | } 72 | } 73 | // Output text labels. // Macros to simplify dump drawing. 74 | #define DD(value,width) GFXNumber(GRID(18,n++),value,16,width,GRIDSIZE,DBGC_DATA,-1) 75 | #define DDC(value) GFXNumber(GRID(18,n++),value,16,1,GRIDSIZE,DBGC_DATA,-1) 76 | 77 | n = 0; // Draw the registers 78 | DD(s->a,2);DD(s->b,2);DD(s->c,2);DD(s->d,2);DD(s->e,2);DD(s->h,2);DD(s->l,2);DD(s->m,2); 79 | DDC(s->cFlag);DDC(s->zFlag);DDC(s->sFlag);DDC(s->pFlag);DDC(s->hFlag); // Draw the flags 80 | DD(s->hl,4);DD(address[3],4);DD(s->cycles,4); // The rest. 81 | 82 | n = 0; // PCTR 83 | GFXNumber(GRID(28,n),s->pc,16,4,GRIDSIZE,DBGC_DATA,-1); 84 | n++; 85 | GFXString(GRID(28,n++),"----",GRIDSIZE,DBGC_DATA,-1); // Translated stack. 86 | for (int i = 0;i < s->stackDepth;i++) 87 | GFXNumber(GRID(28,n++),s->stack[i],16,4,GRIDSIZE,DBGC_DATA,-1); 88 | 89 | //if (showCPU == 0) return; 90 | 91 | n = address[0]; // Dump code. 92 | for (int row = 0;row < 16;row++) { 93 | int isPC = (n & 0x3FFF) == (s->pc); // Check for breakpoint and being at PC 94 | int isBrk = ((n & 0x3FFF) == address[3]); 95 | GFXNumber(GRID(0,row),n & 0x3FFF,16,4,GRIDSIZE,isPC ? DBGC_HIGHLIGHT : DBGC_ADDRESS,isBrk ? 0xF00 : -1); 96 | strcpy(buffer,_mnemonics[CPURead(n & 0x3FFF)]); // Get mnemonic 97 | n++; 98 | if (buffer[strlen(buffer)-2] == '@') { // Replace @1 @2 with 1/2 byte operands 99 | switch(buffer[strlen(buffer)-1]) { 100 | case '1': 101 | sprintf(buffer+strlen(buffer)-2,"%02x",CPURead((n) & 0x3FFF)); 102 | n++; 103 | break; 104 | case '2': 105 | sprintf(buffer+strlen(buffer)-2,"%02x%02x",(CPURead((n+1) & 0x3FFF)) & 0x3F,CPURead((n) & 0x3FFF)); 106 | n += 2; 107 | break; 108 | } 109 | } 110 | GFXString(GRID(5,row),buffer,GRIDSIZE,isPC ? DBGC_HIGHLIGHT : DBGC_DATA,-1); 111 | } 112 | 113 | if (showDisplay == 0) return; 114 | 115 | int xSize = 3; 116 | int ySize = 3; 117 | int ySpacing = 4; 118 | int revs; 119 | 120 | SDL_Rect rc; 121 | rc.w = 8 * 32 * xSize; // 7 x 9 font, 32 x 8 grid 122 | rc.h = (ySpacing+9)* 16 * ySize; // Variable vertical spacing. 123 | rc.x = WIN_WIDTH/2-rc.w/2;rc.y = WIN_HEIGHT-64-rc.h; 124 | SDL_Rect rc2 = rc; 125 | rc2.x -= 10;rc2.y -= 10;rc2.w += 20;rc2.h += 20; 126 | GFXRectangle(&rc2,0xFFF); 127 | rc2.x += 2;rc2.y += 2;rc2.w -= 4;rc2.h -= 4; 128 | GFXRectangle(&rc2,0x000); 129 | 130 | SDL_Rect rpix;rpix.w = xSize;rpix.h = ySize ; 131 | for (int x = 0;x < 32;x++) { 132 | for (int y = 0;y < 16;y++) { 133 | int ch = HWIReadVideoMemory(x+y*32) & 0x7F; 134 | if (ch != 32) { 135 | for (int y1 = 0;y1 < 9;y1++) { 136 | rpix.x = x * 8 * xSize + rc.x; 137 | rpix.y = y * (9 + ySpacing) * ySize + y1 * ySize + rc.y; 138 | int bits = _mcmFont[ch * 9 + y1]; 139 | while (bits != 0) { 140 | if (bits & 0x80) GFXRectangle(&rpix,0xF80); 141 | rpix.x += xSize; 142 | bits = (bits << 1) & 0xFF; 143 | } 144 | } 145 | } 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /8008MC/sys_debug_system.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: sys_debug_system.h 5 | // Purpose: Debugger Code (System Dependent) Header 6 | // Created: 3rd December 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _DEBUG_SYS_H 13 | #define _DEBUG_SYS_H 14 | #include "sys_processor.h" 15 | 16 | #define WIN_TITLE "8008 Computer Emulator" // Initial Window stuff 17 | #define WIN_WIDTH (46*6*4) 18 | #define WIN_HEIGHT (27*8*4+32) 19 | #define WIN_BACKCOLOUR 0x004 20 | 21 | // ******************************************************************************************************************************* 22 | // These functions need to be implemented by the dependent debugger. 23 | // ******************************************************************************************************************************* 24 | 25 | #define DEBUG_ARGUMENTS(ac,av) if (ac == 2) CPULoadBinary(av[1]); // Handle CLI arguments 26 | #define DEBUG_CPURENDER(x) DBGXRender(x,0) // Render the debugging display 27 | #define DEBUG_VDURENDER(x) DBGXRender(x,1) // Render the game display etc. 28 | 29 | #define DEBUG_RESET() CPUReset() // Reset the CPU / Hardware. 30 | #define DEBUG_HOMEPC() (CPUGetStatus()->pc) // Get PC Home Address (e.g. current PCTR value) 31 | 32 | #define DEBUG_SINGLESTEP() CPUExecuteInstruction() // Execute a single instruction, return 0 or Frame rate on frame end. 33 | #define DEBUG_RUN(b1,b2) CPUExecute(b1,b2) // Run a frame or to breakpoint, returns -1 if breakpoint 34 | #define DEBUG_GETOVERBREAK() CPUGetStepOverBreakpoint() // Where would we break to step over here. (0 == single step) 35 | 36 | #define DEBUG_RAMSTART (0x0000) // Initial RAM address for debugger. 37 | #define DEBUG_SHIFT(d,v) ((((d) << 4) | v) & 0x3FFF) // Shifting into displayed address. 38 | 39 | #define DEBUG_KEYMAP(k,r) HWIProcessKey(k,r) // Runtime can remap/process keys etc. 40 | 41 | void DBGXRender(int *address,int showCPU); // Render the debugger screen. 42 | 43 | #endif -------------------------------------------------------------------------------- /8008MC/sys_processor.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: processor.h 5 | // Purpose: Processor Emulation (header) 6 | // Created: 3rd December 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _SYS_PROCESSOR_H 13 | #define _SYS_PROCESSOR_H 14 | 15 | typedef unsigned short WORD16; // 8 and 16 bit types. 16 | typedef unsigned char BYTE8; 17 | typedef unsigned int LONG32; 18 | 19 | #define RAMSIZE (16384) // RAM we have. 20 | 21 | #define DEFAULT_BUS_VALUE (0xFF) // What's on the bus if it's not memory. 22 | #define PCTR PCR[PCIX] 23 | 24 | void CPUReset(void); // CPU methods 25 | BYTE8 CPUExecuteInstruction(void); // Execute one instruction (multi phases) 26 | 27 | void HWIReset(void); // Reset hardware. 28 | void HWIEndFrame(void); // End frame. 29 | void HWIWriteVideoPort(BYTE8 n); // Write to video port 30 | BYTE8 HWIGetXCursor(void); 31 | BYTE8 HWIReadKeyboard(void); // Read keyboard 32 | int HWIProcessKey(int key,int isRunTime); // Process debug key (Win only) 33 | BYTE8 HWIReadVideoMemory(WORD16 offset); // Read video memory 34 | 35 | #ifdef INCLUDE_DEBUGGING_SUPPORT // Only required for debugging 36 | 37 | typedef struct _CPUSTATUS { 38 | int a,b,c,d,e,h,l,zFlag,pFlag,cFlag,sFlag,hFlag; // 8008 registers 39 | int pc,stack[8],stackDepth; // PC and Stack. 40 | int cycles; // Elapsed cycles 41 | int hl,m; // Helper stuff. 42 | } CPUSTATUS; 43 | 44 | CPUSTATUS *CPUGetStatus(void); // Access CPU State 45 | void CPULoadBinary(char *fileName); // Load Binary in. 46 | BYTE8 CPURead(WORD16 address); // Access RAM 47 | BYTE8 CPUExecute(WORD16 break1,WORD16 break2); // Run to break point(s) 48 | WORD16 CPUGetStepOverBreakpoint(void); // Get step over breakpoint 49 | 50 | #endif 51 | #endif -------------------------------------------------------------------------------- /8008MC/test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/8008MC/test.bin -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 paulscottrobson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 1k-coding-challenge 2 | 1k coding challenge for 'Fred', Joe Weisbecker's low volume prototype design 3 | -------------------------------------------------------------------------------- /basic/basic.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/basic/basic.bin -------------------------------------------------------------------------------- /basic/go.sh: -------------------------------------------------------------------------------- 1 | asl -L basic.asm 2 | p2bin -r 0-2048 -l 0 basic.p 3 | rm basic.p 4 | ../8008MC/dist/Debug/GNU-Linux/8008mc basic.bin 5 | -------------------------------------------------------------------------------- /documentation/8008datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/documentation/8008datasheet.pdf -------------------------------------------------------------------------------- /documentation/machine.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/documentation/machine.odt -------------------------------------------------------------------------------- /documents/CDP1802.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/documents/CDP1802.pdf -------------------------------------------------------------------------------- /documents/Hardware.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/documents/Hardware.odt -------------------------------------------------------------------------------- /emulator/.dep.inc: -------------------------------------------------------------------------------- 1 | # This code depends on make tool being used 2 | DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES})) 3 | ifneq (${DEPFILES},) 4 | include ${DEPFILES} 5 | endif 6 | -------------------------------------------------------------------------------- /emulator/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # There exist several targets which are by default empty and which can be 3 | # used for execution of your targets. These targets are usually executed 4 | # before and after some main targets. They are: 5 | # 6 | # .build-pre: called before 'build' target 7 | # .build-post: called after 'build' target 8 | # .clean-pre: called before 'clean' target 9 | # .clean-post: called after 'clean' target 10 | # .clobber-pre: called before 'clobber' target 11 | # .clobber-post: called after 'clobber' target 12 | # .all-pre: called before 'all' target 13 | # .all-post: called after 'all' target 14 | # .help-pre: called before 'help' target 15 | # .help-post: called after 'help' target 16 | # 17 | # Targets beginning with '.' are not intended to be called on their own. 18 | # 19 | # Main targets can be executed directly, and they are: 20 | # 21 | # build build a specific configuration 22 | # clean remove built files from a configuration 23 | # clobber remove all built files 24 | # all build all configurations 25 | # help print help mesage 26 | # 27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and 28 | # .help-impl are implemented in nbproject/makefile-impl.mk. 29 | # 30 | # Available make variables: 31 | # 32 | # CND_BASEDIR base directory for relative paths 33 | # CND_DISTDIR default top distribution directory (build artifacts) 34 | # CND_BUILDDIR default top build directory (object files, ...) 35 | # CONF name of current configuration 36 | # CND_PLATFORM_${CONF} platform name (current configuration) 37 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) 38 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) 39 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) 40 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) 41 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration) 42 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration) 43 | # 44 | # NOCDDL 45 | 46 | 47 | # Environment 48 | MKDIR=mkdir 49 | CP=cp 50 | CCADMIN=CCadmin 51 | 52 | 53 | # build 54 | build: .build-post 55 | 56 | .build-pre: 57 | # Add your pre 'build' code here... 58 | 59 | .build-post: .build-impl 60 | # Add your post 'build' code here... 61 | 62 | 63 | # clean 64 | clean: .clean-post 65 | 66 | .clean-pre: 67 | # Add your pre 'clean' code here... 68 | 69 | .clean-post: .clean-impl 70 | # Add your post 'clean' code here... 71 | 72 | 73 | # clobber 74 | clobber: .clobber-post 75 | 76 | .clobber-pre: 77 | # Add your pre 'clobber' code here... 78 | 79 | .clobber-post: .clobber-impl 80 | # Add your post 'clobber' code here... 81 | 82 | 83 | # all 84 | all: .all-post 85 | 86 | .all-pre: 87 | # Add your pre 'all' code here... 88 | 89 | .all-post: .all-impl 90 | # Add your post 'all' code here... 91 | 92 | 93 | # build tests 94 | build-tests: .build-tests-post 95 | 96 | .build-tests-pre: 97 | # Add your pre 'build-tests' code here... 98 | 99 | .build-tests-post: .build-tests-impl 100 | # Add your post 'build-tests' code here... 101 | 102 | 103 | # run tests 104 | test: .test-post 105 | 106 | .test-pre: build-tests 107 | # Add your pre 'test' code here... 108 | 109 | .test-post: .test-impl 110 | # Add your post 'test' code here... 111 | 112 | 113 | # help 114 | help: .help-post 115 | 116 | .help-pre: 117 | # Add your pre 'help' code here... 118 | 119 | .help-post: .help-impl 120 | # Add your post 'help' code here... 121 | 122 | 123 | 124 | # include project implementation makefile 125 | include nbproject/Makefile-impl.mk 126 | 127 | # include project make variables 128 | include nbproject/Makefile-variables.mk 129 | -------------------------------------------------------------------------------- /emulator/__1802mnemonics.h: -------------------------------------------------------------------------------- 1 | "idl","ldn r1","ldn r2","ldn r3","ldn r4","ldn r5","ldn r6","ldn r7","ldn r8","ldn r9","ldn ra","ldn rb","ldn rc","ldn rd","ldn re","ldn rf","inc r0","inc r1","inc r2","inc r3","inc r4","inc r5","inc r6","inc r7","inc r8","inc r9","inc ra","inc rb","inc rc","inc rd","inc re","inc rf","dec r0","dec r1","dec r2","dec r3","dec r4","dec r5","dec r6","dec r7","dec r8","dec r9","dec ra","dec rb","dec rc","dec rd","dec re","dec rf","br $1","bq $1","bz $1","bdf $1","b1 $1","b2 $1","b3 $1","b4 $1","skp","bnq $1","bnz $1","bnf $1","bn1 $1","bn2 $1","bn3 $1","bn4 $1","lda r0","lda r1","lda r2","lda r3","lda r4","lda r5","lda r6","lda r7","lda r8","lda r9","lda ra","lda rb","lda rc","lda rd","lda re","lda rf","str r0","str r1","str r2","str r3","str r4","str r5","str r6","str r7","str r8","str r9","str ra","str rb","str rc","str rd","str re","str rf","irx","out 1","out 2","out 3","out 4","out 5","out 6","out 7","db 68","inp 1","inp 2","inp 3","inp 4","inp 5","inp 6","inp 7","ret","dis","ldxa","stxd","adc","sdb","rshr","smb","sav","mark","req","seq","adci $1","sdbi $1","rshl","smbi $1","glo r0","glo r1","glo r2","glo r3","glo r4","glo r5","glo r6","glo r7","glo r8","glo r9","glo ra","glo rb","glo rc","glo rd","glo re","glo rf","ghi r0","ghi r1","ghi r2","ghi r3","ghi r4","ghi r5","ghi r6","ghi r7","ghi r8","ghi r9","ghi ra","ghi rb","ghi rc","ghi rd","ghi re","ghi rf","plo r0","plo r1","plo r2","plo r3","plo r4","plo r5","plo r6","plo r7","plo r8","plo r9","plo ra","plo rb","plo rc","plo rd","plo re","plo rf","phi r0","phi r1","phi r2","phi r3","phi r4","phi r5","phi r6","phi r7","phi r8","phi r9","phi ra","phi rb","phi rc","phi rd","phi re","phi rf","lbr $2","lbq $2","lbz $2","lbdf $2","nop","lsnq","lsnz","lsnf","lskp","lbnq $2","lbnz $2","lbnf $2","lsie","lsq","lsz","lsdf","sep r0","sep r1","sep r2","sep r3","sep r4","sep r5","sep r6","sep r7","sep r8","sep r9","sep ra","sep rb","sep rc","sep rd","sep re","sep rf","sex r0","sex r1","sex r2","sex r3","sex r4","sex r5","sex r6","sex r7","sex r8","sex r9","sex ra","sex rb","sex rc","sex rd","sex re","sex rf","ldx","or","and","xor","add","sd","shr","sm","ldi $1","ori $1","ani $1","xri $1","adi $1","sdi $1","shl","smi $1" -------------------------------------------------------------------------------- /emulator/__1802ports.h: -------------------------------------------------------------------------------- 1 | #ifndef OUTPORT0 2 | #define OUTPORT0(n) {} 3 | #endif 4 | #ifndef INPORT1 5 | #define INPORT1() (DEFAULT_BUS_VALUE) 6 | #endif 7 | #ifndef OUTPORT1 8 | #define OUTPORT1(n) {} 9 | #endif 10 | #ifndef INPORT2 11 | #define INPORT2() (DEFAULT_BUS_VALUE) 12 | #endif 13 | #ifndef OUTPORT2 14 | #define OUTPORT2(n) {} 15 | #endif 16 | #ifndef INPORT3 17 | #define INPORT3() (DEFAULT_BUS_VALUE) 18 | #endif 19 | #ifndef OUTPORT3 20 | #define OUTPORT3(n) {} 21 | #endif 22 | #ifndef INPORT4 23 | #define INPORT4() (DEFAULT_BUS_VALUE) 24 | #endif 25 | #ifndef OUTPORT4 26 | #define OUTPORT4(n) {} 27 | #endif 28 | #ifndef INPORT5 29 | #define INPORT5() (DEFAULT_BUS_VALUE) 30 | #endif 31 | #ifndef OUTPORT5 32 | #define OUTPORT5(n) {} 33 | #endif 34 | #ifndef INPORT6 35 | #define INPORT6() (DEFAULT_BUS_VALUE) 36 | #endif 37 | #ifndef OUTPORT6 38 | #define OUTPORT6(n) {} 39 | #endif 40 | #ifndef INPORT7 41 | #define INPORT7() (DEFAULT_BUS_VALUE) 42 | #endif 43 | #ifndef OUTPORT7 44 | #define OUTPORT7(n) {} 45 | #endif 46 | #ifndef EFLAG1 47 | #define EFLAG1() (0) 48 | #endif 49 | #ifndef EFLAG2 50 | #define EFLAG2() (0) 51 | #endif 52 | #ifndef EFLAG3 53 | #define EFLAG3() (0) 54 | #endif 55 | #ifndef EFLAG4 56 | #define EFLAG4() (0) 57 | #endif 58 | -------------------------------------------------------------------------------- /emulator/__1802support.h: -------------------------------------------------------------------------------- 1 | static BYTE8 D,DF,MB,Q,IE,P,X,T; 2 | static WORD16 R[16],Cycles,temp16,MA; 3 | static void __1802Reset(void) { 4 | Q = 0;IE = 1;X = 0;P = 0;R[0] = 0; 5 | DF &= 1; 6 | OUTPORT0(0); 7 | } 8 | #define FETCH() MA = R[P]++;READ() 9 | #define ADD(c) temp16 = D + MB + (c);D = temp16;DF = (temp16 >> 8) & 1 10 | #define SUB(a,b,c) temp16 = (a) + ((b)^0xFF) + (c);D = temp16;DF = (temp16 >> 8) & 1 11 | #define SBRANCH() { R[P] = (R[P] & 0xFF00) | MB; } 12 | #define FETCH2() { FETCH();temp16 = (MB << 8);FETCH();temp16 |= MB; Cycles--; } 13 | #define LBRANCH() { R[P] = temp16; } 14 | #define LSKIP() { R[P] = R[P] + 2; } 15 | static void inline __Mark(void) { 16 | T = (X << 4) | P; 17 | MB = T;MA = R[2];WRITE(); 18 | X = P; 19 | R[2]--; 20 | } 21 | static void inline __Return(void) { 22 | MA = R[X];READ(); 23 | R[X]++; 24 | X = (MB >> 4);P = (MB & 0x0F); 25 | } 26 | static void __1802Interrupt(void) { 27 | if (IE != 0) { 28 | T = (X << 4) | P; 29 | P = 1;X = 2; 30 | IE = 0; 31 | } 32 | } -------------------------------------------------------------------------------- /emulator/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/a.out -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/framework/debugger.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/build/Debug/GNU-Linux/framework/debugger.o -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/framework/debugger.o.d: -------------------------------------------------------------------------------- 1 | build/Debug/GNU-Linux/framework/debugger.o: framework/debugger.cpp \ 2 | framework/gfx.h /usr/include/SDL2/SDL.h /usr/include/SDL2/SDL_main.h \ 3 | /usr/include/SDL2/SDL_stdinc.h /usr/include/SDL2/SDL_config.h \ 4 | /usr/include/SDL2/SDL_platform.h /usr/include/SDL2/begin_code.h \ 5 | /usr/include/SDL2/close_code.h /usr/include/SDL2/SDL_assert.h \ 6 | /usr/include/SDL2/SDL_atomic.h /usr/include/SDL2/SDL_audio.h \ 7 | /usr/include/SDL2/SDL_error.h /usr/include/SDL2/SDL_endian.h \ 8 | /usr/include/SDL2/SDL_mutex.h /usr/include/SDL2/SDL_thread.h \ 9 | /usr/include/SDL2/SDL_rwops.h /usr/include/SDL2/SDL_clipboard.h \ 10 | /usr/include/SDL2/SDL_cpuinfo.h /usr/include/SDL2/SDL_events.h \ 11 | /usr/include/SDL2/SDL_video.h /usr/include/SDL2/SDL_pixels.h \ 12 | /usr/include/SDL2/SDL_rect.h /usr/include/SDL2/SDL_surface.h \ 13 | /usr/include/SDL2/SDL_blendmode.h /usr/include/SDL2/SDL_keyboard.h \ 14 | /usr/include/SDL2/SDL_keycode.h /usr/include/SDL2/SDL_scancode.h \ 15 | /usr/include/SDL2/SDL_mouse.h /usr/include/SDL2/SDL_joystick.h \ 16 | /usr/include/SDL2/SDL_gamecontroller.h /usr/include/SDL2/SDL_quit.h \ 17 | /usr/include/SDL2/SDL_gesture.h /usr/include/SDL2/SDL_touch.h \ 18 | /usr/include/SDL2/SDL_filesystem.h /usr/include/SDL2/SDL_haptic.h \ 19 | /usr/include/SDL2/SDL_hints.h /usr/include/SDL2/SDL_loadso.h \ 20 | /usr/include/SDL2/SDL_log.h /usr/include/SDL2/SDL_messagebox.h \ 21 | /usr/include/SDL2/SDL_power.h /usr/include/SDL2/SDL_render.h \ 22 | /usr/include/SDL2/SDL_system.h /usr/include/SDL2/SDL_timer.h \ 23 | /usr/include/SDL2/SDL_version.h /usr/include/SDL2/SDL_audio.h \ 24 | framework/debugger.h sys_processor.h sys_debug_system.h sys_processor.h \ 25 | hardware.h 26 | 27 | framework/gfx.h: 28 | 29 | /usr/include/SDL2/SDL.h: 30 | 31 | /usr/include/SDL2/SDL_main.h: 32 | 33 | /usr/include/SDL2/SDL_stdinc.h: 34 | 35 | /usr/include/SDL2/SDL_config.h: 36 | 37 | /usr/include/SDL2/SDL_platform.h: 38 | 39 | /usr/include/SDL2/begin_code.h: 40 | 41 | /usr/include/SDL2/close_code.h: 42 | 43 | /usr/include/SDL2/SDL_assert.h: 44 | 45 | /usr/include/SDL2/SDL_atomic.h: 46 | 47 | /usr/include/SDL2/SDL_audio.h: 48 | 49 | /usr/include/SDL2/SDL_error.h: 50 | 51 | /usr/include/SDL2/SDL_endian.h: 52 | 53 | /usr/include/SDL2/SDL_mutex.h: 54 | 55 | /usr/include/SDL2/SDL_thread.h: 56 | 57 | /usr/include/SDL2/SDL_rwops.h: 58 | 59 | /usr/include/SDL2/SDL_clipboard.h: 60 | 61 | /usr/include/SDL2/SDL_cpuinfo.h: 62 | 63 | /usr/include/SDL2/SDL_events.h: 64 | 65 | /usr/include/SDL2/SDL_video.h: 66 | 67 | /usr/include/SDL2/SDL_pixels.h: 68 | 69 | /usr/include/SDL2/SDL_rect.h: 70 | 71 | /usr/include/SDL2/SDL_surface.h: 72 | 73 | /usr/include/SDL2/SDL_blendmode.h: 74 | 75 | /usr/include/SDL2/SDL_keyboard.h: 76 | 77 | /usr/include/SDL2/SDL_keycode.h: 78 | 79 | /usr/include/SDL2/SDL_scancode.h: 80 | 81 | /usr/include/SDL2/SDL_mouse.h: 82 | 83 | /usr/include/SDL2/SDL_joystick.h: 84 | 85 | /usr/include/SDL2/SDL_gamecontroller.h: 86 | 87 | /usr/include/SDL2/SDL_quit.h: 88 | 89 | /usr/include/SDL2/SDL_gesture.h: 90 | 91 | /usr/include/SDL2/SDL_touch.h: 92 | 93 | /usr/include/SDL2/SDL_filesystem.h: 94 | 95 | /usr/include/SDL2/SDL_haptic.h: 96 | 97 | /usr/include/SDL2/SDL_hints.h: 98 | 99 | /usr/include/SDL2/SDL_loadso.h: 100 | 101 | /usr/include/SDL2/SDL_log.h: 102 | 103 | /usr/include/SDL2/SDL_messagebox.h: 104 | 105 | /usr/include/SDL2/SDL_power.h: 106 | 107 | /usr/include/SDL2/SDL_render.h: 108 | 109 | /usr/include/SDL2/SDL_system.h: 110 | 111 | /usr/include/SDL2/SDL_timer.h: 112 | 113 | /usr/include/SDL2/SDL_version.h: 114 | 115 | /usr/include/SDL2/SDL_audio.h: 116 | 117 | framework/debugger.h: 118 | 119 | sys_processor.h: 120 | 121 | sys_debug_system.h: 122 | 123 | sys_processor.h: 124 | 125 | hardware.h: 126 | -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/framework/gfx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/build/Debug/GNU-Linux/framework/gfx.o -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/framework/gfx.o.d: -------------------------------------------------------------------------------- 1 | build/Debug/GNU-Linux/framework/gfx.o: framework/gfx.cpp framework/gfx.h \ 2 | /usr/include/SDL2/SDL.h /usr/include/SDL2/SDL_main.h \ 3 | /usr/include/SDL2/SDL_stdinc.h /usr/include/SDL2/SDL_config.h \ 4 | /usr/include/SDL2/SDL_platform.h /usr/include/SDL2/begin_code.h \ 5 | /usr/include/SDL2/close_code.h /usr/include/SDL2/SDL_assert.h \ 6 | /usr/include/SDL2/SDL_atomic.h /usr/include/SDL2/SDL_audio.h \ 7 | /usr/include/SDL2/SDL_error.h /usr/include/SDL2/SDL_endian.h \ 8 | /usr/include/SDL2/SDL_mutex.h /usr/include/SDL2/SDL_thread.h \ 9 | /usr/include/SDL2/SDL_rwops.h /usr/include/SDL2/SDL_clipboard.h \ 10 | /usr/include/SDL2/SDL_cpuinfo.h /usr/include/SDL2/SDL_events.h \ 11 | /usr/include/SDL2/SDL_video.h /usr/include/SDL2/SDL_pixels.h \ 12 | /usr/include/SDL2/SDL_rect.h /usr/include/SDL2/SDL_surface.h \ 13 | /usr/include/SDL2/SDL_blendmode.h /usr/include/SDL2/SDL_keyboard.h \ 14 | /usr/include/SDL2/SDL_keycode.h /usr/include/SDL2/SDL_scancode.h \ 15 | /usr/include/SDL2/SDL_mouse.h /usr/include/SDL2/SDL_joystick.h \ 16 | /usr/include/SDL2/SDL_gamecontroller.h /usr/include/SDL2/SDL_quit.h \ 17 | /usr/include/SDL2/SDL_gesture.h /usr/include/SDL2/SDL_touch.h \ 18 | /usr/include/SDL2/SDL_filesystem.h /usr/include/SDL2/SDL_haptic.h \ 19 | /usr/include/SDL2/SDL_hints.h /usr/include/SDL2/SDL_loadso.h \ 20 | /usr/include/SDL2/SDL_log.h /usr/include/SDL2/SDL_messagebox.h \ 21 | /usr/include/SDL2/SDL_power.h /usr/include/SDL2/SDL_render.h \ 22 | /usr/include/SDL2/SDL_system.h /usr/include/SDL2/SDL_timer.h \ 23 | /usr/include/SDL2/SDL_version.h /usr/include/SDL2/SDL_audio.h \ 24 | framework/font.h 25 | 26 | framework/gfx.h: 27 | 28 | /usr/include/SDL2/SDL.h: 29 | 30 | /usr/include/SDL2/SDL_main.h: 31 | 32 | /usr/include/SDL2/SDL_stdinc.h: 33 | 34 | /usr/include/SDL2/SDL_config.h: 35 | 36 | /usr/include/SDL2/SDL_platform.h: 37 | 38 | /usr/include/SDL2/begin_code.h: 39 | 40 | /usr/include/SDL2/close_code.h: 41 | 42 | /usr/include/SDL2/SDL_assert.h: 43 | 44 | /usr/include/SDL2/SDL_atomic.h: 45 | 46 | /usr/include/SDL2/SDL_audio.h: 47 | 48 | /usr/include/SDL2/SDL_error.h: 49 | 50 | /usr/include/SDL2/SDL_endian.h: 51 | 52 | /usr/include/SDL2/SDL_mutex.h: 53 | 54 | /usr/include/SDL2/SDL_thread.h: 55 | 56 | /usr/include/SDL2/SDL_rwops.h: 57 | 58 | /usr/include/SDL2/SDL_clipboard.h: 59 | 60 | /usr/include/SDL2/SDL_cpuinfo.h: 61 | 62 | /usr/include/SDL2/SDL_events.h: 63 | 64 | /usr/include/SDL2/SDL_video.h: 65 | 66 | /usr/include/SDL2/SDL_pixels.h: 67 | 68 | /usr/include/SDL2/SDL_rect.h: 69 | 70 | /usr/include/SDL2/SDL_surface.h: 71 | 72 | /usr/include/SDL2/SDL_blendmode.h: 73 | 74 | /usr/include/SDL2/SDL_keyboard.h: 75 | 76 | /usr/include/SDL2/SDL_keycode.h: 77 | 78 | /usr/include/SDL2/SDL_scancode.h: 79 | 80 | /usr/include/SDL2/SDL_mouse.h: 81 | 82 | /usr/include/SDL2/SDL_joystick.h: 83 | 84 | /usr/include/SDL2/SDL_gamecontroller.h: 85 | 86 | /usr/include/SDL2/SDL_quit.h: 87 | 88 | /usr/include/SDL2/SDL_gesture.h: 89 | 90 | /usr/include/SDL2/SDL_touch.h: 91 | 92 | /usr/include/SDL2/SDL_filesystem.h: 93 | 94 | /usr/include/SDL2/SDL_haptic.h: 95 | 96 | /usr/include/SDL2/SDL_hints.h: 97 | 98 | /usr/include/SDL2/SDL_loadso.h: 99 | 100 | /usr/include/SDL2/SDL_log.h: 101 | 102 | /usr/include/SDL2/SDL_messagebox.h: 103 | 104 | /usr/include/SDL2/SDL_power.h: 105 | 106 | /usr/include/SDL2/SDL_render.h: 107 | 108 | /usr/include/SDL2/SDL_system.h: 109 | 110 | /usr/include/SDL2/SDL_timer.h: 111 | 112 | /usr/include/SDL2/SDL_version.h: 113 | 114 | /usr/include/SDL2/SDL_audio.h: 115 | 116 | framework/font.h: 117 | -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/framework/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/build/Debug/GNU-Linux/framework/main.o -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/framework/main.o.d: -------------------------------------------------------------------------------- 1 | build/Debug/GNU-Linux/framework/main.o: framework/main.cpp \ 2 | framework/gfx.h /usr/include/SDL2/SDL.h /usr/include/SDL2/SDL_main.h \ 3 | /usr/include/SDL2/SDL_stdinc.h /usr/include/SDL2/SDL_config.h \ 4 | /usr/include/SDL2/SDL_platform.h /usr/include/SDL2/begin_code.h \ 5 | /usr/include/SDL2/close_code.h /usr/include/SDL2/SDL_assert.h \ 6 | /usr/include/SDL2/SDL_atomic.h /usr/include/SDL2/SDL_audio.h \ 7 | /usr/include/SDL2/SDL_error.h /usr/include/SDL2/SDL_endian.h \ 8 | /usr/include/SDL2/SDL_mutex.h /usr/include/SDL2/SDL_thread.h \ 9 | /usr/include/SDL2/SDL_rwops.h /usr/include/SDL2/SDL_clipboard.h \ 10 | /usr/include/SDL2/SDL_cpuinfo.h /usr/include/SDL2/SDL_events.h \ 11 | /usr/include/SDL2/SDL_video.h /usr/include/SDL2/SDL_pixels.h \ 12 | /usr/include/SDL2/SDL_rect.h /usr/include/SDL2/SDL_surface.h \ 13 | /usr/include/SDL2/SDL_blendmode.h /usr/include/SDL2/SDL_keyboard.h \ 14 | /usr/include/SDL2/SDL_keycode.h /usr/include/SDL2/SDL_scancode.h \ 15 | /usr/include/SDL2/SDL_mouse.h /usr/include/SDL2/SDL_joystick.h \ 16 | /usr/include/SDL2/SDL_gamecontroller.h /usr/include/SDL2/SDL_quit.h \ 17 | /usr/include/SDL2/SDL_gesture.h /usr/include/SDL2/SDL_touch.h \ 18 | /usr/include/SDL2/SDL_filesystem.h /usr/include/SDL2/SDL_haptic.h \ 19 | /usr/include/SDL2/SDL_hints.h /usr/include/SDL2/SDL_loadso.h \ 20 | /usr/include/SDL2/SDL_log.h /usr/include/SDL2/SDL_messagebox.h \ 21 | /usr/include/SDL2/SDL_power.h /usr/include/SDL2/SDL_render.h \ 22 | /usr/include/SDL2/SDL_system.h /usr/include/SDL2/SDL_timer.h \ 23 | /usr/include/SDL2/SDL_version.h /usr/include/SDL2/SDL_audio.h \ 24 | sys_processor.h sys_debug_system.h sys_processor.h hardware.h \ 25 | framework/debugger.h 26 | 27 | framework/gfx.h: 28 | 29 | /usr/include/SDL2/SDL.h: 30 | 31 | /usr/include/SDL2/SDL_main.h: 32 | 33 | /usr/include/SDL2/SDL_stdinc.h: 34 | 35 | /usr/include/SDL2/SDL_config.h: 36 | 37 | /usr/include/SDL2/SDL_platform.h: 38 | 39 | /usr/include/SDL2/begin_code.h: 40 | 41 | /usr/include/SDL2/close_code.h: 42 | 43 | /usr/include/SDL2/SDL_assert.h: 44 | 45 | /usr/include/SDL2/SDL_atomic.h: 46 | 47 | /usr/include/SDL2/SDL_audio.h: 48 | 49 | /usr/include/SDL2/SDL_error.h: 50 | 51 | /usr/include/SDL2/SDL_endian.h: 52 | 53 | /usr/include/SDL2/SDL_mutex.h: 54 | 55 | /usr/include/SDL2/SDL_thread.h: 56 | 57 | /usr/include/SDL2/SDL_rwops.h: 58 | 59 | /usr/include/SDL2/SDL_clipboard.h: 60 | 61 | /usr/include/SDL2/SDL_cpuinfo.h: 62 | 63 | /usr/include/SDL2/SDL_events.h: 64 | 65 | /usr/include/SDL2/SDL_video.h: 66 | 67 | /usr/include/SDL2/SDL_pixels.h: 68 | 69 | /usr/include/SDL2/SDL_rect.h: 70 | 71 | /usr/include/SDL2/SDL_surface.h: 72 | 73 | /usr/include/SDL2/SDL_blendmode.h: 74 | 75 | /usr/include/SDL2/SDL_keyboard.h: 76 | 77 | /usr/include/SDL2/SDL_keycode.h: 78 | 79 | /usr/include/SDL2/SDL_scancode.h: 80 | 81 | /usr/include/SDL2/SDL_mouse.h: 82 | 83 | /usr/include/SDL2/SDL_joystick.h: 84 | 85 | /usr/include/SDL2/SDL_gamecontroller.h: 86 | 87 | /usr/include/SDL2/SDL_quit.h: 88 | 89 | /usr/include/SDL2/SDL_gesture.h: 90 | 91 | /usr/include/SDL2/SDL_touch.h: 92 | 93 | /usr/include/SDL2/SDL_filesystem.h: 94 | 95 | /usr/include/SDL2/SDL_haptic.h: 96 | 97 | /usr/include/SDL2/SDL_hints.h: 98 | 99 | /usr/include/SDL2/SDL_loadso.h: 100 | 101 | /usr/include/SDL2/SDL_log.h: 102 | 103 | /usr/include/SDL2/SDL_messagebox.h: 104 | 105 | /usr/include/SDL2/SDL_power.h: 106 | 107 | /usr/include/SDL2/SDL_render.h: 108 | 109 | /usr/include/SDL2/SDL_system.h: 110 | 111 | /usr/include/SDL2/SDL_timer.h: 112 | 113 | /usr/include/SDL2/SDL_version.h: 114 | 115 | /usr/include/SDL2/SDL_audio.h: 116 | 117 | sys_processor.h: 118 | 119 | sys_debug_system.h: 120 | 121 | sys_processor.h: 122 | 123 | hardware.h: 124 | 125 | framework/debugger.h: 126 | -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/hardware.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/build/Debug/GNU-Linux/hardware.o -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/hardware.o.d: -------------------------------------------------------------------------------- 1 | build/Debug/GNU-Linux/hardware.o: hardware.cpp sys_processor.h hardware.h \ 2 | framework/gfx.h /usr/include/SDL2/SDL.h /usr/include/SDL2/SDL_main.h \ 3 | /usr/include/SDL2/SDL_stdinc.h /usr/include/SDL2/SDL_config.h \ 4 | /usr/include/SDL2/SDL_platform.h /usr/include/SDL2/begin_code.h \ 5 | /usr/include/SDL2/close_code.h /usr/include/SDL2/SDL_assert.h \ 6 | /usr/include/SDL2/SDL_atomic.h /usr/include/SDL2/SDL_audio.h \ 7 | /usr/include/SDL2/SDL_error.h /usr/include/SDL2/SDL_endian.h \ 8 | /usr/include/SDL2/SDL_mutex.h /usr/include/SDL2/SDL_thread.h \ 9 | /usr/include/SDL2/SDL_rwops.h /usr/include/SDL2/SDL_clipboard.h \ 10 | /usr/include/SDL2/SDL_cpuinfo.h /usr/include/SDL2/SDL_events.h \ 11 | /usr/include/SDL2/SDL_video.h /usr/include/SDL2/SDL_pixels.h \ 12 | /usr/include/SDL2/SDL_rect.h /usr/include/SDL2/SDL_surface.h \ 13 | /usr/include/SDL2/SDL_blendmode.h /usr/include/SDL2/SDL_keyboard.h \ 14 | /usr/include/SDL2/SDL_keycode.h /usr/include/SDL2/SDL_scancode.h \ 15 | /usr/include/SDL2/SDL_mouse.h /usr/include/SDL2/SDL_joystick.h \ 16 | /usr/include/SDL2/SDL_gamecontroller.h /usr/include/SDL2/SDL_quit.h \ 17 | /usr/include/SDL2/SDL_gesture.h /usr/include/SDL2/SDL_touch.h \ 18 | /usr/include/SDL2/SDL_filesystem.h /usr/include/SDL2/SDL_haptic.h \ 19 | /usr/include/SDL2/SDL_hints.h /usr/include/SDL2/SDL_loadso.h \ 20 | /usr/include/SDL2/SDL_log.h /usr/include/SDL2/SDL_messagebox.h \ 21 | /usr/include/SDL2/SDL_power.h /usr/include/SDL2/SDL_render.h \ 22 | /usr/include/SDL2/SDL_system.h /usr/include/SDL2/SDL_timer.h \ 23 | /usr/include/SDL2/SDL_version.h /usr/include/SDL2/SDL_audio.h 24 | 25 | sys_processor.h: 26 | 27 | hardware.h: 28 | 29 | framework/gfx.h: 30 | 31 | /usr/include/SDL2/SDL.h: 32 | 33 | /usr/include/SDL2/SDL_main.h: 34 | 35 | /usr/include/SDL2/SDL_stdinc.h: 36 | 37 | /usr/include/SDL2/SDL_config.h: 38 | 39 | /usr/include/SDL2/SDL_platform.h: 40 | 41 | /usr/include/SDL2/begin_code.h: 42 | 43 | /usr/include/SDL2/close_code.h: 44 | 45 | /usr/include/SDL2/SDL_assert.h: 46 | 47 | /usr/include/SDL2/SDL_atomic.h: 48 | 49 | /usr/include/SDL2/SDL_audio.h: 50 | 51 | /usr/include/SDL2/SDL_error.h: 52 | 53 | /usr/include/SDL2/SDL_endian.h: 54 | 55 | /usr/include/SDL2/SDL_mutex.h: 56 | 57 | /usr/include/SDL2/SDL_thread.h: 58 | 59 | /usr/include/SDL2/SDL_rwops.h: 60 | 61 | /usr/include/SDL2/SDL_clipboard.h: 62 | 63 | /usr/include/SDL2/SDL_cpuinfo.h: 64 | 65 | /usr/include/SDL2/SDL_events.h: 66 | 67 | /usr/include/SDL2/SDL_video.h: 68 | 69 | /usr/include/SDL2/SDL_pixels.h: 70 | 71 | /usr/include/SDL2/SDL_rect.h: 72 | 73 | /usr/include/SDL2/SDL_surface.h: 74 | 75 | /usr/include/SDL2/SDL_blendmode.h: 76 | 77 | /usr/include/SDL2/SDL_keyboard.h: 78 | 79 | /usr/include/SDL2/SDL_keycode.h: 80 | 81 | /usr/include/SDL2/SDL_scancode.h: 82 | 83 | /usr/include/SDL2/SDL_mouse.h: 84 | 85 | /usr/include/SDL2/SDL_joystick.h: 86 | 87 | /usr/include/SDL2/SDL_gamecontroller.h: 88 | 89 | /usr/include/SDL2/SDL_quit.h: 90 | 91 | /usr/include/SDL2/SDL_gesture.h: 92 | 93 | /usr/include/SDL2/SDL_touch.h: 94 | 95 | /usr/include/SDL2/SDL_filesystem.h: 96 | 97 | /usr/include/SDL2/SDL_haptic.h: 98 | 99 | /usr/include/SDL2/SDL_hints.h: 100 | 101 | /usr/include/SDL2/SDL_loadso.h: 102 | 103 | /usr/include/SDL2/SDL_log.h: 104 | 105 | /usr/include/SDL2/SDL_messagebox.h: 106 | 107 | /usr/include/SDL2/SDL_power.h: 108 | 109 | /usr/include/SDL2/SDL_render.h: 110 | 111 | /usr/include/SDL2/SDL_system.h: 112 | 113 | /usr/include/SDL2/SDL_timer.h: 114 | 115 | /usr/include/SDL2/SDL_version.h: 116 | 117 | /usr/include/SDL2/SDL_audio.h: 118 | -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/sys_debug_vip.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/build/Debug/GNU-Linux/sys_debug_vip.o -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/sys_debug_vip.o.d: -------------------------------------------------------------------------------- 1 | build/Debug/GNU-Linux/sys_debug_vip.o: sys_debug_vip.cpp framework/gfx.h \ 2 | /usr/include/SDL2/SDL.h /usr/include/SDL2/SDL_main.h \ 3 | /usr/include/SDL2/SDL_stdinc.h /usr/include/SDL2/SDL_config.h \ 4 | /usr/include/SDL2/SDL_platform.h /usr/include/SDL2/begin_code.h \ 5 | /usr/include/SDL2/close_code.h /usr/include/SDL2/SDL_assert.h \ 6 | /usr/include/SDL2/SDL_atomic.h /usr/include/SDL2/SDL_audio.h \ 7 | /usr/include/SDL2/SDL_error.h /usr/include/SDL2/SDL_endian.h \ 8 | /usr/include/SDL2/SDL_mutex.h /usr/include/SDL2/SDL_thread.h \ 9 | /usr/include/SDL2/SDL_rwops.h /usr/include/SDL2/SDL_clipboard.h \ 10 | /usr/include/SDL2/SDL_cpuinfo.h /usr/include/SDL2/SDL_events.h \ 11 | /usr/include/SDL2/SDL_video.h /usr/include/SDL2/SDL_pixels.h \ 12 | /usr/include/SDL2/SDL_rect.h /usr/include/SDL2/SDL_surface.h \ 13 | /usr/include/SDL2/SDL_blendmode.h /usr/include/SDL2/SDL_keyboard.h \ 14 | /usr/include/SDL2/SDL_keycode.h /usr/include/SDL2/SDL_scancode.h \ 15 | /usr/include/SDL2/SDL_mouse.h /usr/include/SDL2/SDL_joystick.h \ 16 | /usr/include/SDL2/SDL_gamecontroller.h /usr/include/SDL2/SDL_quit.h \ 17 | /usr/include/SDL2/SDL_gesture.h /usr/include/SDL2/SDL_touch.h \ 18 | /usr/include/SDL2/SDL_filesystem.h /usr/include/SDL2/SDL_haptic.h \ 19 | /usr/include/SDL2/SDL_hints.h /usr/include/SDL2/SDL_loadso.h \ 20 | /usr/include/SDL2/SDL_log.h /usr/include/SDL2/SDL_messagebox.h \ 21 | /usr/include/SDL2/SDL_power.h /usr/include/SDL2/SDL_render.h \ 22 | /usr/include/SDL2/SDL_system.h /usr/include/SDL2/SDL_timer.h \ 23 | /usr/include/SDL2/SDL_version.h /usr/include/SDL2/SDL_audio.h \ 24 | sys_processor.h framework/debugger.h sys_processor.h sys_debug_system.h \ 25 | sys_processor.h hardware.h hardware.h __1802mnemonics.h 26 | 27 | framework/gfx.h: 28 | 29 | /usr/include/SDL2/SDL.h: 30 | 31 | /usr/include/SDL2/SDL_main.h: 32 | 33 | /usr/include/SDL2/SDL_stdinc.h: 34 | 35 | /usr/include/SDL2/SDL_config.h: 36 | 37 | /usr/include/SDL2/SDL_platform.h: 38 | 39 | /usr/include/SDL2/begin_code.h: 40 | 41 | /usr/include/SDL2/close_code.h: 42 | 43 | /usr/include/SDL2/SDL_assert.h: 44 | 45 | /usr/include/SDL2/SDL_atomic.h: 46 | 47 | /usr/include/SDL2/SDL_audio.h: 48 | 49 | /usr/include/SDL2/SDL_error.h: 50 | 51 | /usr/include/SDL2/SDL_endian.h: 52 | 53 | /usr/include/SDL2/SDL_mutex.h: 54 | 55 | /usr/include/SDL2/SDL_thread.h: 56 | 57 | /usr/include/SDL2/SDL_rwops.h: 58 | 59 | /usr/include/SDL2/SDL_clipboard.h: 60 | 61 | /usr/include/SDL2/SDL_cpuinfo.h: 62 | 63 | /usr/include/SDL2/SDL_events.h: 64 | 65 | /usr/include/SDL2/SDL_video.h: 66 | 67 | /usr/include/SDL2/SDL_pixels.h: 68 | 69 | /usr/include/SDL2/SDL_rect.h: 70 | 71 | /usr/include/SDL2/SDL_surface.h: 72 | 73 | /usr/include/SDL2/SDL_blendmode.h: 74 | 75 | /usr/include/SDL2/SDL_keyboard.h: 76 | 77 | /usr/include/SDL2/SDL_keycode.h: 78 | 79 | /usr/include/SDL2/SDL_scancode.h: 80 | 81 | /usr/include/SDL2/SDL_mouse.h: 82 | 83 | /usr/include/SDL2/SDL_joystick.h: 84 | 85 | /usr/include/SDL2/SDL_gamecontroller.h: 86 | 87 | /usr/include/SDL2/SDL_quit.h: 88 | 89 | /usr/include/SDL2/SDL_gesture.h: 90 | 91 | /usr/include/SDL2/SDL_touch.h: 92 | 93 | /usr/include/SDL2/SDL_filesystem.h: 94 | 95 | /usr/include/SDL2/SDL_haptic.h: 96 | 97 | /usr/include/SDL2/SDL_hints.h: 98 | 99 | /usr/include/SDL2/SDL_loadso.h: 100 | 101 | /usr/include/SDL2/SDL_log.h: 102 | 103 | /usr/include/SDL2/SDL_messagebox.h: 104 | 105 | /usr/include/SDL2/SDL_power.h: 106 | 107 | /usr/include/SDL2/SDL_render.h: 108 | 109 | /usr/include/SDL2/SDL_system.h: 110 | 111 | /usr/include/SDL2/SDL_timer.h: 112 | 113 | /usr/include/SDL2/SDL_version.h: 114 | 115 | /usr/include/SDL2/SDL_audio.h: 116 | 117 | sys_processor.h: 118 | 119 | framework/debugger.h: 120 | 121 | sys_processor.h: 122 | 123 | sys_debug_system.h: 124 | 125 | sys_processor.h: 126 | 127 | hardware.h: 128 | 129 | hardware.h: 130 | 131 | __1802mnemonics.h: 132 | -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/sys_processor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/build/Debug/GNU-Linux/sys_processor.o -------------------------------------------------------------------------------- /emulator/build/Debug/GNU-Linux/sys_processor.o.d: -------------------------------------------------------------------------------- 1 | build/Debug/GNU-Linux/sys_processor.o: sys_processor.cpp sys_processor.h \ 2 | sys_debug_system.h hardware.h __1802ports.h __1802support.h \ 3 | __1802opcodes.h 4 | 5 | sys_processor.h: 6 | 7 | sys_debug_system.h: 8 | 9 | hardware.h: 10 | 11 | __1802ports.h: 12 | 13 | __1802support.h: 14 | 15 | __1802opcodes.h: 16 | -------------------------------------------------------------------------------- /emulator/framework/debugger.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: debugger.c 5 | // Purpose: Debugger Code (System Independent) 6 | // Created: 1st September 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include 14 | #include "gfx.h" 15 | #include "debugger.h" 16 | 17 | static int isInitialised = 0; // Flag to initialise first time 18 | static int addressSettings[] = { 0,0,0,0xFFFF }; // Adjustable values : Code, Data, Other, Break. 19 | static int keyMapping[16]; // Mapping for control keys to key values 20 | static int inRunMode = 0; // Non zero when free Running 21 | static int lastKey,currentKey; // Last and Current key state 22 | static int stepBreakPoint; // Extra breakpoint used for step over. 23 | static Uint32 nextFrame = 0; // Time of next frame. 24 | 25 | // ******************************************************************************************************************************* 26 | // Handle one frame of rendering etc. for the debugger. 27 | // ******************************************************************************************************************************* 28 | 29 | void GFXXRender(SDL_Surface *surface) { 30 | 31 | if (isInitialised == 0) { // Check if first time 32 | isInitialised = 1; // Now initialised 33 | inRunMode = 0; // Now running 34 | addressSettings[0] = DEBUG_HOMEPC(); // Set default locations 35 | addressSettings[1] = DEBUG_RAMSTART; 36 | addressSettings[3] = 0xFFFF; 37 | DBGDefineKey(DBGKEY_RESET,GFXKEY_F1); // Assign default keys 38 | DBGDefineKey(DBGKEY_SHOW,GFXKEY_TAB); 39 | DBGDefineKey(DBGKEY_STEP,GFXKEY_F7); 40 | DBGDefineKey(DBGKEY_STEPOVER,GFXKEY_F8); 41 | DBGDefineKey(DBGKEY_RUN,GFXKEY_F5); 42 | DBGDefineKey(DBGKEY_BREAK,GFXKEY_F6); 43 | DBGDefineKey(DBGKEY_HOME,GFXKEY_F2); 44 | DBGDefineKey(DBGKEY_SETBREAK,GFXKEY_F9); 45 | lastKey = currentKey = -1; 46 | } 47 | 48 | if (inRunMode != 0 || GFXIsKeyPressed(keyMapping[DBGKEY_SHOW])) // Display system screen if Run or Sjhow 49 | DEBUG_VDURENDER(addressSettings); 50 | else // Otherwise show Debugger screen 51 | DEBUG_CPURENDER(addressSettings); 52 | 53 | currentKey = -1; // Identify which key is pressed. 54 | for (int i = 0;i < 128;i++) { 55 | if (!GFXISMODIFIERKEY(i)) { // Don't return SHIFT and CTRL as keypresses. 56 | if (GFXIsKeyPressed(i)) { 57 | currentKey = i; 58 | } 59 | } 60 | } 61 | if (currentKey != lastKey) { // Key changed 62 | lastKey = currentKey; // Update current key. 63 | currentKey = DEBUG_KEYMAP(currentKey,inRunMode != 0); // Pass keypress to called. 64 | if (currentKey >= 0) { // Key depressed ? 65 | currentKey = toupper(currentKey); // Make it capital. 66 | 67 | #define CMDKEY(n) GFXIsKeyPressed(keyMapping[n]) // Support Macro. 68 | 69 | if (CMDKEY(DBGKEY_RESET)) { // Reset processor (F1) 70 | DEBUG_RESET(); 71 | addressSettings[0] = DEBUG_HOMEPC(); 72 | GFXSetFrequency(0); 73 | } 74 | 75 | if (inRunMode == 0) { 76 | GFXSetFrequency(0); // Will drive us mental otherwise. 77 | if (isxdigit(currentKey)) { // Is it a hex digit 0-9 A-F. 78 | int digit = isdigit(currentKey)?currentKey:(currentKey-'A'+10); // Convert to a number. 79 | int setting = 0; // Which value is being changed ? 80 | if (GFXIsKeyPressed(GFXKEY_SHIFT)) setting = 1; 81 | if (GFXIsKeyPressed(GFXKEY_CONTROL)) setting = 2; 82 | addressSettings[setting] = // Shift it using this macro (so we could use Octal, say) 83 | DEBUG_SHIFT(addressSettings[setting],(digit & 0x0F)); 84 | } 85 | 86 | if (CMDKEY(DBGKEY_HOME)) { // Home pointer (F2) 87 | addressSettings[0] = DEBUG_HOMEPC(); 88 | } 89 | if (CMDKEY(DBGKEY_RUN)) { // Run program (F5) 90 | inRunMode = 1; 91 | stepBreakPoint = -1; 92 | } 93 | if (CMDKEY(DBGKEY_STEP)) { // Execute a single instruction (F7) 94 | DEBUG_SINGLESTEP(); 95 | addressSettings[0] = DEBUG_HOMEPC(); 96 | } 97 | if (CMDKEY(DBGKEY_STEPOVER)) { // Step over program calls (F8) 98 | stepBreakPoint = DEBUG_GETOVERBREAK(); // Where if anywhere should we break ? 99 | if (stepBreakPoint == 0) { // No step over, just single step. 100 | DEBUG_SINGLESTEP(); 101 | addressSettings[0] = DEBUG_HOMEPC(); 102 | } else { 103 | inRunMode = 1; // Run until step break or normal break. 104 | } 105 | } 106 | if (CMDKEY(DBGKEY_SETBREAK)) { // Set Breakpoint (F9) 107 | addressSettings[3] = addressSettings[0]; 108 | } 109 | } else { // In Run mode. 110 | if (CMDKEY(DBGKEY_BREAK)) { 111 | inRunMode = 0; 112 | addressSettings[0] = DEBUG_HOMEPC(); 113 | } 114 | } 115 | } 116 | } 117 | if (inRunMode != 0) { // Running a program. 118 | int frameRate = DEBUG_RUN(addressSettings[3],stepBreakPoint); // Run a frame, or try to. 119 | if (frameRate == 0) { // Run code with step breakpoint, maybe. 120 | inRunMode = 0; // Break has occurred. 121 | } else { 122 | while (SDL_GetTicks() < nextFrame) {}; // Wait for frame timer to elapse. 123 | nextFrame = SDL_GetTicks() + 1000 / frameRate; // And calculate the next sync time. 124 | 125 | } 126 | addressSettings[0] = DEBUG_HOMEPC(); 127 | } 128 | } 129 | 130 | // ******************************************************************************************************************************* 131 | // Redefine a key 132 | // ******************************************************************************************************************************* 133 | 134 | void DBGDefineKey(int keyID,int gfxKey) { 135 | keyMapping[keyID] = gfxKey; 136 | } 137 | 138 | // ******************************************************************************************************************************* 139 | // Draw a vertical set of labels (helper) 140 | // ******************************************************************************************************************************* 141 | 142 | void DBGVerticalLabel(int x,int y,const char *labels[],int fgr,int bgr) { 143 | int n = 0; 144 | while (labels[n] != NULL) { 145 | GFXString(GRID(x,y),labels[n],GRIDSIZE,fgr,bgr); 146 | y++;n++; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /emulator/framework/debugger.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: debugger.h 5 | // Purpose: Debugger Code (System Independent) Header 6 | // Created: 3rd September 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _DEBUGGER_H 13 | #define _DEBUGGER_H 14 | 15 | void DBGVerticalLabel(int x,int y,const char *labels[],int fgr,int bgr); 16 | void DBGDefineKey(int keyID,int gfxKey); 17 | 18 | #include "sys_processor.h" 19 | #include "sys_debug_system.h" 20 | 21 | #define DBGKEY_RESET (0) // Debugger key IDs. 22 | #define DBGKEY_SHOW (1) 23 | #define DBGKEY_STEP (2) 24 | #define DBGKEY_STEPOVER (3) 25 | #define DBGKEY_RUN (4) 26 | #define DBGKEY_BREAK (5) 27 | #define DBGKEY_HOME (6) 28 | #define DBGKEY_SETBREAK (7) 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /emulator/framework/debugger.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/framework/debugger.o -------------------------------------------------------------------------------- /emulator/framework/font.h: -------------------------------------------------------------------------------- 1 | static unsigned char fontdata[] = { 2 | 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 (space) 3 | 0x00, 0x00, 0x5F, 0x00, 0x00, // 0x21 '!' 4 | 0x00, 0x07, 0x00, 0x07, 0x00, // 0x22 '"' 5 | 0x14, 0x7F, 0x14, 0x7F, 0x14, // 0x23 '#' 6 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, // 0x24 '$' 7 | 0x23, 0x13, 0x08, 0x64, 0x62, // 0x25 '%' 8 | 0x36, 0x49, 0x55, 0x22, 0x50, // 0x26 '&' 9 | 0x00, 0x05, 0x03, 0x00, 0x00, // 0x27 ''' 10 | 0x00, 0x1C, 0x22, 0x41, 0x00, // 0x28 '(' 11 | 0x00, 0x41, 0x22, 0x1C, 0x00, // 0x29 ')' 12 | 0x08, 0x2A, 0x1C, 0x2A, 0x08, // 0x2A '*' 13 | 0x08, 0x08, 0x3E, 0x08, 0x08, // 0x2B '+' 14 | 0x00, 0x50, 0x30, 0x00, 0x00, // 0x2C ',' 15 | 0x08, 0x08, 0x08, 0x08, 0x08, // 0x2D '-' 16 | 0x00, 0x60, 0x60, 0x00, 0x00, // 0x2E '.' 17 | 0x20, 0x10, 0x08, 0x04, 0x02, // 0x2F '/' 18 | 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0x30 '0' 19 | 0x00, 0x42, 0x7F, 0x40, 0x00, // 0x31 '1' 20 | 0x42, 0x61, 0x51, 0x49, 0x46, // 0x32 '2' 21 | 0x21, 0x41, 0x45, 0x4B, 0x31, // 0x33 '3' 22 | 0x18, 0x14, 0x12, 0x7F, 0x10, // 0x34 '4' 23 | 0x27, 0x45, 0x45, 0x45, 0x39, // 0x35 '5' 24 | 0x3C, 0x4A, 0x49, 0x49, 0x30, // 0x36 '6' 25 | 0x01, 0x71, 0x09, 0x05, 0x03, // 0x37 '7' 26 | 0x36, 0x49, 0x49, 0x49, 0x36, // 0x38 '8' 27 | 0x06, 0x49, 0x49, 0x29, 0x1E, // 0x39 '9' 28 | 0x00, 0x36, 0x36, 0x00, 0x00, // 0x3A ':' 29 | 0x00, 0x56, 0x36, 0x00, 0x00, // 0x3B ';' 30 | 0x00, 0x08, 0x14, 0x22, 0x41, // 0x3C '<' 31 | 0x14, 0x14, 0x14, 0x14, 0x14, // 0x3D '=' 32 | 0x41, 0x22, 0x14, 0x08, 0x00, // 0x3E '>' 33 | 0x02, 0x01, 0x51, 0x09, 0x06, // 0x3F '?' 34 | 0x32, 0x49, 0x79, 0x41, 0x3E, // 0x40 '@' 35 | 0x7E, 0x11, 0x11, 0x11, 0x7E, // 0x41 'A' 36 | 0x7F, 0x49, 0x49, 0x49, 0x36, // 0x42 'B' 37 | 0x3E, 0x41, 0x41, 0x41, 0x22, // 0x43 'C' 38 | 0x7F, 0x41, 0x41, 0x22, 0x1C, // 0x44 'D' 39 | 0x7F, 0x49, 0x49, 0x49, 0x41, // 0x45 'E' 40 | 0x7F, 0x09, 0x09, 0x01, 0x01, // 0x46 'F' 41 | 0x3E, 0x41, 0x41, 0x51, 0x32, // 0x47 'G' 42 | 0x7F, 0x08, 0x08, 0x08, 0x7F, // 0x48 'H' 43 | 0x00, 0x41, 0x7F, 0x41, 0x00, // 0x49 'I' 44 | 0x20, 0x40, 0x41, 0x3F, 0x01, // 0x4A 'J' 45 | 0x7F, 0x08, 0x14, 0x22, 0x41, // 0x4B 'K' 46 | 0x7F, 0x40, 0x40, 0x40, 0x40, // 0x4C 'L' 47 | 0x7F, 0x02, 0x04, 0x02, 0x7F, // 0x4D 'M' 48 | 0x7F, 0x04, 0x08, 0x10, 0x7F, // 0x4E 'N' 49 | 0x3E, 0x41, 0x41, 0x41, 0x3E, // 0x4F 'O' 50 | 0x7F, 0x09, 0x09, 0x09, 0x06, // 0x50 'P' 51 | 0x3E, 0x41, 0x51, 0x21, 0x5E, // 0x51 'Q' 52 | 0x7F, 0x09, 0x19, 0x29, 0x46, // 0x52 'R' 53 | 0x46, 0x49, 0x49, 0x49, 0x31, // 0x53 'S' 54 | 0x01, 0x01, 0x7F, 0x01, 0x01, // 0x54 'T' 55 | 0x3F, 0x40, 0x40, 0x40, 0x3F, // 0x55 'U' 56 | 0x1F, 0x20, 0x40, 0x20, 0x1F, // 0x56 'V' 57 | 0x7F, 0x20, 0x18, 0x20, 0x7F, // 0x57 'W' 58 | 0x63, 0x14, 0x08, 0x14, 0x63, // 0x58 'X' 59 | 0x03, 0x04, 0x78, 0x04, 0x03, // 0x59 'Y' 60 | 0x61, 0x51, 0x49, 0x45, 0x43, // 0x5A 'Z' 61 | 0x00, 0x00, 0x7F, 0x41, 0x41, // 0x5B '[' 62 | 0x02, 0x04, 0x08, 0x10, 0x20, // 0x5C '\' 63 | 0x41, 0x41, 0x7F, 0x00, 0x00, // 0x5D ']' 64 | 0x04, 0x02, 0x01, 0x02, 0x04, // 0x5E '^' 65 | 0x40, 0x40, 0x40, 0x40, 0x40, // 0x5F '_' 66 | 0x00, 0x01, 0x02, 0x04, 0x00, // 0x60 '`' 67 | 0x20, 0x54, 0x54, 0x54, 0x78, // 0x61 'a' 68 | 0x7F, 0x48, 0x44, 0x44, 0x38, // 0x62 'b' 69 | 0x38, 0x44, 0x44, 0x44, 0x20, // 0x63 'c' 70 | 0x38, 0x44, 0x44, 0x48, 0x7F, // 0x64 'd' 71 | 0x38, 0x54, 0x54, 0x54, 0x18, // 0x65 'e' 72 | 0x08, 0x7E, 0x09, 0x01, 0x02, // 0x66 'f' 73 | 0x08, 0x14, 0x54, 0x54, 0x3C, // 0x67 'g' 74 | 0x7F, 0x08, 0x04, 0x04, 0x78, // 0x68 'h' 75 | 0x00, 0x44, 0x7D, 0x40, 0x00, // 0x69 'i' 76 | 0x20, 0x40, 0x44, 0x3D, 0x00, // 0x6A 'j' 77 | 0x00, 0x7F, 0x10, 0x28, 0x44, // 0x6B 'k' 78 | 0x00, 0x41, 0x7F, 0x40, 0x00, // 0x6C 'l' 79 | 0x7C, 0x04, 0x18, 0x04, 0x78, // 0x6D 'm' 80 | 0x7C, 0x08, 0x04, 0x04, 0x78, // 0x6E 'n' 81 | 0x38, 0x44, 0x44, 0x44, 0x38, // 0x6F 'o' 82 | 0x7C, 0x14, 0x14, 0x14, 0x08, // 0x70 'p' 83 | 0x08, 0x14, 0x14, 0x18, 0x7C, // 0x71 'q' 84 | 0x7C, 0x08, 0x04, 0x04, 0x08, // 0x72 'r' 85 | 0x48, 0x54, 0x54, 0x54, 0x20, // 0x73 's' 86 | 0x04, 0x3F, 0x44, 0x40, 0x20, // 0x74 't' 87 | 0x3C, 0x40, 0x40, 0x20, 0x7C, // 0x75 'u' 88 | 0x1C, 0x20, 0x40, 0x20, 0x1C, // 0x76 'v' 89 | 0x3C, 0x40, 0x30, 0x40, 0x3C, // 0x77 'w' 90 | 0x44, 0x28, 0x10, 0x28, 0x44, // 0x78 'x' 91 | 0x0C, 0x50, 0x50, 0x50, 0x3C, // 0x79 'y' 92 | 0x44, 0x64, 0x54, 0x4C, 0x44, // 0x7A 'z' 93 | 0x00, 0x08, 0x36, 0x41, 0x00, // 0x7B '{' 94 | 0x00, 0x00, 0x7F, 0x00, 0x00, // 0x7C '|' 95 | 0x00, 0x41, 0x36, 0x08, 0x00, // 0x7D '}' 96 | 0x08, 0x08, 0x2A, 0x1C, 0x08, // 0x7E ->' 97 | 0x08, 0x1C, 0x2A, 0x08, 0x08, // 0x7F <-' 98 | }; 99 | 100 | -------------------------------------------------------------------------------- /emulator/framework/gfx.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: gfx.h 5 | // Purpose: Support library for SDL (Header) 6 | // Created: 1st September 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _GFX_H 13 | #define _GFX_H 14 | 15 | #include 16 | #include 17 | 18 | #define GFXKEY_BASE (1) 19 | 20 | #define GFXKEY_UP (GFXKEY_BASE+1) 21 | #define GFXKEY_DOWN (GFXKEY_BASE+2) 22 | #define GFXKEY_LEFT (GFXKEY_BASE+3) 23 | #define GFXKEY_RIGHT (GFXKEY_BASE+4) 24 | #define GFXKEY_LSHIFT (GFXKEY_BASE+5) 25 | #define GFXKEY_CONTROL (GFXKEY_BASE+6) 26 | #define GFXKEY_F1 (GFXKEY_BASE+7) 27 | #define GFXKEY_F2 (GFXKEY_BASE+8) 28 | #define GFXKEY_F3 (GFXKEY_BASE+9) 29 | #define GFXKEY_F4 (GFXKEY_BASE+10) 30 | #define GFXKEY_F5 (GFXKEY_BASE+11) 31 | #define GFXKEY_F6 (GFXKEY_BASE+12) 32 | #define GFXKEY_F7 (GFXKEY_BASE+13) 33 | #define GFXKEY_F8 (GFXKEY_BASE+14) 34 | #define GFXKEY_F9 (GFXKEY_BASE+15) 35 | #define GFXKEY_F10 (GFXKEY_BASE+16) 36 | #define GFXKEY_RETURN (GFXKEY_BASE+17) 37 | #define GFXKEY_BACKSPACE (GFXKEY_BASE+18) 38 | #define GFXKEY_TAB (GFXKEY_BASE+19) 39 | #define GFXKEY_RSHIFT (GFXKEY_BASE+20) 40 | #define GFXKEY_SHIFT (GFXKEY_BASE+21) 41 | #define GFXKEY_F11 (GFXKEY_BASE+22) 42 | #define GFXKEY_F12 (GFXKEY_BASE+23) 43 | 44 | #define GFXISMODIFIERKEY(x) (GFXISCONTROLKEY(x) || GFXISSHIFTKEY(x)) 45 | #define GFXISSHIFTKEY(x) ((x) == GFXKEY_SHIFT || (x) == GFXKEY_RSHIFT || (x) == GFXKEY_LSHIFT) 46 | #define GFXISCONTROLKEY(x) ((x) == GFXKEY_CONTROL) 47 | 48 | #define GRID(x,y) _GFXX(x),_GFXY(y) 49 | #define GRIDSIZE _GFXS() 50 | 51 | int _GFXX(int x); 52 | int _GFXY(int y); 53 | int _GFXS(void); 54 | 55 | void GFXOpenWindow(const char *title,int width,int height,int colour); 56 | void GFXStart(void); 57 | void GFXCloseWindow(void); 58 | 59 | void GFXRectangle(SDL_Rect *rc,int colour); 60 | void GFXCharacter(int xc,int yc,int character,int size,int colour,int back); 61 | void GFXString(int xc,int yc,const char *text,int size,int colour,int back); 62 | void GFXNumber(int xc,int yc,int number,int base,int width,int size,int colour,int back); 63 | int GFXIsKeyPressed(int character); 64 | int GFXToASCII(int ch,int applyModifiers); 65 | int GFXTimer(void); 66 | void GFXSetCharacterSize(int xSize,int ySize); 67 | void GFXDefineCharacter(int nChar,int b1,int b2,int b3,int b4,int b5); 68 | 69 | void GFXXRender(SDL_Surface *surface); 70 | void GFXSetFrequency(int freq); 71 | 72 | class Beeper 73 | { 74 | private: 75 | double freq; 76 | double v; 77 | public: 78 | Beeper(); 79 | ~Beeper(); 80 | void setFrequency(double freq); 81 | void generateSamples(Sint16 *stream, int length); 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /emulator/framework/gfx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/framework/gfx.o -------------------------------------------------------------------------------- /emulator/framework/main.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: main.c 5 | // Purpose: Main program 6 | // Created: 1st September 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include "gfx.h" 14 | #include "sys_processor.h" 15 | #include "sys_debug_system.h" 16 | #include "debugger.h" 17 | 18 | int main(int argc,char *argv[]) { 19 | DEBUG_RESET(); 20 | DEBUG_ARGUMENTS(argc,argv); 21 | GFXOpenWindow(WIN_TITLE,WIN_WIDTH,WIN_HEIGHT,WIN_BACKCOLOUR); 22 | GFXStart(); 23 | GFXCloseWindow(); 24 | return(0); 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /emulator/framework/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/framework/main.o -------------------------------------------------------------------------------- /emulator/go.sh: -------------------------------------------------------------------------------- 1 | asl -L test.asm 2 | p2bin -r 0-2047 -l 0 test.p 3 | rm test.p 4 | dist/Debug/GNU-Linux/emulator test.bin -------------------------------------------------------------------------------- /emulator/hardware.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: hardware.cpp 5 | // Purpose: Hardware Interface 6 | // Created: 1st November 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include "sys_processor.h" 14 | #include "hardware.h" 15 | #include "gfx.h" // Want the keyboard access. 16 | 17 | static WORD16 videoMemoryAddress = 0xFFFF; // 1802 Video Memory Address 18 | static BYTE8 screenIsOn = 0; // 1861 turned on 19 | static BYTE8 *videoMemoryPointer; // Physical screen memory ptr in SRAM 20 | 21 | // ******************************************************************************************************************************* 22 | // Hardware Reset 23 | // ******************************************************************************************************************************* 24 | 25 | void HWIReset(void) { 26 | } 27 | 28 | // ******************************************************************************************************************************* 29 | // Process keys passed from debugger 30 | // ******************************************************************************************************************************* 31 | 32 | BYTE8 HWIProcessKey(BYTE8 key,BYTE8 isRunMode) { 33 | if (isRunMode) { // In run mode, push 0-9 A-F 34 | } 35 | return key; 36 | } 37 | 38 | // ******************************************************************************************************************************* 39 | // Called at End of Frame 40 | // ******************************************************************************************************************************* 41 | 42 | void HWIEndFrame(void) { 43 | } 44 | -------------------------------------------------------------------------------- /emulator/hardware.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: hardware.h 5 | // Purpose: Hardware Interface (header) 6 | // Created: 1st November 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _HARDWARE_H 13 | #define _HARDWARE_H 14 | 15 | BYTE8 HWIProcessKey(BYTE8 key,BYTE8 isRunMode); 16 | void HWIEndFrame(void); 17 | void HWIReset(void); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /emulator/monitor_rom.h: -------------------------------------------------------------------------------- 1 | 0xf8,0x80,0xb2,0xf8,0x8,0xa2,0xe2,0xd2,0x64,0x0,0x62,0xc,0xf8,0xff,0xa1,0xf8, 2 | 0xf,0xb1,0xf8,0xaa,0x51,0x1,0xfb,0xaa,0x32,0x22,0x91,0xff,0x4,0x3b,0x22,0xb1, 3 | 0x30,0x12,0x36,0x28,0x90,0xa0,0xe0,0xd0,0xe1,0xf8,0x0,0x73,0x81,0xfb,0xaf,0x3a, 4 | 0x29,0xf8,0xd2,0x73,0xf8,0x9f,0x51,0x81,0xa0,0x91,0xb0,0xf8,0xcf,0xa1,0xd0,0x73, 5 | 0x20,0x20,0x40,0xff,0x1,0x20,0x50,0xfb,0x82,0x3a,0x3e,0x92,0xb3,0xf8,0x51,0xa3, 6 | 0xd3,0x90,0xb2,0xbb,0xbd,0xf8,0x81,0xb1,0xb4,0xb5,0xb7,0xba,0xbc,0xf8,0x46,0xa1, 7 | 0xf8,0xaf,0xa2,0xf8,0xdd,0xa4,0xf8,0xc6,0xa5,0xf8,0xba,0xa7,0xf8,0xa1,0xac,0xe2, 8 | 0x69,0xdc,0xd7,0xd7,0xd7,0xb6,0xd7,0xd7,0xd7,0xa6,0xd4,0xdc,0xbe,0x32,0xf4,0xfb, 9 | 0xa,0x32,0xef,0xdc,0xae,0x22,0x61,0x9e,0xfb,0xb,0x32,0xc2,0x9e,0xfb,0xf,0x3a, 10 | 0x8f,0xf8,0x6f,0xac,0xf8,0x40,0xb9,0x93,0xf6,0xdc,0x29,0x99,0x3a,0x97,0xf8,0x10, 11 | 0xa7,0xb8,0x8,0xa9,0x46,0xb7,0x93,0xfe,0xdc,0x86,0x3a,0xad,0x2e,0x97,0xf6,0xb7, 12 | 0xdc,0x29,0x89,0x3a,0xad,0x17,0x87,0xf6,0xdc,0x8e,0x3a,0x9e,0xdc,0x69,0x26,0xd4, 13 | 0x30,0xc0,0xf8,0x83,0xac,0xf8,0xa,0xb9,0xdc,0x33,0xc5,0x29,0x99,0x3a,0xc8,0xdc, 14 | 0x3b,0xcf,0xf8,0x9,0xa9,0xa7,0x97,0x76,0xb7,0x29,0xdc,0x89,0x3a,0xd6,0x87,0xf6, 15 | 0x33,0xe3,0x7b,0x97,0x56,0x16,0x86,0x3a,0xcf,0x2e,0x8e,0x3a,0xcf,0x30,0xbd,0xdc, 16 | 0x16,0xd4,0x30,0xef,0xd7,0xd7,0xd7,0x56,0xd4,0x16,0x30,0xf4,0x0,0x0,0x0,0x0, 17 | 0x30,0x39,0x22,0x2a,0x3e,0x20,0x24,0x34,0x26,0x28,0x2e,0x18,0x14,0x1c,0x10,0x12, 18 | 0xf0,0x80,0xf0,0x80,0xf0,0x80,0x80,0x80,0xf0,0x50,0x70,0x50,0xf0,0x50,0x50,0x50, 19 | 0xf0,0x80,0xf0,0x10,0xf0,0x80,0xf0,0x90,0xf0,0x90,0xf0,0x10,0xf0,0x10,0xf0,0x90, 20 | 0xf0,0x90,0x90,0x90,0xf0,0x10,0x10,0x10,0x10,0x60,0x20,0x20,0x20,0x70,0xa0,0xa0, 21 | 0xf0,0x20,0x20,0x7a,0x42,0x70,0x22,0x78,0x22,0x52,0xc4,0x19,0xf8,0x0,0xa0,0x9b, 22 | 0xb0,0xe2,0xe2,0x80,0xe2,0xe2,0x20,0xa0,0xe2,0x20,0xa0,0xe2,0x20,0xa0,0x3c,0x53, 23 | 0x98,0x32,0x67,0xab,0x2b,0x8b,0xb8,0x88,0x32,0x43,0x7b,0x28,0x30,0x44,0xd3,0xf8, 24 | 0xa,0x3b,0x76,0xf8,0x20,0x17,0x7b,0xbf,0xff,0x1,0x3a,0x78,0x39,0x6e,0x7a,0x9f, 25 | 0x30,0x78,0xd3,0xf8,0x10,0x3d,0x85,0x3d,0x8f,0xff,0x1,0x3a,0x87,0x17,0x9c,0xfe, 26 | 0x35,0x90,0x30,0x82,0xd3,0xe2,0x9c,0xaf,0x2f,0x22,0x8f,0x52,0x62,0xe2,0xe2,0x3e, 27 | 0x98,0xf8,0x4,0xa8,0x88,0x3a,0xa4,0xf8,0x4,0xa8,0x36,0xa7,0x88,0x31,0xaa,0x8f, 28 | 0xfa,0xf,0x52,0x30,0x94,0x0,0x0,0x0,0x0,0xd3,0xdc,0xfe,0xfe,0xfe,0xfe,0xae, 29 | 0xdc,0x8e,0xf1,0x30,0xb9,0xd4,0xaa,0xa,0xaa,0xf8,0x5,0xaf,0x4a,0x5d,0x8d,0xfc, 30 | 0x8,0xad,0x2f,0x8f,0x3a,0xcc,0x8d,0xfc,0xd9,0xad,0x30,0xc5,0xd3,0x22,0x6,0x73, 31 | 0x86,0x73,0x96,0x52,0xf8,0x6,0xae,0xf8,0xd8,0xad,0x2,0xf6,0xf6,0xf6,0xf6,0xd5, 32 | 0x42,0xfa,0xf,0xd5,0x8e,0xf6,0xae,0x32,0xdc,0x3b,0xea,0x1d,0x1d,0x30,0xea,0x1 33 | -------------------------------------------------------------------------------- /emulator/nbproject/Makefile-Debug.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a -pre and a -post target defined where you can add customized code. 6 | # 7 | # This makefile implements configuration specific macros and targets. 8 | 9 | 10 | # Environment 11 | MKDIR=mkdir 12 | CP=cp 13 | GREP=grep 14 | NM=nm 15 | CCADMIN=CCadmin 16 | RANLIB=ranlib 17 | CC=gcc 18 | CCC=g++ 19 | CXX=g++ 20 | FC=gfortran 21 | AS=as 22 | 23 | # Macros 24 | CND_PLATFORM=GNU-Linux 25 | CND_DLIB_EXT=so 26 | CND_CONF=Debug 27 | CND_DISTDIR=dist 28 | CND_BUILDDIR=build 29 | 30 | # Include project Makefile 31 | include Makefile 32 | 33 | # Object Directory 34 | OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} 35 | 36 | # Object Files 37 | OBJECTFILES= \ 38 | ${OBJECTDIR}/framework/debugger.o \ 39 | ${OBJECTDIR}/framework/gfx.o \ 40 | ${OBJECTDIR}/framework/main.o \ 41 | ${OBJECTDIR}/hardware.o \ 42 | ${OBJECTDIR}/sys_debug_vip.o \ 43 | ${OBJECTDIR}/sys_processor.o 44 | 45 | 46 | # C Compiler Flags 47 | CFLAGS= 48 | 49 | # CC Compiler Flags 50 | CCFLAGS= 51 | CXXFLAGS= 52 | 53 | # Fortran Compiler Flags 54 | FFLAGS= 55 | 56 | # Assembler Flags 57 | ASFLAGS= 58 | 59 | # Link Libraries and Options 60 | LDLIBSOPTIONS=-lSDL2 61 | 62 | # Build Targets 63 | .build-conf: ${BUILD_SUBPROJECTS} 64 | "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator 65 | 66 | ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator: ${OBJECTFILES} 67 | ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} 68 | ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator ${OBJECTFILES} ${LDLIBSOPTIONS} 69 | 70 | ${OBJECTDIR}/framework/debugger.o: framework/debugger.cpp 71 | ${MKDIR} -p ${OBJECTDIR}/framework 72 | ${RM} "$@.d" 73 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/debugger.o framework/debugger.cpp 74 | 75 | ${OBJECTDIR}/framework/gfx.o: framework/gfx.cpp 76 | ${MKDIR} -p ${OBJECTDIR}/framework 77 | ${RM} "$@.d" 78 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/gfx.o framework/gfx.cpp 79 | 80 | ${OBJECTDIR}/framework/main.o: framework/main.cpp 81 | ${MKDIR} -p ${OBJECTDIR}/framework 82 | ${RM} "$@.d" 83 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/main.o framework/main.cpp 84 | 85 | ${OBJECTDIR}/hardware.o: hardware.cpp 86 | ${MKDIR} -p ${OBJECTDIR} 87 | ${RM} "$@.d" 88 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/hardware.o hardware.cpp 89 | 90 | ${OBJECTDIR}/sys_debug_vip.o: sys_debug_vip.cpp 91 | ${MKDIR} -p ${OBJECTDIR} 92 | ${RM} "$@.d" 93 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_debug_vip.o sys_debug_vip.cpp 94 | 95 | ${OBJECTDIR}/sys_processor.o: sys_processor.cpp 96 | ${MKDIR} -p ${OBJECTDIR} 97 | ${RM} "$@.d" 98 | $(COMPILE.cc) -g -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_processor.o sys_processor.cpp 99 | 100 | # Subprojects 101 | .build-subprojects: 102 | 103 | # Clean Targets 104 | .clean-conf: ${CLEAN_SUBPROJECTS} 105 | ${RM} -r ${CND_BUILDDIR}/${CND_CONF} 106 | 107 | # Subprojects 108 | .clean-subprojects: 109 | 110 | # Enable dependency checking 111 | .dep.inc: .depcheck-impl 112 | 113 | include .dep.inc 114 | -------------------------------------------------------------------------------- /emulator/nbproject/Makefile-Release.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a -pre and a -post target defined where you can add customized code. 6 | # 7 | # This makefile implements configuration specific macros and targets. 8 | 9 | 10 | # Environment 11 | MKDIR=mkdir 12 | CP=cp 13 | GREP=grep 14 | NM=nm 15 | CCADMIN=CCadmin 16 | RANLIB=ranlib 17 | CC=gcc 18 | CCC=g++ 19 | CXX=g++ 20 | FC=gfortran 21 | AS=as 22 | 23 | # Macros 24 | CND_PLATFORM=GNU-Linux 25 | CND_DLIB_EXT=so 26 | CND_CONF=Release 27 | CND_DISTDIR=dist 28 | CND_BUILDDIR=build 29 | 30 | # Include project Makefile 31 | include Makefile 32 | 33 | # Object Directory 34 | OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} 35 | 36 | # Object Files 37 | OBJECTFILES= \ 38 | ${OBJECTDIR}/framework/debugger.o \ 39 | ${OBJECTDIR}/framework/gfx.o \ 40 | ${OBJECTDIR}/framework/main.o \ 41 | ${OBJECTDIR}/hardware.o \ 42 | ${OBJECTDIR}/sys_debug_vip.o \ 43 | ${OBJECTDIR}/sys_processor.o 44 | 45 | 46 | # C Compiler Flags 47 | CFLAGS= 48 | 49 | # CC Compiler Flags 50 | CCFLAGS= 51 | CXXFLAGS= 52 | 53 | # Fortran Compiler Flags 54 | FFLAGS= 55 | 56 | # Assembler Flags 57 | ASFLAGS= 58 | 59 | # Link Libraries and Options 60 | LDLIBSOPTIONS=/usr/lib/libSDL2.so 61 | 62 | # Build Targets 63 | .build-conf: ${BUILD_SUBPROJECTS} 64 | "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator 65 | 66 | ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator: /usr/lib/libSDL2.so 67 | 68 | ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator: ${OBJECTFILES} 69 | ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} 70 | ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator ${OBJECTFILES} ${LDLIBSOPTIONS} 71 | 72 | ${OBJECTDIR}/framework/debugger.o: framework/debugger.cpp 73 | ${MKDIR} -p ${OBJECTDIR}/framework 74 | ${RM} "$@.d" 75 | $(COMPILE.cc) -O2 -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/debugger.o framework/debugger.cpp 76 | 77 | ${OBJECTDIR}/framework/gfx.o: framework/gfx.cpp 78 | ${MKDIR} -p ${OBJECTDIR}/framework 79 | ${RM} "$@.d" 80 | $(COMPILE.cc) -O2 -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/gfx.o framework/gfx.cpp 81 | 82 | ${OBJECTDIR}/framework/main.o: framework/main.cpp 83 | ${MKDIR} -p ${OBJECTDIR}/framework 84 | ${RM} "$@.d" 85 | $(COMPILE.cc) -O2 -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/framework/main.o framework/main.cpp 86 | 87 | ${OBJECTDIR}/hardware.o: hardware.cpp 88 | ${MKDIR} -p ${OBJECTDIR} 89 | ${RM} "$@.d" 90 | $(COMPILE.cc) -O2 -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/hardware.o hardware.cpp 91 | 92 | ${OBJECTDIR}/sys_debug_vip.o: sys_debug_vip.cpp 93 | ${MKDIR} -p ${OBJECTDIR} 94 | ${RM} "$@.d" 95 | $(COMPILE.cc) -O2 -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_debug_vip.o sys_debug_vip.cpp 96 | 97 | ${OBJECTDIR}/sys_processor.o: sys_processor.cpp 98 | ${MKDIR} -p ${OBJECTDIR} 99 | ${RM} "$@.d" 100 | $(COMPILE.cc) -O2 -DINCLUDE_DEBUGGING_SUPPORT -I/usr/include/SDL2 -I. -I./framework -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/sys_processor.o sys_processor.cpp 101 | 102 | # Subprojects 103 | .build-subprojects: 104 | 105 | # Clean Targets 106 | .clean-conf: ${CLEAN_SUBPROJECTS} 107 | ${RM} -r ${CND_BUILDDIR}/${CND_CONF} 108 | ${RM} -r ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libSDL2.so 109 | ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator 110 | 111 | # Subprojects 112 | .clean-subprojects: 113 | 114 | # Enable dependency checking 115 | .dep.inc: .depcheck-impl 116 | 117 | include .dep.inc 118 | -------------------------------------------------------------------------------- /emulator/nbproject/Makefile-impl.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a pre- and a post- target defined where you can add customization code. 6 | # 7 | # This makefile implements macros and targets common to all configurations. 8 | # 9 | # NOCDDL 10 | 11 | 12 | # Building and Cleaning subprojects are done by default, but can be controlled with the SUB 13 | # macro. If SUB=no, subprojects will not be built or cleaned. The following macro 14 | # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf 15 | # and .clean-reqprojects-conf unless SUB has the value 'no' 16 | SUB_no=NO 17 | SUBPROJECTS=${SUB_${SUB}} 18 | BUILD_SUBPROJECTS_=.build-subprojects 19 | BUILD_SUBPROJECTS_NO= 20 | BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} 21 | CLEAN_SUBPROJECTS_=.clean-subprojects 22 | CLEAN_SUBPROJECTS_NO= 23 | CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} 24 | 25 | 26 | # Project Name 27 | PROJECTNAME=emulator 28 | 29 | # Active Configuration 30 | DEFAULTCONF=Debug 31 | CONF=${DEFAULTCONF} 32 | 33 | # All Configurations 34 | ALLCONFS=Debug Release 35 | 36 | 37 | # build 38 | .build-impl: .build-pre .validate-impl .depcheck-impl 39 | @#echo "=> Running $@... Configuration=$(CONF)" 40 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf 41 | 42 | 43 | # clean 44 | .clean-impl: .clean-pre .validate-impl .depcheck-impl 45 | @#echo "=> Running $@... Configuration=$(CONF)" 46 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf 47 | 48 | 49 | # clobber 50 | .clobber-impl: .clobber-pre .depcheck-impl 51 | @#echo "=> Running $@..." 52 | for CONF in ${ALLCONFS}; \ 53 | do \ 54 | "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ 55 | done 56 | 57 | # all 58 | .all-impl: .all-pre .depcheck-impl 59 | @#echo "=> Running $@..." 60 | for CONF in ${ALLCONFS}; \ 61 | do \ 62 | "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ 63 | done 64 | 65 | # build tests 66 | .build-tests-impl: .build-impl .build-tests-pre 67 | @#echo "=> Running $@... Configuration=$(CONF)" 68 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf 69 | 70 | # run tests 71 | .test-impl: .build-tests-impl .test-pre 72 | @#echo "=> Running $@... Configuration=$(CONF)" 73 | "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf 74 | 75 | # dependency checking support 76 | .depcheck-impl: 77 | @echo "# This code depends on make tool being used" >.dep.inc 78 | @if [ -n "${MAKE_VERSION}" ]; then \ 79 | echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \ 80 | echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ 81 | echo "include \$${DEPFILES}" >>.dep.inc; \ 82 | echo "endif" >>.dep.inc; \ 83 | else \ 84 | echo ".KEEP_STATE:" >>.dep.inc; \ 85 | echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ 86 | fi 87 | 88 | # configuration validation 89 | .validate-impl: 90 | @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ 91 | then \ 92 | echo ""; \ 93 | echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ 94 | echo "See 'make help' for details."; \ 95 | echo "Current directory: " `pwd`; \ 96 | echo ""; \ 97 | fi 98 | @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ 99 | then \ 100 | exit 1; \ 101 | fi 102 | 103 | 104 | # help 105 | .help-impl: .help-pre 106 | @echo "This makefile supports the following configurations:" 107 | @echo " ${ALLCONFS}" 108 | @echo "" 109 | @echo "and the following targets:" 110 | @echo " build (default target)" 111 | @echo " clean" 112 | @echo " clobber" 113 | @echo " all" 114 | @echo " help" 115 | @echo "" 116 | @echo "Makefile Usage:" 117 | @echo " make [CONF=] [SUB=no] build" 118 | @echo " make [CONF=] [SUB=no] clean" 119 | @echo " make [SUB=no] clobber" 120 | @echo " make [SUB=no] all" 121 | @echo " make help" 122 | @echo "" 123 | @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," 124 | @echo " also build subprojects." 125 | @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," 126 | @echo " also clean subprojects." 127 | @echo "Target 'clobber' will remove all built files from all configurations and," 128 | @echo " unless 'SUB=no', also from subprojects." 129 | @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," 130 | @echo " also build subprojects." 131 | @echo "Target 'help' prints this message." 132 | @echo "" 133 | 134 | -------------------------------------------------------------------------------- /emulator/nbproject/Makefile-variables.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated - do not edit! 3 | # 4 | # NOCDDL 5 | # 6 | CND_BASEDIR=`pwd` 7 | CND_BUILDDIR=build 8 | CND_DISTDIR=dist 9 | # Debug configuration 10 | CND_PLATFORM_Debug=GNU-Linux 11 | CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux 12 | CND_ARTIFACT_NAME_Debug=emulator 13 | CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/emulator 14 | CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package 15 | CND_PACKAGE_NAME_Debug=emulator.tar 16 | CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/emulator.tar 17 | # Release configuration 18 | CND_PLATFORM_Release=GNU-Linux 19 | CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux 20 | CND_ARTIFACT_NAME_Release=emulator 21 | CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/emulator 22 | CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package 23 | CND_PACKAGE_NAME_Release=emulator.tar 24 | CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/emulator.tar 25 | # 26 | # include compiler specific variables 27 | # 28 | # dmake command 29 | ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ 30 | (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) 31 | # 32 | # gmake command 33 | .PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) 34 | # 35 | include nbproject/private/Makefile-variables.mk 36 | -------------------------------------------------------------------------------- /emulator/nbproject/Package-Debug.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # 4 | # Generated - do not edit! 5 | # 6 | 7 | # Macros 8 | TOP=`pwd` 9 | CND_PLATFORM=GNU-Linux 10 | CND_CONF=Debug 11 | CND_DISTDIR=dist 12 | CND_BUILDDIR=build 13 | CND_DLIB_EXT=so 14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging 15 | TMPDIRNAME=tmp-packaging 16 | OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator 17 | OUTPUT_BASENAME=emulator 18 | PACKAGE_TOP_DIR=emulator/ 19 | 20 | # Functions 21 | function checkReturnCode 22 | { 23 | rc=$? 24 | if [ $rc != 0 ] 25 | then 26 | exit $rc 27 | fi 28 | } 29 | function makeDirectory 30 | # $1 directory path 31 | # $2 permission (optional) 32 | { 33 | mkdir -p "$1" 34 | checkReturnCode 35 | if [ "$2" != "" ] 36 | then 37 | chmod $2 "$1" 38 | checkReturnCode 39 | fi 40 | } 41 | function copyFileToTmpDir 42 | # $1 from-file path 43 | # $2 to-file path 44 | # $3 permission 45 | { 46 | cp "$1" "$2" 47 | checkReturnCode 48 | if [ "$3" != "" ] 49 | then 50 | chmod $3 "$2" 51 | checkReturnCode 52 | fi 53 | } 54 | 55 | # Setup 56 | cd "${TOP}" 57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package 58 | rm -rf ${NBTMPDIR} 59 | mkdir -p ${NBTMPDIR} 60 | 61 | # Copy files and create directories and links 62 | cd "${TOP}" 63 | makeDirectory "${NBTMPDIR}/emulator/bin" 64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 65 | 66 | 67 | # Generate tar file 68 | cd "${TOP}" 69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/emulator.tar 70 | cd ${NBTMPDIR} 71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/emulator.tar * 72 | checkReturnCode 73 | 74 | # Cleanup 75 | cd "${TOP}" 76 | rm -rf ${NBTMPDIR} 77 | -------------------------------------------------------------------------------- /emulator/nbproject/Package-Release.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # 4 | # Generated - do not edit! 5 | # 6 | 7 | # Macros 8 | TOP=`pwd` 9 | CND_PLATFORM=GNU-Linux 10 | CND_CONF=Release 11 | CND_DISTDIR=dist 12 | CND_BUILDDIR=build 13 | CND_DLIB_EXT=so 14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging 15 | TMPDIRNAME=tmp-packaging 16 | OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/emulator 17 | OUTPUT_BASENAME=emulator 18 | PACKAGE_TOP_DIR=emulator/ 19 | 20 | # Functions 21 | function checkReturnCode 22 | { 23 | rc=$? 24 | if [ $rc != 0 ] 25 | then 26 | exit $rc 27 | fi 28 | } 29 | function makeDirectory 30 | # $1 directory path 31 | # $2 permission (optional) 32 | { 33 | mkdir -p "$1" 34 | checkReturnCode 35 | if [ "$2" != "" ] 36 | then 37 | chmod $2 "$1" 38 | checkReturnCode 39 | fi 40 | } 41 | function copyFileToTmpDir 42 | # $1 from-file path 43 | # $2 to-file path 44 | # $3 permission 45 | { 46 | cp "$1" "$2" 47 | checkReturnCode 48 | if [ "$3" != "" ] 49 | then 50 | chmod $3 "$2" 51 | checkReturnCode 52 | fi 53 | } 54 | 55 | # Setup 56 | cd "${TOP}" 57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package 58 | rm -rf ${NBTMPDIR} 59 | mkdir -p ${NBTMPDIR} 60 | 61 | # Copy files and create directories and links 62 | cd "${TOP}" 63 | makeDirectory "${NBTMPDIR}/emulator/bin" 64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 65 | 66 | 67 | # Generate tar file 68 | cd "${TOP}" 69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/emulator.tar 70 | cd ${NBTMPDIR} 71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/emulator.tar * 72 | checkReturnCode 73 | 74 | # Cleanup 75 | cd "${TOP}" 76 | rm -rf ${NBTMPDIR} 77 | -------------------------------------------------------------------------------- /emulator/nbproject/configurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | framework/debugger.cpp 9 | framework/debugger.h 10 | framework/font.h 11 | framework/gfx.cpp 12 | framework/gfx.h 13 | framework/main.cpp 14 | 15 | __1802mnemonics.h 16 | __1802opcodes.h 17 | __1802ports.h 18 | __1802support.h 19 | hardware.h 20 | monitor_rom.h 21 | sys_debug_system.h 22 | sys_processor.h 23 | 24 | 27 | 28 | 31 | 32 | 33 | hardware.cpp 34 | sys_debug_vip.cpp 35 | sys_processor.cpp 36 | 37 | 41 | 42 | 46 | Makefile 47 | 48 | 49 | 50 | framework 51 | 52 | Makefile 53 | 54 | 55 | 56 | default 57 | true 58 | false 59 | 60 | 61 | 62 | 63 | /usr/include/SDL 64 | 65 | 66 | 67 | 68 | /usr/include/SDL2 69 | . 70 | ./framework 71 | 72 | 73 | INCLUDE_DEBUGGING_SUPPORT 74 | 75 | 76 | 77 | 78 | SDL2 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | default 120 | true 121 | false 122 | 123 | 124 | 125 | 5 126 | 127 | /usr/include/SDL 128 | 129 | 130 | 131 | 5 132 | 133 | /usr/include/SDL2 134 | . 135 | ./framework 136 | 137 | 138 | INCLUDE_DEBUGGING_SUPPORT 139 | 140 | 141 | 142 | 5 143 | 144 | 145 | 5 146 | 147 | 148 | 149 | /usr/lib/libSDL2.so 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /emulator/nbproject/private/Makefile-variables.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated - do not edit! 3 | # 4 | # NOCDDL 5 | # 6 | # Debug configuration 7 | # Release configuration 8 | -------------------------------------------------------------------------------- /emulator/nbproject/private/c_standard_headers_indexer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | */ 40 | 41 | // List of standard headers was taken in http://en.cppreference.com/w/c/header 42 | 43 | #include // Conditionally compiled macro that compares its argument to zero 44 | #include // Functions to determine the type contained in character data 45 | #include // Macros reporting error conditions 46 | #include // Limits of float types 47 | #include // Sizes of basic types 48 | #include // Localization utilities 49 | #include // Common mathematics functions 50 | #include // Nonlocal jumps 51 | #include // Signal handling 52 | #include // Variable arguments 53 | #include // Common macro definitions 54 | #include // Input/output 55 | #include // String handling 56 | #include // General utilities: memory management, program utilities, string conversions, random numbers 57 | #include // Time/date utilities 58 | #include // (since C95) Alternative operator spellings 59 | #include // (since C95) Extended multibyte and wide character utilities 60 | #include // (since C95) Wide character classification and mapping utilities 61 | #ifdef _STDC_C99 62 | #include // (since C99) Complex number arithmetic 63 | #include // (since C99) Floating-point environment 64 | #include // (since C99) Format conversion of integer types 65 | #include // (since C99) Boolean type 66 | #include // (since C99) Fixed-width integer types 67 | #include // (since C99) Type-generic math (macros wrapping math.h and complex.h) 68 | #endif 69 | #ifdef _STDC_C11 70 | #include // (since C11) alignas and alignof convenience macros 71 | #include // (since C11) Atomic types 72 | #include // (since C11) noreturn convenience macros 73 | #include // (since C11) Thread library 74 | #include // (since C11) UTF-16 and UTF-32 character utilities 75 | #endif 76 | -------------------------------------------------------------------------------- /emulator/nbproject/private/configurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Makefile 4 | 5 | 6 | 7 | localhost 8 | 2 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | gdb 24 | 25 | 26 | 27 | "${OUTPUT_PATH}" 28 | "${OUTPUT_PATH}" test.bin 29 | 30 | "${OUTPUT_PATH}" test.bin 31 | 32 | true 33 | 0 34 | 0 35 | 36 | 37 | 38 | 39 | 40 | 41 | localhost 42 | 2 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | gdb 58 | 59 | 60 | 61 | "${OUTPUT_PATH}" 62 | 63 | "${OUTPUT_PATH}" 64 | 65 | true 66 | 0 67 | 0 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /emulator/nbproject/private/launcher.properties: -------------------------------------------------------------------------------- 1 | # Launchers File syntax: 2 | # 3 | # [Must-have property line] 4 | # launcher1.runCommand= 5 | # [Optional extra properties] 6 | # launcher1.displayName= 7 | # launcher1.hide= 8 | # launcher1.buildCommand= 9 | # launcher1.runDir= 10 | # launcher1.runInOwnTab= 11 | # launcher1.symbolFiles= 12 | # launcher1.env.= 13 | # (If this value is quoted with ` it is handled as a native command which execution result will become the value) 14 | # [Common launcher properties] 15 | # common.runDir= 16 | # (This value is overwritten by a launcher specific runDir value if the latter exists) 17 | # common.env.= 18 | # (Environment variables from common launcher are merged with launcher specific variables) 19 | # common.symbolFiles= 20 | # (This value is overwritten by a launcher specific symbolFiles value if the latter exists) 21 | # 22 | # In runDir, symbolFiles and env fields you can use these macroses: 23 | # ${PROJECT_DIR} - project directory absolute path 24 | # ${OUTPUT_PATH} - linker output path (relative to project directory path) 25 | # ${OUTPUT_BASENAME}- linker output filename 26 | # ${TESTDIR} - test files directory (relative to project directory path) 27 | # ${OBJECTDIR} - object files directory (relative to project directory path) 28 | # ${CND_DISTDIR} - distribution directory (relative to project directory path) 29 | # ${CND_BUILDDIR} - build directory (relative to project directory path) 30 | # ${CND_PLATFORM} - platform name 31 | # ${CND_CONF} - configuration name 32 | # ${CND_DLIB_EXT} - dynamic library extension 33 | # 34 | # All the project launchers must be listed in the file! 35 | # 36 | # launcher1.runCommand=... 37 | # launcher2.runCommand=... 38 | # ... 39 | # common.runDir=... 40 | # common.env.KEY=VALUE 41 | 42 | # launcher1.runCommand= -------------------------------------------------------------------------------- /emulator/nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 0 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /emulator/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.cnd.makeproject 4 | 5 | 6 | emulator 7 | 8 | cpp 9 | h 10 | UTF-8 11 | 12 | 13 | framework 14 | 15 | 16 | 17 | Debug 18 | 1 19 | 20 | 21 | Release 22 | 1 23 | 24 | 25 | 26 | false 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /emulator/sys_debug_system.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: sys_debug_system.h 5 | // Purpose: Debugger Code (System Dependent) Header 6 | // Created: 1st November 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include "sys_processor.h" 13 | #include "hardware.h" 14 | 15 | #ifndef _DEBUG_SYS_H 16 | #define _DEBUG_SYS_H 17 | #include "sys_processor.h" 18 | 19 | #define WIN_TITLE "1802 Machine Emulator" // Initial Window stuff 20 | #define WIN_WIDTH (32*8*4) 21 | #define WIN_HEIGHT (23*8*4+64) 22 | #define WIN_BACKCOLOUR 0x004 23 | 24 | // ******************************************************************************************************************************* 25 | // These functions need to be implemented by the dependent debugger. 26 | // ******************************************************************************************************************************* 27 | 28 | #define DEBUG_ARGUMENTS(ac,av) if (ac == 2) CPULoadBinary(argv[1]); // Handle CLI arguments 29 | 30 | #define DEBUG_CPURENDER(x) DBGXRender(x,0) // Render the debugging display 31 | #define DEBUG_VDURENDER(x) DBGXRender(x,1) // Render the game display etc. 32 | 33 | #define DEBUG_RESET() CPUReset() // Reset the CPU / Hardware. 34 | #define DEBUG_HOMEPC() ((CPUGetStatus()->pc) & 0xFFFF) // Get PC Home Address (e.g. current PCTR value) 35 | 36 | #define DEBUG_SINGLESTEP() CPUExecuteInstruction() // Execute a single instruction, return 0 or Frame rate on frame end. 37 | #define DEBUG_RUN(b1,b2) CPUExecute(b1,b2) // Run a frame or to breakpoint, returns -1 if breakpoint 38 | #define DEBUG_GETOVERBREAK() CPUGetStepOverBreakpoint() // Where would we break to step over here. (0 == single step) 39 | 40 | #define DEBUG_RAMSTART (0x0000) // Initial RAM address for debugger. 41 | #define DEBUG_SHIFT(d,v) ((((d) << 4) | v) & 0xFFFF) // Shifting into displayed address. 42 | 43 | #define DEBUG_KEYMAP(k,r) HWIProcessKey(k,r) 44 | 45 | void DBGXRender(int *address,int showDisplay); // Render the debugger screen. 46 | void DBGXRenderDisplay(void); 47 | void DBGXLoad(char *file); 48 | 49 | #endif -------------------------------------------------------------------------------- /emulator/sys_debug_vip.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: sys_debug_vip.c 5 | // Purpose: Debugger Code (System Dependent) 6 | // Created: 1st November 2016 7 | // Author: Paul Robson (paul@robsons->org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "gfx.h" 17 | #include "sys_processor.h" 18 | #include "debugger.h" 19 | #include "hardware.h" 20 | 21 | static const char*_mnemonics[256] = { // Mnenonics array. 22 | #include "__1802mnemonics.h" 23 | }; 24 | 25 | #define DBGC_ADDRESS (0x0F0) // Colour scheme. 26 | #define DBGC_DATA (0x0FF) // (Background is in main.c) 27 | #define DBGC_HIGHLIGHT (0xFF0) 28 | 29 | // ******************************************************************************************************************************* 30 | // This renders the debug screen 31 | // ******************************************************************************************************************************* 32 | 33 | static const char *labels[] = { "D","DF","P","X","T","Q","IE","RP","RX","CY","BP", NULL }; 34 | 35 | void DBGXRender(int *address,int showDisplay) { 36 | int n = 0; 37 | char buffer[32]; 38 | CPUSTATUS *s = CPUGetStatus(); 39 | GFXSetCharacterSize(32,23); 40 | DBGVerticalLabel(15,0,labels,DBGC_ADDRESS,-1); // Draw the labels for the register 41 | 42 | #define DN(v,w) GFXNumber(GRID(18,n++),v,16,w,GRIDSIZE,DBGC_DATA,-1) // Helper macro 43 | 44 | n = 0; 45 | DN(s->d,2);DN(s->df,1);DN(s->p,1);DN(s->x,1);DN(s->t,2);DN(s->q,1);DN(s->ie,1); // Registers 46 | DN(s->pc,4);DN(s->r[s->x],4);DN(s->cycles,4);DN(address[3],4); // Others 47 | 48 | for (int i = 0;i < 16;i++) { // 16 bit registers 49 | sprintf(buffer,"R%X",i); 50 | GFXString(GRID(i % 4 * 8,i/4+12),buffer,GRIDSIZE,DBGC_ADDRESS,-1); 51 | GFXString(GRID(i % 4 * 8+2,i/4+12),":",GRIDSIZE,DBGC_HIGHLIGHT,-1); 52 | GFXNumber(GRID(i % 4 * 8+3,i/4+12),s->r[i],16,4,GRIDSIZE,DBGC_DATA,-1); 53 | } 54 | 55 | int a = address[1]; // Dump Memory. 56 | for (int row = 17;row < 23;row++) { 57 | GFXNumber(GRID(2,row),a,16,4,GRIDSIZE,DBGC_ADDRESS,-1); 58 | GFXCharacter(GRID(6,row),':',GRIDSIZE,DBGC_HIGHLIGHT,-1); 59 | for (int col = 0;col < 8;col++) { 60 | GFXNumber(GRID(7+col*3,row),CPUReadMemory(a),16,2,GRIDSIZE,DBGC_DATA,-1); 61 | a = (a + 1) & 0xFFFF; 62 | } 63 | } 64 | 65 | int p = address[0]; // Dump program code. 66 | int opc; 67 | 68 | for (int row = 0;row < 11;row++) { 69 | int isPC = (p == ((s->pc) & 0xFFFF)); // Tests. 70 | int isBrk = (p == address[3]); 71 | GFXNumber(GRID(0,row),p,16,4,GRIDSIZE,isPC ? DBGC_HIGHLIGHT:DBGC_ADDRESS, // Display address / highlight / breakpoint 72 | isBrk ? 0xF00 : -1); 73 | opc = CPUReadMemory(p);p = (p + 1) & 0xFFFF; // Read opcode. 74 | strcpy(buffer,_mnemonics[opc]); // Work out the opcode. 75 | char *at = buffer+strlen(buffer)-2; // 2nd char from end 76 | if (*at == '$') { // Operand ? 77 | if (at[1] == '1') { 78 | sprintf(at,"%02x",CPUReadMemory(p)); 79 | p = (p+1) & 0xFFFF; 80 | } 81 | else if (at[1] == '2') { 82 | sprintf(at,"%02x%02x",CPUReadMemory(p),CPUReadMemory(p+1)); 83 | p = (p+2) & 0xFFFF; 84 | } 85 | } 86 | GFXString(GRID(5,row),buffer,GRIDSIZE,isPC ? DBGC_HIGHLIGHT:DBGC_DATA,-1); // Print the mnemonic 87 | } 88 | 89 | if (showDisplay) { 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /emulator/sys_processor.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: sys_processor.c 5 | // Purpose: Processor Emulation. 6 | // Created: 1st November 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #include 13 | #include "sys_processor.h" 14 | #include "sys_debug_system.h" 15 | #include "hardware.h" 16 | 17 | // ******************************************************************************************************************************* 18 | // Timing 19 | // ******************************************************************************************************************************* 20 | 21 | #define CRYSTAL_CLOCK (2000000L) // Clock cycles per second (2Mhz) 22 | #define CYCLE_RATE (CRYSTAL_CLOCK/8) // Cycles per second (8 clocks per cycle) 23 | #define FRAME_RATE (60) // Frames per second (60) 24 | #define CYCLES_PER_FRAME (CYCLE_RATE / FRAME_RATE) // Cycles per frame (3,728) 25 | 26 | // ******************************************************************************************************************************* 27 | // CPU / Memory 28 | // ******************************************************************************************************************************* 29 | 30 | static BYTE8 ramMemory[MEMORYSIZE]; // R/W Memory 31 | 32 | // ******************************************************************************************************************************* 33 | // Port Interfaces 34 | // ******************************************************************************************************************************* 35 | 36 | 37 | #include "__1802ports.h" // Default connections. 38 | 39 | // ******************************************************************************************************************************* 40 | // Memory and I/O read and write macros. 41 | // ******************************************************************************************************************************* 42 | 43 | 44 | #define READ() MB = ramMemory[MA]; 45 | #define WRITE() ramMemory[MA] = MB; 46 | 47 | #include "__1802support.h" 48 | 49 | 50 | // ******************************************************************************************************************************* 51 | // Reset the CPU 52 | // ******************************************************************************************************************************* 53 | 54 | void CPUReset(void) { 55 | HWIReset(); // Reset hardware 56 | __1802Reset(); // Reset CPU 57 | Cycles = 2000; // So no immediate Interrupt 58 | } 59 | 60 | // ******************************************************************************************************************************* 61 | // Execute a single instruction 62 | // ******************************************************************************************************************************* 63 | 64 | BYTE8 CPUExecuteInstruction(void) { 65 | 66 | FETCH(); // Read the opcode 67 | 68 | switch(MB) { // Execute it. 69 | #include "__1802opcodes.h" 70 | } 71 | Cycles -= 2; // Instruction is two cycles 72 | if ((Cycles & 0x8000) == 0) return 0; // Not completed a frame. 73 | 74 | if (IE != 0) { // and interrupts are enabled and display on. 75 | __1802Interrupt(); // Fire an interrupt 76 | } 77 | HWIEndFrame(); // End of Frame code 78 | Cycles = Cycles + CYCLES_PER_FRAME; // Adjust this frame rate. 79 | return FRAME_RATE; // Return frame rate. 80 | } 81 | 82 | #ifdef INCLUDE_DEBUGGING_SUPPORT 83 | 84 | // ******************************************************************************************************************************* 85 | // Execute chunk of code, to either of two break points or frame-out, return non-zero frame rate on frame, breakpoint 0 86 | // ******************************************************************************************************************************* 87 | 88 | BYTE8 CPUExecute(WORD16 breakPoint1,WORD16 breakPoint2) { 89 | do { 90 | BYTE8 r = CPUExecuteInstruction(); // Execute an instruction 91 | if (r != 0) return r; // Frame out. 92 | } while (R[P] != breakPoint1 && R[P] != breakPoint2); // Stop on breakpoint. 93 | return 0; 94 | } 95 | 96 | // ******************************************************************************************************************************* 97 | // Return address of breakpoint for step-over, or 0 if N/A 98 | // ******************************************************************************************************************************* 99 | 100 | WORD16 CPUGetStepOverBreakpoint(void) { 101 | BYTE8 opcode = CPUReadMemory(R[P]); // Current opcode. 102 | if (opcode >= 0xD0 && opcode <= 0xDF) return ((R[P])+1) & 0xFFFF; // If SEP Rx then step is one after. 103 | return 0; // Do a normal single step 104 | } 105 | 106 | // ******************************************************************************************************************************* 107 | // Read/Write Memory 108 | // ******************************************************************************************************************************* 109 | 110 | BYTE8 CPUReadMemory(WORD16 address) { 111 | BYTE8 _MB = MB;WORD16 _MA = MA;BYTE8 result; 112 | MA = address;READ();result = MB; 113 | MB = _MB;MA = _MA; 114 | return result; 115 | } 116 | 117 | void CPUWriteMemory(WORD16 address,BYTE8 data) { 118 | BYTE8 _MB = MB;WORD16 _MA = MA; 119 | MA = address;MB = data;WRITE(); 120 | MB = _MB;MA = _MA; 121 | } 122 | 123 | // ******************************************************************************************************************************* 124 | // Load a binary file into RAM 125 | // ******************************************************************************************************************************* 126 | 127 | #include 128 | 129 | void CPULoadBinary(const char *fileName) { 130 | FILE *f = fopen(fileName,"rb"); 131 | fread(ramMemory,1,MEMORYSIZE,f); 132 | fclose(f); 133 | } 134 | 135 | // ******************************************************************************************************************************* 136 | // Retrieve a snapshot of the processor 137 | // ******************************************************************************************************************************* 138 | 139 | static CPUSTATUS s; // Status area 140 | 141 | CPUSTATUS *CPUGetStatus(void) { 142 | s.d = D;s.df = DF;s.p = P;s.x = X;s.t = T;s.q = Q;s.ie = IE; // Registers 143 | for (int i = 0;i < 16;i++) s.r[i] = R[i]; // 16 bit Registers 144 | s.cycles = Cycles;s.pc = R[P]; // Cycles and "PC" 145 | return &s; 146 | } 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /emulator/sys_processor.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: sys_processor.h 5 | // Purpose: Processor Emulation (header) 6 | // Created: 1st November 2016 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | #ifndef _PROCESSOR_H 13 | #define _PROCESSOR_H 14 | 15 | #define MEMORYSIZE (65536) // RAM allocated. 16 | 17 | typedef unsigned short WORD16; // 8 and 16 bit types. 18 | typedef unsigned char BYTE8; 19 | 20 | #define DEFAULT_BUS_VALUE (0x00) // What's on the bus if it's not memory. 21 | 22 | void CPUReset(void); 23 | BYTE8 CPUExecuteInstruction(void); 24 | 25 | #ifdef INCLUDE_DEBUGGING_SUPPORT // Only required for debugging 26 | 27 | typedef struct __CPUSTATUS { 28 | int d,df,p,x,t,q,ie,r[16]; // 1802 registers 29 | int cycles; // cycle counter 30 | int pc; // program counter. 31 | } CPUSTATUS; 32 | 33 | CPUSTATUS *CPUGetStatus(void); 34 | BYTE8 CPUExecute(WORD16 breakPoint1,WORD16 breakPoint2); 35 | WORD16 CPUGetStepOverBreakpoint(void); 36 | BYTE8 CPUReadMemory(WORD16 address); 37 | void CPUWriteMemory(WORD16 address,BYTE8 data); 38 | void CPULoadBinary(const char *fileName); 39 | #endif 40 | #endif -------------------------------------------------------------------------------- /emulator/test.asm: -------------------------------------------------------------------------------- 1 | 2 | cpu 1802 3 | 4 | r0 = 0 5 | r1 = 1 6 | r2 = 2 7 | r3 = 3 8 | r4 = 4 9 | r5 = 5 10 | rd = 13 11 | re = 14 12 | rf = 15 13 | 14 | dis 15 | ldi 01Eh 16 | plo r2 ; working stack. 17 | ldi 00h 18 | phi r2 19 | ldi start & 255 20 | plo r4 21 | ldi start / 256 22 | phi r4 23 | sep r4 24 | 25 | org 100h 26 | 27 | v2 = 0FFFFh 28 | v1 = 00001h 29 | 30 | start: 31 | sex r2 32 | dec r2 33 | ldi v1/256 ; set up for 0+ pending 34 | stxd ; X+2 = high byte 35 | ldi v1&255 36 | stxd 37 | ldi '*' 38 | str r2 39 | 40 | ; 41 | ; get next term into RF. 42 | ; 43 | ldi 0 ; RE is used for the counter/total for multiply/divide 44 | phi re 45 | plo re 46 | phi rf ; the RF value is initialised to zero for digit constants. 47 | plo rf 48 | 49 | ldi v2/256 50 | phi rf 51 | ldi v2&255 52 | plo rf 53 | 54 | ; 55 | ; Now we have the right hand term in RF, R(X) points to the operator, then low left then high left 56 | ; 57 | 58 | lda r2 ; restore the operator and pop off the stack. 59 | xri '+' ; is it + (add) 60 | bnz __NotPlus 61 | ; 62 | ; 16 bit addition 63 | ; 64 | glo rf ; low byte 65 | add 66 | str r2 67 | ghi rf ; high byte 68 | inc r2 69 | adc 70 | br __WriteHighAndExit 71 | 72 | __NotPlus: 73 | xri '+'!'*' ; is it * (multiply) 74 | bnz __NotMultiply 75 | ; 76 | ; 16 bit multiplication....... slow but compact. 1 x 65535 about 16 seconds :) 77 | ; 78 | __MultiplyLoop: 79 | glo rf ; check completed (e.g. RF = 0) 80 | bnz __MultiplyContinuing 81 | ghi rf 82 | bz __SaveREtoResult 83 | __MultiplyContinuing: 84 | dec rf ; one fewer add 85 | glo re 86 | add 87 | plo re 88 | ghi re 89 | inc r2 90 | adc 91 | phi re 92 | dec r2 93 | br __MultiplyLoop 94 | 95 | 96 | __NotMultiply: 97 | xri '*'!'/' ; check if it is divide. 98 | bnz __NotAddMulDiv ; it is not + * or / 99 | ; 100 | ; 16 bit division. like multiply, 65535 / 1 takes about 16 seconds :) 101 | ; 102 | glo rf ; check divide by zero (e.g. RF = 0) 103 | bnz __DivideLoop 104 | ghi rf 105 | bz __SaveREToResult ; if RF is zero then return 0 - so n/0 = 0 in this. 106 | __DivideLoop: 107 | glo rf ; subtract once. 108 | sd 109 | plo rd ; save result in RD in case we borrow out. 110 | ghi rf 111 | inc r2 112 | sdb 113 | bnf __DivideCompleted ; if DF = 0 we have finished the division. 114 | stxd ; save a-b back on stack space. 115 | glo rd 116 | str r2 117 | inc re ; we've done it once. 118 | br __DivideLoop 119 | 120 | __DivideCompleted: 121 | ldn r2 ; this is remainder high - TODO: save it 122 | dec r2 123 | ldn r2 ; this is remainder low. - TODO: save it. 124 | 125 | __SaveREToResult: 126 | glo re ; copy RE to the final result. 127 | str r2 128 | inc r2 129 | ghi re 130 | br __WriteHighAndExit 131 | 132 | __NotAddMulDiv: ; we don't know, so we do -, it's probably - > < = 133 | glo rf 134 | sd 135 | str r2 136 | ghi rf 137 | inc r2 138 | sdb 139 | __WriteHighAndExit: 140 | stxd 141 | ; 142 | ; Subtraction. 143 | ; 144 | EndEvaluate: ; R2 points to the result. 145 | br EndEvaluate -------------------------------------------------------------------------------- /emulator/test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/emulator/test.bin -------------------------------------------------------------------------------- /mcm6571-font/font.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulscottrobson/1k-coding-challenge/996fd54bc665d1499838bf431e1540aa06c2177e/mcm6571-font/font.tiff -------------------------------------------------------------------------------- /mcm6571-font/fontrip.py: -------------------------------------------------------------------------------- 1 | import Image,ImageDraw 2 | im = Image.open("font.tiff") 3 | draw = ImageDraw.Draw(im) 4 | print(im.size) 5 | font = [ 0 ] * (128*9) 6 | for ch in range(0,128): 7 | xc = ch % 16 8 | yc = ch / 16 9 | x = xc * (88*4+3)/4 + 9 - yc * 38 / 100 10 | y = yc * 215 / 2 + 10 + xc / 5 11 | 12 | for xp in range(0,7): 13 | for yp in range(0,9): 14 | x2 = x + xp * 10 15 | y2 = y + yp * 11 16 | count = 0 17 | for x3 in range(0,8): 18 | for y3 in range(0,8): 19 | c = im.getpixel((x2+x3,y2+y3)) 20 | c = (c[0]+c[1]+c[2])/3 21 | if c > 128: 22 | count = count + 1 23 | 24 | s = 1 25 | on = count < 45 26 | on = on or (ch == 0 and xp == 6 and yp == 8) 27 | on = on or (ch == 6 and xp == 5 and yp == 7) 28 | on = on or (ch == 13 and xp == 5 and yp == 7) 29 | on = on or (ch == 70 and xp == 0 and yp == 8) 30 | on = on or (ch == ord('M') and xp == 6 and yp >= 3) 31 | on = on or (ch == ord('O') and xp >= 2 and xp <= 4 and yp == 8) 32 | on = on or (ch == 95 and yp == 8) 33 | on = on or (ch == ord('m') and xp == 6 and yp >= 3) 34 | on = on or (ch == ord('o') and xp >= 1 and xp <= 4 and yp == 8) 35 | on = on or (ch == ord('o') and xp == 0 and yp == 7) 36 | 37 | off = (ch == 23 and yp < 3) 38 | off = off or (ch == 52 and xp == 4 and (yp == 2 or yp == 3)) 39 | off = off or (ch == 54 and xp == 3 and (yp == 2 or yp == 1)) 40 | off = off or (ch == 55 and yp == 2 and xp == 3) 41 | off = off or (ch == 38 and yp == 1 and xp == 3) 42 | off = off or (ch == 56 and yp == 2 and xp == 3) 43 | off = off or (ch == 67 and xp == 5 and yp == 3) 44 | off = off or (ch == 68 and xp == 4 and yp == 3) 45 | off = off or (ch == ord('H') and xp == 5 and yp == 3) 46 | off = off or (ch == ord('Q') and xp == 3 and yp == 3) 47 | off = off or (ch == ord('W') and xp == 5 and yp == 4) 48 | off = off or (ch == ord('Y') and xp == 4 and yp == 4) 49 | off = off or (ch == 95 and yp == 0) 50 | off = off or (ch == ord('e') and yp <= 2) 51 | off = off or (ch == ord('g') and xp == 6 and yp == 2) 52 | off = off or (ch == ord('j') and xp == 4 and yp == 1) 53 | off = off or (ch == ord('m') and yp <= 2) 54 | off = off or (ch == ord('m') and xp == 6 and yp == 3) 55 | off = off or (ch == ord('u') and xp == 4 and yp == 5) 56 | 57 | if on and (not off): 58 | draw.rectangle((x2,y2,x2+10-s,y2+11-s),fill = (128,0,0)) 59 | font[ch * 9 + yp] = font[ch * 9 + yp] + (128 >> xp) 60 | else: 61 | draw.rectangle((x2,y2,x2+10-s,y2+11-s),fill = (0,255,255)) 62 | 63 | 64 | 65 | #im.show() 66 | font = [str(x) for x in font] 67 | code = ",".join(font) 68 | code = "static BYTE8 _mcm6571font[] = { " + code + "};" 69 | h = open("mcmfont.h","w") 70 | h.write(code+"\n") 71 | h.close() 72 | -------------------------------------------------------------------------------- /mcm6571-font/mcmfont.h: -------------------------------------------------------------------------------- 1 | static char *_mcm6571font[] = { 0,0,0,0,98,148,136,148,98,120,68,120,68,68,120,64,64,128,0,194,36,40,48,32,96,96,96,96,144,128,128,64,96,144,144,96,0,0,48,64,128,240,128,64,48,44,28,32,64,128,128,112,8,32,0,88,164,36,36,36,4,4,4,48,72,132,132,252,132,132,72,48,0,0,0,128,128,128,128,144,96,0,0,128,144,160,192,160,148,136,128,64,32,32,32,32,48,72,132,0,144,144,144,144,232,128,128,128,0,0,0,196,68,72,80,96,64,16,56,64,48,64,128,120,4,24,0,0,0,48,72,132,132,72,48,0,0,0,126,168,40,40,40,40,48,72,132,132,200,176,128,128,128,0,0,0,62,72,132,132,72,48,0,0,0,126,144,16,16,16,16,0,0,0,196,72,72,72,72,48,32,32,112,168,168,168,112,32,32,0,0,0,0,196,40,16,40,70,16,146,84,84,84,56,16,16,16,0,0,0,68,130,146,146,146,108,0,56,68,130,130,130,68,68,198,62,32,32,32,32,32,160,96,32,0,0,8,4,254,4,8,0,0,0,0,32,64,254,64,32,0,0,16,56,84,16,16,16,16,16,16,0,0,16,0,254,0,16,0,0,254,64,32,16,12,16,32,64,254,0,96,146,12,96,146,12,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,16,16,0,0,16,36,36,36,0,0,0,0,0,0,40,40,40,254,40,254,40,40,40,16,126,144,144,124,18,18,252,16,64,162,68,8,16,32,68,138,4,112,136,136,80,32,82,140,140,114,64,64,128,0,0,0,0,0,0,16,32,64,64,64,64,64,32,16,16,8,4,4,4,4,4,8,16,16,146,84,56,254,56,84,146,16,0,16,16,16,254,16,16,16,0,0,0,0,0,0,96,32,32,64,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,32,0,2,4,8,16,32,64,0,0,124,130,134,138,146,162,194,130,124,16,48,16,16,16,16,16,16,124,124,130,2,4,24,32,64,128,254,124,130,2,2,60,2,2,130,124,4,12,20,36,68,254,4,4,4,254,128,128,128,252,2,2,130,124,124,130,128,128,252,130,130,130,124,254,130,4,8,16,32,32,32,32,124,130,130,130,124,130,130,130,124,126,130,130,130,126,2,2,130,124,0,0,64,0,0,0,64,0,0,64,0,0,0,0,96,32,32,64,8,16,32,64,128,64,32,16,8,0,0,0,254,0,254,0,0,0,32,16,8,4,2,4,8,16,32,124,130,130,4,8,16,16,0,16,124,130,130,154,170,188,128,128,124,56,68,130,130,254,130,130,130,130,252,66,66,66,124,66,66,66,252,60,66,128,128,128,128,128,66,60,252,66,66,66,66,66,66,66,252,254,128,128,128,240,128,128,128,254,254,128,128,128,240,128,128,128,128,60,66,128,128,128,142,130,66,60,130,130,130,130,254,130,130,130,130,124,16,16,16,16,16,16,16,124,62,8,8,8,8,8,8,136,112,130,132,136,144,224,144,136,132,130,128,128,128,128,128,128,128,128,254,130,198,170,146,146,130,130,130,130,130,194,162,146,138,134,130,130,130,56,68,130,130,130,130,130,68,56,252,130,130,130,252,128,128,128,128,56,68,130,130,130,130,138,68,58,252,130,130,130,252,144,136,132,130,124,130,128,128,124,2,2,130,124,254,16,16,16,16,16,16,16,16,130,130,130,130,130,130,130,130,124,130,130,130,130,130,130,68,40,16,130,130,130,146,146,146,170,198,130,130,130,68,40,16,40,68,130,130,130,130,68,40,16,16,16,16,16,254,2,4,8,16,32,64,128,254,60,32,32,32,32,32,32,32,60,0,128,64,32,16,8,4,2,0,120,8,8,8,8,8,8,8,120,124,130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,4,4,2,0,0,0,0,0,0,0,0,0,60,68,132,132,140,116,128,128,128,184,196,132,132,196,184,0,0,0,120,132,128,128,132,120,4,4,4,116,140,132,132,140,116,0,0,0,120,132,132,252,128,124,24,36,32,32,248,32,32,32,32,116,140,132,132,140,116,4,4,120,128,128,128,176,200,132,132,132,132,0,16,0,48,16,16,16,16,16,4,4,4,4,4,4,4,132,120,128,128,128,136,144,224,144,136,132,32,32,32,32,32,32,32,32,32,0,0,0,236,146,146,146,146,146,0,0,0,184,196,132,132,132,132,0,0,0,120,132,132,132,132,120,184,196,132,132,196,184,128,128,128,116,140,132,132,140,116,4,4,4,0,0,0,184,196,128,128,128,128,0,0,0,120,132,96,24,132,120,0,32,32,248,32,32,32,36,24,0,0,0,132,132,132,132,132,120,0,0,0,136,136,136,136,80,32,0,0,0,130,146,146,146,146,108,0,0,0,132,72,48,48,72,132,132,132,132,132,140,116,4,132,120,0,0,0,252,8,16,32,64,252,28,32,32,32,64,32,32,32,28,16,16,16,0,0,16,16,16,0,112,8,8,8,4,8,8,8,112,96,146,12,0,0,0,0,0,0,254,254,254,254,254,254,254,254,254} 2 | -------------------------------------------------------------------------------- /processor/8008.def: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************************************* 2 | // ******************************************************************************************************************************* 3 | // 4 | // Name: 8008.def 5 | // Purpose: 8008 CPU Definition file. 6 | // Created: 23rd October 2015 7 | // Author: Paul Robson (paul@robsons.org.uk) 8 | // 9 | // ******************************************************************************************************************************* 10 | // ******************************************************************************************************************************* 11 | 12 | // ***************************************************************************************************************** 13 | // 14 | // %C Condition name (e.g. NZ) (from bits 3,4,5 of opcode) 15 | // %D Source as A,B,C,D,E,H,M (Bits 3,4,5 of opcode) 16 | // %MAHL Put HL as 16 bit value in MA 17 | // %P Port number as hex (from bits 1,2,3,4,5 of opcode) 18 | // %R Reset address as hex (from bits 3,4,5 of opcode) 19 | // %S Source as A,B,C,D,E,H,M (Bits 0,1,2 of opcode) 20 | // %T Condition test (e.g. (A != 0)) (from bits 3,4,5 of opcode) 21 | // 22 | // ***************************************************************************************************************** 23 | 24 | // ***************************************************************************************************************** 25 | // Index Register Instructions 26 | // ***************************************************************************************************************** 27 | 28 | C0-C6 "MOV A,%S" 5 A = %S // Register -> Register movements 29 | C8-CE "MOV B,%S" 5 B = %S 30 | D0-D6 "MOV C,%S" 5 C = %S 31 | D8-DE "MOV D,%S" 5 D = %S 32 | E0-E6 "MOV E,%S" 5 E = %S 33 | E8-EE "MOV H,%S" 5 H = %S 34 | F0-F6 "MOV L,%S" 5 L = %S 35 | 36 | F8-FE "MOV M,%S" 7 %MAHL;MB = %S;WRITE() // Register -> Memory movements 37 | 38 | C7-F7,8 "MOV %D,M" 8 %MAHL;READ();%D = MB // Memory -> Register movements 39 | 40 | 06-36,8 "MVI %D,@1" 8 FETCH();%D = MB // Load immediate register 41 | 3E "MVI M,@1" 9 FETCH();%MAHL;WRITE() // Load immediate memory 42 | 43 | 08-30,8 "INR %D" 5 pszValue = %D = (%D + 1) & 0xFF // Increment register (not A or M) 44 | 09-31,8 "DCR %D" 5 pszValue = %D = (%D - 1) & 0xFF // Decrement register (not A or M) 45 | 46 | // ***************************************************************************************************************** 47 | // ALU Group Instructions 48 | // ***************************************************************************************************************** 49 | 50 | 80-86 "ADD %S" 5 carry = 0;MB = %S;_BinaryAdd();A = pszValue = MB // Add no carry 51 | 87 "ADD M" 8 carry = 0;%MAHL;READ();_BinaryAdd();A = pszValue = MB 52 | 04 "ADI @1" 8 carry = 0;FETCH();_BinaryAdd();A = pszValue = MB 53 | 54 | 88-8E "ADC %S" 5 MB = %S;_BinaryAdd();A = pszValue = MB // Add with carry 55 | 8F "ADC M" 8 %MAHL;READ();_BinaryAdd();A = pszValue = MB 56 | 0C "ACI @1" 8 FETCH();_BinaryAdd();A = pszValue = MB 57 | 58 | 90-96 "SUB %S" 5 carry = 0;MB = %S;_BinarySubtract();A = pszValue = MB // Sub no borrow 59 | 97 "SUB M" 8 carry = 0;%MAHL;READ();_BinarySubtract();A = pszValue = MB 60 | 14 "SUI @1" 8 carry = 0;FETCH();_BinarySubtract();A = pszValue = MB 61 | 62 | 98-9E "SBB %S" 5 MB = %S;_BinarySubtract();A = pszValue = MB // Sub with borrow 63 | 9F "SBB M" 8 %MAHL;READ();_BinarySubtract();A = pszValue = MB 64 | 1C "SBI @1" 8 FETCH();_BinarySubtract();A = pszValue = MB 65 | 66 | A0-A6 "ANA %S" 5 carry = 0;MB = %S;MB &= A;A = pszValue = MB // Logical And 67 | A7 "ANA M" 8 carry = 0;%MAHL;READ();MB &= A;A = pszValue = MB 68 | 24 "ANI @1" 8 carry = 0;FETCH();MB &= A;A = pszValue = MB 69 | 70 | A8-AE "XRA %S" 5 carry = 0;MB = %S;MB ^= A;A = pszValue = MB // Logical Xor 71 | AF "XRA M" 8 carry = 0;%MAHL;READ();MB ^= A;A = pszValue = MB 72 | 2C "XRI @1" 8 carry = 0;FETCH();MB ^= A;A = pszValue = MB 73 | 74 | B0-B6 "ORA %S" 5 carry = 0;MB = %S;MB |= A;A = pszValue = MB // Logical And 75 | B7 "ORA M" 8 carry = 0;%MAHL;READ();MB |= A;A = pszValue = MB 76 | 34 "ORI @1" 8 carry = 0;FETCH();MB |= A;A = pszValue = MB 77 | 78 | B8-BE "CMP %S" 5 carry = 0;MB = %S;_BinarySubtract();pszValue = MB // Compare (flags sub w/o borrow) 79 | BF "CMP M" 8 carry = 0;%MAHL;READ();_BinarySubtract();pszValue = MB 80 | 3C "CPI @1" 8 carry = 0;FETCH();_BinarySubtract();pszValue = MB 81 | 82 | 02 "RLC" 5 carry = A >> 7;A = (A << 1) | carry; // Rotate A left into carry 83 | 0A "RRC" 5 carry = A & 1;A = (A >> 1) | (carry << 7); // Rotate A right into carry 84 | 85 | 12 "RAL" 5 temp16 = (A << 1)|carry;carry = A>>7;A = temp16 & 0xFF // Rotate A left through carry 86 | 1A "RAR" 5 temp16 = A|(carry << 8);carry = temp16&1;A = temp16>>1 // Rotate A right through carry 87 | 88 | // 89 | // Binary Add/Subtract do MB = A +/- MB +/- carry and set the carry/borrow. 90 | // 91 | 92 | // ***************************************************************************************************************** 93 | // Program Counter and Stack Control instructions 94 | // ***************************************************************************************************************** 95 | 96 | 44-7C,8 "JMP @2" 11 FETCHWORD();JUMP() // Unconditional Jump 97 | 40-78,8 "J%C @2" 10 FETCHWORD();if (%T) JUMP() // Conditional Jump 98 | 99 | 46-7E,8 "CALL @2" 11 FETCHWORD();CALL() // Unconditional Call 100 | 42-7A,8 "C%C @2" 10 FETCHWORD();if (%T) CALL() // Conditional Call 101 | 102 | 07-3F,8 "RET" 5 RETURN() // Unconditional Return 103 | 03-3B,8 "R%C" 4 if (%T) RETURN() // Conditional Return 104 | 105 | 05-3D,8 "RST %R" 5 MA = 0x%R;CALL() // Short call 106 | 107 | // ***************************************************************************************************************** 108 | // Input/Output Instructions 109 | // ***************************************************************************************************************** 110 | 111 | 41-4F,2 "IN %P" 8 MB = 0;INPORT%P();A = MB // Input from port 112 | 51-7F,2 "OUT %P" 6 MB = A;OUTPORT%P() // Output to port 113 | 114 | // ***************************************************************************************************************** 115 | // Machine instructions 116 | // ***************************************************************************************************************** 117 | 118 | 00-01 "HLT" 4 HaltFlag = 1 // Halt instruction 119 | FF "HLT" 4 HaltFlag = 1 120 | -------------------------------------------------------------------------------- /processor/__8008_mnemonics.h: -------------------------------------------------------------------------------- 1 | "hlt","hlt","rlc","rnc","adi @1","rst 00","mvi a,@1","ret","inr b","dcr b","rrc","rnz","aci @1","rst 08","mvi b,@1","ret","inr c","dcr c","ral","rp","sui @1","rst 10","mvi c,@1","ret","inr d","dcr d","rar","rpo","sbi @1","rst 18","mvi d,@1","ret","inr e","dcr e","db 22","rc","ani @1","rst 20","mvi e,@1","ret","inr h","dcr h","db 2a","rz","xri @1","rst 28","mvi h,@1","ret","inr l","dcr l","db 32","rm","ori @1","rst 30","mvi l,@1","ret","db 38","db 39","db 3a","rpe","cpi @1","rst 38","mvi m,@1","ret","jnc @2","in 00","cnc @2","in 01","jmp @2","in 02","call @2","in 03","jnz @2","in 04","cnz @2","in 05","jmp @2","in 06","call @2","in 07","jp @2","out 08","cp @2","out 09","jmp @2","out 0a","call @2","out 0b","jpo @2","out 0c","cpo @2","out 0d","jmp @2","out 0e","call @2","out 0f","jc @2","out 10","cc @2","out 11","jmp @2","out 12","call @2","out 13","jz @2","out 14","cz @2","out 15","jmp @2","out 16","call @2","out 17","jm @2","out 18","cm @2","out 19","jmp @2","out 1a","call @2","out 1b","jpe @2","out 1c","cpe @2","out 1d","jmp @2","out 1e","call @2","out 1f","add a","add b","add c","add d","add e","add h","add l","add m","adc a","adc b","adc c","adc d","adc e","adc h","adc l","adc m","sub a","sub b","sub c","sub d","sub e","sub h","sub l","sub m","sbb a","sbb b","sbb c","sbb d","sbb e","sbb h","sbb l","sbb m","ana a","ana b","ana c","ana d","ana e","ana h","ana l","ana m","xra a","xra b","xra c","xra d","xra e","xra h","xra l","xra m","ora a","ora b","ora c","ora d","ora e","ora h","ora l","ora m","cmp a","cmp b","cmp c","cmp d","cmp e","cmp h","cmp l","cmp m","mov a,a","mov a,b","mov a,c","mov a,d","mov a,e","mov a,h","mov a,l","mov a,m","mov b,a","mov b,b","mov b,c","mov b,d","mov b,e","mov b,h","mov b,l","mov b,m","mov c,a","mov c,b","mov c,c","mov c,d","mov c,e","mov c,h","mov c,l","mov c,m","mov d,a","mov d,b","mov d,c","mov d,d","mov d,e","mov d,h","mov d,l","mov d,m","mov e,a","mov e,b","mov e,c","mov e,d","mov e,e","mov e,h","mov e,l","mov e,m","mov h,a","mov h,b","mov h,c","mov h,d","mov h,e","mov h,h","mov h,l","mov h,m","mov l,a","mov l,b","mov l,c","mov l,d","mov l,e","mov l,h","mov l,l","mov l,m","mov m,a","mov m,b","mov m,c","mov m,d","mov m,e","mov m,h","mov m,l","hlt" -------------------------------------------------------------------------------- /processor/__8008_ports.h: -------------------------------------------------------------------------------- 1 | #ifndef INPORT00 2 | #define INPORT00() {} 3 | #endif 4 | #ifndef INPORT01 5 | #define INPORT01() {} 6 | #endif 7 | #ifndef INPORT02 8 | #define INPORT02() {} 9 | #endif 10 | #ifndef INPORT03 11 | #define INPORT03() {} 12 | #endif 13 | #ifndef INPORT04 14 | #define INPORT04() {} 15 | #endif 16 | #ifndef INPORT05 17 | #define INPORT05() {} 18 | #endif 19 | #ifndef INPORT06 20 | #define INPORT06() {} 21 | #endif 22 | #ifndef INPORT07 23 | #define INPORT07() {} 24 | #endif 25 | #ifndef OUTPORT08 26 | #define OUTPORT08() {} 27 | #endif 28 | #ifndef OUTPORT09 29 | #define OUTPORT09() {} 30 | #endif 31 | #ifndef OUTPORT0A 32 | #define OUTPORT0A() {} 33 | #endif 34 | #ifndef OUTPORT0B 35 | #define OUTPORT0B() {} 36 | #endif 37 | #ifndef OUTPORT0C 38 | #define OUTPORT0C() {} 39 | #endif 40 | #ifndef OUTPORT0D 41 | #define OUTPORT0D() {} 42 | #endif 43 | #ifndef OUTPORT0E 44 | #define OUTPORT0E() {} 45 | #endif 46 | #ifndef OUTPORT0F 47 | #define OUTPORT0F() {} 48 | #endif 49 | #ifndef OUTPORT10 50 | #define OUTPORT10() {} 51 | #endif 52 | #ifndef OUTPORT11 53 | #define OUTPORT11() {} 54 | #endif 55 | #ifndef OUTPORT12 56 | #define OUTPORT12() {} 57 | #endif 58 | #ifndef OUTPORT13 59 | #define OUTPORT13() {} 60 | #endif 61 | #ifndef OUTPORT14 62 | #define OUTPORT14() {} 63 | #endif 64 | #ifndef OUTPORT15 65 | #define OUTPORT15() {} 66 | #endif 67 | #ifndef OUTPORT16 68 | #define OUTPORT16() {} 69 | #endif 70 | #ifndef OUTPORT17 71 | #define OUTPORT17() {} 72 | #endif 73 | #ifndef OUTPORT18 74 | #define OUTPORT18() {} 75 | #endif 76 | #ifndef OUTPORT19 77 | #define OUTPORT19() {} 78 | #endif 79 | #ifndef OUTPORT1A 80 | #define OUTPORT1A() {} 81 | #endif 82 | #ifndef OUTPORT1B 83 | #define OUTPORT1B() {} 84 | #endif 85 | #ifndef OUTPORT1C 86 | #define OUTPORT1C() {} 87 | #endif 88 | #ifndef OUTPORT1D 89 | #define OUTPORT1D() {} 90 | #endif 91 | #ifndef OUTPORT1E 92 | #define OUTPORT1E() {} 93 | #endif 94 | #ifndef OUTPORT1F 95 | #define OUTPORT1F() {} 96 | #endif -------------------------------------------------------------------------------- /processor/build.sh: -------------------------------------------------------------------------------- 1 | python process.py 2 | cp __8008*.* ../emulator 3 | -------------------------------------------------------------------------------- /processor/process.py: -------------------------------------------------------------------------------- 1 | # ******************************************************************************************************************************* 2 | # ******************************************************************************************************************************* 3 | # 4 | # Name: sys_debug_system.h 5 | # Purpose: Debugger Code (System Dependent) Header 6 | # Created: 3rd December 2016 7 | # Author: Paul Robson (paul@robsons.org.uk) 8 | # 9 | # ******************************************************************************************************************************* 10 | # ******************************************************************************************************************************* 11 | 12 | import re 13 | 14 | def process(s,opcode): 15 | s = s.replace("%S","ABCDEHLM"[opcode % 8]) 16 | s = s.replace("%D","ABCDEHLM"[int(opcode/8) % 8]) 17 | s = s.replace("%P","{0:02X}".format(int(opcode / 2) % 32)) 18 | s = s.replace("%R","{0:02X}".format(opcode & 0o070)) 19 | s = s.replace("%MAHL","MA = (H << 8)|L") 20 | s = s.replace("%C",["NC","NZ","P","PO","C","Z","M","PE"][int(opcode / 8) % 8]) 21 | s = s.replace("%T",["carry == 0","pszValue != 0","(pszValue & 0x80) == 0","_IsParityEven(pszValue) == 0","carry != 0","pszValue == 0","(pszValue & 0x80) != 0","_IsParityEven(pszValue) != 0"][int(opcode / 8) % 8]) 22 | return s 23 | 24 | source = open("8008.def").readlines() 25 | source = [x.strip() if x.find("//") < 0 else x[:x.find("//")].strip() for x in source] 26 | source = [x.replace("\t"," ") for x in source if x != ""] 27 | 28 | mnemonics = [ None ] * 256 29 | code = [ None ] * 256 30 | 31 | for l in source: 32 | #print(l) 33 | m = re.match("^([0-9A-F\-\,]+)\s*\"([A-Z\s\@12\%\,]+)\"\s*([0-9]+)\s*(.*)$",l) 34 | assert m is not None 35 | 36 | m2 = re.match("^([0-9A-F\-]+)(.*)$",m.group(1)) 37 | assert m2 is not None 38 | step = 1 if m2.group(2) == "" else int(m2.group(2)[-1]) 39 | m2 = re.match("^([0-9A-F]+)\-([0-9A-F]+)",m2.group(1)+"-"+m2.group(1)) 40 | assert m2 is not None 41 | 42 | opcode = int(m2.group(1),16) 43 | lastOpcode = int(m2.group(2),16) 44 | assert (lastOpcode - opcode) % step == 0 45 | 46 | while opcode <= lastOpcode: 47 | assert mnemonics[opcode] is None 48 | mnemonics[opcode] = process(m.group(2),opcode) 49 | code[opcode] = process(m.group(4),opcode)+";CYCLES("+m.group(3)+");break;" 50 | opcode += step 51 | 52 | for i in range(0,256): 53 | if mnemonics[i] == None: 54 | mnemonics[i] = "db {0:02x}".format(i) 55 | 56 | open("__8008_mnemonics.h","w").write(",".join('"'+x.lower()+'"' for x in mnemonics)) 57 | 58 | ports = [(("INPORT" if r < 8 else "OUTPORT")+"{0:02X}").format(r) for r in range(0,32)] 59 | ports = ["#ifndef {0}\n#define {0}() {{}}\n#endif".format(p.upper()) for p in ports] 60 | open("__8008_ports.h","w").write("\n".join(ports)) 61 | 62 | handle = open("__8008_opcodes.h","w") 63 | for i in range(0,256): 64 | if code[i] is not None: 65 | handle.write("case 0x{0:02x}: /**** {1} ****/\n".format(i,mnemonics[i])) 66 | fcode = code[i].replace(";",";#").split("#") 67 | fcode = [" "+x for x in fcode if x != "" and x != ";"] 68 | handle.write("\n".join(fcode)+"\n"); 69 | 70 | print("8008 core built.") 71 | --------------------------------------------------------------------------------