void gen_busreq_w (unsigned int state) { int z80_cycles_to_run; input_raz (); /* from Gens */ if (state) { /* Bus Request */ if (!zbusreq && zreset) { /* Z80 stopped */ /* z80 was ON during the last 68k cycles */ /* we execute the appropriate number of z80 cycles */ z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; z80_run(z80_cycles_to_run); } } else { /* Bus released */ if (zbusreq && zreset) { /* Z80 started */ /* z80 was OFF during the last 68k cycles */ /* we burn the appropriate number of z80 cycles */ z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; count_z80 = z80_cycles_to_run; } } zbusreq = state; zbusack = 1 ^ (zbusreq & zreset); }
void gen_zreset_w(unsigned int data, unsigned int cycles) { if (data) /* !ZRESET released */ { /* check if Z80 is going to be restarted */ if (zstate == 0) { /* resynchronize with 68k */ mcycles_z80 = cycles; /* reset Z80 & YM2612 */ z80_reset(); fm_reset(cycles); } /* check if 68k access to Z80 bus is granted */ else if (zstate == 2) { /* enable 68k access to Z80 bus */ _m68k_memory_map *base = &m68k_memory_map[0xa0]; base->read8 = z80_read_byte; base->read16 = z80_read_word; base->write8 = z80_write_byte; base->write16 = z80_write_word; /* reset Z80 & YM2612 */ z80_reset(); fm_reset(cycles); } /* update Z80 bus status */ zstate |= 1; } else /* !ZRESET asserted */ { /* check if Z80 is going to be stopped */ if (zstate == 1) { /* resynchronize with 68k */ z80_run(cycles); } /* check if 68k had access to Z80 bus */ else if (zstate == 3) { /* disable 68k access to Z80 bus */ _m68k_memory_map *base = &m68k_memory_map[0xa0]; base->read8 = m68k_read_bus_8; base->read16 = m68k_read_bus_16; base->write8 = m68k_unused_8_w; base->write16 = m68k_unused_16_w; } /* stop YM2612 */ fm_reset(cycles); /* update Z80 bus status */ zstate &= 2; } }
/*----------------------------------------------------------------------- Z80 Bus controller chip functions -----------------------------------------------------------------------*/ void gen_zbusreq_w(unsigned int data, unsigned int cycles) { if (data) /* !ZBUSREQ asserted */ { /* check if Z80 is going to be stopped */ if (zstate == 1) { /* resynchronize with 68k */ z80_run(cycles); /* enable 68k access to Z80 bus */ _m68k_memory_map *base = &m68k_memory_map[0xa0]; base->read8 = z80_read_byte; base->read16 = z80_read_word; base->write8 = z80_write_byte; base->write16 = z80_write_word; } /* update Z80 bus status */ zstate |= 2; } else /* !ZBUSREQ released */ { /* check if Z80 is going to be restarted */ if (zstate == 3) { /* resynchronize with 68k */ mcycles_z80 = cycles; /* disable 68k access to Z80 bus */ _m68k_memory_map *base = &m68k_memory_map[0xa0]; base->read8 = m68k_read_bus_8; base->read16 = m68k_read_bus_16; base->write8 = m68k_unused_8_w; base->write16 = m68k_unused_16_w; } /* update Z80 bus status */ zstate &= 1; } }
int main(int argc, char **argv) { FILE *f = fopen("fake_cpm.bin", "rb"); long fsize = file_size(f); if (fsize > sizeof(ram) - OS_START) { fsize = sizeof(ram) - OS_START; } if (fread(ram + OS_START, 1, fsize, f) != fsize) { fprintf(stderr, "Error reading from fake_cpm.bin\n"); exit(1); } f = fopen(argv[1], "rb"); fsize = file_size(f); if (fsize > OS_START - START_OFF) { fsize = OS_START - START_OFF; } if (fread(ram + START_OFF, 1, fsize, f) != fsize) { fprintf(stderr, "Error reading from file %s\n", argv[1]); exit(1); } fclose(f); ram[0] = 0xC3; ram[1] = OS_RESET & 0xFF; ram[2] = OS_RESET >> 8; ram[5] = 0xC3; ram[6] = OS_START & 0xFF; ram[7] = OS_START >> 8; z80_options opts; z80_context context; init_z80_opts(&opts, z80_map, 1, io_map, 3, 1); init_z80_context(&context, &opts); for(;;) { z80_run(&context, 1000000); context.current_cycle = 0; } return 0; }
void Java_org_puder_trs80_XTRS_run(JNIEnv* env, jclass clazz) { clear_paste_string(); if (!setjmp(ex_buf)) { screenUpdateRequired = 1; reset_required = 0; while (isRunning) { z80_run(0); if (screenUpdateRequired) { trigger_screen_update(isForcedScreenUpdateRequired); } if (reset_required) { reset_required = 0; clear_paste_string(); trs_timer_init(); trs_reset(0); } } } else { // Got not implemented exception } OpenSLWrap_Shutdown(); }
void gen_reset_w (unsigned int state) { int z80_cycles_to_run; if (state) { /* stop RESET process */ if (!zbusreq && !zreset) { /* Z80 started */ /* z80 was OFF during the last 68k cycles */ /* we burn the appropriate number of z80 cycles */ z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; count_z80 = z80_cycles_to_run; } } else { /* start RESET process */ if (!zbusreq && zreset) { /* Z80 stopped */ /* z80 was ON during the last 68k cycles */ /* we execute the appropriate number of z80 cycles */ z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; z80_run(z80_cycles_to_run); } /* Reset Z80 & YM2612 */ _YM2612_Reset(); z80_reset (); } zreset = state; zbusack = 1 ^ (zbusreq & zreset); }
int SDLmain(int argc, char *argv[]) { int debug = FALSE; struct stat st; /* program_name must be set first because the error * printing routines use it. */ program_name = strrchr(argv[0], '/'); if (program_name == NULL) { program_name = argv[0]; } else { program_name++; } check_endian(); #ifndef MACOSX putenv("SDL_VIDEO_CENTERED=1"); #endif if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) { fprintf(stderr, "Failed to initialize SDL library"); exit(1); } /* Enable Unicode key translations */ SDL_EnableUNICODE(TRUE); argc = trs_parse_command_line(argc, argv, &debug); if (argc > 1) { fprintf(stderr, "%s: erroneous argument %s\n", program_name, argv[1]); exit(1); } trs_set_keypad_joystick(); trs_open_joystick(); if (stat(trs_disk_dir, &st) < 0) { strcpy(trs_disk_dir,"."); } if (stat(trs_hard_dir, &st) < 0) { strcpy(trs_hard_dir,"."); } if (stat(trs_cass_dir, &st) < 0) { strcpy(trs_cass_dir,"."); } if (stat(trs_state_dir, &st) < 0) { strcpy(trs_state_dir,"."); } if (stat(trs_disk_set_dir, &st) < 0) { strcpy(trs_disk_set_dir,"."); } if (stat(trs_printer_dir, &st) < 0) { strcpy(trs_printer_dir,"."); } mem_init(); trs_disk_init(0); trs_rom_init(); trs_screen_init(); screen_init(); trs_timer_init(); trs_reset(1); if (init_state_file[0] != 0) { trs_state_load(init_state_file); trs_screen_init(); trs_screen_refresh(); } #ifdef MACOSX TrsOriginSet(); #endif if (!debug || fullscreen) { /* Run continuously until exit or request to enter debugger */ z80_run(TRUE); } printf("Entering debugger.\n"); debug_init(); debug_shell(); printf("Quitting.\n"); #ifdef MACOSX trs_mac_save_defaults(); #endif exit(0); }