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

View File

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

View File

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

View File

@ -23,8 +23,7 @@
#include <string.h> #include <string.h>
#include "dirport.h" #include "dirport.h"
DIR *opendir (char *path) DIR *opendir (char *path) {
{
APIRET ulrc; APIRET ulrc;
ULONG cnt = 1; ULONG cnt = 1;
DIR *dir; DIR *dir;
@ -47,15 +46,13 @@ DIR *opendir (char *path)
return dir; return dir;
} }
struct dirent *readdir (DIR *dir) struct dirent *readdir (DIR *dir) {
{
ULONG cnt = 1; ULONG cnt = 1;
return DosFindNext (dir->handle, &(dir->buffer), sizeof(struct _FILEFINDBUF), &cnt) ? NULL : &(dir->buffer); 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); APIRET ulrc = DosFindClose (dir->handle);
free(dir); free(dir);
@ -81,10 +78,10 @@ int closedir (DIR *dir)
not or do provide an inadequate (slow or idiosyncratic) version, which not or do provide an inadequate (slow or idiosyncratic) version, which
calls for a portable implementation of this routine. calls for a portable implementation of this routine.
Author Author
Mark Martinec <mark.martinec@ijs.si>, April 1999, June 2000 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) \ #define fast_memcpy(d,s,n) \
{ register size_t nn = (size_t)(n); \ { register size_t nn = (size_t)(n); \
if (nn >= breakeven_point) memcpy((d), (s), nn); \ 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; \ register char *dd; register const char *ss; \
for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } } for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } }
#define fast_memset(d,c,n) \ #define fast_memset(d,c,n) \
{ register size_t nn = (size_t)(n); \ { register size_t nn = (size_t)(n); \
if (nn >= breakeven_point) memset((d), (int)(c), nn); \ 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); \ register char *dd; register const int cc=(int)(c); \
for (dd=(d); nn>0; nn--) *dd++ = cc; } } 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_list ap2;
va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ 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*/ 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 */ assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
*ptr = (char *) malloc(str_m = (size_t)str_l + 1); *ptr = (char *) malloc(str_m = (size_t)str_l + 1);
if (*ptr == NULL) { errno = ENOMEM; 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_list ap2;
va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ 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*/ 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 */ 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 ((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 */ /* 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); size_t n = !q ? strlen(p) : (q-p);
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m-str_l; 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; p += n; str_l += n;
} else { } 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 '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; case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, ulong_arg); break;
#ifdef SNPRINTF_LONGLONG_SUPPORT #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 #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? */ /* zero padding to specified precision? */
if (num_of_digits < 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? */ /* zero padding to specified minimal field width? */
if (!justify_left && zero_padding) { if (!justify_left && zero_padding) {
int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); 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 (n > 0) {
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m-str_l; 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; 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 (n > 0) {
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m-str_l; 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; 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 (n > 0) {
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m-str_l; 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; 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) { if (str_l < str_m) {
size_t avail = str_m-str_l; size_t avail = str_m-str_l;
fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind, fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind,
(n>avail?avail:n)); (n>avail ? avail : n));
} }
str_l += n; str_l += n;
} }}
}
/* insert right padding */ /* insert right padding */
if (justify_left) { /* right blank padding to the field width */ if (justify_left) { /* right blank padding to the field width */
int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
if (n > 0) { if (n > 0) {
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m-str_l; 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; str_l += n;
} }
@ -832,4 +825,4 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
Local Variables: Local Variables:
tab-width: 3 tab-width: 3
end: end:
*/ */

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
/** This module implements AARP, a necessary protocol for ELAP communication. **/ /** This module implements AARP, a necessary protocol for ELAP communication. **/
@ -38,13 +38,11 @@ static unsigned int retry_count;
static clock_t retry_timer; static clock_t retry_timer;
void aarp_init() void aarp_init() {
{
aarp_retry_reset(); aarp_retry_reset();
} }
void aarp_shutdown() void aarp_shutdown() {
{
struct amt_entry_t* entry = amt; struct amt_entry_t* entry = amt;
while (entry) 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) if (source_at_addr && dest_at_addr && dest_hw_addr)
{ {
struct aarp_header_t response; 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) if (addr)
{ {
aarp_send_packet(AARP_FUNCTION_PROBE, addr, addr, &HW_ZERO); 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) if (addr)
{ {
aarp_send_packet(AARP_FUNCTION_REQUEST, atbridge_get_addr(), addr, &HW_ZERO); 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) if (hardware)
{ {
struct amt_entry_t* entry = amt; 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; 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) if (protocol)
{ {
struct amt_entry_t* entry = amt; 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; 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) if (protocol)
{ {
struct amt_entry_t* entry = amt; 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. // 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); struct amt_entry_t* entry = amt_lookup_entry_protocol(protocol);
if (entry) if (entry)
@ -179,8 +170,7 @@ static void amt_add(const struct at_addr_t* protocol, const struct ether_addr_t*
amt = entry; 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); struct amt_entry_t* entry = amt_lookup_entry_protocol(protocol);
if (entry) 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); struct amt_entry_t* entry = amt_lookup_entry_hardware(hardware);
if (entry) if (entry)
return (const struct at_addr_t*)&entry->protocol; 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; return 0;
} }
bool aarp_retry() bool aarp_retry() {
{
return retry_count > 0; return retry_count > 0;
} }
void aarp_retry_reset() void aarp_retry_reset() {
{
retry_count = AARP_REQUEST_COUNT; retry_count = AARP_REQUEST_COUNT;
retry_timer = clock(); 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); 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 // reference 2-8
if (protocol) 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 && if (aarp &&
aarp->hardware_type == AARP_HARDWARE_ETHER && aarp->hardware_type == AARP_HARDWARE_ETHER &&
aarp->protocol_type == AARP_PROTOCOL_TYPE && aarp->protocol_type == AARP_PROTOCOL_TYPE &&

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) 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. **/ /** 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(); 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 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) if (local_address.network == 0)
{ {
@ -61,25 +60,21 @@ bool atbridge_init()
return true; return true;
} }
void atbridge_shutdown() void atbridge_shutdown() {
{
llap_shutdown(); llap_shutdown();
elap_shutdown(); elap_shutdown();
aarp_shutdown(); aarp_shutdown();
} }
void atbridge_set_diagnostics(bool enabled) void atbridge_set_diagnostics(bool enabled) {
{
diagnostics = enabled; diagnostics = enabled;
} }
bool atbridge_get_diagnostics() bool atbridge_get_diagnostics() {
{
return diagnostics; return diagnostics;
} }
void atbridge_printf(const char *fmt, ...) void atbridge_printf(const char *fmt, ...) {
{
if (atbridge_get_diagnostics()) if (atbridge_get_diagnostics())
{ {
va_list args; 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; return &local_address;
} }
const at_network_t atbridge_get_net() const at_network_t atbridge_get_net() {
{
return local_address.network; return local_address.network;
} }
const at_node_t atbridge_get_node() const at_node_t atbridge_get_node() {
{
return local_address.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; local_address.network = net;
} }
void atbridge_set_node(at_node_t node) void atbridge_set_node(at_node_t node) {
{
local_address.node = 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) if (!sent_rtmp_request)
send_rtmp_request(); send_rtmp_request();
return aarp_address_used(addr); return aarp_address_used(addr);
} }
/* Calculate a DDP checksum, per Apple's documented algorithm in 4-17 of "Inside AppleTalk". */ /* 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; word16 cksum = 0;
for (unsigned int i = 0; i < size; i++) for (unsigned int i = 0; i < size; i++)
{ {
@ -135,8 +123,7 @@ static word16 get_checksum(size_t size, byte data[])
return cksum; 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)) if (packet && packet->data && (packet->size >= sizeof(struct DDP_LONG)) && (packet->type == LAP_DDP_LONG))
{ {
struct DDP_LONG* header = (struct DDP_LONG*)(packet->data); 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. */ /* 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; word16 size;
if (!in || !out) 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. */ /* 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. */ /* 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; word16 size;
if (!in || !out) 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. */ /* Convert a short-form DDP packet to a long-form packet. */
/* This function converts an entire packet, not just the header. */ /* 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))) 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; 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. */ /* 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) if (packet && (packet->type == LAP_DDP_LONG) && packet->data)
{ {
struct DDP_LONG* header_long = (struct 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) /*static void convert_rtmp_to_extended(struct packet_t* packet)
{ {
if (packet && (packet->type == LAP_DDP_SHORT) && packet->data) if (packet && (packet->type == LAP_DDP_SHORT) && packet->data)
{ {
struct DDP_SHORT* header_short = (struct 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->size = size;
packet->type = LAP_DDP_LONG; 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) if (packet && (packet->type == LAP_DDP_LONG) && packet->data)
{ {
struct DDP_LONG* header_long = (struct 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. /* "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), 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. */ 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) if (packet && (packet->type == LAP_DDP_LONG) && packet->data)
{ {
struct DDP_LONG* header_long = (struct 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)); struct packet_t* packet = (struct packet_t*)malloc(sizeof(struct packet_t));
packet->type = LAP_DDP_LONG; packet->type = LAP_DDP_LONG;
@ -390,8 +370,7 @@ static void send_rtmp_request()
sent_rtmp_request = true; sent_rtmp_request = true;
} }
void atbridge_process() void atbridge_process() {
{
elap_process(); elap_process();
//llap_process(); //llap_process();

View File

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

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
/** This module implements the LLAP port of the bridge. **/ /** 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 dialog_end_dcycs;
static double last_frame_dcycs; static double last_frame_dcycs;
void llap_init() void llap_init() {
{
dialog_state = DIALOG_READY; dialog_state = DIALOG_READY;
last_frame_dcycs = 0; last_frame_dcycs = 0;
port_init(&llap_port); port_init(&llap_port);
} }
void llap_shutdown() void llap_shutdown() {
{
port_shutdown(&llap_port); port_shutdown(&llap_port);
} }
/** Queue one data packet out from the bridge's LLAP port and into the guest. **/ /** 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. // Generate the RTS.
struct packet_t* rts = (struct packet_t*)malloc(sizeof(struct packet_t)); struct packet_t* rts = (struct packet_t*)malloc(sizeof(struct packet_t));
rts->source.network = packet->source.network; rts->source.network = packet->source.network;
@ -70,13 +67,11 @@ void llap_enqueue_out(struct packet_t* packet)
enqueue_packet(&llap_port.out, packet); enqueue_packet(&llap_port.out, packet);
} }
struct packet_t* llap_dequeue_in() struct packet_t* llap_dequeue_in() {
{
return dequeue(&llap_port.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) if (size < LLAP_PACKET_MIN)
atbridge_printf("LLAP short packet.\n"); atbridge_printf("LLAP short packet.\n");
else if (size > LLAP_PACKET_MAX) 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 **/ /** 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 dest_addr = { 0, dest };
struct at_addr_t source_addr = { 0, source }; 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. **/ /** 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 dest = data[0];
at_node_t source = data[1]; at_node_t source = data[1];
LLAP_TYPES type = (LLAP_TYPES)(data[2]); 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. **/ /** 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 dest = data[0];
at_node_t source = data[1]; at_node_t source = data[1];
LLAP_TYPES type = (LLAP_TYPES)(data[2]); 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 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. 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; dialog_state = DIALOG_READY;
last_frame_dcycs = 0; last_frame_dcycs = 0;
@ -208,8 +199,7 @@ static void llap_reset_dialog()
} }
/** Transfer (send) one LLAP packet from the GS. **/ /** 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); atbridge_printf("<%0.0f> TX: ", dcycs);
llap_dump_packet(size, data); 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. **/ /** 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; *size = 0;
// The LocalTalk protocol requires a minimum 400us gap between dialogs (called the IDG). // 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 Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
#include <stdbool.h> #include <stdbool.h>
#include "pcap_delay.h" #include "pcap_delay.h"
@ -17,8 +17,7 @@ static void* module = 0;
#endif #endif
bool pcapdelay_load() bool pcapdelay_load() {
{
if (!pcapdelay_is_loaded()) if (!pcapdelay_is_loaded())
{ {
#ifdef WIN32 #ifdef WIN32
@ -30,8 +29,7 @@ bool pcapdelay_load()
return pcapdelay_is_loaded(); return pcapdelay_is_loaded();
} }
bool pcapdelay_is_loaded() bool pcapdelay_is_loaded() {
{
#ifdef WIN32 #ifdef WIN32
return module != NULL; return module != NULL;
#elif __linux__ #elif __linux__
@ -40,8 +38,7 @@ bool pcapdelay_is_loaded()
return 0; return 0;
} }
void pcapdelay_unload() void pcapdelay_unload() {
{
if (pcapdelay_is_loaded()) if (pcapdelay_is_loaded())
{ {
#ifdef WIN32 #ifdef WIN32
@ -56,8 +53,7 @@ void pcapdelay_unload()
typedef void (*PFNVOID)(); 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) if (pcapdelay_load() && proc && ppfn && !*ppfn)
{ {
#ifdef WIN32 #ifdef WIN32
@ -72,16 +68,14 @@ static PFNVOID delay_load(const char* proc, PFNVOID* ppfn)
return 0; return 0;
} }
void pcapdelay_freealldevs(pcap_if_t* a0) void pcapdelay_freealldevs(pcap_if_t* a0) {
{
typedef void (*PFN)(pcap_if_t*); typedef void (*PFN)(pcap_if_t*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_freealldevs", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_freealldevs", (PFNVOID*)&pfn)))
(*pfn)(a0); (*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*); typedef pcap_t* (*PFN)(const char*, int, int, int, char*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_open_live", (PFNVOID*)&pfn))) 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; return 0;
} }
void pcapdelay_close(pcap_t* a0) void pcapdelay_close(pcap_t* a0) {
{
typedef void (*PFN)(pcap_t*); typedef void (*PFN)(pcap_t*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_close", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_close", (PFNVOID*)&pfn)))
(*pfn)(a0); (*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*); typedef int (*PFN)(pcap_if_t**, char*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_findalldevs", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_findalldevs", (PFNVOID*)&pfn)))
@ -108,9 +100,8 @@ int pcapdelay_findalldevs(pcap_if_t** a0, char* a1)
return 0; return 0;
} }
int pcapdelay_datalink(pcap_t* a0) int pcapdelay_datalink(pcap_t* a0) {
{ typedef int (*PFN)(pcap_t*);
typedef int(*PFN)(pcap_t*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_datalink", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_datalink", (PFNVOID*)&pfn)))
return (*pfn)(a0); return (*pfn)(a0);
@ -118,9 +109,8 @@ int pcapdelay_datalink(pcap_t* a0)
return 0; return 0;
} }
int pcapdelay_setnonblock(pcap_t* a0, int a1, char* a2) int pcapdelay_setnonblock(pcap_t* a0, int a1, char* a2) {
{ typedef int (*PFN)(pcap_t*, int, char*);
typedef int(*PFN)(pcap_t*, int, char*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_setnonblock", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_setnonblock", (PFNVOID*)&pfn)))
return (*pfn)(a0, a1, a2); return (*pfn)(a0, a1, a2);
@ -128,9 +118,8 @@ int pcapdelay_setnonblock(pcap_t* a0, int a1, char* a2)
return 0; return 0;
} }
int pcapdelay_sendpacket(pcap_t* a0, u_char* a1, int a2) int pcapdelay_sendpacket(pcap_t* a0, u_char* a1, int a2) {
{ typedef int (*PFN)(pcap_t*, u_char*, int);
typedef int(*PFN)(pcap_t*, u_char*, int);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_sendpacket", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_sendpacket", (PFNVOID*)&pfn)))
return (*pfn)(a0, a1, a2); return (*pfn)(a0, a1, a2);
@ -138,8 +127,7 @@ int pcapdelay_sendpacket(pcap_t* a0, u_char* a1, int a2)
return 0; 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*); typedef const u_char*(*PFN)(pcap_t*, struct pcap_pkthdr*);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_next", (PFNVOID*)&pfn))) 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; return 0;
} }
int pcapdelay_dispatch(pcap_t* a0, int a1, pcap_handler a2, u_char* a3) 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 *);
typedef const int(*PFN)(pcap_t *, int, pcap_handler, u_char *);
static PFN pfn = 0; static PFN pfn = 0;
if ((pfn = (PFN)delay_load("pcap_dispatch", (PFNVOID*)&pfn))) if ((pfn = (PFN)delay_load("pcap_dispatch", (PFNVOID*)&pfn)))
return (*pfn)(a0, a1, a2, a3); return (*pfn)(a0, a1, a2, a3);

View File

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

View File

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

View File

@ -3,6 +3,6 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) 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 Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
#include "defc.h" #include "defc.h"
#include <stdarg.h> #include <stdarg.h>
@ -230,27 +230,27 @@ Cfg_menu g_cfg_uiless_menu[] = {
Cfg_menu g_cfg_disk_menu[] = { Cfg_menu g_cfg_disk_menu[] = {
{ "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU }, { "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU },
{ "s5d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x5000 }, { "s5d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x5000 },
{ "s5d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x5010 }, { "s5d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x5010 },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "s6d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x6000 }, { "s6d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x6000 },
{ "s6d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x6010 }, { "s6d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x6010 },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "s7d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x7000 }, { "s7d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x7000 },
{ "s7d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x7010 }, { "s7d2 = ", 0, 0, 0, CFGTYPE_DISK + 0x7010 },
{ "s7d3 = ", 0, 0, 0, CFGTYPE_DISK + 0x7020 }, { "s7d3 = ", 0, 0, 0, CFGTYPE_DISK + 0x7020 },
{ "s7d4 = ", 0, 0, 0, CFGTYPE_DISK + 0x7030 }, { "s7d4 = ", 0, 0, 0, CFGTYPE_DISK + 0x7030 },
{ "s7d5 = ", 0, 0, 0, CFGTYPE_DISK + 0x7040 }, { "s7d5 = ", 0, 0, 0, CFGTYPE_DISK + 0x7040 },
{ "s7d6 = ", 0, 0, 0, CFGTYPE_DISK + 0x7050 }, { "s7d6 = ", 0, 0, 0, CFGTYPE_DISK + 0x7050 },
{ "s7d7 = ", 0, 0, 0, CFGTYPE_DISK + 0x7060 }, { "s7d7 = ", 0, 0, 0, CFGTYPE_DISK + 0x7060 },
{ "s7d8 = ", 0, 0, 0, CFGTYPE_DISK + 0x7070 }, { "s7d8 = ", 0, 0, 0, CFGTYPE_DISK + 0x7070 },
{ "s7d9 = ", 0, 0, 0, CFGTYPE_DISK + 0x7080 }, { "s7d9 = ", 0, 0, 0, CFGTYPE_DISK + 0x7080 },
{ "s7d10 = ", 0, 0, 0, CFGTYPE_DISK + 0x7090 }, { "s7d10 = ", 0, 0, 0, CFGTYPE_DISK + 0x7090 },
{ "s7d11 = ", 0, 0, 0, CFGTYPE_DISK + 0x70a0 }, { "s7d11 = ", 0, 0, 0, CFGTYPE_DISK + 0x70a0 },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
// OG Use define instead of const for joystick_types // OG Use define instead of const for joystick_types
@ -258,215 +258,215 @@ Cfg_menu g_cfg_disk_menu[] = {
#define TOSTRING(x) STRINGIFY(x) #define TOSTRING(x) STRINGIFY(x)
Cfg_menu g_cfg_joystick_menu[] = { Cfg_menu g_cfg_joystick_menu[] = {
{ "Joystick Configuration", g_cfg_joystick_menu, 0, 0, CFGTYPE_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," { "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 }, 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 Scale X,0x100,Standard,0x119,+10%,0x133,+20%,"
"0x150,+30%,0xb0,-30%,0xcd,-20%,0xe7,-10%", "0x150,+30%,0xb0,-30%,0xcd,-20%,0xe7,-10%",
KNMP(g_joystick_scale_factor_x), CFGTYPE_INT }, 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%", "0x150,+30%,0xb0,-30%,0xcd,-20%,0xe7,-10%",
KNMP(g_joystick_scale_factor_y), CFGTYPE_INT }, KNMP(g_joystick_scale_factor_y), CFGTYPE_INT },
{ "Joystick Trim X", KNMP(g_joystick_trim_amount_x), CFGTYPE_INT }, { "Joystick Trim X", KNMP(g_joystick_trim_amount_x), CFGTYPE_INT },
{ "Joystick Trim Y", KNMP(g_joystick_trim_amount_y), 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", { "Swap Joystick X and Y,0,Normal operation,1,Paddle 1 and Paddle 0 swapped",
KNMP(g_swap_paddles), CFGTYPE_INT }, 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 }, KNMP(g_invert_paddles), CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_rom_menu[] = { Cfg_menu g_cfg_rom_menu[] = {
{ "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU }, { "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU },
{ "ROM File", KNMP(g_cfg_rom_path), CFGTYPE_FILE }, { "ROM File", KNMP(g_cfg_rom_path), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_host_menu[] = { Cfg_menu g_cfg_host_menu[] = {
{ "Host FST Configuration", g_cfg_host_menu, 0, 0, CFGTYPE_MENU }, { "Host FST Configuration", g_cfg_host_menu, 0, 0, CFGTYPE_MENU },
{ "Shared Host Folder", KNMP(g_cfg_host_path), CFGTYPE_DIR }, { "Shared Host Folder", KNMP(g_cfg_host_path), CFGTYPE_DIR },
{ "Read Only,0,No,1,Yes", KNMP(g_cfg_host_read_only), CFGTYPE_INT }, { "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 }, { "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 }, { "Merlin conversion,0,No,1,Yes", KNMP(g_cfg_host_merlin), CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_serial_menu[] = { 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 #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 }, 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 }, KNMP(g_serial_type[1]), CFGTYPE_INT },
#else #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 }, 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 }, KNMP(g_serial_type[1]), CFGTYPE_INT },
#endif #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 }, 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]), "incoming and outgoing emulation", KNMP(g_serial_modem[0]),
CFGTYPE_INT }, 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]), "incoming and outgoing emulation", KNMP(g_serial_modem[1]),
CFGTYPE_INT }, CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_parallel_menu[] = { Cfg_menu g_cfg_parallel_menu[] = {
{ "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU }, { "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU },
{ "Parallel Card in Slot 1,0,Off,1,On", { "Parallel Card in Slot 1,0,Off,1,On",
KNMP(g_parallel), CFGTYPE_INT }, 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 }, KNMP(g_parallel_out_masking), CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_ethernet_menu[] = { Cfg_menu g_cfg_ethernet_menu[] = {
{ "Ethernet Card Configuration", g_cfg_ethernet_menu, 0, 0, CFGTYPE_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", { "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 }, KNMP(g_ethernet_interface), CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Uthernet Card in Slot 3,0,Off,1,On", { "Uthernet Card in Slot 3,0,Off,1,On",
KNMP(g_ethernet), CFGTYPE_INT }, KNMP(g_ethernet), CFGTYPE_INT },
#ifdef HAVE_ATBRIDGE #ifdef HAVE_ATBRIDGE
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "AppleTalk Bridging,0,Off,1,On", { "AppleTalk Bridging,0,Off,1,On",
KNMP(g_appletalk_bridging), CFGTYPE_INT }, 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 }, KNMP(g_appletalk_turbo), CFGTYPE_INT },
#endif #endif
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
#ifdef HAVE_SDL #ifdef HAVE_SDL
Cfg_menu g_cfg_printer_menu[] = { Cfg_menu g_cfg_printer_menu[] = {
{ "Virtual Epson Configuration", g_cfg_printer_menu, 0, 0, CFGTYPE_MENU }, { "Virtual Epson Configuration", g_cfg_printer_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Printer Type,0,Epson LQ", { "Virtual Printer Type,0,Epson LQ",
KNMP(g_printer), CFGTYPE_INT }, 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 }, 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 }, 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 }, 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 }, KNMP(g_printer_timeout), CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Epson LQ Fonts", 0, 0, 0, 0 }, { "Epson LQ Fonts", 0, 0, 0, 0 },
{ "--------------", 0, 0, 0, 0 }, { "--------------", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Roman", KNMP(g_printer_font_roman), CFGTYPE_FILE }, { "Roman", KNMP(g_printer_font_roman), CFGTYPE_FILE },
{ "Sans Serif", KNMP(g_printer_font_sans), CFGTYPE_FILE }, { "Sans Serif", KNMP(g_printer_font_sans), CFGTYPE_FILE },
{ "Courier", KNMP(g_printer_font_courier), CFGTYPE_FILE }, { "Courier", KNMP(g_printer_font_courier), CFGTYPE_FILE },
{ "Prestige", KNMP(g_printer_font_prestige), CFGTYPE_FILE }, { "Prestige", KNMP(g_printer_font_prestige), CFGTYPE_FILE },
{ "Script", KNMP(g_printer_font_script), CFGTYPE_FILE }, { "Script", KNMP(g_printer_font_script), CFGTYPE_FILE },
{ "OCR A/B", KNMP(g_printer_font_ocra), CFGTYPE_FILE }, { "OCR A/B", KNMP(g_printer_font_ocra), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_imagewriter_menu[] = { Cfg_menu g_cfg_imagewriter_menu[] = {
{ "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU }, { "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU },
{ "Virtual Printer Type,0,ImageWriter II,1,ImageWriter LQ", { "Virtual Printer Type,0,ImageWriter II,1,ImageWriter LQ",
KNMP(g_imagewriter), CFGTYPE_INT }, 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 }, 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 }, 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 }, 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 }, 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 }, 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 }, KNMP(g_imagewriter_timeout), CFGTYPE_INT },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "ImageWriter Fonts", 0, 0, 0, 0 }, { "ImageWriter Fonts", 0, 0, 0, 0 },
{ "-----------------", 0, 0, 0, 0 }, { "-----------------", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Fixed Width Font", KNMP(g_imagewriter_fixed_font), CFGTYPE_FILE }, { "Fixed Width Font", KNMP(g_imagewriter_fixed_font), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Proportional Font", KNMP(g_imagewriter_prop_font), CFGTYPE_FILE }, { "Proportional Font", KNMP(g_imagewriter_prop_font), CFGTYPE_FILE },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
#endif #endif
Cfg_menu g_cfg_devel_menu[] = { 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) #if defined(_WIN32) || defined(__CYGWIN__) && !defined(WIN_SDL)
{ "Status lines,0,Hide,1,Show", KNMP(g_win_status_debug_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 }, { "Console,0,Hide,1,Show", KNMP(g_win_show_console_request), CFGTYPE_INT },
#endif #endif
#ifdef HAVE_ATBRIDGE #ifdef HAVE_ATBRIDGE
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Show AppleTalk Diagnostics,0,No,1,Yes", KNMP(g_appletalk_diagnostics), CFGTYPE_INT }, { "Show AppleTalk Diagnostics,0,No,1,Yes", KNMP(g_appletalk_diagnostics), CFGTYPE_INT },
{ "AppleTalk Network Hint", KNMP(g_appletalk_network_hint), CFGTYPE_INT }, { "AppleTalk Network Hint", KNMP(g_appletalk_network_hint), CFGTYPE_INT },
#endif #endif
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
#ifndef _WIN32 #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 #endif
{ "Code Red Halts,0,Do not stop on bad accesses,1,Enter debugger on bad accesses", KNMP(g_user_halt_bad), CFGTYPE_INT }, { "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 }, { "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 }, { "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 }, { "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 }, { "", 0, 0, 0, 0 },
{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
Cfg_menu g_cfg_main_menu[] = { Cfg_menu g_cfg_main_menu[] = {
{ "GSplus Configuration", g_cfg_main_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 }, { "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU },
{ "Joystick Configuration", g_cfg_joystick_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 }, { "ROM File Selection", g_cfg_rom_menu, 0, 0, CFGTYPE_MENU },
{ "HOST FST Configuration", g_cfg_host_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 }, { "Serial Port Configuration", g_cfg_serial_menu, 0, 0, CFGTYPE_MENU },
{ "Ethernet Card Configuration", g_cfg_ethernet_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 }, { "Parallel Card Configuration", g_cfg_parallel_menu, 0, 0, CFGTYPE_MENU },
#ifdef HAVE_SDL #ifdef HAVE_SDL
{ "Virtual Epson Configuration", g_cfg_printer_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 }, { "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU },
#endif #endif
{ "Developer Options", g_cfg_devel_menu, 0, 0, CFGTYPE_MENU }, { "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 }, { "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 }, { "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," { "Expansion Mem Size,0,0MB,0x100000,1MB,0x200000,2MB,0x300000,3MB,"
"0x400000,4MB,0x600000,6MB,0x800000,8MB,0xa00000,10MB,0xc00000,12MB," "0x400000,4MB,0x600000,6MB,0x800000,8MB,0xa00000,10MB,0xc00000,12MB,"
"0xe00000,14MB", KNMP(g_mem_size_exp), CFGTYPE_INT }, "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 #ifdef HAVE_SDL
{ "Reset Virtual ImageWriter", (void *)cfg_iwreset, 0, 0, CFGTYPE_FUNC }, { "Reset Virtual ImageWriter", (void *)cfg_iwreset, 0, 0, CFGTYPE_FUNC },
#endif #endif
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Save changes to configuration file", (void *)config_write_config_gsplus_file, 0, 0, { "Save changes to configuration file", (void *)config_write_config_gsplus_file, 0, 0,
CFGTYPE_FUNC }, CFGTYPE_FUNC },
{ "", 0, 0, 0, 0 }, { "", 0, 0, 0, 0 },
{ "Exit Config (or press F4)", (void *)cfg_exit, 0, 0, CFGTYPE_FUNC }, { "Exit Config (or press F4)", (void *)cfg_exit, 0, 0, CFGTYPE_FUNC },
{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 },
}; };
@ -490,7 +490,7 @@ Cfg_listhdr g_cfg_partitionlist = { 0 };
int g_cfg_file_pathfield = 0; int g_cfg_file_pathfield = 0;
const char *g_gsplus_rom_names[] = { "ROM", "ROM", "ROM01", "ROM03", "ROM.01", "ROM.03", 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_c1rom_names[] = { "parallel.rom", 0 };
const char *g_gsplus_c2rom_names[] = { 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, 0, g_gsplus_c1rom_names,
g_gsplus_c2rom_names, g_gsplus_c3rom_names, g_gsplus_c2rom_names, g_gsplus_c3rom_names,
g_gsplus_c4rom_names, g_gsplus_c5rom_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] = { byte g_rom_c600_rom01_diffs[256] = {
0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xe2, 0x00,
@ -542,9 +543,7 @@ byte g_rom_c600_rom01_diffs[256] = {
}; };
void void config_init_menus(Cfg_menu *menuptr) {
config_init_menus(Cfg_menu *menuptr)
{
void *voidptr; void *voidptr;
const char *name_str; const char *name_str;
Cfg_defval *defptr; Cfg_defval *defptr;
@ -606,9 +605,7 @@ config_init_menus(Cfg_menu *menuptr)
} }
} }
void void config_init() {
config_init()
{
int can_create; int can_create;
config_init_menus(g_cfg_main_menu); config_init_menus(g_cfg_main_menu);
@ -622,26 +619,20 @@ config_init()
config_parse_config_gsplus_file(); config_parse_config_gsplus_file();
} }
void void cfg_exit() {
cfg_exit()
{
if(g_rom_version >= 1) { if(g_rom_version >= 1) {
g_config_control_panel = 0; g_config_control_panel = 0;
} }
} }
void void cfg_toggle_config_panel() {
cfg_toggle_config_panel()
{
g_config_control_panel = !g_config_control_panel; g_config_control_panel = !g_config_control_panel;
if(g_rom_version < 0) { if(g_rom_version < 0) {
g_config_control_panel = 1; /* Stay in config mode */ g_config_control_panel = 1; /* Stay in config mode */
} }
} }
void void cfg_text_screen_dump() {
cfg_text_screen_dump()
{
char buf[85]; char buf[85];
char *filename; char *filename;
FILE *ofile; FILE *ofile;
@ -686,18 +677,14 @@ cfg_text_screen_dump()
} }
fclose(ofile); fclose(ofile);
} }
void void cfg_iwreset() {
cfg_iwreset()
{
imagewriter_feed(); imagewriter_feed();
imagewriter_close(); imagewriter_close();
imagewriter_init(g_imagewriter_dpi,g_imagewriter_paper,g_imagewriter_banner, g_imagewriter_output,g_imagewriter_multipage); imagewriter_init(g_imagewriter_dpi,g_imagewriter_paper,g_imagewriter_banner, g_imagewriter_output,g_imagewriter_multipage);
return; return;
} }
#ifdef HAVE_TFE #ifdef HAVE_TFE
void void cfg_get_tfe_name() {
cfg_get_tfe_name()
{
int i = 0; int i = 0;
char *ppname = NULL; char *ppname = NULL;
char *ppdes = NULL; char *ppdes = NULL;
@ -727,9 +714,7 @@ cfg_get_tfe_name()
} }
#endif #endif
void void config_vbl_update(int doit_3_persec) {
config_vbl_update(int doit_3_persec)
{
if(doit_3_persec) { if(doit_3_persec) {
if(g_config_gsplus_auto_update && g_config_gsplus_update_needed) { if(g_config_gsplus_auto_update && g_config_gsplus_update_needed) {
config_write_config_gsplus_file(); config_write_config_gsplus_file();
@ -738,9 +723,7 @@ config_vbl_update(int doit_3_persec)
return; return;
} }
void void config_parse_option(char *buf, int pos, int len, int line) {
config_parse_option(char *buf, int pos, int len, int line)
{
Cfg_menu *menuptr; Cfg_menu *menuptr;
Cfg_defval *defptr; Cfg_defval *defptr;
char *nameptr; char *nameptr;
@ -827,9 +810,7 @@ config_parse_option(char *buf, int pos, int len, int line)
} }
void void config_parse_bram(char *buf, int pos, int len) {
config_parse_bram(char *buf, int pos, int len)
{
int bram_num; int bram_num;
int offset; int offset;
int val; int val;
@ -862,9 +843,7 @@ config_parse_bram(char *buf, int pos, int len)
} }
} }
void void config_load_roms() {
config_load_roms()
{
struct stat stat_buf; struct stat stat_buf;
const char **names_ptr; const char **names_ptr;
int more_than_8mb; int more_than_8mb;
@ -1062,9 +1041,7 @@ config_load_roms()
} }
} }
void void config_parse_config_gsplus_file() {
config_parse_config_gsplus_file()
{
FILE *fconf; FILE *fconf;
char *buf; char *buf;
char *ptr; char *ptr;
@ -1169,7 +1146,7 @@ config_parse_config_gsplus_file()
if(buf[pos] == ',') { if(buf[pos] == ',') {
/* read optional size parameter */ /* read optional size parameter */
pos++; 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'; size = size * 10 + buf[pos] - '0';
pos++; pos++;
} }
@ -1225,9 +1202,7 @@ config_parse_config_gsplus_file()
} }
Disk * Disk *cfg_get_dsk_from_slot_drive(int slot, int drive) {
cfg_get_dsk_from_slot_drive(int slot, int drive)
{
Disk *dsk; Disk *dsk;
int max_drive; int max_drive;
@ -1252,10 +1227,8 @@ cfg_get_dsk_from_slot_drive(int slot, int drive)
return dsk; return dsk;
} }
void void config_generate_config_gsplus_name(char *outstr, int maxlen, Disk *dsk,
config_generate_config_gsplus_name(char *outstr, int maxlen, Disk *dsk, int with_extras) {
int with_extras)
{
char *str; char *str;
str = outstr; 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); snprintf(str, maxlen - (str - outstr), "%s", dsk->name_ptr);
} }
void void config_write_config_gsplus_file() {
config_write_config_gsplus_file()
{
FILE *fconf; FILE *fconf;
Disk *dsk; Disk *dsk;
Cfg_defval *defptr; Cfg_defval *defptr;
@ -1370,10 +1341,8 @@ config_write_config_gsplus_file()
g_config_gsplus_update_needed = 0; g_config_gsplus_update_needed = 0;
} }
void void insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
insert_disk(int slot, int drive, const char *name, int ejected, int force_size, const char *partition_name, int part_num) {
const char *partition_name, int part_num)
{
byte buf_2img[512]; byte buf_2img[512];
Disk *dsk; Disk *dsk;
char *name_ptr, *uncomp_ptr, *system_str; 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 void eject_named_disk(Disk *dsk, const char *name, const char *partition_name) {
eject_named_disk(Disk *dsk, const char *name, const char *partition_name)
{
if(!dsk->file) { if(!dsk->file) {
return; return;
@ -1723,9 +1690,7 @@ eject_named_disk(Disk *dsk, const char *name, const char *partition_name)
} }
} }
void void eject_disk_by_num(int slot, int drive) {
eject_disk_by_num(int slot, int drive)
{
Disk *dsk; Disk *dsk;
dsk = cfg_get_dsk_from_slot_drive(slot, drive); dsk = cfg_get_dsk_from_slot_drive(slot, drive);
@ -1733,9 +1698,7 @@ eject_disk_by_num(int slot, int drive)
eject_disk(dsk); eject_disk(dsk);
} }
void void eject_disk(Disk *dsk) {
eject_disk(Disk *dsk)
{
int motor_on; int motor_on;
int i; int i;
@ -1788,9 +1751,7 @@ eject_disk(Disk *dsk)
/* Leave name_ptr valid */ /* Leave name_ptr valid */
} }
int int cfg_get_fd_size(char *filename) {
cfg_get_fd_size(char *filename)
{
struct stat stat_buf; struct stat stat_buf;
int ret; int ret;
@ -1804,9 +1765,7 @@ cfg_get_fd_size(char *filename)
return stat_buf.st_size; return stat_buf.st_size;
} }
int int cfg_partition_read_block(FILE *file, void *buf, int blk, int blk_size) {
cfg_partition_read_block(FILE *file, void *buf, int blk, int blk_size)
{
int ret; int ret;
ret = fseek(file, blk * blk_size, SEEK_SET); 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; return ret;
} }
int int cfg_partition_find_by_name_or_num(FILE *file, const char *partnamestr, int part_num,
cfg_partition_find_by_name_or_num(FILE *file, const char *partnamestr, int part_num, Disk *dsk) {
Disk *dsk)
{
Cfg_dirent *direntptr; Cfg_dirent *direntptr;
int match; int match;
int num_parts; int num_parts;
@ -1868,9 +1825,7 @@ cfg_partition_find_by_name_or_num(FILE *file, const char *partnamestr, int part_
return -1; return -1;
} }
int int cfg_partition_make_list(char *filename, FILE *file) {
cfg_partition_make_list(char *filename, FILE *file)
{
Driver_desc *driver_desc_ptr; Driver_desc *driver_desc_ptr;
Part_map *part_map_ptr; Part_map *part_map_ptr;
word32 *blk_bufptr; word32 *blk_bufptr;
@ -1963,9 +1918,7 @@ cfg_partition_make_list(char *filename, FILE *file)
return g_cfg_partitionlist.last; return g_cfg_partitionlist.last;
} }
int int cfg_maybe_insert_disk(int slot, int drive, const char *namestr) {
cfg_maybe_insert_disk(int slot, int drive, const char *namestr)
{
int num_parts; int num_parts;
FILE *file; FILE *file;
@ -1988,9 +1941,7 @@ cfg_maybe_insert_disk(int slot, int drive, const char *namestr)
return 0; return 0;
} }
int int cfg_stat(char *path, struct stat *sb) {
cfg_stat(char *path, struct stat *sb)
{
int removed_slash; int removed_slash;
int len; int len;
int ret; int ret;
@ -2019,9 +1970,7 @@ cfg_stat(char *path, struct stat *sb)
return ret; return ret;
} }
void void cfg_htab_vtab(int x, int y) {
cfg_htab_vtab(int x, int y)
{
if(x > 79) { if(x > 79) {
x = 0; x = 0;
} }
@ -2034,9 +1983,7 @@ cfg_htab_vtab(int x, int y)
g_cfg_curs_mousetext = 0; g_cfg_curs_mousetext = 0;
} }
void void cfg_home() {
cfg_home()
{
int i; int i;
cfg_htab_vtab(0, 0); cfg_htab_vtab(0, 0);
@ -2045,9 +1992,7 @@ cfg_home()
} }
} }
void void cfg_cleol() {
cfg_cleol()
{
g_cfg_curs_inv = 0; g_cfg_curs_inv = 0;
g_cfg_curs_mousetext = 0; g_cfg_curs_mousetext = 0;
cfg_putchar(' '); cfg_putchar(' ');
@ -2056,9 +2001,7 @@ cfg_cleol()
} }
} }
void void cfg_putchar(int c) {
cfg_putchar(int c)
{
int offset; int offset;
int x, y; int x, y;
@ -2104,9 +2047,7 @@ cfg_putchar(int c)
g_cfg_curs_x = x; g_cfg_curs_x = x;
} }
void void cfg_printf(const char *fmt, ...) {
cfg_printf(const char *fmt, ...)
{
va_list ap; va_list ap;
int c; int c;
int i; int i;
@ -2124,9 +2065,7 @@ cfg_printf(const char *fmt, ...)
} }
} }
void void cfg_print_num(int num, int max_len) {
cfg_print_num(int num, int max_len)
{
char buf[64]; char buf[64];
char buf2[64]; char buf2[64];
int len; int len;
@ -2158,9 +2097,7 @@ cfg_print_num(int num, int max_len)
cfg_printf(&buf2[1]); cfg_printf(&buf2[1]);
} }
void void cfg_get_disk_name(char *outstr, int maxlen, int type_ext, int with_extras) {
cfg_get_disk_name(char *outstr, int maxlen, int type_ext, int with_extras)
{
Disk *dsk; Disk *dsk;
int slot, drive; 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); config_generate_config_gsplus_name(outstr, maxlen, dsk, with_extras);
} }
void void cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change) {
cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change)
{
char valbuf[CFG_OPT_MAXSTR]; char valbuf[CFG_OPT_MAXSTR];
char **str_ptr; char **str_ptr;
const char *menustr; 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; g_cfg_opt_buf[CFG_OPT_MAXSTR-1] = 0;
} }
void void cfg_get_base_path(char *pathptr, const char *inptr, int go_up) {
cfg_get_base_path(char *pathptr, const char *inptr, int go_up)
{
const char *tmpptr; const char *tmpptr;
char *slashptr; char *slashptr;
char *outptr; char *outptr;
@ -2551,9 +2484,7 @@ cfg_get_base_path(char *pathptr, const char *inptr, int go_up)
// pathptr, is_dotdot, add_dotdot); // pathptr, is_dotdot, add_dotdot);
} }
void void cfg_file_init() {
cfg_file_init()
{
int slot, drive; int slot, drive;
int i; int i;
@ -2587,9 +2518,7 @@ cfg_file_init()
g_cfg_dirlist.invalid = 1; g_cfg_dirlist.invalid = 1;
} }
void void cfg_free_alldirents(Cfg_listhdr *listhdrptr) {
cfg_free_alldirents(Cfg_listhdr *listhdrptr)
{
int i; int i;
if(listhdrptr->max > 0) { if(listhdrptr->max > 0) {
@ -2610,10 +2539,8 @@ cfg_free_alldirents(Cfg_listhdr *listhdrptr)
} }
void void cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir,
cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir, int size, int image_start, int part_num) {
int size, int image_start, int part_num)
{
Cfg_dirent *direntptr; Cfg_dirent *direntptr;
char *ptr; char *ptr;
int inc_amt; int inc_amt;
@ -2645,9 +2572,7 @@ cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir,
listhdrptr->last++; listhdrptr->last++;
} }
int int cfg_dirent_sortfn(const void *obj1, const void *obj2) {
cfg_dirent_sortfn(const void *obj1, const void *obj2)
{
const Cfg_dirent *direntptr1, *direntptr2; const Cfg_dirent *direntptr1, *direntptr2;
int ret; int ret;
@ -2664,9 +2589,7 @@ cfg_dirent_sortfn(const void *obj1, const void *obj2)
return ret; return ret;
} }
int int cfg_str_match(const char *str1, const char *str2, int len) {
cfg_str_match(const char *str1, const char *str2, int len)
{
const byte *bptr1, *bptr2; const byte *bptr1, *bptr2;
int c, c2; int c, c2;
int i; int i;
@ -2693,9 +2616,7 @@ cfg_str_match(const char *str1, const char *str2, int len)
return 0; return 0;
} }
void void cfg_file_readdir(const char *pathptr) {
cfg_file_readdir(const char *pathptr)
{
struct dirent *direntptr; struct dirent *direntptr;
struct stat stat_buf; struct stat stat_buf;
@ -2710,7 +2631,7 @@ cfg_file_readdir(const char *pathptr)
int i; int i;
if(!strncmp(pathptr, &g_cfg_file_cachedpath[0], CFG_PATH_MAX) && 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; return;
} }
// No match, must read new directory // No match, must read new directory
@ -2778,7 +2699,7 @@ cfg_file_readdir(const char *pathptr)
len = strlen(g_cfg_tmp_path); len = strlen(g_cfg_tmp_path);
is_dir = 0; is_dir = 0;
is_gz = 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; is_gz = 1;
} }
if(ret != 0) { if(ret != 0) {
@ -2825,14 +2746,12 @@ cfg_file_readdir(const char *pathptr)
} }
} }
void void cfg_inspect_maybe_insert_file(char *filename, int should_boot) {
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. 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. Used for blind operations like dragging/dropping files.
Optionally boot from that slot. Optionally boot from that slot.
*/ */
int rc = 0; int rc = 0;
int slot = 0; int slot = 0;
rc = cfg_guess_image_size(filename); 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); glogf("Unable to determine appropriate place to insert file %s.",filename);
} }
int int cfg_guess_image_size(char *filename) {
cfg_guess_image_size(char *filename)
{
/* /*
Guess the image size. Return values: Guess the image size. Return values:
-1 : invalid/unknown. Can't guess. -1 : invalid/unknown. Can't guess.
0 : Less than 140k; might be ram disk image. 0 : Less than 140k; might be ram disk image.
1 : 140k, 5.25" image. 1 : 140k, 5.25" image.
2 : 800k, 3.5" image. 2 : 800k, 3.5" image.
3 : Something bigger. 3 : Something bigger.
*/ */
struct stat stat_buf; struct stat stat_buf;
int rc = -1; int rc = -1;
int len; int len;
@ -2899,9 +2816,7 @@ Guess the image size. Return values:
return rc; return rc;
} }
char * char *cfg_shorten_filename(const char *in_ptr, int maxlen) {
cfg_shorten_filename(const char *in_ptr, int maxlen)
{
char *out_ptr; char *out_ptr;
int len; int len;
int c; int c;
@ -2932,9 +2847,7 @@ cfg_shorten_filename(const char *in_ptr, int maxlen)
} }
return out_ptr; return out_ptr;
} }
void void cfg_fix_topent(Cfg_listhdr *listhdrptr) {
cfg_fix_topent(Cfg_listhdr *listhdrptr)
{
int num_to_show; int num_to_show;
num_to_show = listhdrptr->num_to_show; num_to_show = listhdrptr->num_to_show;
/* Force curent and topent to make sense */ /* Force curent and topent to make sense */
@ -2954,9 +2867,7 @@ cfg_fix_topent(Cfg_listhdr *listhdrptr)
listhdrptr->topent = 0; listhdrptr->topent = 0;
} }
} }
void void cfg_file_draw() {
cfg_file_draw()
{
Cfg_listhdr *listhdrptr; Cfg_listhdr *listhdrptr;
Cfg_dirent *direntptr; Cfg_dirent *direntptr;
char *str, *fmt; char *str, *fmt;
@ -3059,9 +2970,7 @@ cfg_file_draw()
} }
cfg_putchar('\t'); cfg_putchar('\t');
} }
void void cfg_partition_selected() {
cfg_partition_selected()
{
char *str; char *str;
const char *part_str; const char *part_str;
char *part_str2; char *part_str2;
@ -3089,9 +2998,7 @@ cfg_partition_selected()
g_cfg_slotdrive = -1; g_cfg_slotdrive = -1;
g_cfg_select_partition = -1; g_cfg_select_partition = -1;
} }
void void cfg_file_update_ptr(char *str) {
cfg_file_update_ptr(char *str)
{
char *newstr; char *newstr;
int len; int len;
len = strlen(str) + 1; len = strlen(str) + 1;
@ -3109,9 +3016,7 @@ cfg_file_update_ptr(char *str)
} }
g_config_gsplus_update_needed = 1; g_config_gsplus_update_needed = 1;
} }
void void cfg_file_selected(int select_dir) {
cfg_file_selected(int select_dir)
{
struct stat stat_buf; struct stat stat_buf;
char *str; char *str;
int fmt; int fmt;
@ -3166,9 +3071,7 @@ cfg_file_selected(int select_dir)
} }
} }
void void cfg_file_handle_key(int key) {
cfg_file_handle_key(int key)
{
Cfg_listhdr *listhdrptr; Cfg_listhdr *listhdrptr;
int len; int len;
if(g_cfg_file_pathfield) { if(g_cfg_file_pathfield) {
@ -3249,9 +3152,7 @@ cfg_file_handle_key(int key)
} }
} }
void void config_control_panel() {
config_control_panel()
{
void (*fn_ptr)(); void (*fn_ptr)();
const char *str; const char *str;
Cfg_menu *menuptr; Cfg_menu *menuptr;
@ -3499,8 +3400,7 @@ config_control_panel()
g_a2_screen_buffer_changed = -1; g_a2_screen_buffer_changed = -1;
} }
void x_clk_setup_bram_version() void x_clk_setup_bram_version() {
{
if(g_rom_version < 3) { if(g_rom_version < 3) {
g_bram_ptr = (&g_bram[0][0]); // ROM 01 g_bram_ptr = (&g_bram[0][0]); // ROM 01
} else { } 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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/ioctl.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 */ /* socket debug version */
void void do_go_debug() {
do_go_debug()
{
while (1) { while (1) {
if (g_dbg_step >= 0) { if (g_dbg_step >= 0) {
if (g_dbg_step == 1) { if (g_dbg_step == 1) {
@ -293,9 +298,9 @@ void api_push_cpu() {
tmp_y = eptr->yreg; tmp_y = eptr->yreg;
tmp_psw = eptr->psr; 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\"}}", "\"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); char *msg = (char*)malloc(sizeof(char) * size);
strcpy(msg,tmp_buffer_4k); 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) { while (sscanf(bytes_data, "%02x", &byte) == 1) {
printf("$%02x <---- BYTE @ $%06X\n", byte, address ); printf("$%02x <---- BYTE @ $%06X\n", byte, address );
bytes_data += 2; bytes_data += 2;
address ++; address++;
set_byte_at_address(address, byte & 0xFF); set_byte_at_address(address, byte & 0xFF);
} }
} }
@ -791,7 +796,7 @@ void debug_setup_socket() {
/*************************************************************/ /*************************************************************/
/* Initialize the pollfd structure */ /* Initialize the pollfd structure */
/*************************************************************/ /*************************************************************/
memset(fds, 0 , sizeof(fds)); memset(fds, 0, sizeof(fds));
/*************************************************************/ /*************************************************************/
/* Set up the initial listening socket */ /* Set up the initial listening socket */
@ -865,10 +870,10 @@ void write_array_next() {
int writeDataToClient(int sckt, const void *data, int datalen) { int writeDataToClient(int sckt, const void *data, int datalen) {
const char *pdata = (const char*) data; const char *pdata = (const char*) data;
while (datalen > 0){ while (datalen > 0) {
int numSent = send(sckt, pdata, 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"); printf("The client was not written to: disconnected\n");
} else { } else {
perror("The client was not written to"); 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 // @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\"}}", "\"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); return(args+1);
} }

View File

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

120
src/dis.c
View File

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

View File

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

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
/* /*
* fbdriver - Linux fullscreen framebuffer graphics driver * fbdriver - Linux fullscreen framebuffer graphics driver
@ -203,8 +203,7 @@ int evfd[MAX_EVDEV], evdevs, termfd, fbfd = 0;
/* /*
* Clean up * Clean up
*/ */
void xdriver_end(void) void xdriver_end(void) {
{
char c; char c;
static char xexit = 0; static char xexit = 0;
if (!xexit) if (!xexit)
@ -231,8 +230,7 @@ void xdriver_end(void)
/* /*
* Init framebuffer and input * Init framebuffer and input
*/ */
void dev_video_init(void) void dev_video_init(void) {
{
int i; int i;
char evdevname[20]; char evdevname[20];
struct termios termio; struct termios termio;
@ -348,8 +346,7 @@ void dev_video_init(void)
*/ */
__u16 cmapred[256], cmapgreen[256], cmapblue[256]; __u16 cmapred[256], cmapgreen[256], cmapblue[256];
int cmapstart, cmaplen, cmapdirty = 0; 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); cmapred[col_num] = red | (red << 8);
cmapgreen[col_num] = green | (green << 8); cmapgreen[col_num] = green | (green << 8);
cmapblue[col_num] = blue | (blue << 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; cmaplen = col_num - cmapstart + 1;
} }
} }
void x_update_physical_colormap(void) void x_update_physical_colormap(void) {
{
struct fb_cmap fbcol; struct fb_cmap fbcol;
if (cmapdirty) if (cmapdirty)
{ {
@ -385,25 +381,21 @@ void x_update_physical_colormap(void)
ioctl(fbfd, FBIOPUTCMAP, &fbcol); ioctl(fbfd, FBIOPUTCMAP, &fbcol);
} }
} }
void show_xcolor_array(void) void show_xcolor_array(void) {
{
} }
/* /*
* Screen update * 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); 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->data_ptr)
if (kimage_ptr->width_req != 640 || kimage_ptr->height != 400) if (kimage_ptr->width_req != 640 || kimage_ptr->height != 400)
free(kimage_ptr->data_ptr); free(kimage_ptr->data_ptr);
kimage_ptr->data_ptr = NULL; 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; byte *src_ptr, *dst_ptr;
// Copy sub-image to framebuffer // 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; src_ptr += kimage_ptr->width_act * pix_size;
} }
} }
void x_push_done(void) void x_push_done(void) {
{
} }
/* /*
* NOP routines * 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... // Just write the config file already...
config_write_config_gsplus_file(); 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 // Not implemented yet
adb_all_keys_up(); adb_all_keys_up();
clear_fatal_logs(); clear_fatal_logs();
return 0; 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; return 1;
} }
void clipboard_paste(void) void clipboard_paste(void) {
{
} }
int clipboard_get_char(void) int clipboard_get_char(void) {
{
return 0; return 0;
} }
/* /*
* Input handling * Input handling
*/ */
void check_input_events(void) void check_input_events(void) {
{
struct input_event ev; struct input_event ev;
int i; 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(); xdriver_end();
exit (-1); exit (-1);
} }
/* /*
* Application entrypoint * Application entrypoint
*/ */
int main(int argc,char *argv[]) int main(int argc,char *argv[]) {
{
if (signal(SIGINT, sig_bye) == SIG_ERR) if (signal(SIGINT, sig_bye) == SIG_ERR)
exit(-1); exit(-1);
if (signal(SIGHUP, sig_bye) == SIG_ERR) 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 <stdio.h>
#include <time.h> #include <time.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -1,21 +1,9 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Based on the KEGS emulator written by Kent Dickey
This program is free software; you can redistribute it and/or modify it See COPYRIGHT.txt for Copyright information
under the terms of the GNU General Public License as published by the See LICENSE.txt for license (GPL v2)
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
*/
#include "defc.h" #include "defc.h"
#include "glog.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) 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 #define _BSD_SOURCE
@ -415,8 +418,7 @@ struct file_info {
byte finder_info[32]; byte finder_info[32];
}; };
static int hex(byte c) static int hex(byte c) {
{
if (c >= '0' && c <= '9') return c - '0'; 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';
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; fi->resource_blocks = (tmp + 511) / 512;
tmp = getxattr(path, XATTR_FINDERINFO_NAME, fi->finder_info, 32, 0, 0); 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; fi->has_fi = 1;
finder_info_to_filetype(fi->finder_info, &fi->file_type, &fi->aux_type); 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; fi->resource_blocks = (tmp + 511) / 512;
tmp = getxattr(path, "user.com.apple.FinderInfo", fi->finder_info, 32); 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; fi->has_fi = 1;
finder_info_to_filetype(fi->finder_info, &fi->file_type, &fi->aux_type); 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 *dot = NULL;
const char *slash = NULL; const char *slash = NULL;
for(n = 0; ; ++n) { for(n = 0;; ++n) {
char c = path[n]; char c = path[n];
if (c == 0) break; if (c == 0) break;
else if (c == '/') { slash = path + n + 1; dot = NULL; } 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 >= 5) set_memory16_c(pb + OpenRecGS_access, access, 0);
if (pcount >= 6) set_memory16_c(pb + OpenRecGS_fileType, fi.file_type, 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 >= 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 >= 9) set_date_time_rec(pb + OpenRecGS_createDateTime, fi.create_date);
if (pcount >= 10) set_date_time_rec(pb + OpenRecGS_modDateTime, fi.modified_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; return tooManyFilesOpen;
} }
if (type == regular_file){ if (type == regular_file) {
if (g_cfg_host_crlf) { if (g_cfg_host_crlf) {
if (fi.file_type == 0x04 || fi.file_type == 0xb0) 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) for (int i = 0; i < 256; ++i)
newline_table[i] = get_memory_c(global_buffer + 2 + i, 0); 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; byte b;
ok = safe_read(e, &b, 1); ok = safe_read(e, &b, 1);
if (ok < 0) return map_errno(); if (ok < 0) return map_errno();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,23 +1,9 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2010 - 2011 by GSport contributors Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey See LICENSE.txt for license (GPL v2)
*/
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
*/
/* /*
* Copyright (C) 2002-2004 The DOSBox Team * 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 Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
#include "defc.h" #include "defc.h"
#include "scc_llap.h" #include "scc_llap.h"
@ -81,9 +81,7 @@ static char* rr_names[] = {
int g_scc_overflow = 0; int g_scc_overflow = 0;
void void scc_init() {
scc_init()
{
Scc *scc_ptr; Scc *scc_ptr;
int i, j; int i, j;
@ -123,9 +121,7 @@ scc_init()
scc_reset(); scc_reset();
} }
void void scc_reset() {
scc_reset()
{
Scc *scc_ptr; Scc *scc_ptr;
int i; int i;
@ -153,9 +149,7 @@ scc_reset()
} }
} }
void void scc_hard_reset_port(int port) {
scc_hard_reset_port(int port)
{
Scc *scc_ptr; Scc *scc_ptr;
scc_reset_port(port); scc_reset_port(port);
@ -182,9 +176,7 @@ scc_hard_reset_port(int port)
scc_regen_clocks(port); scc_regen_clocks(port);
} }
void void scc_reset_port(int port) {
scc_reset_port(int port)
{
Scc *scc_ptr; Scc *scc_ptr;
scc_ptr = &(scc_stat[port]); scc_ptr = &(scc_stat[port]);
@ -215,9 +207,7 @@ scc_reset_port(int port)
scc_clr_rx_int(port); scc_clr_rx_int(port);
} }
void void scc_regen_clocks(int port) {
scc_regen_clocks(int port)
{
Scc *scc_ptr; Scc *scc_ptr;
double br_dcycs, tx_dcycs, rx_dcycs; double br_dcycs, tx_dcycs, rx_dcycs;
double rx_char_size, tx_char_size; double rx_char_size, tx_char_size;
@ -386,9 +376,7 @@ scc_regen_clocks(int port)
} }
void void scc_port_init(int port) {
scc_port_init(int port)
{
int state; int state;
state = 0; state = 0;
switch (g_serial_type[port]) { switch (g_serial_type[port]) {
@ -414,9 +402,7 @@ scc_port_init(int port)
} }
} }
void void scc_try_to_empty_writebuf(int port, double dcycs) {
scc_try_to_empty_writebuf(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int state; int state;
@ -453,9 +439,7 @@ scc_try_to_empty_writebuf(int port, double dcycs)
} }
} }
void void scc_try_fill_readbuf(int port, double dcycs) {
scc_try_fill_readbuf(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int space_used_before_rx, space_left; int space_used_before_rx, space_left;
int space_used_after_rx; 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; scc_ptr->lad += space_used_after_rx - space_used_before_rx;
} }
void void scc_update(double dcycs) {
scc_update(double dcycs)
{
if (g_appletalk_bridging && (scc_stat[0].state == 3 || scc_stat[1].state == 3)) if (g_appletalk_bridging && (scc_stat[0].state == 3 || scc_stat[1].state == 3))
scc_llap_update(); scc_llap_update();
@ -557,9 +539,7 @@ scc_update(double dcycs)
} }
} }
void void do_scc_event(int type, double dcycs) {
do_scc_event(int type, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int port; int port;
@ -585,9 +565,7 @@ do_scc_event(int type, double dcycs)
return; return;
} }
void void show_scc_state() {
show_scc_state()
{
Scc *scc_ptr; Scc *scc_ptr;
int i, j; int i, j;
@ -650,9 +628,7 @@ int g_scc_log_pos = 0;
#define SCC_REGNUM(wr,port,reg) ((wr << 8) + (port << 4) + reg) #define SCC_REGNUM(wr,port,reg) ((wr << 8) + (port << 4) + reg)
void void scc_log(int regnum, word32 val, double dcycs) {
scc_log(int regnum, word32 val, double dcycs)
{
int pos; int pos;
pos = g_scc_log_pos; pos = g_scc_log_pos;
@ -666,9 +642,7 @@ scc_log(int regnum, word32 val, double dcycs)
g_scc_log_pos = pos; g_scc_log_pos = pos;
} }
void void show_scc_log(void) {
show_scc_log(void)
{
double dcycs; double dcycs;
int regnum; int regnum;
int pos; 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 // 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 // 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. // 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; return 0;
} }
word32 word32 scc_read_reg(int port, double dcycs) {
scc_read_reg(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
word32 ret; word32 ret;
int regnum; int regnum;
@ -780,7 +751,7 @@ scc_read_reg(int port, double dcycs)
ret = scc_stat[0].reg[2]; ret = scc_stat[0].reg[2];
wr9 = scc_stat[0].reg[9]; wr9 = scc_stat[0].reg[9];
for(i = 0; i < 8; i++) { for(i = 0; i < 8; i++) {
if(ZZZ){}; if(ZZZ) {};
} }
if(wr9 & 0x10) { if(wr9 & 0x10) {
/* wr9 status high */ /* wr9 status high */
@ -831,9 +802,7 @@ scc_read_reg(int port, double dcycs)
return ret; return ret;
} }
void void scc_write_reg(int port, word32 val, double dcycs) {
scc_write_reg(int port, word32 val, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
word32 old_val; word32 old_val;
word32 changed_bits; word32 changed_bits;
@ -1174,9 +1143,7 @@ scc_write_reg(int port, word32 val, double dcycs)
} }
} }
void void scc_maybe_br_event(int port, double dcycs) {
scc_maybe_br_event(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
double br_dcycs; 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)); add_event_scc(dcycs + br_dcycs, SCC_MAKE_EVENT(port, SCC_BR_EVENT));
} }
void void scc_evaluate_ints(int port) {
scc_evaluate_ints(int port)
{
Scc *scc_ptr; Scc *scc_ptr;
word32 irq_add_mask, irq_remove_mask; word32 irq_add_mask, irq_remove_mask;
int mie; int mie;
@ -1257,9 +1222,7 @@ scc_evaluate_ints(int port)
} }
void void scc_maybe_rx_event(int port, double dcycs) {
scc_maybe_rx_event(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
double rx_dcycs; double rx_dcycs;
int in_rdptr, in_wrptr; 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)); add_event_scc(dcycs + rx_dcycs, SCC_MAKE_EVENT(port, SCC_RX_EVENT));
} }
void void scc_maybe_rx_int(int port, double dcycs) {
scc_maybe_rx_int(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int depth; int depth;
int rx_int_mode; int rx_int_mode;
@ -1338,16 +1299,12 @@ scc_maybe_rx_int(int port, double dcycs)
scc_evaluate_ints(port); scc_evaluate_ints(port);
} }
void void scc_clr_rx_int(int port) {
scc_clr_rx_int(int port)
{
scc_stat[port].wantint_rx = 0; scc_stat[port].wantint_rx = 0;
scc_evaluate_ints(port); scc_evaluate_ints(port);
} }
void void scc_handle_tx_event(int port, double dcycs) {
scc_handle_tx_event(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int tx_int_mode; int tx_int_mode;
@ -1361,9 +1318,7 @@ scc_handle_tx_event(int port, double dcycs)
scc_evaluate_ints(port); scc_evaluate_ints(port);
} }
void void scc_maybe_tx_event(int port, double dcycs) {
scc_maybe_tx_event(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
double tx_dcycs; double tx_dcycs;
@ -1382,16 +1337,12 @@ scc_maybe_tx_event(int port, double dcycs)
} }
} }
void void scc_clr_tx_int(int port) {
scc_clr_tx_int(int port)
{
scc_stat[port].wantint_tx = 0; scc_stat[port].wantint_tx = 0;
scc_evaluate_ints(port); scc_evaluate_ints(port);
} }
void void scc_set_zerocnt_int(int port) {
scc_set_zerocnt_int(int port)
{
Scc *scc_ptr; Scc *scc_ptr;
scc_ptr = &(scc_stat[port]); scc_ptr = &(scc_stat[port]);
@ -1402,16 +1353,12 @@ scc_set_zerocnt_int(int port)
scc_evaluate_ints(port); scc_evaluate_ints(port);
} }
void void scc_clr_zerocnt_int(int port) {
scc_clr_zerocnt_int(int port)
{
scc_stat[port].wantint_zerocnt = 0; scc_stat[port].wantint_zerocnt = 0;
scc_evaluate_ints(port); scc_evaluate_ints(port);
} }
void void scc_add_to_readbuf(int port, word32 val, double dcycs) {
scc_add_to_readbuf(int port, word32 val, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int in_wrptr; int in_wrptr;
int in_wrptr_next; int in_wrptr_next;
@ -1440,9 +1387,7 @@ scc_add_to_readbuf(int port, word32 val, double dcycs)
scc_maybe_rx_event(port, dcycs); scc_maybe_rx_event(port, dcycs);
} }
void void scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...) {
scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...)
{
va_list ap; va_list ap;
char *bufptr; char *bufptr;
int len, c; int len, c;
@ -1463,9 +1408,7 @@ scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void scc_transmit(int port, word32 val, double dcycs) {
scc_transmit(int port, word32 val, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int out_wrptr; int out_wrptr;
int out_rdptr; int out_rdptr;
@ -1504,9 +1447,7 @@ scc_transmit(int port, word32 val, double dcycs)
scc_add_to_writebuf(port, val, dcycs); scc_add_to_writebuf(port, val, dcycs);
} }
void void scc_add_to_writebuf(int port, word32 val, double dcycs) {
scc_add_to_writebuf(int port, word32 val, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
int out_wrptr; int out_wrptr;
int out_wrptr_next; int out_wrptr_next;
@ -1542,9 +1483,7 @@ scc_add_to_writebuf(int port, word32 val, double dcycs)
} }
} }
word32 word32 scc_read_data(int port, double dcycs) {
scc_read_data(int port, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
word32 ret; word32 ret;
int depth; int depth;
@ -1588,9 +1527,7 @@ scc_read_data(int port, double dcycs)
} }
void void scc_write_data(int port, word32 val, double dcycs) {
scc_write_data(int port, word32 val, double dcycs)
{
Scc *scc_ptr; Scc *scc_ptr;
scc_printf("SCC write %04x: %02x\n", 0xc03b-port, val); 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 Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
/* This is an interface between the SCC emulation and the Virtual Imagewriter. */ /* 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 imagewriter_port_block = 0;
int iw_scc_write = 0; int iw_scc_write = 0;
int scc_imagewriter_init(int port) int scc_imagewriter_init(int port) {
{
Scc *scc_ptr; Scc *scc_ptr;
scc_ptr = &(scc_stat[port]); scc_ptr = &(scc_stat[port]);
imagewriter_init(g_imagewriter_dpi,g_imagewriter_paper,g_imagewriter_banner,g_imagewriter_output,g_imagewriter_multipage); 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 **/ /** 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) if (iw_scc_write)
{ {
size_t bytes_read; 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. **/ /** 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; Scc* scc_ptr;
int rdptr; 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 //application doesn't send a form feed at the end of the page. It also
//allows multipage mode Postscript and native printer documents to //allows multipage mode Postscript and native printer documents to
//print somewhat how a regular application would. //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) if (imagewriter_port_block != 1 && imagewriter_vbl_count != 0 && g_vbl_count >= imagewriter_vbl_count)
{ {
printf("Calling imagewriter_update and flushing!\n"); printf("Calling imagewriter_update and flushing!\n");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
#include "defc.h" #include "defc.h"
#include "glog.h" #include "glog.h"
@ -35,9 +35,7 @@ STRUCT(Smpt_log) {
Smpt_log g_smpt_log[LEN_SMPT_LOG]; Smpt_log g_smpt_log[LEN_SMPT_LOG];
int g_smpt_log_pos = 0; int g_smpt_log_pos = 0;
void void smartport_error(void) {
smartport_error(void)
{
int pos; int pos;
int i; int i;
@ -61,9 +59,7 @@ smartport_error(void)
g_smpt_log[pos].blk); g_smpt_log[pos].blk);
} }
} }
void void smartport_log(word32 start_addr, int cmd, int rts_addr, int cmd_list) {
smartport_log(word32 start_addr, int cmd, int rts_addr, int cmd_list)
{
int pos; int pos;
pos = g_smpt_log_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; g_smpt_log_pos = pos;
} }
void void do_c70d(word32 arg0) {
do_c70d(word32 arg0)
{
int cmd; int cmd;
int cmd_list_lo, cmd_list_mid, cmd_list_hi; int cmd_list_lo, cmd_list_mid, cmd_list_hi;
int rts_lo, rts_hi; int rts_lo, rts_hi;
@ -203,7 +197,7 @@ do_c70d(word32 arg0)
return; return;
} else if(unit > 0 && status_code == 0) { } else if(unit > 0 && status_code == 0) {
/* status for unit x */ /* 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; stat_val = 0x80;
size = 0; size = 0;
} else { } else {
@ -227,7 +221,7 @@ do_c70d(word32 arg0)
disk_printf("just finished unit %d, stat 0\n", unit); disk_printf("just finished unit %d, stat 0\n", unit);
return; return;
} else if(status_code == 3) { } 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; stat_val = 0x80;
size = 0; size = 0;
} else { } else {
@ -442,9 +436,7 @@ do_c70d(word32 arg0)
cmd, cmd_list, rts_addr); cmd, cmd_list, rts_addr);
} }
void void do_c70a(word32 arg0) {
do_c70a(word32 arg0)
{
int cmd, unit; int cmd, unit;
int buf_lo, buf_hi; int buf_lo, buf_hi;
int blk_lo, blk_hi; int blk_lo, blk_hi;
@ -513,9 +505,7 @@ do_c70a(word32 arg0)
return; return;
} }
int int do_read_c7(int unit_num, word32 buf, int blk) {
do_read_c7(int unit_num, word32 buf, int blk)
{
byte local_buf[0x200]; byte local_buf[0x200];
register word32 start_time; register word32 start_time;
register word32 end_time; register word32 end_time;
@ -593,9 +583,7 @@ do_read_c7(int unit_num, word32 buf, int blk)
} }
int int do_write_c7(int unit_num, word32 buf, int blk) {
do_write_c7(int unit_num, word32 buf, int blk)
{
word32 local_buf[0x200/4]; word32 local_buf[0x200/4];
Disk *dsk; Disk *dsk;
word32 *ptr; word32 *ptr;
@ -674,9 +662,7 @@ do_write_c7(int unit_num, word32 buf, int blk)
} }
int int do_format_c7(int unit_num) {
do_format_c7(int unit_num)
{
byte local_buf[0x1000]; byte local_buf[0x1000];
Disk *dsk; Disk *dsk;
FILE *file; FILE *file;
@ -749,9 +735,7 @@ extern byte* g_bram_ptr;
extern byte g_temp_boot_slot; extern byte g_temp_boot_slot;
extern byte g_orig_boot_slot; extern byte g_orig_boot_slot;
extern int g_config_gsplus_update_needed; extern int g_config_gsplus_update_needed;
void void do_c700(word32 ret) {
do_c700(word32 ret)
{
disk_printf("do_c700 called, ret: %08x\n", ret); disk_printf("do_c700 called, ret: %08x\n", ret);
if (g_temp_boot_slot != 254) { 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. // 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 Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
#include "defc.h" #include "defc.h"
#include "sound.h" #include "sound.h"
@ -106,9 +106,7 @@ int g_doc_log_pos = 0;
#define SND_PTR_SHIFT 14 #define SND_PTR_SHIFT 14
#define SND_PTR_SHIFT_DBL ((double)(1 << SND_PTR_SHIFT)) #define SND_PTR_SHIFT_DBL ((double)(1 << SND_PTR_SHIFT))
void void doc_log_rout(char *msg, int osc, double dsamps, int etc) {
doc_log_rout(char *msg, int osc, double dsamps, int etc)
{
int pos; int pos;
pos = g_doc_log_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; extern double g_cur_dcycs;
void void show_doc_log(void) {
show_doc_log(void)
{
FILE *docfile; FILE *docfile;
Doc_reg *rptr; Doc_reg *rptr;
double dsamp_start; double dsamp_start;
@ -189,9 +185,7 @@ show_doc_log(void)
fclose(docfile); fclose(docfile);
} }
void void sound_init() {
sound_init()
{
Doc_reg *rptr; Doc_reg *rptr;
int i; int i;
@ -247,9 +241,7 @@ sound_init()
} }
void void sound_init_general() {
sound_init_general()
{
/* Workaround - gcc in cygwin wasn't defining _WIN32 */ /* Workaround - gcc in cygwin wasn't defining _WIN32 */
#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL) #if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL)
@ -373,9 +365,7 @@ sound_init_general()
} }
void void parent_sound_get_sample_rate(int read_fd) {
parent_sound_get_sample_rate(int read_fd)
{
word32 tmp; word32 tmp;
int ret; int ret;
@ -390,9 +380,7 @@ parent_sound_get_sample_rate(int read_fd)
set_audio_rate(tmp); set_audio_rate(tmp);
} }
void void set_audio_rate(int rate) {
set_audio_rate(int rate)
{
g_audio_rate = rate; g_audio_rate = rate;
g_daudio_rate = (rate)*1.0; g_daudio_rate = (rate)*1.0;
g_drecip_audio_rate = 1.0/(rate); 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); g_fsamps_per_dcyc = (float)((rate*1.0) / DCYCS_1_MHZ);
} }
void void sound_reset(double dcycs) {
sound_reset(double dcycs)
{
double dsamps; double dsamps;
int i; int i;
@ -429,9 +415,7 @@ sound_reset(double dcycs)
*/ */
} }
void void sound_shutdown() {
sound_shutdown()
{
// OG stop sound and free memory on sound_shutdown // OG stop sound and free memory on sound_shutdown
sound_reset(g_cur_dcycs); sound_reset(g_cur_dcycs);
@ -458,9 +442,7 @@ sound_shutdown()
void void sound_update(double dcycs) {
sound_update(double dcycs)
{
double dsamps; double dsamps;
/* Called every VBL time to update sound status */ /* 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_sound_to_file = 0;
int g_send_file_bytes = 0; int g_send_file_bytes = 0;
void void open_sound_file() {
open_sound_file()
{
char name[256]; char name[256];
FILE *fd; FILE *fd;
@ -523,9 +503,7 @@ open_sound_file()
g_send_file_bytes = 0; g_send_file_bytes = 0;
} }
void void close_sound_file() {
close_sound_file()
{
if(g_sound_file_fd != 0) { if(g_sound_file_fd != 0) {
fclose(g_sound_file_fd); fclose(g_sound_file_fd);
} }
@ -533,9 +511,7 @@ close_sound_file()
g_sound_file_fd = 0; g_sound_file_fd = 0;
} }
void void check_for_range(word32 *addr, int num_samps, int offset) {
check_for_range(word32 *addr, int num_samps, int offset)
{
short *shortptr; short *shortptr;
int i; int i;
int left; 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); printf("check4 max: %d over %d\n", max, num_samps);
} }
void void send_sound_to_file(word32 *addr, int shm_pos, int num_samps) {
send_sound_to_file(word32 *addr, int shm_pos, int num_samps)
{
int size; int size;
int ret; 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 // is called with real_samps = 1 to output sound
void void send_sound(int real_samps, int size) {
send_sound(int real_samps, int size)
{
// real_samps = 1, size = 1602 // real_samps = 1, size = 1602
word32 tmp; word32 tmp;
@ -651,13 +623,11 @@ send_sound(int real_samps, int size)
#endif #endif
} }
void show_c030_state() void show_c030_state() {
{
show_c030_samps(&(g_samp_buf[0]), 100); 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; int i;
printf("c030_fsamps[]: %d\n", g_num_c030_fsamps); 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 start_time1, start_time2, start_time3, start_time4;
register word32 end_time1, end_time2, end_time3; register word32 end_time1, end_time2, end_time3;
Doc_reg *rptr; 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_hi_val = ((VAL_C030_BASE + VAL_C030_RANGE)*g_doc_vol) >> 4;
c030_lo_val = (VAL_C030_BASE * 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_range = (float)(((VAL_C030_RANGE) *g_doc_vol) >> 4);
fc030_base = (float)(((VAL_C030_BASE) * g_doc_vol) >> 4); fc030_base = (float)(((VAL_C030_BASE) *g_doc_vol) >> 4);
val = c030_lo_val; val = c030_lo_val;
if(c030_state) { if(c030_state) {
@ -1138,9 +1107,7 @@ void sound_play(double dsamps)
} }
void void doc_handle_event(int osc, double dcycs) {
doc_handle_event(int osc, double dcycs)
{
double dsamps; double dsamps;
/* handle osc stopping and maybe interrupting */ /* handle osc stopping and maybe interrupting */
@ -1157,9 +1124,7 @@ doc_handle_event(int osc, double dcycs)
} }
void void doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps) {
doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps)
{
Doc_reg *rptr, *orptr; Doc_reg *rptr, *orptr;
int mode, omode; int mode, omode;
int other_osc; int other_osc;
@ -1236,9 +1201,7 @@ doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps)
return; return;
} }
void void add_sound_irq(int osc) {
add_sound_irq(int osc)
{
int num_osc_interrupting; int num_osc_interrupting;
if(g_doc_regs[osc].has_irq_pending) { 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); DOC_LOG("add_irq", osc, g_cur_dcycs * g_dsamps_per_dcyc, 0);
} }
void void remove_sound_irq(int osc, int must) {
remove_sound_irq(int osc, int must)
{
Doc_reg *rptr; Doc_reg *rptr;
int num_osc_interrupt; int num_osc_interrupt;
int has_irq_pending; int has_irq_pending;
@ -1328,9 +1289,7 @@ remove_sound_irq(int osc, int must)
} }
} }
void void start_sound(int osc, double eff_dsamps, double dsamps) {
start_sound(int osc, double eff_dsamps, double dsamps)
{
register word32 start_time1; register word32 start_time1;
register word32 end_time1; register word32 end_time1;
Doc_reg *rptr; 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); g_cycs_in_start_sound += (end_time1 - start_time1);
} }
void void wave_end_estimate(int osc, double eff_dsamps, double dsamps) {
wave_end_estimate(int osc, double eff_dsamps, double dsamps)
{
register word32 start_time1; register word32 start_time1;
register word32 end_time1; register word32 end_time1;
Doc_reg *rptr; Doc_reg *rptr;
@ -1490,9 +1447,7 @@ wave_end_estimate(int osc, double eff_dsamps, double dsamps)
} }
void void remove_sound_event(int osc) {
remove_sound_event(int osc)
{
if(g_doc_regs[osc].event) { if(g_doc_regs[osc].event) {
g_doc_regs[osc].event = 0; g_doc_regs[osc].event = 0;
remove_event_doc(osc); remove_event_doc(osc);
@ -1500,9 +1455,7 @@ remove_sound_event(int osc)
} }
void void doc_write_ctl_reg(int osc, int val, double dsamps) {
doc_write_ctl_reg(int osc, int val, double dsamps)
{
Doc_reg *rptr; Doc_reg *rptr;
double eff_dsamps; double eff_dsamps;
word32 old_halt; word32 old_halt;
@ -1601,9 +1554,7 @@ doc_write_ctl_reg(int osc, int val, double dsamps)
} }
} }
void void doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps) {
doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps)
{
Doc_reg *rptr; Doc_reg *rptr;
double dfreq; double dfreq;
double dtmp1; 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); DOC_LOG("recalc", osc, dsamps, (rptr->waveptr << 16) + wave_size);
} }
int int doc_read_c030(double dcycs) {
doc_read_c030(double dcycs)
{
int num; int num;
num = g_num_c030_fsamps; num = g_num_c030_fsamps;
@ -1665,15 +1614,11 @@ doc_read_c030(double dcycs)
return 0; return 0;
} }
int int doc_read_c03c(double dcycs) {
doc_read_c03c(double dcycs)
{
return doc_sound_ctl; return doc_sound_ctl;
} }
int int doc_read_c03d(double dcycs) {
doc_read_c03d(double dcycs)
{
double dsamps; double dsamps;
Doc_reg *rptr; Doc_reg *rptr;
int osc; int osc;
@ -1766,9 +1711,7 @@ doc_read_c03d(double dcycs)
return ret; return ret;
} }
void void doc_write_c03c(int val, double dcycs) {
doc_write_c03c(int val, double dcycs)
{
int vol; int vol;
vol = val & 0xf; vol = val & 0xf;
@ -1785,9 +1728,7 @@ doc_write_c03c(int val, double dcycs)
doc_sound_ctl = val; doc_sound_ctl = val;
} }
void void doc_write_c03d(int val, double dcycs) {
doc_write_c03d(int val, double dcycs)
{
double dsamps; double dsamps;
double eff_dsamps; double eff_dsamps;
Doc_reg *rptr; Doc_reg *rptr;
@ -1966,9 +1907,7 @@ doc_write_c03d(int val, double dcycs)
doc_saved_val = val; doc_saved_val = val;
} }
void void doc_show_ensoniq_state(int osc) {
doc_show_ensoniq_state(int osc)
{
Doc_reg *rptr; Doc_reg *rptr;
int i; int i;

View File

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

View File

@ -26,8 +26,6 @@
*/ */
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -63,7 +61,7 @@
/* /*
This variable is used when we need to postpone the initialization This variable is used when we need to postpone the initialization
because tfe_init() is not yet called because tfe_init() is not yet called
*/ */
static int should_activate = 0; static int should_activate = 0;
static int init_tfe_flag = 0; static int init_tfe_flag = 0;
typedef signed int log_t; typedef signed int log_t;
@ -75,7 +73,7 @@ static log_t tfe_log = LOG_ERR;
/* status which received packages to accept /* status which received packages to accept
This is used in tfe_should_accept(). This is used in tfe_should_accept().
*/ */
static byte tfe_ia_mac[6] = { 0,0,0,0,0,0 }; static byte tfe_ia_mac[6] = { 0,0,0,0,0,0 };
/* remember the value of the hash mask */ /* 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 REMARK: The TFE operatoes the cs8900a in IO space configuration, as
it generates I/OW and I/OR signals. it generates I/OW and I/OR signals.
*/ */
#define TFE_COUNT_IO_REGISTER 0x10 /* we have 16 I/O register */ #define TFE_COUNT_IO_REGISTER 0x10 /* we have 16 I/O register */
static byte *tfe = NULL; 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_PTR = DE0A/DE0B (PacketPage Pointer) (see. page 75p: Read -011.---- ----.----)
RW: PP_DATA0 = DE0C/DE0D (PacketPage Data (Port 0)) RW: PP_DATA0 = DE0C/DE0D (PacketPage Data (Port 0))
RW: PP_DATA1 = DE0E/DE0F (PacketPage Data (Port 1)) (for 32 bit only) RW: PP_DATA1 = DE0E/DE0F (PacketPage Data (Port 1)) (for 32 bit only)
*/ */
#define TFE_ADDR_RXTXDATA 0x00 /* RW */ #define TFE_ADDR_RXTXDATA 0x00 /* RW */
#define TFE_ADDR_RXTXDATA2 0x02 /* RW 32 bit only! */ #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 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 #define MAXLEN_DEBUG 1600
int i; int i;
@ -332,7 +329,7 @@ static char *debug_outbuffer(const int length, const unsigned char * const buffe
if (i>=length) if (i>=length)
break; 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; p+=3;
} }
@ -344,8 +341,7 @@ static char *debug_outbuffer(const int length, const unsigned char * const buffe
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* initialization and deinitialization functions */ /* 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); word16 old_status = GET_PP_16(TFE_PP_ADDR_SE_BUSST);
/* mask out TxBidErr and Rdy4TxNOW */ /* 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_enabled = enabled;
rx_state = TFE_RX_IDLE; rx_state = TFE_RX_IDLE;
rxevent_read_mask = 3; /* was L or H byte read in RXEVENT? */ 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_enabled = enabled;
tx_state = TFE_TX_IDLE; tx_state = TFE_TX_IDLE;
tfe_set_tx_status(0,0); tfe_set_tx_status(0,0);
} }
void tfe_reset(void) void tfe_reset(void) {
{
if (tfe_enabled && !should_activate) if (tfe_enabled && !should_activate)
{ {
int i; int i;
@ -446,7 +439,7 @@ void tfe_reset(void)
/* spec: mac address is undefined after reset. /* spec: mac address is undefined after reset.
real HW: keeps the last set address. */ 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]); SET_PP_8(TFE_PP_ADDR_MAC_ADDR+i,tfe_ia_mac[i]);
/* reset state */ /* reset state */
@ -460,8 +453,7 @@ void tfe_reset(void)
} }
#ifdef DOS_TFE #ifdef DOS_TFE
static void set_standard_tfe_interface(void) static void set_standard_tfe_interface(void) {
{
char *dev, errbuf[PCAP_ERRBUF_SIZE]; char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf); dev = pcap_lookupdev(errbuf);
util_string_set(&tfe_interface, dev); util_string_set(&tfe_interface, dev);
@ -469,8 +461,7 @@ static void set_standard_tfe_interface(void)
#endif #endif
static static
int tfe_activate_i(void) int tfe_activate_i(void) {
{
assert( tfe == NULL ); assert( tfe == NULL );
assert( tfe_packetpage == NULL ); assert( tfe_packetpage == NULL );
@ -528,8 +519,7 @@ int tfe_activate_i(void)
} }
static static
int tfe_deactivate_i(void) int tfe_deactivate_i(void) {
{
#ifdef TFE_DEBUG #ifdef TFE_DEBUG
log_message( tfe_log, "tfe_deactivate_i()." ); log_message( tfe_log, "tfe_deactivate_i()." );
#endif #endif
@ -576,8 +566,7 @@ int tfe_deactivate(void) {
return 0; return 0;
} }
void tfe_init(void) void tfe_init(void) {
{
tfe_enabled = 1; tfe_enabled = 1;
init_tfe_flag = 1; init_tfe_flag = 1;
should_activate = 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)); assert( (tfe && tfe_packetpage) || (!tfe && !tfe_packetpage));
if (tfe) if (tfe)
@ -611,19 +599,19 @@ void tfe_shutdown(void)
/* reading and writing TFE register functions */ /* 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_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_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_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_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_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_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_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_MAC_ADDR 0x0158 * # RW - 4.6., p. 71 - 5.3., p. 86 *
0x015a 0x015a
0x015c 0x015c
*/ */
#ifdef TFE_DEBUG_FRAMES #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_; \ 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; \ 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 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. 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 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) */ int hashreg; /* Hash Register (for hash computation) */
assert(length>=6); /* we need at least 6 octets since the DA has this length */ 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 */ /* now check if DA passes the hash filter */
hashreg = (~crc32_buf((char *)buffer,6) >> 26) & 0x3F; 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) { if (*phashed) {
*phash_index = hashreg; *phash_index = hashreg;
@ -729,8 +716,7 @@ int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phas
#endif #endif
static static
word16 tfe_receive(void) word16 tfe_receive(void) {
{
word16 ret_val = 0x0004; word16 ret_val = 0x0004;
byte buffer[MAX_RXLENGTH]; byte buffer[MAX_RXLENGTH];
@ -751,7 +737,7 @@ word16 tfe_receive(void)
do { do {
len = MAX_RXLENGTH; 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( newframe = tfe_arch_receive(
buffer, /* where to store a frame */ 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 relevant parts of the PP area to correct values */
SET_PP_16(TFE_PP_ADDR_RXLENGTH, len); 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]); SET_PP_8(TFE_PP_ADDR_RX_FRAMELOC+i, buffer[i]);
} }
@ -855,8 +841,7 @@ word16 tfe_receive(void)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* TX/RX buffer handling */ /* 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 */ /* write tx data only if valid buffer is ready */
if(tx_state != TFE_TX_READ_BUSST) { if(tx_state != TFE_TX_READ_BUSST) {
#ifdef TFE_DEBUG_WARN_RXTX #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) { if(rx_state != TFE_RX_GOT_FRAME) {
#ifdef TFE_DEBUG_WARN_RXTX #ifdef TFE_DEBUG_WARN_RXTX
log_message(tfe_log, "WARNING! RX Read without frame available! (odd=%d)", 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 - TFE_PP_ADDR_RX_FRAMELOC+4: proceed -
*/ */
word16 addr = odd_address ? 1:0; word16 addr = odd_address ? 1 : 0;
byte value; byte value;
/* read RXSTATUS or RX_LENGTH */ /* read RXSTATUS or RX_LENGTH */
if(rx_count<4) { 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 This is called *after* the relevant octets are written
*/ */
static 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" }; // const char *on_off[2] = { "on","off" };
//#define on_off_str(x) ((x) ? on_off[0] : on_off[1]) //#define on_off_str(x) ((x) ? on_off[0] : on_off[1])
word16 content = GET_PP_16( ppaddress ); 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 This is called *before* the relevant octets are read
*/ */
static static
void tfe_sideeffects_read_pp(word16 ppaddress,int odd_address) void tfe_sideeffects_read_pp(word16 ppaddress,int odd_address) {
{
switch (ppaddress) switch (ppaddress)
{ {
case TFE_PP_ADDR_SE_RXEVENT: 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/write from packet page register */
/* read a register from packet page */ /* 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); word16 value = GET_PP_16(ppaddress);
/* --- check the register address --- */ /* --- check the register address --- */
@ -1282,7 +1263,7 @@ static word16 tfe_read_register(word16 ppaddress)
else if(ppaddress<0x120) { else if(ppaddress<0x120) {
word16 regNum = ppaddress - 0x100; word16 regNum = ppaddress - 0x100;
regNum &= ~1; regNum &= ~1;
regNum ++; regNum++;
#ifdef TFE_DEBUG_REGISTERS #ifdef TFE_DEBUG_REGISTERS
log_message(tfe_log, log_message(tfe_log,
"Read Control Register %04x: %04x (reg=%02x)", "Read Control Register %04x: %04x (reg=%02x)",
@ -1413,8 +1394,7 @@ static word16 tfe_read_register(word16 ppaddress)
return value; return value;
} }
void tfe_write_register(word16 ppaddress,word16 value) void tfe_write_register(word16 ppaddress,word16 value) {
{
/* --- write bus interface register range --- */ /* --- write bus interface register range --- */
if(ppaddress<0x100) { if(ppaddress<0x100) {
int ignore = 0; int ignore = 0;
@ -1536,7 +1516,7 @@ void tfe_write_register(word16 ppaddress,word16 value)
#endif #endif
return; return;
} }
else if(ppaddress<0xa00){ else if(ppaddress<0xa00) {
#ifdef TFE_DEBUG_WARN_REG #ifdef TFE_DEBUG_WARN_REG
log_message(tfe_log, log_message(tfe_log,
"WARNING! Ignoring write to RX Buffer Range %04x", "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_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 */ #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 */ /* perform auto increment of packet page pointer */
if((tfe_packetpage_ptr & PP_PTR_AUTO_INCR_FLAG)==PP_PTR_AUTO_INCR_FLAG) { if((tfe_packetpage_ptr & PP_PTR_AUTO_INCR_FLAG)==PP_PTR_AUTO_INCR_FLAG) {
/* pointer is always increment by one on real HW */ /* 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 ) ) #define LOHI_WORD(x,y) ( (word16)(x) | ( ((word16)(y)) <<8 ) )
/* ----- read byte from I/O range in VICE ----- */ /* ----- read byte from I/O range in VICE ----- */
byte tfe_read(word16 io_address) byte tfe_read(word16 io_address) {
{
byte retval,lo,hi; byte retval,lo,hi;
word16 word_value; word16 word_value;
word16 reg_base; word16 reg_base;
@ -1677,8 +1655,7 @@ byte tfe_read(word16 io_address)
} }
/* ----- write byte to I/O range of VICE ----- */ /* ----- 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 reg_base;
word16 word_value; word16 word_value;
assert( tfe ); assert( tfe );
@ -1786,14 +1763,13 @@ void tfe_store(word16 io_address, byte var)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* resources support functions */ /* resources support functions */
#if 0 #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 */ /* dummy function since we don't want "disabled" to be stored on disk */
return 0; return 0;
} }
/*static int set_tfe_rr_net(int val, void *param) /*static int set_tfe_rr_net(int val, void *param)
{ {
if (!tfe_cannot_use) { if (!tfe_cannot_use) {
if (!val) { if (!val) {
// TFE should not be used as rr net // TFE should not be used as rr net
@ -1820,10 +1796,9 @@ static int set_tfe_disabled(int val, void *param)
} }
return 0; 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 (!tfe_cannot_use) {
if (!val) { if (!val) {
/* TFE should be deactived */ /* TFE should be deactived */
@ -1850,8 +1825,7 @@ static int set_tfe_enabled(int val, void *param)
} }
#endif /* 0 */ #endif /* 0 */
int set_tfe_interface(const char *name) int set_tfe_interface(const char *name) {
{
if (tfe_interface != NULL && name != NULL if (tfe_interface != NULL && name != NULL
&& strcmp(name, tfe_interface) == 0) && strcmp(name, tfe_interface) == 0)
return 0; return 0;
@ -1883,9 +1857,9 @@ int set_tfe_interface(const char *name)
ARCHDEP_ETHERNET_DEFAULT_DEVICE, RES_EVENT_NO, NULL, ARCHDEP_ETHERNET_DEFAULT_DEVICE, RES_EVENT_NO, NULL,
&tfe_interface, set_tfe_interface, NULL }, &tfe_interface, set_tfe_interface, NULL },
{ NULL } { NULL }
}; };
static const resource_int_t resources_int[] = { static const resource_int_t resources_int[] = {
{ "ETHERNET_DISABLED", 0, RES_EVENT_NO, NULL, { "ETHERNET_DISABLED", 0, RES_EVENT_NO, NULL,
&tfe_cannot_use, set_tfe_disabled, NULL }, &tfe_cannot_use, set_tfe_disabled, NULL },
{ "ETHERNET_ACTIVE", 0, RES_EVENT_STRICT, (resource_value_t)0, { "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, { "ETHERNET_AS_RR", 0, RES_EVENT_NO, NULL,
&tfe_as_rr_net, set_tfe_rr_net, NULL }, &tfe_as_rr_net, set_tfe_rr_net, NULL },
{ NULL } { NULL }
};*/ };*/
/*int tfe_resources_init(void) /*int tfe_resources_init(void)
{ {
if (resources_register_string(resources_string) < 0) if (resources_register_string(resources_string) < 0)
return -1; return -1;
return resources_register_int(resources_int); return resources_register_int(resources_int);
}*/ }*/
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* commandline support functions */ /* commandline support functions */
/*static const cmdline_option_t cmdline_options[] = /*static const cmdline_option_t cmdline_options[] =
{ {
{ "-tfe", SET_RESOURCE, 0, { "-tfe", SET_RESOURCE, 0,
NULL, NULL, "ETHERNET_ACTIVE", (resource_value_t)1, NULL, NULL, "ETHERNET_ACTIVE", (resource_value_t)1,
USE_PARAM_STRING, USE_DESCRIPTION_ID, USE_PARAM_STRING, USE_DESCRIPTION_ID,
@ -1934,12 +1908,12 @@ static const resource_int_t resources_int[] = {
IDCLS_UNUSED, IDCLS_DISABLE_TFE_AS_RRNET, IDCLS_UNUSED, IDCLS_DISABLE_TFE_AS_RRNET,
NULL, NULL }, NULL, NULL },
{ NULL } { NULL }
}; };
int tfe_cmdline_options_init(void) int tfe_cmdline_options_init(void)
{ {
return cmdline_register_options(cmdline_options); return cmdline_register_options(cmdline_options);
}*/ }*/
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -1951,14 +1925,12 @@ static char snap_module_name[] = "TFE1764";
#define SNAP_MAJOR 0 #define SNAP_MAJOR 0
#define SNAP_MINOR 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 */ /* @SRT TODO: not yet implemented */
return -1; 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 */ /* @SRT TODO: not yet implemented */
return -1; return -1;
} }
@ -1968,8 +1940,7 @@ int tfe_write_snapshot_module(struct snapshot_s *s)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* functions for selecting and querying available NICs */ /* functions for selecting and querying available NICs */
int tfe_enumadapter_open(void) int tfe_enumadapter_open(void) {
{
if (!tfe_arch_enumadapter_open()) { if (!tfe_arch_enumadapter_open()) {
tfe_cannot_use = 1; tfe_cannot_use = 1;
return 0; return 0;
@ -1977,13 +1948,11 @@ int tfe_enumadapter_open(void)
return 1; return 1;
} }
int tfe_enumadapter(char **ppname, char **ppdescription) int tfe_enumadapter(char **ppname, char **ppdescription) {
{
return tfe_arch_enumadapter(ppname, ppdescription); return tfe_arch_enumadapter(ppname, ppdescription);
} }
int tfe_enumadapter_close(void) int tfe_enumadapter_close(void) {
{
return tfe_arch_enumadapter_close(); return tfe_arch_enumadapter_close();
} }

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
Based on the KEGS emulator written by Kent Dickey Based on the KEGS emulator written by Kent Dickey
See COPYRIGHT.txt for Copyright information See COPYRIGHT.txt for Copyright information
See LICENSE.txt for license (GPL v2) See LICENSE.txt for license (GPL v2)
*/ */
#include <time.h> #include <time.h>
@ -319,16 +319,14 @@ const word32 g_hires_convert[64] = {
BIGEND(0x0f0f0f0f), /* 11,1111 = white ,white, white, white */ BIGEND(0x0f0f0f0f), /* 11,1111 = white ,white, white, white */
}; };
int g_screen_index[] = { int g_screen_index[] = {
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380,
0x028, 0x0a8, 0x128, 0x1a8, 0x228, 0x2a8, 0x328, 0x3a8, 0x028, 0x0a8, 0x128, 0x1a8, 0x228, 0x2a8, 0x328, 0x3a8,
0x050, 0x0d0, 0x150, 0x1d0, 0x250, 0x2d0, 0x350, 0x3d0 0x050, 0x0d0, 0x150, 0x1d0, 0x250, 0x2d0, 0x350, 0x3d0
}; };
void void video_init() {
video_init()
{
word32 col[4]; word32 col[4];
Kimage *kimage_ptr; Kimage *kimage_ptr;
word32 *ptr; word32 *ptr;
@ -403,7 +401,7 @@ video_init()
g_red_right_shift = 0; g_red_right_shift = 0;
g_green_right_shift = 0; g_green_right_shift = 0;
g_blue_right_shift = 0; g_blue_right_shift = 0;
*/ */
/* Initialize video system */ /* Initialize video system */
@ -539,9 +537,7 @@ video_init()
fflush(stdout); fflush(stdout);
} }
void void show_a2_line_stuff() {
show_a2_line_stuff()
{
int i; int i;
for(i = 0; i < 200; i++) { for(i = 0; i < 200; i++) {
@ -563,9 +559,7 @@ show_a2_line_stuff()
int g_flash_count = 0; int g_flash_count = 0;
void void video_reset() {
video_reset()
{
int stat; int stat;
int i; int i;
@ -596,10 +590,9 @@ int g_screen_redraw_skip_amt = -1;
word32 g_cycs_in_check_input = 0; word32 g_cycs_in_check_input = 0;
int g_needfullrefreshfornextframe = 1 ; int g_needfullrefreshfornextframe = 1;
void video_update() void video_update() {
{
int did_video; int did_video;
// OG g_needfullrefreshfornextframe // OG g_needfullrefreshfornextframe
@ -656,9 +649,7 @@ void video_update()
} }
int int video_all_stat_to_line_stat(int line, int new_all_stat) {
video_all_stat_to_line_stat(int line, int new_all_stat)
{
int page, color, dbl; int page, color, dbl;
int st80, hires, annunc3, mix_t_gr; int st80, hires, annunc3, mix_t_gr;
int altchar, text_color, bg_color, flash_state; 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); (color << 1) + dbl);
} }
int * int *video_update_kimage_ptr(int line, int new_stat) {
video_update_kimage_ptr(int line, int new_stat)
{
Kimage *kimage_ptr; Kimage *kimage_ptr;
int *mode_ptr; int *mode_ptr;
int page; int page;
@ -762,9 +751,7 @@ video_update_kimage_ptr(int line, int new_stat)
return mode_ptr; return mode_ptr;
} }
void void change_a2vid_palette(int new_palette) {
change_a2vid_palette(int new_palette)
{
int i; int i;
for(i = 0; i < 200; 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_num_a2vid_palette_checks = 1;
int g_shr_palette_used[16]; int g_shr_palette_used[16];
void void check_a2vid_palette() {
check_a2vid_palette()
{
int sum; int sum;
int min; int min;
int val; int val;
@ -811,7 +796,7 @@ check_a2vid_palette()
/* borders don't change when all 256 superhires colors are used */ /* borders don't change when all 256 superhires colors are used */
g_num_a2vid_palette_checks--; 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; return;
} }
@ -837,9 +822,7 @@ check_a2vid_palette()
} }
} }
void void change_display_mode(double dcycs) {
change_display_mode(double dcycs)
{
int line, tmp_line; int line, tmp_line;
line = ((get_lines_since_vbl(dcycs) + 0xff) >> 8); 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 */ /* otherwise, g_cur_a2_stat is covered at the end of vbl */
} }
void void video_update_all_stat_through_line(int line) {
video_update_all_stat_through_line(int line)
{
int start_line; int start_line;
int prev_stat; int prev_stat;
int max_line; int max_line;
@ -889,9 +870,7 @@ int g_border_color = 0; // OG Expose border color
Border_changes g_border_changes[MAX_BORDER_CHANGES]; Border_changes g_border_changes[MAX_BORDER_CHANGES];
int g_num_border_changes = 0; int g_num_border_changes = 0;
void void change_border_color(double dcycs, int val) {
change_border_color(double dcycs, int val)
{
int pos; int pos;
g_border_color = val; // OG Expose border color g_border_color = val; // OG Expose border color
@ -911,9 +890,7 @@ change_border_color(double dcycs, int val)
extern int first; extern int first;
void void update_border_info() {
update_border_info()
{
double dlines_per_dcyc; double dlines_per_dcyc;
double dcycs, dline, dcyc_line_start; double dcycs, dline, dcyc_line_start;
int offset; int offset;
@ -963,13 +940,13 @@ update_border_info()
new_val = g_border_changes[i].val; new_val = g_border_changes[i].val;
new_line_offset = (new_line << 8) + offset; 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); printf("new_line_offset: %05x\n", new_line_offset);
new_line_offset = last_line_offset; new_line_offset = last_line_offset;
} }
while(last_line_offset < new_line_offset) { while(last_line_offset < new_line_offset) {
/* see if this will finish it */ /* 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, update_border_line(last_line_offset,
new_line_offset, color_now); new_line_offset, color_now);
last_line_offset = new_line_offset; last_line_offset = new_line_offset;
@ -1000,9 +977,7 @@ update_border_info()
g_vbl_border_color = (g_c034_val & 0xf); g_vbl_border_color = (g_c034_val & 0xf);
} }
void void update_border_line(int st_line_offset, int end_line_offset, int color) {
update_border_line(int st_line_offset, int end_line_offset, int color)
{
word32 val; word32 val;
int st_offset, end_offset; int st_offset, end_offset;
int left, right; int left, right;
@ -1101,10 +1076,8 @@ update_border_line(int st_line_offset, int end_line_offset, int color)
} }
} }
void void video_border_pixel_write(Kimage *kimage_ptr, int starty, int num_lines,
video_border_pixel_write(Kimage *kimage_ptr, int starty, int num_lines, word32 val, int st_off, int end_off) {
word32 val, int st_off, int end_off)
{
word32 *ptr; word32 *ptr;
int width; int width;
int width_act; 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; \ ch_mask = ch_mask << ch_shift_amount; \
\ \
if(reparse) { \ 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) \ #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; \ continue; \
} }
void void redraw_changed_text_40(int start_offset, int start_line, int num_lines,
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 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; register word32 start_time, end_time;
word32 *img_ptr, *img_ptr2; word32 *img_ptr, *img_ptr2;
word32 *save_img_ptr, *save_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; g_need_redraw = 0;
} }
void void redraw_changed_text_80(int start_offset, int start_line, int num_lines,
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 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; const word32 *font_ptr0, *font_ptr1, *font_ptr2, *font_ptr3;
word32 *ch_ptr; word32 *ch_ptr;
word32 *img_ptr, *img_ptr2; 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; g_need_redraw = 0;
} }
void void redraw_changed_gr(int start_offset, int start_line, int num_lines, int reparse,
redraw_changed_gr(int start_offset, int start_line, int num_lines, int reparse, byte *screen_data, int pixels_per_line) {
byte *screen_data, int pixels_per_line)
{
word32 *img_ptr; word32 *img_ptr;
word32 *save_img_ptr; word32 *save_img_ptr;
word32 *ch_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; g_need_redraw = 0;
} }
void void redraw_changed_dbl_gr(int start_offset, int start_line, int num_lines,
redraw_changed_dbl_gr(int start_offset, int start_line, int num_lines, int reparse, byte *screen_data, int pixels_per_line) {
int reparse, byte *screen_data, int pixels_per_line)
{
word32 *img_ptr; word32 *img_ptr;
word32 *save_img_ptr; word32 *save_img_ptr;
word32 *ch_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; g_need_redraw = 0;
} }
void void redraw_changed_hires(int start_offset, int start_line, int num_lines,
redraw_changed_hires(int start_offset, int start_line, int num_lines, int color, int reparse, byte *screen_data, int pixels_per_line) {
int color, int reparse, byte *screen_data, int pixels_per_line)
{
if(!color) { if(!color) {
redraw_changed_hires_color(start_offset, start_line, num_lines, redraw_changed_hires_color(start_offset, start_line, num_lines,
reparse, screen_data, pixels_per_line); reparse, screen_data, pixels_per_line);
@ -1827,10 +1790,8 @@ redraw_changed_hires(int start_offset, int start_line, int num_lines,
} }
} }
void void redraw_changed_hires_bw(int start_offset, int start_line, int num_lines,
redraw_changed_hires_bw(int start_offset, int start_line, int num_lines, int reparse, byte *screen_data, int pixels_per_line) {
int reparse, byte *screen_data, int pixels_per_line)
{
word32 *img_ptr, *img_ptr2; word32 *img_ptr, *img_ptr2;
word32 *ch_ptr; word32 *ch_ptr;
byte *b_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; g_need_redraw = 0;
} }
void void redraw_changed_hires_color(int start_offset, int start_line, int num_lines,
redraw_changed_hires_color(int start_offset, int start_line, int num_lines, int reparse, byte *screen_data, int pixels_per_line) {
int reparse, byte *screen_data, int pixels_per_line)
{
word32 *img_ptr, *img_ptr2; word32 *img_ptr, *img_ptr2;
word32 *ch_ptr; word32 *ch_ptr;
byte *b_ptr; byte *b_ptr;
@ -2083,10 +2042,8 @@ redraw_changed_hires_color(int start_offset, int start_line, int num_lines,
} }
void void redraw_changed_dbl_hires(int start_offset, int start_line, int num_lines,
redraw_changed_dbl_hires(int start_offset, int start_line, int num_lines, int color, int reparse, byte *screen_data, int pixels_per_line) {
int color, int reparse, byte *screen_data, int pixels_per_line)
{
if(!color) { if(!color) {
redraw_changed_dbl_hires_color(start_offset, start_line, redraw_changed_dbl_hires_color(start_offset, start_line,
num_lines, reparse, screen_data, pixels_per_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 void redraw_changed_dbl_hires_bw(int start_offset, int start_line, int num_lines,
redraw_changed_dbl_hires_bw(int start_offset, int start_line, int num_lines, int reparse, byte *screen_data, int pixels_per_line) {
int reparse, byte *screen_data, int pixels_per_line)
{
word32 *img_ptr, *img_ptr2; word32 *img_ptr, *img_ptr2;
word32 *ch_ptr; word32 *ch_ptr;
byte *b_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; g_need_redraw = 0;
} }
void void redraw_changed_dbl_hires_color(int start_offset, int start_line, int num_lines,
redraw_changed_dbl_hires_color(int start_offset, int start_line, int num_lines, int reparse, byte *screen_data, int pixels_per_line) {
int reparse, byte *screen_data, int pixels_per_line)
{
word32 *ch_ptr; word32 *ch_ptr;
word32 *img_ptr, *img_ptr2; word32 *img_ptr, *img_ptr2;
byte *slow_mem_ptr; 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; g_need_redraw = 0;
} }
int int video_rebuild_super_hires_palette(word32 scan_info, int line, int reparse) {
video_rebuild_super_hires_palette(word32 scan_info, int line, int reparse)
{
word32 *word_ptr; word32 *word_ptr;
word32 *ch_ptr; word32 *ch_ptr;
byte *byte_ptr; byte *byte_ptr;
@ -2531,10 +2482,8 @@ video_rebuild_super_hires_palette(word32 scan_info, int line, int reparse)
void void redraw_changed_super_hires(int start_offset, int start_line, int num_lines,
redraw_changed_super_hires(int start_offset, int start_line, int num_lines, int in_reparse, byte *screen_data) {
int in_reparse, byte *screen_data)
{
word32 *ch_ptr; word32 *ch_ptr;
word32 mask_per_line; word32 mask_per_line;
word32 all_checks; word32 all_checks;
@ -2731,15 +2680,11 @@ redraw_changed_super_hires(int start_offset, int start_line, int num_lines,
g_need_redraw = 0; g_need_redraw = 0;
} }
void void display_screen() {
display_screen()
{
video_update_through_line(262); video_update_through_line(262);
} }
void void video_update_event_line(int line) {
video_update_event_line(int line)
{
int new_line; int new_line;
video_update_through_line(line); video_update_through_line(line);
@ -2763,9 +2708,7 @@ video_update_event_line(int line)
} }
} }
void void video_check_input_events() {
video_check_input_events()
{
word32 start_time, end_time; word32 start_time, end_time;
g_video_dcycs_check_input = g_cur_dcycs + 4000.0; 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); g_cycs_in_check_input += (end_time - start_time);
} }
void void video_update_through_line(int line) {
video_update_through_line(int line)
{
register word32 start_time; register word32 start_time;
register word32 end_time; register word32 end_time;
int *mode_ptr; int *mode_ptr;
@ -2891,9 +2832,7 @@ video_update_through_line(int line)
} }
} }
void void video_refresh_lines(int st_line, int num_lines, int must_reparse) {
video_refresh_lines(int st_line, int num_lines, int must_reparse)
{
byte *ptr; byte *ptr;
int line; int line;
int stat; int stat;
@ -2990,18 +2929,14 @@ video_refresh_lines(int st_line, int num_lines, int must_reparse)
} }
} }
void void refresh_border() {
refresh_border()
{
/**ZZZZ***/ /**ZZZZ***/
} }
// OG Added video_release_kimages proto // OG Added video_release_kimages proto
void video_release_kimages(); void video_release_kimages();
void void end_screen() {
end_screen()
{
glog("Shutting down display"); glog("Shutting down display");
// OG Free up allocated images // OG Free up allocated images
@ -3013,9 +2948,7 @@ byte g_font_array[256][8] = {
#include "gsportfont.h" #include "gsportfont.h"
}; };
void void read_a2_font() {
read_a2_font()
{
byte *f40_e_ptr; byte *f40_e_ptr;
byte *f40_o_ptr; byte *f40_o_ptr;
byte *f80_0_ptr, *f80_1_ptr, *f80_2_ptr, *f80_3_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 */ /* Helper routine for the *driver.c files */
void void video_get_kimage(Kimage *kimage_ptr, int extend_info, int depth, int mdepth) {
video_get_kimage(Kimage *kimage_ptr, int extend_info, int depth, int mdepth)
{
int width; int width;
int height; int height;
@ -3108,9 +3039,7 @@ video_get_kimage(Kimage *kimage_ptr, int extend_info, int depth, int mdepth)
x_get_kimage(kimage_ptr); x_get_kimage(kimage_ptr);
} }
void void video_get_kimages() {
video_get_kimages()
{
video_get_kimage(&g_kimage_text[0], 0, 8, 8); 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_text[1], 0, 8, 8);
video_get_kimage(&g_kimage_hires[0], 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) // 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); extern void x_release_kimage(Kimage *kimage_ptr);
x_release_kimage(&g_kimage_text[0]); x_release_kimage(&g_kimage_text[0]);
@ -3138,10 +3066,8 @@ void video_release_kimages()
} }
void void video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx,
video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx, int starty, int width, int height) {
int starty, int width, int height)
{
byte *indata, *inptr; byte *indata, *inptr;
word32 *outdata32, *outptr32; word32 *outdata32, *outptr32;
word16 *outdata16, *outptr16; word16 *outdata16, *outptr16;
@ -3193,10 +3119,8 @@ video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx,
} }
} }
void void video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix, int right_pix) {
int right_pix)
{
int mdepth_mismatch; int mdepth_mismatch;
int srcy; int srcy;
int center = 0; // OG added variable to center screen 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) if (!kimage_ptr)
{ {
printf("warning : video_push_lines(kimage_ptr=null)\n"); printf("warning : video_push_lines(kimage_ptr=null)\n");
return ; return;
} }
if(left_pix >= right_pix || left_pix < 0 || right_pix <= 0) { 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)); (right_pix - left_pix), 2*(end_line - start_line));
} }
void void video_push_border_sides_lines(int src_x, int dest_x, int width, int start_line,
video_push_border_sides_lines(int src_x, int dest_x, int width, int start_line, int end_line) {
int end_line)
{
Kimage *kimage_ptr; Kimage *kimage_ptr;
int srcy; int srcy;
@ -3285,9 +3207,7 @@ video_push_border_sides_lines(int src_x, int dest_x, int width, int start_line,
} }
} }
void void video_push_border_sides() {
video_push_border_sides()
{
int old_width; int old_width;
int prev_line; int prev_line;
int width; int width;
@ -3319,7 +3239,7 @@ video_push_border_sides()
old_width = width; 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); 0, old_width, prev_line, 200);
/* right side--can be "jagged" */ /* 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); X_A2_WINDOW_WIDTH - old_width, old_width, prev_line, 200);
} }
void void video_push_border_special() {
video_push_border_special()
{
Kimage *kimage_ptr; Kimage *kimage_ptr;
int width, height; int width, height;
int src_x, src_y; 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+1] = 0xFF;
kimage_ptr->data_ptr[i*4+2] = 0x00; kimage_ptr->data_ptr[i*4+2] = 0x00;
} }
*/ */
if(width > 0 && height > 0) { if(width > 0 && height > 0) {
#ifdef WINSDL_BORDERHACK #ifdef WINSDL_BORDERHACK
x_push_kimage(kimage_ptr, dest_x+72, dest_y, src_x, src_y, width, height); 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 // OG Added window ratio support
extern int x_calc_ratio(float ratiox,float ratioy); extern int x_calc_ratio(float ratiox,float ratioy);
void void video_push_kimages() {
video_push_kimages()
{
register word32 start_time; register word32 start_time;
register word32 end_time; register word32 end_time;
Kimage *last_kim, *cur_kim; Kimage *last_kim, *cur_kim;
@ -3516,9 +3432,7 @@ video_push_kimages()
} }
void void video_update_color_raw(int col_num, int a2_color) {
video_update_color_raw(int col_num, int a2_color)
{
word32 tmp; word32 tmp;
int red, green, blue; int red, green, blue;
int newred, newgreen, newblue; 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); x_update_color(col_num, red, green, blue, tmp);
} }
void void video_update_color_array(int col_num, int a2_color) {
video_update_color_array(int col_num, int a2_color)
{
int palette; int palette;
int full; int full;
@ -3570,9 +3482,7 @@ video_update_color_array(int col_num, int a2_color)
video_update_color_raw(col_num, a2_color); video_update_color_raw(col_num, a2_color);
} }
void void video_update_colormap() {
video_update_colormap()
{
int palette; int palette;
int full; int full;
int i; int i;
@ -3588,9 +3498,7 @@ video_update_colormap()
} }
} }
void void video_update_status_line(int line, const char *string) {
video_update_status_line(int line, const char *string)
{
char *buf; char *buf;
const char *ptr; const char *ptr;
int i; int i;
@ -3614,9 +3522,7 @@ video_update_status_line(int line, const char *string)
buf[STATUS_LINE_LENGTH] = 0; buf[STATUS_LINE_LENGTH] = 0;
} }
void void video_show_debug_info() {
video_show_debug_info()
{
word32 tmp1; word32 tmp1;
printf("g_cur_dcycs: %f, last_vbl: %f\n", g_cur_dcycs, 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); printf("Last line updated: %d\n", g_vid_update_last_line);
} }
word32 word32 float_bus(double dcycs) {
float_bus(double dcycs)
{
word32 val; word32 val;
int lines_since_vbl; int lines_since_vbl;
int line, eff_line, line24; 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+ #define _WIN32_WINNT 0x0600 // vista+
#include <Windows.h> #include <Windows.h>
@ -404,8 +408,7 @@ struct file_info {
struct AFP_Info afp; struct AFP_Info afp;
}; };
static int hex(byte c) static int hex(byte c) {
{
if (c >= '0' && c <= '9') return c - '0'; 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';
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 *dot = NULL;
const char *slash = NULL; const char *slash = NULL;
for(n = 0; ; ++n) { for(n = 0;; ++n) {
char c = path[n]; char c = path[n];
if (c == 0) break; if (c == 0) break;
else if (c == '/') { slash = path + n + 1; dot = NULL; } 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"); char *rpath = append_string(path, ":AFP_AfpInfo");
HANDLE h = CreateFile(rpath, GENERIC_WRITE, 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(); if (h == INVALID_HANDLE_VALUE) return map_last_error();
WriteFile(h, &fi->afp, sizeof(struct AFP_Info), NULL, NULL); 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}; static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3; y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7; return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
} }
/* /*
* converts time_t to a gs/os readhextime date/time record. * 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 >= 5) set_memory16_c(pb + OpenRecGS_access, access, 0);
if (pcount >= 6) set_memory16_c(pb + OpenRecGS_fileType, fi.file_type, 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 >= 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 >= 9) set_date_time_rec(pb + OpenRecGS_createDateTime, fi.create_date);
if (pcount >= 10) set_date_time_rec(pb + OpenRecGS_modDateTime, fi.modified_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; return tooManyFilesOpen;
} }
if (type == regular_file){ if (type == regular_file) {
if (g_cfg_host_crlf) { if (g_cfg_host_crlf) {
if (fi.file_type == 0x04 || fi.file_type == 0xb0) 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) for (int i = 0; i < 256; ++i)
newline_table[i] = get_memory_c(global_buffer + 2 + i, 0); 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; byte b;
DWORD read_count; DWORD read_count;
ok = ReadFile(e->handle, &b, 1, &read_count, NULL); ok = ReadFile(e->handle, &b, 1, &read_count, NULL);

View File

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

View File

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

View File

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

View File

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