1
0
mirror of https://github.com/mist64/perfect6502.git synced 2024-06-08 12:29:28 +00:00

fix bad function declarations and type casting (bring up to relatively modern standards)

This commit is contained in:
ChrisCoxArt 2021-09-28 17:33:09 -07:00
parent 268d16647c
commit 101b2c9d5d
14 changed files with 162 additions and 133 deletions

10
.gitignore vendored
View File

@ -1,8 +1,2 @@
# emacs-style backup files
*~
# patch detritus
*.orig
*.rej
# object files
cbmbasic
*.o
build
*.xcodeproj

View File

@ -1,16 +1,38 @@
#include <stdio.h>
#include "../perfect6502.h"
#include "runtime.h"
#include "runtime_init.h"
#include <time.h>
/*
See https://www.c64-wiki.com/wiki/C64-Commands
10 PRINT 200 * 25.4
20 PRINT 200 / 3.3333
30 END
RUN
Xeon 3.4 Ghz
original speed: 19611 to 19677 steps per second
original memory usage: 21.3 MB
*/
int
main()
{
int clk = 0;
clock_t start_time, end_time;
void *state = initAndResetChip();
/* set up memory for user program */
init_monitor();
start_time = clock();
/* emulate the 6502! */
for (;;) {
@ -20,6 +42,11 @@ main()
handle_monitor(state);
// chipStatus(state);
//if (!(cycle % 1000)) printf("%d\n", cycle);
if ( (cycle % 20000) == 0 ) {
end_time = clock();
double time = (end_time - start_time)/ (double)(CLOCKS_PER_SEC);
double speed = cycle / time;
printf("cycle %u, speed %g steps per second\n", cycle, speed);
}
};
}

View File

@ -20,11 +20,11 @@ enum {
COLOR_GREY3,
};
void clear_screen();
void up_cursor();
void down_cursor();
void left_cursor();
void right_cursor();
void clear_screen(void);
void up_cursor(void);
void down_cursor(void);
void left_cursor(void);
void right_cursor(void);
void move_cursor(int x, int y);
void get_cursor(int* x, int* y);
void set_color(int c);

View File

@ -16,7 +16,7 @@ static uint16_t PC;
static uint8_t A, X, Y, S, P;
static uint8_t temp_lo, temp_hi;
#define TEMP16 (temp_lo | temp_hi << 8)
#define TEMP16 (uint16_t)( ((uint16_t)temp_lo) | ((uint16_t)temp_hi) << 8)
static uint16_t AB;
static uint8_t DB;
@ -49,7 +49,7 @@ LOAD(uint16_t a)
#define IS_T7 (t & T7)
void
IFETCH()
IFETCH(void)
{
AB = PC;
RW = RW_READ;
@ -57,7 +57,7 @@ IFETCH()
}
void
init()
init(void)
{
t = T1;
ir = 0;
@ -71,7 +71,7 @@ init()
}
void
EOI_INCPC_READPC()
EOI_INCPC_READPC(void)
{
PC++;
t <<= 1;
@ -80,31 +80,31 @@ EOI_INCPC_READPC()
}
void
DB_TO_ADDRLO()
DB_TO_ADDRLO(void)
{
temp_lo = DB;
}
void
DB_TO_ADDRHI()
DB_TO_ADDRHI(void)
{
temp_hi = DB;
}
void
EOI()
EOI(void)
{
t <<= 1;
}
void
EOI_INCPC()
EOI_INCPC(void)
{
PC++;
EOI();
}
void
EOI_INCPC_READADDR()
EOI_INCPC_READADDR(void)
{
EOI_INCPC();
AB = TEMP16;
@ -112,7 +112,7 @@ EOI_INCPC_READADDR()
}
void
EOI_INCPC_WRITEADDR()
EOI_INCPC_WRITEADDR(void)
{
EOI_INCPC();
AB = TEMP16;
@ -120,7 +120,7 @@ EOI_INCPC_WRITEADDR()
}
void
pha()
pha(void)
{
printf("%s",__func__);
if (IS_T2) {
@ -138,7 +138,7 @@ pha()
}
void
plp()
plp(void)
{
printf("%s",__func__);
if (IS_T2) {
@ -162,7 +162,7 @@ plp()
}
void
txs()
txs(void)
{
printf("%s",__func__);
/* T2 */
@ -171,7 +171,7 @@ txs()
}
void
lda_imm()
lda_imm(void)
{
printf("%s",__func__);
/* T2 */
@ -181,7 +181,7 @@ lda_imm()
}
void
ldx_imm()
ldx_imm(void)
{
printf("%s",__func__);
/* T2 */
@ -191,7 +191,7 @@ ldx_imm()
}
void
ldy_imm()
ldy_imm(void)
{
printf("%s",__func__);
/* T2 */
@ -201,7 +201,7 @@ ldy_imm()
}
void
lda_abs()
lda_abs(void)
{
printf("%s",__func__);
if (IS_T2) {
@ -217,7 +217,7 @@ lda_abs()
}
void
sta_abs()
sta_abs(void)
{
printf("%s",__func__);
if (IS_T2) {
@ -235,7 +235,7 @@ sta_abs()
static int cycle = 0;
void
emulate_step()
emulate_step(void)
{
/* memory */
if (RW == RW_READ) {
@ -284,22 +284,22 @@ emulate_step()
}
void
setup_emu()
setup_emu(void)
{
init();
}
void
reset_emu()
reset_emu(void)
{
init();
PC = memory[0xFFFC] | memory[0xFFFD] << 8;
PC = (uint16_t)( memory[0xFFFC] | (((uint16_t)memory[0xFFFD]) << 8) );
printf("PC %x\n", PC);
IFETCH();
}
int
emu_measure_instruction()
emu_measure_instruction(void)
{
for (;;) {

View File

@ -55,8 +55,9 @@
#include "console.h"
static unsigned short
get_chrptr() {
return RAM[0x7A] | RAM[0x7B]<<8;
get_chrptr(void) {
return (unsigned short)(((unsigned short)RAM[0x7A])
| (((unsigned short)RAM[0x7B])<<8));
}
static void
@ -97,19 +98,19 @@ call(unsigned short pc) {
}
static void
check_comma() {
check_comma(void) {
call(0xAEFD);
}
static unsigned short
get_word() {
get_word(void) {
call(0xAD8A);
call(0xB7F7);
return RAM[0x14] | (RAM[0x15]<<8);
return (unsigned short)(((unsigned short)RAM[0x14]) | (((unsigned short)RAM[0x15])<<8));
}
static unsigned char
get_byte() {
get_byte(void) {
call(0xB79E);
return X;
}
@ -120,8 +121,10 @@ get_string(char *s) {
call(0xAD9E);
call(0xB6A3);
for (i = 0; i < A; i++)
s[i] = RAM[(X|(Y<<8))+i];
unsigned short addr = (unsigned short) ( ((unsigned short)X) | (((unsigned short)Y)<<8) );
for (i = 0; i < A; i++) {
s[i] = (char)RAM[addr+i];
}
s[A] = 0;
}
@ -169,7 +172,7 @@ error(unsigned char index) {
* print friendlier strings, or implement "ON ERROR GOTO".
*/
unsigned short
plugin_error() {
plugin_error(void) {
return 0;
}
@ -179,7 +182,7 @@ plugin_error() {
* This gets called whenever we are in direct mode.
*/
unsigned short
plugin_main() {
plugin_main(void) {
return 0;
}
@ -187,7 +190,7 @@ plugin_main() {
* Tokenize BASIC Text
*/
unsigned short
plugin_crnch() {
plugin_crnch(void) {
return 0;
}
@ -195,7 +198,7 @@ plugin_crnch() {
* BASIC Text LIST
*/
unsigned short
plugin_qplop() {
plugin_qplop(void) {
return 0;
}
@ -205,7 +208,7 @@ plugin_qplop() {
* This is used for interpreting statements.
*/
unsigned short
plugin_gone() {
plugin_gone(void) {
set_chrptr(get_chrptr()+1);
for (;;) {
unsigned short chrptr;
@ -282,6 +285,6 @@ plugin_gone() {
* New functions and operators go here.
*/
unsigned short
plugin_eval() {
plugin_eval(void) {
return 0;
}

View File

@ -1,7 +1,7 @@
#define WIN32_LEAN_AND_MEAN
#include <errno.h>
#include <stdlib.h>
#include <windows.h> // FindFirstFile, FindNextFile
//#include <windows.h> // FindFirstFile, FindNextFile
#include "readdir.h"
typedef struct dir_private

View File

@ -162,7 +162,7 @@ init_os(int argc, char **argv) {
if (fgetc(input_file)=='#') {
char c;
do {
c = fgetc(input_file);
c = (char) fgetc(input_file);
} while((c!=13)&&(c!=10));
} else {
fseek(input_file, 0, SEEK_SET);
@ -182,13 +182,13 @@ int plugin = 0;
void
replace_vector(unsigned short address, unsigned short new, unsigned short *old) {
*old = RAM[address] | (RAM[address+1]<<8);
*old = (unsigned short)( (unsigned short)RAM[address] | (((unsigned short)RAM[address+1])<<8) );
RAM[address] = (new)&0xFF;
RAM[address+1] = (new)>>8;
}
void
plugin_on() {
plugin_on(void) {
if (plugin)
return;
@ -203,7 +203,7 @@ plugin_on() {
}
static void
plugin_off() {
plugin_off(void) {
unsigned short dummy;
if (!plugin)
@ -220,13 +220,13 @@ plugin_off() {
}
static void
SETMSG() {
SETMSG(void) {
kernal_msgflag = A;
A = kernal_status;
}
static void
MEMTOP() {
MEMTOP(void) {
#if DEBUG /* CBMBASIC doesn't do this */
if (!C) {
printf("UNIMPL: set top of RAM");
@ -245,7 +245,7 @@ MEMTOP() {
/* MEMBOT */
static void
MEMBOT() {
MEMBOT(void) {
#if DEBUG /* CBMBASIC doesn't do this */
if (!C) {
printf("UNIMPL: set bot of RAM");
@ -258,13 +258,13 @@ MEMBOT() {
/* READST */
static void
READST() {
READST(void) {
A = kernal_status;
}
/* SETLFS */
static void
SETLFS() {
SETLFS(void) {
kernal_lfn = A;
kernal_dev = X;
kernal_sec = Y;
@ -272,14 +272,14 @@ SETLFS() {
/* SETNAM */
static void
SETNAM() {
kernal_filename = X | Y<<8;
SETNAM(void) {
kernal_filename = (unsigned short)( ((unsigned short)X) | (((unsigned short)Y)<<8) );
kernal_filename_len = A;
}
/* OPEN */
static void
OPEN() {
OPEN(void) {
kernal_status = 0;
if (kernal_files[kernal_lfn]) {
C = 1;
@ -305,7 +305,7 @@ OPEN() {
/* CLOSE */
static void
CLOSE() {
CLOSE(void) {
if (!kernal_files[kernal_lfn]) {
C = 1;
A = KERN_ERR_FILE_NOT_OPEN;
@ -318,7 +318,7 @@ CLOSE() {
/* CHKIN */
static void
CHKIN() {
CHKIN(void) {
kernal_status = 0;
if (!kernal_files[X]) {
C = 1;
@ -332,7 +332,7 @@ CHKIN() {
/* CHKOUT */
static void
CHKOUT() {
CHKOUT(void) {
kernal_status = 0;
if (!kernal_files[X]) {
C = 1;
@ -346,7 +346,7 @@ CHKOUT() {
/* CLRCHN */
static void
CLRCHN() {
CLRCHN(void) {
kernal_input = 0;
kernal_output = 0;
}
@ -358,7 +358,7 @@ int fakerun_index = 0;
/* CHRIN */
static void
CHRIN() {
CHRIN(void) {
if ((!interactive) && (readycount==2)) {
exit(0);
}
@ -370,25 +370,25 @@ CHRIN() {
} else {
if (kernal_files_next[kernal_input] == EOF)
kernal_files_next[kernal_input] = fgetc(kernal_files[kernal_input]);
A = kernal_files_next[kernal_input];
A = (unsigned char) kernal_files_next[kernal_input];
kernal_files_next[kernal_input] = fgetc(kernal_files[kernal_input]);
if (kernal_files_next[kernal_input] == EOF)
kernal_status |= KERN_ST_EOF;
}
} else if (!input_file) {
A = getchar(); /* stdin */
A = (unsigned char) getchar(); /* stdin */
if (A=='\n') A = '\r';
} else {
if (fakerun) {
A = run[fakerun_index++];
A = (unsigned char) run[fakerun_index++];
if (fakerun_index==sizeof(run))
input_file = 0; /* switch to stdin */
} else {
A = fgetc(input_file);
A = (unsigned char) fgetc(input_file);
if ((A==255)&&(readycount==1)) {
fakerun = 1;
fakerun_index = 0;
A = run[fakerun_index++];
A = (unsigned char) run[fakerun_index++];
}
if (A=='\n') A = '\r';
}
@ -398,7 +398,7 @@ CHRIN() {
/* CHROUT */
static void
CHROUT() {
CHROUT(void) {
//return;
//exit(1);
#if 0
@ -550,7 +550,7 @@ printf("CHROUT: %d @ %x,%x,%x,%x\n", A, a, b, c, d);
/* LOAD */
static void
LOAD() {
LOAD(void) {
FILE *f;
struct stat st;
unsigned short start;
@ -599,13 +599,13 @@ LOAD() {
while ((dp = readdir(dirp))) {
size_t namlen = strlen(dp->d_name);
stat(dp->d_name, &st);
file_size = (st.st_size + 253)/254; /* convert file size from num of bytes to num of blocks(254 bytes) */
file_size = (int) ((st.st_size + 253)/254); /* convert file size from num of bytes to num of blocks(254 bytes) */
if (file_size>0xFFFF)
file_size = 0xFFFF;
old_memp = memp;
memp += 2;
RAM[memp++] = file_size & 0xFF;
RAM[memp++] = file_size >> 8;
RAM[memp++] = (unsigned char)(file_size & 0xFF);
RAM[memp++] = (unsigned char)(file_size >> 8);
if (file_size<1000) {
RAM[memp++] = ' ';
if (file_size<100) {
@ -621,7 +621,7 @@ LOAD() {
memcpy(&RAM[memp], dp->d_name, namlen);
memp += namlen;
RAM[memp++] = '"';
for (i=namlen; i<16; i++)
for (i=(int)namlen; i<16; i++)
RAM[memp++] = ' ';
RAM[memp++] = ' ';
RAM[memp++] = 'P';
@ -667,10 +667,10 @@ for (i=0; i<255; i++) {
f = fopen((char*)&RAM[kernal_filename], "rb");
if (!f)
goto file_not_found;
start = ((unsigned char)fgetc(f)) | ((unsigned char)fgetc(f))<<8;
start = (unsigned short)( (unsigned char)fgetc(f) | (((unsigned short)fgetc(f))<<8) );
if (!kernal_sec)
start = X | Y<<8;
end = start + fread(&RAM[start], 1, 65536-start, f); /* TODO may overwrite ROM */
start = (unsigned short)(X | (((unsigned short)Y)<<8) );
end = (unsigned short)( start + fread(&RAM[start], 1, 65536-start, f) ); /* TODO may overwrite ROM */
printf("LOADING FROM $%04X to $%04X\n", start, end);
fclose(f);
@ -696,14 +696,14 @@ missing_file_name:
/* SAVE */
static void
SAVE() {
SAVE(void) {
FILE *f;
unsigned char savedbyte;
unsigned short start;
unsigned short end;
start = RAM[A] | RAM[A+1]<<8;
end = X | Y << 8;
start = (unsigned short)( RAM[A] | (((unsigned short)RAM[A+1])<<8) );
end = (unsigned short)( X | (((unsigned short)Y) << 8) );
if (end<start) {
C = 1;
A = KERN_ERR_NONE;
@ -732,7 +732,7 @@ SAVE() {
/* SETTIM */
static void
SETTIM() {
SETTIM(void) {
unsigned long jiffies = Y*65536 + X*256 + A;
unsigned long seconds = jiffies/60;
#ifdef _WIN32
@ -751,9 +751,9 @@ SETTIM() {
localtime_r(&now, &bd);
bd.tm_sec = seconds%60;
bd.tm_min = seconds/60;
bd.tm_hour = seconds/3600;
bd.tm_sec = (int)(seconds%60);
bd.tm_min = (int)(seconds/60);
bd.tm_hour = (int)(seconds/3600);
tv.tv_sec = mktime(&bd);
tv.tv_usec = (jiffies % 60) * (1000000/60);
@ -764,7 +764,7 @@ SETTIM() {
/* RDTIM */
static void
RDTIM() {
RDTIM(void) {
unsigned long jiffies;
#ifdef _WIN32
SYSTEMTIME st;
@ -779,7 +779,7 @@ RDTIM() {
localtime_r(&now, &bd);
gettimeofday(&tv, 0);
jiffies = ((bd.tm_hour*60 + bd.tm_min)*60 + bd.tm_sec)*60 + tv.tv_usec / (1000000/60);
jiffies = (unsigned long)( ((bd.tm_hour*60 + bd.tm_min)*60 + bd.tm_sec)*60 + tv.tv_usec / (1000000/60) );
#endif
Y = (unsigned char)(jiffies/65536);
X = (unsigned char)((jiffies%65536)/256);
@ -789,13 +789,13 @@ RDTIM() {
/* STOP */
static void
STOP() {
STOP(void) {
SETZ(0); /* TODO we don't support the STOP key */
}
/* GETIN */
static void
GETIN() {
GETIN(void) {
if (kernal_input != 0) {
if (feof(kernal_files[kernal_input])) {
kernal_status |= KERN_ST_EOF;
@ -804,7 +804,7 @@ GETIN() {
} else {
if (kernal_files_next[kernal_input] == EOF)
kernal_files_next[kernal_input] = fgetc(kernal_files[kernal_input]);
A = kernal_files_next[kernal_input];
A = (unsigned char) kernal_files_next[kernal_input];
kernal_files_next[kernal_input] = fgetc(kernal_files[kernal_input]);
if (kernal_files_next[kernal_input] == EOF)
kernal_status |= KERN_ST_EOF;
@ -813,11 +813,11 @@ GETIN() {
} else {
#ifdef _WIN32
if (_kbhit())
A = _getch();
A = (unsigned char) _getch();
else
A = 0;
#else
A = getchar();
A = (unsigned char) getchar();
#endif
if (A=='\n') A = '\r';
C = 0;
@ -826,8 +826,8 @@ GETIN() {
/* CLALL */
static void
CLALL() {
int i;
CLALL(void) {
size_t i;
for (i = 0; i < sizeof(kernal_files)/sizeof(kernal_files[0]); ++i) {
if (kernal_files[i]) {
fclose(kernal_files[i]);
@ -838,12 +838,12 @@ CLALL() {
/* PLOT */
static void
PLOT() {
PLOT(void) {
if (C) {
int CX, CY;
get_cursor(&CX, &CY);
Y = CX;
X = CY;
Y = (unsigned char) CX;
X = (unsigned char) CY;
} else {
printf("UNIMPL: set cursor %d %d\n", Y, X);
exit(1);
@ -853,7 +853,7 @@ PLOT() {
/* IOBASE */
static void
IOBASE() {
IOBASE(void) {
#define CIA 0xDC00 /* we could put this anywhere... */
/*
* IOBASE is just used inside RND to get a timer value.
@ -863,19 +863,19 @@ IOBASE() {
*/
int pseudo_timer;
pseudo_timer = rand();
RAM[CIA+4] = pseudo_timer&0xff;
RAM[CIA+5] = pseudo_timer>>8;
RAM[CIA+4] = (unsigned char) (pseudo_timer&0xff);
RAM[CIA+5] = (unsigned char) (pseudo_timer>>8);
pseudo_timer = rand(); /* more entropy! */
RAM[CIA+8] = pseudo_timer&0xff;
RAM[CIA+9] = pseudo_timer>>8;
RAM[CIA+8] = (unsigned char) (pseudo_timer&0xff);
RAM[CIA+9] = (unsigned char) (pseudo_timer>>8);
X = CIA & 0xFF;
Y = CIA >> 8;
}
int
kernal_dispatch() {
kernal_dispatch(void) {
//{ printf("kernal_dispatch $%04X; ", PC); int i; printf("stack (%02X): ", S); for (i=S+1; i<0x100; i++) { printf("%02X ", RAM[0x0100+i]); } printf("\n"); }
unsigned int new_pc;
unsigned short new_pc;
switch(PC) {
case 0x0073: CHRGET(); break;
case 0x0079: CHRGOT(); break;

View File

@ -1 +1 @@
void handle_monitor();
void handle_monitor(void *state);

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include "../perfect6502.h"
/* XXX hook up memory[] with RAM[] in runtime.c */
@ -9,7 +10,7 @@
*
************************************************************/
extern int kernal_dispatch();
extern int kernal_dispatch(void);
/* imported by runtime.c */
unsigned char A, X, Y, S, P;
@ -17,10 +18,14 @@ unsigned short PC;
int N, Z, C;
void
init_monitor()
init_monitor(void)
{
FILE *f;
f = fopen("cbmbasic/cbmbasic.bin", "r");
f = fopen("cbmbasic/cbmbasic.bin", "rb");
if (f == NULL) {
fprintf(stderr,"Could not open cmbasic file\n");
exit(-1);
}
fread(memory + 0xA000, 1, 17591, f);
fclose(f);

View File

@ -1 +1 @@
void init_monitor();
void init_monitor(void);

View File

@ -698,7 +698,7 @@ isNodeHigh(state_t *state, nodenum_t nn)
unsigned int
readNodes(state_t *state, int count, nodenum_t *nodelist)
{
int result = 0;
unsigned int result = 0;
for (int i = count - 1; i >= 0; i--) {
result <<= 1;
result |= isNodeHigh(state, nodelist[i]);

View File

@ -35,13 +35,13 @@
uint16_t
readAddressBus(void *state)
{
return readNodes(state, 16, (nodenum_t[]){ ab0, ab1, ab2, ab3, ab4, ab5, ab6, ab7, ab8, ab9, ab10, ab11, ab12, ab13, ab14, ab15 });
return (uint16_t)readNodes(state, 16, (nodenum_t[]){ ab0, ab1, ab2, ab3, ab4, ab5, ab6, ab7, ab8, ab9, ab10, ab11, ab12, ab13, ab14, ab15 });
}
uint8_t
readDataBus(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ db0, db1, db2, db3, db4, db5, db6, db7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ db0, db1, db2, db3, db4, db5, db6, db7 });
}
void
@ -59,55 +59,55 @@ readRW(void *state)
uint8_t
readA(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ a0,a1,a2,a3,a4,a5,a6,a7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ a0,a1,a2,a3,a4,a5,a6,a7 });
}
uint8_t
readX(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ x0,x1,x2,x3,x4,x5,x6,x7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ x0,x1,x2,x3,x4,x5,x6,x7 });
}
uint8_t
readY(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ y0,y1,y2,y3,y4,y5,y6,y7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ y0,y1,y2,y3,y4,y5,y6,y7 });
}
uint8_t
readP(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ p0,p1,p2,p3,p4,p5,p6,p7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ p0,p1,p2,p3,p4,p5,p6,p7 });
}
uint8_t
readIR(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ notir0,notir1,notir2,notir3,notir4,notir5,notir6,notir7 }) ^ 0xFF;
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ notir0,notir1,notir2,notir3,notir4,notir5,notir6,notir7 }) ^ 0xFF;
}
uint8_t
readSP(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ s0,s1,s2,s3,s4,s5,s6,s7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ s0,s1,s2,s3,s4,s5,s6,s7 });
}
uint8_t
readPCL(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ pcl0,pcl1,pcl2,pcl3,pcl4,pcl5,pcl6,pcl7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ pcl0,pcl1,pcl2,pcl3,pcl4,pcl5,pcl6,pcl7 });
}
uint8_t
readPCH(void *state)
{
return readNodes(state, 8, (nodenum_t[]){ pch0,pch1,pch2,pch3,pch4,pch5,pch6,pch7 });
return (uint8_t)readNodes(state, 8, (nodenum_t[]){ pch0,pch1,pch2,pch3,pch4,pch5,pch6,pch7 });
}
uint16_t
readPC(void *state)
{
return (readPCH(state) << 8) | readPCL(state);
return (uint16_t)((uint16_t)readPCH(state) << 8) | ((uint16_t)readPCL(state));
}
/************************************************************
@ -164,7 +164,7 @@ step(void *state)
}
void *
initAndResetChip()
initAndResetChip(void)
{
/* set up data structures for efficient emulation */
nodenum_t nodes = sizeof(netlist_6502_node_is_pullup)/sizeof(*netlist_6502_node_is_pullup);

View File

@ -2,7 +2,7 @@
#define state_t void
#endif
extern state_t *initAndResetChip();
extern state_t *initAndResetChip(void);
extern void destroyChip(state_t *state);
extern void step(state_t *state);
extern void chipStatus(state_t *state);

10
types.h
View File

@ -3,16 +3,16 @@
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int BOOL;
typedef unsigned char BOOL;
typedef uint16_t nodenum_t;
typedef struct {
int gate;
int c1;
int c2;
nodenum_t gate;
nodenum_t c1;
nodenum_t c2;
} netlist_transdefs;
#define YES 1
#define NO 0
#endif
#endif