/* main entry of SegmentTracker for each Amiga run: setting up AutoConf area... if tracker is enabled then install a dummy resident that does the function patching in its init function */ uaecptr segtracker_startup (uaecptr resaddr) { /* reset dos patching and clear seglist */ dos_base = 0; del_all_seglists(); if(!segtracker_enabled) { return resaddr; } write_log("segtracker: startup\n"); /* setup a fake resident resident */ put_word (resaddr + 0x0, 0x4AFC); put_long (resaddr + 0x2, resaddr); put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ put_word (resaddr + 0xA, 0x0101); /* RTF_COLDSTART; Version 1 */ put_word (resaddr + 0xC, 0x0078); /* NT_UNKNOWN; pri 05 */ put_long (resaddr + 0xE, 0); /* no name */ put_long (resaddr + 0x12, 0); /* no id */ put_long (resaddr + 0x16, init_addr); resaddr += 0x1A; return resaddr; }
static int dev_do_io (struct s2devstruct *dev, uaecptr request, int quick) { uae_u32 command = get_word (request + 28); struct priv_s2devstruct *pdev = getps2devstruct (request); uaecptr data = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); put_byte (request + 31, 0); if (!pdev) { write_log (_T("%s unknown iorequest %08x\n"), getdevname (), request); return 0; } if (command == NSCMD_DEVICEQUERY) { uae_u32 data = get_long (request + 40); /* io_data */ put_long (data + 0, 0); put_long (data + 4, 16); /* size */ put_word (data + 8, 7); /* NSDEVTYPE_SANA2 */ put_word (data + 10, 0); put_long (data + 12, nscmd_cmd); put_long (request + 32, 16); /* io_actual */ return 0; } else if (get_word (request + 0x12) < SANA2_IOREQSIZE) { put_byte (request + 31, IOERR_BADLENGTH); return 0; } return dev_do_io_2 (dev, request, quick); }
int set_vec(u16 vector, u16 addr) { u16 location,cs; location = vector << 2; put_word(addr, 0, location); put_word(0x1000,0,location+2); }
int hop(u32 newsegment) { // Variables int j, i; u16 segment; // set it up to load umode properly! segment = (newsegment + 1) * MTXSEG; // calculate the newsegment kcopy(running->uss, segment, 32 * 1024); //load("/bin/u1", segment); for (i = 1; i <= 8; i++) put_word(j, segment, -2 * i); put_word(0x0200, segment, segment - 2); put_word(segment, segment, segment - 4); put_word(segment, segment, segment - 14); put_word(segment, segment, segment - 16); running->uss = segment; running->usp = segment - 16; //was 24 printf("Proc[%d] hopped to segment 0x%x!\n", running->pid, segment); // return the proc!!! return (running->pid); }
static inline AVP_dword DATA_PARAM put_wchar_string( Serialize* sz, wchar_t * string ) { AVP_dword total_size; if ( string ) { AVP_dword psize = (AVP_dword)wcslen (string) * sizeof(AVP_wchar); AVP_word wsize = (AVP_word)psize; if ( psize >= USHRT_MAX ) { _RPT0( _CRT_ASSERT, "String is too long" ); return 0; } if ( sizeof(AVP_word) != put_word (sz, &wsize) ) return 0; for ( ; *string; string++ ) { if ( put_word(sz, string) != sizeof(AVP_word) ) return 0; } total_size = sizeof(AVP_word) + psize; } else { AVP_word dummy = USHRT_MAX; if ( sizeof(AVP_word) == put_word(sz,&dummy) ) total_size = sizeof(AVP_word); else total_size = 0; } return total_size; }
int exec(char *filename){ // basically do the same initialization as kfork but with different path char name[128]; int i, child; u16 segment = (running->pid +1) * 0x1000; // get the filename from umode for (i = 0; i < 128; i++) { name[i] = get_byte(segment, filename + i); if (name[i] == '\0') break; } // load the file load(name, segment); // clear registers except flag, uDS uES and uCS for (i = 1; i < 13; i++) { switch(i){ case 1: child = 0x0200; break; case 2: case 11: case 12: child = segment; break; case 10: put_word(0, segment, 0x1000-i*2); continue; default: child = 0; break; } put_word(child, segment, 0x1000-i*2); } // set uss to file position and set usp ustack top position running->uss = segment; running->usp = 0x1000-24; put_word(0, segment, running->usp + 8*2); return 1; }
/************************************************************************* scroll(): scroll UP one line **************************************************************************/ int scroll() { int i; u16 w, bytes; // test offset = org + ONE screen + ONE more line offset = org + SCR_BYTES + 2*LINE_WIDTH; if (offset <= vid_mask){ // offset still within vRAM area org += 2*LINE_WIDTH; // just advance org by ONE line } else{ // offset exceeds vRAM area ==> reset to vRAM beginning by // copy current rows 1-24 to BASE, then reset org to 0 for (i=0; i<24*80; i++){ w = get_word(base, org+160+2*i); put_word(w, base, 0+2*i); } org = 0; } // org has been set up correctly offset = org + 2*24*80; // offset = beginning of row 24 // copy a line of BLANKs to row 24 w = 0x0C00; // HRGB=1100 ==> HighLight RED, Null char for (i=0; i<80; i++) put_word(w, base, offset + 2*i); set_VDC(VID_ORG, org >> 1); // set VID_ORG to org }
static void fpu_op_illg (uae_u32 opcode, int pcoffset) { if ((currprefs.cpu_model == 68060 && (currprefs.fpu_model == 0 || (regs.pcr & 2))) || (currprefs.cpu_model == 68040 && currprefs.fpu_model == 0)) { /* 68040 unimplemented/68060 FPU disabled exception. * Line F exception with different stack frame.. */ uaecptr newpc = m68k_getpc (); uaecptr oldpc = newpc - pcoffset; MakeSR (); if (!regs.s) { regs.usp = m68k_areg (regs, 7); m68k_areg (regs, 7) = regs.isp; } regs.s = 1; m68k_areg (regs, 7) -= 4; put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 4; put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 2; put_word (m68k_areg (regs, 7), 0x4000 + 11 * 4); m68k_areg (regs, 7) -= 4; put_long (m68k_areg (regs, 7), newpc); m68k_areg (regs, 7) -= 2; put_word (m68k_areg (regs, 7), regs.sr); write_log ("68040/060 FPU disabled exception PC=%x\n", newpc); newpc = get_long (regs.vbr + 11 * 4); m68k_setpc (newpc); return; } op_illg (opcode); }
static void output_bin_data( lan_blk_t *lbp ) { unsigned int offs = 4 * (lbp->nblk * 3 + 1); int i, j, k; put_dword( lbp->nblk ); /* NBlocks */ for (i = 0; i < lbp->nblk; i++) { put_dword( lbp->blks[i].idlo ); /* Lo */ put_dword( lbp->blks[i].idhi ); /* Hi */ put_dword( offs ); /* Offs */ offs += lbp->blks[i].size; } for (i = 0; i < lbp->nblk; i++) { block_t *blk = &lbp->blks[i]; for (j = 0; j < blk->nmsg; j++) { int len = (2 * blk->msgs[j]->len + 3) & ~3; put_word( len + 4 ); put_word( 1 ); for (k = 0; k < blk->msgs[j]->len; k++) put_word( blk->msgs[j]->msg[k] ); align_output( 4 ); } } }
/******************************************************************** Copyright 2010-2015 K.C. Wang, <*****@*****.**> 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 3 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, see <http://www.gnu.org/licenses/>. ********************************************************************/ int makeUimage(char *filename, PROC *p) { u16 i, segment; // make Umode image by loading /u1 into segment segment = (p->pid + 1)*0x1000; load(filename, segment); /***** Fill in U mode information in proc *****/ /************************************************** We know segment=0x2000 + index*0x1000 ====> ustack is at the high end of this segment, say TOP. We must make ustak contain: 1 2 3 4 5 6 7 8 9 10 11 12 flag uCS uPC ax bx cx dx bp si di es ds 0x0200 seg 0 0 0 0 0 0 0 0 seg seg So, first a loop to set all to 0, then put_word(seg, segment, -2*i); i=2,11,12; **************************************************/ for (i=1; i<=12; i++){ put_word(0, segment, -2*i); } put_word(0x0200, segment, -2*1); /* flag */ put_word(segment, segment, -2*2); /* uCS */ put_word(segment, segment, -2*11); /* uES */ put_word(segment, segment, -2*12); /* uDS */ /* initial USP relative to USS */ p->usp = -2*12; p->uss = segment; return 0; }
/* tell the target to write a block of memory */ void target_write_block(unsigned addr, const char *buf, unsigned size, unsigned progress) { assert(portfd >= 0); while (size > 0) { char checksum = 0; int step = min(size, SERIAL_BLOCKSIZE); put_char('W'); put_word(addr); put_word(step); xawrite(portfd, buf, step); addr += step; size -= step; progress += step; while (step-- > 0) { checksum += *buf++; } if (checksum != (char)get_char()) { printf("\nSerial checksum error\n"); exit(1); } printf("0x%08x\r", progress); fflush(NULL); } }
//execs a given file path int kexec(int path) { PROC *p; int i, child,j; u16 segment; char file_path[32]; p = running; /*** get a PROC for child process: ***/ /* initialize the new proc and its stack */ /******* write C code to to do THIS YOURSELF ******************** Initialize p's kstack AS IF it had called tswitch() from the entry address of body(): HI -1 -2 -3 -4 -5 -6 -7 -8 -9 LOW ------------------------------------------------------------- |body| ax | bx | cx | dx | bp | si | di |flag| ------------------------------------------------------------ ^ PROC.ksp ---| ******************************************************************/ for (j=1; j<10;j++) p->kstack[SSIZE-j]; p->kstack[SSIZE-1]=(int)goUmode; p->ksp = &(p->kstack[SSIZE-9]); enqueue(&readyQueue, p); // make Umode image by loading the file designated segment = (p->pid + 1)*0x2000; for (i = 0;i<32;i++) { file_path[i]=get_byte(running->uss,path+i); if (get_byte(running->uss,path+i)==0) break; } printf("\nloading %s\n",file_path); load(file_path,segment); //gotta fix that segment to make sure it doesnt reference wrong stuff p->uss = segment; p->usp = 0x2000 - 24; put_word(0x0200,segment,0x2000-2); put_word(segment,segment,0x2000-4); for (j=3;j<11;j++) put_word(0,segment,0x2000-2*j); put_word(segment,segment,0x2000-22); put_word(segment,segment,0x2000-24); return p->pid; }
int ufork(){ PROC *p; int i, child; u16 segment; /*** get a PROC for child process: **/ if ( (p = get_proc(&freeList)) == NULL){ printf("no more proc\n"); return(-1); } printf("ufork\n"); /* set procs values to running and ready so we can use it */ p->status = READY; p->next = NULL; p->ppid = running->pid; p->parent = running; p->priority = running->priority; /* zero out kstack registers*/ for (i = 1; i < 10; i++) { p->kstack[SSIZE -i] = 0; } // set address to resume to p->kstack[SSIZE -1] =(int)goUmode; p->ksp = &(p->kstack[SSIZE-9]); // set segment to processes data position segment = (p->pid + 1)*0x1000; // copy the segment copy_image(segment); printf("loaded at %u\n", segment); // clean the registers and set flag and uCs and uDs to runnings values for (i = 1; i < 13; i++) { child = 0x1000 - i*2; switch(i){ case 1: put_word(segment, segment, child); break; case 2: put_word(segment, segment, child); break; case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: put_word(0,segment, child); break; case 11: case 12: put_word(segment, segment, child); break; } } // same as kfork p->uss = segment; p->usp = 0x1000 - 24; put_word(0, segment, p->usp + 8*2); printf("Proc%d forked a child %d segment=%x\n", running->pid,p->pid,segment); enqueue(&readyQueue, p); nproc++; return(p->pid); }
/********************************************************************** * ConvertMenu32To16 (KERNEL.616) */ VOID WINAPI ConvertMenu32To16( LPVOID menu32, DWORD size, LPVOID menu16 ) { WORD version, headersize, flags, level = 1; version = get_word( &menu32 ); headersize = get_word( &menu32 ); put_word( &menu16, version ); put_word( &menu16, headersize ); if ( headersize ) { memcpy( menu16, menu32, headersize ); menu16 = (BYTE *)menu16 + headersize; menu32 = (BYTE *)menu32 + headersize; } while ( level ) if ( version == 0 ) /* standard */ { flags = get_word( &menu32 ); put_word( &menu16, flags ); if ( !(flags & MF_POPUP) ) put_word( &menu16, get_word( &menu32 ) ); /* ID */ else level++; WideCharToMultiByte( CP_ACP, 0, (LPWSTR)menu32, -1, (LPSTR)menu16, 0x7fffffff, NULL, NULL ); menu16 = (LPSTR)menu16 + strlen( (LPSTR)menu16 ) + 1; menu32 = (LPWSTR)menu32 + strlenW( (LPWSTR)menu32 ) + 1; if ( flags & MF_END ) level--; } else /* extended */ { put_dword( &menu16, get_dword( &menu32 ) ); /* fType */ put_dword( &menu16, get_dword( &menu32 ) ); /* fState */ put_word( &menu16, get_dword( &menu32 ) ); /* ID */ flags = get_word( &menu32 ); put_byte(&menu16,flags); WideCharToMultiByte( CP_ACP, 0, (LPWSTR)menu32, -1, (LPSTR)menu16, 0x7fffffff, NULL, NULL ); menu16 = (LPSTR)menu16 + strlen( (LPSTR)menu16 ) + 1; menu32 = (LPWSTR)menu32 + strlenW( (LPWSTR)menu32 ) + 1; /* align on DWORD boundary (32-bit only) */ menu32 = (LPVOID)(((UINT_PTR)menu32 + 3) & ~3); /* If popup, transfer helpid */ if ( flags & 1) { put_dword( &menu16, get_dword( &menu32 ) ); level++; } if ( flags & MF_END ) level--; } }
void prot_login_send_info( struct qqclient* qq ) { static uchar unknown5[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00 }; static uchar unknown6[] = {0xE9,0xC4,0xD6,0x5C,0x4D,0x9D, 0xA0,0x17,0xE5,0x24,0x6B,0x55,0x57,0xD3,0xAB,0xF1 }; static uchar unknown7[] = {0xCB,0x8D,0xA4,0xE2,0x61,0xC2, 0xDD,0x27,0x39,0xEC,0x8A,0xCA,0xA6,0x98,0xF8,0x9B }; qqpacket* p = packetmgr_new_send( qq, QQ_CMD_LOGIN_SEND_INFO ); if( !p ) return; bytebuffer *buf = p->buf; //prepare sth. randkey( unknown6 ); randkey( unknown7 ); put_word( buf, 0x0001 ); put_data( buf, qq->data.version_spec, sizeof(qq->data.version_spec) ); put_int( buf, qq->data.login_info_unknown2 ); put_int( buf, qq->server_time ); put_int( buf, qq->client_ip ); put_int( buf, 00000000 ); put_word( buf, qq->data.login_info_large.len ); put_data( buf, qq->data.login_info_large.data, qq->data.login_info_large.len ); buf->pos += 35; put_data( buf, qq->data.exe_hash, sizeof(qq->data.exe_hash) ); put_byte( buf, rand2() ); //unknown important byte put_byte( buf, qq->mode ); put_data( buf, unknown5, sizeof(unknown5) ); put_data( buf, qq->data.server_data, sizeof(qq->data.server_data) ); put_data( buf, qq->data.locale, sizeof(qq->data.locale) ); buf->pos += 16; //16 zeros put_word( buf, qq->data.token_c.len ); put_data( buf, qq->data.token_c.data, qq->data.token_c.len ); put_int( buf, 0x00000007 ); put_int( buf, 0x00000000 ); put_int( buf, 0x08041801 ); put_byte( buf, 0x40 ); //length of the following put_byte( buf, 0x01 ); put_int( buf, rand2() ); // put_int( buf, 0x0741E9748 ); put_word( buf, sizeof(unknown6) ); put_data( buf, unknown6, sizeof(unknown6) ); put_data( buf, unknown5, sizeof(unknown5) ); put_data( buf, qq->data.server_data, sizeof(qq->data.server_data) ); put_byte( buf, 0x02 ); put_int( buf, rand2() ); // put_int( buf, 0x8BED382E ); put_word( buf, sizeof(unknown7) ); put_data( buf, unknown7, sizeof(unknown7) ); buf->pos += 249; //all zeros memcpy( p->key, qq->data.login_info_key1, sizeof(qq->data.login_info_key1) ); post_packet( qq, p, RANDOM_KEY ); }
static __attribute__((always_inline)) void patch_CXNCAS_4_2_0_532_extra(void) { #if NDLESS write_ndless3x_loader(0, 4); #else put_word(0x100C5F24, 0xE12FFF1E); #endif put_byte(0x1008DB8B, 0xEA); put_word(0x1014E008, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CXNCAS_3_6_0_546_extra(void) { #if NDLESS write_ndless3x_loader(0, 1); #else put_word(0x100BDED4, 0xE12FFF1E); #endif put_byte(0x1008D81B, 0xEA); put_word(0x10135838, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CXCAS_3_6_0_546_extra(void) { #if NDLESS write_ndless3x_loader(1, 1); #else put_word(0x100BE1BC, 0xE12FFF1E); #endif put_byte(0x1008D7A7, 0xEA); put_word(0x10135E8C, 0xE12FFF1E); }
/* output a resource directory in binary format */ static inline void output_bin_res_dir( unsigned int nb_names, unsigned int nb_ids ) { put_dword( 0 ); /* Characteristics */ put_dword( 0 ); /* TimeDateStamp */ put_word( 0 ); /* MajorVersion */ put_word( 0 ); /* MinorVersion */ put_word( nb_names ); /* NumberOfNamedEntries */ put_word( nb_ids ); /* NumberOfIdEntries */ }
static __attribute__((always_inline)) void patch_NCAS_3_9_0_46x_extra(void) { #if NDLESS write_ndless3x_loader(0, 2); #else put_word(0x100BE7D0, 0xE12FFF1E); #endif put_byte(0x1008870B, 0xEA); put_word(0x10111788, NOP); put_word(0x1013C764, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CAS_3_9_0_46x_extra(void) { #if NDLESS write_ndless3x_loader(1, 2); #else put_word(0x100BE598, 0xE12FFF1E); #endif put_byte(0x1008817B, 0xEA); put_word(0x10111584, NOP); put_word(0x1013C894, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CXNCAS_3_9_1_38_extra(void) { #if NDLESS write_ndless3x_loader(0, 2); #else put_word(0x100BDA94, 0xE12FFF1E); #endif put_byte(0x100879CF, 0xEA); put_word(0x1011194C, NOP); put_word(0x1013B9B0, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CXCAS_3_9_1_38_extra(void) { #if NDLESS write_ndless3x_loader(1, 2); #else put_word(0x100BD88C, 0xE12FFF1E); #endif put_byte(0x1008746F, 0xEA); put_word(0x10111778, NOP); put_word(0x1013BB08, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CXCAS_4_0_3_29_extra(void) { #if NDLESS write_ndless3x_loader(1, 3); #else put_word(0x100C2174, 0xE12FFF1E); #endif put_byte(0x1008B74B, 0xEA); put_word(0x10117F7C, NOP); put_word(0x10147F50, 0xE12FFF1E); }
static __attribute__((always_inline)) void patch_CXNCAS_4_0_3_29_extra(void) { #if NDLESS write_ndless3x_loader(0, 3); #else put_word(0x100C235C, 0xE12FFF1E); #endif put_byte(0x1008BC8F, 0xEA); put_word(0x1011812C, NOP); put_word(0x10147DD0, 0xE12FFF1E); }
int set_vector(u16 vector, u16 addr) { // put_word(word, segment, offset) /*put_word(handler, 0, vector*4); // set PC = _int80h put_word(0x1000, 0,(vector*4) + 2); // set CS = 0x1000*/ u16 location,cs; location = vector << 2; put_word(addr, 0, location); put_word(0x1000,0,location+2); }
int fork() { PROC *p; int i, child, pid; u16 segment; pid = kfork(0); // kfork() but do NOT load any Umode image for child if (pid < 0){ // kfork failed return -1; } p = &proc[pid]; // we can do this because of static pid for (i=0; i<NFD; i++){ p->fd[i] = running->fd[i]; if (p->fd[i] != 0){ p->fd[i]->refCount++; if (p->fd[i]->mode == READ_PIPE) p->fd[i]->pipe_ptr->nreader++; if (p->fd[i]->mode == WRITE_PIPE){ p->fd[i]->pipe_ptr->nwriter++; } } } segment = (pid+1)*0x2000; copyImage(running->uss, segment, 32*1024); p->uss = segment; p->usp = 0x2000 - 24; // YOUR CODE to make the child runnable in User mode p->kstack[SSIZE -1] =(int)goUmode; /**** ADD these : copy file descriptors ****/ // clean the registers and set flag and uCs and uDs to runnings values for (i = 1; i < 13; i++) { child = 0x2000 - i*2; switch(i){ case 1: put_word(segment, segment, child); break; case 2: put_word(segment, segment, child); break; case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: put_word(0,segment, child); break; case 11: case 12: put_word(segment, segment, child); break; } } return(p->pid); }
LOCAL void emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) /* Output the GIF file header, including color map */ /* If colormap==NULL, synthesize a gray-scale colormap */ { int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; int cshift = dinfo->cinfo->data_precision - 8; int i; if (num_colors > 256) ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); /* Compute bits/pixel and related values */ BitsPerPixel = 1; while (num_colors > (1 << BitsPerPixel)) BitsPerPixel++; ColorMapSize = 1 << BitsPerPixel; if (BitsPerPixel <= 1) InitCodeSize = 2; else InitCodeSize = BitsPerPixel; /* * Write the GIF header. * Note that we generate a plain GIF87 header for maximum compatibility. */ putc('G', dinfo->pub.output_file); putc('I', dinfo->pub.output_file); putc('F', dinfo->pub.output_file); putc('8', dinfo->pub.output_file); putc('7', dinfo->pub.output_file); putc('a', dinfo->pub.output_file); /* Write the Logical Screen Descriptor */ put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); FlagByte = 0x80; /* Yes, there is a global color table */ FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ FlagByte |= (BitsPerPixel-1); /* size of global color table */ putc(FlagByte, dinfo->pub.output_file); putc(0, dinfo->pub.output_file); /* Background color index */ putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ /* Write the Global Color Map */ /* If the color map is more than 8 bits precision, */ /* we reduce it to 8 bits by shifting */ for (i=0; i < ColorMapSize; i++) { if (i < num_colors) { if (colormap != NULL) { if (dinfo->cinfo->out_color_space == JCS_RGB) { /* Normal case: RGB color map */ putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); } else { /* Grayscale "color map": possible if quantizing grayscale image */ put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); } } else {
int do_fork() { PROC *p; int i, child,j; u16 segment; /*** get a PROC for child process: ***/ if ( (p = get_proc(&freeList)) == 0){ printf("no more proc\n"); return(-1); } /* initialize the new proc and its stack */ p->status = READY; p->ppid = running->pid; p->parent = running; p->priority = 1; // all of the same priority 1 /******* write C code to to do THIS YOURSELF ******************** Initialize p's kstack AS IF it had called tswitch() from the entry address of body(): HI -1 -2 -3 -4 -5 -6 -7 -8 -9 LOW ------------------------------------------------------------- |body| ax | bx | cx | dx | bp | si | di |flag| ------------------------------------------------------------ ^ PROC.ksp ---| ******************************************************************/ for (j=1; j<10;j++) p->kstack[SSIZE-j]; p->kstack[SSIZE-1]=(int)goUmode; p->ksp = &(p->kstack[SSIZE-9]); enqueue(&readyQueue, p); // make Umode image by copying the segment from the host process segment = (p->pid + 1)*0x1000; copy_image(segment); //gotta fix that segment to make sure it doesnt reference wrong stuff p->uss = segment; p->usp = 0x1000 - 24; put_word(0x0200,segment,0x1000-2); put_word(segment,segment,0x1000-4); for (j=3;j<11;j++) put_word(0,segment,0x1000-2*j); put_word(segment,segment,0x1000-22); put_word(segment,segment,0x1000-24); return p->pid; }
static uae_u32 REGPARAM2 res_initcode (TrapContext *ctx) { uaecptr rb; base = m68k_dreg (regs, 0); rb = base + SIZEOF_LIBRARY; put_word (rb + 0, UAEMAJOR); put_word (rb + 2, UAEMINOR); put_word (rb + 4, UAESUBREV); put_word (rb + 6, 0); put_long (rb + 8, rtarea_base); return base; }