diff --git a/cpu.c b/cpu.c index 8dd5559..db8545e 100644 --- a/cpu.c +++ b/cpu.c @@ -10,6 +10,8 @@ #include "fastmem.h" #include "cpuregs.h" #include "cpucore.h" +#include "lcdc.h" +#include "debug.h" #ifdef USE_ASM #include "asm.h" diff --git a/cpu.h b/cpu.h index 085181c..ffe86ef 100644 --- a/cpu.h +++ b/cpu.h @@ -28,8 +28,13 @@ struct cpu extern struct cpu cpu; - - +void cpu_reset(); +void div_advance(int cnt); +void timer_advance(int cnt); +void lcdc_advance(int cnt); +void sound_advance(int cnt); +void cpu_timers(int cnt); +int cpu_emulate(int cycles); #endif diff --git a/debug.h b/debug.h new file mode 100644 index 0000000..815b8c9 --- /dev/null +++ b/debug.h @@ -0,0 +1,7 @@ +#ifndef DEBUG_H +#define DEBUG_H + +void debug_disassemble(addr a, int c); + +#endif + diff --git a/defs.h b/defs.h index ddbeae3..51c95f5 100644 --- a/defs.h +++ b/defs.h @@ -28,7 +28,9 @@ typedef signed int n32; typedef un16 word; typedef word addr; - +/* stuff from main.c ... */ +void die(char *fmt, ...); +void doevents(); diff --git a/emu.c b/emu.c index 544526d..bc015f0 100644 --- a/emu.c +++ b/emu.c @@ -8,6 +8,10 @@ #include "mem.h" #include "lcd.h" #include "rc.h" +#include "rtc.h" +#include "sys.h" +#include "sound.h" +#include "cpu.h" static int framelen = 16743; diff --git a/emu.h b/emu.h new file mode 100644 index 0000000..2fb60c9 --- /dev/null +++ b/emu.h @@ -0,0 +1,9 @@ +#ifndef EMU_H +#define EMU_H + +void emu_run(); +void emu_reset(); + +#endif + + diff --git a/exports.c b/exports.c index d958143..68f6e4d 100644 --- a/exports.c +++ b/exports.c @@ -1,5 +1,4 @@ - - +#include #include #include "rc.h" diff --git a/exports.h b/exports.h new file mode 100644 index 0000000..5c46dda --- /dev/null +++ b/exports.h @@ -0,0 +1,8 @@ +#ifndef EXPORTS_H +#define EXPORTS_H + +void show_exports(); +void init_exports(); + +#endif + diff --git a/hw.c b/hw.c index 46107c8..f214787 100644 --- a/hw.c +++ b/hw.c @@ -1,4 +1,4 @@ - +#include #include "defs.h" diff --git a/hw.h b/hw.h index f425efc..a4a2585 100644 --- a/hw.h +++ b/hw.h @@ -34,6 +34,13 @@ struct hw extern struct hw hw; +void hw_interrupt(byte i, byte mask); +void hw_dma(byte b); +void hw_hdma(); +void hw_hdma_cmd(byte c); +void hw_reset(); +void pad_refresh(); +void pad_set(byte k, int st); #endif diff --git a/inflate.h b/inflate.h new file mode 100644 index 0000000..d2a1215 --- /dev/null +++ b/inflate.h @@ -0,0 +1,7 @@ +#ifndef INFLATE_H +#define INFLATE_H + +int unzip (const unsigned char *data, long *p, void (* callback) (unsigned char d)); + +#endif + diff --git a/keytable.c b/keytable.c index 599a90a..2d8d943 100644 --- a/keytable.c +++ b/keytable.c @@ -6,6 +6,8 @@ #include #include +#include +#include #include "input.h" diff --git a/lcd.c b/lcd.c index 71d138e..d4e8a5f 100644 --- a/lcd.c +++ b/lcd.c @@ -1,6 +1,7 @@ +#include - - +#include "refresh.h" +#include "palette.h" #include "defs.h" #include "regs.h" #include "hw.h" diff --git a/lcd.h b/lcd.h index b062534..4cbbd96 100644 --- a/lcd.h +++ b/lcd.h @@ -47,7 +47,25 @@ struct lcd extern struct lcd lcd; extern struct scan scan; - +void updatepatpix(); +void tilebuf(); +void bg_scan(); +void wnd_scan(); +void bg_scan_pri(); +void wnd_scan_pri(); +void bg_scan_color(); +void wnd_scan_color(); +void spr_count(); +void spr_enum(); +void spr_scan(); +void lcd_begin(); +void lcd_refreshline(); +void pal_write(int i, byte b); +void pal_write_dmg(int i, int mapnum, byte d); +void vram_write(int a, byte b); +void vram_dirty(); +void pal_dirty(); +void lcd_reset(); diff --git a/lcdc.c b/lcdc.c index 8b6e946..e247f92 100644 --- a/lcdc.c +++ b/lcdc.c @@ -6,7 +6,7 @@ #include "hw.h" #include "cpu.h" #include "regs.h" - +#include "lcd.h" #define C (cpu.lcdc) diff --git a/lcdc.h b/lcdc.h new file mode 100644 index 0000000..241d44b --- /dev/null +++ b/lcdc.h @@ -0,0 +1,11 @@ +#ifndef LCDC_H +#define LCDC_H + +void lcdc_change(byte b); +void lcdc_trans(); +void stat_write(byte b); +void stat_trigger(); + +#endif + + diff --git a/loader.c b/loader.c index b884048..dc8536b 100644 --- a/loader.c +++ b/loader.c @@ -1,4 +1,13 @@ +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include +#include +#include +#include +#include #include "defs.h" #include "regs.h" @@ -6,12 +15,11 @@ #include "hw.h" #include "rtc.h" #include "rc.h" - -#include -#include -#include - -char *strdup(); +#include "lcd.h" +#include "inflate.h" +#include "save.h" +#include "sound.h" +#include "sys.h" static int mbc_table[256] = { diff --git a/loader.h b/loader.h index fd68f44..b86d930 100644 --- a/loader.h +++ b/loader.h @@ -21,7 +21,9 @@ int rom_load(); int sram_load(); int sram_save(); - +void loader_init(char *s); +void state_save(int n); +void state_load(int n); #endif diff --git a/main.c b/main.c index 3c2c84c..d3eecfd 100644 --- a/main.c +++ b/main.c @@ -1,21 +1,19 @@ - - - - - - +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include #include #include -#include - -char *strdup(); #include #include #include "input.h" #include "rc.h" - +#include "sys.h" +#include "rckeys.h" +#include "emu.h" +#include "exports.h" +#include "loader.h" #include "Version" diff --git a/mem.c b/mem.c index e798120..37889d5 100644 --- a/mem.c +++ b/mem.c @@ -8,6 +8,8 @@ #include "mem.h" #include "rtc.h" #include "lcd.h" +#include "lcdc.h" +#include "sound.h" struct mbc mbc; struct rom rom; diff --git a/mem.h b/mem.h index 29caa68..4c7b8eb 100644 --- a/mem.h +++ b/mem.h @@ -57,6 +57,7 @@ void ioreg_write(byte r, byte b); void mbc_write(int a, byte b); void mem_write(int a, byte b); byte mem_read(int a); +void mbc_reset(); diff --git a/palette.c b/palette.c index 7a335f8..0ef8da8 100644 --- a/palette.c +++ b/palette.c @@ -1,8 +1,8 @@ - +#include #include "defs.h" #include "fb.h" - +#include "sys.h" static byte palmap[32768]; static byte pallock[256]; diff --git a/palette.h b/palette.h new file mode 100644 index 0000000..e47d8ce --- /dev/null +++ b/palette.h @@ -0,0 +1,13 @@ +#ifndef PALETTE_H +#define PALETTE_H + +#include "defs.h" + +void pal_lock(byte n); +void pal_release(byte n); +void pal_expire(); +void pal_set332(); +byte pal_getcolor(int c, int r, int g, int b); + +#endif + diff --git a/path.c b/path.c index 13a87bd..722b730 100644 --- a/path.c +++ b/path.c @@ -1,11 +1,9 @@ - - +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include #include #include -#include - -char *strdup(); #ifdef ALT_PATH_SEP #define SEP ';' diff --git a/rc.h b/rc.h index 7c2be30..904779e 100644 --- a/rc.h +++ b/rc.h @@ -55,6 +55,8 @@ int rc_getint(char *name); int *rc_getvec(char *name); char *rc_getstr(char *name); +int rc_command(char *line); +int rc_sourcefile(char *filename); #endif diff --git a/rccmds.c b/rccmds.c index 2ea68cf..f6c1b71 100644 --- a/rccmds.c +++ b/rccmds.c @@ -1,13 +1,13 @@ - - - - +#include #include #include "defs.h" #include "rc.h" +#include "rckeys.h" #include "hw.h" - +#include "emu.h" +#include "loader.h" +#include "split.h" /* diff --git a/rckeys.h b/rckeys.h new file mode 100644 index 0000000..04cb60b --- /dev/null +++ b/rckeys.h @@ -0,0 +1,10 @@ +#ifndef RCKEYS_H +#define RCKEYS_H + +void rc_dokey(int key, int st); +int rc_bindkey(char *keyname, char *cmd); +int rc_unbindkey(char *keyname); +void rc_unbindall(); + +#endif + diff --git a/rcvars.c b/rcvars.c index 8364e89..f024088 100644 --- a/rcvars.c +++ b/rcvars.c @@ -1,11 +1,11 @@ - - -#include +#undef _GNU_SOURCE +#define _GNU_SOURCE #include +#include +#include -char *strdup(); #include "defs.h" #include "rc.h" diff --git a/refresh.h b/refresh.h new file mode 100644 index 0000000..e688f8d --- /dev/null +++ b/refresh.h @@ -0,0 +1,20 @@ +#ifndef REFRESH_H +#define REFRESH_H +#include "defs.h" + +void refresh_1(byte *dest, byte *src, byte *pal, int cnt); +void refresh_2(un16 *dest, byte *src, un16 *pal, int cnt); +void refresh_3(byte *dest, byte *src, un32 *pal, int cnt); +void refresh_4(un32 *dest, byte *src, un32 *pal, int cnt); +void refresh_1_2x(byte *dest, byte *src, byte *pal, int cnt); +void refresh_2_2x(un16 *dest, byte *src, un16 *pal, int cnt); +void refresh_3_2x(byte *dest, byte *src, un32 *pal, int cnt); +void refresh_4_2x(un32 *dest, byte *src, un32 *pal, int cnt); +void refresh_2_3x(un16 *dest, byte *src, un16 *pal, int cnt); +void refresh_3_3x(byte *dest, byte *src, un32 *pal, int cnt); +void refresh_4_3x(un32 *dest, byte *src, un32 *pal, int cnt); +void refresh_3_4x(byte *dest, byte *src, un32 *pal, int cnt); +void refresh_4_4x(un32 *dest, byte *src, un32 *pal, int cnt); + +#endif + diff --git a/rtc.c b/rtc.c index c3f96ec..9ae17d5 100644 --- a/rtc.c +++ b/rtc.c @@ -2,6 +2,7 @@ #include +#include #include "defs.h" #include "mem.h" diff --git a/rtc.h b/rtc.h index 76f5017..1515152 100644 --- a/rtc.h +++ b/rtc.h @@ -16,8 +16,15 @@ struct rtc extern struct rtc rtc; +#include "defs.h" +void rtc_latch(byte b); +void rtc_write(byte b); +void rtc_tick(); +#include +void rtc_save_internal(FILE *f); +void rtc_load_internal(FILE *f); #endif diff --git a/save.c b/save.c index 1dc7905..a442fce 100644 --- a/save.c +++ b/save.c @@ -1,5 +1,5 @@ - +#include #include #include "defs.h" diff --git a/save.h b/save.h new file mode 100644 index 0000000..ed362a9 --- /dev/null +++ b/save.h @@ -0,0 +1,10 @@ +#ifndef SAVE_H +#define SAVE_H + +#include + +void savestate(FILE *f); +void loadstate(FILE *f); + +#endif + diff --git a/sound.c b/sound.c index 00ca286..c441ff1 100644 --- a/sound.c +++ b/sound.c @@ -1,4 +1,4 @@ - +#include #include "defs.h" @@ -9,7 +9,7 @@ #include "regs.h" #include "rc.h" #include "noise.h" - +#include "sys.h" const static byte dmgwave[16] = { diff --git a/sound.h b/sound.h index 2056f80..7b6410c 100644 --- a/sound.h +++ b/sound.h @@ -26,8 +26,18 @@ struct snd extern struct snd snd; +#include "defs.h" - +void sound_write(byte r, byte b); +byte sound_read(byte r); +void sound_dirty(); +void sound_off(); +void sound_reset(); +void sound_mix(); +void s1_init(); +void s2_init(); +void s3_init(); +void s4_init(); diff --git a/split.h b/split.h new file mode 100644 index 0000000..4f2f11f --- /dev/null +++ b/split.h @@ -0,0 +1,7 @@ +#ifndef SPLIT_H +#define SPLIT_H + +int splitline(char **argv, int max, char *line); + +#endif + diff --git a/sys.h b/sys.h new file mode 100644 index 0000000..09537a3 --- /dev/null +++ b/sys.h @@ -0,0 +1,38 @@ +#ifndef VID_H +#define VID_H + +/* stuff implemented by the different sys/ backends */ + +void vid_begin(); +void vid_end(); +void vid_init(); +void vid_preinit(); +void vid_close(); +void vid_setpal(int i, int r, int g, int b); +void vid_settitle(char *title); + +void pcm_init(); +int pcm_submit(); +void pcm_close(); + +void ev_poll(); + +void sys_checkdir(char *path, int wr); +void sys_sleep(int us); +void sys_sanitize(char *s); + +void joy_init(); +void joy_poll(); +void joy_close(); + +void kb_init(); +void kb_poll(); +void kb_close(); + + +/* FIXME these have different prototype for obsolete ( == M$ ) platforms */ +#include +int sys_elapsed(struct timeval *prev); +void sys_initpath(); + +#endif diff --git a/sys/linux/fbdev.c b/sys/linux/fbdev.c index 5fcd1a8..eb1bad9 100644 --- a/sys/linux/fbdev.c +++ b/sys/linux/fbdev.c @@ -7,10 +7,12 @@ * This file may be distributed under the terms of the GNU GPL. */ +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include #include -#include -char *strdup(); +#include #include #include #include @@ -20,6 +22,7 @@ char *strdup(); #include "defs.h" #include "fb.h" #include "rc.h" +#include "sys.h" #include "matrox.h" struct fb fb; diff --git a/sys/linux/joy.c b/sys/linux/joy.c index eacb2a1..04c6129 100644 --- a/sys/linux/joy.c +++ b/sys/linux/joy.c @@ -1,8 +1,9 @@ +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include #include #include -#include -char *strdup(); #include #include #include diff --git a/sys/nix/nix.c b/sys/nix/nix.c index dbb024c..c403308 100644 --- a/sys/nix/nix.c +++ b/sys/nix/nix.c @@ -3,6 +3,10 @@ * * System interface for *nix systems. */ +#undef _GNU_SOURCE +#define _GNU_SOURCE +#undef _BSD_SOURCE +#define _BSD_SOURCE #ifdef HAVE_CONFIG_H #include "config.h" @@ -12,10 +16,14 @@ #include #include #include +#include #include #include #include +#include "../../defs.h" +#include "../../rc.h" + #define DOTDIR ".gnuboy" #ifndef HAVE_USLEEP diff --git a/sys/oss/oss.c b/sys/oss/oss.c index b8e4d6a..83f8a11 100644 --- a/sys/oss/oss.c +++ b/sys/oss/oss.c @@ -1,8 +1,11 @@ +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include +#include +#include #include -#include -char *strdup(); #include #include #include diff --git a/sys/x11/xlib.c b/sys/x11/xlib.c index 596ac72..fe7afdc 100644 --- a/sys/x11/xlib.c +++ b/sys/x11/xlib.c @@ -4,6 +4,8 @@ * Xlib interface. * dist under gnu gpl */ +#include +#include "../../sys.h" #ifdef HAVE_CONFIG_H #include "config.h"