static void autoexec(void) { struct { BYTE reserved[21]; BYTE attr; WORD time; WORD date; LONG size; BYTE name[14]; } dta; WORD err; if (kbshift(-1) & MODE_CTRL) /* check if Control is held down */ return; bootstrap(); /* try to boot the new OS kernel directly */ if( ! blkdev_avail(bootdev) ) /* check, if bootdev available */ return; trap1( 0x1a, &dta); /* Setdta */ err = trap1( 0x4e, "\\AUTO\\*.PRG", 7); /* Fsfirst */ while(err == 0) { #ifdef TARGET_PRG if (!strncmp(dta.name, "EMUTOS", 6)) { KDEBUG(("Skipping %s from AUTO folder\n", dta.name)); } else #endif { run_auto_program(dta.name); /* Setdta. BetaDOS corrupted the AUTO load if the Setdta * not repeated here */ trap1( 0x1a, &dta); } err = trap1( 0x4f ); /* Fsnext */ } }
/* * escfn12: v_curtext() - outputs cursor addressable alpha text * * The cursor will be displayed at the new location, * if it is not currently hidden. * * inputs: * CONTRL[3] = character count * INTIN = character array */ static void escfn12(Vwk * vwk) { int cnt; WORD *chr; cnt = CONTRL[3]; /* get the character count */ chr = INTIN; /* address of the character array */ while (cnt--) { trap1(rawio, *chr++); /* raw i/o to standard input/output */ } }
/* * escfn11: vs_curaddress() - sets the cursor position * * The cursor will be displayed at the new location, * if it is not currently hidden. * * inputs: * INTIN[0] = cursor row (1 - max_y_cell) * INTIN[1] = cursor column (1 - max_x_cell) */ static void escfn11(Vwk * vwk) { char out[5]; /* send string via VT-52 terminal emulation */ out[0] = '\033'; out[1] = 'Y'; out[2] = 0x20 + INTIN[0] - 1; /* zero-based */ out[3] = 0x20 + INTIN[1] - 1; out[4] = '\0'; trap1(wntstr, out); }
static void bootstrap(void) { #if DETECT_NATIVE_FEATURES /* start the kernel provided by the emulator */ PD *pd; LONG length; LONG r; char args[128]; args[0] = '\0'; nf_getbootstrap_args(args, sizeof(args)); /* allocate space */ pd = (PD *) trap1_pexec(PE_BASEPAGE, "mint.prg", args, default_env); /* get the TOS executable from the emulator */ length = nf_bootstrap( (char*)pd->p_lowtpa + sizeof(PD), (long)pd->p_hitpa - pd->p_lowtpa); /* free the allocated space if something is wrong */ if ( length <= 0 ) goto err; /* relocate the loaded executable */ r = trap1_pexec(PE_RELOCATE, (char*)length, pd, ""); if ( r != (LONG)pd ) goto err; /* set the boot drive for the new OS to use */ bootdev = nf_getbootdrive(); /* execute the relocated process */ trap1_pexec(PE_GO, "", pd, ""); err: trap1(0x49, (long)pd->p_env); /* Mfree() the environment */ trap1(0x49, (long)pd); /* Mfree() the process area */ #endif }
/* * escfn6: v_curright() - moves the alpha cursor right one column */ static void escfn6(Vwk * vwk) { trap1(wntstr, "\033C"); }
/* * escfn5: v_curdown() - moves the alpha cursor down one line */ static void escfn5(Vwk * vwk) { trap1(wntstr, "\033B"); }
/* * escfn4: v_curup() - moves the alpha cursor up one line */ static void escfn4(Vwk * vwk) { trap1(wntstr, "\033A"); }
/* * escfn8: v_curhome() - moves the alpha cursor home */ static void escfn8(Vwk * vwk) { trap1(wntstr, "\033H"); }
bool traps(int n, char board[21][21], bool humanPlayer, char humanPlayerC, char compPlayerC) { int bestScore = -1; int moveX = -1; int moveY = -1; char trapBoard[10][10]; bool done = false; trap1(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap2(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap3(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap4(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap5(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap6(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap7(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap8(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 7)) done = true; trap9(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap10(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap11(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap12(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap13(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap14(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap15(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap16(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap17(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap18(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; trap19(n, trapBoard); if (!done && nextTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard, &bestScore, &moveX, &moveY, 8)) done = true; if (moveX == -1 && moveY == -1) return false; else if (board[moveX][moveY] == 'U') { board[moveX][moveY] = compPlayerC; printf("Computer moves %c at %d %d\n", compPlayerC, moveX, moveY); printBoard(n, board); return true; } return false; }
/* * escfn14: v_rvoff() - switch to normal video */ static void escfn14(Vwk * vwk) { trap1(wntstr, "\033q"); /* enter normal video */ }
/* * escfn13: v_rvon(): - switch to reverse video */ static void escfn13(Vwk * vwk) { trap1(wntstr, "\033p"); /* enter reverse video */ }
/* * escfn10: v_eeol() - clears screen from cursor position to end of line */ static void escfn10(Vwk * vwk) { trap1(wntstr, "\033K"); }
/* * escfn9: v_eeos() - clears screen from cursor position to end of screen */ static void escfn9(Vwk * vwk) { trap1(wntstr, "\033J"); }
void biosmain(void) { BOOL show_initinfo; /* TRUE if welcome screen must be displayed */ BYTE *p; bios_init(); /* Initialize the BIOS */ trap1( 0x30 ); /* initial test, if BDOS works: Sversion() */ if (!HAS_RTC) trap1( 0x2b, os_dosdate); /* set initial date in GEMDOS format: Tsetdate() */ /* Steem needs this to initialize its GEMDOS hard disk emulation. * This may change drvbits. See Steem sources: * File steem/code/emulator.cpp, function intercept_bios(). */ Drvmap(); /* * if it's not the first boot, we use the existing bootdev. * this allows a boot device that was selected via the welcome * screen to persist across warm boots. */ if (first_boot) bootdev = blkdev_avail(DEFAULT_BOOTDEV) ? DEFAULT_BOOTDEV : FLOPPY_BOOTDEV; #if INITINFO_DURATION == 0 show_initinfo = FALSE; #elif ALWAYS_SHOW_INITINFO show_initinfo = TRUE; #else show_initinfo = first_boot; #endif if (show_initinfo) bootdev = initinfo(); /* show the welcome screen */ KDEBUG(("bootdev = %d\n", bootdev)); /* boot eventually from a block device (floppy or harddisk) */ blkdev_boot(); defdrv = bootdev; trap1( 0x0e , defdrv ); /* Set boot drive: Dsetdrv(defdrv) */ #if ENABLE_RESET_RESIDENT run_reset_resident(); /* see comments above */ #endif /* * build default environment, just a PATH= string */ strcpy(default_env,PATH_ENV); p = default_env + sizeof(PATH_ENV); /* point to first byte of path string */ strcpy(p,DEF_PATH); *p = 'A' + defdrv; /* fix up drive letter */ p += sizeof(DEF_PATH); *p = '\0'; /* terminate with double nul */ #if WITH_CLI if (early_cli) { /* run an early console */ PD *pd = (PD *) trap1_pexec(PE_BASEPAGE, "", "", default_env); pd->p_tbase = (LONG) coma_start; pd->p_tlen = pd->p_dlen = pd->p_blen = 0; trap1_pexec(PE_GOTHENFREE, "", pd, ""); } #endif autoexec(); /* autoexec PRGs from AUTO folder */ /* clear commandline */ if(cmdload != 0) { /* Pexec a program called COMMAND.PRG */ trap1_pexec(PE_LOADGO, "COMMAND.PRG", "", default_env); } else if (exec_os) { /* start the default (ROM) shell */ PD *pd; pd = (PD *) trap1_pexec(PE_BASEPAGE, "", "", default_env); pd->p_tbase = (LONG) exec_os; pd->p_tlen = pd->p_dlen = pd->p_blen = 0; trap1_pexec(PE_GO, "", pd, ""); } #if CONF_WITH_SHUTDOWN /* try to shutdown the machine / close the emulator */ shutdown(); #endif /* hide cursor */ cprintf("\033f"); kcprintf(_("System halted!\n")); halt(); }
/* * escfn2: v_exit_cur() - exit alpha mode and enter graphics mode */ static void escfn2(Vwk * vwk) { trap1(wntstr, "\033f\033E"); /* hide alpha cursor */ vdi_v_clrwk(vwk); }
/*This function creates a blueprint trap board for every trap layout saved, * and then checks if the enemy has this trap created in order to block it using * the detectTrap function. */ bool detectEnemyTraps(int n, char board[21][21], bool humanPlayer, char humanPlayerC, char compPlayerC) { char trapBoard[10][10]; trap1(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap2(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap3(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap4(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap5(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap6(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap7(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap8(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap9(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap10(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap11(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap12(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap13(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap14(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap15(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap16(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap17(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap18(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; trap19(n, trapBoard); if (detectTrap(n, board, humanPlayer, humanPlayerC, compPlayerC, trapBoard)) return true; return false; }
/* * escfn3: v_enter_cur() - enter alpha mode and exit graphics mode */ static void escfn3(Vwk * vwk) { vdi_v_clrwk(vwk); trap1(wntstr, "\033E\033e"); /* show alpha cursor */ }
int _read(int file, char *ptr,int len) { return trap1(file,(unsigned long)ptr,1); }
/* * escfn7: v_curleft() - moves the alpha cursor left one column */ static void escfn7(Vwk * vwk) { trap1(wntstr, "\033D"); }