using code beautifier (uncrustify), possibly most controversial commit ever\?

This commit is contained in:
Dagen Brock 2018-08-13 12:22:40 -05:00
parent a509cc0a3c
commit 65f280569c
58 changed files with 32660 additions and 34069 deletions

3
.gitignore vendored
View File

@ -23,3 +23,6 @@ images/
# Screenshot dir
screens/
# build tools that are often kept/tested locally as well as on the ci machines
yoursway-create-dmg/

19
assets/uncrustify.cfg Normal file
View File

@ -0,0 +1,19 @@
output_tab_size = 2 # new tab size
indent_columns = output_tab_size
indent_switch_case = output_tab_size
indent_with_tabs = 0
pp_indent_if = 0 # number
pp_if_indent_code = false # false/true
pp_define_at_level = false # false/true
nl_assign_leave_one_liners = true # false/true
nl_class_leave_one_liners = true # false/true
nl_enum_leave_one_liners = true # false/true
nl_getset_leave_one_liners = true # false/true
nl_func_leave_one_liners = true # false/true
nl_if_leave_one_liners = true # false/true
nl_while_leave_one_liners = true # false/true
nl_func_type_name = remove
nl_fdef_brace = remove
sp_fparen_brace = add

181
src/adb.c
View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/* adb_mode bit 3 and bit 2 (faster repeats for arrows and space/del) not done*/
@ -47,7 +47,7 @@ enum {
#define ADB_C027_MOUSE_COORD 0x02
#define ADB_C027_CMD_FULL 0x01
#define ADB_C027_NEG_MASK ( ~ ( \
#define ADB_C027_NEG_MASK ( ~( \
ADB_C027_MOUSE_DATA | ADB_C027_DATA_VALID | \
ADB_C027_KBD_VALID | ADB_C027_MOUSE_COORD | \
ADB_C027_CMD_FULL))
@ -124,14 +124,14 @@ int g_mouse_dev_addr = 3; /* ADB physical mouse addr */
int g_kbd_ctl_addr = 2; /* ADB microcontroller's kbd addr */
int g_mouse_ctl_addr = 3; /* ADB ucontroller's mouse addr*/
/* above are ucontroller's VIEW of where mouse/kbd */
/* are...if they are moved, mouse/keyboard funcs */
/* should stop (c025, c000, c024, etc). */
/* above are ucontroller's VIEW of where mouse/kbd */
/* are...if they are moved, mouse/keyboard funcs */
/* should stop (c025, c000, c024, etc). */
word32 g_virtual_key_up[4]; /* bitmask of all possible 128 a2codes */
/* indicates which keys are up=1 by bit */
int g_keypad_key_is_down[10] = { 0 };/* List from 0-9 of which keypad */
int g_keypad_key_is_down[10] = { 0 }; /* List from 0-9 of which keypad */
/* keys are currently pressed */
@ -151,9 +151,7 @@ int g_kbd_reg3_16bit = 0x602; /* also set in adb_reset()! */
int g_adb_init = 0;
void
adb_init()
{
void adb_init() {
int keycode;
int i;
@ -184,14 +182,11 @@ adb_init()
}
// OG Added adb_shut()
void adb_shut()
{
void adb_shut() {
g_adb_init = 0;
}
void
adb_reset()
{
void adb_reset() {
g_c027_val = 0;
@ -229,9 +224,7 @@ STRUCT(Adb_log) {
Adb_log g_adb_log[LEN_ADB_LOG];
int g_adb_log_pos = 0;
void
adb_log(word32 addr, int val)
{
void adb_log(word32 addr, int val) {
int pos;
pos = g_adb_log_pos;
@ -245,9 +238,7 @@ adb_log(word32 addr, int val)
g_adb_log_pos = pos;
}
void
show_adb_log(void)
{
void show_adb_log(void) {
int pos;
int i;
@ -269,9 +260,7 @@ show_adb_log(void)
g_adb_state, g_adb_interrupt_byte);
}
void
adb_error(void)
{
void adb_error(void) {
halt_printf("Adb Error\n");
show_adb_log();
@ -279,9 +268,7 @@ adb_error(void)
void
adb_add_kbd_srq()
{
void adb_add_kbd_srq() {
if(g_kbd_reg3_16bit & 0x200) {
/* generate SRQ */
g_adb_interrupt_byte |= 0x08;
@ -291,47 +278,35 @@ adb_add_kbd_srq()
}
}
void
adb_clear_kbd_srq()
{
void adb_clear_kbd_srq() {
remove_irq(IRQ_PENDING_ADB_KBD_SRQ);
/* kbd SRQ's are the only ones to handle now, so just clean it out */
g_adb_interrupt_byte &= (~(0x08));
}
void
adb_add_data_int()
{
void adb_add_data_int() {
if(g_c027_val & ADB_C027_DATA_INT) {
add_irq(IRQ_PENDING_ADB_DATA);
}
}
void
adb_add_mouse_int()
{
void adb_add_mouse_int() {
if(g_c027_val & ADB_C027_MOUSE_INT) {
add_irq(IRQ_PENDING_ADB_MOUSE);
}
}
void
adb_clear_data_int()
{
void adb_clear_data_int() {
remove_irq(IRQ_PENDING_ADB_DATA);
}
void
adb_clear_mouse_int()
{
void adb_clear_mouse_int() {
remove_irq(IRQ_PENDING_ADB_MOUSE);
}
void
adb_send_bytes(int num_bytes, word32 val0, word32 val1, word32 val2)
{
void adb_send_bytes(int num_bytes, word32 val0, word32 val1, word32 val2) {
word32 val;
int shift_amount;
int i;
@ -360,9 +335,7 @@ adb_send_bytes(int num_bytes, word32 val0, word32 val1, word32 val2)
}
void
adb_send_1byte(word32 val)
{
void adb_send_1byte(word32 val) {
if(g_adb_data_pending != 0) {
halt_printf("g_adb_data_pending: %d\n", g_adb_data_pending);
@ -373,9 +346,7 @@ adb_send_1byte(word32 val)
void
adb_response_packet(int num_bytes, word32 val)
{
void adb_response_packet(int num_bytes, word32 val) {
if(g_adb_data_pending != 0) {
halt_printf("adb_response_packet, but pending: %d\n",
@ -401,9 +372,7 @@ adb_response_packet(int num_bytes, word32 val)
}
void
adb_kbd_reg0_data(int a2code, int is_up)
{
void adb_kbd_reg0_data(int a2code, int is_up) {
if(g_kbd_reg0_pos >= MAX_ADB_KBD_REG3) {
/* too many keys, toss */
halt_printf("Had to toss key: %02x, %d\n", a2code, is_up);
@ -420,9 +389,7 @@ adb_kbd_reg0_data(int a2code, int is_up)
adb_add_kbd_srq();
}
void
adb_kbd_talk_reg0()
{
void adb_kbd_talk_reg0() {
word32 val0, val1;
word32 reg;
int num_bytes;
@ -470,9 +437,7 @@ adb_kbd_talk_reg0()
}
}
void
adb_set_config(word32 val0, word32 val1, word32 val2)
{
void adb_set_config(word32 val0, word32 val1, word32 val2) {
int new_mouse;
int new_kbd;
int tmp1;
@ -544,9 +509,7 @@ adb_set_config(word32 val0, word32 val1, word32 val2)
}
void
adb_set_new_mode(word32 val)
{
void adb_set_new_mode(word32 val) {
if(val & 0x03) {
glogf("Disabling keyboard/mouse:%02x!", val);
}
@ -560,9 +523,7 @@ adb_set_new_mode(word32 val)
}
int
adb_read_c026()
{
int adb_read_c026() {
word32 ret;
int i;
@ -616,9 +577,7 @@ adb_read_c026()
}
void
adb_write_c026(int val)
{
void adb_write_c026(int val) {
word32 tmp;
int dev;
@ -819,9 +778,7 @@ adb_write_c026(int val)
return;
}
void
do_adb_cmd()
{
void do_adb_cmd() {
int dev;
int new_kbd;
int addr;
@ -953,9 +910,7 @@ do_adb_cmd()
}
int
adb_read_c027()
{
int adb_read_c027() {
word32 ret;
if(halt_on_all_c027) {
@ -995,9 +950,7 @@ adb_read_c027()
return ret;
}
void
adb_write_c027(int val)
{
void adb_write_c027(int val) {
word32 old_val;
word32 new_int;
word32 old_int;
@ -1029,9 +982,7 @@ adb_write_c027(int val)
return;
}
int
read_adb_ram(word32 addr)
{
int read_adb_ram(word32 addr) {
int val;
adb_printf("Reading adb ram addr: %02x\n", addr);
@ -1069,9 +1020,7 @@ read_adb_ram(word32 addr)
return val;
}
void
write_adb_ram(word32 addr, int val)
{
void write_adb_ram(word32 addr, int val) {
adb_printf("Writing adb_ram addr: %02x: %02x\n", addr, val);
@ -1083,9 +1032,7 @@ write_adb_ram(word32 addr, int val)
}
}
int
adb_get_keypad_xy(int get_y)
{
int adb_get_keypad_xy(int get_y) {
int x, y;
int key;
int num_keys;
@ -1119,9 +1066,7 @@ adb_get_keypad_xy(int get_y)
}
}
int
update_mouse(int x, int y, int button_states, int buttons_valid)
{
int update_mouse(int x, int y, int button_states, int buttons_valid) {
double dcycs;
int button1_changed;
int mouse_moved;
@ -1246,9 +1191,7 @@ update_mouse(int x, int y, int button_states, int buttons_valid)
return mouse_moved;
}
int
mouse_read_c024(double dcycs)
{
int mouse_read_c024(double dcycs) {
word32 ret;
word32 tool_start;
int em_active;
@ -1259,7 +1202,7 @@ mouse_read_c024(double dcycs)
int clamped;
int pos;
if(((g_adb_mode & 0x2) != 0) || (g_mouse_dev_addr != g_mouse_ctl_addr)){
if(((g_adb_mode & 0x2) != 0) || (g_mouse_dev_addr != g_mouse_ctl_addr)) {
/* mouse is off, return 0, or mouse is not autopoll */
g_adb_mouse_valid_data = 0;
adb_clear_mouse_int();
@ -1404,9 +1347,7 @@ mouse_read_c024(double dcycs)
return ret;
}
void
mouse_compress_fifo(double dcycs)
{
void mouse_compress_fifo(double dcycs) {
int pos;
/* The mouse fifo exists so that fast button changes don't get lost */
@ -1427,9 +1368,7 @@ mouse_compress_fifo(double dcycs)
}
}
void
adb_key_event(int a2code, int is_up)
{
void adb_key_event(int a2code, int is_up) {
word32 special;
word32 vbl_count;
int key;
@ -1528,7 +1467,7 @@ adb_key_event(int a2code, int is_up)
g_key_down = 0;
}
g_c025_val = g_c025_val & (~ special);
g_c025_val = g_c025_val & (~special);
adb_printf("new c025_and: %02x\n", g_c025_val);
}
@ -1541,9 +1480,7 @@ adb_key_event(int a2code, int is_up)
}
word32
adb_read_c000()
{
word32 adb_read_c000() {
word32 vbl_count;
if( ((g_kbd_buf[0] & 0x80) == 0) && (g_key_down == 0)) {
@ -1579,9 +1516,7 @@ adb_read_c000()
return g_kbd_buf[0];
}
word32
adb_access_c010()
{
word32 adb_access_c010() {
int tmp;
int i;
@ -1598,32 +1533,24 @@ adb_access_c010()
g_kbd_chars_buffered--;
}
g_c025_val = g_c025_val & (~ (0x08));
g_c025_val = g_c025_val & (~(0x08));
return tmp;
}
word32
adb_read_c025()
{
word32 adb_read_c025() {
return g_c025_val;
}
int
adb_is_cmd_key_down()
{
int adb_is_cmd_key_down() {
return CMD_DOWN;
}
int
adb_is_option_key_down()
{
int adb_is_option_key_down() {
return OPTION_DOWN;
}
void
adb_increment_speed()
{
void adb_increment_speed() {
const char *str;
g_limit_speed++;
@ -1649,9 +1576,7 @@ adb_increment_speed()
glogf("Setting g_limit_speed = %d %s", g_limit_speed, str);
}
void
adb_physical_key_update(int a2code, int is_up)
{
void adb_physical_key_update(int a2code, int is_up) {
int autopoll;
int special;
int ascii_and_type;
@ -1843,9 +1768,7 @@ adb_physical_key_update(int a2code, int is_up)
}
}
void
adb_virtual_key_update(int a2code, int is_up)
{
void adb_virtual_key_update(int a2code, int is_up) {
int i;
int bitpos;
word32 mask;
@ -1876,9 +1799,7 @@ adb_virtual_key_update(int a2code, int is_up)
}
}
void
adb_all_keys_up()
{
void adb_all_keys_up() {
word32 mask;
int i, j;
@ -1893,8 +1814,6 @@ adb_all_keys_up()
}
}
void
adb_kbd_repeat_off()
{
void adb_kbd_repeat_off() {
g_key_down = 0;
}

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "../../defc.h"
#include "../../protos.h"
@ -68,37 +68,29 @@ extern char *g_status_ptrs[MAX_STATUS_LINES];
VOID DispErrorMessage();
int
win_nonblock_read_stdin(int fd, char *bufptr, int len)
{
int win_nonblock_read_stdin(int fd, char *bufptr, int len) {
return 0;
}
void
x_dialog_create_gsport_conf(const char *str)
{
void x_dialog_create_gsport_conf(const char *str) {
}
int
x_show_alert(int is_fatal, const char *str)
{
int x_show_alert(int is_fatal, const char *str) {
return 0;
}
int
main(int argc, char **argv)
{
DEVOPENSTRUC pszData;
ULONG flCreate; /* Window creation control flags*/
int height;
SIZEL sizel;
int main(int argc, char **argv) {
DEVOPENSTRUC pszData;
ULONG flCreate; /* Window creation control flags*/
int height;
SIZEL sizel;
if ((g_hab = WinInitialize(0)) == 0L) /* Initialize PM */
os2_abort(g_hwnd_frame, g_hwnd_client); /* Terminate the application */
if ((g_hmq = WinCreateMsgQueue( g_hab, 0 )) == 0L)/* Create a msg queue */
if ((g_hmq = WinCreateMsgQueue( g_hab, 0 )) == 0L) /* Create a msg queue */
os2_abort(g_hwnd_frame, g_hwnd_client); /* Terminate the application */
if (!WinRegisterClass( /* Register window class */
@ -163,10 +155,9 @@ SIZEL sizel;
* the message command and parameters.
*
*************************************************************************/
MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
HPS hps;
RECTL rcl;
MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
HPS hps;
RECTL rcl;
switch( msg )
{
@ -232,9 +223,7 @@ RECTL rcl;
return (MRESULT)FALSE;
} /* End of MyWindowProc */
void
check_input_events()
{
void check_input_events() {
/*
* Get and dispatch messages from the application message queue
@ -253,32 +242,22 @@ check_input_events()
}
void
x_update_color(int col_num, int red, int green, int blue, word32 rgb)
{
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) {
}
void
x_update_physical_colormap()
{
void x_update_physical_colormap() {
}
void
show_xcolor_array()
{
void show_xcolor_array() {
}
void
xdriver_end()
{
void xdriver_end() {
printf("OS/2 driver_end\n");
}
void
x_get_kimage(Kimage *kimage_ptr)
{
void x_get_kimage(Kimage *kimage_ptr) {
byte *ptr;
int width;
int height;
@ -334,9 +313,7 @@ x_get_kimage(Kimage *kimage_ptr)
}
void
dev_video_init()
{
void dev_video_init() {
int lores_col;
int i;
@ -375,9 +352,7 @@ dev_video_init()
fflush(stdout);
}
void
x_redraw_status_lines()
{
void x_redraw_status_lines() {
int line,len,height;
POINTL pt;
@ -404,14 +379,12 @@ x_redraw_status_lines()
}
}
}
*/
*/
}
void
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height)
{
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height) {
RECTL rc;
POINTL pt[4];
HBITMAP hbmOld, hbmNew;
@ -428,27 +401,26 @@ x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
pt[3].x = srcx+width;
pt[3].y = srcy+height;
if (width == 560)
{
if (width == 560)
{
/* Paint a known-good bitmap until we can figure out why images aren't showing up */
hbmNew = GpiLoadBitmap(g_hps_memory,NULLHANDLE,ID_BITMAP,560,400);
hbmOld = GpiSetBitmap(g_hps_memory, hbmNew);
GpiBitBlt(g_hps_screen,g_hps_memory,4L,pt,ROP_SRCCOPY, BBO_IGNORE);
GpiSetBitmap(g_hps_memory, hbmOld);
GpiDeleteBitmap(hbmNew);
}
else
{
}
else
{
hbmOld = GpiSetBitmap(g_hps_memory, (HBITMAP)kimage_ptr->dev_handle);
GpiBitBlt(g_hps_screen,g_hps_memory,4L,pt,ROP_SRCCOPY, BBO_IGNORE);
GpiSetBitmap(g_hps_memory, hbmOld);
}
}
}
// OG Adding release
void x_release_kimage(Kimage* kimage_ptr)
{
void x_release_kimage(Kimage* kimage_ptr) {
if (kimage_ptr->dev_handle == (void*)-1)
{
free(kimage_ptr->data_ptr);
@ -459,34 +431,23 @@ void x_release_kimage(Kimage* kimage_ptr)
}
}
void
x_push_done()
{
void x_push_done() {
}
void
x_auto_repeat_on(int must)
{
void x_auto_repeat_on(int must) {
}
void
x_auto_repeat_off(int must)
{
void x_auto_repeat_off(int must) {
}
void
x_hide_pointer(int do_hide)
{
void x_hide_pointer(int do_hide) {
}
void
x_full_screen(int do_full)
{
void x_full_screen(int do_full) {
return;
}
int x_calc_ratio(float ratiox,float ratioy)
{
int x_calc_ratio(float ratiox,float ratioy) {
return 0; // not stretched
}
@ -496,8 +457,7 @@ int x_calc_ratio(float ratiox,float ratioy)
/* The error message is displayed using a message box */
/* */
/**************************************************************************/
VOID DispErrorMessage()
{
VOID DispErrorMessage() {
PERRINFO pErrInfoBlk;
PSZ pszOffSet, pszErrMsg;
ERRORID ErrorId;
@ -521,8 +481,6 @@ VOID DispErrorMessage()
}
}
void
os2_abort(HWND g_hwnd_frame, HWND g_hwnd_client)
{
void os2_abort(HWND g_hwnd_frame, HWND g_hwnd_client) {
exit(-1);
}

View File

@ -3,6 +3,6 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
int g_preferred_rate = 48000;

View File

@ -23,8 +23,7 @@
#include <string.h>
#include "dirport.h"
DIR *opendir (char *path)
{
DIR *opendir (char *path) {
APIRET ulrc;
ULONG cnt = 1;
DIR *dir;
@ -47,15 +46,13 @@ DIR *opendir (char *path)
return dir;
}
struct dirent *readdir (DIR *dir)
{
struct dirent *readdir (DIR *dir) {
ULONG cnt = 1;
return DosFindNext (dir->handle, &(dir->buffer), sizeof(struct _FILEFINDBUF), &cnt) ? NULL : &(dir->buffer);
}
int closedir (DIR *dir)
{
int closedir (DIR *dir) {
APIRET ulrc = DosFindClose (dir->handle);
free(dir);
@ -81,10 +78,10 @@ int closedir (DIR *dir)
not or do provide an inadequate (slow or idiosyncratic) version, which
calls for a portable implementation of this routine.
Author
Author
Mark Martinec <mark.martinec@ijs.si>, April 1999, June 2000
Copyright © 1999, Mark Martinec
Copyright <EFBFBD> 1999, Mark Martinec
*/
@ -167,14 +164,14 @@ Author
#define fast_memcpy(d,s,n) \
{ register size_t nn = (size_t)(n); \
if (nn >= breakeven_point) memcpy((d), (s), nn); \
else if (nn > 0) { /* proc call overhead is worth only for large strings*/\
else if (nn > 0) { /* proc call overhead is worth only for large strings*/ \
register char *dd; register const char *ss; \
for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } }
#define fast_memset(d,c,n) \
{ register size_t nn = (size_t)(n); \
if (nn >= breakeven_point) memset((d), (int)(c), nn); \
else if (nn > 0) { /* proc call overhead is worth only for large strings*/\
else if (nn > 0) { /* proc call overhead is worth only for large strings*/ \
register char *dd; register const int cc=(int)(c); \
for (dd=(d); nn>0; nn--) *dd++ = cc; } }
@ -251,8 +248,7 @@ int vasprintf(char **ptr, const char *fmt, va_list ap) {
{ va_list ap2;
va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */
str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/
va_end(ap2);
}
va_end(ap2);}
assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
*ptr = (char *) malloc(str_m = (size_t)str_l + 1);
if (*ptr == NULL) { errno = ENOMEM; str_l = -1; }
@ -300,8 +296,7 @@ int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap) {
{ va_list ap2;
va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */
str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/
va_end(ap2);
}
va_end(ap2);}
assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */
/* if str_m is 0, no buffer is allocated, just set *ptr to NULL */
@ -365,7 +360,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
size_t n = !q ? strlen(p) : (q-p);
if (str_l < str_m) {
size_t avail = str_m-str_l;
fast_memcpy(str+str_l, p, (n>avail?avail:n));
fast_memcpy(str+str_l, p, (n>avail ? avail : n));
}
p += n; str_l += n;
} else {
@ -676,7 +671,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, uint_arg); break;
case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, ulong_arg); break;
#ifdef SNPRINTF_LONGLONG_SUPPORT
case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,ulong_long_arg);break;
case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,ulong_long_arg); break;
#endif
}
}
@ -714,8 +709,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
}
/* zero padding to specified precision? */
if (num_of_digits < precision)
number_of_zeros_to_pad = precision - num_of_digits;
}
number_of_zeros_to_pad = precision - num_of_digits; }
/* zero padding to specified minimal field width? */
if (!justify_left && zero_padding) {
int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
@ -750,7 +744,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
if (n > 0) {
if (str_l < str_m) {
size_t avail = str_m-str_l;
fast_memset(str+str_l, (zero_padding?'0':' '), (n>avail?avail:n));
fast_memset(str+str_l, (zero_padding ? '0' : ' '), (n>avail ? avail : n));
}
str_l += n;
}
@ -767,7 +761,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
if (n > 0) {
if (str_l < str_m) {
size_t avail = str_m-str_l;
fast_memcpy(str+str_l, str_arg, (n>avail?avail:n));
fast_memcpy(str+str_l, str_arg, (n>avail ? avail : n));
}
str_l += n;
}
@ -776,7 +770,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
if (n > 0) {
if (str_l < str_m) {
size_t avail = str_m-str_l;
fast_memset(str+str_l, '0', (n>avail?avail:n));
fast_memset(str+str_l, '0', (n>avail ? avail : n));
}
str_l += n;
}
@ -788,18 +782,17 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
if (str_l < str_m) {
size_t avail = str_m-str_l;
fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind,
(n>avail?avail:n));
(n>avail ? avail : n));
}
str_l += n;
}
}
}}
/* insert right padding */
if (justify_left) { /* right blank padding to the field width */
int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
if (n > 0) {
if (str_l < str_m) {
size_t avail = str_m-str_l;
fast_memset(str+str_l, ' ', (n>avail?avail:n));
fast_memset(str+str_l, ' ', (n>avail ? avail : n));
}
str_l += n;
}
@ -832,4 +825,4 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
Local Variables:
tab-width: 3
end:
*/
*/

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/** This module implements AARP, a necessary protocol for ELAP communication. **/
@ -38,13 +38,11 @@ static unsigned int retry_count;
static clock_t retry_timer;
void aarp_init()
{
void aarp_init() {
aarp_retry_reset();
}
void aarp_shutdown()
{
void aarp_shutdown() {
struct amt_entry_t* entry = amt;
while (entry)
{
@ -56,8 +54,7 @@ void aarp_shutdown()
////
static void aarp_send_packet(enum AARP_FUNCTION function, const struct at_addr_t* source_at_addr, const struct at_addr_t* dest_at_addr, const struct ether_addr_t* dest_hw_addr)
{
static void aarp_send_packet(enum AARP_FUNCTION function, const struct at_addr_t* source_at_addr, const struct at_addr_t* dest_at_addr, const struct ether_addr_t* dest_hw_addr) {
if (source_at_addr && dest_at_addr && dest_hw_addr)
{
struct aarp_header_t response;
@ -86,16 +83,14 @@ static void aarp_send_packet(enum AARP_FUNCTION function, const struct at_addr_t
}
}
void aarp_probe(const struct at_addr_t* addr)
{
void aarp_probe(const struct at_addr_t* addr) {
if (addr)
{
aarp_send_packet(AARP_FUNCTION_PROBE, addr, addr, &HW_ZERO);
}
}
static void aarp_request(const struct at_addr_t* addr)
{
static void aarp_request(const struct at_addr_t* addr) {
if (addr)
{
aarp_send_packet(AARP_FUNCTION_REQUEST, atbridge_get_addr(), addr, &HW_ZERO);
@ -104,8 +99,7 @@ static void aarp_request(const struct at_addr_t* addr)
////
static struct amt_entry_t* amt_lookup_entry_hardware(const struct ether_addr_t* hardware)
{
static struct amt_entry_t* amt_lookup_entry_hardware(const struct ether_addr_t* hardware) {
if (hardware)
{
struct amt_entry_t* entry = amt;
@ -119,8 +113,7 @@ static struct amt_entry_t* amt_lookup_entry_hardware(const struct ether_addr_t*
return 0;
}
static struct amt_entry_t* amt_lookup_entry_protocol(const struct at_addr_t* protocol)
{
static struct amt_entry_t* amt_lookup_entry_protocol(const struct at_addr_t* protocol) {
if (protocol)
{
struct amt_entry_t* entry = amt;
@ -134,8 +127,7 @@ static struct amt_entry_t* amt_lookup_entry_protocol(const struct at_addr_t* pro
return 0;
}
static void amt_delete_entry_protocol(const struct at_addr_t* protocol)
{
static void amt_delete_entry_protocol(const struct at_addr_t* protocol) {
if (protocol)
{
struct amt_entry_t* entry = amt;
@ -154,8 +146,7 @@ static void amt_delete_entry_protocol(const struct at_addr_t* protocol)
}
}
static void amt_add(const struct at_addr_t* protocol, const struct ether_addr_t* hardware)
{
static void amt_add(const struct at_addr_t* protocol, const struct ether_addr_t* hardware) {
// Does an entry matching one of the protocol or hardware addresses exist? If so, update it.
struct amt_entry_t* entry = amt_lookup_entry_protocol(protocol);
if (entry)
@ -179,8 +170,7 @@ static void amt_add(const struct at_addr_t* protocol, const struct ether_addr_t*
amt = entry;
}
const struct ether_addr_t* aarp_request_hardware(const struct at_addr_t* protocol)
{
const struct ether_addr_t* aarp_request_hardware(const struct at_addr_t* protocol) {
struct amt_entry_t* entry = amt_lookup_entry_protocol(protocol);
if (entry)
{
@ -205,8 +195,7 @@ const struct ether_addr_t* aarp_request_hardware(const struct at_addr_t* protoco
}
}
const struct at_addr_t* aarp_request_protocol(const struct ether_addr_t* hardware)
{
const struct at_addr_t* aarp_request_protocol(const struct ether_addr_t* hardware) {
struct amt_entry_t* entry = amt_lookup_entry_hardware(hardware);
if (entry)
return (const struct at_addr_t*)&entry->protocol;
@ -214,24 +203,20 @@ const struct at_addr_t* aarp_request_protocol(const struct ether_addr_t* hardwar
return 0;
}
bool aarp_retry()
{
bool aarp_retry() {
return retry_count > 0;
}
void aarp_retry_reset()
{
void aarp_retry_reset() {
retry_count = AARP_REQUEST_COUNT;
retry_timer = clock();
}
void aarp_glean(const struct at_addr_t* protocol, const struct ether_addr_t* hardware)
{
void aarp_glean(const struct at_addr_t* protocol, const struct ether_addr_t* hardware) {
amt_add(protocol, hardware);
}
bool aarp_address_used(const struct at_addr_t* protocol)
{
bool aarp_address_used(const struct at_addr_t* protocol) {
// reference 2-8
if (protocol)
{
@ -256,8 +241,7 @@ bool aarp_address_used(const struct at_addr_t* protocol)
////
void aarp_handle_packet(const struct aarp_header_t* aarp)
{
void aarp_handle_packet(const struct aarp_header_t* aarp) {
if (aarp &&
aarp->hardware_type == AARP_HARDWARE_ETHER &&
aarp->protocol_type == AARP_PROTOCOL_TYPE &&

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/** This module is the "heart" of the bridge and provides the connection between the ELAP and LLAP ports. **/
@ -37,8 +37,7 @@ static const at_node_t NODE_STARTUP_HIGH = 0xFE;
static void send_rtmp_request();
bool atbridge_init()
{
bool atbridge_init() {
// If the GS reboots, we may try to reinitialize the bridge. If this is the case, keep the old address and AMT.
if (local_address.network == 0)
{
@ -61,25 +60,21 @@ bool atbridge_init()
return true;
}
void atbridge_shutdown()
{
void atbridge_shutdown() {
llap_shutdown();
elap_shutdown();
aarp_shutdown();
}
void atbridge_set_diagnostics(bool enabled)
{
void atbridge_set_diagnostics(bool enabled) {
diagnostics = enabled;
}
bool atbridge_get_diagnostics()
{
bool atbridge_get_diagnostics() {
return diagnostics;
}
void atbridge_printf(const char *fmt, ...)
{
void atbridge_printf(const char *fmt, ...) {
if (atbridge_get_diagnostics())
{
va_list args;
@ -89,41 +84,34 @@ void atbridge_printf(const char *fmt, ...)
}
}
const struct at_addr_t* atbridge_get_addr()
{
const struct at_addr_t* atbridge_get_addr() {
return &local_address;
}
const at_network_t atbridge_get_net()
{
const at_network_t atbridge_get_net() {
return local_address.network;
}
const at_node_t atbridge_get_node()
{
const at_node_t atbridge_get_node() {
return local_address.node;
}
void atbridge_set_net(at_network_t net)
{
void atbridge_set_net(at_network_t net) {
local_address.network = net;
}
void atbridge_set_node(at_node_t node)
{
void atbridge_set_node(at_node_t node) {
local_address.node = node;
}
bool atbridge_address_used(const struct at_addr_t* addr)
{
bool atbridge_address_used(const struct at_addr_t* addr) {
if (!sent_rtmp_request)
send_rtmp_request();
return aarp_address_used(addr);
}
/* Calculate a DDP checksum, per Apple's documented algorithm in 4-17 of "Inside AppleTalk". */
static word16 get_checksum(size_t size, byte data[])
{
static word16 get_checksum(size_t size, byte data[]) {
word16 cksum = 0;
for (unsigned int i = 0; i < size; i++)
{
@ -135,8 +123,7 @@ static word16 get_checksum(size_t size, byte data[])
return cksum;
}
static void calculate_checksum(struct packet_t* packet)
{
static void calculate_checksum(struct packet_t* packet) {
if (packet && packet->data && (packet->size >= sizeof(struct DDP_LONG)) && (packet->type == LAP_DDP_LONG))
{
struct DDP_LONG* header = (struct DDP_LONG*)(packet->data);
@ -147,8 +134,7 @@ static void calculate_checksum(struct packet_t* packet)
}
/* Convert a long-form DDP header to a short-form header. This function only converts the headers. */
static word16 convert_ddp_header_to_short(const struct DDP_LONG* in, struct DDP_SHORT* out)
{
static word16 convert_ddp_header_to_short(const struct DDP_LONG* in, struct DDP_SHORT* out) {
word16 size;
if (!in || !out)
@ -169,8 +155,7 @@ static word16 convert_ddp_header_to_short(const struct DDP_LONG* in, struct DDP_
/* Convert a short-form DDP header to a long-form header. ELAP requires long-form, but LLAP often uses short-form. */
/* This function only converts the headers. */
static word16 convert_ddp_header_to_long(const struct at_addr_t dest, const struct at_addr_t source, const struct DDP_SHORT* in, struct DDP_LONG* out)
{
static word16 convert_ddp_header_to_long(const struct at_addr_t dest, const struct at_addr_t source, const struct DDP_SHORT* in, struct DDP_LONG* out) {
word16 size;
if (!in || !out)
@ -207,8 +192,7 @@ static word16 convert_ddp_header_to_long(const struct at_addr_t dest, const stru
/* Convert a short-form DDP packet to a long-form packet. */
/* This function converts an entire packet, not just the header. */
static void convert_ddp_packet_to_long(struct packet_t* packet)
{
static void convert_ddp_packet_to_long(struct packet_t* packet) {
if (packet && (packet->type == LAP_DDP_SHORT) && packet->data && (packet->size >= sizeof(struct DDP_SHORT)))
{
struct DDP_SHORT* header_short = (struct DDP_SHORT*)packet->data;
@ -235,8 +219,7 @@ static void convert_ddp_packet_to_long(struct packet_t* packet)
}
/* Convert a long-form DDP packet to short-form. */
static void convert_ddp_packet_to_short(struct packet_t* packet)
{
static void convert_ddp_packet_to_short(struct packet_t* packet) {
if (packet && (packet->type == LAP_DDP_LONG) && packet->data)
{
struct DDP_LONG* header_long = (struct DDP_LONG*)packet->data;
@ -258,7 +241,7 @@ static void convert_ddp_packet_to_short(struct packet_t* packet)
}
/*static void convert_rtmp_to_extended(struct packet_t* packet)
{
{
if (packet && (packet->type == LAP_DDP_SHORT) && packet->data)
{
struct DDP_SHORT* header_short = (struct DDP_SHORT*)packet->data;
@ -297,10 +280,9 @@ static void convert_ddp_packet_to_short(struct packet_t* packet)
packet->size = size;
packet->type = LAP_DDP_LONG;
}
}*/
}*/
static void convert_rtmp_to_nonextended(struct packet_t* packet)
{
static void convert_rtmp_to_nonextended(struct packet_t* packet) {
if (packet && (packet->type == LAP_DDP_LONG) && packet->data)
{
struct DDP_LONG* header_long = (struct DDP_LONG*)packet->data;
@ -343,8 +325,7 @@ static void convert_rtmp_to_nonextended(struct packet_t* packet)
/* "Inside AppleTalk", section 4-8, describes this approach for non-extended networks.
Technically, we probably should be doing the more complicated extended network approach (also on 4-8),
but the easy approach using RTMP seems adequate for now. */
static void glean_net_from_rtmp(struct packet_t* packet)
{
static void glean_net_from_rtmp(struct packet_t* packet) {
if (packet && (packet->type == LAP_DDP_LONG) && packet->data)
{
struct DDP_LONG* header_long = (struct DDP_LONG*)packet->data;
@ -357,8 +338,7 @@ static void glean_net_from_rtmp(struct packet_t* packet)
}
}
static void send_rtmp_request()
{
static void send_rtmp_request() {
struct packet_t* packet = (struct packet_t*)malloc(sizeof(struct packet_t));
packet->type = LAP_DDP_LONG;
@ -390,8 +370,7 @@ static void send_rtmp_request()
sent_rtmp_request = true;
}
void atbridge_process()
{
void atbridge_process() {
elap_process();
//llap_process();

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/** This module implements the ELAP port of the bridge. **/
@ -37,7 +37,7 @@ static struct packet_port_t elap_port;
static struct ether_addr_t HW_LOCAL;
/*static void dump_device_list(pcap_if_t* devices)
{
{
int i = 0;
for(pcap_if_t* device = devices; device; device = device->next)
{
@ -47,10 +47,9 @@ static struct ether_addr_t HW_LOCAL;
else
printf(" (No description available)\n");
}
}*/
}*/
static void elap_clone_host_mac(pcap_if_t* device)
{
static void elap_clone_host_mac(pcap_if_t* device) {
if (!device)
return;
@ -112,13 +111,11 @@ static void elap_clone_host_mac(pcap_if_t* device)
#endif
}
const struct ether_addr_t* elap_get_mac()
{
const struct ether_addr_t* elap_get_mac() {
return &HW_LOCAL;
}
bool elap_init()
{
bool elap_init() {
port_init(&elap_port);
memcpy(&HW_LOCAL, &HW_LOCAL_DEFAULT, sizeof(HW_LOCAL));
@ -191,8 +188,7 @@ bool elap_init()
}
}
void elap_shutdown()
{
void elap_shutdown() {
port_shutdown(&elap_port);
if (pcap_session)
{
@ -202,18 +198,15 @@ void elap_shutdown()
pcapdelay_unload();
}
void elap_enqueue_out(struct packet_t* packet)
{
void elap_enqueue_out(struct packet_t* packet) {
enqueue_packet(&elap_port.out, packet);
}
struct packet_t* elap_dequeue_in()
{
struct packet_t* elap_dequeue_in() {
return dequeue(&elap_port.in);
}
void elap_send(const struct ether_addr_t* dest, const struct snap_discriminator_t* discriminator, size_t size, byte data[])
{
void elap_send(const struct ether_addr_t* dest, const struct snap_discriminator_t* discriminator, size_t size, byte data[]) {
if (pcap_session && dest && discriminator)
{
// Allocate heap space for the frame.
@ -249,8 +242,7 @@ void elap_send(const struct ether_addr_t* dest, const struct snap_discriminator_
}
}
static bool elap_send_one_queued()
{
static bool elap_send_one_queued() {
// Attempt to send one packet out the host network interface.
struct packet_t* packet = queue_peek(&elap_port.out);
if (packet)
@ -290,13 +282,11 @@ static bool elap_send_one_queued()
return false;
}
static void elap_send_all_queued()
{
static void elap_send_all_queued() {
while (elap_send_one_queued());
}
static bool elap_receive_one()
{
static bool elap_receive_one() {
if (!pcap_session)
return false;
@ -374,13 +364,11 @@ static bool elap_receive_one()
return false;
}
static void elap_receive_all()
{
static void elap_receive_all() {
while (elap_receive_one());
}
void elap_process()
{
void elap_process() {
elap_receive_all();
elap_send_all_queued();
}

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/** This module implements the LLAP port of the bridge. **/
@ -39,22 +39,19 @@ static DIALOG_STATE dialog_state;
static double dialog_end_dcycs;
static double last_frame_dcycs;
void llap_init()
{
void llap_init() {
dialog_state = DIALOG_READY;
last_frame_dcycs = 0;
port_init(&llap_port);
}
void llap_shutdown()
{
void llap_shutdown() {
port_shutdown(&llap_port);
}
/** Queue one data packet out from the bridge's LLAP port and into the guest. **/
void llap_enqueue_out(struct packet_t* packet)
{
void llap_enqueue_out(struct packet_t* packet) {
// Generate the RTS.
struct packet_t* rts = (struct packet_t*)malloc(sizeof(struct packet_t));
rts->source.network = packet->source.network;
@ -70,13 +67,11 @@ void llap_enqueue_out(struct packet_t* packet)
enqueue_packet(&llap_port.out, packet);
}
struct packet_t* llap_dequeue_in()
{
struct packet_t* llap_dequeue_in() {
return dequeue(&llap_port.in);
}
static void llap_dump_packet(size_t size, byte data[])
{
static void llap_dump_packet(size_t size, byte data[]) {
if (size < LLAP_PACKET_MIN)
atbridge_printf("LLAP short packet.\n");
else if (size > LLAP_PACKET_MAX)
@ -122,8 +117,7 @@ static void llap_dump_packet(size_t size, byte data[])
}
/** Reply to a control packet from the GS **/
static void llap_reply_control(at_node_t dest, at_node_t source, LLAP_TYPES type)
{
static void llap_reply_control(at_node_t dest, at_node_t source, LLAP_TYPES type) {
struct at_addr_t dest_addr = { 0, dest };
struct at_addr_t source_addr = { 0, source };
@ -133,8 +127,7 @@ static void llap_reply_control(at_node_t dest, at_node_t source, LLAP_TYPES type
}
/** Accept a data packet from the GS. **/
static void llap_handle_data(size_t size, byte data[])
{
static void llap_handle_data(size_t size, byte data[]) {
at_node_t dest = data[0];
at_node_t source = data[1];
LLAP_TYPES type = (LLAP_TYPES)(data[2]);
@ -149,8 +142,7 @@ static void llap_handle_data(size_t size, byte data[])
}
/** Accept a control packet from the GS. **/
static void llap_handle_control(size_t size, byte data[])
{
static void llap_handle_control(size_t size, byte data[]) {
at_node_t dest = data[0];
at_node_t source = data[1];
LLAP_TYPES type = (LLAP_TYPES)(data[2]);
@ -185,8 +177,7 @@ static void llap_handle_control(size_t size, byte data[])
or, more likely, a bug in the SCC emulation. Regardless, when such a thing does occur, discard the
current, corrupted dialog. Link errors are routine in real LocalTalk networks, and LocalTalk will recover.
**/
static void llap_reset_dialog()
{
static void llap_reset_dialog() {
dialog_state = DIALOG_READY;
last_frame_dcycs = 0;
@ -208,8 +199,7 @@ static void llap_reset_dialog()
}
/** Transfer (send) one LLAP packet from the GS. **/
void llap_enqueue_in(double dcycs, size_t size, byte data[])
{
void llap_enqueue_in(double dcycs, size_t size, byte data[]) {
atbridge_printf("<%0.0f> TX: ", dcycs);
llap_dump_packet(size, data);
@ -244,8 +234,7 @@ void llap_enqueue_in(double dcycs, size_t size, byte data[])
}
/** Transfer (receive) one LLAP packet to the GS. **/
void llap_dequeue_out(double dcycs, size_t* size, byte* data[])
{
void llap_dequeue_out(double dcycs, size_t* size, byte* data[]) {
*size = 0;
// The LocalTalk protocol requires a minimum 400us gap between dialogs (called the IDG).

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include <stdbool.h>
#include "pcap_delay.h"
@ -17,8 +17,7 @@ static void* module = 0;
#endif
bool pcapdelay_load()
{
bool pcapdelay_load() {
if (!pcapdelay_is_loaded())
{
#ifdef WIN32
@ -30,8 +29,7 @@ bool pcapdelay_load()
return pcapdelay_is_loaded();
}
bool pcapdelay_is_loaded()
{
bool pcapdelay_is_loaded() {
#ifdef WIN32
return module != NULL;
#elif __linux__
@ -40,8 +38,7 @@ bool pcapdelay_is_loaded()
return 0;
}
void pcapdelay_unload()
{
void pcapdelay_unload() {
if (pcapdelay_is_loaded())
{
#ifdef WIN32
@ -56,8 +53,7 @@ void pcapdelay_unload()
typedef void (*PFNVOID)();
static PFNVOID delay_load(const char* proc, PFNVOID* ppfn)
{
static PFNVOID delay_load(const char* proc, PFNVOID* ppfn) {
if (pcapdelay_load() && proc && ppfn && !*ppfn)
{
#ifdef WIN32
@ -72,16 +68,14 @@ static PFNVOID delay_load(const char* proc, PFNVOID* ppfn)
return 0;
}
void pcapdelay_freealldevs(pcap_if_t* a0)
{
void pcapdelay_freealldevs(pcap_if_t* a0) {
typedef void (*PFN)(pcap_if_t*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_freealldevs", (PFNVOID*)&pfn)))
(*pfn)(a0);
}
pcap_t* pcapdelay_open_live(const char* a0, int a1, int a2, int a3, char* a4)
{
pcap_t* pcapdelay_open_live(const char* a0, int a1, int a2, int a3, char* a4) {
typedef pcap_t* (*PFN)(const char*, int, int, int, char*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_open_live", (PFNVOID*)&pfn)))
@ -90,16 +84,14 @@ pcap_t* pcapdelay_open_live(const char* a0, int a1, int a2, int a3, char* a4)
return 0;
}
void pcapdelay_close(pcap_t* a0)
{
void pcapdelay_close(pcap_t* a0) {
typedef void (*PFN)(pcap_t*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_close", (PFNVOID*)&pfn)))
(*pfn)(a0);
}
int pcapdelay_findalldevs(pcap_if_t** a0, char* a1)
{
int pcapdelay_findalldevs(pcap_if_t** a0, char* a1) {
typedef int (*PFN)(pcap_if_t**, char*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_findalldevs", (PFNVOID*)&pfn)))
@ -108,9 +100,8 @@ int pcapdelay_findalldevs(pcap_if_t** a0, char* a1)
return 0;
}
int pcapdelay_datalink(pcap_t* a0)
{
typedef int(*PFN)(pcap_t*);
int pcapdelay_datalink(pcap_t* a0) {
typedef int (*PFN)(pcap_t*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_datalink", (PFNVOID*)&pfn)))
return (*pfn)(a0);
@ -118,9 +109,8 @@ int pcapdelay_datalink(pcap_t* a0)
return 0;
}
int pcapdelay_setnonblock(pcap_t* a0, int a1, char* a2)
{
typedef int(*PFN)(pcap_t*, int, char*);
int pcapdelay_setnonblock(pcap_t* a0, int a1, char* a2) {
typedef int (*PFN)(pcap_t*, int, char*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_setnonblock", (PFNVOID*)&pfn)))
return (*pfn)(a0, a1, a2);
@ -128,9 +118,8 @@ int pcapdelay_setnonblock(pcap_t* a0, int a1, char* a2)
return 0;
}
int pcapdelay_sendpacket(pcap_t* a0, u_char* a1, int a2)
{
typedef int(*PFN)(pcap_t*, u_char*, int);
int pcapdelay_sendpacket(pcap_t* a0, u_char* a1, int a2) {
typedef int (*PFN)(pcap_t*, u_char*, int);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_sendpacket", (PFNVOID*)&pfn)))
return (*pfn)(a0, a1, a2);
@ -138,8 +127,7 @@ int pcapdelay_sendpacket(pcap_t* a0, u_char* a1, int a2)
return 0;
}
const u_char* pcapdelay_next(pcap_t* a0, struct pcap_pkthdr* a1)
{
const u_char* pcapdelay_next(pcap_t* a0, struct pcap_pkthdr* a1) {
typedef const u_char*(*PFN)(pcap_t*, struct pcap_pkthdr*);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_next", (PFNVOID*)&pfn)))
@ -148,9 +136,8 @@ const u_char* pcapdelay_next(pcap_t* a0, struct pcap_pkthdr* a1)
return 0;
}
int pcapdelay_dispatch(pcap_t* a0, int a1, pcap_handler a2, u_char* a3)
{
typedef const int(*PFN)(pcap_t *, int, pcap_handler, u_char *);
int pcapdelay_dispatch(pcap_t* a0, int a1, pcap_handler a2, u_char* a3) {
typedef const int (*PFN)(pcap_t *, int, pcap_handler, u_char *);
static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_dispatch", (PFNVOID*)&pfn)))
return (*pfn)(a0, a1, a2, a3);

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/** This module implements queues for storing and transferring packets within the bridge. **/
@ -11,8 +11,7 @@
#include "atalk.h"
#include "port.h"
void port_init(struct packet_port_t* port)
{
void port_init(struct packet_port_t* port) {
if (port)
{
queue_init(&port->in);
@ -20,8 +19,7 @@ void port_init(struct packet_port_t* port)
}
}
void port_shutdown(struct packet_port_t* port)
{
void port_shutdown(struct packet_port_t* port) {
if (port)
{
queue_shutdown(&port->in);
@ -29,16 +27,14 @@ void port_shutdown(struct packet_port_t* port)
}
}
void queue_init(struct packet_queue_t* queue)
{
void queue_init(struct packet_queue_t* queue) {
if (queue)
{
queue->head = queue->tail = 0;
}
}
void queue_shutdown(struct packet_queue_t* queue)
{
void queue_shutdown(struct packet_queue_t* queue) {
if (queue)
{
struct packet_t* packet = dequeue(queue);
@ -52,8 +48,7 @@ void queue_shutdown(struct packet_queue_t* queue)
}
}
void enqueue(struct packet_queue_t* queue, struct at_addr_t dest, struct at_addr_t source, byte type, size_t size, byte data[])
{
void enqueue(struct packet_queue_t* queue, struct at_addr_t dest, struct at_addr_t source, byte type, size_t size, byte data[]) {
if (!queue)
return;
@ -68,8 +63,7 @@ void enqueue(struct packet_queue_t* queue, struct at_addr_t dest, struct at_addr
enqueue_packet(queue, packet);
}
void enqueue_packet(struct packet_queue_t* queue, struct packet_t* packet)
{
void enqueue_packet(struct packet_queue_t* queue, struct packet_t* packet) {
packet->next = 0;
if (queue->tail)
@ -79,8 +73,7 @@ void enqueue_packet(struct packet_queue_t* queue, struct packet_t* packet)
queue->tail = packet;
}
void insert(struct packet_queue_t* queue, struct at_addr_t dest, struct at_addr_t source, byte type, size_t size, byte data[])
{
void insert(struct packet_queue_t* queue, struct at_addr_t dest, struct at_addr_t source, byte type, size_t size, byte data[]) {
if (!queue)
return;
@ -95,16 +88,14 @@ void insert(struct packet_queue_t* queue, struct at_addr_t dest, struct at_addr_
insert_packet(queue, packet);
}
void insert_packet(struct packet_queue_t* queue, struct packet_t* packet)
{
void insert_packet(struct packet_queue_t* queue, struct packet_t* packet) {
packet->next = queue->head;
queue->head = packet;
if (!queue->tail)
queue->tail = queue->head;
}
struct packet_t* dequeue(struct packet_queue_t* queue)
{
struct packet_t* dequeue(struct packet_queue_t* queue) {
if (queue && queue->head)
{
struct packet_t* packet = queue->head;
@ -118,8 +109,7 @@ struct packet_t* dequeue(struct packet_queue_t* queue)
return 0;
}
struct packet_t* queue_peek(struct packet_queue_t* queue)
{
struct packet_t* queue_peek(struct packet_queue_t* queue) {
if (queue)
return queue->head;
else

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include <time.h>
@ -41,9 +41,7 @@ byte g_orig_boot_slot = 0;
word32 g_clk_cur_time = 0xa0000000;
int g_clk_next_vbl_update = 0;
double
get_dtime()
{
double get_dtime() {
#ifndef _WIN32
struct timeval tp1;
double dsec;
@ -74,9 +72,7 @@ get_dtime()
return dtime;
}
int
micro_sleep(double dtime)
{
int micro_sleep(double dtime) {
#ifndef _WIN32
struct timeval Timer;
int ret;
@ -107,9 +103,7 @@ micro_sleep(double dtime)
return 0;
}
void
clk_bram_zero()
{
void clk_bram_zero() {
int i, j;
/* zero out all bram */
@ -121,24 +115,18 @@ clk_bram_zero()
g_bram_ptr = &(g_bram[0][0]);
}
void
clk_bram_set(int bram_num, int offset, int val)
{
void clk_bram_set(int bram_num, int offset, int val) {
g_bram[bram_num][offset] = val;
}
extern void x_clk_setup_bram_version();
void
clk_setup_bram_version()
{
void clk_setup_bram_version() {
x_clk_setup_bram_version();
}
void
clk_write_bram(FILE *fconf)
{
void clk_write_bram(FILE *fconf) {
int i, j, k;
for(i = 0; i < 2; i++) {
@ -153,8 +141,7 @@ clk_write_bram(FILE *fconf)
}
}
void
clk_calculate_bram_checksum(void) {
void clk_calculate_bram_checksum(void) {
int checksum = 0;
int i;
if (g_bram_ptr[251] == 0xff) {
@ -183,9 +170,7 @@ clk_calculate_bram_checksum(void) {
}
}
void
update_cur_time()
{
void update_cur_time() {
struct tm *tm_ptr;
time_t cur_time;
unsigned int secs, secs2;
@ -240,15 +225,11 @@ update_cur_time()
}
/* clock_update called by sim65816 every VBL */
void
clock_update()
{
void clock_update() {
/* Nothing to do */
}
void
clock_update_if_needed()
{
void clock_update_if_needed() {
int diff;
diff = g_clk_next_vbl_update - g_vbl_count;
@ -258,9 +239,7 @@ clock_update_if_needed()
}
}
void
clock_write_c034(word32 val)
{
void clock_write_c034(word32 val) {
g_c034_val = val & 0x7f;
if((val & 0x80) != 0) {
if((val & 0x20) == 0) {
@ -272,9 +251,7 @@ clock_write_c034(word32 val)
}
void
do_clock_data()
{
void do_clock_data() {
word32 mask;
int read;
int op;
@ -343,7 +320,7 @@ do_clock_data()
if(read) {
if(g_clk_read) {
/* Yup, read */
if ((g_clk_reg1 == 0x28) && (g_temp_boot_slot != 254)){
if ((g_clk_reg1 == 0x28) && (g_temp_boot_slot != 254)) {
// Modify boot slot
g_c033_data = g_temp_boot_slot;
clk_calculate_bram_checksum();

View File

@ -3,6 +3,6 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
char g_compile_time[] = "Compiled: " __DATE__ " " __TIME__ ;
char g_compile_time[] = "Compiled: " __DATE__ " " __TIME__;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include <stdarg.h>
@ -230,27 +230,27 @@ Cfg_menu g_cfg_uiless_menu[] = {
Cfg_menu g_cfg_disk_menu[] = {
{ "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU },
{ "s5d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x5000 },
{ "s5d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x5010 },
{ "", 0, 0, 0, 0 },
{ "s6d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x6000 },
{ "s6d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x6010 },
{ "", 0, 0, 0, 0 },
{ "s7d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x7000 },
{ "s7d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x7010 },
{ "s7d3 = ", 0, 0, 0, CFGTYPE_DISK + 0x7020 },
{ "s7d4 = ", 0, 0, 0, CFGTYPE_DISK + 0x7030 },
{ "s7d5 = ", 0, 0, 0, CFGTYPE_DISK + 0x7040 },
{ "s7d6 = ", 0, 0, 0, CFGTYPE_DISK + 0x7050 },
{ "s7d7 = ", 0, 0, 0, CFGTYPE_DISK + 0x7060 },
{ "s7d8 = ", 0, 0, 0, CFGTYPE_DISK + 0x7070 },
{ "s7d9 = ", 0, 0, 0, CFGTYPE_DISK + 0x7080 },
{ "s7d10 = ", 0, 0, 0, CFGTYPE_DISK + 0x7090 },
{ "s7d11 = ", 0, 0, 0, CFGTYPE_DISK + 0x70a0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU },
{ "s5d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x5000 },
{ "s5d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x5010 },
{ "", 0, 0, 0, 0 },
{ "s6d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x6000 },
{ "s6d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x6010 },
{ "", 0, 0, 0, 0 },
{ "s7d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x7000 },
{ "s7d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x7010 },
{ "s7d3 = ", 0, 0, 0, CFGTYPE_DISK + 0x7020 },
{ "s7d4 = ", 0, 0, 0, CFGTYPE_DISK + 0x7030 },
{ "s7d5 = ", 0, 0, 0, CFGTYPE_DISK + 0x7040 },
{ "s7d6 = ", 0, 0, 0, CFGTYPE_DISK + 0x7050 },
{ "s7d7 = ", 0, 0, 0, CFGTYPE_DISK + 0x7060 },
{ "s7d8 = ", 0, 0, 0, CFGTYPE_DISK + 0x7070 },
{ "s7d9 = ", 0, 0, 0, CFGTYPE_DISK + 0x7080 },
{ "s7d10 = ", 0, 0, 0, CFGTYPE_DISK + 0x7090 },
{ "s7d11 = ", 0, 0, 0, CFGTYPE_DISK + 0x70a0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
// OG Use define instead of const for joystick_types
@ -258,215 +258,215 @@ Cfg_menu g_cfg_disk_menu[] = {
#define TOSTRING(x) STRINGIFY(x)
Cfg_menu g_cfg_joystick_menu[] = {
{ "Joystick Configuration", g_cfg_joystick_menu, 0, 0, CFGTYPE_MENU },
{ "Joystick Emulation,"TOSTRING(JOYSTICK_TYPE_KEYPAD)",Keypad Joystick,"TOSTRING(JOYSTICK_TYPE_MOUSE)",Mouse Joystick,"TOSTRING(JOYSTICK_TYPE_NATIVE_1)",Native Joystick 1,"
TOSTRING(JOYSTICK_TYPE_NATIVE_2)",Native Joystick 2,"TOSTRING(JOYSTICK_TYPE_NONE)",No Joystick", KNMP(g_joystick_type), CFGTYPE_INT },
{ "Joystick Scale X,0x100,Standard,0x119,+10%,0x133,+20%,"
{ "Joystick Configuration", g_cfg_joystick_menu, 0, 0, CFGTYPE_MENU },
{ "Joystick Emulation,"TOSTRING (JOYSTICK_TYPE_KEYPAD)",Keypad Joystick,"TOSTRING (JOYSTICK_TYPE_MOUSE)",Mouse Joystick,"TOSTRING (JOYSTICK_TYPE_NATIVE_1)",Native Joystick 1,"
TOSTRING(JOYSTICK_TYPE_NATIVE_2) ",Native Joystick 2,"TOSTRING (JOYSTICK_TYPE_NONE)",No Joystick", KNMP(g_joystick_type), CFGTYPE_INT },
{ "Joystick Scale X,0x100,Standard,0x119,+10%,0x133,+20%,"
"0x150,+30%,0xb0,-30%,0xcd,-20%,0xe7,-10%",
KNMP(g_joystick_scale_factor_x), CFGTYPE_INT },
{ "Joystick Scale Y,0x100,Standard,0x119,+10%,0x133,+20%,"
{ "Joystick Scale Y,0x100,Standard,0x119,+10%,0x133,+20%,"
"0x150,+30%,0xb0,-30%,0xcd,-20%,0xe7,-10%",
KNMP(g_joystick_scale_factor_y), CFGTYPE_INT },
{ "Joystick Trim X", KNMP(g_joystick_trim_amount_x), CFGTYPE_INT },
{ "Joystick Trim Y", KNMP(g_joystick_trim_amount_y), CFGTYPE_INT },
{ "Swap Joystick X and Y,0,Normal operation,1,Paddle 1 and Paddle 0 swapped",
{ "Joystick Trim X", KNMP(g_joystick_trim_amount_x), CFGTYPE_INT },
{ "Joystick Trim Y", KNMP(g_joystick_trim_amount_y), CFGTYPE_INT },
{ "Swap Joystick X and Y,0,Normal operation,1,Paddle 1 and Paddle 0 swapped",
KNMP(g_swap_paddles), CFGTYPE_INT },
{ "Invert Joystick,0,Normal operation,1,Left becomes right and up becomes down",
{ "Invert Joystick,0,Normal operation,1,Left becomes right and up becomes down",
KNMP(g_invert_paddles), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_rom_menu[] = {
{ "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU },
{ "ROM File", KNMP(g_cfg_rom_path), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU },
{ "ROM File", KNMP(g_cfg_rom_path), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_host_menu[] = {
{ "Host FST Configuration", g_cfg_host_menu, 0, 0, CFGTYPE_MENU },
{ "Shared Host Folder", KNMP(g_cfg_host_path), CFGTYPE_DIR },
{ "Read Only,0,No,1,Yes", KNMP(g_cfg_host_read_only), CFGTYPE_INT },
{ "CR/LF conversion,0,No,1,Yes", KNMP(g_cfg_host_crlf), CFGTYPE_INT },
{ "Merlin conversion,0,No,1,Yes", KNMP(g_cfg_host_merlin), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "Host FST Configuration", g_cfg_host_menu, 0, 0, CFGTYPE_MENU },
{ "Shared Host Folder", KNMP(g_cfg_host_path), CFGTYPE_DIR },
{ "Read Only,0,No,1,Yes", KNMP(g_cfg_host_read_only), CFGTYPE_INT },
{ "CR/LF conversion,0,No,1,Yes", KNMP(g_cfg_host_crlf), CFGTYPE_INT },
{ "Merlin conversion,0,No,1,Yes", KNMP(g_cfg_host_merlin), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_serial_menu[] = {
{ "Serial Port Configuration", g_cfg_serial_menu, 0, 0, CFGTYPE_MENU },
{ "Serial Port Configuration", g_cfg_serial_menu, 0, 0, CFGTYPE_MENU },
#ifdef HAVE_SDL
{ "Port 0 (slot 1),0,Only use socket 6501,1,Use real port if avail,2,Virtual ImageWriter",
{ "Port 0 (slot 1),0,Only use socket 6501,1,Use real port if avail,2,Virtual ImageWriter",
KNMP(g_serial_type[0]), CFGTYPE_INT },
{ "Port 1 (slot 2),0,Only use socket 6502,1,Use real port if avail,2,Virtual ImageWriter",
{ "Port 1 (slot 2),0,Only use socket 6502,1,Use real port if avail,2,Virtual ImageWriter",
KNMP(g_serial_type[1]), CFGTYPE_INT },
#else
{ "Port 0 (slot 1),0,Only use socket 6501,1,Use real port if avail",
{ "Port 0 (slot 1),0,Only use socket 6501,1,Use real port if avail",
KNMP(g_serial_type[0]), CFGTYPE_INT },
{ "Port 1 (slot 2),0,Only use socket 6502,1,Use real port if avail",
{ "Port 1 (slot 2),0,Only use socket 6502,1,Use real port if avail",
KNMP(g_serial_type[1]), CFGTYPE_INT },
#endif
{ "Serial Output,0,Send full 8-bit data,1,Mask off high bit",
{ "Serial Output,0,Send full 8-bit data,1,Mask off high bit",
KNMP(g_serial_out_masking), CFGTYPE_INT },
{ "Modem on port 0 (slot 1),0,Simple socket emulation mode,1,Modem with "
{ "Modem on port 0 (slot 1),0,Simple socket emulation mode,1,Modem with "
"incoming and outgoing emulation", KNMP(g_serial_modem[0]),
CFGTYPE_INT },
{ "Modem on port 1 (slot 2),0,Simple socket emulation mode,1,Modem with "
{ "Modem on port 1 (slot 2),0,Simple socket emulation mode,1,Modem with "
"incoming and outgoing emulation", KNMP(g_serial_modem[1]),
CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_parallel_menu[] = {
{ "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU },
{ "Parallel Card in Slot 1,0,Off,1,On",
{ "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU },
{ "Parallel Card in Slot 1,0,Off,1,On",
KNMP(g_parallel), CFGTYPE_INT },
{ "Parallel Output,0,Send full 8-bit data,1,Mask off high bit",
{ "Parallel Output,0,Send full 8-bit data,1,Mask off high bit",
KNMP(g_parallel_out_masking), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_ethernet_menu[] = {
{ "Ethernet Card Configuration", g_cfg_ethernet_menu, 0, 0, CFGTYPE_MENU },
{ "Use Interface Number,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10",
{ "Ethernet Card Configuration", g_cfg_ethernet_menu, 0, 0, CFGTYPE_MENU },
{ "Use Interface Number,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10",
KNMP(g_ethernet_interface), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Uthernet Card in Slot 3,0,Off,1,On",
{ "", 0, 0, 0, 0 },
{ "Uthernet Card in Slot 3,0,Off,1,On",
KNMP(g_ethernet), CFGTYPE_INT },
#ifdef HAVE_ATBRIDGE
{ "", 0, 0, 0, 0 },
{ "AppleTalk Bridging,0,Off,1,On",
{ "", 0, 0, 0, 0 },
{ "AppleTalk Bridging,0,Off,1,On",
KNMP(g_appletalk_bridging), CFGTYPE_INT },
{ "AppleTalk Speed,0,Normal (230.4 kbps),1,Turbo",
{ "AppleTalk Speed,0,Normal (230.4 kbps),1,Turbo",
KNMP(g_appletalk_turbo), CFGTYPE_INT },
#endif
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
#ifdef HAVE_SDL
Cfg_menu g_cfg_printer_menu[] = {
{ "Virtual Epson Configuration", g_cfg_printer_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Printer Type,0,Epson LQ",
{ "Virtual Epson Configuration", g_cfg_printer_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Printer Type,0,Epson LQ",
KNMP(g_printer), CFGTYPE_INT },
{ "Printer DPI,60,60x60 dpi,180,180x180 dpi,360,360x360 dpi",
{ "Printer DPI,60,60x60 dpi,180,180x180 dpi,360,360x360 dpi",
KNMP(g_printer_dpi), CFGTYPE_INT },
{ "Printer Output Type,bmp,Windows Bitmap,ps,Postscript (B&W),printer,Direct to host printer,text,Text file",
{ "Printer Output Type,bmp,Windows Bitmap,ps,Postscript (B&W),printer,Direct to host printer,text,Text file",
KNMP(g_printer_output), CFGTYPE_STR },
{ "Multipage Files? (PS and Direct to Host Only),0,No,1,Yes",
{ "Multipage Files? (PS and Direct to Host Only),0,No,1,Yes",
KNMP(g_printer_multipage), CFGTYPE_INT },
{ "Printer Timeout,0,Never,2,2 sec.,15,15 sec.,30,30 sec.,60, 1 min.",
{ "Printer Timeout,0,Never,2,2 sec.,15,15 sec.,30,30 sec.,60, 1 min.",
KNMP(g_printer_timeout), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Epson LQ Fonts", 0, 0, 0, 0 },
{ "--------------", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Roman", KNMP(g_printer_font_roman), CFGTYPE_FILE },
{ "Sans Serif", KNMP(g_printer_font_sans), CFGTYPE_FILE },
{ "Courier", KNMP(g_printer_font_courier), CFGTYPE_FILE },
{ "Prestige", KNMP(g_printer_font_prestige), CFGTYPE_FILE },
{ "Script", KNMP(g_printer_font_script), CFGTYPE_FILE },
{ "OCR A/B", KNMP(g_printer_font_ocra), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Epson LQ Fonts", 0, 0, 0, 0 },
{ "--------------", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Roman", KNMP(g_printer_font_roman), CFGTYPE_FILE },
{ "Sans Serif", KNMP(g_printer_font_sans), CFGTYPE_FILE },
{ "Courier", KNMP(g_printer_font_courier), CFGTYPE_FILE },
{ "Prestige", KNMP(g_printer_font_prestige), CFGTYPE_FILE },
{ "Script", KNMP(g_printer_font_script), CFGTYPE_FILE },
{ "OCR A/B", KNMP(g_printer_font_ocra), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_imagewriter_menu[] = {
{ "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Printer Type,0,ImageWriter II,1,ImageWriter LQ",
{ "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Printer Type,0,ImageWriter II,1,ImageWriter LQ",
KNMP(g_imagewriter), CFGTYPE_INT },
{ "Paper Size,0,US Letter (8.5x11in),1,US Legal (8.5x14in),2,ISO A4 (210 x 297mm),3,ISO B5 (176 x 250mm),4,Wide Fanfold (14 x 11in),5,Ledger (11 x 17in),6,ISO A3 (297 x 420mm)",
{ "Paper Size,0,US Letter (8.5x11in),1,US Legal (8.5x14in),2,ISO A4 (210 x 297mm),3,ISO B5 (176 x 250mm),4,Wide Fanfold (14 x 11in),5,Ledger (11 x 17in),6,ISO A3 (297 x 420mm)",
KNMP(g_imagewriter_paper), CFGTYPE_INT },
{ "Printer DPI,360,360x360 dpi (Best for 8-bit software),720,720x720 dpi (Best for GS/OS & IW LQ Modes),1440,1440x1440 dpi",
{ "Printer DPI,360,360x360 dpi (Best for 8-bit software),720,720x720 dpi (Best for GS/OS & IW LQ Modes),1440,1440x1440 dpi",
KNMP(g_imagewriter_dpi), CFGTYPE_INT },
{ "Banner Printing (Limited To 144x144 dpi Output),0,Banner Printing Off,3,3 Pages Long,4,4 Pages Long,5,5 Pages Long,6,6 Pages Long,7,7 Pages Long,8,8 Pages Long,9,9 Pages Long,10,10 Pages Long",
{ "Banner Printing (Limited To 144x144 dpi Output),0,Banner Printing Off,3,3 Pages Long,4,4 Pages Long,5,5 Pages Long,6,6 Pages Long,7,7 Pages Long,8,8 Pages Long,9,9 Pages Long,10,10 Pages Long",
KNMP(g_imagewriter_banner), CFGTYPE_INT },
{ "Printer Output Type,bmp,Windows Bitmap,ps,Postscript (B&W),colorps,Postscript (Color),printer,Direct to host printer,text,Text file",
{ "Printer Output Type,bmp,Windows Bitmap,ps,Postscript (B&W),colorps,Postscript (Color),printer,Direct to host printer,text,Text file",
KNMP(g_imagewriter_output), CFGTYPE_STR },
{ "Multipage Files? (PS and Direct to Host Only),0,No,1,Yes",
{ "Multipage Files? (PS and Direct to Host Only),0,No,1,Yes",
KNMP(g_imagewriter_multipage), CFGTYPE_INT },
{ "Printer Timeout,0,Never,2,2 sec.,15,15 sec.,30,30 sec.,60, 1 min.",
{ "Printer Timeout,0,Never,2,2 sec.,15,15 sec.,30,30 sec.,60, 1 min.",
KNMP(g_imagewriter_timeout), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "ImageWriter Fonts", 0, 0, 0, 0 },
{ "-----------------", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Fixed Width Font", KNMP(g_imagewriter_fixed_font), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "Proportional Font", KNMP(g_imagewriter_prop_font), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "ImageWriter Fonts", 0, 0, 0, 0 },
{ "-----------------", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Fixed Width Font", KNMP(g_imagewriter_fixed_font), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "Proportional Font", KNMP(g_imagewriter_prop_font), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
#endif
Cfg_menu g_cfg_devel_menu[] = {
{ "Developer Options", g_cfg_devel_menu, 0, 0, CFGTYPE_MENU },
{ "Developer Options", g_cfg_devel_menu, 0, 0, CFGTYPE_MENU },
#if defined(_WIN32) || defined(__CYGWIN__) && !defined(WIN_SDL)
{ "Status lines,0,Hide,1,Show", KNMP(g_win_status_debug_request), CFGTYPE_INT },
{ "Console,0,Hide,1,Show", KNMP(g_win_show_console_request), CFGTYPE_INT },
{ "Status lines,0,Hide,1,Show", KNMP(g_win_status_debug_request), CFGTYPE_INT },
{ "Console,0,Hide,1,Show", KNMP(g_win_show_console_request), CFGTYPE_INT },
#endif
#ifdef HAVE_ATBRIDGE
{ "", 0, 0, 0, 0 },
{ "Show AppleTalk Diagnostics,0,No,1,Yes", KNMP(g_appletalk_diagnostics), CFGTYPE_INT },
{ "AppleTalk Network Hint", KNMP(g_appletalk_network_hint), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Show AppleTalk Diagnostics,0,No,1,Yes", KNMP(g_appletalk_diagnostics), CFGTYPE_INT },
{ "AppleTalk Network Hint", KNMP(g_appletalk_network_hint), CFGTYPE_INT },
#endif
{ "", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
#ifndef _WIN32
{ "Force X-windows display depth", KNMP(g_force_depth), CFGTYPE_INT },
{ "Force X-windows display depth", KNMP(g_force_depth), CFGTYPE_INT },
#endif
{ "Code Red Halts,0,Do not stop on bad accesses,1,Enter debugger on bad accesses", KNMP(g_user_halt_bad), CFGTYPE_INT },
{ "3200 Color Enable,0,Auto (Full if fast enough),1,Full (Update every line),8,Off (Update video every 8 lines)", KNMP(g_video_line_update_interval), CFGTYPE_INT },
{ "Keyboard and mouse poll rate,0,60 times per second,1,240 times per second", KNMP(g_video_extra_check_inputs), CFGTYPE_INT },
{ "Enable Text Page 2 Shadow,0,Disabled on ROM 01 (matches real hardware),1,Enabled on ROM 01 and 03", KNMP(g_user_page2_shadow), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
{ "Code Red Halts,0,Do not stop on bad accesses,1,Enter debugger on bad accesses", KNMP(g_user_halt_bad), CFGTYPE_INT },
{ "3200 Color Enable,0,Auto (Full if fast enough),1,Full (Update every line),8,Off (Update video every 8 lines)", KNMP(g_video_line_update_interval), CFGTYPE_INT },
{ "Keyboard and mouse poll rate,0,60 times per second,1,240 times per second", KNMP(g_video_extra_check_inputs), CFGTYPE_INT },
{ "Enable Text Page 2 Shadow,0,Disabled on ROM 01 (matches real hardware),1,Enabled on ROM 01 and 03", KNMP(g_user_page2_shadow), CFGTYPE_INT },
{ "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 },
};
Cfg_menu g_cfg_main_menu[] = {
{ "GSplus Configuration", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU },
{ "Joystick Configuration", g_cfg_joystick_menu, 0, 0, CFGTYPE_MENU },
{ "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU },
{ "HOST FST Configuration", g_cfg_host_menu, 0, 0, CFGTYPE_MENU },
{ "Serial Port Configuration", g_cfg_serial_menu, 0, 0, CFGTYPE_MENU },
{ "Ethernet Card Configuration", g_cfg_ethernet_menu, 0, 0, CFGTYPE_MENU },
{ "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU },
{ "GSplus Configuration", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU },
{ "Joystick Configuration", g_cfg_joystick_menu, 0, 0, CFGTYPE_MENU },
{ "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU },
{ "HOST FST Configuration", g_cfg_host_menu, 0, 0, CFGTYPE_MENU },
{ "Serial Port Configuration", g_cfg_serial_menu, 0, 0, CFGTYPE_MENU },
{ "Ethernet Card Configuration", g_cfg_ethernet_menu, 0, 0, CFGTYPE_MENU },
{ "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU },
#ifdef HAVE_SDL
{ "Virtual Epson Configuration", g_cfg_printer_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Epson Configuration", g_cfg_printer_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU },
#endif
{ "Developer Options", g_cfg_devel_menu, 0, 0, CFGTYPE_MENU },
{ "Auto-update configuration file,0,Manual,1,Immediately", KNMP(g_config_gsplus_auto_update), CFGTYPE_INT },
{ "Speed,0,Unlimited,1,1.0MHz,2,2.8MHz,3,8.0MHz (Zip)", KNMP(g_limit_speed), CFGTYPE_INT },
{ "Expansion Mem Size,0,0MB,0x100000,1MB,0x200000,2MB,0x300000,3MB,"
{ "Developer Options", g_cfg_devel_menu, 0, 0, CFGTYPE_MENU },
{ "Auto-update configuration file,0,Manual,1,Immediately", KNMP(g_config_gsplus_auto_update), CFGTYPE_INT },
{ "Speed,0,Unlimited,1,1.0MHz,2,2.8MHz,3,8.0MHz (Zip)", KNMP(g_limit_speed), CFGTYPE_INT },
{ "Expansion Mem Size,0,0MB,0x100000,1MB,0x200000,2MB,0x300000,3MB,"
"0x400000,4MB,0x600000,6MB,0x800000,8MB,0xa00000,10MB,0xc00000,12MB,"
"0xe00000,14MB", KNMP(g_mem_size_exp), CFGTYPE_INT },
{ "Dump text screen to file", (void *)cfg_text_screen_dump, 0, 0, CFGTYPE_FUNC},
{ "Dump text screen to file", (void *)cfg_text_screen_dump, 0, 0, CFGTYPE_FUNC},
#ifdef HAVE_SDL
{ "Reset Virtual ImageWriter", (void *)cfg_iwreset, 0, 0, CFGTYPE_FUNC },
{ "Reset Virtual ImageWriter", (void *)cfg_iwreset, 0, 0, CFGTYPE_FUNC },
#endif
{ "", 0, 0, 0, 0 },
{ "Save changes to configuration file", (void *)config_write_config_gsplus_file, 0, 0,
{ "", 0, 0, 0, 0 },
{ "Save changes to configuration file", (void *)config_write_config_gsplus_file, 0, 0,
CFGTYPE_FUNC },
{ "", 0, 0, 0, 0 },
{ "Exit Config (or press F4)", (void *)cfg_exit, 0, 0, CFGTYPE_FUNC },
{ 0, 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 },
{ "Exit Config (or press F4)", (void *)cfg_exit, 0, 0, CFGTYPE_FUNC },
{ 0, 0, 0, 0, 0 },
};
@ -490,7 +490,7 @@ Cfg_listhdr g_cfg_partitionlist = { 0 };
int g_cfg_file_pathfield = 0;
const char *g_gsplus_rom_names[] = { "ROM", "ROM", "ROM01", "ROM03", "ROM.01", "ROM.03", 0 };
/* First entry is special--it will be overwritten by g_cfg_rom_path */
/* First entry is special--it will be overwritten by g_cfg_rom_path */
const char *g_gsplus_c1rom_names[] = { "parallel.rom", 0 };
const char *g_gsplus_c2rom_names[] = { 0 };
@ -504,7 +504,8 @@ const char **g_gsplus_rom_card_list[8] = {
0, g_gsplus_c1rom_names,
g_gsplus_c2rom_names, g_gsplus_c3rom_names,
g_gsplus_c4rom_names, g_gsplus_c5rom_names,
g_gsplus_c6rom_names, g_gsplus_c7rom_names };
g_gsplus_c6rom_names, g_gsplus_c7rom_names
};
byte g_rom_c600_rom01_diffs[256] = {
0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xe2, 0x00,
@ -542,9 +543,7 @@ byte g_rom_c600_rom01_diffs[256] = {
};
void
config_init_menus(Cfg_menu *menuptr)
{
void config_init_menus(Cfg_menu *menuptr) {
void *voidptr;
const char *name_str;
Cfg_defval *defptr;
@ -606,9 +605,7 @@ config_init_menus(Cfg_menu *menuptr)
}
}
void
config_init()
{
void config_init() {
int can_create;
config_init_menus(g_cfg_main_menu);
@ -622,26 +619,20 @@ config_init()
config_parse_config_gsplus_file();
}
void
cfg_exit()
{
void cfg_exit() {
if(g_rom_version >= 1) {
g_config_control_panel = 0;
}
}
void
cfg_toggle_config_panel()
{
void cfg_toggle_config_panel() {
g_config_control_panel = !g_config_control_panel;
if(g_rom_version < 0) {
g_config_control_panel = 1; /* Stay in config mode */
}
}
void
cfg_text_screen_dump()
{
void cfg_text_screen_dump() {
char buf[85];
char *filename;
FILE *ofile;
@ -686,18 +677,14 @@ cfg_text_screen_dump()
}
fclose(ofile);
}
void
cfg_iwreset()
{
void cfg_iwreset() {
imagewriter_feed();
imagewriter_close();
imagewriter_init(g_imagewriter_dpi,g_imagewriter_paper,g_imagewriter_banner, g_imagewriter_output,g_imagewriter_multipage);
return;
}
#ifdef HAVE_TFE
void
cfg_get_tfe_name()
{
void cfg_get_tfe_name() {
int i = 0;
char *ppname = NULL;
char *ppdes = NULL;
@ -727,9 +714,7 @@ cfg_get_tfe_name()
}
#endif
void
config_vbl_update(int doit_3_persec)
{
void config_vbl_update(int doit_3_persec) {
if(doit_3_persec) {
if(g_config_gsplus_auto_update && g_config_gsplus_update_needed) {
config_write_config_gsplus_file();
@ -738,9 +723,7 @@ config_vbl_update(int doit_3_persec)
return;
}
void
config_parse_option(char *buf, int pos, int len, int line)
{
void config_parse_option(char *buf, int pos, int len, int line) {
Cfg_menu *menuptr;
Cfg_defval *defptr;
char *nameptr;
@ -827,9 +810,7 @@ config_parse_option(char *buf, int pos, int len, int line)
}
void
config_parse_bram(char *buf, int pos, int len)
{
void config_parse_bram(char *buf, int pos, int len) {
int bram_num;
int offset;
int val;
@ -862,9 +843,7 @@ config_parse_bram(char *buf, int pos, int len)
}
}
void
config_load_roms()
{
void config_load_roms() {
struct stat stat_buf;
const char **names_ptr;
int more_than_8mb;
@ -1062,9 +1041,7 @@ config_load_roms()
}
}
void
config_parse_config_gsplus_file()
{
void config_parse_config_gsplus_file() {
FILE *fconf;
char *buf;
char *ptr;
@ -1169,7 +1146,7 @@ config_parse_config_gsplus_file()
if(buf[pos] == ',') {
/* read optional size parameter */
pos++;
while(pos < len && buf[pos] >= '0' && buf[pos] <= '9'){
while(pos < len && buf[pos] >= '0' && buf[pos] <= '9') {
size = size * 10 + buf[pos] - '0';
pos++;
}
@ -1225,9 +1202,7 @@ config_parse_config_gsplus_file()
}
Disk *
cfg_get_dsk_from_slot_drive(int slot, int drive)
{
Disk *cfg_get_dsk_from_slot_drive(int slot, int drive) {
Disk *dsk;
int max_drive;
@ -1252,10 +1227,8 @@ cfg_get_dsk_from_slot_drive(int slot, int drive)
return dsk;
}
void
config_generate_config_gsplus_name(char *outstr, int maxlen, Disk *dsk,
int with_extras)
{
void config_generate_config_gsplus_name(char *outstr, int maxlen, Disk *dsk,
int with_extras) {
char *str;
str = outstr;
@ -1280,9 +1253,7 @@ config_generate_config_gsplus_name(char *outstr, int maxlen, Disk *dsk,
snprintf(str, maxlen - (str - outstr), "%s", dsk->name_ptr);
}
void
config_write_config_gsplus_file()
{
void config_write_config_gsplus_file() {
FILE *fconf;
Disk *dsk;
Cfg_defval *defptr;
@ -1370,10 +1341,8 @@ config_write_config_gsplus_file()
g_config_gsplus_update_needed = 0;
}
void
insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
const char *partition_name, int part_num)
{
void insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
const char *partition_name, int part_num) {
byte buf_2img[512];
Disk *dsk;
char *name_ptr, *uncomp_ptr, *system_str;
@ -1700,9 +1669,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
}
void
eject_named_disk(Disk *dsk, const char *name, const char *partition_name)
{
void eject_named_disk(Disk *dsk, const char *name, const char *partition_name) {
if(!dsk->file) {
return;
@ -1723,9 +1690,7 @@ eject_named_disk(Disk *dsk, const char *name, const char *partition_name)
}
}
void
eject_disk_by_num(int slot, int drive)
{
void eject_disk_by_num(int slot, int drive) {
Disk *dsk;
dsk = cfg_get_dsk_from_slot_drive(slot, drive);
@ -1733,9 +1698,7 @@ eject_disk_by_num(int slot, int drive)
eject_disk(dsk);
}
void
eject_disk(Disk *dsk)
{
void eject_disk(Disk *dsk) {
int motor_on;
int i;
@ -1788,9 +1751,7 @@ eject_disk(Disk *dsk)
/* Leave name_ptr valid */
}
int
cfg_get_fd_size(char *filename)
{
int cfg_get_fd_size(char *filename) {
struct stat stat_buf;
int ret;
@ -1804,9 +1765,7 @@ cfg_get_fd_size(char *filename)
return stat_buf.st_size;
}
int
cfg_partition_read_block(FILE *file, void *buf, int blk, int blk_size)
{
int cfg_partition_read_block(FILE *file, void *buf, int blk, int blk_size) {
int ret;
ret = fseek(file, blk * blk_size, SEEK_SET);
@ -1825,10 +1784,8 @@ cfg_partition_read_block(FILE *file, void *buf, int blk, int blk_size)
return ret;
}
int
cfg_partition_find_by_name_or_num(FILE *file, const char *partnamestr, int part_num,
Disk *dsk)
{
int cfg_partition_find_by_name_or_num(FILE *file, const char *partnamestr, int part_num,
Disk *dsk) {
Cfg_dirent *direntptr;
int match;
int num_parts;
@ -1868,9 +1825,7 @@ cfg_partition_find_by_name_or_num(FILE *file, const char *partnamestr, int part_
return -1;
}
int
cfg_partition_make_list(char *filename, FILE *file)
{
int cfg_partition_make_list(char *filename, FILE *file) {
Driver_desc *driver_desc_ptr;
Part_map *part_map_ptr;
word32 *blk_bufptr;
@ -1963,9 +1918,7 @@ cfg_partition_make_list(char *filename, FILE *file)
return g_cfg_partitionlist.last;
}
int
cfg_maybe_insert_disk(int slot, int drive, const char *namestr)
{
int cfg_maybe_insert_disk(int slot, int drive, const char *namestr) {
int num_parts;
FILE *file;
@ -1988,9 +1941,7 @@ cfg_maybe_insert_disk(int slot, int drive, const char *namestr)
return 0;
}
int
cfg_stat(char *path, struct stat *sb)
{
int cfg_stat(char *path, struct stat *sb) {
int removed_slash;
int len;
int ret;
@ -2019,9 +1970,7 @@ cfg_stat(char *path, struct stat *sb)
return ret;
}
void
cfg_htab_vtab(int x, int y)
{
void cfg_htab_vtab(int x, int y) {
if(x > 79) {
x = 0;
}
@ -2034,9 +1983,7 @@ cfg_htab_vtab(int x, int y)
g_cfg_curs_mousetext = 0;
}
void
cfg_home()
{
void cfg_home() {
int i;
cfg_htab_vtab(0, 0);
@ -2045,9 +1992,7 @@ cfg_home()
}
}
void
cfg_cleol()
{
void cfg_cleol() {
g_cfg_curs_inv = 0;
g_cfg_curs_mousetext = 0;
cfg_putchar(' ');
@ -2056,9 +2001,7 @@ cfg_cleol()
}
}
void
cfg_putchar(int c)
{
void cfg_putchar(int c) {
int offset;
int x, y;
@ -2104,9 +2047,7 @@ cfg_putchar(int c)
g_cfg_curs_x = x;
}
void
cfg_printf(const char *fmt, ...)
{
void cfg_printf(const char *fmt, ...) {
va_list ap;
int c;
int i;
@ -2124,9 +2065,7 @@ cfg_printf(const char *fmt, ...)
}
}
void
cfg_print_num(int num, int max_len)
{
void cfg_print_num(int num, int max_len) {
char buf[64];
char buf2[64];
int len;
@ -2158,9 +2097,7 @@ cfg_print_num(int num, int max_len)
cfg_printf(&buf2[1]);
}
void
cfg_get_disk_name(char *outstr, int maxlen, int type_ext, int with_extras)
{
void cfg_get_disk_name(char *outstr, int maxlen, int type_ext, int with_extras) {
Disk *dsk;
int slot, drive;
@ -2176,9 +2113,7 @@ cfg_get_disk_name(char *outstr, int maxlen, int type_ext, int with_extras)
config_generate_config_gsplus_name(outstr, maxlen, dsk, with_extras);
}
void
cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change)
{
void cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change) {
char valbuf[CFG_OPT_MAXSTR];
char **str_ptr;
const char *menustr;
@ -2460,9 +2395,7 @@ cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change)
g_cfg_opt_buf[CFG_OPT_MAXSTR-1] = 0;
}
void
cfg_get_base_path(char *pathptr, const char *inptr, int go_up)
{
void cfg_get_base_path(char *pathptr, const char *inptr, int go_up) {
const char *tmpptr;
char *slashptr;
char *outptr;
@ -2551,9 +2484,7 @@ cfg_get_base_path(char *pathptr, const char *inptr, int go_up)
// pathptr, is_dotdot, add_dotdot);
}
void
cfg_file_init()
{
void cfg_file_init() {
int slot, drive;
int i;
@ -2587,9 +2518,7 @@ cfg_file_init()
g_cfg_dirlist.invalid = 1;
}
void
cfg_free_alldirents(Cfg_listhdr *listhdrptr)
{
void cfg_free_alldirents(Cfg_listhdr *listhdrptr) {
int i;
if(listhdrptr->max > 0) {
@ -2610,10 +2539,8 @@ cfg_free_alldirents(Cfg_listhdr *listhdrptr)
}
void
cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir,
int size, int image_start, int part_num)
{
void cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir,
int size, int image_start, int part_num) {
Cfg_dirent *direntptr;
char *ptr;
int inc_amt;
@ -2645,9 +2572,7 @@ cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir,
listhdrptr->last++;
}
int
cfg_dirent_sortfn(const void *obj1, const void *obj2)
{
int cfg_dirent_sortfn(const void *obj1, const void *obj2) {
const Cfg_dirent *direntptr1, *direntptr2;
int ret;
@ -2664,9 +2589,7 @@ cfg_dirent_sortfn(const void *obj1, const void *obj2)
return ret;
}
int
cfg_str_match(const char *str1, const char *str2, int len)
{
int cfg_str_match(const char *str1, const char *str2, int len) {
const byte *bptr1, *bptr2;
int c, c2;
int i;
@ -2693,9 +2616,7 @@ cfg_str_match(const char *str1, const char *str2, int len)
return 0;
}
void
cfg_file_readdir(const char *pathptr)
{
void cfg_file_readdir(const char *pathptr) {
struct dirent *direntptr;
struct stat stat_buf;
@ -2710,7 +2631,7 @@ cfg_file_readdir(const char *pathptr)
int i;
if(!strncmp(pathptr, &g_cfg_file_cachedpath[0], CFG_PATH_MAX) &&
(g_cfg_dirlist.last > 0) && (g_cfg_dirlist.invalid==0)){
(g_cfg_dirlist.last > 0) && (g_cfg_dirlist.invalid==0)) {
return;
}
// No match, must read new directory
@ -2778,7 +2699,7 @@ cfg_file_readdir(const char *pathptr)
len = strlen(g_cfg_tmp_path);
is_dir = 0;
is_gz = 0;
if((len > 3) && (strcmp(&g_cfg_tmp_path[len - 3], ".gz") == 0)){
if((len > 3) && (strcmp(&g_cfg_tmp_path[len - 3], ".gz") == 0)) {
is_gz = 1;
}
if(ret != 0) {
@ -2825,14 +2746,12 @@ cfg_file_readdir(const char *pathptr)
}
}
void
cfg_inspect_maybe_insert_file(char *filename, int should_boot)
{
void cfg_inspect_maybe_insert_file(char *filename, int should_boot) {
/*
Take a look at a file. Based on its size, guess a slot/drive to insert it into.
Used for blind operations like dragging/dropping files.
Optionally boot from that slot.
*/
Take a look at a file. Based on its size, guess a slot/drive to insert it into.
Used for blind operations like dragging/dropping files.
Optionally boot from that slot.
*/
int rc = 0;
int slot = 0;
rc = cfg_guess_image_size(filename);
@ -2857,17 +2776,15 @@ Optionally boot from that slot.
glogf("Unable to determine appropriate place to insert file %s.",filename);
}
int
cfg_guess_image_size(char *filename)
{
int cfg_guess_image_size(char *filename) {
/*
Guess the image size. Return values:
Guess the image size. Return values:
-1 : invalid/unknown. Can't guess.
0 : Less than 140k; might be ram disk image.
1 : 140k, 5.25" image.
2 : 800k, 3.5" image.
3 : Something bigger.
*/
*/
struct stat stat_buf;
int rc = -1;
int len;
@ -2899,9 +2816,7 @@ Guess the image size. Return values:
return rc;
}
char *
cfg_shorten_filename(const char *in_ptr, int maxlen)
{
char *cfg_shorten_filename(const char *in_ptr, int maxlen) {
char *out_ptr;
int len;
int c;
@ -2932,9 +2847,7 @@ cfg_shorten_filename(const char *in_ptr, int maxlen)
}
return out_ptr;
}
void
cfg_fix_topent(Cfg_listhdr *listhdrptr)
{
void cfg_fix_topent(Cfg_listhdr *listhdrptr) {
int num_to_show;
num_to_show = listhdrptr->num_to_show;
/* Force curent and topent to make sense */
@ -2954,9 +2867,7 @@ cfg_fix_topent(Cfg_listhdr *listhdrptr)
listhdrptr->topent = 0;
}
}
void
cfg_file_draw()
{
void cfg_file_draw() {
Cfg_listhdr *listhdrptr;
Cfg_dirent *direntptr;
char *str, *fmt;
@ -3059,9 +2970,7 @@ cfg_file_draw()
}
cfg_putchar('\t');
}
void
cfg_partition_selected()
{
void cfg_partition_selected() {
char *str;
const char *part_str;
char *part_str2;
@ -3089,9 +2998,7 @@ cfg_partition_selected()
g_cfg_slotdrive = -1;
g_cfg_select_partition = -1;
}
void
cfg_file_update_ptr(char *str)
{
void cfg_file_update_ptr(char *str) {
char *newstr;
int len;
len = strlen(str) + 1;
@ -3109,9 +3016,7 @@ cfg_file_update_ptr(char *str)
}
g_config_gsplus_update_needed = 1;
}
void
cfg_file_selected(int select_dir)
{
void cfg_file_selected(int select_dir) {
struct stat stat_buf;
char *str;
int fmt;
@ -3166,9 +3071,7 @@ cfg_file_selected(int select_dir)
}
}
void
cfg_file_handle_key(int key)
{
void cfg_file_handle_key(int key) {
Cfg_listhdr *listhdrptr;
int len;
if(g_cfg_file_pathfield) {
@ -3249,9 +3152,7 @@ cfg_file_handle_key(int key)
}
}
void
config_control_panel()
{
void config_control_panel() {
void (*fn_ptr)();
const char *str;
Cfg_menu *menuptr;
@ -3499,8 +3400,7 @@ config_control_panel()
g_a2_screen_buffer_changed = -1;
}
void x_clk_setup_bram_version()
{
void x_clk_setup_bram_version() {
if(g_rom_version < 3) {
g_bram_ptr = (&g_bram[0][0]); // ROM 01
} else {

View File

@ -1,3 +1,10 @@
/*
GSPLUS - Advanced Apple IIGS Emulator Environment
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
@ -141,9 +148,7 @@ int debugger_sd = -1; // this holds our socket file descriptor for the debugger,
/* socket debug version */
void
do_go_debug()
{
void do_go_debug() {
while (1) {
if (g_dbg_step >= 0) {
if (g_dbg_step == 1) {
@ -293,9 +298,9 @@ void api_push_cpu() {
tmp_y = eptr->yreg;
tmp_psw = eptr->psr;
int size = snprintf(tmp_buffer_4k, sizeof(tmp_buffer_4k),"{\"type\":\"cpu\",\"data\":{\"K\":\"%02X\",\"PC\":\"%04X\",\"A\":\"%04X\","\
int size = snprintf(tmp_buffer_4k, sizeof(tmp_buffer_4k),"{\"type\":\"cpu\",\"data\":{\"K\":\"%02X\",\"PC\":\"%04X\",\"A\":\"%04X\"," \
"\"X\":\"%04X\",\"Y\":\"%04X\",\"S\":\"%04X\",\"D\":\"%04X\",\"B\":\"%02X\",\"PSR\":\"%04X\"}}",
kpc>>16, kpc & 0xffff ,tmp_acc,tmp_x,tmp_y,stack,direct_page,dbank, tmp_psw & 0xFFF);
kpc>>16, kpc & 0xffff,tmp_acc,tmp_x,tmp_y,stack,direct_page,dbank, tmp_psw & 0xFFF);
char *msg = (char*)malloc(sizeof(char) * size);
strcpy(msg,tmp_buffer_4k);
@ -523,7 +528,7 @@ void handle_set_bytes(int address, char *bytes_data) {
while (sscanf(bytes_data, "%02x", &byte) == 1) {
printf("$%02x <---- BYTE @ $%06X\n", byte, address );
bytes_data += 2;
address ++;
address++;
set_byte_at_address(address, byte & 0xFF);
}
}
@ -791,7 +796,7 @@ void debug_setup_socket() {
/*************************************************************/
/* Initialize the pollfd structure */
/*************************************************************/
memset(fds, 0 , sizeof(fds));
memset(fds, 0, sizeof(fds));
/*************************************************************/
/* Set up the initial listening socket */
@ -865,10 +870,10 @@ void write_array_next() {
int writeDataToClient(int sckt, const void *data, int datalen) {
const char *pdata = (const char*) data;
while (datalen > 0){
while (datalen > 0) {
int numSent = send(sckt, pdata, datalen, 0);
if (numSent <= 0){
if (numSent == 0){
if (numSent <= 0) {
if (numSent == 0) {
printf("The client was not written to: disconnected\n");
} else {
perror("The client was not written to");
@ -1454,9 +1459,9 @@ int do_dis_json(char *buf, word32 kpc, int accsize, int xsize, int op_provided,
// @TODO: FIX!!! NEEDS REAL BUFFER SIZE, note magic 1024
snprintf(buf, 1024,"{\"type\":\"dis\",\"data\":{\"K\":\"%02X\",\"PC\":\"%04X\",\"bytes\":%s,"\
snprintf(buf, 1024,"{\"type\":\"dis\",\"data\":{\"K\":\"%02X\",\"PC\":\"%04X\",\"bytes\":%s," \
"\"disasm\":\"%s\",\"chain\":\"%d\"}}",
oldkpc>>16, oldkpc & 0xffff ,buf_instructions, buf_disasm, chain);
oldkpc>>16, oldkpc & 0xffff,buf_instructions, buf_disasm, chain);
return(args+1);
}

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defcomm.h"
@ -289,10 +289,10 @@ STRUCT(Emustate_word32list) {
(page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr)
#define SET_PAGE_INFO_RD(page,val) \
;page_info_rd_wr[page].rd_wr = (Pg_info)val;
; page_info_rd_wr[page].rd_wr = (Pg_info)val;
#define SET_PAGE_INFO_WR(page,val) \
;page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr = \
; page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr = \
(Pg_info)val;
#define VERBOSE_DISK 0x001

120
src/dis.c
View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include <stdio.h>
#include "defc.h"
@ -51,19 +51,13 @@ int got_num;
// OG replaced by HALT_WANTTOQUIT
//int g_quit_sim_now = 0;
int
get_num()
{
int get_num() {
int tmp1;
a2 = 0;
got_num = 0;
while(1) {
if(mode == 0 && got_num != 0) {
/*
printf("In getnum, mode =0, setting a1,a3 = a2\n");
printf("a2: %x\n", a2);
*/
a3 = a2;
a3bank = a2bank;
a1 = a2;
@ -89,9 +83,7 @@ get_num()
}
}
void
debugger_help()
{
void debugger_help() {
printf("GSplus Debugger Help (courtesy Fredric Devernay)\n\n");
printf("General command syntax:\n");
printf(" [bank]/[address][command]\n\n");
@ -138,9 +130,7 @@ debugger_help()
printf(" q Quit Debugger (and GSplus)\n");
}
void
do_debug_intfc()
{
void do_debug_intfc() {
char linebuf[LINE_SIZE];
int slot_drive;
int track;
@ -183,7 +173,7 @@ do_debug_intfc()
/*
printf("input line: :%s:\n", linebuf);
printf("mode: %d\n", mode);
*/
*/
mode = 0;
while(*line_ptr != 0) {
@ -191,7 +181,7 @@ do_debug_intfc()
/*
printf("ret_val: %x, got_num= %d\n", ret_val,
got_num);
*/
*/
old_mode = mode;
mode = 0;
switch(ret_val) {
@ -404,9 +394,7 @@ do_debug_intfc()
printf("Console closed.\n");
}
word32
dis_get_memory_ptr(word32 addr)
{
word32 dis_get_memory_ptr(word32 addr) {
word32 tmp1, tmp2, tmp3;
tmp1 = get_memory_c(addr, 0);
@ -416,9 +404,7 @@ dis_get_memory_ptr(word32 addr)
return (tmp3 << 16) + (tmp2 << 8) + tmp1;
}
void
show_one_toolset(FILE *toolfile, int toolnum, word32 addr)
{
void show_one_toolset(FILE *toolfile, int toolnum, word32 addr) {
word32 rout_addr;
int num_routs;
int i;
@ -433,9 +419,7 @@ show_one_toolset(FILE *toolfile, int toolnum, word32 addr)
}
}
void
show_toolset_tables(word32 a2bank, word32 addr)
{
void show_toolset_tables(word32 a2bank, word32 addr) {
FILE *toolfile;
word32 tool_addr;
int num_tools;
@ -461,9 +445,7 @@ show_toolset_tables(word32 a2bank, word32 addr)
fclose(toolfile);
}
void
set_bp(word32 addr)
{
void set_bp(word32 addr) {
int count;
printf("About to set BP at %06x\n", addr);
@ -478,9 +460,7 @@ set_bp(word32 addr)
fixup_brks();
}
void
show_bp()
{
void show_bp() {
int i;
printf("Showing breakpoints set\n");
@ -489,9 +469,7 @@ show_bp()
}
}
void
delete_bp(word32 addr)
{
void delete_bp(word32 addr) {
int count;
int hit;
int i;
@ -521,9 +499,7 @@ delete_bp(word32 addr)
show_bp();
}
void
do_blank()
{
void do_blank() {
int tmp, i;
switch(old_mode) {
@ -569,9 +545,7 @@ do_blank()
/* also called by do_step */
void
do_go()
{
void do_go() {
g_config_control_panel = 0;
clear_halt();
run_prog();
@ -579,9 +553,7 @@ do_go()
g_config_control_panel = 1;
}
void
do_step()
{
void do_step() {
int size;
int size_mem_imm, size_x_imm;
@ -602,16 +574,12 @@ do_step()
size = do_dis(stdout, engine.kpc, size_mem_imm, size_x_imm, 0, 0);
}
void
xam_mem(int count)
{
void xam_mem(int count) {
show_hex_mem(a1bank, a1, a2bank, a2, count);
a1 = a2 + 1;
}
void
show_hex_mem(int startbank, word32 start, int endbank, word32 end, int count)
{
void show_hex_mem(int startbank, word32 start, int endbank, word32 end, int count) {
char ascii[MAXNUM_HEX_PER_LINE];
word32 i;
int val, offset;
@ -649,9 +617,7 @@ show_hex_mem(int startbank, word32 start, int endbank, word32 end, int count)
}
int
read_line(char *buf, int len)
{
int read_line(char *buf, int len) {
int space_left;
int ret;
#if !defined(_WIN32)
@ -707,9 +673,7 @@ read_line(char *buf, int len)
return (len-space_left);
}
void
do_debug_list()
{
void do_debug_list() {
int i;
int size;
int size_mem_imm, size_x_imm;
@ -728,16 +692,14 @@ do_debug_list()
if(engine.psr & 0x10) {
size_x_imm = 1;
}
for(i=0;i<20;i++) {
for(i=0; i<20; i++) {
size = do_dis(stdout, list_kpc, size_mem_imm,
size_x_imm, 0, 0);
list_kpc += size;
}
}
void
dis_do_memmove()
{
void dis_do_memmove() {
word32 val;
printf("Memory move from %02x/%04x.%04x to %02x/%04x\n", a1bank, a1, a2, g_a4bank, g_a4);
@ -751,15 +713,11 @@ dis_do_memmove()
g_a4 = g_a4 & 0xffff;
}
void
dis_do_pattern_search()
{
void dis_do_pattern_search() {
printf("Memory pattern search for %04x in %02x/%04x.%04x\n", g_a4, a1bank, a1, a2);
}
void
dis_do_compare()
{
void dis_do_compare() {
word32 val1, val2;
printf("Memory Compare from %02x/%04x.%04x with %02x/%04x\n", a1bank, a1, a2, g_a4bank, g_a4);
@ -776,9 +734,7 @@ dis_do_compare()
g_a4 = g_a4 & 0xffff;
}
void
do_debug_unix()
{
void do_debug_unix() {
char localbuf[LINE_SIZE];
word32 offset, len;
int fd, ret;
@ -855,17 +811,13 @@ do_debug_unix()
a1 = a1 + ret;
}
void
do_debug_load()
{
void do_debug_load() {
printf("Sorry, can't load now\n");
}
int
do_dis(FILE *outfile, word32 kpc, int accsize, int xsize,
int op_provided, word32 instr)
{
int do_dis(FILE *outfile, word32 kpc, int accsize, int xsize,
int op_provided, word32 instr) {
char buffer[150];
const char *out;
int args, type;
@ -1132,10 +1084,8 @@ do_dis(FILE *outfile, word32 kpc, int accsize, int xsize,
return(args+1);
}
void
show_line(FILE *outfile, word32 kaddr, word32 operand, int size,
char *string)
{
void show_line(FILE *outfile, word32 kaddr, word32 operand, int size,
char *string) {
int i;
int opcode;
@ -1143,19 +1093,17 @@ show_line(FILE *outfile, word32 kaddr, word32 operand, int size,
opcode = (operand >> 24) & 0xff;
fprintf(outfile,"%02x ", opcode);
for(i=1;i<size;i++) {
for(i=1; i<size; i++) {
fprintf(outfile, "%02x ", operand & 0xff);
operand = operand >> 8;
}
for(;i<5;i++) {
for(; i<5; i++) {
fprintf(outfile, " ");
}
fprintf(outfile,"%s\n", string);
}
void
halt_printf(const char *fmt, ...)
{
void halt_printf(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
@ -1165,9 +1113,7 @@ halt_printf(const char *fmt, ...)
set_halt(1);
}
void
halt2_printf(const char *fmt, ...)
{
void halt2_printf(const char *fmt, ...) {
va_list args;
va_start(args, fmt);

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "protos_engine_c.h"
@ -151,7 +151,7 @@ extern Page_info page_info_rd_wr[];
extern word32 slow_mem_changed[];
#define GET_MEMORY8(addr,dest) \
addr_latch = (addr);\
addr_latch = (addr); \
CYCLES_PLUS_1; \
stat = GET_PAGE_INFO_RD(((addr) >> 8) & 0xffff); \
wstat = PTR2WORD(stat) & 0xff; \
@ -352,9 +352,7 @@ extern word32 slow_mem_changed[];
ptr[2] = (val) >> 16; \
}
void
check_breakpoints(word32 addr)
{
void check_breakpoints(word32 addr) {
int count;
int i;
@ -367,10 +365,8 @@ check_breakpoints(word32 addr)
}
}
word32
get_memory8_io_stub(word32 addr, byte *stat, double *fcycs_ptr,
double fplus_x_m1)
{
word32 get_memory8_io_stub(word32 addr, byte *stat, double *fcycs_ptr,
double fplus_x_m1) {
double fcycles;
word32 wstat;
byte *ptr;
@ -390,10 +386,8 @@ get_memory8_io_stub(word32 addr, byte *stat, double *fcycs_ptr,
}
}
word32
get_memory16_pieces_stub(word32 addr, byte *stat, double *fcycs_ptr,
Fplus *fplus_ptr, int in_bank)
{
word32 get_memory16_pieces_stub(word32 addr, byte *stat, double *fcycs_ptr,
Fplus *fplus_ptr, int in_bank) {
byte *ptr;
double fcycles, fcycles_tmp1;
double fplus_1;
@ -416,10 +410,8 @@ get_memory16_pieces_stub(word32 addr, byte *stat, double *fcycs_ptr,
return (ret << 8) + (tmp1);
}
word32
get_memory24_pieces_stub(word32 addr, byte *stat, double *fcycs_ptr,
Fplus *fplus_ptr, int in_bank)
{
word32 get_memory24_pieces_stub(word32 addr, byte *stat, double *fcycs_ptr,
Fplus *fplus_ptr, int in_bank) {
byte *ptr;
double fcycles, fcycles_tmp1;
double fplus_1;
@ -448,10 +440,8 @@ get_memory24_pieces_stub(word32 addr, byte *stat, double *fcycs_ptr,
return (ret << 16) + (tmp2 << 8) + tmp1;
}
void
set_memory8_io_stub(word32 addr, word32 val, byte *stat, double *fcycs_ptr,
double fplus_x_m1)
{
void set_memory8_io_stub(word32 addr, word32 val, byte *stat, double *fcycs_ptr,
double fplus_x_m1) {
double fcycles;
word32 setmem_tmp1;
word32 tmp1, tmp2;
@ -495,10 +485,8 @@ set_memory8_io_stub(word32 addr, word32 val, byte *stat, double *fcycs_ptr,
}
}
void
set_memory16_pieces_stub(word32 addr, word32 val, double *fcycs_ptr,
double fplus_1, double fplus_x_m1, int in_bank)
{
void set_memory16_pieces_stub(word32 addr, word32 val, double *fcycs_ptr,
double fplus_1, double fplus_x_m1, int in_bank) {
byte *ptr;
byte *stat;
double fcycles, fcycles_tmp1;
@ -515,10 +503,8 @@ set_memory16_pieces_stub(word32 addr, word32 val, double *fcycs_ptr,
*fcycs_ptr = fcycles;
}
void
set_memory24_pieces_stub(word32 addr, word32 val, double *fcycs_ptr,
Fplus *fplus_ptr, int in_bank)
{
void set_memory24_pieces_stub(word32 addr, word32 val, double *fcycs_ptr,
Fplus *fplus_ptr, int in_bank) {
byte *ptr;
byte *stat;
double fcycles, fcycles_tmp1;
@ -546,9 +532,7 @@ set_memory24_pieces_stub(word32 addr, word32 val, double *fcycs_ptr,
}
word32
get_memory_c(word32 addr, int cycs)
{
word32 get_memory_c(word32 addr, int cycs) {
byte *stat;
byte *ptr;
double fcycles, fcycles_tmp1;
@ -565,9 +549,7 @@ get_memory_c(word32 addr, int cycs)
return ret;
}
word32
get_memory16_c(word32 addr, int cycs)
{
word32 get_memory16_c(word32 addr, int cycs) {
double fcycs;
fcycs = 0;
@ -575,9 +557,7 @@ get_memory16_c(word32 addr, int cycs)
(get_memory_c(addr+1, (int)fcycs) << 8);
}
word32
get_memory24_c(word32 addr, int cycs)
{
word32 get_memory24_c(word32 addr, int cycs) {
double fcycs;
fcycs = 0;
@ -589,9 +569,7 @@ get_memory24_c(word32 addr, int cycs)
word32
get_memory32_c(word32 addr, int cycs)
{
word32 get_memory32_c(word32 addr, int cycs) {
double fcycs;
fcycs = 0;
@ -603,9 +581,7 @@ get_memory32_c(word32 addr, int cycs)
void
set_memory_c(word32 addr, word32 val, int cycs)
{
void set_memory_c(word32 addr, word32 val, int cycs) {
byte *stat;
byte *ptr;
double fcycles, fcycles_tmp1;
@ -618,9 +594,7 @@ set_memory_c(word32 addr, word32 val, int cycs)
SET_MEMORY8(addr, val);
}
void
set_memory16_c(word32 addr, word32 val, int cycs)
{
void set_memory16_c(word32 addr, word32 val, int cycs) {
byte *stat;
byte *ptr;
double fcycles, fcycles_tmp1;
@ -635,17 +609,13 @@ set_memory16_c(word32 addr, word32 val, int cycs)
SET_MEMORY16(addr, val, 0);
}
void
set_memory24_c(word32 addr, word32 val, int cycs)
{
void set_memory24_c(word32 addr, word32 val, int cycs) {
set_memory_c(addr, val, 0);
set_memory_c(addr + 1, val >> 8, 0);
set_memory_c(addr + 2, val >> 16, 0);
}
void
set_memory32_c(word32 addr, word32 val, int cycs)
{
void set_memory32_c(word32 addr, word32 val, int cycs) {
set_memory_c(addr, val, 0);
set_memory_c(addr + 1, val >> 8, 0);
set_memory_c(addr + 2, val >> 16, 0);
@ -654,9 +624,7 @@ set_memory32_c(word32 addr, word32 val, int cycs)
word32
do_adc_sbc8(word32 in1, word32 in2, word32 psr, int sub)
{
word32 do_adc_sbc8(word32 in1, word32 in2, word32 psr, int sub) {
word32 sum, carry, overflow;
word32 zero;
int decimal;
@ -707,9 +675,7 @@ do_adc_sbc8(word32 in1, word32 in2, word32 psr, int sub)
return (psr << 16) + (sum & 0xff);
}
word32
do_adc_sbc16(word32 in1, word32 in2, word32 psr, int sub)
{
word32 do_adc_sbc16(word32 in1, word32 in2, word32 psr, int sub) {
word32 sum, carry, overflow;
word32 tmp1, tmp2;
word32 zero;
@ -758,9 +724,7 @@ int g_ret1;
int g_ret2;
void
fixed_memory_ptrs_init()
{
void fixed_memory_ptrs_init() {
/* set g_slow_memory_ptr, g_rom_fc_ff_ptr, g_dummy_memory1_ptr, */
/* and rom_cards_ptr */
@ -783,8 +747,7 @@ fixed_memory_ptrs_init()
}
// OG added fixed_memory_ptrs_shut
void fixed_memory_ptrs_shut()
{
void fixed_memory_ptrs_shut() {
free(g_slow_memory_ptr_allocated);
free(g_dummy_memory1_ptr_allocated);
@ -798,9 +761,7 @@ void fixed_memory_ptrs_shut()
}
word32
get_itimer()
{
word32 get_itimer() {
#if defined(_WIN32)
LARGE_INTEGER count;
if (QueryPerformanceCounter(&count))
@ -820,22 +781,20 @@ get_itimer()
register word32 ret;
asm volatile ("rdtsc;movl %%eax,%0" : "=r"(ret) : : "%eax","%edx");
asm volatile ("rdtsc;movl %%eax,%0" : "=r" (ret) : : "%eax","%edx");
return ret;
#elif defined(__POWERPC__) && defined(__GNUC__)
register word32 ret;
asm volatile ("mftb %0" : "=r"(ret));
asm volatile ("mftb %0" : "=r" (ret));
return ret;
#else
return 0;
#endif
}
void
set_halt_act(int val)
{
void set_halt_act(int val) {
if(val == 1 && g_ignore_halts && !g_user_halt_bad) {
g_code_red++;
} else {
@ -844,15 +803,11 @@ set_halt_act(int val)
}
}
void
clr_halt_act()
{
void clr_halt_act() {
halt_sim = 0;
}
word32
get_remaining_operands(word32 addr, word32 opcode, word32 psr, Fplus *fplus_ptr)
{
word32 get_remaining_operands(word32 addr, word32 opcode, word32 psr, Fplus *fplus_ptr) {
byte *stat;
byte *ptr;
double fcycles, fcycles_tmp1;
@ -918,7 +873,7 @@ get_remaining_operands(word32 addr, word32 opcode, word32 psr, Fplus *fplus_ptr)
ptr = stat - wstat + ((addr) & 0xff); \
arg_ptr = ptr; \
opcode = *ptr; \
if((wstat & (1 << (31-BANK_IO_BIT))) || ((addr & 0xff) > 0xfc)) {\
if((wstat & (1 << (31-BANK_IO_BIT))) || ((addr & 0xff) > 0xfc)) { \
if(wstat & BANK_BREAK) { \
check_breakpoints(addr); \
} \
@ -939,16 +894,14 @@ get_remaining_operands(word32 addr, word32 opcode, word32 psr, Fplus *fplus_ptr)
} else { \
opcode = *ptr; \
} \
arg = get_remaining_operands(addr, opcode, psr, fplus_ptr);\
arg = get_remaining_operands(addr, opcode, psr, fplus_ptr); \
arg_ptr = (byte *)&tmp_bytes; \
arg_ptr[1] = arg; \
arg_ptr[2] = arg >> 8; \
arg_ptr[3] = arg >> 16; \
}
int
enter_engine(Engine_reg *engine_ptr)
{
int enter_engine(Engine_reg *engine_ptr) {
register byte *ptr;
byte *arg_ptr;
Pc_log *tmp_pc_ptr;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/*
* fbdriver - Linux fullscreen framebuffer graphics driver
@ -203,8 +203,7 @@ int evfd[MAX_EVDEV], evdevs, termfd, fbfd = 0;
/*
* Clean up
*/
void xdriver_end(void)
{
void xdriver_end(void) {
char c;
static char xexit = 0;
if (!xexit)
@ -231,8 +230,7 @@ void xdriver_end(void)
/*
* Init framebuffer and input
*/
void dev_video_init(void)
{
void dev_video_init(void) {
int i;
char evdevname[20];
struct termios termio;
@ -348,8 +346,7 @@ void dev_video_init(void)
*/
__u16 cmapred[256], cmapgreen[256], cmapblue[256];
int cmapstart, cmaplen, cmapdirty = 0;
void x_update_color(int col_num, int red, int green, int blue, word32 rgb)
{
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) {
cmapred[col_num] = red | (red << 8);
cmapgreen[col_num] = green | (green << 8);
cmapblue[col_num] = blue | (blue << 8);
@ -370,8 +367,7 @@ void x_update_color(int col_num, int red, int green, int blue, word32 rgb)
cmaplen = col_num - cmapstart + 1;
}
}
void x_update_physical_colormap(void)
{
void x_update_physical_colormap(void) {
struct fb_cmap fbcol;
if (cmapdirty)
{
@ -385,25 +381,21 @@ void x_update_physical_colormap(void)
ioctl(fbfd, FBIOPUTCMAP, &fbcol);
}
}
void show_xcolor_array(void)
{
void show_xcolor_array(void) {
}
/*
* Screen update
*/
void x_get_kimage(Kimage *kimage_ptr)
{
void x_get_kimage(Kimage *kimage_ptr) {
kimage_ptr->data_ptr = (byte *)malloc(kimage_ptr->width_req * kimage_ptr->height * kimage_ptr->mdepth / 8);
}
void x_release_kimage(Kimage* kimage_ptr)
{
void x_release_kimage(Kimage* kimage_ptr) {
if (kimage_ptr->data_ptr)
if (kimage_ptr->width_req != 640 || kimage_ptr->height != 400)
free(kimage_ptr->data_ptr);
kimage_ptr->data_ptr = NULL;
}
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy, int width, int height)
{
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy, int width, int height) {
byte *src_ptr, *dst_ptr;
// Copy sub-image to framebuffer
@ -417,55 +409,43 @@ void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
src_ptr += kimage_ptr->width_act * pix_size;
}
}
void x_push_done(void)
{
void x_push_done(void) {
}
/*
* NOP routines
*/
void x_dialog_create_gsport_conf(const char *str)
{
void x_dialog_create_gsport_conf(const char *str) {
// Just write the config file already...
config_write_config_gsplus_file();
}
int x_show_alert(int is_fatal, const char *str)
{
int x_show_alert(int is_fatal, const char *str) {
// Not implemented yet
adb_all_keys_up();
clear_fatal_logs();
return 0;
}
void x_toggle_status_lines(void)
{
void x_toggle_status_lines(void) {
}
void x_redraw_status_lines(void)
{
void x_redraw_status_lines(void) {
}
void x_hide_pointer(int do_hide)
{
void x_hide_pointer(int do_hide) {
}
void x_auto_repeat_on(int must)
{
void x_auto_repeat_on(int must) {
}
void x_full_screen(int do_full)
{
void x_full_screen(int do_full) {
}
int x_calc_ratio(float x, float y)
{
int x_calc_ratio(float x, float y) {
return 1;
}
void clipboard_paste(void)
{
void clipboard_paste(void) {
}
int clipboard_get_char(void)
{
int clipboard_get_char(void) {
return 0;
}
/*
* Input handling
*/
void check_input_events(void)
{
void check_input_events(void) {
struct input_event ev;
int i;
@ -523,16 +503,14 @@ void check_input_events(void)
}
}
}
static void sig_bye(int signo)
{
static void sig_bye(int signo) {
xdriver_end();
exit (-1);
}
/*
* Application entrypoint
*/
int main(int argc,char *argv[])
{
int main(int argc,char *argv[]) {
if (signal(SIGINT, sig_bye) == SIG_ERR)
exit(-1);
if (signal(SIGHUP, sig_bye) == SIG_ERR)

View File

@ -1,3 +1,9 @@
/*
GSPLUS - Advanced Apple IIGS Emulator Environment
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
#include <stdio.h>
#include <time.h>
#include <stdarg.h>

View File

@ -1,21 +1,9 @@
/*
GSPLUS - Advanced Apple IIGS Emulator Environment
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
#include "defc.h"
#include "glog.h"
@ -100,4 +88,3 @@ void
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy, int width, int height)
{
}

View File

@ -1,5 +1,8 @@
/*
* host_fst.c
GSPLUS - Advanced Apple IIGS Emulator Environment
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
#define _BSD_SOURCE
@ -415,8 +418,7 @@ struct file_info {
byte finder_info[32];
};
static int hex(byte c)
{
static int hex(byte c) {
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c + 10 - 'a';
if (c >= 'A' && c <= 'F') return c + 10 - 'A';
@ -548,7 +550,7 @@ static void get_file_xinfo(const char *path, struct file_info *fi) {
fi->resource_blocks = (tmp + 511) / 512;
tmp = getxattr(path, XATTR_FINDERINFO_NAME, fi->finder_info, 32, 0, 0);
if (tmp == 16 || tmp == 32){
if (tmp == 16 || tmp == 32) {
fi->has_fi = 1;
finder_info_to_filetype(fi->finder_info, &fi->file_type, &fi->aux_type);
@ -590,7 +592,7 @@ static void get_file_xinfo(const char *path, struct file_info *fi) {
fi->resource_blocks = (tmp + 511) / 512;
tmp = getxattr(path, "user.com.apple.FinderInfo", fi->finder_info, 32);
if (tmp == 16 || tmp == 32){
if (tmp == 16 || tmp == 32) {
fi->has_fi = 1;
finder_info_to_filetype(fi->finder_info, &fi->file_type, &fi->aux_type);
@ -686,7 +688,7 @@ static word32 get_file_info(const char *path, struct file_info *fi) {
const char *dot = NULL;
const char *slash = NULL;
for(n = 0; ; ++n) {
for(n = 0;; ++n) {
char c = path[n];
if (c == 0) break;
else if (c == '/') { slash = path + n + 1; dot = NULL; }
@ -1653,7 +1655,7 @@ static word32 fst_open(int class, const char *path) {
if (pcount >= 5) set_memory16_c(pb + OpenRecGS_access, access, 0);
if (pcount >= 6) set_memory16_c(pb + OpenRecGS_fileType, fi.file_type, 0);
if (pcount >= 7) set_memory32_c(pb + OpenRecGS_auxType, fi.aux_type, 0);
if (pcount >= 8) set_memory16_c(pb + OpenRecGS_storageType, fi. storage_type, 0);
if (pcount >= 8) set_memory16_c(pb + OpenRecGS_storageType, fi.storage_type, 0);
if (pcount >= 9) set_date_time_rec(pb + OpenRecGS_createDateTime, fi.create_date);
if (pcount >= 10) set_date_time_rec(pb + OpenRecGS_modDateTime, fi.modified_date);
@ -1691,7 +1693,7 @@ static word32 fst_open(int class, const char *path) {
return tooManyFilesOpen;
}
if (type == regular_file){
if (type == regular_file) {
if (g_cfg_host_crlf) {
if (fi.file_type == 0x04 || fi.file_type == 0xb0)
@ -1762,7 +1764,7 @@ static word32 fst_read(int class) {
for (int i = 0; i < 256; ++i)
newline_table[i] = get_memory_c(global_buffer + 2 + i, 0);
for (word32 i = 0 ; i < request_count; ++i) {
for (word32 i = 0; i < request_count; ++i) {
byte b;
ok = safe_read(e, &b, 1);
if (ok < 0) return map_errno();

View File

@ -1,23 +1,9 @@
/*
GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2010 - 2011 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
/*
* Copyright (C) 2002-2004 The DOSBox Team

164
src/iwm.c
View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "glog.h"
@ -79,9 +79,7 @@ int iwm_read_data_525(Disk *dsk, int fast_disk_emul, double dcycs);
void iwm_write_data_35(Disk *dsk, word32 val, int fast_disk_emul, double dcycs);
void iwm_write_data_525(Disk *dsk, word32 val, int fast_disk_emul,double dcycs);
void
iwm_init_drive(Disk *dsk, int smartport, int drive, int disk_525)
{
void iwm_init_drive(Disk *dsk, int smartport, int drive, int disk_525) {
dsk->dcycs_last_read = 0.0;
dsk->name_ptr = 0;
dsk->partition_name = 0;
@ -107,9 +105,7 @@ iwm_init_drive(Disk *dsk, int smartport, int drive, int disk_525)
}
void
disk_set_num_tracks(Disk *dsk, int num_tracks)
{
void disk_set_num_tracks(Disk *dsk, int num_tracks) {
int i;
if(dsk->trks != 0) {
@ -131,9 +127,7 @@ disk_set_num_tracks(Disk *dsk, int num_tracks)
}
}
void
iwm_init()
{
void iwm_init() {
int val;
int i;
@ -164,9 +158,7 @@ iwm_init()
// OG Added shut function to IWM
// Free the memory, and more important free the open handle onto the disk
void
iwm_shut()
{
void iwm_shut() {
int i;
for(i = 0; i < 2; i++) {
eject_disk(&iwm.drive525[i]);
@ -180,9 +172,7 @@ iwm_shut()
from_disk_byte_valid = 0;
}
void
iwm_reset()
{
void iwm_reset() {
iwm.q6 = 0;
iwm.q7 = 0;
iwm.motor_on = 0;
@ -206,9 +196,7 @@ iwm_reset()
g_c031_disk35 = 0;
}
void
draw_iwm_status(int line, char *buf)
{
void draw_iwm_status(int line, char *buf) {
char *flag[2][2];
int apple35_sel;
@ -227,11 +215,11 @@ draw_iwm_status(int line, char *buf)
extern void ki_loading(int _motorOn,int _slot,int _drive, int _curtrack);
int curtrack=0;
if (apple35_sel)
curtrack = iwm.drive35[iwm.drive_select].cur_qtr_track ;
curtrack = iwm.drive35[iwm.drive_select].cur_qtr_track;
else
curtrack = iwm.drive525[iwm.drive_select].cur_qtr_track >> 2 ;
curtrack = iwm.drive525[iwm.drive_select].cur_qtr_track >> 2;
ki_loading(g_iwm_motor_on,apple35_sel?5:6,iwm.drive_select+1,curtrack);
ki_loading(g_iwm_motor_on,apple35_sel ? 5 : 6,iwm.drive_select+1,curtrack);
}
#endif
@ -249,9 +237,7 @@ draw_iwm_status(int line, char *buf)
}
void
iwm_flush_disk_to_unix(Disk *dsk)
{
void iwm_flush_disk_to_unix(Disk *dsk) {
byte buffer[0x4000];
int num_dirty;
int j;
@ -323,9 +309,7 @@ extern byte* g_bram_ptr;
extern byte g_temp_boot_slot;
extern byte g_orig_boot_slot;
extern int g_config_gsplus_update_needed;
void
iwm_vbl_update(int doit_3_persec)
{
void iwm_vbl_update(int doit_3_persec) {
Disk *dsk;
int motor_on;
int i;
@ -377,9 +361,7 @@ iwm_vbl_update(int doit_3_persec)
}
void
iwm_show_stats()
{
void iwm_show_stats() {
glogf("IWM stats: q7,q6: %d, %d, reset,enable2: %d,%d, mode: %02x",
iwm.q7, iwm.q6, iwm.reset, iwm.enable2, iwm.iwm_mode);
glogf("motor: %d,%d, motor35:%d drive: %d, c031:%02x phs: %d %d %d %d",
@ -393,9 +375,7 @@ iwm_show_stats()
iwm.drive525[0].last_phase, iwm.drive525[1].last_phase);
}
void
iwm_touch_switches(int loc, double dcycs)
{
void iwm_touch_switches(int loc, double dcycs) {
Disk *dsk;
int phase;
int on;
@ -513,9 +493,7 @@ iwm_touch_switches(int loc, double dcycs)
}
}
void
iwm_move_to_track(Disk *dsk, int new_track)
{
void iwm_move_to_track(Disk *dsk, int new_track) {
int disk_525;
int dr;
@ -550,9 +528,7 @@ iwm_move_to_track(Disk *dsk, int new_track)
}
}
void
iwm525_phase_change(int drive, int phase)
{
void iwm525_phase_change(int drive, int phase) {
Disk *dsk;
int qtr_track;
int delta;
@ -590,9 +566,7 @@ iwm525_phase_change(int drive, int phase)
iwm.iwm_phase[1], iwm.iwm_phase[2], iwm.iwm_phase[3]);
}
int
iwm_read_status35(double dcycs)
{
int iwm_read_status35(double dcycs) {
Disk *dsk;
int drive;
int state;
@ -693,9 +667,7 @@ iwm_read_status35(double dcycs)
}
}
void
iwm_do_action35(double dcycs)
{
void iwm_do_action35(double dcycs) {
Disk *dsk;
int drive;
int state;
@ -743,7 +715,7 @@ iwm_do_action35(double dcycs)
#ifdef ACTIVEGS // OG : pass eject info to the Control (ActiveX specific)
{
extern void ejectDisk(int slot,int disk);
ejectDisk(dsk->disk_525?6:5,dsk->drive+1);
ejectDisk(dsk->disk_525 ? 6 : 5,dsk->drive+1);
}
#endif
break;
@ -761,9 +733,7 @@ iwm_do_action35(double dcycs)
}
}
int
iwm_read_c0ec(double dcycs)
{
int iwm_read_c0ec(double dcycs) {
Disk *dsk;
int drive;
@ -785,9 +755,7 @@ iwm_read_c0ec(double dcycs)
}
int
read_iwm(int loc, double dcycs)
{
int read_iwm(int loc, double dcycs) {
Disk *dsk;
word32 status;
double diff_dcycs;
@ -886,9 +854,7 @@ read_iwm(int loc, double dcycs)
return 0;
}
void
write_iwm(int loc, int val, double dcycs)
{
void write_iwm(int loc, int val, double dcycs) {
Disk *dsk;
int on;
int state;
@ -958,18 +924,14 @@ write_iwm(int loc, int val, double dcycs)
int
iwm_read_enable2(double dcycs)
{
int iwm_read_enable2(double dcycs) {
iwm_printf("Read under enable2!\n");
return 0xff;
}
int g_cnt_enable2_handshake = 0;
int
iwm_read_enable2_handshake(double dcycs)
{
int iwm_read_enable2_handshake(double dcycs) {
int val;
iwm_printf("Read handshake under enable2!\n");
@ -984,17 +946,13 @@ iwm_read_enable2_handshake(double dcycs)
return val;
}
void
iwm_write_enable2(int val, double dcycs)
{
void iwm_write_enable2(int val, double dcycs) {
iwm_printf("Write under enable2: %02x!\n", val);
return;
}
int
iwm_read_data(Disk *dsk, int fast_disk_emul, double dcycs)
{
int iwm_read_data(Disk *dsk, int fast_disk_emul, double dcycs) {
if(dsk->disk_525) {
return iwm_read_data_525(dsk, fast_disk_emul, dcycs);
} else {
@ -1002,9 +960,7 @@ iwm_read_data(Disk *dsk, int fast_disk_emul, double dcycs)
}
}
void
iwm_write_data(Disk *dsk, word32 val, int fast_disk_emul, double dcycs)
{
void iwm_write_data(Disk *dsk, word32 val, int fast_disk_emul, double dcycs) {
if(dsk->disk_525) {
iwm_write_data_525(dsk, val, fast_disk_emul, dcycs);
} else {
@ -1045,9 +1001,7 @@ iwm_write_data(Disk *dsk, word32 val, int fast_disk_emul, double dcycs)
/* c600 */
void
sector_to_partial_nib(byte *in, byte *nib_ptr)
{
void sector_to_partial_nib(byte *in, byte *nib_ptr) {
byte *aux_buf;
byte *nib_out;
int val;
@ -1084,9 +1038,7 @@ sector_to_partial_nib(byte *in, byte *nib_ptr)
}
int
disk_unnib_4x4(Disk *dsk)
{
int disk_unnib_4x4(Disk *dsk) {
int val1;
int val2;
@ -1096,9 +1048,7 @@ disk_unnib_4x4(Disk *dsk)
return ((val1 << 1) + 1) & val2;
}
int
iwm_denib_track525(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf)
{
int iwm_denib_track525(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf) {
byte aux_buf[0x80];
byte *buf;
int sector_done[16];
@ -1306,9 +1256,7 @@ iwm_denib_track525(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf)
return -1;
}
int
iwm_denib_track35(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf)
{
int iwm_denib_track35(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf) {
word32 buf_c00[0x100];
word32 buf_d00[0x100];
word32 buf_e00[0x100];
@ -1631,9 +1579,7 @@ iwm_denib_track35(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf)
/* ret = 1 -> dirty data written out */
/* ret = 0 -> not dirty, no error */
/* ret < 0 -> error */
int
disk_track_to_unix(Disk *dsk, int qtr_track, byte *outbuf)
{
int disk_track_to_unix(Disk *dsk, int qtr_track, byte *outbuf) {
int i;
Trk *trk;
int disk_525;
@ -1679,9 +1625,7 @@ disk_track_to_unix(Disk *dsk, int qtr_track, byte *outbuf)
}
void
show_hex_data(byte *buf, int count)
{
void show_hex_data(byte *buf, int count) {
int i;
for(i = 0; i < count; i += 16) {
@ -1695,9 +1639,7 @@ show_hex_data(byte *buf, int count)
}
void
disk_check_nibblization(Disk *dsk, int qtr_track, byte *buf, int size)
{
void disk_check_nibblization(Disk *dsk, int qtr_track, byte *buf, int size) {
byte buffer[0x3000];
Trk *trk;
int ret, ret2;
@ -1744,10 +1686,8 @@ disk_check_nibblization(Disk *dsk, int qtr_track, byte *buf, int size)
#define TRACK_BUF_LEN 0x2000
void
disk_unix_to_nib(Disk *dsk, int qtr_track, int unix_pos, int unix_len,
int nib_len)
{
void disk_unix_to_nib(Disk *dsk, int qtr_track, int unix_pos, int unix_len,
int nib_len) {
byte track_buf[TRACK_BUF_LEN];
Trk *trk;
int must_clear_track;
@ -1830,9 +1770,7 @@ disk_unix_to_nib(Disk *dsk, int qtr_track, int unix_pos, int unix_len,
}
}
void
iwm_nibblize_track_nib525(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track)
{
void iwm_nibblize_track_nib525(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track) {
byte *nib_ptr;
byte *trk_ptr;
int len;
@ -1849,9 +1787,7 @@ iwm_nibblize_track_nib525(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track)
iwm_printf("Nibblized q_track %02x\n", qtr_track);
}
void
iwm_nibblize_track_525(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track)
{
void iwm_nibblize_track_525(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track) {
byte partial_nib_buf[0x300];
word32 *word_ptr;
word32 val;
@ -1941,9 +1877,7 @@ iwm_nibblize_track_525(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track)
}
}
void
iwm_nibblize_track_35(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track)
{
void iwm_nibblize_track_35(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track) {
int phys_to_log_sec[16];
word32 buf_c00[0x100];
word32 buf_d00[0x100];
@ -2187,16 +2121,12 @@ iwm_nibblize_track_35(Disk *dsk, Trk *trk, byte *track_buf, int qtr_track)
}
}
void
disk_4x4_nib_out(Disk *dsk, word32 val)
{
void disk_4x4_nib_out(Disk *dsk, word32 val) {
disk_nib_out(dsk, 0xaa | (val >> 1), 8);
disk_nib_out(dsk, 0xaa | val, 8);
}
void
disk_nib_out(Disk *dsk, byte val, int size)
{
void disk_nib_out(Disk *dsk, byte val, int size) {
Trk *trk;
int pos;
int old_size;
@ -2277,9 +2207,7 @@ disk_nib_out(Disk *dsk, byte val, int size)
}
}
void
disk_nib_end_track(Disk *dsk)
{
void disk_nib_end_track(Disk *dsk) {
int qtr_track;
dsk->nib_pos = 0;
@ -2289,9 +2217,7 @@ disk_nib_end_track(Disk *dsk)
dsk->disk_dirty = 0;
}
void
iwm_show_track(int slot_drive, int track)
{
void iwm_show_track(int slot_drive, int track) {
Disk *dsk;
Trk *trk;
int drive;
@ -2334,9 +2260,7 @@ iwm_show_track(int slot_drive, int track)
iwm_show_a_track(trk);
}
void
iwm_show_a_track(Trk *trk)
{
void iwm_show_a_track(Trk *trk) {
int sum;
int len;
int pos;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "glog.h"
@ -57,9 +57,7 @@ int g_joystick_button_3 = 3; // SDL2
#if defined(HAVE_SDL) && !defined(JOYSTICK_DEFINED)
# define JOYSTICK_DEFINED
void
joystick_init()
{
void joystick_init() {
int i;
if( SDL_Init( SDL_INIT_JOYSTICK ) < 0 ) {
glogf( "SDL could not initialize joystick! SDL Error: %s", SDL_GetError() );
@ -88,9 +86,7 @@ joystick_init()
joystick_update(0.0);
}
void
joystick_update(double dcycs)
{
void joystick_update(double dcycs) {
if (gGameController) {
SDL_JoystickUpdate();
g_paddle_val[0] = (int)SDL_JoystickGetAxis(gGameController, g_joystick_x_axis); // default is 0
@ -122,9 +118,7 @@ joystick_update(double dcycs)
}
}
void
joystick_update_buttons()
{
void joystick_update_buttons() {
}
void joystick_shut() {
@ -139,9 +133,7 @@ void joystick_shut() {
#if defined(__linux__) && !defined(JOYSTICK_DEFINED)
# define JOYSTICK_DEFINED
void
joystick_init()
{
void joystick_init() {
char joy_name[MAX_JOY_NAME];
int version;
int fd;
@ -180,9 +172,7 @@ joystick_init()
/* joystick_update_linux() called from paddles.c. Update g_paddle_val[] */
/* and g_paddle_buttons with current information */
void
joystick_update(double dcycs)
{
void joystick_update(double dcycs) {
struct js_event js; /* the linux joystick event record */
int mask;
int val;
@ -224,17 +214,13 @@ joystick_update(double dcycs)
// }
}
void
joystick_update_buttons()
{
void joystick_update_buttons() {
}
#endif /* LINUX */
#if defined(_WIN32) && !defined(JOYSTICK_DEFINED)
# define JOYSTICK_DEFINED
void
joystick_init()
{
void joystick_init() {
JOYINFO info;
JOYCAPS joycap;
MMRESULT ret1, ret2;
@ -282,9 +268,7 @@ joystick_init()
joystick_update(0.0);
}
void
joystick_update(double dcycs)
{
void joystick_update(double dcycs) {
JOYCAPS joycap;
JOYINFO info;
UINT id;
@ -313,9 +297,7 @@ joystick_update(double dcycs)
}
}
void
joystick_update_buttons()
{
void joystick_update_buttons() {
JOYINFOEX info;
UINT id;
@ -344,17 +326,13 @@ joystick_update_buttons()
#ifndef JOYSTICK_DEFINED
/* stubs for the routines */
void
joystick_init()
{
void joystick_init() {
g_joystick_native_type1 = -1;
g_joystick_native_type2 = -1;
g_joystick_native_type = -1;
}
void
joystick_update(double dcycs)
{
void joystick_update(double dcycs) {
int i;
for(i = 0; i < 4; i++) {
@ -363,12 +341,9 @@ joystick_update(double dcycs)
g_paddle_buttons = 0xc;
}
void
joystick_update_buttons()
{
void joystick_update_buttons() {
}
void joystick_shut()
{
void joystick_shut() {
}
#endif

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#ifdef ACTIVEIPHONE
#include <CoreGraphics/CGContext.h>
@ -82,9 +82,7 @@ Rect g_main_window_saved_rect;
extern char *g_fatal_log_strs[];
extern int g_fatal_log;
int
x_show_alert(int is_fatal, const char *str)
{
int x_show_alert(int is_fatal, const char *str) {
DialogRef alert;
DialogItemIndex out_item_hit;
CFStringRef cfstrref, cfstrref2;
@ -150,9 +148,7 @@ x_show_alert(int is_fatal, const char *str)
pascal OSStatus
quit_event_handler(EventHandlerCallRef call_ref, EventRef event, void *ignore)
{
pascal OSStatus quit_event_handler(EventHandlerCallRef call_ref, EventRef event, void *ignore) {
OSStatus err;
err = CallNextEventHandler(call_ref, event);
@ -162,9 +158,7 @@ quit_event_handler(EventHandlerCallRef call_ref, EventRef event, void *ignore)
return err;
}
void
show_simple_alert(char *str1, char *str2, char *str3, int num)
{
void show_simple_alert(char *str1, char *str2, char *str3, int num) {
char buf[256];
g_fatal_log_strs[0] = gsplus_malloc_str(str1);
@ -178,9 +172,7 @@ show_simple_alert(char *str1, char *str2, char *str3, int num)
x_show_alert(0, 0);
}
void
x_dialog_create_gsport_conf(const char *str)
{
void x_dialog_create_gsport_conf(const char *str) {
char *path;
char tmp_buf[512];
int ret;
@ -192,9 +184,7 @@ x_dialog_create_gsport_conf(const char *str)
}
pascal OSStatus
my_cmd_handler( EventHandlerCallRef handlerRef, EventRef event, void *userdata)
{
pascal OSStatus my_cmd_handler( EventHandlerCallRef handlerRef, EventRef event, void *userdata) {
OSStatus osresult;
HICommand command;
word32 command_id;
@ -238,9 +228,7 @@ my_cmd_handler( EventHandlerCallRef handlerRef, EventRef event, void *userdata)
pascal OSStatus
my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata)
{
pascal OSStatus my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata) {
OSStatus os_result;
UInt32 event_kind;
@ -272,10 +260,8 @@ my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata)
}
pascal OSStatus
dummy_event_handler(EventHandlerCallRef call_ref, EventRef in_event,
void *ignore)
{
pascal OSStatus dummy_event_handler(EventHandlerCallRef call_ref, EventRef in_event,
void *ignore) {
OSStatus err;
EventHandlerRef installed_handler;
EventTypeSpec event_spec = { kEventClassApplication, kEventAppQuit };
@ -294,9 +280,7 @@ dummy_event_handler(EventHandlerCallRef call_ref, EventRef in_event,
void
check_input_events()
{
void check_input_events() {
OSStatus err;
EventTargetRef target;
EventRef event;
@ -485,9 +469,7 @@ check_input_events()
return;
}
void
temp_run_application_event_loop(void)
{
void temp_run_application_event_loop(void) {
OSStatus err;
EventRef dummy_event;
EventHandlerRef install_handler;
@ -535,14 +517,13 @@ macmain
#else
main
#endif
(int argc, char* argv[])
{
(int argc, char* argv[]) {
ProcessSerialNumber my_psn;
IBNibRef nibRef;
EventHandlerUPP handlerUPP;
EventTypeSpec cmd_event[3];
GDHandle g_gdhandle ;
GDHandle g_gdhandle;
Rect win_rect;
OSStatus err;
char *argptr;
@ -715,9 +696,7 @@ CantGetNibRef:
return err;
}
void
xdriver_end()
{
void xdriver_end() {
printf("xdriver_end\n");
@ -727,9 +706,7 @@ xdriver_end()
}
void
x_redraw_status_lines()
{
void x_redraw_status_lines() {
// OG Disable status line
#ifndef ACTIVEGS
Rect rect;
@ -769,9 +746,7 @@ x_redraw_status_lines()
#endif
}
void
x_full_screen(int do_full)
{
void x_full_screen(int do_full) {
#if 0
WindowRef new_window;
@ -813,9 +788,7 @@ x_full_screen(int do_full)
}
void
x_push_done()
{
void x_push_done() {
CGrafPtr window_port;
@ -826,9 +799,7 @@ x_push_done()
}
void
mac_warp_mouse()
{
void mac_warp_mouse() {
#ifndef ACTIVEGS
Rect port_rect;
Point win_origin_pt;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#ifdef ACTIVEIPHONE
#include <CoreGraphics/CGContext.h>
@ -100,9 +100,7 @@ int g_upd_count = 0;
void
update_window(void)
{
void update_window(void) {
// OG Not needed
/*
@ -124,9 +122,7 @@ update_window(void)
}
void
mac_update_modifiers(word32 state)
{
void mac_update_modifiers(word32 state) {
#ifndef ACTIVEIPHONE
word32 state_xor;
@ -164,20 +160,14 @@ mac_update_modifiers(word32 state)
}
void
x_update_color(int col_num, int red, int green, int blue, word32 rgb)
{
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) {
}
void
x_update_physical_colormap()
{
void x_update_physical_colormap() {
}
void
show_xcolor_array()
{
void show_xcolor_array() {
int i;
for(i = 0; i < 256; i++) {
@ -187,9 +177,7 @@ show_xcolor_array()
void
x_get_kimage(Kimage *kimage_ptr)
{
void x_get_kimage(Kimage *kimage_ptr) {
#ifdef ENABLEQD
PixMapHandle pixmap_handle;
GWorldPtr world;
@ -236,7 +224,7 @@ x_get_kimage(Kimage *kimage_ptr)
{
kimage_ptr->width_act = width ;
kimage_ptr->width_act = width;
size = height* kimage_ptr->width_act * mdepth >> 3;
ptr = (byte *)malloc(size);
@ -254,8 +242,8 @@ x_get_kimage(Kimage *kimage_ptr)
/* allocate buffers for video.c to draw into */
kimage_ptr->width_act = width ;
size = height* kimage_ptr->width_act * mdepth >> 3 ;
kimage_ptr->width_act = width;
size = height* kimage_ptr->width_act * mdepth >> 3;
ptr = (byte *)malloc(size);
if(ptr == 0) {
@ -278,9 +266,7 @@ PixMapHandle pixmap_backbuffer=NULL;
GWorldPtr backbuffer=NULL;
#endif
void
dev_video_init()
{
void dev_video_init() {
int lores_col;
int i;
@ -302,17 +288,17 @@ dev_video_init()
int pixelsWide = 704;
int pixelsHigh = 462;
bitmapBytesPerRow = (pixelsWide * 4);// 1
bitmapBytesPerRow = (pixelsWide * 4); // 1
bitmapByteCount = (bitmapBytesPerRow * pixelsHigh);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
bitmapData = (char*)malloc( bitmapByteCount );// 3
bitmapData = (char*)malloc( bitmapByteCount ); // 3
if (bitmapData == NULL)
{
fprintf (stderr, "Memory not allocated!");
return ;
return;
}
offscreenContext = CGBitmapContextCreate (bitmapData,// 4
offscreenContext = CGBitmapContextCreate (bitmapData, // 4
pixelsWide,
pixelsHigh,
8, // bits per component
@ -321,15 +307,15 @@ dev_video_init()
kCGImageAlphaNoneSkipLast);
if (offscreenContext== NULL)
{
free (bitmapData);// 5
free (bitmapData); // 5
fprintf (stderr, "Context not created!");
return ;
return;
}
CGContextSetRGBFillColor (offscreenContext, 1, 0.5, 0.5, 1);
CGContextFillRect (offscreenContext, CGRectMake (0,0, 704, 462 ));
CGColorSpaceRelease( colorSpace );// 6
CGColorSpaceRelease( colorSpace ); // 6
}
@ -355,10 +341,8 @@ dev_video_init()
void
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height)
{
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height) {
int i;
if (!macUsingCoreGraphics)
@ -381,7 +365,7 @@ x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
srcCopy, NULL);
#else // !ACTIVEGSPLUGIN
// OG Write to the back buffer instead of the display window
window_port = mac_window_port ;
window_port = mac_window_port;
SetGWorld(backbuffer,NULL);
CopyBits( (BitMap *)(*pixmap_handle),
@ -397,7 +381,7 @@ x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int w = width *4;
char* ptrdest = bitmapData + bitmapBytesPerRow*desty + destx*4;
char* srcdest = (char*)kimage_ptr->data_ptr + wd*srcy + srcx*4;
for(i=0;i<height;i+=1)
for(i=0; i<height; i+=1)
{
memcpy(ptrdest,srcdest,w);
ptrdest += bitmapBytesPerRow;
@ -408,19 +392,13 @@ x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
}
void
x_auto_repeat_on(int must)
{
void x_auto_repeat_on(int must) {
}
void
x_auto_repeat_off(int must)
{
void x_auto_repeat_off(int must) {
}
void
x_hide_pointer(int do_hide)
{
void x_hide_pointer(int do_hide) {
#ifdef ENABLEQD
if(do_hide) {
HideCursor();
@ -431,9 +409,7 @@ x_hide_pointer(int do_hide)
}
void
update_main_window_size()
{
void update_main_window_size() {
#ifdef ENABLEQD
Rect win_rect;
int width, height;
@ -465,8 +441,7 @@ update_main_window_size()
// OG Adding release
void x_release_kimage(Kimage* kimage_ptr)
{
void x_release_kimage(Kimage* kimage_ptr) {
if (kimage_ptr->dev_handle == (void*)-1)
{
free(kimage_ptr->data_ptr);
@ -487,14 +462,11 @@ void x_release_kimage(Kimage* kimage_ptr)
}
// OG Addding ratio
int x_calc_ratio(float x,float y)
{
int x_calc_ratio(float x,float y) {
return 1;
}
void
clipboard_paste(void)
{
void clipboard_paste(void) {
#define CHUNK_SIZE 1024
char buffer[CHUNK_SIZE];
int bufsize = 1;
@ -529,8 +501,7 @@ clipboard_paste(void)
}
}
int clipboard_get_char(void)
{
int clipboard_get_char(void) {
if (!g_clipboard)
return 0;
if (g_clipboard[g_clipboard_pos] == '\n')

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
@ -39,9 +39,7 @@ SndChannelPtr g_snd_channel_ptr;
ExtSoundHeader g_snd_hdr;
SndCommand g_snd_cmd;
void
mac_snd_callback(SndChannelPtr snd_chan_ptr, SndCommand *in_sndcmd)
{
void mac_snd_callback(SndChannelPtr snd_chan_ptr, SndCommand *in_sndcmd) {
OSStatus err;
int samps;
@ -84,9 +82,7 @@ mac_snd_callback(SndChannelPtr snd_chan_ptr, SndCommand *in_sndcmd)
}
}
int
mac_send_audio(byte *ptr, int in_size)
{
int mac_send_audio(byte *ptr, int in_size) {
SndCommand snd_cmd = {0};
word32 *wptr, *macptr;
word32 *eptr;
@ -113,9 +109,7 @@ mac_send_audio(byte *ptr, int in_size)
return in_size;
}
void
child_sound_init_mac()
{
void child_sound_init_mac() {
OSStatus err;
mac_printf("In mac child\n");
@ -147,9 +141,7 @@ child_sound_init_mac()
fflush(stdout);
}
void
macsnd_init(word32 *shmaddr)
{
void macsnd_init(word32 *shmaddr) {
g_macsnd_rebuf_cur = &g_macsnd_rebuf[0];
g_macsnd_rebuf_ptr = &g_macsnd_rebuf[0];
mac_printf("macsnd_init called\n");

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
@ -64,17 +64,17 @@ int g_c068_statereg = 0;
int g_c08x_wrdefram = 0;
int g_zipgs_unlock = 0;
int g_zipgs_reg_c059 = 0x5f;
// 7=LC cache dis, 6==5ms paddle del en, 5==5ms ext del en,
// 4==5ms c02e enab, 3==CPS follow enab, 2-0: 111
// 7=LC cache dis, 6==5ms paddle del en, 5==5ms ext del en,
// 4==5ms c02e enab, 3==CPS follow enab, 2-0: 111
int g_zipgs_reg_c05a = 0x0f;
// 7:4 = current ZIP speed, 0=100%, 1=93.75%, F=6.25%
// 3:0: always 1111
// 7:4 = current ZIP speed, 0=100%, 1=93.75%, F=6.25%
// 3:0: always 1111
int g_zipgs_reg_c05b = 0x40;
// 7==1ms clock, 6==cshupd: tag data at c05f updated
// 5==LC cache disable, 4==bd is disabled, 3==delay in effect,
// 2==rombank, 1-0==ram size (00:8K, 01=16K, 10=32K, 11=64K)
// 7==1ms clock, 6==cshupd: tag data at c05f updated
// 5==LC cache disable, 4==bd is disabled, 3==delay in effect,
// 2==rombank, 1-0==ram size (00:8K, 01=16K, 10=32K, 11=64K)
int g_zipgs_reg_c05c = 0x00;
// 7:1==slot delay enable (for 52-54ms), 0==speaker 5ms delay
// 7:1==slot delay enable (for 52-54ms), 0==speaker 5ms delay
#define EMUSTATE(a) { #a, &a }
@ -144,15 +144,15 @@ unsigned char transwarpcode[][32]
#if !defined(_WIN32)
__attribute__ ((aligned(256)))
#endif
={
{
={
{
/*0xBCFF00*/ 'T','W','G','S',0,0,0,0,0,0,0,0,0,0,0,0,
/*0xBCFF10*/ 0x5C,0x40,0xFF,0xBC, // JMP GetMaxSpeed
/*0xBCFF14*/ 0x5C,0x60,0xFF,0xBC, // JMP GetNumISpeed
/*0xBCFF18*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF1C*/ 0x6B,0x00,0x00,0x00 // ???
},
{
},
{
/*0xBCFF20*/ 0x5C,0x80,0xFF,0xBC, // JMP GetCurSpeed
/*0xBCFF24*/ 0x5C,0xA0,0xFF,0xBC, // JMP SetCurSpeed
/*0xBCFF28*/ 0x5C,0xC0,0xFF,0xBC, // JMP GetCurISpeed
@ -161,55 +161,54 @@ __attribute__ ((aligned(256)))
/*0xBCFF34*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF38*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF3C*/ 0x6B,0x00,0x00,0x00 // GetTWConfig
},
{
},
{
/* 0xBCFF40*/ // GetMaxSpeed
#define ZIP_SPEED 8000
0xA9, ZIP_SPEED & 0xFF, (ZIP_SPEED >> 8) &0xFF, // LDA 0x1F40 // Max Speed = 8.0Mhz
0x6B, // RTL
0x00,0x00,0x00,0x00, //4
0x00,0x00,0x00,0x00, //8
0x6B,0x00,0x00,0x00, //C Space Shark calls this address ???
},
{
0xA9, ZIP_SPEED & 0xFF, (ZIP_SPEED >> 8) &0xFF, // LDA 0x1F40 // Max Speed = 8.0Mhz
0x6B, // RTL
0x00,0x00,0x00,0x00, //4
0x00,0x00,0x00,0x00, //8
0x6B,0x00,0x00,0x00, //C Space Shark calls this address ???
},
{
/* 0xBCFF60*/ //GetNumISpeed
0xA9,0x02,0x00, // LDA 0x0002 // 0=slow, 1=normal, 2=warp
0x6B, // RTL
},
{
0xA9,0x02,0x00, // LDA 0x0002 // 0=slow, 1=normal, 2=warp
0x6B, // RTL
},
{
/* 0xBCFF80*/ //GetCurSpeed
0xAF, 0x6A, 0xC0, 0x00, // LDA 0xC06A (/6B)
0x6B, // RTL
},
{
0xAF, 0x6A, 0xC0, 0x00, // LDA 0xC06A (/6B)
0x6B, // RTL
},
{
/* 0xBCFFA0*/ //SetCurSpeed
0x8F, 0x6A, 0xC0, 0x00, // STA 0xC06A (/6B)
0x6B, // RTL
},
{
0x8F, 0x6A, 0xC0, 0x00, // STA 0xC06A (/6B)
0x6B, // RTL
},
{
/* 0xBCFFC0*/ //GetCurISpeed
0x48, // PHA
0xAF, 0x6C, 0xC0, 0x00, // LDA 0xC06C (/6D)
0xAA, // TAX
0x68, // PLA
0x6B, // RTL
},
{
0x48, // PHA
0xAF, 0x6C, 0xC0, 0x00, // LDA 0xC06C (/6D)
0xAA, // TAX
0x68, // PLA
0x6B, // RTL
},
{
/* 0xBCFFE0*/ //SetCurISpeed
0x48, // PHA
0x8A, // TXA
0x8F, 0x6C, 0xC0, 0x00, // STA 0xC06C (/6D)
0x68, // PLA
0x6B, // RTL
}
}
0x48, // PHA
0x8A, // TXA
0x8F, 0x6C, 0xC0, 0x00, // STA 0xC06C (/6D)
0x68, // PLA
0x6B, // RTL
}
}
;
// OG Added moremem_init()
void moremem_init()
{
void moremem_init() {
g_em_emubyte_cnt = 0;
g_paddle_buttons = 0;
g_irq_pending = 0;
@ -235,9 +234,7 @@ void moremem_init()
g_zipgs_reg_c05c = 0x00;
}
void
fixup_brks()
{
void fixup_brks() {
word32 page;
word32 tmp, tmp2;
Pg_info val;
@ -261,9 +258,7 @@ fixup_brks()
}
}
void
fixup_hires_on()
{
void fixup_hires_on() {
if((g_cur_a2_stat & ALL_STAT_ST80) == 0) {
return;
}
@ -272,15 +267,13 @@ fixup_hires_on()
fixup_brks();
}
void
fixup_bank0_2000_4000()
{
void fixup_bank0_2000_4000() {
byte *mem0rd;
byte *mem0wr;
mem0rd = &(g_memory_ptr[0x2000]);
mem0wr = mem0rd;
if((g_cur_a2_stat & ALL_STAT_ST80) && (g_cur_a2_stat & ALL_STAT_HIRES)){
if((g_cur_a2_stat & ALL_STAT_ST80) && (g_cur_a2_stat & ALL_STAT_HIRES)) {
if(g_cur_a2_stat & ALL_STAT_PAGE2) {
mem0rd += 0x10000;
mem0wr += 0x10000;
@ -310,9 +303,7 @@ fixup_bank0_2000_4000()
fixup_any_bank_any_page(0x20, 0x20, mem0rd, mem0wr);
}
void
fixup_bank0_0400_0800()
{
void fixup_bank0_0400_0800() {
byte *mem0rd;
byte *mem0wr;
int shadow;
@ -342,10 +333,8 @@ fixup_bank0_0400_0800()
fixup_any_bank_any_page(0x4, 4, mem0rd, mem0wr);
}
void
fixup_any_bank_any_page(int start_page, int num_pages, byte *mem0rd,
byte *mem0wr)
{
void fixup_any_bank_any_page(int start_page, int num_pages, byte *mem0rd,
byte *mem0wr) {
int i;
for(i = 0; i < num_pages; i++) {
@ -360,9 +349,7 @@ fixup_any_bank_any_page(int start_page, int num_pages, byte *mem0rd,
}
void
fixup_intcx()
{
void fixup_intcx() {
byte *rom10000;
byte *rom_inc;
int no_io_shadow;
@ -430,9 +417,7 @@ fixup_intcx()
fixup_brks();
}
void
fixup_wrdefram(int new_wrdefram)
{
void fixup_wrdefram(int new_wrdefram) {
byte *mem0wr;
byte *wrptr;
int j;
@ -466,7 +451,7 @@ fixup_wrdefram(int new_wrdefram)
}
wrptr = mem0wr + 0x1d000;
if(! LCBANK2) {
if(!LCBANK2) {
wrptr -= 0x1000;
}
for(j = 0x1d0; j < 0x1e0; j++) {
@ -475,7 +460,7 @@ fixup_wrdefram(int new_wrdefram)
}
wrptr = mem0wr + 0xd000;
if(! LCBANK2) {
if(!LCBANK2) {
wrptr -= 0x1000;
}
if(ALTZP) {
@ -489,9 +474,7 @@ fixup_wrdefram(int new_wrdefram)
fixup_brks();
}
void
fixup_st80col(double dcycs)
{
void fixup_st80col(double dcycs) {
int cur_a2_stat;
cur_a2_stat = g_cur_a2_stat;
@ -511,9 +494,7 @@ fixup_st80col(double dcycs)
fixup_brks();
}
void
fixup_altzp()
{
void fixup_altzp() {
byte *mem0rd, *mem0wr;
int rdrom, c08x_wrdefram;
int altzp;
@ -549,7 +530,7 @@ fixup_altzp()
mem0rd += 0x10000;
mem0wr += 0x10000;
}
if(! LCBANK2) {
if(!LCBANK2) {
mem0rd -= 0x1000;
mem0wr -= 0x1000;
}
@ -576,9 +557,7 @@ fixup_altzp()
/* No need for fixup_brks since called from set_statereg() */
}
void
fixup_page2(double dcycs)
{
void fixup_page2(double dcycs) {
if((g_cur_a2_stat & ALL_STAT_ST80)) {
fixup_bank0_0400_0800();
if((g_cur_a2_stat & ALL_STAT_HIRES)) {
@ -589,9 +568,7 @@ fixup_page2(double dcycs)
}
}
void
fixup_ramrd()
{
void fixup_ramrd() {
byte *mem0rd;
int cur_a2_stat;
int j;
@ -625,9 +602,7 @@ fixup_ramrd()
/* No need for fixup_brks since only called from set_statereg() */
}
void
fixup_ramwrt()
{
void fixup_ramwrt() {
byte *mem0wr;
int cur_a2_stat;
int shadow;
@ -698,9 +673,7 @@ fixup_ramwrt()
/* No need for fixup_brks() since only called from set_statereg() */
}
void
fixup_lcbank2()
{
void fixup_lcbank2() {
byte *mem0rd, *mem0wr;
int lcbank2, c08x_wrdefram, rdrom;
int off;
@ -729,7 +702,7 @@ fixup_lcbank2()
c08x_wrdefram = 1;
rdrom = 0;
}
if(! lcbank2) {
if(!lcbank2) {
mem0rd -= 0x1000; /* lcbank1, use 0xc000-cfff */
}
mem0wr = mem0rd;
@ -747,9 +720,7 @@ fixup_lcbank2()
/* or from other routines which will handle it */
}
void
fixup_rdrom()
{
void fixup_rdrom() {
byte *mem0rd;
int j, k;
@ -775,9 +746,7 @@ fixup_rdrom()
/* No need for fixup_brks() since only called from set_statereg() */
}
void
set_statereg(double dcycs, int val)
{
void set_statereg(double dcycs, int val) {
int _xor; // OG renamed xor to _xor
_xor = val ^ g_c068_statereg;
@ -831,9 +800,7 @@ set_statereg(double dcycs, int val)
}
}
void
fixup_shadow_txt1()
{
void fixup_shadow_txt1() {
byte *mem0wr;
int j;
@ -848,9 +815,7 @@ fixup_shadow_txt1()
}
}
void
fixup_shadow_txt2()
{
void fixup_shadow_txt2() {
byte *mem0wr;
int shadow;
int j;
@ -881,9 +846,7 @@ fixup_shadow_txt2()
}
}
void
fixup_shadow_hires1()
{
void fixup_shadow_hires1() {
byte *mem0wr;
int j;
@ -899,9 +862,7 @@ fixup_shadow_hires1()
}
}
void
fixup_shadow_hires2()
{
void fixup_shadow_hires2() {
byte *mem0wr;
int j;
@ -930,9 +891,7 @@ fixup_shadow_hires2()
}
}
void
fixup_shadow_shr()
{
void fixup_shadow_shr() {
byte *mem0wr;
int j;
@ -958,9 +917,7 @@ fixup_shadow_shr()
}
}
void
fixup_shadow_iolc()
{
void fixup_shadow_iolc() {
byte *mem0rd;
int k;
@ -993,9 +950,7 @@ fixup_shadow_iolc()
}
}
void
update_shadow_reg(int val)
{
void update_shadow_reg(int val) {
int _xor;
if(g_c035_shadow_reg == val) {
@ -1036,9 +991,7 @@ update_shadow_reg(int val)
}
}
void
fixup_shadow_all_banks()
{
void fixup_shadow_all_banks() {
byte *mem0rd;
int shadow;
int num_banks;
@ -1063,9 +1016,7 @@ fixup_shadow_all_banks()
fixup_brks();
}
void
setup_pageinfo()
{
void setup_pageinfo() {
byte *mem0rd;
word32 mem_size_pages;
@ -1128,9 +1079,7 @@ setup_pageinfo()
#endif
}
void
show_bankptrs_bank0rdwr()
{
void show_bankptrs_bank0rdwr() {
show_bankptrs(0);
show_bankptrs(1);
show_bankptrs(0xe0);
@ -1138,9 +1087,7 @@ show_bankptrs_bank0rdwr()
printf("statereg: %02x\n", g_c068_statereg);
}
void
show_bankptrs(int bnk)
{
void show_bankptrs(int bnk) {
int i;
Pg_info rd, wr;
byte *ptr_rd, *ptr_wr;
@ -1179,8 +1126,7 @@ unsigned char * get_page_ptr_rd(int addr) {
}
// function to get a byte from a 24bit address - db
int get_byte_at_address(int addr)
{
int get_byte_at_address(int addr) {
unsigned char *page_ptr_rd = get_page_ptr_rd(addr);
int offset = addr & 0xff;
int mem_byte = page_ptr_rd[offset] & 0xff;
@ -1189,8 +1135,7 @@ int get_byte_at_address(int addr)
}
// function to set a byte from a 24bit address - db
void set_byte_at_address(int addr, int value)
{
void set_byte_at_address(int addr, int value) {
unsigned char *page_ptr_rd = get_page_ptr_rd(addr);
int offset = addr & 0xff;
page_ptr_rd[offset] = value;
@ -1198,9 +1143,7 @@ void set_byte_at_address(int addr, int value)
}
void
show_addr(byte *ptr)
{
void show_addr(byte *ptr) {
word32 mem_size;
mem_size = g_mem_size_total;
@ -1210,10 +1153,10 @@ show_addr(byte *ptr)
} else if(ptr >= g_rom_fc_ff_ptr && ptr < &g_rom_fc_ff_ptr[256*1024]) {
printf("%p--rom_fc_ff[%06x]", ptr,
(word32)(ptr - g_rom_fc_ff_ptr));
} else if(ptr >= g_slow_memory_ptr && ptr<&g_slow_memory_ptr[128*1024]){
} else if(ptr >= g_slow_memory_ptr && ptr<&g_slow_memory_ptr[128*1024]) {
printf("%p--slow_memory[%06x]", ptr,
(word32)(ptr - g_slow_memory_ptr));
} else if(ptr >=g_dummy_memory1_ptr && ptr < &g_dummy_memory1_ptr[256]){
} else if(ptr >=g_dummy_memory1_ptr && ptr < &g_dummy_memory1_ptr[256]) {
printf("%p--dummy_memory[%06x]", ptr,
(word32)(ptr - g_dummy_memory1_ptr));
} else {
@ -1226,9 +1169,7 @@ show_addr(byte *ptr)
dcycs = g_last_vbl_dcycs + *cyc_ptr;
int
io_read(word32 loc, double *cyc_ptr)
{
int io_read(word32 loc, double *cyc_ptr) {
double dcycs;
word64 word64_tmp;
word32 mask;
@ -1664,7 +1605,7 @@ io_read(word32 loc, double *cyc_ptr)
case 0xbd:
case 0xbe:
case 0xbf:
if (tfe_enabled){
if (tfe_enabled) {
return tfe_read((word16)loc & 0xf);
}
else
@ -1739,9 +1680,7 @@ io_read(word32 loc, double *cyc_ptr)
return 0xff;
}
void
io_write(word32 loc, int val, double *cyc_ptr)
{
void io_write(word32 loc, int val, double *cyc_ptr) {
double dcycs;
int new_tmp;
int new_lcbank2;
@ -2240,7 +2179,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
// OG writeTranswarp pseudo-register
case 0x6a: /* 0xc06a */
transwarp_low_val = val;
return ;
return;
case 0x6b: /* 0xc06b */
val = (val<<8) + transwarp_low_val;
if ((val==2600) || (val==0x0028)) // Bug for demo ...
@ -2275,7 +2214,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
}
else
printf("unknown twgs index:%d\n",val);
return ;
return;
#else
case 0x6a: /* 0xc06a */
case 0x6b: /* 0xc06b */
@ -2464,9 +2403,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
#if 0
int
get_slow_mem(word32 loc, int duff_cycles)
{
int get_slow_mem(word32 loc, int duff_cycles) {
int val;
loc = loc & 0x1ffff;
@ -2490,9 +2427,7 @@ get_slow_mem(word32 loc, int duff_cycles)
return val;
}
int
set_slow_mem(word32 loc, int val, int duff_cycles)
{
int set_slow_mem(word32 loc, int val, int duff_cycles) {
int or_pos;
word32 or_val;
@ -2534,9 +2469,7 @@ set_slow_mem(word32 loc, int val, int duff_cycles)
/* vertical blanking engages on line 192, even if in super hires mode */
/* (Last 8 lines in SHR are drawn with vbl_active set */
word32
get_lines_since_vbl(double dcycs)
{
word32 get_lines_since_vbl(double dcycs) {
double dcycs_since_last_vbl;
double dlines_since_vbl;
double dcyc_line_start;
@ -2568,9 +2501,7 @@ get_lines_since_vbl(double dcycs)
}
int
in_vblank(double dcycs)
{
int in_vblank(double dcycs) {
int lines_since_vbl;
lines_since_vbl = get_lines_since_vbl(dcycs);
@ -2585,9 +2516,7 @@ in_vblank(double dcycs)
/* horizontal video counter goes from 0x00,0x40 - 0x7f, then 0x80,0xc0-0xff */
/* over 2*65 cycles. The last visible screen pos is 0x7f and 0xff */
/* This matches GSport starting line 0 at the border for line -1 */
int
read_vid_counters(int loc, double dcycs)
{
int read_vid_counters(int loc, double dcycs) {
word32 mask;
int lines_since_vbl;

View File

@ -1,3 +1,9 @@
/*
GSPLUS - Advanced Apple IIGS Emulator Environment
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
#include <string.h>
#include <stdlib.h>

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
@ -26,15 +26,13 @@ int g_joystick_native_type = -1;
extern int g_paddle_buttons;
int g_paddle_val[4] = { 0, 0, 0, 0 };
/* g_paddle_val[0]: Joystick X coord, [1]:Y coord */
/* g_paddle_val[0]: Joystick X coord, [1]:Y coord */
double g_paddle_dcycs[4] = { 0.0, 0.0, 0.0, 0.0 };
/* g_paddle_dcycs are the dcycs the paddle goes to 0 */
/* g_paddle_dcycs are the dcycs the paddle goes to 0 */
void
paddle_fixup_joystick_type()
{
void paddle_fixup_joystick_type() {
/* If g_joystick_type points to an illegal value, change it */
if(g_joystick_type == JOYSTICK_TYPE_NATIVE_1) {
g_joystick_native_type = g_joystick_native_type1;
@ -52,9 +50,7 @@ paddle_fixup_joystick_type()
}
}
void
paddle_trigger(double dcycs)
{
void paddle_trigger(double dcycs) {
/* Called by read/write to $c070 */
g_paddle_trig_dcycs = dcycs;
@ -76,9 +72,7 @@ paddle_trigger(double dcycs)
}
}
void
paddle_trigger_mouse(double dcycs)
{
void paddle_trigger_mouse(double dcycs) {
int val_x, val_y;
int mouse_x, mouse_y;
@ -102,9 +96,7 @@ paddle_trigger_mouse(double dcycs)
paddle_update_trigger_dcycs(dcycs);
}
void
paddle_trigger_keypad(double dcycs)
{
void paddle_trigger_keypad(double dcycs) {
int get_y;
int val_x, val_y;
@ -121,9 +113,7 @@ paddle_trigger_keypad(double dcycs)
paddle_update_trigger_dcycs(dcycs);
}
void
paddle_update_trigger_dcycs(double dcycs)
{
void paddle_update_trigger_dcycs(double dcycs) {
double trig_dcycs;
int val;
int paddle_num;
@ -167,9 +157,7 @@ paddle_update_trigger_dcycs(double dcycs)
}
}
int
read_paddles(double dcycs, int paddle)
{
int read_paddles(double dcycs, int paddle) {
double trig_dcycs;
trig_dcycs = g_paddle_dcycs[paddle & 3];
@ -181,9 +169,7 @@ read_paddles(double dcycs, int paddle)
}
}
void
paddle_update_buttons()
{
void paddle_update_buttons() {
paddle_fixup_joystick_type();
joystick_update_buttons();
}

View File

@ -3,15 +3,13 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/*
parallel.c
This file handles the Apple II Parallel Card emulation in slot 1. Its very
basic, but allows for future support of redirecting the output to a real
parallel port, files, and additional types of emulated printers.
*/
This file handles the Apple II Parallel Card emulation in slot 1. Its very
basic, but allows for future support of redirecting the output to a real
parallel port, files, and additional types of emulated printers.
*/
#include "defc.h"
#include "printer.h"
@ -21,14 +19,13 @@ extern int g_printer_timeout;
word32 printer_vbl_count = 0;
int port_block = 0;
byte parallel_read(word16 io_address)
{
byte parallel_read(word16 io_address) {
//printf("parallel card status called at %x\n", io_address);
//since we only have a virtual printer, always return state as "Ready"
return 0xff;
}
void parallel_write(word16 io_address, byte val)
{
void parallel_write(word16 io_address, byte val) {
//Mask MSB if user has it set.
if(g_parallel_out_masking) {
val = val & 0x7f;
@ -50,8 +47,7 @@ void parallel_write(word16 io_address, byte val)
//application doesn't send a form feed at the end of the page. It also
//allows multipage mode Postscript and native printer documents to
//print somewhat how a regular application would.
void printer_update()
{
void printer_update() {
if (port_block != 1 && printer_vbl_count != 0 && g_vbl_count >= printer_vbl_count)
{
printf("Calling printer_update and flushing!\n");

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include <fcntl.h>
@ -14,9 +14,7 @@
#define BUF_SIZE 65536
char buf[BUF_SIZE];
void
read_block(int fd, char *buf, int blk, int blk_size)
{
void read_block(int fd, char *buf, int blk, int blk_size) {
int ret;
ret = lseek(fd, blk * blk_size, SEEK_SET);
@ -32,9 +30,7 @@ read_block(int fd, char *buf, int blk, int blk_size)
}
}
int
main(int argc, char **argv)
{
int main(int argc, char **argv) {
Driver_desc *driver_desc_ptr;
Part_map *part_map_ptr;
double dsize;

View File

@ -1,23 +1,9 @@
/*
GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2010 - 2011 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
/*
* Copyright (C) 2002-2004 The DOSBox Team

131
src/scc.c
View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "scc_llap.h"
@ -81,9 +81,7 @@ static char* rr_names[] = {
int g_scc_overflow = 0;
void
scc_init()
{
void scc_init() {
Scc *scc_ptr;
int i, j;
@ -123,9 +121,7 @@ scc_init()
scc_reset();
}
void
scc_reset()
{
void scc_reset() {
Scc *scc_ptr;
int i;
@ -153,9 +149,7 @@ scc_reset()
}
}
void
scc_hard_reset_port(int port)
{
void scc_hard_reset_port(int port) {
Scc *scc_ptr;
scc_reset_port(port);
@ -182,9 +176,7 @@ scc_hard_reset_port(int port)
scc_regen_clocks(port);
}
void
scc_reset_port(int port)
{
void scc_reset_port(int port) {
Scc *scc_ptr;
scc_ptr = &(scc_stat[port]);
@ -215,9 +207,7 @@ scc_reset_port(int port)
scc_clr_rx_int(port);
}
void
scc_regen_clocks(int port)
{
void scc_regen_clocks(int port) {
Scc *scc_ptr;
double br_dcycs, tx_dcycs, rx_dcycs;
double rx_char_size, tx_char_size;
@ -386,9 +376,7 @@ scc_regen_clocks(int port)
}
void
scc_port_init(int port)
{
void scc_port_init(int port) {
int state;
state = 0;
switch (g_serial_type[port]) {
@ -414,9 +402,7 @@ scc_port_init(int port)
}
}
void
scc_try_to_empty_writebuf(int port, double dcycs)
{
void scc_try_to_empty_writebuf(int port, double dcycs) {
Scc *scc_ptr;
int state;
@ -453,9 +439,7 @@ scc_try_to_empty_writebuf(int port, double dcycs)
}
}
void
scc_try_fill_readbuf(int port, double dcycs)
{
void scc_try_fill_readbuf(int port, double dcycs) {
Scc *scc_ptr;
int space_used_before_rx, space_left;
int space_used_after_rx;
@ -526,9 +510,7 @@ scc_try_fill_readbuf(int port, double dcycs)
scc_ptr->lad += space_used_after_rx - space_used_before_rx;
}
void
scc_update(double dcycs)
{
void scc_update(double dcycs) {
if (g_appletalk_bridging && (scc_stat[0].state == 3 || scc_stat[1].state == 3))
scc_llap_update();
@ -557,9 +539,7 @@ scc_update(double dcycs)
}
}
void
do_scc_event(int type, double dcycs)
{
void do_scc_event(int type, double dcycs) {
Scc *scc_ptr;
int port;
@ -585,9 +565,7 @@ do_scc_event(int type, double dcycs)
return;
}
void
show_scc_state()
{
void show_scc_state() {
Scc *scc_ptr;
int i, j;
@ -650,9 +628,7 @@ int g_scc_log_pos = 0;
#define SCC_REGNUM(wr,port,reg) ((wr << 8) + (port << 4) + reg)
void
scc_log(int regnum, word32 val, double dcycs)
{
void scc_log(int regnum, word32 val, double dcycs) {
int pos;
pos = g_scc_log_pos;
@ -666,9 +642,7 @@ scc_log(int regnum, word32 val, double dcycs)
g_scc_log_pos = pos;
}
void
show_scc_log(void)
{
void show_scc_log(void) {
double dcycs;
int regnum;
int pos;
@ -698,8 +672,7 @@ show_scc_log(void)
}
}
word16 scc_read_lad(int port)
{
word16 scc_read_lad(int port) {
// The IIgs provides a "LocalTalk link activity detector (LAD)" through repurposing the
// MegaII mouse interface. Per the IIgs schematic, the MegaII mouse inputs connect via
// the MSEX and MSEY lines to the RX lines of the SCC between the SCC and the line drivers.
@ -728,9 +701,7 @@ word16 scc_read_lad(int port)
return 0;
}
word32
scc_read_reg(int port, double dcycs)
{
word32 scc_read_reg(int port, double dcycs) {
Scc *scc_ptr;
word32 ret;
int regnum;
@ -780,7 +751,7 @@ scc_read_reg(int port, double dcycs)
ret = scc_stat[0].reg[2];
wr9 = scc_stat[0].reg[9];
for(i = 0; i < 8; i++) {
if(ZZZ){};
if(ZZZ) {};
}
if(wr9 & 0x10) {
/* wr9 status high */
@ -831,9 +802,7 @@ scc_read_reg(int port, double dcycs)
return ret;
}
void
scc_write_reg(int port, word32 val, double dcycs)
{
void scc_write_reg(int port, word32 val, double dcycs) {
Scc *scc_ptr;
word32 old_val;
word32 changed_bits;
@ -1174,9 +1143,7 @@ scc_write_reg(int port, word32 val, double dcycs)
}
}
void
scc_maybe_br_event(int port, double dcycs)
{
void scc_maybe_br_event(int port, double dcycs) {
Scc *scc_ptr;
double br_dcycs;
@ -1199,9 +1166,7 @@ scc_maybe_br_event(int port, double dcycs)
add_event_scc(dcycs + br_dcycs, SCC_MAKE_EVENT(port, SCC_BR_EVENT));
}
void
scc_evaluate_ints(int port)
{
void scc_evaluate_ints(int port) {
Scc *scc_ptr;
word32 irq_add_mask, irq_remove_mask;
int mie;
@ -1257,9 +1222,7 @@ scc_evaluate_ints(int port)
}
void
scc_maybe_rx_event(int port, double dcycs)
{
void scc_maybe_rx_event(int port, double dcycs) {
Scc *scc_ptr;
double rx_dcycs;
int in_rdptr, in_wrptr;
@ -1299,9 +1262,7 @@ scc_maybe_rx_event(int port, double dcycs)
add_event_scc(dcycs + rx_dcycs, SCC_MAKE_EVENT(port, SCC_RX_EVENT));
}
void
scc_maybe_rx_int(int port, double dcycs)
{
void scc_maybe_rx_int(int port, double dcycs) {
Scc *scc_ptr;
int depth;
int rx_int_mode;
@ -1338,16 +1299,12 @@ scc_maybe_rx_int(int port, double dcycs)
scc_evaluate_ints(port);
}
void
scc_clr_rx_int(int port)
{
void scc_clr_rx_int(int port) {
scc_stat[port].wantint_rx = 0;
scc_evaluate_ints(port);
}
void
scc_handle_tx_event(int port, double dcycs)
{
void scc_handle_tx_event(int port, double dcycs) {
Scc *scc_ptr;
int tx_int_mode;
@ -1361,9 +1318,7 @@ scc_handle_tx_event(int port, double dcycs)
scc_evaluate_ints(port);
}
void
scc_maybe_tx_event(int port, double dcycs)
{
void scc_maybe_tx_event(int port, double dcycs) {
Scc *scc_ptr;
double tx_dcycs;
@ -1382,16 +1337,12 @@ scc_maybe_tx_event(int port, double dcycs)
}
}
void
scc_clr_tx_int(int port)
{
void scc_clr_tx_int(int port) {
scc_stat[port].wantint_tx = 0;
scc_evaluate_ints(port);
}
void
scc_set_zerocnt_int(int port)
{
void scc_set_zerocnt_int(int port) {
Scc *scc_ptr;
scc_ptr = &(scc_stat[port]);
@ -1402,16 +1353,12 @@ scc_set_zerocnt_int(int port)
scc_evaluate_ints(port);
}
void
scc_clr_zerocnt_int(int port)
{
void scc_clr_zerocnt_int(int port) {
scc_stat[port].wantint_zerocnt = 0;
scc_evaluate_ints(port);
}
void
scc_add_to_readbuf(int port, word32 val, double dcycs)
{
void scc_add_to_readbuf(int port, word32 val, double dcycs) {
Scc *scc_ptr;
int in_wrptr;
int in_wrptr_next;
@ -1440,9 +1387,7 @@ scc_add_to_readbuf(int port, word32 val, double dcycs)
scc_maybe_rx_event(port, dcycs);
}
void
scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...)
{
void scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...) {
va_list ap;
char *bufptr;
int len, c;
@ -1463,9 +1408,7 @@ scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...)
va_end(ap);
}
void
scc_transmit(int port, word32 val, double dcycs)
{
void scc_transmit(int port, word32 val, double dcycs) {
Scc *scc_ptr;
int out_wrptr;
int out_rdptr;
@ -1504,9 +1447,7 @@ scc_transmit(int port, word32 val, double dcycs)
scc_add_to_writebuf(port, val, dcycs);
}
void
scc_add_to_writebuf(int port, word32 val, double dcycs)
{
void scc_add_to_writebuf(int port, word32 val, double dcycs) {
Scc *scc_ptr;
int out_wrptr;
int out_wrptr_next;
@ -1542,9 +1483,7 @@ scc_add_to_writebuf(int port, word32 val, double dcycs)
}
}
word32
scc_read_data(int port, double dcycs)
{
word32 scc_read_data(int port, double dcycs) {
Scc *scc_ptr;
word32 ret;
int depth;
@ -1588,9 +1527,7 @@ scc_read_data(int port, double dcycs)
}
void
scc_write_data(int port, word32 val, double dcycs)
{
void scc_write_data(int port, word32 val, double dcycs) {
Scc *scc_ptr;
scc_printf("SCC write %04x: %02x\n", 0xc03b-port, val);

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/* This is an interface between the SCC emulation and the Virtual Imagewriter. */
@ -25,8 +25,7 @@ word32 imagewriter_vbl_count = 0;
int imagewriter_port_block = 0;
int iw_scc_write = 0;
int scc_imagewriter_init(int port)
{
int scc_imagewriter_init(int port) {
Scc *scc_ptr;
scc_ptr = &(scc_stat[port]);
imagewriter_init(g_imagewriter_dpi,g_imagewriter_paper,g_imagewriter_banner,g_imagewriter_output,g_imagewriter_multipage);
@ -35,8 +34,7 @@ int scc_imagewriter_init(int port)
}
/** Transfer data from Imagewriter to the SCC **/
void scc_imagewriter_fill_readbuf(int port, int space_left, double dcycs)
{
void scc_imagewriter_fill_readbuf(int port, int space_left, double dcycs) {
if (iw_scc_write)
{
size_t bytes_read;
@ -77,8 +75,7 @@ void scc_imagewriter_fill_readbuf(int port, int space_left, double dcycs)
}
/** Transfer data from the SCC to the Imagewriter. **/
void scc_imagewriter_empty_writebuf(int port, double dcycs)
{
void scc_imagewriter_empty_writebuf(int port, double dcycs) {
Scc* scc_ptr;
int rdptr;
@ -134,8 +131,7 @@ void scc_imagewriter_empty_writebuf(int port, double dcycs)
//application doesn't send a form feed at the end of the page. It also
//allows multipage mode Postscript and native printer documents to
//print somewhat how a regular application would.
void imagewriter_update()
{
void imagewriter_update() {
if (imagewriter_port_block != 1 && imagewriter_vbl_count != 0 && g_vbl_count >= imagewriter_vbl_count)
{
printf("Calling imagewriter_update and flushing!\n");

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/* This is an interface between the SCC emulation and the LAP bridge. */
@ -25,20 +25,17 @@ extern Scc scc_stat[2];
extern int g_config_gsplus_update_needed;
static bool bridge_initialized = false;
void scc_llap_init()
{
void scc_llap_init() {
atbridge_set_diagnostics(g_appletalk_diagnostics);
bridge_initialized = atbridge_init();
atbridge_set_net(g_appletalk_network_hint);
}
void scc_llap_set_node(byte val)
{
void scc_llap_set_node(byte val) {
atbridge_set_node(val);
}
void scc_llap_update()
{
void scc_llap_update() {
if (bridge_initialized)
{
atbridge_process();
@ -54,8 +51,7 @@ void scc_llap_update()
}
/** Transfer one packet from the bridge to the SCC **/
void scc_llap_fill_readbuf(int port, int space_left, double dcycs)
{
void scc_llap_fill_readbuf(int port, int space_left, double dcycs) {
atbridge_set_diagnostics(g_appletalk_diagnostics);
byte* data;
@ -80,8 +76,7 @@ void scc_llap_fill_readbuf(int port, int space_left, double dcycs)
}
/** Transfer one packet from the SCC to the AppleTalk bridge. **/
void scc_llap_empty_writebuf(int port, double dcycs)
{
void scc_llap_empty_writebuf(int port, double dcycs) {
atbridge_set_diagnostics(g_appletalk_diagnostics);
Scc* scc_ptr;
@ -130,23 +125,18 @@ void scc_llap_empty_writebuf(int port, double dcycs)
}
#else
void scc_llap_init()
{
void scc_llap_init() {
}
void scc_llap_set_node(byte val)
{
void scc_llap_set_node(byte val) {
}
void scc_llap_update()
{
void scc_llap_update() {
}
void scc_llap_fill_readbuf(int port, int space_left, double dcycs)
{
void scc_llap_fill_readbuf(int port, int space_left, double dcycs) {
}
void scc_llap_empty_writebuf(int port, double dcycs)
{
void scc_llap_empty_writebuf(int port, double dcycs) {
}
#endif

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/* This file contains the Mac serial calls */
@ -18,9 +18,7 @@ extern Scc scc_stat[2];
extern word32 g_c025_val;
#ifdef MAC
int
scc_serial_mac_init(int port)
{
int scc_serial_mac_init(int port) {
char str_buf[1024];
Scc *scc_ptr;
int state;
@ -54,9 +52,7 @@ scc_serial_mac_init(int port)
return state;
}
void
scc_serial_mac_change_params(int port)
{
void scc_serial_mac_change_params(int port) {
struct termios termios_buf;
Scc *scc_ptr;
int fd;
@ -124,9 +120,7 @@ scc_serial_mac_change_params(int port)
}
}
void
scc_serial_mac_fill_readbuf(int port, int space_left, double dcycs)
{
void scc_serial_mac_fill_readbuf(int port, int space_left, double dcycs) {
byte tmp_buf[256];
Scc *scc_ptr;
int fd;
@ -152,9 +146,7 @@ scc_serial_mac_fill_readbuf(int port, int space_left, double dcycs)
}
void
scc_serial_mac_empty_writebuf(int port)
{
void scc_serial_mac_empty_writebuf(int port) {
Scc *scc_ptr;
int fd;
int rdptr;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/* This file contains the socket calls */
@ -34,9 +34,7 @@ typedef unsigned short USHORT;
/* outgoing socket. Any hang-up causes the socket to be closed and it will */
/* then re-open on a subsequent call to scc_socket_open */
void
scc_socket_init(int port)
{
void scc_socket_init(int port) {
Scc *scc_ptr;
#ifdef _WIN32
@ -65,9 +63,7 @@ scc_socket_init(int port)
/* Real init will be done when bytes need to be read/write from skt */
}
static int
scc_socket_close_handle(SOCKET sockfd)
{
static int scc_socket_close_handle(SOCKET sockfd) {
if (sockfd != -1)
{
#if defined(_WIN32)
@ -79,9 +75,7 @@ scc_socket_close_handle(SOCKET sockfd)
return 0;
}
void
scc_socket_maybe_open_incoming(int port, double dcycs)
{
void scc_socket_maybe_open_incoming(int port, double dcycs) {
Scc *scc_ptr;
struct sockaddr_in sa_in;
int on;
@ -165,9 +159,7 @@ scc_socket_maybe_open_incoming(int port, double dcycs)
}
void
scc_socket_open_outgoing(int port, double dcycs)
{
void scc_socket_open_outgoing(int port, double dcycs) {
Scc *scc_ptr;
struct sockaddr_in sa_in;
struct hostent *hostentptr;
@ -262,9 +254,7 @@ scc_socket_open_outgoing(int port, double dcycs)
scc_ptr->rdwrfd = scc_ptr->sockfd;
}
void
scc_socket_make_nonblock(int port, double dcycs)
{
void scc_socket_make_nonblock(int port, double dcycs) {
Scc *scc_ptr;
SOCKET sockfd;
int ret;
@ -301,14 +291,10 @@ scc_socket_make_nonblock(int port, double dcycs)
#endif
}
void
scc_socket_change_params(int port)
{
void scc_socket_change_params(int port) {
}
void
scc_socket_close(int port, int full_close, double dcycs)
{
void scc_socket_close(int port, int full_close, double dcycs) {
Scc *scc_ptr;
int rdwrfd;
SOCKET sockfd;
@ -358,9 +344,7 @@ scc_socket_close(int port, int full_close, double dcycs)
}
}
void
scc_accept_socket(int port, double dcycs)
{
void scc_accept_socket(int port, double dcycs) {
#ifdef SCC_SOCKETS
Scc *scc_ptr;
int flags;
@ -420,9 +404,7 @@ scc_accept_socket(int port, double dcycs)
#endif
}
void
scc_socket_telnet_reqs(int port, double dcycs)
{
void scc_socket_telnet_reqs(int port, double dcycs) {
Scc *scc_ptr;
word32 mask, willmask, domask;
int i, j;
@ -447,9 +429,7 @@ scc_socket_telnet_reqs(int port, double dcycs)
}
}
void
scc_socket_fill_readbuf(int port, int space_left, double dcycs)
{
void scc_socket_fill_readbuf(int port, int space_left, double dcycs) {
#ifdef SCC_SOCKETS
byte tmp_buf[256];
Scc *scc_ptr;
@ -493,9 +473,7 @@ scc_socket_fill_readbuf(int port, int space_left, double dcycs)
int g_scc_dbg_print_cnt = 50;
void
scc_socket_recvd_char(int port, int c, double dcycs)
{
void scc_socket_recvd_char(int port, int c, double dcycs) {
Scc *scc_ptr;
word32 locmask, remmask, mask;
word32 reqwillmask, reqdomask;
@ -675,9 +653,7 @@ scc_socket_recvd_char(int port, int c, double dcycs)
scc_ptr->telnet_mode = telnet_mode;
}
void
scc_socket_empty_writebuf(int port, double dcycs)
{
void scc_socket_empty_writebuf(int port, double dcycs) {
#ifdef SCC_SOCKETS
# if !defined(_WIN32)
struct sigaction newact, oldact;
@ -808,9 +784,7 @@ scc_socket_empty_writebuf(int port, double dcycs)
#endif
}
void
scc_socket_modem_write(int port, int c, double dcycs)
{
void scc_socket_modem_write(int port, int c, double dcycs) {
Scc *scc_ptr;
char *str;
word32 modem_mode;
@ -876,9 +850,7 @@ scc_socket_modem_write(int port, int c, double dcycs)
}
}
void
scc_socket_do_cmd_str(int port, double dcycs)
{
void scc_socket_do_cmd_str(int port, double dcycs) {
Scc *scc_ptr;
char *str;
int pos, len;
@ -1057,9 +1029,7 @@ scc_socket_do_cmd_str(int port, double dcycs)
}
}
void
scc_socket_send_modem_code(int port, int code, double dcycs)
{
void scc_socket_send_modem_code(int port, int code, double dcycs) {
Scc *scc_ptr;
char *str;
word32 modem_mode;
@ -1093,22 +1063,16 @@ scc_socket_send_modem_code(int port, int code, double dcycs)
}
}
void
scc_socket_modem_hangup(int port, double dcycs)
{
void scc_socket_modem_hangup(int port, double dcycs) {
scc_socket_send_modem_code(port, 3, dcycs);
}
void
scc_socket_modem_connect(int port, double dcycs)
{
void scc_socket_modem_connect(int port, double dcycs) {
/* decide which code to send. Default to 1 if needed */
scc_socket_send_modem_code(port, 13, dcycs); /*13=9600*/
}
void
scc_socket_modem_do_ring(int port, double dcycs)
{
void scc_socket_modem_do_ring(int port, double dcycs) {
Scc *scc_ptr;
double diff_dcycs;
int num_rings;
@ -1141,9 +1105,7 @@ scc_socket_modem_do_ring(int port, double dcycs)
}
}
void
scc_socket_do_answer(int port, double dcycs)
{
void scc_socket_do_answer(int port, double dcycs) {
Scc *scc_ptr;
scc_ptr = &(scc_stat[port]);

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
/* This file contains the Win32 COM1/COM2 calls */
@ -23,9 +23,7 @@ extern Scc scc_stat[2];
extern word32 g_c025_val;
#ifdef _WIN32
int
scc_serial_win_init(int port)
{
int scc_serial_win_init(int port) {
COMMTIMEOUTS commtimeouts;
TCHAR str_buf[8];
Scc *scc_ptr;
@ -75,9 +73,7 @@ scc_serial_win_init(int port)
return state;
}
void
scc_serial_win_change_params(int port)
{
void scc_serial_win_change_params(int port) {
DCB *dcbptr;
HANDLE host_handle;
Scc *scc_ptr;
@ -157,9 +153,7 @@ scc_serial_win_change_params(int port)
}
}
void
scc_serial_win_fill_readbuf(int port, int space_left, double dcycs)
{
void scc_serial_win_fill_readbuf(int port, int space_left, double dcycs) {
byte tmp_buf[256];
Scc *scc_ptr;
HANDLE host_handle;
@ -190,9 +184,7 @@ scc_serial_win_fill_readbuf(int port, int space_left, double dcycs)
}
void
scc_serial_win_empty_writebuf(int port)
{
void scc_serial_win_empty_writebuf(int port) {
Scc *scc_ptr;
HANDLE host_handle;
int rdptr;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
// fps shiz
unsigned int lastTime = 0, currentTime, frames;
@ -192,8 +192,7 @@ int a2_key_to_sdlkeycode[][3] = {
int main(int argc, char **argv)
{
int main(int argc, char **argv) {
return gsplusmain(argc, argv);
}
@ -311,9 +310,8 @@ void dev_video_init_sdl() {
window = SDL_CreateWindow(
window_title, // window title (GSport vX.X)
// SDL_WINDOWPOS_UNDEFINED, // initial x position
// SDL_WINDOWPOS_UNDEFINED, // initial y position
startx, starty,
startx,
starty,
BASE_WINDOW_WIDTH, // width, in pixels
X_A2_WINDOW_HEIGHT, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
@ -384,15 +382,6 @@ void dev_video_init_sdl() {
// Copy a rect to our SDL window
void sdl_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy, int width, int height) {
// FPS shiz
currentTime = SDL_GetTicks();
if (currentTime > lastTime + 1000) {
printf("FPS: %d\n", frames);
frames = 0;
lastTime = currentTime;
}
frames++;
byte *src_ptr;
int pixel_size = 4;
@ -463,7 +452,7 @@ void check_input_events_sdl() {
if (event.type == SDL_WINDOWEVENT) {
set_refresh_needed();
}
switch( event.type ){
switch( event.type ) {
case SDL_KEYDOWN:
case SDL_KEYUP:
handle_sdl_key_event(event);
@ -581,7 +570,7 @@ void handle_sdl_key_event(SDL_Event event) {
if (event.type == SDL_KEYUP) {
is_up = 1;
}
switch( event.key.keysym.sym ){
switch( event.key.keysym.sym ) {
case SDLK_F11:
if (kb_shift_control_state & ShiftMask) { // SHIFT+F11
if (!is_up) {
@ -623,7 +612,7 @@ int handle_sdl_mouse_motion_event(SDL_Event event) {
x = event.motion.x - BASE_MARGIN_LEFT;
y = event.motion.y - BASE_MARGIN_TOP;
if (event.type == SDL_MOUSEBUTTONUP) {
return update_mouse(x, y, 0 , event.motion.state &7 );
return update_mouse(x, y, 0, event.motion.state &7 );
} else {
return update_mouse(x, y, event.motion.state, event.motion.state &7 );
}
@ -714,7 +703,7 @@ void x_take_screenshot() {
SDL_FreeSurface(image);
}
SDL_FreeSurface(s);
}
}
void clipboard_paste(void) {

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "SDL.h"
#include "defc.h"
@ -29,8 +29,7 @@ static int g_zeroes_seen;
SDL_AudioDeviceID dev = 0;
void sdlsnd_init(word32 *shmaddr)
{
void sdlsnd_init(word32 *shmaddr) {
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
glog("Could not initialize SDL2 audio");
g_audio_enable = 0;
@ -43,9 +42,7 @@ void sdlsnd_init(word32 *shmaddr)
}
void
sound_write_sdl(int real_samps, int size)
{
void sound_write_sdl(int real_samps, int size) {
#ifdef HAVE_SDL
int shm_read;
@ -91,8 +88,7 @@ sound_write_sdl(int real_samps, int size)
#ifdef HAVE_SDL
/* Callback for sound */
static void _snd_callback(void* userdata, Uint8 *stream, int len)
{
static void _snd_callback(void* userdata, Uint8 *stream, int len) {
int i;
/* Slurp off the play buffer */
assert((snd_buf+snd_write - snd_read)%snd_buf == g_playbuf_buffered%snd_buf);
@ -121,9 +117,7 @@ static void _snd_callback(void* userdata, Uint8 *stream, int len)
long
sound_init_device_sdl()
{
long sound_init_device_sdl() {
#ifdef HAVE_SDL
long rate;
SDL_AudioSpec wanted;
@ -189,7 +183,7 @@ sound_init_device_sdl()
set_audio_rate(rate);
return rate;
snd_error:
snd_error:
/* Oops! Something bad happened, cleanup. */
SDL_CloseAudioDevice(dev);
SDL_QuitSubSystem(SDL_INIT_AUDIO);
@ -203,9 +197,7 @@ sound_init_device_sdl()
#endif
}
void
sound_shutdown_sdl()
{
void sound_shutdown_sdl() {
#ifdef HAVE_SDL
SDL_CloseAudioDevice(dev);
if(playbuf)

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include <assert.h>
#include "defc.h"
@ -55,8 +55,7 @@ static void sound_write_sdl(int real_samps, int size);
#endif
void sdlsnd_init(word32 *shmaddr)
{
void sdlsnd_init(word32 *shmaddr) {
printf("sdlsnd_init\n");
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
printf("Cannot initialize SDL audio\n");
@ -70,9 +69,7 @@ void sdlsnd_init(word32 *shmaddr)
void
win32snd_init(word32 *shmaddr)
{
void win32snd_init(word32 *shmaddr) {
printf("win32snd_init\n");
child_sound_loop(-1, -1, shmaddr);
@ -104,7 +101,7 @@ void handle_sdl_snd(void *userdata, Uint8 *stream, int len) {
/* if ( g_playbuf_buffered == 0) {
return;
}
*/
*/
for(int i = 0; i < len; ++i) {
if(g_playbuf_buffered <= 0) {
stream[i] = 0;
@ -144,9 +141,7 @@ void handle_sdl_snd(void *userdata, Uint8 *stream, int len) {
}
void
child_sound_init_sdl()
{
void child_sound_init_sdl() {
printf("child_sound_init_sdl");
SDL_memset(&want, 0, sizeof(want)); // or SDL_zero(want)
@ -193,8 +188,7 @@ child_sound_init_sdl()
void
sdlsnd_shutdown() {
void sdlsnd_shutdown() {
//SDL_Delay(5000); // let the audio callback play some sound for 5 seconds.
SDL_CloseAudioDevice(dev);
printf("sdlsnd_shutdown");

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include <math.h>
#include "defc.h"
@ -28,12 +28,12 @@ extern char g_config_gsplus_screenshot_dir[];
#define WIN32_LEAN_AND_MEAN /* Tell windows we want less header gunk */
#define STRICT /* Tell Windows we want compile type checks */
#include <windows.h> /* Need a definition for LPTSTR in CYGWIN */
extern void get_cwd(LPTSTR buffer, int size);
extern void get_cwd(LPTSTR buffer, int size);
#endif
#define PC_LOG_LEN (8*1024)
int g_speed_fast ; // OG Expose fast parameter
int g_speed_fast; // OG Expose fast parameter
int g_initialized = 0; // OG To know if the emulator has finalized its initialization
int g_accept_events = 0; // OG To know if the emulator is ready to accept external events
char g_argv0_path[256] = "./";
@ -51,7 +51,8 @@ const char *g_gsplus_default_paths[] = { // probably overkill on the paths
"/usr/share/gsplus/",
"/var/lib/",
"${0}/",
0 };
0
};
#define MAX_EVENTS 64
@ -469,9 +470,7 @@ void show_toolbox_log() {
#if 0
/* get_memory_c is not used, get_memory_asm is, but this does what the */
/* assembly language would do */
word32
get_memory_c(word32 loc, int diff_cycles)
{
word32 get_memory_c(word32 loc, int diff_cycles) {
byte *addr;
word32 result;
int index;
@ -541,16 +540,12 @@ word32 get_memory_io(word32 loc, double *cyc_ptr) {
}
#if 0
word32
get_memory16_pieces(word32 loc, int diff_cycles)
{
word32 get_memory16_pieces(word32 loc, int diff_cycles) {
return(get_memory_c(loc, diff_cycles) +
(get_memory_c(loc+1, diff_cycles) << 8));
}
word32
get_memory24(word32 loc, int diff_cycles)
{
word32 get_memory24(word32 loc, int diff_cycles) {
return(get_memory_c(loc, diff_cycles) +
(get_memory_c(loc+1, diff_cycles) << 8) +
(get_memory_c(loc+2, diff_cycles) << 16));
@ -558,9 +553,7 @@ get_memory24(word32 loc, int diff_cycles)
#endif
#if 0
void
set_memory(word32 loc, int val, int diff_cycles)
{
void set_memory(word32 loc, int val, int diff_cycles) {
byte *ptr;
word32 new_addr;
word32 tmp;
@ -659,9 +652,7 @@ void set_memory_io(word32 loc, int val, double *cyc_ptr) {
#if 0
void
check_breakpoints_c(word32 loc)
{
void check_breakpoints_c(word32 loc) {
int index;
int count;
int i;
@ -679,9 +670,7 @@ check_breakpoints_c(word32 loc)
#endif
void
show_regs_act(Engine_reg *eptr)
{
void show_regs_act(Engine_reg *eptr) {
int tmp_acc, tmp_x, tmp_y, tmp_psw;
int kpc;
int direct_page, dbank;
@ -699,7 +688,7 @@ show_regs_act(Engine_reg *eptr)
tmp_psw = eptr->psr;
printf(" PC=%02x.%04x A=%04x X=%04x Y=%04x P=%03x",
kpc>>16, kpc & 0xffff ,tmp_acc,tmp_x,tmp_y,tmp_psw);
kpc>>16, kpc & 0xffff,tmp_acc,tmp_x,tmp_y,tmp_psw);
printf(" S=%04x D=%04x B=%02x,cyc:%.3f\n", stack, direct_page,
dbank, g_cur_dcycs);
}
@ -716,10 +705,10 @@ void quitEmulator() {
//OG change exit to fatal_exit()
#ifndef ACTIVEGS
// use standard exit function
// use standard exit function
#define fatalExit exit
#else
extern void fatalExit(int);
extern void fatalExit(int);
#endif
void my_exit(int ret) {
@ -735,7 +724,7 @@ void do_reset() {
// OG Cleared remaining IRQS on RESET
extern int g_irq_pending;
extern int g_scan_int_events ;
extern int g_scan_int_events;
extern int g_c023_val;
g_c068_statereg = 0x08 + 0x04 + 0x01; /* rdrom, lcbank2, intcx */
@ -1037,9 +1026,7 @@ int gsplusmain(int argc, char **argv) {
return 0;
}
void
load_roms_init_memory()
{
void load_roms_init_memory() {
config_load_roms();
memory_ptr_init();
clk_setup_bram_version(); /* Must be after config_load_roms */
@ -1059,16 +1046,13 @@ load_roms_init_memory()
}
// OG Added load_roms_shut_memory
void load_roms_shut_memory()
{
void load_roms_shut_memory() {
memory_ptr_shut();
}
#ifndef ACTIVEGS
void
gsport_expand_path(char *out_ptr, const char *in_ptr, int maxlen)
{
void gsport_expand_path(char *out_ptr, const char *in_ptr, int maxlen) {
char name_buf[256];
char *tmp_ptr;
int name_len;
@ -1138,8 +1122,7 @@ gsport_expand_path(char *out_ptr, const char *in_ptr, int maxlen)
}
}
void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_create_file, const char **name_ptr)
{
void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_create_file, const char **name_ptr) {
char local_path[256];
struct stat stat_buf;
const char **path_ptr;
@ -1227,9 +1210,7 @@ Event g_event_list[MAX_EVENTS];
Event g_event_free;
Event g_event_start;
void
initialize_events()
{
void initialize_events() {
int i;
for(i = 1; i < MAX_EVENTS; i++) {
@ -1244,9 +1225,7 @@ initialize_events()
add_event_entry(DCYCS_IN_16MS, EV_60HZ);
}
void
check_for_one_event_type(int type)
{
void check_for_one_event_type(int type) {
Event *ptr;
int count;
int depth;
@ -1269,9 +1248,7 @@ check_for_one_event_type(int type)
}
void
add_event_entry(double dcycs, int type)
{
void add_event_entry(double dcycs, int type) {
Event *this_event;
Event *ptr, *prev_ptr;
int tmp_type;
@ -1330,9 +1307,7 @@ add_event_entry(double dcycs, int type)
extern int g_doc_saved_ctl;
double
remove_event_entry(int type)
{
double remove_event_entry(int type) {
Event *ptr, *prev_ptr;
Event *next_ptr;
@ -1367,15 +1342,11 @@ remove_event_entry(int type)
return 0.0;
}
void
add_event_stop(double dcycs)
{
void add_event_stop(double dcycs) {
add_event_entry(dcycs, EV_STOP);
}
void
add_event_doc(double dcycs, int osc)
{
void add_event_doc(double dcycs, int osc) {
if(dcycs < g_cur_dcycs) {
dcycs = g_cur_dcycs;
#if 0
@ -1387,9 +1358,7 @@ add_event_doc(double dcycs, int osc)
add_event_entry(dcycs, EV_DOC_INT + (osc << 8));
}
void
add_event_scc(double dcycs, int type)
{
void add_event_scc(double dcycs, int type) {
if(dcycs < g_cur_dcycs) {
dcycs = g_cur_dcycs;
}
@ -1397,39 +1366,29 @@ add_event_scc(double dcycs, int type)
add_event_entry(dcycs, EV_SCC + (type << 8));
}
void
add_event_vbl()
{
void add_event_vbl() {
double dcycs;
dcycs = g_last_vbl_dcycs + (DCYCS_IN_16MS * (192.0/262.0));
add_event_entry(dcycs, EV_VBL_INT);
}
void
add_event_vid_upd(int line)
{
void add_event_vid_upd(int line) {
double dcycs;
dcycs = g_last_vbl_dcycs + ((DCYCS_IN_16MS * line) / 262.0);
add_event_entry(dcycs, EV_VID_UPD + (line << 8));
}
double
remove_event_doc(int osc)
{
double remove_event_doc(int osc) {
return remove_event_entry(EV_DOC_INT + (osc << 8));
}
double
remove_event_scc(int type)
{
double remove_event_scc(int type) {
return remove_event_entry(EV_SCC + (type << 8));
}
void
show_all_events()
{
void show_all_events() {
Event *ptr;
int count;
double dcycs;
@ -1471,17 +1430,13 @@ Fplus g_recip_projected_pmhz_fast;
Fplus g_recip_projected_pmhz_zip;
Fplus g_recip_projected_pmhz_unl;
void
show_pmhz()
{
void show_pmhz() {
printf("Pmhz: %f, c036:%02x, limit: %d\n",
g_projected_pmhz, g_c036_val_speed, g_limit_speed);
}
void
setup_zip_speeds()
{
void setup_zip_speeds() {
double frecip;
double fmhz;
int mult;
@ -1508,9 +1463,7 @@ setup_zip_speeds()
}
}
void
run_prog()
{
void run_prog() {
Fplus *fplus_ptr;
Event *this_event;
Event *db1;
@ -1764,9 +1717,7 @@ run_prog()
x_auto_repeat_on(0);
}
void
add_irq(word32 irq_mask)
{
void add_irq(word32 irq_mask) {
if(g_irq_pending & irq_mask) {
/* Already requested, just get out */
return;
@ -1775,15 +1726,11 @@ add_irq(word32 irq_mask)
set_halt(HALT_EVENT);
}
void
remove_irq(word32 irq_mask)
{
void remove_irq(word32 irq_mask) {
g_irq_pending = g_irq_pending & (~irq_mask);
}
void
take_irq(int is_it_brk)
{
void take_irq(int is_it_brk) {
word32 new_kpc;
word32 va;
@ -1864,9 +1811,7 @@ int g_scan_int_events = 0;
void
show_dtime_array()
{
void show_dtime_array() {
double dfirst_time;
double first_total_cycs;
int i;
@ -1919,9 +1864,7 @@ extern int g_a2vid_palette;
extern int g_status_refresh_needed;
void
update_60hz(double dcycs, double dtime_now)
{
void update_60hz(double dcycs, double dtime_now) {
register word32 end_time;
char status_buf[1024];
char sim_mhz_buf[128];
@ -2157,11 +2100,11 @@ update_60hz(double dcycs, double dtime_now)
predicted_pmhz = eff_pmhz * dratio;
if(! (predicted_pmhz < (1.4 * g_projected_pmhz))) {
if(!(predicted_pmhz < (1.4 * g_projected_pmhz))) {
predicted_pmhz = 1.4 * g_projected_pmhz;
}
if(! (predicted_pmhz > (0.7 * g_projected_pmhz))) {
if(!(predicted_pmhz > (0.7 * g_projected_pmhz))) {
predicted_pmhz = 0.7 * g_projected_pmhz;
}
@ -2278,9 +2221,7 @@ update_60hz(double dcycs, double dtime_now)
paddle_update_buttons();
}
void
do_vbl_int()
{
void do_vbl_int() {
if(g_c041_val & C041_EN_VBL_INTS) {
g_c046_val |= 0x08;
add_irq(IRQ_PENDING_C046_VBL);
@ -2290,9 +2231,7 @@ do_vbl_int()
}
void
do_scan_int(double dcycs, int line)
{
void do_scan_int(double dcycs, int line) {
int c023_val;
g_scan_int_events = 0;
@ -2320,9 +2259,7 @@ do_scan_int(double dcycs, int line)
}
}
void
check_scan_line_int(double dcycs, int cur_video_line)
{
void check_scan_line_int(double dcycs, int cur_video_line) {
int delay;
int start;
int line;
@ -2365,9 +2302,7 @@ check_scan_line_int(double dcycs, int cur_video_line)
}
}
void
check_for_new_scan_int(double dcycs)
{
void check_for_new_scan_int(double dcycs) {
int cur_video_line;
cur_video_line = get_lines_since_vbl(dcycs) >> 8;
@ -2375,9 +2310,7 @@ check_for_new_scan_int(double dcycs)
check_scan_line_int(dcycs, cur_video_line);
}
void
init_reg()
{
void init_reg() {
engine.acc = 0;
engine.xreg = 0;
engine.yreg = 0;
@ -2389,9 +2322,7 @@ init_reg()
}
void
handle_action(word32 ret)
{
void handle_action(word32 ret) {
int type;
type = EXTRU(ret,3,4);
@ -2441,22 +2372,16 @@ handle_action(word32 ret)
}
#if 0
void
do_add_dec_8(word32 ret)
{
void do_add_dec_8(word32 ret) {
halt_printf("do_add_dec_8 called, ret: %08x\n", ret);
}
void
do_add_dec_16(word32 ret)
{
void do_add_dec_16(word32 ret) {
halt_printf("do_add_dec_16 called, ret: %08x\n", ret);
}
#endif
void
do_break(word32 ret)
{
void do_break(word32 ret) {
if(!g_testing) {
printf("I think I got a break, second byte: %02x!\n", ret);
printf("kpc: %06x\n", engine.kpc);
@ -2466,17 +2391,13 @@ do_break(word32 ret)
enter_debug = 1;
}
void
do_cop(word32 ret)
{
void do_cop(word32 ret) {
halt_printf("COP instr %02x!\n", ret);
fflush(stdout);
}
#if 0
void
do_mvn(word32 banks)
{
void do_mvn(word32 banks) {
int src_bank, dest_bank;
int dest, src;
int num;
@ -2516,9 +2437,7 @@ do_mvn(word32 banks)
extern void host_fst(void);
void
do_wdm(word32 arg)
{
void do_wdm(word32 arg) {
switch(arg) {
case 0x8d: /* Bouncin Ferno does WDM 8d */
break;
@ -2532,15 +2451,11 @@ do_wdm(word32 arg)
}
}
void
do_wai()
{
void do_wai() {
halt_printf("do_wai!\n");
}
void
do_stp()
{
void do_stp() {
if(!g_stp_pending) {
g_stp_pending = 1;
halt_printf("Hit STP instruction at: %06x, press RESET to "
@ -2548,15 +2463,11 @@ do_stp()
}
}
void
size_fail(int val, word32 v1, word32 v2)
{
void size_fail(int val, word32 v1, word32 v2) {
halt_printf("Size failure, val: %08x, %08x %08x\n", val, v1, v2);
}
int
gsplus_vprintf(const char *fmt, va_list ap)
{
int gsplus_vprintf(const char *fmt, va_list ap) {
char *bufptr, *buf2ptr;
int len;
int ret;
@ -2583,9 +2494,7 @@ gsplus_vprintf(const char *fmt, va_list ap)
}
int
fatal_printf(const char *fmt, ...)
{
int fatal_printf(const char *fmt, ...) {
va_list ap;
int ret;
@ -2600,9 +2509,7 @@ fatal_printf(const char *fmt, ...)
return ret;
}
void
must_write(int fd, char *bufptr, int len)
{
void must_write(int fd, char *bufptr, int len) {
int ret;
while(len > 0) {
ret = write(fd, bufptr, len);
@ -2615,9 +2522,7 @@ must_write(int fd, char *bufptr, int len)
}
}
void
clear_fatal_logs()
{
void clear_fatal_logs() {
int i;
for(i = 0; i < g_fatal_log; i++) {
@ -2627,9 +2532,7 @@ clear_fatal_logs()
g_fatal_log = -1;
}
char *
gsplus_malloc_str(char *in_str)
{
char *gsplus_malloc_str(char *in_str) {
char *str;
int len;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "glog.h"
@ -35,9 +35,7 @@ STRUCT(Smpt_log) {
Smpt_log g_smpt_log[LEN_SMPT_LOG];
int g_smpt_log_pos = 0;
void
smartport_error(void)
{
void smartport_error(void) {
int pos;
int i;
@ -61,9 +59,7 @@ smartport_error(void)
g_smpt_log[pos].blk);
}
}
void
smartport_log(word32 start_addr, int cmd, int rts_addr, int cmd_list)
{
void smartport_log(word32 start_addr, int cmd, int rts_addr, int cmd_list) {
int pos;
pos = g_smpt_log_pos;
@ -93,9 +89,7 @@ smartport_log(word32 start_addr, int cmd, int rts_addr, int cmd_list)
g_smpt_log_pos = pos;
}
void
do_c70d(word32 arg0)
{
void do_c70d(word32 arg0) {
int cmd;
int cmd_list_lo, cmd_list_mid, cmd_list_hi;
int rts_lo, rts_hi;
@ -203,7 +197,7 @@ do_c70d(word32 arg0)
return;
} else if(unit > 0 && status_code == 0) {
/* status for unit x */
if(unit > MAX_C7_DISKS || (!iwm.smartport[unit-1].file)){
if(unit > MAX_C7_DISKS || (!iwm.smartport[unit-1].file)) {
stat_val = 0x80;
size = 0;
} else {
@ -227,7 +221,7 @@ do_c70d(word32 arg0)
disk_printf("just finished unit %d, stat 0\n", unit);
return;
} else if(status_code == 3) {
if(unit > MAX_C7_DISKS || (!iwm.smartport[unit-1].file)){
if(unit > MAX_C7_DISKS || (!iwm.smartport[unit-1].file)) {
stat_val = 0x80;
size = 0;
} else {
@ -442,9 +436,7 @@ do_c70d(word32 arg0)
cmd, cmd_list, rts_addr);
}
void
do_c70a(word32 arg0)
{
void do_c70a(word32 arg0) {
int cmd, unit;
int buf_lo, buf_hi;
int blk_lo, blk_hi;
@ -513,9 +505,7 @@ do_c70a(word32 arg0)
return;
}
int
do_read_c7(int unit_num, word32 buf, int blk)
{
int do_read_c7(int unit_num, word32 buf, int blk) {
byte local_buf[0x200];
register word32 start_time;
register word32 end_time;
@ -593,9 +583,7 @@ do_read_c7(int unit_num, word32 buf, int blk)
}
int
do_write_c7(int unit_num, word32 buf, int blk)
{
int do_write_c7(int unit_num, word32 buf, int blk) {
word32 local_buf[0x200/4];
Disk *dsk;
word32 *ptr;
@ -674,9 +662,7 @@ do_write_c7(int unit_num, word32 buf, int blk)
}
int
do_format_c7(int unit_num)
{
int do_format_c7(int unit_num) {
byte local_buf[0x1000];
Disk *dsk;
FILE *file;
@ -749,9 +735,7 @@ extern byte* g_bram_ptr;
extern byte g_temp_boot_slot;
extern byte g_orig_boot_slot;
extern int g_config_gsplus_update_needed;
void
do_c700(word32 ret)
{
void do_c700(word32 ret) {
disk_printf("do_c700 called, ret: %08x\n", ret);
if (g_temp_boot_slot != 254) {
// Booting from slot 7 - now is a good time to turn off the temp boot slot, if it was on.

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "sound.h"
@ -106,9 +106,7 @@ int g_doc_log_pos = 0;
#define SND_PTR_SHIFT 14
#define SND_PTR_SHIFT_DBL ((double)(1 << SND_PTR_SHIFT))
void
doc_log_rout(char *msg, int osc, double dsamps, int etc)
{
void doc_log_rout(char *msg, int osc, double dsamps, int etc) {
int pos;
pos = g_doc_log_pos;
@ -132,9 +130,7 @@ doc_log_rout(char *msg, int osc, double dsamps, int etc)
extern double g_cur_dcycs;
void
show_doc_log(void)
{
void show_doc_log(void) {
FILE *docfile;
Doc_reg *rptr;
double dsamp_start;
@ -189,9 +185,7 @@ show_doc_log(void)
fclose(docfile);
}
void
sound_init()
{
void sound_init() {
Doc_reg *rptr;
int i;
@ -247,9 +241,7 @@ sound_init()
}
void
sound_init_general()
{
void sound_init_general() {
/* Workaround - gcc in cygwin wasn't defining _WIN32 */
#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL)
@ -373,9 +365,7 @@ sound_init_general()
}
void
parent_sound_get_sample_rate(int read_fd)
{
void parent_sound_get_sample_rate(int read_fd) {
word32 tmp;
int ret;
@ -390,9 +380,7 @@ parent_sound_get_sample_rate(int read_fd)
set_audio_rate(tmp);
}
void
set_audio_rate(int rate)
{
void set_audio_rate(int rate) {
g_audio_rate = rate;
g_daudio_rate = (rate)*1.0;
g_drecip_audio_rate = 1.0/(rate);
@ -401,9 +389,7 @@ set_audio_rate(int rate)
g_fsamps_per_dcyc = (float)((rate*1.0) / DCYCS_1_MHZ);
}
void
sound_reset(double dcycs)
{
void sound_reset(double dcycs) {
double dsamps;
int i;
@ -429,9 +415,7 @@ sound_reset(double dcycs)
*/
}
void
sound_shutdown()
{
void sound_shutdown() {
// OG stop sound and free memory on sound_shutdown
sound_reset(g_cur_dcycs);
@ -458,9 +442,7 @@ sound_shutdown()
void
sound_update(double dcycs)
{
void sound_update(double dcycs) {
double dsamps;
/* Called every VBL time to update sound status */
@ -504,9 +486,7 @@ FILE *g_sound_file_fd = 0;
int g_send_sound_to_file = 0;
int g_send_file_bytes = 0;
void
open_sound_file()
{
void open_sound_file() {
char name[256];
FILE *fd;
@ -523,9 +503,7 @@ open_sound_file()
g_send_file_bytes = 0;
}
void
close_sound_file()
{
void close_sound_file() {
if(g_sound_file_fd != 0) {
fclose(g_sound_file_fd);
}
@ -533,9 +511,7 @@ close_sound_file()
g_sound_file_fd = 0;
}
void
check_for_range(word32 *addr, int num_samps, int offset)
{
void check_for_range(word32 *addr, int num_samps, int offset) {
short *shortptr;
int i;
int left;
@ -567,9 +543,7 @@ check_for_range(word32 *addr, int num_samps, int offset)
printf("check4 max: %d over %d\n", max, num_samps);
}
void
send_sound_to_file(word32 *addr, int shm_pos, int num_samps)
{
void send_sound_to_file(word32 *addr, int shm_pos, int num_samps) {
int size;
int ret;
@ -615,9 +589,7 @@ send_sound_to_file(word32 *addr, int shm_pos, int num_samps)
// is called with real_samps = 1 to output sound
void
send_sound(int real_samps, int size)
{
void send_sound(int real_samps, int size) {
// real_samps = 1, size = 1602
word32 tmp;
@ -651,13 +623,11 @@ send_sound(int real_samps, int size)
#endif
}
void show_c030_state()
{
void show_c030_state() {
show_c030_samps(&(g_samp_buf[0]), 100);
}
void show_c030_samps(int *outptr, int num)
{
void show_c030_samps(int *outptr, int num) {
int i;
printf("c030_fsamps[]: %d\n", g_num_c030_fsamps);
@ -674,8 +644,7 @@ void show_c030_samps(int *outptr, int num)
}
}
void sound_play(double dsamps)
{
void sound_play(double dsamps) {
register word32 start_time1, start_time2, start_time3, start_time4;
register word32 end_time1, end_time2, end_time3;
Doc_reg *rptr;
@ -779,8 +748,8 @@ void sound_play(double dsamps)
c030_hi_val = ((VAL_C030_BASE + VAL_C030_RANGE)*g_doc_vol) >> 4;
c030_lo_val = (VAL_C030_BASE * g_doc_vol) >> 4;
fc030_range = (float)(((VAL_C030_RANGE) * g_doc_vol) >> 4);
fc030_base = (float)(((VAL_C030_BASE) * g_doc_vol) >> 4);
fc030_range = (float)(((VAL_C030_RANGE) *g_doc_vol) >> 4);
fc030_base = (float)(((VAL_C030_BASE) *g_doc_vol) >> 4);
val = c030_lo_val;
if(c030_state) {
@ -1138,9 +1107,7 @@ void sound_play(double dsamps)
}
void
doc_handle_event(int osc, double dcycs)
{
void doc_handle_event(int osc, double dcycs) {
double dsamps;
/* handle osc stopping and maybe interrupting */
@ -1157,9 +1124,7 @@ doc_handle_event(int osc, double dcycs)
}
void
doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps)
{
void doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps) {
Doc_reg *rptr, *orptr;
int mode, omode;
int other_osc;
@ -1236,9 +1201,7 @@ doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps)
return;
}
void
add_sound_irq(int osc)
{
void add_sound_irq(int osc) {
int num_osc_interrupting;
if(g_doc_regs[osc].has_irq_pending) {
@ -1258,9 +1221,7 @@ add_sound_irq(int osc)
DOC_LOG("add_irq", osc, g_cur_dcycs * g_dsamps_per_dcyc, 0);
}
void
remove_sound_irq(int osc, int must)
{
void remove_sound_irq(int osc, int must) {
Doc_reg *rptr;
int num_osc_interrupt;
int has_irq_pending;
@ -1328,9 +1289,7 @@ remove_sound_irq(int osc, int must)
}
}
void
start_sound(int osc, double eff_dsamps, double dsamps)
{
void start_sound(int osc, double eff_dsamps, double dsamps) {
register word32 start_time1;
register word32 end_time1;
Doc_reg *rptr;
@ -1408,9 +1367,7 @@ start_sound(int osc, double eff_dsamps, double dsamps)
g_cycs_in_start_sound += (end_time1 - start_time1);
}
void
wave_end_estimate(int osc, double eff_dsamps, double dsamps)
{
void wave_end_estimate(int osc, double eff_dsamps, double dsamps) {
register word32 start_time1;
register word32 end_time1;
Doc_reg *rptr;
@ -1490,9 +1447,7 @@ wave_end_estimate(int osc, double eff_dsamps, double dsamps)
}
void
remove_sound_event(int osc)
{
void remove_sound_event(int osc) {
if(g_doc_regs[osc].event) {
g_doc_regs[osc].event = 0;
remove_event_doc(osc);
@ -1500,9 +1455,7 @@ remove_sound_event(int osc)
}
void
doc_write_ctl_reg(int osc, int val, double dsamps)
{
void doc_write_ctl_reg(int osc, int val, double dsamps) {
Doc_reg *rptr;
double eff_dsamps;
word32 old_halt;
@ -1601,9 +1554,7 @@ doc_write_ctl_reg(int osc, int val, double dsamps)
}
}
void
doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps)
{
void doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps) {
Doc_reg *rptr;
double dfreq;
double dtmp1;
@ -1645,9 +1596,7 @@ doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps)
DOC_LOG("recalc", osc, dsamps, (rptr->waveptr << 16) + wave_size);
}
int
doc_read_c030(double dcycs)
{
int doc_read_c030(double dcycs) {
int num;
num = g_num_c030_fsamps;
@ -1665,15 +1614,11 @@ doc_read_c030(double dcycs)
return 0;
}
int
doc_read_c03c(double dcycs)
{
int doc_read_c03c(double dcycs) {
return doc_sound_ctl;
}
int
doc_read_c03d(double dcycs)
{
int doc_read_c03d(double dcycs) {
double dsamps;
Doc_reg *rptr;
int osc;
@ -1766,9 +1711,7 @@ doc_read_c03d(double dcycs)
return ret;
}
void
doc_write_c03c(int val, double dcycs)
{
void doc_write_c03c(int val, double dcycs) {
int vol;
vol = val & 0xf;
@ -1785,9 +1728,7 @@ doc_write_c03c(int val, double dcycs)
doc_sound_ctl = val;
}
void
doc_write_c03d(int val, double dcycs)
{
void doc_write_c03d(int val, double dcycs) {
double dsamps;
double eff_dsamps;
Doc_reg *rptr;
@ -1966,9 +1907,7 @@ doc_write_c03d(int val, double dcycs)
doc_saved_val = val;
}
void
doc_show_ensoniq_state(int osc)
{
void doc_show_ensoniq_state(int osc) {
Doc_reg *rptr;
int i;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "sound.h"
@ -59,9 +59,7 @@ void child_sound_init_mac();
void child_sound_init_sdl();
long sound_init_device_sdl();
void
reliable_buf_write(word32 *shm_addr, int pos, int size)
{
void reliable_buf_write(word32 *shm_addr, int pos, int size) {
byte *ptr;
int ret = 0;
@ -98,9 +96,7 @@ reliable_buf_write(word32 *shm_addr, int pos, int size)
}
void
reliable_zero_write(int amt)
{
void reliable_zero_write(int amt) {
int len;
while(amt > 0) {
@ -111,9 +107,7 @@ reliable_zero_write(int amt)
}
void
child_sound_loop(int read_fd, int write_fd, word32 *shm_addr)
{
void child_sound_loop(int read_fd, int write_fd, word32 *shm_addr) {
word32 tmp;
int ret;
@ -177,9 +171,7 @@ child_sound_loop(int read_fd, int write_fd, word32 *shm_addr)
}
// called by sound.c:send_sound()
void
child_sound_playit(word32 tmp)
{
void child_sound_playit(word32 tmp) {
int size;
size = tmp & 0xffffff;
@ -252,9 +244,7 @@ child_sound_playit(word32 tmp)
#ifdef HPUX
void
child_sound_init_hpdev()
{
void child_sound_init_hpdev() {
struct audio_describe audio_descr;
int output_channel;
char *str;
@ -345,9 +335,7 @@ child_sound_init_hpdev()
#endif /* HPUX */
#if defined(__linux__) || defined(OSS)
void
child_sound_init_linux()
{
void child_sound_init_linux() {
int stereo;
int sample_size;
int rate;

View File

@ -26,8 +26,6 @@
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@ -63,7 +61,7 @@
/*
This variable is used when we need to postpone the initialization
because tfe_init() is not yet called
*/
*/
static int should_activate = 0;
static int init_tfe_flag = 0;
typedef signed int log_t;
@ -75,7 +73,7 @@ static log_t tfe_log = LOG_ERR;
/* status which received packages to accept
This is used in tfe_should_accept().
*/
*/
static byte tfe_ia_mac[6] = { 0,0,0,0,0,0 };
/* remember the value of the hash mask */
@ -107,7 +105,7 @@ static char *tfe_interface = NULL;
REMARK: The TFE operatoes the cs8900a in IO space configuration, as
it generates I/OW and I/OR signals.
*/
*/
#define TFE_COUNT_IO_REGISTER 0x10 /* we have 16 I/O register */
static byte *tfe = NULL;
@ -120,7 +118,7 @@ static byte *tfe = NULL;
RW: PP_PTR = DE0A/DE0B (PacketPage Pointer) (see. page 75p: Read -011.---- ----.----)
RW: PP_DATA0 = DE0C/DE0D (PacketPage Data (Port 0))
RW: PP_DATA1 = DE0E/DE0F (PacketPage Data (Port 1)) (for 32 bit only)
*/
*/
#define TFE_ADDR_RXTXDATA 0x00 /* RW */
#define TFE_ADDR_RXTXDATA2 0x02 /* RW 32 bit only! */
@ -316,8 +314,7 @@ static int rxevent_read_mask = 3; /* set if L and/or H byte was read in RXEVENT?
static int TfeDebugMaxFrameLengthToDump = 150;
static char *debug_outbuffer(const int length, const unsigned char * const buffer)
{
static char *debug_outbuffer(const int length, const unsigned char * const buffer) {
#define MAXLEN_DEBUG 1600
int i;
@ -332,7 +329,7 @@ static char *debug_outbuffer(const int length, const unsigned char * const buffe
if (i>=length)
break;
sprintf( p, "%02X%c", buffer[i], ((i+1)%16==0)?'*':(((i+1)%8==0)?'-':' '));
sprintf( p, "%02X%c", buffer[i], ((i+1)%16==0) ? '*' : (((i+1)%8==0) ? '-' : ' '));
p+=3;
}
@ -344,8 +341,7 @@ static char *debug_outbuffer(const int length, const unsigned char * const buffe
/* ------------------------------------------------------------------------- */
/* initialization and deinitialization functions */
static void tfe_set_tx_status(int ready,int error)
{
static void tfe_set_tx_status(int ready,int error) {
word16 old_status = GET_PP_16(TFE_PP_ADDR_SE_BUSST);
/* mask out TxBidErr and Rdy4TxNOW */
@ -364,24 +360,21 @@ static void tfe_set_tx_status(int ready,int error)
}
}
static void tfe_set_receiver(int enabled)
{
static void tfe_set_receiver(int enabled) {
rx_enabled = enabled;
rx_state = TFE_RX_IDLE;
rxevent_read_mask = 3; /* was L or H byte read in RXEVENT? */
}
static void tfe_set_transmitter(int enabled)
{
static void tfe_set_transmitter(int enabled) {
tx_enabled = enabled;
tx_state = TFE_TX_IDLE;
tfe_set_tx_status(0,0);
}
void tfe_reset(void)
{
void tfe_reset(void) {
if (tfe_enabled && !should_activate)
{
int i;
@ -446,7 +439,7 @@ void tfe_reset(void)
/* spec: mac address is undefined after reset.
real HW: keeps the last set address. */
for(i=0;i<6;i++)
for(i=0; i<6; i++)
SET_PP_8(TFE_PP_ADDR_MAC_ADDR+i,tfe_ia_mac[i]);
/* reset state */
@ -460,8 +453,7 @@ void tfe_reset(void)
}
#ifdef DOS_TFE
static void set_standard_tfe_interface(void)
{
static void set_standard_tfe_interface(void) {
char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf);
util_string_set(&tfe_interface, dev);
@ -469,8 +461,7 @@ static void set_standard_tfe_interface(void)
#endif
static
int tfe_activate_i(void)
{
int tfe_activate_i(void) {
assert( tfe == NULL );
assert( tfe_packetpage == NULL );
@ -528,8 +519,7 @@ int tfe_activate_i(void)
}
static
int tfe_deactivate_i(void)
{
int tfe_deactivate_i(void) {
#ifdef TFE_DEBUG
log_message( tfe_log, "tfe_deactivate_i()." );
#endif
@ -576,8 +566,7 @@ int tfe_deactivate(void) {
return 0;
}
void tfe_init(void)
{
void tfe_init(void) {
tfe_enabled = 1;
init_tfe_flag = 1;
should_activate = 1;
@ -595,8 +584,7 @@ void tfe_init(void)
}
}
void tfe_shutdown(void)
{
void tfe_shutdown(void) {
assert( (tfe && tfe_packetpage) || (!tfe && !tfe_packetpage));
if (tfe)
@ -611,19 +599,19 @@ void tfe_shutdown(void)
/* reading and writing TFE register functions */
/*
These registers are currently fully or partially supported:
These registers are currently fully or partially supported:
TFE_PP_ADDR_CC_RXCFG 0x0102 * # RW - 4.4.6., p. 52 - 0003 *
TFE_PP_ADDR_CC_RXCTL 0x0104 * # RW - 4.4.8., p. 54 - 0005 *
TFE_PP_ADDR_CC_LINECTL 0x0112 * # RW - 4.4.16., p. 62 - 0013 *
TFE_PP_ADDR_SE_RXEVENT 0x0124 * # R- - 4.4.7., p. 53 - 0004 *
TFE_PP_ADDR_SE_BUSST 0x0138 * # R- - 4.4.21., p. 67 - 0018 *
TFE_PP_ADDR_TXCMD 0x0144 * # -W - 4.5., p. 70 - 5.7., p. 98 *
TFE_PP_ADDR_TXLENGTH 0x0146 * # -W - 4.5., p. 70 - 5.7., p. 98 *
TFE_PP_ADDR_MAC_ADDR 0x0158 * # RW - 4.6., p. 71 - 5.3., p. 86 *
TFE_PP_ADDR_CC_RXCFG 0x0102 * # RW - 4.4.6., p. 52 - 0003 *
TFE_PP_ADDR_CC_RXCTL 0x0104 * # RW - 4.4.8., p. 54 - 0005 *
TFE_PP_ADDR_CC_LINECTL 0x0112 * # RW - 4.4.16., p. 62 - 0013 *
TFE_PP_ADDR_SE_RXEVENT 0x0124 * # R- - 4.4.7., p. 53 - 0004 *
TFE_PP_ADDR_SE_BUSST 0x0138 * # R- - 4.4.21., p. 67 - 0018 *
TFE_PP_ADDR_TXCMD 0x0144 * # -W - 4.5., p. 70 - 5.7., p. 98 *
TFE_PP_ADDR_TXLENGTH 0x0146 * # -W - 4.5., p. 70 - 5.7., p. 98 *
TFE_PP_ADDR_MAC_ADDR 0x0158 * # RW - 4.6., p. 71 - 5.3., p. 86 *
0x015a
0x015c
*/
*/
#ifdef TFE_DEBUG_FRAMES
@ -631,7 +619,7 @@ TFE_PP_ADDR_MAC_ADDR 0x0158 * # RW - 4.6., p. 71 - 5.3., p. 86 *
{ \
int retval = _x_; \
\
log_message(tfe_log, "%s correct_mac=%u, broadcast=%u, multicast=%u, hashed=%u, hash_index=%u", (retval? "+++ ACCEPTED":"--- rejected"), *pcorrect_mac, *pbroadcast, *pmulticast, *phashed, *phash_index); \
log_message(tfe_log, "%s correct_mac=%u, broadcast=%u, multicast=%u, hashed=%u, hash_index=%u", (retval ? "+++ ACCEPTED" : "--- rejected"), *pcorrect_mac, *pbroadcast, *pmulticast, *phashed, *phash_index); \
\
return retval; \
}
@ -643,10 +631,9 @@ TFE_PP_ADDR_MAC_ADDR 0x0158 * # RW - 4.6., p. 71 - 5.3., p. 86 *
This function is even allowed to be called in tfearch.c from tfe_arch_receive() if
necessary, which is the reason why its prototype is included here in tfearch.h.
*/
*/
int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index,
int *pcorrect_mac, int *pbroadcast, int *pmulticast)
{
int *pcorrect_mac, int *pbroadcast, int *pmulticast) {
int hashreg; /* Hash Register (for hash computation) */
assert(length>=6); /* we need at least 6 octets since the DA has this length */
@ -703,7 +690,7 @@ int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phas
/* now check if DA passes the hash filter */
hashreg = (~crc32_buf((char *)buffer,6) >> 26) & 0x3F;
*phashed = (tfe_hash_mask[(hashreg>=32)?1:0] & (1 << (hashreg&0x1F))) ? 1 : 0;
*phashed = (tfe_hash_mask[(hashreg>=32) ? 1 : 0] & (1 << (hashreg&0x1F))) ? 1 : 0;
if (*phashed) {
*phash_index = hashreg;
@ -729,8 +716,7 @@ int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phas
#endif
static
word16 tfe_receive(void)
{
word16 tfe_receive(void) {
word16 ret_val = 0x0004;
byte buffer[MAX_RXLENGTH];
@ -751,7 +737,7 @@ word16 tfe_receive(void)
do {
len = MAX_RXLENGTH;
ready = 1 ; /* assume we will find a good frame */
ready = 1; /* assume we will find a good frame */
newframe = tfe_arch_receive(
buffer, /* where to store a frame */
@ -820,7 +806,7 @@ word16 tfe_receive(void)
/* set relevant parts of the PP area to correct values */
SET_PP_16(TFE_PP_ADDR_RXLENGTH, len);
for (i=0;i<len; i++) {
for (i=0; i<len; i++) {
SET_PP_8(TFE_PP_ADDR_RX_FRAMELOC+i, buffer[i]);
}
@ -855,8 +841,7 @@ word16 tfe_receive(void)
/* ------------------------------------------------------------------------- */
/* TX/RX buffer handling */
static void tfe_write_tx_buffer(byte value,int odd_address)
{
static void tfe_write_tx_buffer(byte value,int odd_address) {
/* write tx data only if valid buffer is ready */
if(tx_state != TFE_TX_READ_BUSST) {
#ifdef TFE_DEBUG_WARN_RXTX
@ -925,8 +910,7 @@ static void tfe_write_tx_buffer(byte value,int odd_address)
}
}
static byte tfe_read_rx_buffer(int odd_address)
{
static byte tfe_read_rx_buffer(int odd_address) {
if(rx_state != TFE_RX_GOT_FRAME) {
#ifdef TFE_DEBUG_WARN_RXTX
log_message(tfe_log, "WARNING! RX Read without frame available! (odd=%d)",
@ -948,7 +932,7 @@ static byte tfe_read_rx_buffer(int odd_address)
TFE_PP_ADDR_RX_FRAMELOC+4: proceed -
*/
word16 addr = odd_address ? 1:0;
word16 addr = odd_address ? 1 : 0;
byte value;
/* read RXSTATUS or RX_LENGTH */
if(rx_count<4) {
@ -993,10 +977,9 @@ static byte tfe_read_rx_buffer(int odd_address)
/*
This is called *after* the relevant octets are written
*/
*/
static
void tfe_sideeffects_write_pp(word16 ppaddress, int odd_address)
{
void tfe_sideeffects_write_pp(word16 ppaddress, int odd_address) {
// const char *on_off[2] = { "on","off" };
//#define on_off_str(x) ((x) ? on_off[0] : on_off[1])
word16 content = GET_PP_16( ppaddress );
@ -1195,10 +1178,9 @@ void tfe_sideeffects_write_pp(word16 ppaddress, int odd_address)
/*
This is called *before* the relevant octets are read
*/
*/
static
void tfe_sideeffects_read_pp(word16 ppaddress,int odd_address)
{
void tfe_sideeffects_read_pp(word16 ppaddress,int odd_address) {
switch (ppaddress)
{
case TFE_PP_ADDR_SE_RXEVENT:
@ -1266,8 +1248,7 @@ void tfe_sideeffects_read_pp(word16 ppaddress,int odd_address)
/* read/write from packet page register */
/* read a register from packet page */
static word16 tfe_read_register(word16 ppaddress)
{
static word16 tfe_read_register(word16 ppaddress) {
word16 value = GET_PP_16(ppaddress);
/* --- check the register address --- */
@ -1282,7 +1263,7 @@ static word16 tfe_read_register(word16 ppaddress)
else if(ppaddress<0x120) {
word16 regNum = ppaddress - 0x100;
regNum &= ~1;
regNum ++;
regNum++;
#ifdef TFE_DEBUG_REGISTERS
log_message(tfe_log,
"Read Control Register %04x: %04x (reg=%02x)",
@ -1413,8 +1394,7 @@ static word16 tfe_read_register(word16 ppaddress)
return value;
}
void tfe_write_register(word16 ppaddress,word16 value)
{
void tfe_write_register(word16 ppaddress,word16 value) {
/* --- write bus interface register range --- */
if(ppaddress<0x100) {
int ignore = 0;
@ -1536,7 +1516,7 @@ void tfe_write_register(word16 ppaddress,word16 value)
#endif
return;
}
else if(ppaddress<0xa00){
else if(ppaddress<0xa00) {
#ifdef TFE_DEBUG_WARN_REG
log_message(tfe_log,
"WARNING! Ignoring write to RX Buffer Range %04x",
@ -1561,8 +1541,7 @@ void tfe_write_register(word16 ppaddress,word16 value)
#define PP_PTR_FLAG_MASK 0xf000 /* is always : x y 1 1 (with x=auto incr) */
#define PP_PTR_ADDR_MASK 0x0fff /* address portion of packet page pointer */
static void tfe_auto_incr_pp_ptr(void)
{
static void tfe_auto_incr_pp_ptr(void) {
/* perform auto increment of packet page pointer */
if((tfe_packetpage_ptr & PP_PTR_AUTO_INCR_FLAG)==PP_PTR_AUTO_INCR_FLAG) {
/* pointer is always increment by one on real HW */
@ -1581,8 +1560,7 @@ static void tfe_auto_incr_pp_ptr(void)
#define LOHI_WORD(x,y) ( (word16)(x) | ( ((word16)(y)) <<8 ) )
/* ----- read byte from I/O range in VICE ----- */
byte tfe_read(word16 io_address)
{
byte tfe_read(word16 io_address) {
byte retval,lo,hi;
word16 word_value;
word16 reg_base;
@ -1677,8 +1655,7 @@ byte tfe_read(word16 io_address)
}
/* ----- write byte to I/O range of VICE ----- */
void tfe_store(word16 io_address, byte var)
{
void tfe_store(word16 io_address, byte var) {
word16 reg_base;
word16 word_value;
assert( tfe );
@ -1786,14 +1763,13 @@ void tfe_store(word16 io_address, byte var)
/* ------------------------------------------------------------------------- */
/* resources support functions */
#if 0
static int set_tfe_disabled(int val, void *param)
{
static int set_tfe_disabled(int val, void *param) {
/* dummy function since we don't want "disabled" to be stored on disk */
return 0;
}
/*static int set_tfe_rr_net(int val, void *param)
{
{
if (!tfe_cannot_use) {
if (!val) {
// TFE should not be used as rr net
@ -1820,10 +1796,9 @@ static int set_tfe_disabled(int val, void *param)
}
return 0;
}*/
}*/
static int set_tfe_enabled(int val, void *param)
{
static int set_tfe_enabled(int val, void *param) {
if (!tfe_cannot_use) {
if (!val) {
/* TFE should be deactived */
@ -1850,8 +1825,7 @@ static int set_tfe_enabled(int val, void *param)
}
#endif /* 0 */
int set_tfe_interface(const char *name)
{
int set_tfe_interface(const char *name) {
if (tfe_interface != NULL && name != NULL
&& strcmp(name, tfe_interface) == 0)
return 0;
@ -1883,9 +1857,9 @@ int set_tfe_interface(const char *name)
ARCHDEP_ETHERNET_DEFAULT_DEVICE, RES_EVENT_NO, NULL,
&tfe_interface, set_tfe_interface, NULL },
{ NULL }
};
};
static const resource_int_t resources_int[] = {
static const resource_int_t resources_int[] = {
{ "ETHERNET_DISABLED", 0, RES_EVENT_NO, NULL,
&tfe_cannot_use, set_tfe_disabled, NULL },
{ "ETHERNET_ACTIVE", 0, RES_EVENT_STRICT, (resource_value_t)0,
@ -1893,21 +1867,21 @@ static const resource_int_t resources_int[] = {
{ "ETHERNET_AS_RR", 0, RES_EVENT_NO, NULL,
&tfe_as_rr_net, set_tfe_rr_net, NULL },
{ NULL }
};*/
};*/
/*int tfe_resources_init(void)
{
{
if (resources_register_string(resources_string) < 0)
return -1;
return resources_register_int(resources_int);
}*/
}*/
/* ------------------------------------------------------------------------- */
/* commandline support functions */
/*static const cmdline_option_t cmdline_options[] =
{
{
{ "-tfe", SET_RESOURCE, 0,
NULL, NULL, "ETHERNET_ACTIVE", (resource_value_t)1,
USE_PARAM_STRING, USE_DESCRIPTION_ID,
@ -1934,12 +1908,12 @@ static const resource_int_t resources_int[] = {
IDCLS_UNUSED, IDCLS_DISABLE_TFE_AS_RRNET,
NULL, NULL },
{ NULL }
};
};
int tfe_cmdline_options_init(void)
{
int tfe_cmdline_options_init(void)
{
return cmdline_register_options(cmdline_options);
}*/
}*/
/* ------------------------------------------------------------------------- */
@ -1951,14 +1925,12 @@ static char snap_module_name[] = "TFE1764";
#define SNAP_MAJOR 0
#define SNAP_MINOR 0
int tfe_read_snapshot_module(struct snapshot_s *s)
{
int tfe_read_snapshot_module(struct snapshot_s *s) {
/* @SRT TODO: not yet implemented */
return -1;
}
int tfe_write_snapshot_module(struct snapshot_s *s)
{
int tfe_write_snapshot_module(struct snapshot_s *s) {
/* @SRT TODO: not yet implemented */
return -1;
}
@ -1968,8 +1940,7 @@ int tfe_write_snapshot_module(struct snapshot_s *s)
/* ------------------------------------------------------------------------- */
/* functions for selecting and querying available NICs */
int tfe_enumadapter_open(void)
{
int tfe_enumadapter_open(void) {
if (!tfe_arch_enumadapter_open()) {
tfe_cannot_use = 1;
return 0;
@ -1977,13 +1948,11 @@ int tfe_enumadapter_open(void)
return 1;
}
int tfe_enumadapter(char **ppname, char **ppdescription)
{
int tfe_enumadapter(char **ppname, char **ppdescription) {
return tfe_arch_enumadapter(ppname, ppdescription);
}
int tfe_enumadapter_close(void)
{
int tfe_enumadapter_close(void) {
return tfe_arch_enumadapter_close();
}

View File

@ -60,8 +60,7 @@ static char TfePcapErrbuf[PCAP_ERRBUF_SIZE];
#ifdef TFE_DEBUG_PKTDUMP
static
void debug_output( const char *text, unsigned char *what, int count )
{
void debug_output( const char *text, unsigned char *what, int count ) {
char buffer[256];
char *p = buffer;
char *pbuffer1 = what;
@ -101,10 +100,9 @@ void debug_output( const char *text, unsigned char *what, int count )
Each function returns 1 on success, and 0 on failure.
TfeEnumAdapter() only fails if there is no more adpater; in this case,
*ppname and *ppdescription are not altered.
*/
int tfe_arch_enumadapter_open(void)
{
* ppname and *ppdescription are not altered.
*/
int tfe_arch_enumadapter_open(void) {
if (pcapdelay_findalldevs(&TfePcapAlldevs, TfePcapErrbuf) == -1)
{
#ifdef TFE_DEBUG_ARCH
@ -126,8 +124,7 @@ int tfe_arch_enumadapter_open(void)
return 1;
}
int tfe_arch_enumadapter(char **ppname, char **ppdescription)
{
int tfe_arch_enumadapter(char **ppname, char **ppdescription) {
if (!TfePcapNextDev || (TfePcapNextDev->name == NULL))
return 0;
@ -141,8 +138,7 @@ int tfe_arch_enumadapter(char **ppname, char **ppdescription)
return 1;
}
int tfe_arch_enumadapter_close(void)
{
int tfe_arch_enumadapter_close(void) {
if (TfePcapAlldevs) {
pcapdelay_freealldevs(TfePcapAlldevs);
TfePcapAlldevs = NULL;
@ -151,8 +147,7 @@ int tfe_arch_enumadapter_close(void)
}
static
int TfePcapOpenAdapter(const char *interface_name)
{
int TfePcapOpenAdapter(const char *interface_name) {
pcap_if_t *TfePcapDevice = NULL;
if (!tfe_enumadapter_open()) {
@ -221,29 +216,25 @@ int TfePcapOpenAdapter(const char *interface_name)
/* the architecture-dependend functions */
int tfe_arch_init(void)
{
int tfe_arch_init(void) {
//tfe_arch_log = log_open("TFEARCH");
return 1;
}
void tfe_arch_pre_reset( void )
{
void tfe_arch_pre_reset( void ) {
#ifdef TFE_DEBUG_ARCH
log_message( tfe_arch_log, "tfe_arch_pre_reset()." );
#endif
}
void tfe_arch_post_reset( void )
{
void tfe_arch_post_reset( void ) {
#ifdef TFE_DEBUG_ARCH
log_message( tfe_arch_log, "tfe_arch_post_reset()." );
#endif
}
int tfe_arch_activate(const char *interface_name)
{
int tfe_arch_activate(const char *interface_name) {
#ifdef TFE_DEBUG_ARCH
log_message( tfe_arch_log, "tfe_arch_activate()." );
#endif
@ -253,15 +244,13 @@ int tfe_arch_activate(const char *interface_name)
return 1;
}
void tfe_arch_deactivate( void )
{
void tfe_arch_deactivate( void ) {
#ifdef TFE_DEBUG_ARCH
log_message( tfe_arch_log, "tfe_arch_deactivate()." );
#endif
}
void tfe_arch_set_mac( const unsigned char mac[6] )
{
void tfe_arch_set_mac( const unsigned char mac[6] ) {
#if defined(TFE_DEBUG_ARCH) || defined(TFE_DEBUG_FRAMES)
log_message( tfe_arch_log, "New MAC address set: %02X:%02X:%02X:%02X:%02X:%02X.",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
@ -275,8 +264,7 @@ void tfe_arch_recv_ctl( int bBroadcast, /* broadcast */
int bCorrect, /* accept correct frames */
int bPromiscuous, /* promiscuous mode */
int bIAHash /* accept if IA passes the hash filter */
)
{
) {
#if defined(TFE_DEBUG_ARCH) || defined(TFE_DEBUG_FRAMES)
log_message( tfe_arch_log, "tfe_arch_recv_ctl() called with the following parameters:" );
log_message( tfe_arch_log, "\tbBroadcast = %s", bBroadcast ? "TRUE" : "FALSE" );
@ -288,8 +276,7 @@ void tfe_arch_recv_ctl( int bBroadcast, /* broadcast */
#endif
}
void tfe_arch_line_ctl(int bEnableTransmitter, int bEnableReceiver )
{
void tfe_arch_line_ctl(int bEnableTransmitter, int bEnableReceiver ) {
#if defined(TFE_DEBUG_ARCH) || defined(TFE_DEBUG_FRAMES)
log_message( tfe_arch_log, "tfe_arch_line_ctl() called with the following parameters:" );
log_message( tfe_arch_log, "\tbEnableTransmitter = %s", bEnableTransmitter ? "TRUE" : "FALSE" );
@ -307,8 +294,7 @@ typedef struct TFE_PCAP_INTERNAL_tag {
/* Callback function invoked by libpcap for every incoming packet */
static
void TfePcapPacketHandler(unsigned char *param, const struct pcap_pkthdr *header, const unsigned char *pkt_data)
{
void TfePcapPacketHandler(unsigned char *param, const struct pcap_pkthdr *header, const unsigned char *pkt_data) {
TFE_PCAP_INTERNAL *pinternal = (TFE_PCAP_INTERNAL*)param;
/* determine the count of bytes which has been returned,
@ -329,10 +315,9 @@ void TfePcapPacketHandler(unsigned char *param, const struct pcap_pkthdr *header
bytes as return value.
At most 'len' bytes are copied.
*/
*/
static
int tfe_arch_receive_frame(TFE_PCAP_INTERNAL *pinternal)
{
int tfe_arch_receive_frame(TFE_PCAP_INTERNAL *pinternal) {
int ret = -1;
/* check if there is something to receive */
@ -354,8 +339,7 @@ void tfe_arch_transmit(int force, /* FORCE: Delete waiting frames in trans
int tx_pad_dis, /* TXPADDIS: Disable padding to 60 Bytes */
int txlength, /* Frame length */
unsigned char *txframe /* Pointer to the frame to be transmitted */
)
{
) {
#ifdef TFE_DEBUG_ARCH
log_message( tfe_arch_log, "tfe_arch_transmit() called, with: "
"force = %s, onecoll = %s, inhibit_crc=%s, tx_pad_dis=%s, txlength=%u",
@ -398,10 +382,10 @@ void tfe_arch_transmit(int force, /* FORCE: Delete waiting frames in trans
- if the dest. address was accepted because it's exactly our MAC address
(set by tfe_arch_set_mac()), *pcorrect_mac is set, else cleared.
- if the dest. address was accepted since it was a broadcast address,
*pbroadcast is set, else cleared.
* pbroadcast is set, else cleared.
- if the received frame had a crc error, *pcrc_error is set, else cleared
*/
int tfe_arch_receive(unsigned char *pbuffer , /* where to store a frame */
*/
int tfe_arch_receive(unsigned char *pbuffer, /* where to store a frame */
int *plen, /* IN: maximum length of frame to copy;
OUT: length of received frame
OUT can be bigger than IN if received frame was
@ -412,8 +396,7 @@ int tfe_arch_receive(unsigned char *pbuffer , /* where to store a frame */
int *pcorrect_mac, /* set if dest. address is exactly our IA */
int *pbroadcast, /* set if dest. address is a broadcast address */
int *pcrc_error /* set if received frame had a CRC error */
)
{
) {
int len;
TFE_PCAP_INTERNAL internal = { *plen, pbuffer };

View File

@ -61,8 +61,7 @@
static unsigned long crc32_table[256];
static int crc32_is_initialized = 0;
void lib_free(void *ptr)
{
void lib_free(void *ptr) {
#ifdef LIB_DEBUG
lib_debug_free(ptr, 1, 1);
#endif
@ -74,8 +73,7 @@ void lib_free(void *ptr)
#endif
}
void *lib_malloc(size_t size)
{
void *lib_malloc(size_t size) {
#ifdef LIB_DEBUG
void *ptr = lib_debug_libc_malloc(size);
#else
@ -95,8 +93,7 @@ void *lib_malloc(size_t size)
/* Malloc enough space for `str', copy `str' into it and return its
address. */
char *lib_stralloc(const char *str)
{
char *lib_stralloc(const char *str) {
size_t size;
char *ptr;
@ -113,8 +110,7 @@ char *lib_stralloc(const char *str)
/* Like realloc, but abort if not enough memory is available. */
void *lib_realloc(void *ptr, size_t size)
{
void *lib_realloc(void *ptr, size_t size) {
#ifdef LIB_DEBUG
void *new_ptr = lib_debug_libc_realloc(ptr, size);
#else
@ -135,8 +131,7 @@ void *lib_realloc(void *ptr, size_t size)
/* Set a new value to the dynamically allocated string *str.
Returns `-1' if nothing has to be done. */
int util_string_set(char **str, const char *new_value)
{
int util_string_set(char **str, const char *new_value) {
if (*str == NULL) {
if (new_value != NULL)
*str = lib_stralloc(new_value);
@ -159,8 +154,7 @@ int util_string_set(char **str, const char *new_value)
// crc32 Stuff
unsigned long crc32_buf(const char *buffer, unsigned int len)
{
unsigned long crc32_buf(const char *buffer, unsigned int len) {
int i, j;
unsigned long crc, c;
const char *p;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include <ctype.h>
@ -27,8 +27,7 @@ int g_crlf = 0;
void make_legal_prodos_name(char *new_name, char *old_name);
static int hex(byte c)
{
static int hex(byte c) {
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c + 10 - 'a';
if (c >= 'A' && c <= 'F') return c + 10 - 'A';
@ -97,9 +96,7 @@ void get_file_type(const char *name, int *file_type, int *aux_type) {
*aux_type = g_def_aux_type;
}
int
main(int argc, char **argv)
{
int main(int argc, char **argv) {
char *files[MAX_FILE_NAMES];
char *name;
struct stat stat_buf;
@ -239,9 +236,7 @@ main(int argc, char **argv)
return 0;
}
void
make_legal_prodos_name(char *new_name, char *old_name)
{
void make_legal_prodos_name(char *new_name, char *old_name) {
char *ptr;
int start_len, start_char;
int len;
@ -298,27 +293,21 @@ make_legal_prodos_name(char *new_name, char *old_name)
printf("new_name: %s\n", new_name);
}
void
flush_disk(ProDisk *disk)
{
void flush_disk(ProDisk *disk) {
disk_write_data(disk, 6, disk->bitmap_ptr,
disk->size_bitmap_blocks * 512);
close(disk->fd);
disk->fd = -1;
}
void
close_file(ProDisk *disk)
{
void close_file(ProDisk *disk) {
write_ind_block(disk);
write_master_ind_block(disk);
disk_write_data(disk, disk->dir_blk_num, &(disk->dir_blk_data[0]), 512);
disk->file_ptr = 0;
}
ProDisk *
allocate_memdisk(char *out_name, int size)
{
ProDisk *allocate_memdisk(char *out_name, int size) {
ProDisk *disk;
int out;
@ -346,9 +335,7 @@ allocate_memdisk(char *out_name, int size)
return disk;
}
void
format_memdisk(ProDisk *disk, char *name)
{
void format_memdisk(ProDisk *disk, char *name) {
byte zero_buf[1024];
int total_blocks;
byte *bitmap_ptr;
@ -430,9 +417,7 @@ format_memdisk(ProDisk *disk, char *name)
disk->disk_bytes_left = disk_blocks_left * 512;
}
void
disk_write_data(ProDisk *disk, int blk_num, byte *buf, int size)
{
void disk_write_data(ProDisk *disk, int blk_num, byte *buf, int size) {
int size_in_blocks;
int ret;
@ -464,9 +449,7 @@ disk_write_data(ProDisk *disk, int blk_num, byte *buf, int size)
}
}
void
disk_read_data(ProDisk *disk, int blk_num, byte *buf, int size)
{
void disk_read_data(ProDisk *disk, int blk_num, byte *buf, int size) {
int size_in_blocks;
int ret;
int i;
@ -497,9 +480,7 @@ disk_read_data(ProDisk *disk, int blk_num, byte *buf, int size)
}
}
Directory *
disk_read_dir(ProDisk *disk, int blk_num)
{
Directory *disk_read_dir(ProDisk *disk, int blk_num) {
disk_write_dir(disk, blk_num);
disk->dir_blk_num = blk_num;
@ -508,9 +489,7 @@ disk_read_dir(ProDisk *disk, int blk_num)
return (Directory *)&(disk->dir_blk_data[0]);
}
void
disk_write_dir(ProDisk *disk, int blk_num)
{
void disk_write_dir(ProDisk *disk, int blk_num) {
if(disk->dir_blk_num >= 0) {
if(disk->dir_blk_num != blk_num) {
printf("disk_write_dir: %04x != %04x\n",
@ -522,11 +501,9 @@ disk_write_dir(ProDisk *disk, int blk_num)
}
}
void
create_new_file(ProDisk *disk, int dir_block, int storage_type, char *name,
void create_new_file(ProDisk *disk, int dir_block, int storage_type, char *name,
int file_type, word32 creation_time, int version, int min_version,
int access, int aux_type, word32 last_mod, word32 eof)
{
int access, int aux_type, word32 last_mod, word32 eof) {
Vol_hdr *vol_ptr;
int val;
Directory *dir_ptr;
@ -596,8 +573,8 @@ create_new_file(ProDisk *disk, int dir_block, int storage_type, char *name,
break;
} else {
/* check to make sure name is unique */
if((file_ptr->storage_type_name_len & 0x0f)== name_len){
if(!memcmp(file_ptr->file_name, name,name_len)){
if((file_ptr->storage_type_name_len & 0x0f)== name_len) {
if(!memcmp(file_ptr->file_name, name,name_len)) {
printf("Name %s already on disk!\n",
name);
exit(8);
@ -619,9 +596,7 @@ create_new_file(ProDisk *disk, int dir_block, int storage_type, char *name,
}
}
int
pro_write_file(ProDisk *disk, byte *in_buf, int pos, int size)
{
int pro_write_file(ProDisk *disk, byte *in_buf, int pos, int size) {
int block;
int i;
@ -646,9 +621,7 @@ pro_write_file(ProDisk *disk, byte *in_buf, int pos, int size)
int
get_disk_block(ProDisk *disk, int pos, int create)
{
int get_disk_block(ProDisk *disk, int pos, int create) {
File_entry *file_ptr;
int storage_type;
word32 eof;
@ -779,9 +752,7 @@ get_disk_block(ProDisk *disk, int pos, int create)
exit(5);
}
void
get_new_ind_block(ProDisk *disk)
{
void get_new_ind_block(ProDisk *disk) {
int ind_blk_num;
int i;
@ -795,9 +766,7 @@ get_new_ind_block(ProDisk *disk)
disk->ind_blk_num = ind_blk_num;
}
void
write_ind_block(ProDisk *disk)
{
void write_ind_block(ProDisk *disk) {
int ind_blk_num;
ind_blk_num = disk->ind_blk_num;
@ -809,9 +778,7 @@ write_ind_block(ProDisk *disk)
}
}
void
get_new_master_ind_block(ProDisk *disk)
{
void get_new_master_ind_block(ProDisk *disk) {
int master_ind_blk_num;
int i;
@ -825,9 +792,7 @@ get_new_master_ind_block(ProDisk *disk)
disk->master_ind_blk_num = master_ind_blk_num;
}
void
write_master_ind_block(ProDisk *disk)
{
void write_master_ind_block(ProDisk *disk) {
int master_ind_blk_num;
master_ind_blk_num = disk->master_ind_blk_num;
@ -839,9 +804,7 @@ write_master_ind_block(ProDisk *disk)
}
}
int
find_next_free_block(ProDisk *disk)
{
int find_next_free_block(ProDisk *disk) {
byte *bitmap_ptr;
int pos;
int bitmap_bytes;
@ -871,9 +834,7 @@ find_next_free_block(ProDisk *disk)
void
set_bitmap_used(byte *ptr, int i)
{
void set_bitmap_used(byte *ptr, int i) {
word32 offset, bit;
word32 val;
@ -884,9 +845,7 @@ set_bitmap_used(byte *ptr, int i)
ptr[offset] &= val;
}
void
set_bitmap_free(byte *ptr, int i)
{
void set_bitmap_free(byte *ptr, int i) {
int offset, bit;
int val;
@ -897,12 +856,10 @@ set_bitmap_free(byte *ptr, int i)
ptr[offset] |= val;
}
void
set_file_entry(File_entry *entry, int storage_type_name_len, char *file_name,
void set_file_entry(File_entry *entry, int storage_type_name_len, char *file_name,
int file_type, int key_pointer, int blocks_used, int eof,
word32 creation_time, int version, int min_version, int access,
int aux_type, word32 last_mod, int header_pointer)
{
int aux_type, word32 last_mod, int header_pointer) {
entry->storage_type_name_len = storage_type_name_len;
strncpy((char *)entry->file_name, file_name, 15);
@ -920,52 +877,40 @@ set_file_entry(File_entry *entry, int storage_type_name_len, char *file_name,
}
void
set_l2byte(L2byte *ptr, int val)
{
void set_l2byte(L2byte *ptr, int val) {
ptr->low = (val & 0xff);
ptr->hi = ((val >> 8) & 0xff);
}
void
set_l3byte(L3byte *ptr, int val)
{
void set_l3byte(L3byte *ptr, int val) {
ptr->low = (val & 0xff);
ptr->hi = ((val >> 8) & 0xff);
ptr->higher = ((val >> 16) & 0xff);
}
void
set_pro_time(Pro_time *ptr, word32 val)
{
void set_pro_time(Pro_time *ptr, word32 val) {
ptr->times[0] = ((val >> 24) & 0xff);
ptr->times[1] = ((val >> 16) & 0xff);
ptr->times[2] = ((val >> 8) & 0xff);
ptr->times[3] = ((val) & 0xff);
}
int
get_l2byte(L2byte *ptr)
{
int get_l2byte(L2byte *ptr) {
int val;
val = ((ptr->hi) * 256) + ptr->low;
return val;
}
int
get_l3byte(L3byte *ptr)
{
int get_l3byte(L3byte *ptr) {
int val;
val = ((ptr->higher) * 65536) + ((ptr->hi) * 256) + ptr->low;
return val;
}
void
inc_l2byte(L2byte *ptr)
{
void inc_l2byte(L2byte *ptr) {
set_l2byte(ptr, get_l2byte(ptr) + 1);
}

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include <time.h>
@ -319,16 +319,14 @@ const word32 g_hires_convert[64] = {
BIGEND(0x0f0f0f0f), /* 11,1111 = white ,white, white, white */
};
int g_screen_index[] = {
int g_screen_index[] = {
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380,
0x028, 0x0a8, 0x128, 0x1a8, 0x228, 0x2a8, 0x328, 0x3a8,
0x050, 0x0d0, 0x150, 0x1d0, 0x250, 0x2d0, 0x350, 0x3d0
};
void
video_init()
{
void video_init() {
word32 col[4];
Kimage *kimage_ptr;
word32 *ptr;
@ -403,7 +401,7 @@ video_init()
g_red_right_shift = 0;
g_green_right_shift = 0;
g_blue_right_shift = 0;
*/
*/
/* Initialize video system */
@ -539,9 +537,7 @@ video_init()
fflush(stdout);
}
void
show_a2_line_stuff()
{
void show_a2_line_stuff() {
int i;
for(i = 0; i < 200; i++) {
@ -563,9 +559,7 @@ show_a2_line_stuff()
int g_flash_count = 0;
void
video_reset()
{
void video_reset() {
int stat;
int i;
@ -596,10 +590,9 @@ int g_screen_redraw_skip_amt = -1;
word32 g_cycs_in_check_input = 0;
int g_needfullrefreshfornextframe = 1 ;
int g_needfullrefreshfornextframe = 1;
void video_update()
{
void video_update() {
int did_video;
// OG g_needfullrefreshfornextframe
@ -656,9 +649,7 @@ void video_update()
}
int
video_all_stat_to_line_stat(int line, int new_all_stat)
{
int video_all_stat_to_line_stat(int line, int new_all_stat) {
int page, color, dbl;
int st80, hires, annunc3, mix_t_gr;
int altchar, text_color, bg_color, flash_state;
@ -716,9 +707,7 @@ video_all_stat_to_line_stat(int line, int new_all_stat)
(color << 1) + dbl);
}
int *
video_update_kimage_ptr(int line, int new_stat)
{
int *video_update_kimage_ptr(int line, int new_stat) {
Kimage *kimage_ptr;
int *mode_ptr;
int page;
@ -762,9 +751,7 @@ video_update_kimage_ptr(int line, int new_stat)
return mode_ptr;
}
void
change_a2vid_palette(int new_palette)
{
void change_a2vid_palette(int new_palette) {
int i;
for(i = 0; i < 200; i++) {
@ -796,9 +783,7 @@ change_a2vid_palette(int new_palette)
int g_num_a2vid_palette_checks = 1;
int g_shr_palette_used[16];
void
check_a2vid_palette()
{
void check_a2vid_palette() {
int sum;
int min;
int val;
@ -811,7 +796,7 @@ check_a2vid_palette()
/* borders don't change when all 256 superhires colors are used */
g_num_a2vid_palette_checks--;
if(g_num_a2vid_palette_checks || g_installed_full_superhires_colormap){
if(g_num_a2vid_palette_checks || g_installed_full_superhires_colormap) {
return;
}
@ -837,9 +822,7 @@ check_a2vid_palette()
}
}
void
change_display_mode(double dcycs)
{
void change_display_mode(double dcycs) {
int line, tmp_line;
line = ((get_lines_since_vbl(dcycs) + 0xff) >> 8);
@ -857,9 +840,7 @@ change_display_mode(double dcycs)
/* otherwise, g_cur_a2_stat is covered at the end of vbl */
}
void
video_update_all_stat_through_line(int line)
{
void video_update_all_stat_through_line(int line) {
int start_line;
int prev_stat;
int max_line;
@ -889,9 +870,7 @@ int g_border_color = 0; // OG Expose border color
Border_changes g_border_changes[MAX_BORDER_CHANGES];
int g_num_border_changes = 0;
void
change_border_color(double dcycs, int val)
{
void change_border_color(double dcycs, int val) {
int pos;
g_border_color = val; // OG Expose border color
@ -911,9 +890,7 @@ change_border_color(double dcycs, int val)
extern int first;
void
update_border_info()
{
void update_border_info() {
double dlines_per_dcyc;
double dcycs, dline, dcyc_line_start;
int offset;
@ -963,13 +940,13 @@ update_border_info()
new_val = g_border_changes[i].val;
new_line_offset = (new_line << 8) + offset;
if(new_line_offset < -256 || new_line_offset >(262*256 + 0x80)){
if(new_line_offset < -256 || new_line_offset >(262*256 + 0x80)) {
printf("new_line_offset: %05x\n", new_line_offset);
new_line_offset = last_line_offset;
}
while(last_line_offset < new_line_offset) {
/* see if this will finish it */
if((last_line_offset & -256)==(new_line_offset & -256)){
if((last_line_offset & -256)==(new_line_offset & -256)) {
update_border_line(last_line_offset,
new_line_offset, color_now);
last_line_offset = new_line_offset;
@ -1000,9 +977,7 @@ update_border_info()
g_vbl_border_color = (g_c034_val & 0xf);
}
void
update_border_line(int st_line_offset, int end_line_offset, int color)
{
void update_border_line(int st_line_offset, int end_line_offset, int color) {
word32 val;
int st_offset, end_offset;
int left, right;
@ -1101,10 +1076,8 @@ update_border_line(int st_line_offset, int end_line_offset, int color)
}
}
void
video_border_pixel_write(Kimage *kimage_ptr, int starty, int num_lines,
word32 val, int st_off, int end_off)
{
void video_border_pixel_write(Kimage *kimage_ptr, int starty, int num_lines,
word32 val, int st_off, int end_off) {
word32 *ptr;
int width;
int width_act;
@ -1164,7 +1137,7 @@ video_border_pixel_write(Kimage *kimage_ptr, int starty, int num_lines,
ch_mask = ch_mask << ch_shift_amount; \
\
if(reparse) { \
ch_mask = - (1 << (32 - bits_per_line)); \
ch_mask = -(1 << (32 - bits_per_line)); \
}
#define CH_LOOP_A2_VID(ch_mask, ch_tmp) \
@ -1175,11 +1148,9 @@ video_border_pixel_write(Kimage *kimage_ptr, int starty, int num_lines,
continue; \
}
void
redraw_changed_text_40(int start_offset, int start_line, int num_lines,
void redraw_changed_text_40(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int altcharset, int bg_val, int fg_val,
int pixels_per_line)
{
int pixels_per_line) {
register word32 start_time, end_time;
word32 *img_ptr, *img_ptr2;
word32 *save_img_ptr, *save_img_ptr2;
@ -1354,11 +1325,9 @@ redraw_changed_text_40(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
void
redraw_changed_text_80(int start_offset, int start_line, int num_lines,
void redraw_changed_text_80(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int altcharset, int bg_val, int fg_val,
int pixels_per_line)
{
int pixels_per_line) {
const word32 *font_ptr0, *font_ptr1, *font_ptr2, *font_ptr3;
word32 *ch_ptr;
word32 *img_ptr, *img_ptr2;
@ -1545,10 +1514,8 @@ redraw_changed_text_80(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
void
redraw_changed_gr(int start_offset, int start_line, int num_lines, int reparse,
byte *screen_data, int pixels_per_line)
{
void redraw_changed_gr(int start_offset, int start_line, int num_lines, int reparse,
byte *screen_data, int pixels_per_line) {
word32 *img_ptr;
word32 *save_img_ptr;
word32 *ch_ptr;
@ -1670,10 +1637,8 @@ redraw_changed_gr(int start_offset, int start_line, int num_lines, int reparse,
g_need_redraw = 0;
}
void
redraw_changed_dbl_gr(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_dbl_gr(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line) {
word32 *img_ptr;
word32 *save_img_ptr;
word32 *ch_ptr;
@ -1814,10 +1779,8 @@ redraw_changed_dbl_gr(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
void
redraw_changed_hires(int start_offset, int start_line, int num_lines,
int color, int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_hires(int start_offset, int start_line, int num_lines,
int color, int reparse, byte *screen_data, int pixels_per_line) {
if(!color) {
redraw_changed_hires_color(start_offset, start_line, num_lines,
reparse, screen_data, pixels_per_line);
@ -1827,10 +1790,8 @@ redraw_changed_hires(int start_offset, int start_line, int num_lines,
}
}
void
redraw_changed_hires_bw(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_hires_bw(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line) {
word32 *img_ptr, *img_ptr2;
word32 *ch_ptr;
byte *b_ptr;
@ -1945,10 +1906,8 @@ redraw_changed_hires_bw(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
void
redraw_changed_hires_color(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_hires_color(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line) {
word32 *img_ptr, *img_ptr2;
word32 *ch_ptr;
byte *b_ptr;
@ -2083,10 +2042,8 @@ redraw_changed_hires_color(int start_offset, int start_line, int num_lines,
}
void
redraw_changed_dbl_hires(int start_offset, int start_line, int num_lines,
int color, int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_dbl_hires(int start_offset, int start_line, int num_lines,
int color, int reparse, byte *screen_data, int pixels_per_line) {
if(!color) {
redraw_changed_dbl_hires_color(start_offset, start_line,
num_lines, reparse, screen_data, pixels_per_line);
@ -2097,10 +2054,8 @@ redraw_changed_dbl_hires(int start_offset, int start_line, int num_lines,
}
void
redraw_changed_dbl_hires_bw(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_dbl_hires_bw(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line) {
word32 *img_ptr, *img_ptr2;
word32 *ch_ptr;
byte *b_ptr;
@ -2217,10 +2172,8 @@ redraw_changed_dbl_hires_bw(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
void
redraw_changed_dbl_hires_color(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line)
{
void redraw_changed_dbl_hires_color(int start_offset, int start_line, int num_lines,
int reparse, byte *screen_data, int pixels_per_line) {
word32 *ch_ptr;
word32 *img_ptr, *img_ptr2;
byte *slow_mem_ptr;
@ -2351,9 +2304,7 @@ redraw_changed_dbl_hires_color(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
int
video_rebuild_super_hires_palette(word32 scan_info, int line, int reparse)
{
int video_rebuild_super_hires_palette(word32 scan_info, int line, int reparse) {
word32 *word_ptr;
word32 *ch_ptr;
byte *byte_ptr;
@ -2531,10 +2482,8 @@ video_rebuild_super_hires_palette(word32 scan_info, int line, int reparse)
void
redraw_changed_super_hires(int start_offset, int start_line, int num_lines,
int in_reparse, byte *screen_data)
{
void redraw_changed_super_hires(int start_offset, int start_line, int num_lines,
int in_reparse, byte *screen_data) {
word32 *ch_ptr;
word32 mask_per_line;
word32 all_checks;
@ -2731,15 +2680,11 @@ redraw_changed_super_hires(int start_offset, int start_line, int num_lines,
g_need_redraw = 0;
}
void
display_screen()
{
void display_screen() {
video_update_through_line(262);
}
void
video_update_event_line(int line)
{
void video_update_event_line(int line) {
int new_line;
video_update_through_line(line);
@ -2763,9 +2708,7 @@ video_update_event_line(int line)
}
}
void
video_check_input_events()
{
void video_check_input_events() {
word32 start_time, end_time;
g_video_dcycs_check_input = g_cur_dcycs + 4000.0;
@ -2777,9 +2720,7 @@ video_check_input_events()
g_cycs_in_check_input += (end_time - start_time);
}
void
video_update_through_line(int line)
{
void video_update_through_line(int line) {
register word32 start_time;
register word32 end_time;
int *mode_ptr;
@ -2891,9 +2832,7 @@ video_update_through_line(int line)
}
}
void
video_refresh_lines(int st_line, int num_lines, int must_reparse)
{
void video_refresh_lines(int st_line, int num_lines, int must_reparse) {
byte *ptr;
int line;
int stat;
@ -2990,18 +2929,14 @@ video_refresh_lines(int st_line, int num_lines, int must_reparse)
}
}
void
refresh_border()
{
void refresh_border() {
/**ZZZZ***/
}
// OG Added video_release_kimages proto
void video_release_kimages();
void
end_screen()
{
void end_screen() {
glog("Shutting down display");
// OG Free up allocated images
@ -3013,9 +2948,7 @@ byte g_font_array[256][8] = {
#include "gsportfont.h"
};
void
read_a2_font()
{
void read_a2_font() {
byte *f40_e_ptr;
byte *f40_o_ptr;
byte *f80_0_ptr, *f80_1_ptr, *f80_2_ptr, *f80_3_ptr;
@ -3076,9 +3009,7 @@ read_a2_font()
/* Helper routine for the *driver.c files */
void
video_get_kimage(Kimage *kimage_ptr, int extend_info, int depth, int mdepth)
{
void video_get_kimage(Kimage *kimage_ptr, int extend_info, int depth, int mdepth) {
int width;
int height;
@ -3108,9 +3039,7 @@ video_get_kimage(Kimage *kimage_ptr, int extend_info, int depth, int mdepth)
x_get_kimage(kimage_ptr);
}
void
video_get_kimages()
{
void video_get_kimages() {
video_get_kimage(&g_kimage_text[0], 0, 8, 8);
video_get_kimage(&g_kimage_text[1], 0, 8, 8);
video_get_kimage(&g_kimage_hires[0], 0, 8, 8);
@ -3124,8 +3053,7 @@ video_get_kimages()
}
// OG Added video_release_kimages (to match video_get_kimages)
void video_release_kimages()
{
void video_release_kimages() {
extern void x_release_kimage(Kimage *kimage_ptr);
x_release_kimage(&g_kimage_text[0]);
@ -3138,10 +3066,8 @@ void video_release_kimages()
}
void
video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx,
int starty, int width, int height)
{
void video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx,
int starty, int width, int height) {
byte *indata, *inptr;
word32 *outdata32, *outptr32;
word16 *outdata16, *outptr16;
@ -3193,10 +3119,8 @@ video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx,
}
}
void
video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
int right_pix)
{
void video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
int right_pix) {
int mdepth_mismatch;
int srcy;
int center = 0; // OG added variable to center screen
@ -3205,7 +3129,7 @@ video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
if (!kimage_ptr)
{
printf("warning : video_push_lines(kimage_ptr=null)\n");
return ;
return;
}
if(left_pix >= right_pix || left_pix < 0 || right_pix <= 0) {
@ -3240,10 +3164,8 @@ video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
(right_pix - left_pix), 2*(end_line - start_line));
}
void
video_push_border_sides_lines(int src_x, int dest_x, int width, int start_line,
int end_line)
{
void video_push_border_sides_lines(int src_x, int dest_x, int width, int start_line,
int end_line) {
Kimage *kimage_ptr;
int srcy;
@ -3285,9 +3207,7 @@ video_push_border_sides_lines(int src_x, int dest_x, int width, int start_line,
}
}
void
video_push_border_sides()
{
void video_push_border_sides() {
int old_width;
int prev_line;
int width;
@ -3319,7 +3239,7 @@ video_push_border_sides()
old_width = width;
}
}
video_push_border_sides_lines(0/*BORDER_WIDTH*/,
video_push_border_sides_lines(0 /*BORDER_WIDTH*/,
0, old_width, prev_line, 200);
/* right side--can be "jagged" */
@ -3340,13 +3260,11 @@ video_push_border_sides()
}
}
video_push_border_sides_lines(0/*BORDER_WIDTH*/,
video_push_border_sides_lines(0 /*BORDER_WIDTH*/,
X_A2_WINDOW_WIDTH - old_width, old_width, prev_line, 200);
}
void
video_push_border_special()
{
void video_push_border_special() {
Kimage *kimage_ptr;
int width, height;
int src_x, src_y;
@ -3372,7 +3290,7 @@ video_push_border_special()
kimage_ptr->data_ptr[i*4+1] = 0xFF;
kimage_ptr->data_ptr[i*4+2] = 0x00;
}
*/
*/
if(width > 0 && height > 0) {
#ifdef WINSDL_BORDERHACK
x_push_kimage(kimage_ptr, dest_x+72, dest_y, src_x, src_y, width, height);
@ -3399,9 +3317,7 @@ video_push_border_special()
// OG Added window ratio support
extern int x_calc_ratio(float ratiox,float ratioy);
void
video_push_kimages()
{
void video_push_kimages() {
register word32 start_time;
register word32 end_time;
Kimage *last_kim, *cur_kim;
@ -3516,9 +3432,7 @@ video_push_kimages()
}
void
video_update_color_raw(int col_num, int a2_color)
{
void video_update_color_raw(int col_num, int a2_color) {
word32 tmp;
int red, green, blue;
int newred, newgreen, newblue;
@ -3542,9 +3456,7 @@ video_update_color_raw(int col_num, int a2_color)
x_update_color(col_num, red, green, blue, tmp);
}
void
video_update_color_array(int col_num, int a2_color)
{
void video_update_color_array(int col_num, int a2_color) {
int palette;
int full;
@ -3570,9 +3482,7 @@ video_update_color_array(int col_num, int a2_color)
video_update_color_raw(col_num, a2_color);
}
void
video_update_colormap()
{
void video_update_colormap() {
int palette;
int full;
int i;
@ -3588,9 +3498,7 @@ video_update_colormap()
}
}
void
video_update_status_line(int line, const char *string)
{
void video_update_status_line(int line, const char *string) {
char *buf;
const char *ptr;
int i;
@ -3614,9 +3522,7 @@ video_update_status_line(int line, const char *string)
buf[STATUS_LINE_LENGTH] = 0;
}
void
video_show_debug_info()
{
void video_show_debug_info() {
word32 tmp1;
printf("g_cur_dcycs: %f, last_vbl: %f\n", g_cur_dcycs,
@ -3626,9 +3532,7 @@ video_show_debug_info()
printf("Last line updated: %d\n", g_vid_update_last_line);
}
word32
float_bus(double dcycs)
{
word32 float_bus(double dcycs) {
word32 val;
int lines_since_vbl;
int line, eff_line, line24;

View File

@ -1,7 +1,11 @@
/*
* host_fst.c
GSPLUS - Advanced Apple IIGS Emulator Environment
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
#define _WIN32_WINNT 0x0600 // vista+
#include <Windows.h>
@ -404,8 +408,7 @@ struct file_info {
struct AFP_Info afp;
};
static int hex(byte c)
{
static int hex(byte c) {
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c + 10 - 'a';
if (c >= 'A' && c <= 'F') return c + 10 - 'A';
@ -671,7 +674,7 @@ static word32 get_file_info(const char *path, struct file_info *fi) {
const char *dot = NULL;
const char *slash = NULL;
for(n = 0; ; ++n) {
for(n = 0;; ++n) {
char c = path[n];
if (c == 0) break;
else if (c == '/') { slash = path + n + 1; dot = NULL; }
@ -726,7 +729,7 @@ static word32 set_file_info(const char *path, struct file_info *fi) {
char *rpath = append_string(path, ":AFP_AfpInfo");
HANDLE h = CreateFile(rpath, GENERIC_WRITE,
FILE_SHARE_READ , NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) return map_last_error();
WriteFile(h, &fi->afp, sizeof(struct AFP_Info), NULL, NULL);
@ -955,12 +958,11 @@ static word32 set_option_list(word32 ptr, word16 fstID, const byte *data, int si
}
static int dayofweek(int y, int m, int d) /* 1 <= m <= 12, y > 1752 (in the U.K.) */
{
static int dayofweek(int y, int m, int d) { /* 1 <= m <= 12, y > 1752 (in the U.K.) */
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
}
/*
* converts time_t to a gs/os readhextime date/time record.
*/
@ -1783,7 +1785,7 @@ static word32 fst_open(int class, const char *path) {
if (pcount >= 5) set_memory16_c(pb + OpenRecGS_access, access, 0);
if (pcount >= 6) set_memory16_c(pb + OpenRecGS_fileType, fi.file_type, 0);
if (pcount >= 7) set_memory32_c(pb + OpenRecGS_auxType, fi.aux_type, 0);
if (pcount >= 8) set_memory16_c(pb + OpenRecGS_storageType, fi. storage_type, 0);
if (pcount >= 8) set_memory16_c(pb + OpenRecGS_storageType, fi.storage_type, 0);
if (pcount >= 9) set_date_time_rec(pb + OpenRecGS_createDateTime, fi.create_date);
if (pcount >= 10) set_date_time_rec(pb + OpenRecGS_modDateTime, fi.modified_date);
@ -1821,7 +1823,7 @@ static word32 fst_open(int class, const char *path) {
return tooManyFilesOpen;
}
if (type == regular_file){
if (type == regular_file) {
if (g_cfg_host_crlf) {
if (fi.file_type == 0x04 || fi.file_type == 0xb0)
@ -1897,7 +1899,7 @@ static word32 fst_read(int class) {
for (int i = 0; i < 256; ++i)
newline_table[i] = get_memory_c(global_buffer + 2 + i, 0);
for (word32 i = 0 ; i < request_count; ++i) {
for (word32 i = 0; i < request_count; ++i) {
byte b;
DWORD read_count;
ok = ReadFile(e->handle, &b, 1, &read_count, NULL);

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#include "defc.h"
#include "sound.h"
@ -29,9 +29,7 @@ extern int g_preferred_rate;
int g_win32snd_buflen = 0x1000;
void
win32snd_init(word32 *shmaddr)
{
void win32snd_init(word32 *shmaddr) {
printf("win32snd_init\n");
child_sound_loop(-1, -1, shmaddr);
@ -43,9 +41,7 @@ win32snd_init(word32 *shmaddr)
byte *bptr = NULL;
// OG shut win32 sound resources
void
win32snd_shutdown()
{
void win32snd_shutdown() {
if (g_wave_handle)
{
@ -57,7 +53,7 @@ win32snd_shutdown()
if (res!=MMSYSERR_NOERROR )
printf("waveOutClose Failed");
g_wave_handle=NULL;
}
}
// OG Free dedicated sound memory
if (bptr)
{
@ -68,10 +64,8 @@ win32snd_shutdown()
}
void CALLBACK
handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1,
DWORD_PTR dwParam2)
{
void CALLBACK handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1,
DWORD_PTR dwParam2) {
LPWAVEHDR lpwavehdr;
/* Only service "buffer done playing messages */
@ -84,9 +78,7 @@ handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1
return;
}
void
check_wave_error(int res, char *str)
{
void check_wave_error(int res, char *str) {
TCHAR buf[256];
if(res == MMSYSERR_NOERROR) {
@ -98,9 +90,7 @@ check_wave_error(int res, char *str)
exit(1);
}
void
child_sound_init_win32()
{
void child_sound_init_win32() {
WAVEFORMATEX wavefmt;
WAVEOUTCAPS caps;
@ -181,9 +171,7 @@ child_sound_init_win32()
}
void
win32_send_audio2(byte *ptr, int size)
{
void win32_send_audio2(byte *ptr, int size) {
int found;
int res;
int i;
@ -211,9 +199,7 @@ win32_send_audio2(byte *ptr, int size)
return;
}
int
win32_send_audio(byte *ptr, int in_size)
{
int win32_send_audio(byte *ptr, int in_size) {
int size;
int tmpsize;

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#define WIN32_LEAN_AND_MEAN /* Tell windows we want less header gunk */
#define STRICT /* Tell Windows we want compile type checks */
@ -25,9 +25,7 @@ extern int g_win_status_debug;
extern int g_win_status_debug_request;
extern int g_win_fullscreen_state;
int
win_nonblock_read_stdin(int fd, char *bufptr, int len)
{
int win_nonblock_read_stdin(int fd, char *bufptr, int len) {
DWORD charsRead = 0;
ReadConsole(GetStdHandle(STD_INPUT_HANDLE), bufptr, len, &charsRead, NULL);
@ -44,8 +42,7 @@ win_nonblock_read_stdin(int fd, char *bufptr, int len)
}
}
void get_cwd(LPTSTR buffer, int size)
{
void get_cwd(LPTSTR buffer, int size) {
HMODULE hSelf;
hSelf = GetModuleHandle(NULL);
GetModuleFileName(hSelf,buffer,size);
@ -53,21 +50,16 @@ void get_cwd(LPTSTR buffer, int size)
//printf("Local directory: [%s]\n",buffer);
}
void
x_dialog_create_gsport_conf(const char *str)
{
void x_dialog_create_gsport_conf(const char *str) {
// Just write the config file already...
config_write_config_gsplus_file();
}
int
x_show_alert(int is_fatal, const char *str)
{
int x_show_alert(int is_fatal, const char *str) {
return 0;
}
void get_default_window_size(LPSIZE size)
{
void get_default_window_size(LPSIZE size) {
// Calculate the window client dimensions.
RECT rect;
rect.left = 0;
@ -85,8 +77,7 @@ void get_default_window_size(LPSIZE size)
size->cy = rect.bottom - rect.top;
}
void x_toggle_status_lines()
{
void x_toggle_status_lines() {
SIZE size;
if (!g_win_fullscreen_state)
@ -100,8 +91,7 @@ void x_toggle_status_lines()
}
}
void x_show_console(int show)
{
void x_show_console(int show) {
HWND hWnd = GetConsoleWindow();
if (hWnd)
ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE);
@ -110,14 +100,11 @@ void x_show_console(int show)
SetFocus(g_hwnd_main);
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
return main(0,0);
}
int
main(int argc, char **argv)
{
int main(int argc, char **argv) {
// Hide the console initially to reduce window flashing. We'll show the console later if needed.
x_show_console(0);
@ -173,8 +160,7 @@ main(int argc, char **argv)
return ret;
}
void x_check_input_events()
{
void x_check_input_events() {
MSG msg;
while(PeekMessage(&msg, g_hwnd_main, 0, 0, PM_NOREMOVE)) {
@ -188,9 +174,7 @@ void x_check_input_events()
}
}
void
x_redraw_status_lines()
{
void x_redraw_status_lines() {
COLORREF oldtextcolor, oldbkcolor;
char *buf;
int line;
@ -219,8 +203,6 @@ x_redraw_status_lines()
}
}
int
x_calc_ratio(float ratiox,float ratioy)
{
int x_calc_ratio(float ratiox,float ratioy) {
return 0; // not stretched
}

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
#define WIN32_LEAN_AND_MEAN /* Tell windows we want less header gunk */
#define STRICT /* Tell Windows we want compile type checks */
@ -69,9 +69,7 @@ size_t g_clipboard_pos;
int x_calc_ratio(float ratiox, float ratioy);
int
win_update_mouse(int x, int y, int button_states, int buttons_valid)
{
int win_update_mouse(int x, int y, int button_states, int buttons_valid) {
int buttons_changed;
#ifdef ACTIVEGS
@ -135,8 +133,7 @@ struct win32_key win32_keys[MAX_EVENT];
// OG Push Mouse Event
void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
{
void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam) {
#ifdef ACTIVEGS
if (g_config_control_panel) // OG ignore input events while in debugger
@ -153,9 +150,7 @@ void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
// OG Push Key Event
void
add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
{
void add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags) {
#ifdef ACTIVEGS
if (g_config_control_panel) // OG ignore input events while in debugger
return;
@ -172,9 +167,7 @@ add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
nb_win32_key++;
}
void
win_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
{
void win_event_mouse(int umsg,WPARAM wParam, LPARAM lParam) {
POINT pt;
word32 flags;
int buttons;
@ -215,9 +208,7 @@ win_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
}
}
void
win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
{
void win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags) {
word32 vk;
int a2code;
int is_up;
@ -269,23 +260,17 @@ win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
printf("VK: %04x unknown\n", vk);
}
void
win_event_quit(HWND hwnd)
{
void win_event_quit(HWND hwnd) {
quitEmulator();
}
extern int g_needfullrefreshfornextframe ;
extern int g_needfullrefreshfornextframe;
void
win_event_redraw()
{
void win_event_redraw() {
g_needfullrefreshfornextframe = 1;
}
LRESULT CALLBACK
win_event_handler(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
LRESULT CALLBACK win_event_handler(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
int i;
int numDraggedFiles;
int szFilename;
@ -328,8 +313,7 @@ win_event_handler(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hwnd, umsg, wParam, lParam);
}
void gsportinit(HWND _hwnd)
{
void gsportinit(HWND _hwnd) {
g_hwnd_main = _hwnd;
HDC localdc = GetDC(g_hwnd_main);
@ -340,8 +324,7 @@ void gsportinit(HWND _hwnd)
ReleaseDC(g_hwnd_main,localdc);
}
void gsportshut()
{
void gsportshut() {
if (g_main_cdc)
{
DeleteDC(g_main_cdc);
@ -350,9 +333,7 @@ void gsportshut()
g_hwnd_main = NULL;
}
void
check_input_events()
{
void check_input_events() {
x_check_input_events();
// OG Unstack Mouse Events
@ -367,8 +348,8 @@ check_input_events()
}
last_win32_mouse=i;
for(i=0;i<nb_win32_key;i++)
win_event_key(NULL,win32_keys[i].raw_vk ,win32_keys[i].down,win32_keys[i].repeat , win32_keys[i].flags );
for(i=0; i<nb_win32_key; i++)
win_event_key(NULL,win32_keys[i].raw_vk,win32_keys[i].down,win32_keys[i].repeat, win32_keys[i].flags );
nb_win32_key=0;
if (g_win_status_debug_request != g_win_status_debug)
@ -380,19 +361,13 @@ check_input_events()
}
}
void
x_update_color(int col_num, int red, int green, int blue, word32 rgb)
{
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) {
}
void
x_update_physical_colormap()
{
void x_update_physical_colormap() {
}
void
show_xcolor_array()
{
void show_xcolor_array() {
int i;
for(i = 0; i < 256; i++) {
@ -401,8 +376,7 @@ show_xcolor_array()
}
// OG Add function to clear all get_images loaded (dev dependent)
void x_release_kimage(Kimage *kimage_ptr)
{
void x_release_kimage(Kimage *kimage_ptr) {
if ((int)kimage_ptr->dev_handle != -1)
{
DeleteObject(kimage_ptr->dev_handle);
@ -417,9 +391,7 @@ void x_release_kimage(Kimage *kimage_ptr)
}
// OG Free video global memory
void
xdriver_end() // Should be renamed to dev_video_shut() ???
{
void xdriver_end() { // Should be renamed to dev_video_shut() ???
x_release_kimage(&g_mainwin_kimage);
@ -429,9 +401,7 @@ xdriver_end() // Should be renamed to dev_video_shut() ???
printf("win32 video driver end\n");
}
void
x_get_kimage(Kimage *kimage_ptr)
{
void x_get_kimage(Kimage *kimage_ptr) {
byte *ptr;
int width;
int height;
@ -476,9 +446,7 @@ x_get_kimage(Kimage *kimage_ptr)
return;
}
void
dev_video_init()
{
void dev_video_init() {
int extra_size;
int lores_col;
int i;
@ -508,15 +476,15 @@ dev_video_init()
g_screen_mdepth = 16;
extern word32 g_red_mask ;
extern word32 g_green_mask ;
extern word32 g_blue_mask ;
extern int g_red_left_shift;
extern int g_green_left_shift;
extern int g_blue_left_shift ;
extern int g_red_right_shift ;
extern int g_green_right_shift ;
extern int g_blue_right_shift ;
extern word32 g_red_mask;
extern word32 g_green_mask;
extern word32 g_blue_mask;
extern int g_red_left_shift;
extern int g_green_left_shift;
extern int g_blue_left_shift;
extern int g_red_right_shift;
extern int g_green_right_shift;
extern int g_blue_right_shift;
g_red_mask = 0xff;
@ -573,10 +541,8 @@ extern int g_blue_right_shift ;
fflush(stdout);
}
void
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height)
{
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height) {
void *bitm_old;
HDC localdc = GetDC(g_hwnd_main);
@ -600,24 +566,16 @@ x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
ReleaseDC(g_hwnd_main,localdc);
}
void
x_push_done()
{
void x_push_done() {
}
void
x_auto_repeat_on(int must)
{
void x_auto_repeat_on(int must) {
}
void
x_auto_repeat_off(int must)
{
void x_auto_repeat_off(int must) {
}
void
x_hide_pointer(int do_hide)
{
void x_hide_pointer(int do_hide) {
if(do_hide) {
ShowCursor(0);
} else {
@ -625,9 +583,7 @@ x_hide_pointer(int do_hide)
}
}
void
x_full_screen(int do_full)
{
void x_full_screen(int do_full) {
MONITORINFO monitor_info;
FULLSCREEN_SCALE_TYPE width, height, scalex, scaley;
int top, left;
@ -678,9 +634,7 @@ x_full_screen(int do_full)
return;
}
void
clipboard_paste()
{
void clipboard_paste() {
if (!IsClipboardFormatAvailable(CF_TEXT))
return;
if (!OpenClipboard(g_hwnd_main))
@ -708,9 +662,7 @@ clipboard_paste()
CloseClipboard();
}
int
clipboard_get_char()
{
int clipboard_get_char() {
if (!g_clipboard)
return 0;
if (g_clipboard[g_clipboard_pos] == '\n')

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2)
*/
*/
# if !defined(__CYGWIN__) && !defined(__POWERPC__)
/* No shared memory on Cygwin */
@ -241,22 +241,16 @@ int a2_key_to_xsym[][3] = {
{ -1, -1, -1 }
};
int
main(int argc, char **argv)
{
int main(int argc, char **argv) {
return gsplusmain(argc, argv);
}
void
x_dialog_create_gsport_conf(const char *str)
{
void x_dialog_create_gsport_conf(const char *str) {
// Just write the config file already...
config_write_config_gsplus_file();
}
int
x_show_alert(int is_fatal, const char *str)
{
int x_show_alert(int is_fatal, const char *str) {
/* Not implemented yet */
adb_all_keys_up();
@ -267,9 +261,7 @@ x_show_alert(int is_fatal, const char *str)
#define MAKE_2(val) ( (val << 8) + val)
void
x_update_color(int col_num, int red, int green, int blue, word32 rgb)
{
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) {
XColor *xcol;
xcol = &(g_xcolor_a2vid_array[col_num]);
@ -279,18 +271,14 @@ x_update_color(int col_num, int red, int green, int blue, word32 rgb)
xcol->flags = DoRed | DoGreen | DoBlue;
}
void
x_update_physical_colormap()
{
void x_update_physical_colormap() {
if(g_needs_cmap) {
XStoreColors(g_display, g_a2_colormap,
&g_xcolor_a2vid_array[0], Max_color_size);
}
}
void
show_xcolor_array()
{
void show_xcolor_array() {
int i;
for(i = 0; i < 256; i++) {
@ -306,9 +294,7 @@ show_xcolor_array()
}
int
my_error_handler(Display *display, XErrorEvent *ev)
{
int my_error_handler(Display *display, XErrorEvent *ev) {
char msg[1024];
XGetErrorText(display, ev->error_code, msg, 1000);
printf("X Error code %s\n", msg);
@ -317,9 +303,7 @@ my_error_handler(Display *display, XErrorEvent *ev)
return 0;
}
void
xdriver_end()
{
void xdriver_end() {
printf("xdriver_end\n");
if(g_display) {
@ -328,9 +312,7 @@ xdriver_end()
}
}
void
show_colormap(char *str, Colormap cmap, int index1, int index2, int index3)
{
void show_colormap(char *str, Colormap cmap, int index1, int index2, int index3) {
XColor xcol;
int i;
int pix;
@ -355,9 +337,7 @@ show_colormap(char *str, Colormap cmap, int index1, int index2, int index3)
}
}
void
x_badpipe(int signum)
{
void x_badpipe(int signum) {
/* restore normal sigpipe handling */
signal(SIGPIPE, SIG_DFL);
@ -366,9 +346,7 @@ x_badpipe(int signum)
my_exit(5);
}
void
dev_video_init()
{
void dev_video_init() {
int tmp_array[0x80];
XGCValues new_gc;
XSetWindowAttributes win_attr;
@ -641,9 +619,7 @@ dev_video_init()
fflush(stdout);
}
Visual *
x_try_find_visual(int depth, int screen_num, XVisualInfo **visual_list_ptr)
{
Visual *x_try_find_visual(int depth, int screen_num, XVisualInfo **visual_list_ptr) {
XVisualInfo *visualList;
XVisualInfo *v_chosen;
XVisualInfo vTemplate;
@ -730,10 +706,8 @@ x_try_find_visual(int depth, int screen_num, XVisualInfo **visual_list_ptr)
return v_chosen->visual;
}
void
x_set_mask_and_shift(word32 x_mask, word32 *mask_ptr, int *shift_left_ptr,
int *shift_right_ptr)
{
void x_set_mask_and_shift(word32 x_mask, word32 *mask_ptr, int *shift_left_ptr,
int *shift_right_ptr) {
int shift;
int i;
@ -765,15 +739,12 @@ x_set_mask_and_shift(word32 x_mask, word32 *mask_ptr, int *shift_left_ptr,
int g_xshm_error = 0;
int
xhandle_shm_error(Display *display, XErrorEvent *event)
{
int xhandle_shm_error(Display *display, XErrorEvent *event) {
g_xshm_error = 1;
return 0;
}
void
x_get_kimage(Kimage *kimage_ptr) {
void x_get_kimage(Kimage *kimage_ptr) {
if(g_use_shmem) {
g_use_shmem = get_shm(kimage_ptr);
}
@ -782,9 +753,7 @@ x_get_kimage(Kimage *kimage_ptr) {
}
}
int
get_shm(Kimage *kimage_ptr)
{
int get_shm(Kimage *kimage_ptr) {
#ifdef X_SHARED_MEM
XShmSegmentInfo *seginfo;
XImage *xim;
@ -866,9 +835,7 @@ get_shm(Kimage *kimage_ptr)
#endif /* X_SHARED_MEM */
}
void
get_ximage(Kimage *kimage_ptr)
{
void get_ximage(Kimage *kimage_ptr) {
XImage *xim;
byte *ptr;
int width;
@ -916,9 +883,7 @@ get_ximage(Kimage *kimage_ptr)
}
void
x_toggle_status_lines()
{
void x_toggle_status_lines() {
XSizeHints my_winSizeHints;
XClassHint my_winClassHint;
int base_height = X_A2_WINDOW_HEIGHT;
@ -941,9 +906,7 @@ x_toggle_status_lines()
x_redraw_status_lines();
}
void
x_redraw_status_lines()
{
void x_redraw_status_lines() {
char *buf;
int line;
int height;
@ -980,10 +943,8 @@ x_redraw_status_lines()
}
void
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height)
{
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height) {
XImage *xim;
xim = (XImage *)kimage_ptr->dev_handle;
@ -1000,9 +961,7 @@ x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
}
}
void
x_push_done()
{
void x_push_done() {
XFlush(g_display);
}
@ -1012,9 +971,7 @@ x_push_done()
int g_num_check_input_calls = 0;
int g_check_input_flush_rate = 2;
int
x_update_mouse(int raw_x, int raw_y, int button_states, int buttons_valid)
{
int x_update_mouse(int raw_x, int raw_y, int button_states, int buttons_valid) {
int x, y;
x = raw_x - BASE_MARGIN_LEFT;
@ -1029,9 +986,7 @@ x_update_mouse(int raw_x, int raw_y, int button_states, int buttons_valid)
return update_mouse(x, y, button_states, buttons_valid & 7);
}
void
check_input_events()
{
void check_input_events() {
XEvent ev;
int len;
int motion;
@ -1156,9 +1111,7 @@ check_input_events()
}
void
x_hide_pointer(int do_hide)
{
void x_hide_pointer(int do_hide) {
if(do_hide) {
XDefineCursor(g_display, g_a2_win, g_cursor);
} else {
@ -1167,9 +1120,7 @@ x_hide_pointer(int do_hide)
}
void
handle_keysym(XEvent *xev_in)
{
void handle_keysym(XEvent *xev_in) {
KeySym keysym;
word32 state;
int keycode;
@ -1279,9 +1230,7 @@ handle_keysym(XEvent *xev_in)
}
}
int
x_keysym_to_a2code(int keysym, int is_up)
{
int x_keysym_to_a2code(int keysym, int is_up) {
int i;
if(keysym == 0) {
@ -1326,9 +1275,7 @@ x_keysym_to_a2code(int keysym, int is_up)
return -1;
}
void
x_update_modifier_state(int state)
{
void x_update_modifier_state(int state) {
int state_xor;
int is_up;
@ -1351,9 +1298,7 @@ x_update_modifier_state(int state)
g_x_shift_control_state = state;
}
void
x_auto_repeat_on(int must)
{
void x_auto_repeat_on(int must) {
if((g_auto_repeat_on <= 0) || must) {
g_auto_repeat_on = 1;
XAutoRepeatOn(g_display);
@ -1362,9 +1307,7 @@ x_auto_repeat_on(int must)
}
}
void
x_auto_repeat_off(int must)
{
void x_auto_repeat_off(int must) {
if((g_auto_repeat_on != 0) || must) {
XAutoRepeatOff(g_display);
XFlush(g_display);
@ -1373,15 +1316,12 @@ x_auto_repeat_off(int must)
}
}
void
x_full_screen(int do_full)
{
void x_full_screen(int do_full) {
return;
}
// OG Adding release
void x_release_kimage(Kimage* kimage_ptr)
{
void x_release_kimage(Kimage* kimage_ptr) {
if (kimage_ptr->dev_handle == (void*)-1)
{
free(kimage_ptr->data_ptr);
@ -1390,20 +1330,15 @@ void x_release_kimage(Kimage* kimage_ptr)
}
// OG Addding ratio
int x_calc_ratio(float x,float y)
{
int x_calc_ratio(float x,float y) {
return 1;
}
void
clipboard_paste(void)
{
void clipboard_paste(void) {
// TODO: Add clipboard support
}
int
clipboard_get_char(void)
{
int clipboard_get_char(void) {
// TODO: Add clipboard support
return 0;
}