|
|
1.1 ! root 1: /*****************************************************************************/ ! 2: /* Generator - Sega Genesis emulation - (c) James Ponder 1997-1998 */ ! 3: /*****************************************************************************/ ! 4: /* */ ! 5: /* ui.c - Acorn user interface */ ! 6: /* */ ! 7: /* *** THIS IS OUT OF DATE / NOT SUPPORTED, AND WON'T WORK *** */ ! 8: /* */ ! 9: /*****************************************************************************/ ! 10: ! 11: #include <stdlib.h> ! 12: #include <stdio.h> ! 13: ! 14: #include <sys/swis.h> ! 15: #include <sys/os.h> ! 16: ! 17: #include <unistd.h> ! 18: #include <sys/time.h> ! 19: ! 20: #include <generator.h> ! 21: #include <ui.h> ! 22: #include <vdp.h> ! 23: #include <cpu68k.h> ! 24: #include <reg68k.h> ! 25: ! 26: typedef struct { ! 27: uint32 flags; ! 28: uint32 xres; ! 29: uint32 yres; ! 30: uint32 pixdepth; ! 31: uint32 framerate; ! 32: uint32 settings; ! 33: } t_modeblock; ! 34: ! 35: static uint8 *screenaddr; ! 36: static char file[256]; ! 37: static unsigned int ui_bank; ! 38: ! 39: int ui_init(int argc, char *argv[]) ! 40: { ! 41: uint32 r[10]; ! 42: os_error *errblk; ! 43: t_modeblock *mb = malloc(sizeof(t_modeblock)+8*4); ! 44: uint32 *vars; ! 45: uint32 in[2]; ! 46: uint32 out[2]; ! 47: uint32 i; ! 48: ! 49: strcpy(file, argv[1]); ! 50: ! 51: if (!mb) { ! 52: fprintf(stderr, "Out of memory!\n"); ! 53: exit(1); ! 54: } ! 55: ! 56: vars = &(mb->settings); ! 57: ! 58: mb->flags = 1; ! 59: mb->xres = 320; ! 60: mb->yres = 480; ! 61: mb->pixdepth = 3; ! 62: mb->framerate = 60; ! 63: *vars++ = 0; /* ModeFlags */ ! 64: *vars++ = 128; ! 65: *vars++ = 3; /* NColour */ ! 66: *vars++ = 255; ! 67: *vars++ = 4; /* X eig factor */ ! 68: *vars++ = 2; ! 69: *vars++ = 5; /* Y eig factor */ ! 70: *vars++ = 2; ! 71: *vars++ = -1; ! 72: r[0] = (uint32)0; ! 73: r[1] = (uint32)mb; ! 74: errblk = os_swi(OS_ScreenMode, r); ! 75: if (errblk) { ! 76: fprintf(stderr, errblk->errmess); ! 77: exit(1); ! 78: } ! 79: free(mb); ! 80: r[0] = 2; ! 81: os_swi(OS_ReadDynamicArea, r); ! 82: if (r[1] < 320*480*2) { ! 83: r[1]-= 320*480*2; ! 84: i = r[1]; ! 85: errblk = os_swi(OS_ChangeDynamicArea, r); ! 86: if (errblk) { ! 87: fprintf(stderr, errblk->errmess); ! 88: exit(1); ! 89: } ! 90: if (r[1] != i) { ! 91: fprintf(stderr, "Cannot allocate enough screen memory\n"); ! 92: exit(1); ! 93: } ! 94: } ! 95: in[0] = 149; ! 96: in[1] = -1; ! 97: r[0] = (uint32)in; ! 98: r[1] = (uint32)out; ! 99: errblk = os_swi(OS_ReadVduVariables, r); ! 100: if (errblk) { ! 101: fprintf(stderr, errblk->errmess); ! 102: exit(1); ! 103: } ! 104: screenaddr = (uint8 *)(out[0]); ! 105: ! 106: cpu68k_skip = 2; ! 107: vdp_basepixel = 32; ! 108: ! 109: ui_bank = 0; ! 110: ! 111: return(0); ! 112: } ! 113: ! 114: char *ui_setinfo(char *name, char *copyright) ! 115: { ! 116: return 0; ! 117: } ! 118: ! 119: int ui_loop(void) ! 120: { ! 121: char *retstr; ! 122: ! 123: if ((retstr = gen_loadimage(file))) { ! 124: fprintf(stderr, retstr); ! 125: exit(1); ! 126: } ! 127: ui_run(); ! 128: return 0; ! 129: } ! 130: ! 131: void ui_line(unsigned int line) ! 132: { ! 133: vdp_renderline(line, screenaddr+ui_bank*320*480+640*line); ! 134: } ! 135: ! 136: void ui_endframe(void) ! 137: { ! 138: unsigned int i; ! 139: uint16 ent; ! 140: static uint32 cbuf[256]; ! 141: uint32 r[10]; ! 142: uint8 red, green, blue; ! 143: ! 144: ui_bank^= 1; ! 145: ! 146: r[0] = 19; ! 147: r[1] = 0; ! 148: r[2] = 0; ! 149: os_swi(OS_Byte, r); ! 150: ! 151: r[0] = 113; ! 152: r[1] = (ui_bank^1) + 1; ! 153: os_swi(OS_Byte, r); ! 154: ! 155: r[0] = 112; ! 156: r[1] = ui_bank + 1; ! 157: os_swi(OS_Byte, r); ! 158: ! 159: cbuf[0] = 0; ! 160: cbuf[1] = 0xFFFFFF00; ! 161: cbuf[255] = 0xFFFFFF00; ! 162: ! 163: for (i = 0; i < 64; i++) { ! 164: ent = LOCENDIAN16(((uint16 *)vdp_cram)[i]); ! 165: blue = (ent>>9) & 7; ! 166: green = (ent>>5) & 7; ! 167: red = (ent>>1) & 7; ! 168: cbuf[vdp_basepixel+i] = blue<<29 | green<<21 | red<<13; ! 169: cbuf[vdp_basepixel+64+i] = blue<<28 | green<<20 | red<<12; ! 170: cbuf[vdp_basepixel+128+i] = 0x80808000 | (blue<<28 | green<<20 | red<<12); ! 171: } ! 172: r[0] = -1; ! 173: r[1] = -1; ! 174: r[2] = (uint32)cbuf; ! 175: r[3] = 0; ! 176: r[4] = 0; ! 177: os_swi(ColourTrans_WritePalette, r); ! 178: return; ! 179: } ! 180: ! 181: void ui_run(void) ! 182: { ! 183: uint32 r[10]; ! 184: uint32 lasttime = 0; ! 185: uint32 frames = 0; ! 186: uint32 clocks = 0; ! 187: struct timeval tv; ! 188: char tmp[100]; ! 189: uint32 start; ! 190: ! 191: gettimeofday(&tv, NULL); ! 192: start = tv.tv_sec; ! 193: ! 194: while(0==0) { ! 195: reg68k_framestep(); ! 196: gettimeofday(&tv, NULL); ! 197: if (tv.tv_sec != lasttime) { ! 198: os_vdu(7); ! 199: os_vdu(4); ! 200: os_vdu(31); ! 201: os_vdu(0); ! 202: os_vdu(59); ! 203: sprintf(tmp, "%02d %08X %04d", cpu68k_frames - frames, regs.pc, ! 204: tv.tv_sec - start); ! 205: r[0] = (uint32)tmp; ! 206: os_swi(OS_Write0, r); ! 207: frames = cpu68k_frames; ! 208: clocks = reg68k_clocks; ! 209: lasttime = tv.tv_sec;; ! 210: } ! 211: /* ! 212: if (cpu68k_frames > 2000) { ! 213: os_swi(OS_ReadC, r); ! 214: } ! 215: */ ! 216: } ! 217: } ! 218: ! 219: void ui_final(void) ! 220: { ! 221: return; ! 222: } ! 223: int atexit(void (*func)(void)) { ! 224: return -1; ! 225: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.