|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * BeBox port specific stuff ! 5: * ! 6: * (c) 1996 Christian Bauer ! 7: * (c) 1996 Patrick Hanevold ! 8: */ ! 9: ! 10: #define VersionStr "0.6.4" ! 11: ! 12: #include <AppKit.h> ! 13: #include <InterfaceKit.h> ! 14: #include <KernelKit.h> ! 15: #include <Record.h> ! 16: #include <File.h> ! 17: ! 18: #include <stdio.h> ! 19: #include <stdlib.h> ! 20: #include <string.h> ! 21: #define __STDC__ 1 ! 22: #define __GNU_LIBRARY__ ! 23: #include <getopt.h> ! 24: #undef __GNU_LIBRARY__ ! 25: #undef __STDC__ ! 26: ! 27: #ifndef __bebox__ ! 28: #error Compiling bebox.cpp, but __bebox__ unset. ! 29: #endif ! 30: ! 31: #include "bebox.h" ! 32: ! 33: extern void deinit_sound(void); ! 34: ! 35: ! 36: /* ! 37: * Create application object and start it ! 38: */ ! 39: ! 40: UAE *the_app; ! 41: ! 42: main() ! 43: { ! 44: the_app = new UAE(); ! 45: the_app->Run(); ! 46: delete the_app; ! 47: ! 48: return 0; ! 49: } ! 50: ! 51: ! 52: /* ! 53: * UAE Constructor: Initialize member variables ! 54: */ ! 55: ! 56: UAE::UAE() : BApplication('UAEm') ! 57: { ! 58: the_bitmap = NULL; ! 59: the_emulator = NULL; ! 60: main_window = NULL; ! 61: window_open = FALSE; ! 62: // Init Key events ! 63: CurentEvent = (Event*)malloc(sizeof(Event)); ! 64: LastEvent=CurentEvent; ! 65: CurentEvent->Age=0; ! 66: CurentEvent->Next=0; ! 67: } ! 68: ! 69: void UAE::ArgvReceived(int argc, char **argv) ! 70: { ! 71: parse_cmdline(argc,argv); ! 72: } ! 73: ! 74: /* ! 75: * Arguments processed, create and start emulation ! 76: */ ! 77: ! 78: void UAE::ReadyToRun(void) ! 79: { ! 80: vsize = correct_aspect ? 2*numscrlines : numscrlines; ! 81: hsize = use_lores ? 400 : 800; ! 82: hpixels = use_lores ? 320 : 796; ! 83: ! 84: // Allocate bitmap ! 85: the_bitmap = new BBitmap(BRect(0, 0, hsize-1, vsize-1), B_COLOR_8_BIT); ! 86: ! 87: // Set up vidinfo ! 88: gfxvidinfo.bufmem = (char *)the_bitmap->Bits(); ! 89: gfxvidinfo.rowbytes = the_bitmap->BytesPerRow(); ! 90: gfxvidinfo.pixbytes = 1; ! 91: gfxvidinfo.maxblocklines = 100; ! 92: gfxvidinfo.maxlinetoscr = 0; ! 93: gfxvidinfo.x_adjust = 0; ! 94: gfxvidinfo.maxline = 100000; /* ??? */ ! 95: ! 96: // Open window ! 97: main_window = new UAEWindow(BRect(0, 0, hpixels-1, vsize+B_MENU_BAR_HEIGHT), the_bitmap); ! 98: ! 99: // Initialize mouse and keyboard variables ! 100: buttonstate[0] = buttonstate[1] = buttonstate[2] = FALSE; ! 101: lastmx = lastmy = 0; ! 102: newmousecounters = FALSE; ! 103: inwindow = TRUE; ! 104: ! 105: // Start emulation ! 106: the_emulator = new Emulator; ! 107: the_emulator->Run(); ! 108: } ! 109: ! 110: ! 111: /* ! 112: * Quit requested (either by menu or by closing the window) ! 113: */ ! 114: ! 115: bool UAE::QuitRequested(void) ! 116: { ! 117: if (BApplication::QuitRequested()) { ! 118: ! 119: // Stop emulation ! 120: if (the_emulator) { ! 121: the_emulator->Quit(); ! 122: delete the_emulator; ! 123: } ! 124: ! 125: // Deallocate bitmap ! 126: if (the_bitmap) ! 127: delete the_bitmap; ! 128: ! 129: return TRUE; ! 130: } ! 131: return FALSE; ! 132: } ! 133: ! 134: ! 135: /* ! 136: * Display "about" window ! 137: */ ! 138: ! 139: void UAE::AboutRequested(void) ! 140: { ! 141: char str[256]; ! 142: ! 143: sprintf(str, " Un*x Amiga Emulator V"VersionStr"\n" ! 144: " by Bernd Schmidt\n" ! 145: " BeBox port by Christian Bauer\n" ! 146: "Additional porting by Patrick Hanevold"); ! 147: BAlert *the_alert = new BAlert("", str, "OK"); ! 148: the_alert->Go(); ! 149: } ! 150: ! 151: //void UAE::MessageReceived(BMessage *Msg) ! 152: //{ ! 153: // switch(Msg->what) ! 154: // { ! 155: // default: ! 156: // BApplication::MessageReceived(Msg); ! 157: // } ! 158: //} ! 159: ! 160: char *DiskName[4]; ! 161: char *FileName[4]; ! 162: int FloppyN; ! 163: ! 164: void UAE::RefsReceived(BMessage *Msg) ! 165: { ! 166: ulong type; ! 167: long count; ! 168: BFile *File; ! 169: BDirectory *dir,*dir2; ! 170: char FileNm[256]; // = (char*)Msg->FindString("filename"); ! 171: char Path1[512]=""; ! 172: char Path2[512]=""; ! 173: int err; ! 174: ! 175: Msg->GetInfo("refs",&type,&count); ! 176: for(long n=--count;n>=0;n--){ ! 177: record_ref item = Msg->FindRef("refs",n); ! 178: if(item.database>=0 && item.record>=0){ ! 179: if(does_ref_conform(item,"File")){ ! 180: File = new BFile; ! 181: File->SetRef(item); ! 182: File->GetName(FileNm); ! 183: DiskName[FloppyN]=FileNm; ! 184: File->GetName(Path2); ! 185: dir = new BDirectory; ! 186: dir2 = new BDirectory; ! 187: err = File->GetParent(dir); ! 188: while(err == B_NO_ERROR) ! 189: { ! 190: dir->GetName(Path1); ! 191: if(strlen(Path2)) ! 192: { ! 193: strcat(Path1,"/"); ! 194: strcat(Path1,Path2); ! 195: } ! 196: strcpy(Path2,Path1); ! 197: err = dir->GetParent(dir2); ! 198: if(err==B_NO_ERROR) dir->SetRef(dir2->Record()->Ref()); ! 199: } ! 200: strcpy(Path1,"/"); ! 201: strcat(Path1,Path2); ! 202: // strcpy(FileName[FloppyN],Path1); ! 203: FileName[FloppyN]=Path1; ! 204: disk_eject(FloppyN); ! 205: disk_insert(FloppyN,Path1); ! 206: delete(dir); ! 207: delete(dir2); ! 208: delete(File); ! 209: } ! 210: //else BRecord *rec = new BRecord(item); ! 211: } ! 212: } ! 213: } ! 214: ! 215: void UAE::FilePanelClosed(BMessage *Msg) ! 216: { ! 217: } ! 218: ! 219: void UAE::RequestFile(char *Title,int Drive) ! 220: { ! 221: FloppyN=Drive; ! 222: RunFilePanel(Title,"Insert","Eject",FALSE,NULL); ! 223: } ! 224: ! 225: /* ! 226: * UAE Window constructor ! 227: */ ! 228: ! 229: LEDView *PowerLED,*DriveLED; ! 230: ! 231: #define M_DF0 'MDF0' ! 232: #define M_DF1 'MDF1' ! 233: #define M_DF2 'MDF2' ! 234: #define M_DF3 'MDF3' ! 235: #define M_FR1 'MFR1' ! 236: #define M_FR2 'MFR2' ! 237: #define M_FR3 'MFR3' ! 238: #define M_FR4 'MFR4' ! 239: #define M_FR5 'MFR5' ! 240: #define M_FR6 'MFR6' ! 241: #define M_FR7 'MFR7' ! 242: ! 243: UAEWindow::UAEWindow(BRect frame, BBitmap *bitmap) : BWindow(frame,"UAE "VersionStr, B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) ! 244: { ! 245: BRect MenuRect = Bounds(); ! 246: BRect PowerRect = Bounds(); ! 247: BRect DriveRect = Bounds(); ! 248: BRect MeterRect = Bounds(); ! 249: MenuRect.bottom = MenuRect.top + B_MENU_BAR_HEIGHT; ! 250: MenuRect.right -= 8; ! 251: DriveRect.bottom = MenuRect.bottom; ! 252: DriveRect.left = MenuRect.right+1; ! 253: DriveRect.right = DriveRect.left+3; ! 254: PowerRect.bottom = MenuRect.bottom; ! 255: PowerRect.left = DriveRect.right+1; ! 256: PowerRect.right = PowerRect.left+3; ! 257: MeterRect.left += 50; ! 258: MeterRect.right -= 15; ! 259: MeterRect.top += 5; ! 260: MeterRect.bottom = B_MENU_BAR_HEIGHT-5; ! 261: ! 262: BView *DriveView = new BView(DriveRect,"",B_FOLLOW_NONE, B_WILL_DRAW); ! 263: ! 264: BMenuBar *MenuBar = new BMenuBar(MenuRect,"MenuBar",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP, B_ITEMS_IN_ROW, FALSE); ! 265: ! 266: BMenu *Menu; ! 267: BMenu *SubMenu; ! 268: BMenuItem *DriveItem[4],*RateItem[7]; ! 269: ! 270: DiskName[0]=df0; ! 271: DiskName[1]=df1; ! 272: DiskName[2]=df2; ! 273: DiskName[3]=df3; ! 274: Menu = new BMenu("Amiga", B_ITEMS_IN_COLUMN); MenuBar->AddItem(Menu); ! 275: SubMenu = new BMenu("Floppy", B_ITEMS_IN_COLUMN); Menu->AddItem(SubMenu); ! 276: DriveItem[0] = new BMenuItem(DiskName[0], new BMessage(M_DF0), NULL); SubMenu->AddItem(DriveItem[0]); ! 277: DriveItem[1] = new BMenuItem(DiskName[1], new BMessage(M_DF1), NULL); SubMenu->AddItem(DriveItem[1]); ! 278: DriveItem[2] = new BMenuItem(DiskName[2], new BMessage(M_DF2), NULL); SubMenu->AddItem(DriveItem[2]); ! 279: DriveItem[3] = new BMenuItem(DiskName[3], new BMessage(M_DF3), NULL); SubMenu->AddItem(DriveItem[3]); ! 280: SubMenu = new BMenu("Framerate", B_ITEMS_IN_COLUMN); Menu->AddItem(SubMenu); ! 281: SubMenu->SetRadioMode(TRUE); ! 282: RateItem[0] = new BMenuItem("1/1", new BMessage(M_FR1), NULL); SubMenu->AddItem(RateItem[0]); ! 283: RateItem[1] = new BMenuItem("1/2", new BMessage(M_FR2), NULL); SubMenu->AddItem(RateItem[1]); ! 284: RateItem[2] = new BMenuItem("1/3", new BMessage(M_FR3), NULL); SubMenu->AddItem(RateItem[2]); ! 285: RateItem[3] = new BMenuItem("1/4", new BMessage(M_FR4), NULL); SubMenu->AddItem(RateItem[3]); ! 286: RateItem[4] = new BMenuItem("1/5", new BMessage(M_FR5), NULL); SubMenu->AddItem(RateItem[4]); ! 287: RateItem[5] = new BMenuItem("1/6", new BMessage(M_FR6), NULL); SubMenu->AddItem(RateItem[5]); ! 288: RateItem[6] = new BMenuItem("1/7", new BMessage(M_FR7), NULL); SubMenu->AddItem(RateItem[6]); ! 289: RateItem[3]->SetMarked(TRUE); ! 290: ! 291: AddChild(MenuBar); ! 292: // AddChild(DriveView); ! 293: // Lock(); ! 294: // DriveView->SetHighColor(0xff,0,0); ! 295: // DriveView->FillRect(DriveRect,B_SOLID_HIGH); ! 296: // Unlock(); ! 297: ! 298: // SetPulseRate(500000.0/100.0); ! 299: ! 300: DriveLED = new LEDView(DriveRect,0xff,0x80,0,0x80,0x40,0); ! 301: AddChild(DriveLED); ! 302: PowerLED = new LEDView(PowerRect,0,0xe0,0,0,0xb0,0); ! 303: AddChild(PowerLED); ! 304: MeterView *Meter = new MeterView(MeterRect); ! 305: AddChild(Meter); ! 306: ! 307: int r, g, b, i; ! 308: ! 309: // Move window to right position ! 310: MoveTo(80, 60); ! 311: ! 312: // Create bitmap view ! 313: Lock(); ! 314: frame.Set(0,B_MENU_BAR_HEIGHT+1,hsize-1,vsize+B_MENU_BAR_HEIGHT); ! 315: main_view = new BitmapView(frame, bitmap); ! 316: AddChild(main_view); ! 317: main_view->MakeFocus(); ! 318: main_view->GetKeys(&old_key_info, FALSE); ! 319: Unlock(); ! 320: ! 321: bitmap_view = main_view; ! 322: bitmap_window = this; ! 323: ! 324: // Initialize xcolors ! 325: i = 0; ! 326: for (r=0; r<16; r++) { ! 327: for (g=0; g<16; g++) { ! 328: for (b=0; b<16; b++) ! 329: xcolors[i++] = index_for_color(r<<4 | r, g<<4 | g, b<<4 | b); ! 330: } ! 331: } ! 332: ! 333: // Show window ! 334: Show(); ! 335: window_open = TRUE; ! 336: } ! 337: ! 338: void UAEWindow::MessageReceived(BMessage *Msg) ! 339: { ! 340: switch(Msg->what) ! 341: { ! 342: case M_DF0: ! 343: the_app->RequestFile("Insert floppy in DF0:",0); ! 344: break; ! 345: case M_DF1: ! 346: the_app->RequestFile("Insert floppy in DF1:",1); ! 347: break; ! 348: case M_DF2: ! 349: the_app->RequestFile("Insert floppy in DF2:",2); ! 350: break; ! 351: case M_DF3: ! 352: the_app->RequestFile("Insert floppy in DF3:",3); ! 353: break; ! 354: case M_FR1: ! 355: framerate = 1; ! 356: break; ! 357: case M_FR2: ! 358: framerate = 2; ! 359: break; ! 360: case M_FR3: ! 361: framerate = 3; ! 362: break; ! 363: case M_FR4: ! 364: framerate = 4; ! 365: break; ! 366: case M_FR5: ! 367: framerate = 5; ! 368: break; ! 369: case M_FR6: ! 370: framerate = 6; ! 371: break; ! 372: case M_FR7: ! 373: framerate = 7; ! 374: break; ! 375: default: ! 376: printf("Err\n"); ! 377: BWindow::MessageReceived(Msg); ! 378: } ! 379: } ! 380: ! 381: /* ! 382: * Closing the window quits UAE ! 383: */ ! 384: ! 385: bool UAEWindow::QuitRequested(void) ! 386: { ! 387: window_open = FALSE; ! 388: be_app->PostMessage(B_QUIT_REQUESTED); ! 389: return TRUE; ! 390: } ! 391: ! 392: ! 393: /* ! 394: * Window was (de)activated ! 395: */ ! 396: ! 397: void UAEWindow::WindowActivated(bool active) ! 398: { ! 399: inwindow = active; ! 400: } ! 401: ! 402: /* ! 403: * Bitmap view constructor ! 404: */ ! 405: ! 406: BitmapView::BitmapView(BRect frame, BBitmap *bitmap) : BView(frame, "", B_FOLLOW_NONE, B_WILL_DRAW) ! 407: { ! 408: the_bitmap = bitmap; ! 409: } ! 410: ! 411: ! 412: /* ! 413: * Blit the bitmap ! 414: */ ! 415: ! 416: void BitmapView::Draw(BRect update) ! 417: { ! 418: int xs = use_lores ? prev_max_diwstop - 328 : 0; ! 419: BRect from=update; ! 420: from.left+=xs; ! 421: from.right+=xs; ! 422: DrawBitmap(the_bitmap, from, update); ! 423: } ! 424: ! 425: void BitmapView::Draw(BRect from, BRect to) ! 426: { ! 427: DrawBitmap(the_bitmap, from, to); ! 428: } ! 429: ! 430: //char KeyState[256]; ! 431: char RawKeys[128]={ ! 432: // 0 1 2 3 4 5 6 7 8 9 A B C D E F ! 433: /* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, AK_BS,AK_TAB,AK_RET,0, 0, 0, 0, 0, ! 434: /* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, AK_ESC, 0, 0, 0, 0, ! 435: /* 20 */ AK_SPC,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, AK_NPADD, 0, AK_NPSUB,0, 0, ! 436: /* 30 */ AK_0, AK_1,AK_2,AK_3,AK_4,AK_5,AK_6,AK_7,AK_8, AK_9, 0, AK_SEMICOLON,0, 0, 0, 0, ! 437: /* 40 */ 0, AK_A,AK_B,AK_C,AK_D,AK_E,AK_F,AK_G,AK_H, AK_I, AK_J, AK_K, AK_L, AK_M, AK_N,AK_O, ! 438: /* 50 */ AK_P, AK_Q,AK_R,AK_S,AK_T,AK_U,AK_V,AK_W,AK_X, AK_Y, AK_Z, 0, AK_BACKSLASH,0, 0, 0, ! 439: /* 60 */ 0, AK_A,AK_B,AK_C,AK_D,AK_E,AK_F,AK_G,AK_H, AK_I, AK_J, AK_K, AK_L, AK_M, AK_N,AK_O, ! 440: /* 70 */ AK_P, AK_Q,AK_R,AK_S,AK_T,AK_U,AK_V,AK_W,AK_X, AK_Y, AK_Z, 0, 0, 0, 0, AK_DEL}; ! 441: ! 442: void BitmapView::KeyDown(ulong aChar) ! 443: { ! 444: // printf("$%x\n",aChar); ! 445: /* ! 446: Event *NewEvent=(Event*)malloc(sizeof(Event)); ! 447: NewEvent->Next=0; ! 448: NewEvent->Age=3; ! 449: if((aChar>0x40)&&(aChar<0x5b)){ ! 450: NewEvent->Key=AK_LSH; ! 451: LastEvent->Next=NewEvent; ! 452: LastEvent=NewEvent; ! 453: NewEvent=(Event*)malloc(sizeof(Event)); ! 454: NewEvent->Next=0; ! 455: NewEvent->Age=3; ! 456: NewEvent->Key=RawKeys[aChar]; ! 457: LastEvent->Next=NewEvent; ! 458: LastEvent=NewEvent; ! 459: NewEvent=(Event*)malloc(sizeof(Event)); ! 460: NewEvent->Next=0; ! 461: NewEvent->Age=3; ! 462: NewEvent->Key=AK_LSH; ! 463: }else{ ! 464: switch(aChar) ! 465: { ! 466: case 0x3a: ! 467: NewEvent->Key=AK_LSH; ! 468: LastEvent->Next=NewEvent; ! 469: LastEvent=NewEvent; ! 470: NewEvent=(Event*)malloc(sizeof(Event)); ! 471: NewEvent->Next=0; ! 472: NewEvent->Age=3; ! 473: NewEvent->Key=AK_SEMICOLON; ! 474: LastEvent->Next=NewEvent; ! 475: LastEvent=NewEvent; ! 476: NewEvent=(Event*)malloc(sizeof(Event)); ! 477: NewEvent->Next=0; ! 478: NewEvent->Age=3; ! 479: NewEvent->Key=AK_LSH; ! 480: break; ! 481: default: ! 482: NewEvent->Key=RawKeys[aChar]; ! 483: } ! 484: } ! 485: LastEvent->Next=NewEvent; ! 486: LastEvent=NewEvent; ! 487: */ ! 488: } ! 489: ! 490: /* ! 491: * LED ! 492: */ ! 493: ! 494: LEDView::LEDView(BRect frame, int aR, int aG, int aB, int iR, int iG, int iB) : BView(frame,"", B_FOLLOW_NONE, B_WILL_DRAW) ! 495: { ! 496: ActiveColor.R=aR; ! 497: ActiveColor.G=aG; ! 498: ActiveColor.B=aB; ! 499: IdleColor.R=iR; ! 500: IdleColor.G=iG; ! 501: IdleColor.B=iB; ! 502: State = FALSE; ! 503: } ! 504: ! 505: void LEDView::AttachedToWindow(void) ! 506: { ! 507: bounds = Bounds(); ! 508: } ! 509: ! 510: void LEDView::Draw(BRect update) ! 511: { ! 512: Refresh(); ! 513: } ! 514: ! 515: void LEDView::SetState(bool NewState) ! 516: { ! 517: if(NewState!=State) ! 518: { ! 519: State = NewState; ! 520: Refresh(); ! 521: } ! 522: } ! 523: ! 524: void LEDView::Refresh(void) ! 525: { ! 526: Window()->Lock(); ! 527: if(State) SetHighColor(ActiveColor.R,ActiveColor.G,ActiveColor.B); ! 528: else SetHighColor(IdleColor.R,IdleColor.G,IdleColor.B); ! 529: FillRect(bounds); ! 530: Window()->Unlock(); ! 531: } ! 532: ! 533: /* ! 534: * Meter ! 535: */ ! 536: ! 537: MeterView::MeterView(BRect frame) : BView(frame,"", B_FOLLOW_NONE, B_WILL_DRAW|B_PULSE_NEEDED) ! 538: { ! 539: } ! 540: ! 541: void MeterView::AttachedToWindow(void) ! 542: { ! 543: bounds = Bounds(); ! 544: } ! 545: ! 546: void MeterView::Draw(BRect) ! 547: { ! 548: Refresh(); ! 549: } ! 550: ! 551: void MeterView::Pulse(void) ! 552: { ! 553: Refresh(); ! 554: } ! 555: ! 556: void MeterView::Refresh(void) ! 557: { ! 558: ulong Speed=frametime/timeframes; ! 559: int Frames=Speed/20+1; ! 560: BRect Fine=bounds; ! 561: Fine.left=Fine.right-(bounds.right-bounds.left)/Frames; ! 562: Fine.right=Fine.left+(Speed-20*(Frames-1))*((bounds.right-bounds.left)/Frames)/20; ! 563: Window()->Lock(); ! 564: SetHighColor(0,0,0); ! 565: FillRect(bounds); ! 566: SetHighColor(255,0,0); ! 567: FillRect(Fine); ! 568: int R=255-200/Frames; ! 569: for(int n=Frames-1; n; n--){ ! 570: R-=200/Frames; ! 571: SetHighColor(R,0,0); ! 572: Fine.left=(n-1)*((bounds.right-bounds.left)/Frames); ! 573: Fine.right=n*((bounds.right-bounds.left)/Frames); ! 574: FillRect(Fine); ! 575: } ! 576: Window()->Unlock(); ! 577: } ! 578: ! 579: /* ! 580: * Start main emulation thread ! 581: */ ! 582: ! 583: void Emulator::Run(void) ! 584: { ! 585: // Initialize everything ! 586: produce_sound = TRUE; ! 587: init_sound(); ! 588: gui_init(); ! 589: init_joystick(); ! 590: keybuf_init (); ! 591: memory_init(); ! 592: custom_init(); ! 593: DISK_init(); ! 594: init_m68k(); ! 595: MC68000_reset(); ! 596: ! 597: // Start the emulation thread ! 598: the_thread = spawn_thread(thread_invoc, "UAE 68000", B_NORMAL_PRIORITY, this); ! 599: resume_thread(the_thread); ! 600: thread_running = TRUE; ! 601: } ! 602: ! 603: ! 604: /* ! 605: * Stop main emulation thread ! 606: */ ! 607: ! 608: void Emulator::Quit(void) ! 609: { ! 610: // Kill the thread if it is running ! 611: if (thread_running) { ! 612: kill_thread(the_thread); ! 613: thread_running = FALSE; ! 614: } ! 615: ! 616: close_joystick(); ! 617: deinit_sound(); ! 618: } ! 619: ! 620: ! 621: /* ! 622: * The thread's main function ! 623: */ ! 624: ! 625: long Emulator::thread_invoc(void *data) //Emulator *obj) ! 626: { ! 627: Emulator *obj = (Emulator*)data; ! 628: obj->thread_func(); ! 629: return 0; ! 630: } ! 631: ! 632: void Emulator::thread_func(void) ! 633: { ! 634: // This jumps to MC68000_run() and executes the main loop ! 635: debug(); ! 636: thread_running = FALSE; ! 637: } ! 638: ! 639: ! 640: /* ! 641: * Redraw a line ! 642: */ ! 643: ! 644: void flush_line(int y) ! 645: { ! 646: if (window_open) { ! 647: bitmap_window->Lock(); ! 648: bitmap_view->Draw(BRect(0, y, hpixels+-1, y)); ! 649: bitmap_window->Unlock(); ! 650: } ! 651: } ! 652: ! 653: ! 654: /* ! 655: * Redraw a block ! 656: */ ! 657: ! 658: void flush_block(int ystart, int ystop) ! 659: { ! 660: int xs = use_lores ? prev_max_diwstop - 328 : 0; ! 661: ! 662: if (window_open) { ! 663: bitmap_window->Lock(); ! 664: bitmap_view->Draw(BRect(xs, ystart, hpixels+xs-1, ystop), BRect(0, ystart, hpixels-1, ystop)); ! 665: bitmap_window->Unlock(); ! 666: } ! 667: } ! 668: ! 669: ! 670: /* ! 671: * Redraw the screen ! 672: */ ! 673: ! 674: void flush_screen(int ystart, int ystop) ! 675: { ! 676: } ! 677: ! 678: ! 679: /* ! 680: * Poll mouse and keyboard ! 681: */ ! 682: ! 683: void handle_events(void) ! 684: { ! 685: key_info the_key_info; ! 686: int be_code, be_byte, be_bit, amiga_code; ! 687: BPoint mouse_point; ! 688: ulong mouse_buttons; ! 689: ! 690: // Keyboard ! 691: if (window_open && inwindow) { ! 692: bitmap_window->Lock(); ! 693: bitmap_view->GetKeys(&the_key_info, FALSE); ! 694: bitmap_window->Unlock(); ! 695: ! 696: for (be_code=0; be_code<0x80; be_code++) { ! 697: be_byte = be_code >> 3; ! 698: be_bit = 1 << (~be_code & 7); ! 699: ! 700: // Key state changed? ! 701: if ((the_key_info.key_states[be_byte] & be_bit) ! 702: != (old_key_info.key_states[be_byte] & be_bit)) { ! 703: ! 704: amiga_code = keycode2amiga[be_code]; ! 705: if (the_key_info.key_states[be_byte] & be_bit) { ! 706: ! 707: // Key pressed ! 708: if (amiga_code == AK_mousestuff) ! 709: togglemouse(); ! 710: else ! 711: printf("Key\n"); ! 712: record_key(amiga_code << 1); ! 713: } else { ! 714: ! 715: // Key released ! 716: record_key((amiga_code << 1) | 1); ! 717: } ! 718: } ! 719: } ! 720: old_key_info = the_key_info; ! 721: ! 722: // "Affengriff" ! 723: if ((the_key_info.key_states[0x5c >> 3] & (1 << (~0x5c & 7))) ! 724: && (the_key_info.key_states[0x5d >> 3] & (1 << (~0x5d & 7))) ! 725: && (the_key_info.key_states[0x5f >> 3] & (1 << (~0x5f & 7)))) ! 726: MC68000_reset(); ! 727: ! 728: // Scroll lock toggles inhibit_frame ! 729: inhibit_frame = the_key_info.key_states[0x0f >> 3] & (1 << (~0x0f & 7)); ! 730: /* ! 731: static bool ShiftState=FALSE; ! 732: if(CurentEvent->Age){ ! 733: if(CurentEvent->Key==AK_LSH){ ! 734: CurentEvent->Age--; ! 735: if(CurentEvent->Age==2){ ! 736: if(ShiftState) {record_key((AK_LSH<<1)|1); ShiftState=FALSE; printf("ShU\n");} ! 737: else {record_key(AK_LSH<<1); ShiftState=TRUE; printf("ShD\n");} ! 738: } ! 739: }else{ ! 740: CurentEvent->Age--; ! 741: if(CurentEvent->Age==2) record_key(CurentEvent->Key<<1); ! 742: if(CurentEvent->Age==0) record_key((CurentEvent->Key<<1)|1); ! 743: } ! 744: } ! 745: else{ ! 746: if(CurentEvent->Next) ! 747: { ! 748: Event *TrashEvent=CurentEvent; ! 749: CurentEvent=CurentEvent->Next; ! 750: free(TrashEvent); ! 751: } ! 752: } ! 753: */ ! 754: } ! 755: // Mouse ! 756: if (window_open && inwindow) { ! 757: bitmap_window->Lock(); ! 758: bitmap_view->GetMouse(&mouse_point, &mouse_buttons, FALSE); ! 759: bitmap_window->Unlock(); ! 760: lastmx = mouse_point.x; ! 761: lastmy = mouse_point.y; ! 762: ! 763: if(lastmx>=0&&lastmy>=0&&lastmx<hsize&&lastmy<vsize){ ! 764: buttonstate[0] = mouse_buttons & B_PRIMARY_MOUSE_BUTTON; ! 765: buttonstate[1] = mouse_buttons & B_TERTIARY_MOUSE_BUTTON; ! 766: buttonstate[2] = mouse_buttons & B_SECONDARY_MOUSE_BUTTON; ! 767: } ! 768: } ! 769: } ! 770: ! 771: int debuggable(void) ! 772: { ! 773: return TRUE; ! 774: } ! 775: ! 776: int needmousehack(void) ! 777: { ! 778: return TRUE; ! 779: } ! 780: ! 781: void LED(int on) ! 782: { ! 783: // printf("PowerLED: %d\n",on); ! 784: PowerLED->SetState((bool)~on); ! 785: } ! 786: ! 787: bool LEDs[4]; ! 788: ! 789: void gui_led(int led, int on) ! 790: { ! 791: if(led<4) ! 792: { ! 793: LEDs[led]=on; ! 794: DriveLED->SetState(LEDs[0]|LEDs[1]|LEDs[2]|LEDs[3]); ! 795: // printf("DriveLeds: %d,%d,%d,%d\n",LEDs[0],LEDs[1],LEDs[2],LEDs[3]); ! 796: } ! 797: } ! 798: ! 799: void calc_adjustment(void) ! 800: { ! 801: gfxvidinfo.x_adjust = 0; ! 802: } ! 803: ! 804: void target_specific_usage(void) ! 805: { ! 806: } ! 807: ! 808: int quit_program; ! 809: ! 810: static void sigchldhandler(int foo) ! 811: { ! 812: } ! 813: ! 814: int gui_init(void) ! 815: { ! 816: LEDs[0]=LEDs[1]=LEDs[2]=LEDs[3]=FALSE; ! 817: quit_program = 0; ! 818: return 0; ! 819: } ! 820: ! 821: void gui_exit(void) ! 822: { ! 823: } ! 824: ! 825: //void gui_led(int led, int on) ! 826: //{ ! 827: //} ! 828: ! 829: void gui_filename(int num, char *name) ! 830: { ! 831: } ! 832: ! 833: static void getline(char *p) ! 834: { ! 835: } ! 836: ! 837: void gui_handle_events(void) ! 838: { ! 839: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.