mirror of
https://github.com/trudnai/Steve2.git
synced 2025-04-14 20:37:33 +00:00
Warning elimination + skeleton of debugger
This commit is contained in:
parent
0717ac7fcb
commit
50ae3a33a4
@ -27,6 +27,8 @@
|
||||
32440BA32480D5C0000F9DA1 /* LoRes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32440BA22480D5C0000F9DA1 /* LoRes.swift */; };
|
||||
324D15D324ADAC71008AAFB0 /* floppy.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 324D15D224ADAC71008AAFB0 /* floppy.png */; };
|
||||
32544195264A6C1600B7E3ED /* DisplayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32544194264A6C1600B7E3ED /* DisplayView.swift */; };
|
||||
325B7611290A0C4100B29605 /* 6502_debugger.c in Sources */ = {isa = PBXBuildFile; fileRef = 325B75DF2909F95000B29605 /* 6502_debugger.c */; };
|
||||
325B761B290A0C4200B29605 /* 6502_debugger.c in Sources */ = {isa = PBXBuildFile; fileRef = 325B75DF2909F95000B29605 /* 6502_debugger.c */; };
|
||||
325DC40E24AC5ABC00EB8858 /* doc.on.doc.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 325DC40D24AC5ABC00EB8858 /* doc.on.doc.png */; };
|
||||
325DC41024AC691B00EB8858 /* rgb_color.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 325DC40F24AC691B00EB8858 /* rgb_color.png */; };
|
||||
325DC41324AC692D00EB8858 /* rgb_mono.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 325DC41124AC692D00EB8858 /* rgb_mono.png */; };
|
||||
@ -1646,6 +1648,7 @@
|
||||
32799F86264B1A5700255669 /* HiRes.swift in Sources */,
|
||||
32799F87264B1A5700255669 /* LoRes.swift in Sources */,
|
||||
32C6995327C5439300D0F25D /* Debugger.swift in Sources */,
|
||||
325B761B290A0C4200B29605 /* 6502_debugger.c in Sources */,
|
||||
327B75D829064FDC00A86A71 /* DebuggerViewController.swift in Sources */,
|
||||
32799F88264B1A5700255669 /* RepeatingTimer.swift in Sources */,
|
||||
32A6AAFA266AEDF50023257A /* mmio.c in Sources */,
|
||||
@ -1667,6 +1670,7 @@
|
||||
32BCCCE9264DBDC8002151C5 /* 6502.c in Sources */,
|
||||
323D04332489BFD80086A901 /* PreferencesWindowController.swift in Sources */,
|
||||
32E3126924A98B9300E61891 /* dsk2woz.c in Sources */,
|
||||
325B7611290A0C4100B29605 /* 6502_debugger.c in Sources */,
|
||||
325EB63623F8F78300C6B4A4 /* disk.c in Sources */,
|
||||
32100A8B2875387300D894EE /* CheatMenu.swift in Sources */,
|
||||
3268B97A27DE7D6A003FBDCC /* disassembler.c in Sources */,
|
||||
|
@ -30,9 +30,9 @@
|
||||
|
||||
|
||||
#ifdef DEBUGGER
|
||||
#define INSTR INLINE static
|
||||
#define INSTR INLINE UNUSED static
|
||||
#else
|
||||
#define INSTR INLINE static
|
||||
#define INSTR INLINE UNUSED static
|
||||
#endif
|
||||
|
||||
#define CRYSTAL_MHZ 14.31818 // NTSC version (original)
|
||||
|
@ -41,14 +41,6 @@
|
||||
#include "speaker.h"
|
||||
|
||||
|
||||
void ViewController_spk_up_play(void);
|
||||
void ViewController_spk_dn_play(void);
|
||||
|
||||
|
||||
volatile cpuMode_s cpuMode = cpuMode_normal;
|
||||
volatile cpuState_s cpuState = cpuState_unknown;
|
||||
|
||||
|
||||
#include "../util/common.h"
|
||||
|
||||
|
||||
@ -58,32 +50,8 @@ volatile cpuState_s cpuState = cpuState_unknown;
|
||||
#define RESET_VECTOR 0xFFFC
|
||||
#define IRQ_VECTOR 0xFFFE
|
||||
|
||||
const unsigned long long int iterations = G;
|
||||
unsigned long long int inst_cnt = 0;
|
||||
|
||||
unsigned int video_fps_divider = DEF_VIDEO_DIV;
|
||||
unsigned int fps = DEFAULT_FPS;
|
||||
|
||||
const double default_MHz_6502 = DEFAULT_MHZ_6502; // default_crystal_MHz / 14; // 1.023; // 2 * M; // 4 * M; // 8 * M; // 16 * M; // 128 * M; // 256 * M; // 512 * M;
|
||||
const double iigs_MHz_6502 = 2.8;
|
||||
const double iicplus_MHz_6502 = 4;
|
||||
const double startup_MHz_6502 = 32;
|
||||
double MHz_6502 = default_MHz_6502;
|
||||
unsigned int clk_6502_per_frm = FRAME_INIT( default_MHz_6502 );
|
||||
unsigned int clk_6502_per_frm_set = FRAME_INIT( default_MHz_6502 );
|
||||
unsigned int clk_6502_per_frm_max_sound = 4 * FRAME_INIT( default_MHz_6502 );
|
||||
unsigned int clk_6502_per_frm_max = 0;
|
||||
|
||||
|
||||
unsigned long long tick_per_sec = G;
|
||||
unsigned long long tick_6502_per_sec = 0;
|
||||
|
||||
|
||||
extern m6502_t m6502;
|
||||
|
||||
const int ecoSpindown = 25; // initial value of ECO Spingdown Counter
|
||||
|
||||
|
||||
#include "../util/disassembler.h"
|
||||
#include "../dev/mem/mmio.h"
|
||||
|
||||
@ -105,56 +73,8 @@ typedef struct {
|
||||
|
||||
#include "6502_instructions.h"
|
||||
|
||||
INLINE int m6502_Step(void) {
|
||||
INLINE int m6502_Disass_1_Instr(void) {
|
||||
|
||||
|
||||
#ifdef DEBUG___
|
||||
switch ( m6502.PC ) {
|
||||
case 0x1E60:
|
||||
printf("Wavy Navy...\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch ( m6502.PC ) {
|
||||
case 0xC600:
|
||||
printf("DISK...\n");
|
||||
break;
|
||||
|
||||
case 0xC62F:
|
||||
printf("DISK IO...\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch ( m6502.PC ) {
|
||||
case 0xE000:
|
||||
dbgPrintf("START...\n");
|
||||
break;
|
||||
|
||||
case 0xF168:
|
||||
dbgPrintf("START...\n");
|
||||
break;
|
||||
|
||||
case 0xF16B:
|
||||
dbgPrintf("START...\n");
|
||||
break;
|
||||
|
||||
case 0xF195: // RAM size init
|
||||
dbgPrintf("START...\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
disNewInstruction();
|
||||
|
||||
switch ( fetch() ) {
|
||||
@ -170,19 +90,8 @@ INLINE int m6502_Step(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
unsigned long long ee = 0;
|
||||
unsigned long long dd = 0;
|
||||
|
||||
// nanosec does not work very well for some reason
|
||||
struct timespec tim = { 0, 400L };
|
||||
|
||||
double mips = 0;
|
||||
double mhz = 0;
|
||||
unsigned long long epoch = 0;
|
||||
|
||||
|
||||
|
||||
void m6502_Run() {
|
||||
void m6502_Disass(void) {
|
||||
|
||||
// init time
|
||||
//#ifdef CLK_WAIT
|
||||
@ -206,165 +115,17 @@ void m6502_Run() {
|
||||
#elif defined( CLK_WAIT )
|
||||
// we clear the clkfrm from ViewController Update()
|
||||
// we will also use this to pause the simulation if not finished by the end of the frame
|
||||
for ( clk_6502_per_frm_max = clk_6502_per_frm; m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Step() )
|
||||
for ( clk_6502_per_frm_max = clk_6502_per_frm; m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Disass_1_Instr() )
|
||||
#else
|
||||
// this is for max speed only -- WARNING! It works only if simulation runs in a completely different thread from the Update()
|
||||
for ( ; ; )
|
||||
#endif
|
||||
{
|
||||
|
||||
}
|
||||
// TODO: clkfrm is already increamented!!!
|
||||
printDisassembly(outdev);
|
||||
|
||||
#ifdef INTERRUPT_CHECK_PER_STEP
|
||||
if ( m6502.IF ) {
|
||||
switch (m6502.interrupt) {
|
||||
case HALT:
|
||||
// CPU is haletd, nothing to do here...
|
||||
return;
|
||||
|
||||
case IRQ:
|
||||
interrupt_IRQ();
|
||||
break;
|
||||
|
||||
case NMI:
|
||||
interrupt_NMI();
|
||||
break;
|
||||
|
||||
case HARDRESET:
|
||||
hardReset();
|
||||
break;
|
||||
|
||||
case SOFTRESET:
|
||||
softReset();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m6502.IF = 0;
|
||||
}
|
||||
#endif // INTERRUPT_CHECK_PER_STEP
|
||||
|
||||
}
|
||||
|
||||
if ( cpuMode == cpuMode_eco ) {
|
||||
// check if this is a busy keyboard poll (aka waiting for user input)
|
||||
if ( m6502.clkfrm - m6502.lastIO < 16 ) {
|
||||
if (m6502.ecoSpindown) {
|
||||
m6502.ecoSpindown--;
|
||||
}
|
||||
else {
|
||||
cpuState = cpuState_halting;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// play the entire sound buffer for this frame
|
||||
spkr_update();
|
||||
// this will take care of turning off disk motor sound when time is up
|
||||
spkr_update_disk_sfx();
|
||||
}
|
||||
|
||||
void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, const uint16_t addr, const uint16_t size ) {
|
||||
|
||||
char fullPath[256];
|
||||
|
||||
strcpy( fullPath, bundlePath );
|
||||
strcat( fullPath, "/");
|
||||
strcat( fullPath, filename );
|
||||
|
||||
FILE * f = fopen(fullPath, "rb");
|
||||
if (f == NULL) {
|
||||
perror("Failed to read ROM image: ");
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(f, 0L, SEEK_END);
|
||||
uint16_t flen = ftell(f);
|
||||
fseek(f, 0L, SEEK_SET);
|
||||
|
||||
if ( size && (size > flen) ) {
|
||||
printf("ROM image is too small (size:0x%04X flen:0x%04X)\n", size, flen);
|
||||
return;
|
||||
}
|
||||
|
||||
fread( rom + addr, 1, size, f);
|
||||
fclose(f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
size_t getFileSize ( const char * fullPath ) {
|
||||
FILE * f = fopen(fullPath, "rb");
|
||||
if (f == NULL) {
|
||||
perror("Failed to get filesize for ROM image: ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(f, 0L, SEEK_END);
|
||||
size_t flen = ftell(f);
|
||||
fseek(f, 0L, SEEK_SET);
|
||||
|
||||
fclose(f);
|
||||
|
||||
return flen;
|
||||
}
|
||||
|
||||
|
||||
void rom_loadFile( const char * bundlePath, const char * filename ) {
|
||||
char fullPath[256];
|
||||
|
||||
strcpy( fullPath, bundlePath );
|
||||
strcat( fullPath, "/");
|
||||
strcat( fullPath, filename );
|
||||
|
||||
printf("Loading ROM: %s\n", filename);
|
||||
|
||||
size_t flen = getFileSize(fullPath);
|
||||
|
||||
if ( flen == 0 ) {
|
||||
return; // there was an error
|
||||
}
|
||||
|
||||
else if ( flen == 32 * KB ) {
|
||||
read_rom( bundlePath, filename, INT_64K_ROM + 0x8000, 0, 32 * KB);
|
||||
memcpy(Apple2_64K_MEM + 0xC000, INT_64K_ROM + 0xC000, 16 * KB); // activate the upper ROM
|
||||
}
|
||||
|
||||
else if ( flen == 16 * KB ) {
|
||||
read_rom( bundlePath, filename, INT_64K_ROM + 0xC000, 0, 16 * KB);
|
||||
memcpy(Apple2_64K_MEM + 0xC000, INT_64K_ROM + 0xC000, 16 * KB);
|
||||
}
|
||||
|
||||
else if ( flen == 12 * KB ) {
|
||||
read_rom( bundlePath, filename, INT_64K_ROM + 0xD000, 0x1000, 12 * KB);
|
||||
memcpy(Apple2_64K_MEM + 0xD000, INT_64K_ROM + 0xD000, 12 * KB);
|
||||
}
|
||||
|
||||
|
||||
// make a copy of the perfieral ROM area -- so it will fall back to this if no card inserted
|
||||
memcpy(EXP_64K_ROM + 0xC100, INT_64K_ROM + 0xC100, 0x0F00);
|
||||
}
|
||||
|
||||
|
||||
void openLog() {
|
||||
#ifdef DISASSEMBLER
|
||||
outdev = fopen("/Users/trudnai/Library/Containers/com.trudnai.steveii/Data/disassembly_new.log", "w+");
|
||||
#endif
|
||||
// for DEBUG ONLY!!! -- use stdout if could not create log file
|
||||
// if (outdev == NULL) {
|
||||
// outdev = stdout;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void closeLog() {
|
||||
if ( ( outdev ) && ( outdev != stdout ) && ( outdev != stderr ) ) {
|
||||
fclose(outdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,24 +55,28 @@ INSTR void JMP( uint16_t addr ) {
|
||||
}
|
||||
|
||||
|
||||
#ifndef DEBUGGER
|
||||
|
||||
// for patching game purposes -- it should not be inline!
|
||||
void CALL( uint16_t addr ) {
|
||||
dbgPrintf("CALL ");
|
||||
disPrintf(disassembly.inst, "CALL");
|
||||
|
||||
#ifndef DEBUGGER
|
||||
PUSH_addr(m6502.PC -1);
|
||||
m6502.PC = addr;
|
||||
#endif
|
||||
}
|
||||
|
||||
// for patching game purposes -- it should not be inline!
|
||||
void JUMP( uint16_t addr ) {
|
||||
dbgPrintf("JUMP ");
|
||||
disPrintf(disassembly.inst, "JUMP");
|
||||
|
||||
m6502.PC = addr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
JSR Jump to New Location Saving Return Address
|
||||
|
||||
|
@ -89,7 +89,7 @@ INSTR void LDX( uint8_t src ) {
|
||||
absolute LDY oper AC 3 4
|
||||
absolute,X LDY oper,X BC 3 4*
|
||||
**/
|
||||
INSTR static void LDY( uint8_t src ) {
|
||||
INSTR void LDY( uint8_t src ) {
|
||||
dbgPrintf("LDY(%02X) ", src);
|
||||
disPrintf(disassembly.inst, "LDY");
|
||||
#ifndef DEBUGGER
|
||||
@ -98,7 +98,7 @@ INSTR static void LDY( uint8_t src ) {
|
||||
}
|
||||
|
||||
|
||||
char * charConv =
|
||||
static char * charConv =
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
|
@ -451,7 +451,7 @@ int spkr_unqueue( ALuint src ) {
|
||||
return processed;
|
||||
}
|
||||
|
||||
void spkr_unqueueAll() {
|
||||
void spkr_unqueueAll(void) {
|
||||
for ( int i = 0; i < SOURCES_COUNT; i++ ) {
|
||||
spkr_unqueue( spkr_src[i] );
|
||||
}
|
||||
@ -976,7 +976,7 @@ INLINE static void spkr_filter() {
|
||||
}
|
||||
|
||||
|
||||
INLINE void spkr_debug_spike() {
|
||||
INLINE void spkr_debug_spike(void) {
|
||||
// printf("spkr_debug_spike: %llu\n", m6502.clktime + m6502.clkfrm);
|
||||
int level = 28000;
|
||||
|
||||
@ -989,7 +989,7 @@ INLINE void spkr_debug_spike() {
|
||||
}
|
||||
|
||||
|
||||
void spkr_play() {
|
||||
void spkr_play(void) {
|
||||
ALenum state;
|
||||
alGetSourcei( spkr_src[SPKR_SRC_GAME_SFX], AL_SOURCE_STATE, &state );
|
||||
// al_check_error();
|
||||
@ -1053,7 +1053,7 @@ void spkr_play() {
|
||||
//}
|
||||
|
||||
|
||||
void spkr_play_with_pause() {
|
||||
void spkr_play_with_pause(void) {
|
||||
ALenum state;
|
||||
alGetSourcei( spkr_src[SPKR_SRC_GAME_SFX], AL_SOURCE_STATE, &state );
|
||||
// al_check_error();
|
||||
@ -1086,7 +1086,7 @@ void spkr_play_with_pause() {
|
||||
}
|
||||
|
||||
|
||||
void spkr_buffer_with_prebuf() {
|
||||
void spkr_buffer_with_prebuf(void) {
|
||||
if (--freeBuffers < 0) {
|
||||
printf("freeBuffer < 0 (%i)\n", freeBuffers);
|
||||
freeBuffers = 0;
|
||||
|
@ -84,7 +84,7 @@ uint8_t * currentLowWRMEM = Apple2_64K_RAM;
|
||||
|
||||
|
||||
/// No writing (Readonly), and mark it as NO need to commit from Shadow RAM
|
||||
INLINE void set_MEM_readonly() {
|
||||
INLINE void set_MEM_readonly(void) {
|
||||
dbgPrintf2("NOWR_AUX (pc:$%04X)\n", m6502.PC);
|
||||
|
||||
MEMcfg.WR_RAM = 0;
|
||||
@ -95,7 +95,7 @@ INLINE void set_MEM_readonly() {
|
||||
|
||||
|
||||
/// Returns TRUE if already writeable or second of the "two consecutive" reads on appropriate soft switches
|
||||
INLINE int is_wr_enabled() {
|
||||
INLINE int is_wr_enabled(void) {
|
||||
uint64_t clk = m6502.clktime + m6502.clkfrm;
|
||||
// uint64_t elapsed = clk - m6502.clk_wrenable;
|
||||
// int is_enabled = ( elapsed < 16 ) || MEMcfg.WR_RAM;
|
||||
@ -111,7 +111,7 @@ INLINE int is_wr_enabled() {
|
||||
|
||||
/// Make AUX RAM writeable -- This is when AUX is also readable, othwrwise use set_AUX_write...
|
||||
/// Note: Need to save the content back from the shadow memory
|
||||
INLINE void set_AUX_read_write() {
|
||||
INLINE void set_AUX_read_write(void) {
|
||||
// two consecutive read or write needs for write enable
|
||||
// Note: if it is already writeable and was previously a ROM read + RAM write, then we also need to bound AUX to MEM
|
||||
if ( is_wr_enabled() ) {
|
||||
@ -127,7 +127,7 @@ INLINE void set_AUX_read_write() {
|
||||
|
||||
/// Make AUX RAM writeable -- This is when ROM is readable, othwrwise use set_MEM_write...
|
||||
/// Note: NO NEED to write back the content since it writes everything directly to AUX memory
|
||||
INLINE void set_AUX_write() {
|
||||
INLINE void set_AUX_write(void) {
|
||||
// will write directly to Auxiliary RAM, and mark it as NO need to commit from Shadow RAM
|
||||
// Note: if it is already writeable and was previously a RAM read + RAM write, then we also need to bound AUX to MEM
|
||||
if ( is_wr_enabled() ) {
|
||||
@ -146,7 +146,7 @@ INLINE void set_AUX_write() {
|
||||
|
||||
|
||||
// save the content of Shadow Memory in needed
|
||||
INLINE void save_AUX() {
|
||||
INLINE void save_AUX(void) {
|
||||
if ( MEMcfg.WR_RAM && MEMcfg.RD_INT_RAM ) {
|
||||
dbgPrintf2("Saving RAM Bank %d to %d (pc:$%04X)\n", MEMcfg.RAM_BANK_2 + 1, (current_RAM_bank == Apple2_64K_AUX + 0xD000) + 1, m6502.PC);
|
||||
// save LC Bank 1 or 2
|
||||
|
@ -75,7 +75,7 @@ uint8_t * shadowScreen = _shadowScreen;
|
||||
int was = 0;
|
||||
|
||||
|
||||
void initHiResLineAddresses() {
|
||||
void initHiResLineAddresses(void) {
|
||||
int i = 0;
|
||||
|
||||
for( int x = 0; x <= 0x50; x += 0x28 ) {
|
||||
@ -88,12 +88,12 @@ void initHiResLineAddresses() {
|
||||
}
|
||||
|
||||
|
||||
void init() {
|
||||
void init(void) {
|
||||
initHiResLineAddresses();
|
||||
}
|
||||
|
||||
|
||||
void hires_clearChanges() {
|
||||
void hires_clearChanges(void) {
|
||||
memset(_blockChanged, 0, sizeof(_blockChanged));
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,13 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define UNUSED __attribute__((unused))
|
||||
|
||||
#ifdef DEBUG
|
||||
#define INLINE
|
||||
#define INLINE UNUSED
|
||||
#else
|
||||
// #define INLINE static __attribute__((always_inline))
|
||||
#define INLINE __attribute__((always_inline))
|
||||
#define INLINE __attribute__((always_inline)) UNUSED
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
disassembly_t disassembly;
|
||||
unsigned long long discnt = 0;
|
||||
|
||||
INLINE flags_t getFlags2() {
|
||||
INLINE flags_t getFlags2(void) {
|
||||
flags_t f = {
|
||||
m6502.C != 0, // Carry Flag
|
||||
m6502.Z != 0, // Zero Flag
|
||||
@ -61,7 +61,7 @@ void _disPrintf( char * s, const size_t n, const char * fmt, ... ) {
|
||||
}
|
||||
}
|
||||
|
||||
void _disNewInstruction() {
|
||||
void _disNewInstruction(void) {
|
||||
if ( m6502.dbgLevel.trace ) {
|
||||
memset( &disassembly, 0, sizeof(disassembly) );
|
||||
disassembly.clk = m6502.clktime + m6502.clkfrm;
|
||||
|
Loading…
x
Reference in New Issue
Block a user