From f3e5bb2807319c210d124d6150e019130c54867b Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 30 Oct 2008 12:48:57 +0000 Subject: [PATCH] Fixed fullscreen<-->windowed mode swith in OpenGL mode, phase one of removal of all undeclared externs --- Makefile | 1 + src/cdrom.cpp | 238 +++++++++++++++--------------- src/dsp.h | 4 + src/gui.cpp | 347 ++------------------------------------------ src/gui.h | 8 +- src/jaguar.cpp | 35 +++-- src/jaguar.h | 42 ++---- src/jerry.cpp | 30 ++-- src/joystick.cpp | 70 ++++----- src/joystick.h | 20 ++- src/sdlemu_opengl.c | 83 ++++++----- src/video.cpp | 105 ++++++++------ src/video.h | 4 + src/vj.cpp | 35 +---- vj.cfg | 4 +- 15 files changed, 352 insertions(+), 674 deletions(-) diff --git a/Makefile b/Makefile index 3746100..2d417f7 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ OBJS = \ obj/dac.o \ obj/dsp.o \ obj/eeprom.o \ + obj/file.o \ obj/gpu.o \ obj/gui.o \ obj/jagdasm.o \ diff --git a/src/cdrom.cpp b/src/cdrom.cpp index 1eb8445..a7569ac 100644 --- a/src/cdrom.cpp +++ b/src/cdrom.cpp @@ -46,7 +46,7 @@ I2SDAT2 equ BUTCH+$28 ; i2s FIFO data ; bit5 - CD module command receive buffer full ; bit6 - CIRC failure interrupt ; -; bit7-31 reserved, set to 0 +; bit7-31 reserved, set to 0 ; ; When read (Long): ; @@ -139,7 +139,7 @@ static uint16 CDROMBusRead(void); const char * BReg[12] = { "BUTCH", "DSCNTRL", "DS_DATA", "???", "I2CNTRL", "SBCNTRL", "SUBDATA", "SUBDATB", "SB_TIME", "FIFO_DATA", "I2SDAT2", "UNKNOWN" }; -extern const char * whoName[9]; +//extern const char * whoName[9]; static uint8 cdRam[0x100]; @@ -233,7 +233,7 @@ void BUTCHExec(uint32 cycles) // We're chickening out for now... return; #else - extern uint8 * jerry_ram_8; // Hmm. +// extern uint8 * jerry_ram_8; // Hmm. // For now, we just do the FIFO interrupt. Timing is also likely to be WRONG as well. uint32 cdState = GET32(cdRam, BUTCH); @@ -278,7 +278,7 @@ uint16 CDROMReadWord(uint32 offset, uint32 who/*=UNKNOWN*/) offset &= 0xFF; uint16 data = 0x0000; - + if (offset == BUTCH) data = 0x0000; else if (offset == BUTCH + 2) @@ -938,116 +938,116 @@ CDINTF: Disc summary CDROM: Read sector 18517 (18667 - 150)... -0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0018: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0048: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0078: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00A8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00D8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0108: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0138: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0168: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0198: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -01B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -01C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -01F8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0228: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0258: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0288: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -02A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -02B8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -02D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -02E8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0318: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0348: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0378: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -03A8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -03C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -03D8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -03F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0408: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0438: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0468: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0498: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -04B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -04C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -04E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -04F8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0528: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0558: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0588: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -05A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -05B8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -05D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -05E8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0618: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0678: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -06A8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -06C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -06D8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -06F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0708: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0738: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0768: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -0798: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -07B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -07C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[54 41 49 52]54 41 -07E0: 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 -07F8: 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 -0810: 49 52 54 41 49 52[54 41 49 52]54 41 52 41 20 49 50 41 52 50 56 4F 44 45 -0828: 44 20 54 41 20 41 45 48 44 41 52 45 41 20 52 54 20 49[00 00 00 50]01 00 -0840: 80 83 FC 23 07 00 07 00 F0 00 0C 21 FC 23 07 00 07 00 F1 00 0C A1 FC 33 -0858: FF FF F0 00 4E 00 7C 2E 1F 00 FC FF 00 61 08 00 F9 4E 00 00 00 51 E7 48 -0870: 00 FE 39 30 F1 00 02 40 40 02 10 00 00 67 1C 00 79 42 01 00 8C D3 3C 34 -0888: 37 03 3C 30 81 05 3C 3C 0A 01 3C 38 F1 00 00 60 1A 00 FC 33 01 00 01 00 -08A0: 8C D3 3C 34 4B 03 3C 30 65 05 3C 3C 42 01 3C 38 1F 01 C0 33 01 00 88 D3 -08B8: C4 33 01 00 8A D3 00 32 41 E2 41 94 7C D4 04 00 7C 92 01 00 41 00 00 04 -08D0: C1 33 01 00 82 D3 C1 33 F0 00 3C 00 C2 33 01 00 80 D3 C2 33 F0 00 38 00 -08E8: C2 33 F0 00 3A 00 06 3A 44 9A C5 33 01 00 84 D3 44 DC C6 33 01 00 86 D3 -0900: F9 33 01 00 84 D3 F0 00 46 00 FC 33 FF FF F0 00 48 00 FC 23 00 00 00 00 -0918: F0 00 2A 00 FC 33 00 00 F0 00 58 00 DF 4C 7F 00 75 4E 00 00 00 00 00 00 +0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0018: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0048: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0078: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00A8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00D8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0108: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0138: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0168: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0198: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01F8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0228: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0258: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0288: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02B8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02E8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0318: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0348: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0378: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03A8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03D8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0408: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0438: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0468: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0498: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +04B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +04C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +04E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +04F8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0528: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0558: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0588: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +05A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +05B8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +05D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +05E8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0618: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0678: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +06A8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +06C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +06D8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +06F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0708: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0738: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0768: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0798: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +07B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +07C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[54 41 49 52]54 41 +07E0: 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 +07F8: 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 +0810: 49 52 54 41 49 52[54 41 49 52]54 41 52 41 20 49 50 41 52 50 56 4F 44 45 +0828: 44 20 54 41 20 41 45 48 44 41 52 45 41 20 52 54 20 49[00 00 00 50]01 00 +0840: 80 83 FC 23 07 00 07 00 F0 00 0C 21 FC 23 07 00 07 00 F1 00 0C A1 FC 33 +0858: FF FF F0 00 4E 00 7C 2E 1F 00 FC FF 00 61 08 00 F9 4E 00 00 00 51 E7 48 +0870: 00 FE 39 30 F1 00 02 40 40 02 10 00 00 67 1C 00 79 42 01 00 8C D3 3C 34 +0888: 37 03 3C 30 81 05 3C 3C 0A 01 3C 38 F1 00 00 60 1A 00 FC 33 01 00 01 00 +08A0: 8C D3 3C 34 4B 03 3C 30 65 05 3C 3C 42 01 3C 38 1F 01 C0 33 01 00 88 D3 +08B8: C4 33 01 00 8A D3 00 32 41 E2 41 94 7C D4 04 00 7C 92 01 00 41 00 00 04 +08D0: C1 33 01 00 82 D3 C1 33 F0 00 3C 00 C2 33 01 00 80 D3 C2 33 F0 00 38 00 +08E8: C2 33 F0 00 3A 00 06 3A 44 9A C5 33 01 00 84 D3 44 DC C6 33 01 00 86 D3 +0900: F9 33 01 00 84 D3 F0 00 46 00 FC 33 FF FF F0 00 48 00 FC 23 00 00 00 00 +0918: F0 00 2A 00 FC 33 00 00 F0 00 58 00 DF 4C 7F 00 75 4E 00 00 00 00 00 00 Raw P-W subchannel data: -00: 80 80 C0 80 80 80 80 C0 80 80 80 80 80 80 C0 80 -10: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 -20: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 C0 -30: 80 80 80 80 80 80 80 80 80 80 80 80 80 C0 80 80 -40: 80 80 80 80 C0 80 80 80 80 C0 C0 80 80 C0 C0 80 -50: C0 80 80 C0 C0 C0 80 80 C0 80 80 80 C0 80 80 80 +00: 80 80 C0 80 80 80 80 C0 80 80 80 80 80 80 C0 80 +10: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 +20: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 C0 +30: 80 80 80 80 80 80 80 80 80 80 80 80 80 C0 80 80 +40: 80 80 80 80 C0 80 80 80 80 C0 C0 80 80 C0 C0 80 +50: C0 80 80 C0 C0 C0 80 80 C0 80 80 80 C0 80 80 80 -P subchannel data: FF FF FF FF FF FF FF FF FF FF FF FF -Q subchannel data: 21 02 00 00 00 01 00 04 08 66 9C 88 +P subchannel data: FF FF FF FF FF FF FF FF FF FF FF FF +Q subchannel data: 21 02 00 00 00 01 00 04 08 66 9C 88 Run address: $5000, Length: $18380 */ @@ -1125,13 +1125,13 @@ read: .play: move.l d0,d1 ; mess with copy in d1 lsr.l #8,d1 ; shift the byte over - lsr.w #8,d1 + lsr.w #8,d1 or.w #$1000,d1 ; format it for goto move.w d1,DS_DATA ; DSA tx bsr.b DSA_tx move.l d0,d1 ; mess with copy in d1 - lsr.w #8,d1 + lsr.w #8,d1 or.w #$1100,d1 ; format it for goto move.w d1,DS_DATA ; DSA tx bsr.b DSA_tx @@ -1141,7 +1141,7 @@ read: or.w #$1200,d1 ; format it for goto move.w d1,DS_DATA ; DSA tx bsr.b DSA_tx - + rts @@ -1186,7 +1186,7 @@ HERE: ; Now we clear the DSARX interrupt in Butch subq #12,r24 ; does what the above says - load (r24),r26 ;Clears DSA pending interrupt + load (r24),r26 ;Clears DSA pending interrupt addq #6,r24 loadw (r24),r27 ; Read DSA response btst #10,r27 ; Check for error @@ -1213,9 +1213,9 @@ noerror: load (Ptrloc),Dataptr ;get pointer ; Check to see if we should stop - addq #4,Ptrloc + addq #4,Ptrloc load (Ptrloc),TEMP - subq #4,Ptrloc + subq #4,Ptrloc cmp Dataptr,TEMP jr pl,notend ; nop @@ -1227,7 +1227,7 @@ notend: move CDdata,r25 addq #4,CDdata loptop: - load (CDdata),TEMP + load (CDdata),TEMP load (r25),r30 load (CDdata),r21 load (r25),r22 @@ -1257,7 +1257,7 @@ loptop: exit_isr: movei #J_INT,r24 ; Acknowledge in Jerry moveq #1,TEMP - bset #8,TEMP + bset #8,TEMP storew TEMP,(r24) .if FLAG @@ -1312,7 +1312,7 @@ exit_isr: addq #2,r28 ;Fix it up - addq #4,r31 + addq #4,r31 jump (r28) ;Return store r29,(r30) ;Restore broken flags diff --git a/src/dsp.h b/src/dsp.h index 4dbb2f8..dc4b13c 100644 --- a/src/dsp.h +++ b/src/dsp.h @@ -31,6 +31,10 @@ void DSPExecP2(int32 cycles); //void DSPExecP3(int32 cycles); void DSPExecComp(int32 cycles); +// Exported vars + +extern bool doDSPDis; + // DSP interrupt numbers (in $F1A100, bits 4-8 & 16) enum { DSPIRQ_CPU = 0, DSPIRQ_SSI, DSPIRQ_TIMER0, DSPIRQ_TIMER1, DSPIRQ_EXT0, DSPIRQ_EXT1 }; diff --git a/src/gui.cpp b/src/gui.cpp index 9c8ec59..0ff948f 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -7,7 +7,6 @@ #include "gui.h" -#include #include // For MacOS dependency #include #include @@ -23,12 +22,10 @@ #include "font14pt.h" // Also 15, 16, 17, 18 #include "guielements.h" #include "crc32.h" -#include "zlib.h" -#include "unzip.h" #include "sdlemu_opengl.h" #include "log.h" #include "jaguar.h" -#include "eeprom.h" +#include "file.h" using namespace std; // For STL stuff @@ -55,22 +52,16 @@ Window * Quit(void); Window * About(void); Window * MiscOptions(void); -int gzfilelength(gzFile gd); - -// External variables - -extern uint8 * jaguar_mainRam; -extern uint8 * jaguar_mainRom; -extern uint8 * jaguar_bootRom; -extern uint8 * jaguar_CDBootROM; -extern bool BIOSLoaded; -extern bool CDBIOSLoaded; - // Local global variables +bool showGUI = false; bool exitGUI = false; // GUI (emulator) done variable int mouseX = 0, mouseY = 0; uint32 background[1280 * 256]; // GUI background buffer +bool showMessage = false; +//uint32 showMessageTimeout; +//char messageBuffer[200]; +bool finished = false; const char separator[] = "--------------------------------------------------------"; @@ -942,7 +933,7 @@ FileList::FileList(uint32 x, uint32 y, uint32 w, uint32 h): Window(x, y, w, h) AddElement(load); load->SetNotificationElement(this); -//!!! FIX !!! Directory might not exist--this shouldn't cause VJ to crash! +#warning !!! FIX !!! Directory might not exist--this shouldn't cause VJ to crash! DIR * dp = opendir(vjs.ROMPath); dirent * de; @@ -1642,7 +1633,7 @@ WriteLog("GUI: Inside GUIMain...\n"); pointerBGSave[1] = 8; // Need to set things up so that it loads and runs a file if given on the command line. !!! FIX !!! [DONE] - extern uint32 * backbuffer; +// extern uint32 * backbuffer; // bool done = false; SDL_Event event; Window * mainWindow = NULL; @@ -2046,12 +2037,12 @@ doGPUDis = true;//*/ bool debounceRunKey = true; Window * RunEmu(void) { - extern uint32 * backbuffer; +// extern uint32 * backbuffer; uint32 * overlayPixels = (uint32 *)sdlemuGetOverlayPixels(); memset(overlayPixels, 0x00, 640 * 480 * 4); // Clear out overlay... //This is crappy... !!! FIX !!! - extern bool finished, showGUI; +// extern bool finished, showGUI; sdlemuDisableOverlay(); @@ -2225,321 +2216,3 @@ Window * MiscOptions(void) return window; } - - -// -// Generic ROM loading -// -uint32 JaguarLoadROM(uint8 * rom, char * path) -{ -// We really should have some kind of sanity checking for the ROM size here to prevent -// a buffer overflow... !!! FIX !!! - uint32 romSize = 0; - -WriteLog("JaguarLoadROM: Attempting to load file '%s'...", path); - char * ext = strrchr(path, '.'); -if (ext == NULL) - WriteLog("FAILED!\n"); -else - WriteLog("Succeeded in finding extension (%s)!\n", ext); - - if (ext != NULL) - { - WriteLog("VJ: Loading \"%s\"...", path); - - if (strcasecmp(ext, ".zip") == 0) - { - // Handle ZIP file loading here... - WriteLog("(ZIPped)..."); - - if (load_zipped_file(0, 0, path, NULL, &rom, &romSize) == -1) - { - WriteLog("Failed!\n"); - return 0; - } - } - else - { -/* FILE * fp = fopen(path, "rb"); - - if (fp == NULL) - { - WriteLog("Failed!\n"); - return 0; - } - - fseek(fp, 0, SEEK_END); - romSize = ftell(fp); - fseek(fp, 0, SEEK_SET); - fread(rom, 1, romSize, fp); - fclose(fp);*/ - - // Handle gzipped files transparently [Adam Green]... - - gzFile fp = gzopen(path, "rb"); - - if (fp == NULL) - { - WriteLog("Failed!\n"); - return 0; - } - - romSize = gzfilelength(fp); - gzseek(fp, 0, SEEK_SET); - gzread(fp, rom, romSize); - gzclose(fp); - } - - WriteLog("OK (%i bytes)\n", romSize); - } - - return romSize; -} - -// -// Jaguar file loading -// -bool JaguarLoadFile(char * path) -{ -// jaguarRomSize = JaguarLoadROM(mem, path); - jaguarRomSize = JaguarLoadROM(jaguar_mainRom, path); - -/*//This is not *nix friendly for some reason... -// if (!UserSelectFile(path, newPath)) - if (!UserSelectFile((strlen(path) == 0 ? (char *)"." : path), newPath)) - { - WriteLog("VJ: Could not find valid ROM in directory \"%s\"...\nAborting!\n", path); - log_done(); - exit(0); - }*/ - - if (jaguarRomSize == 0) - { -// WriteLog("VJ: Could not load ROM from file \"%s\"...\nAborting!\n", newPath); - WriteLog("GUI: Could not load ROM from file \"%s\"...\nAborting load!\n", path); -// Need to do something else here, like throw up an error dialog instead of aborting. !!! FIX !!! -// log_done(); -// exit(0); - return false; // This is a start... - } - - jaguar_mainRom_crc32 = crc32_calcCheckSum(jaguar_mainRom, jaguarRomSize); - WriteLog("CRC: %08X\n", (unsigned int)jaguar_mainRom_crc32); - eeprom_init(); - - jaguarRunAddress = 0x802000; - - char * ext = strrchr(path, '.'); // Get the file's extension for non-cartridge checking - -//NOTE: Should fix JaguarLoadROM() to replace .zip with what's *in* the zip (.abs, .j64, etc.) - if (strcasecmp(ext, ".rom") == 0) - { - // File extension ".ROM": Alpine image that loads/runs at $802000 - WriteLog("GUI: Setting up homebrew (ROM)... Run address: 00802000, length: %08X\n", jaguarRomSize); - - for(int i=jaguarRomSize-1; i>=0; i--) - jaguar_mainRom[0x2000 + i] = jaguar_mainRom[i]; - - memset(jaguar_mainRom, 0xFF, 0x2000); -/* memcpy(jaguar_mainRam, jaguar_mainRom, jaguarRomSize); - memset(jaguar_mainRom, 0xFF, 0x600000); - memcpy(jaguar_mainRom + 0x2000, jaguar_mainRam, jaguarRomSize); - memset(jaguar_mainRam, 0x00, 0x400000);*/ - -/* -Stubulator ROM vectors... -handler 001 at $00E00008 -handler 002 at $00E008DE -handler 003 at $00E008E2 -handler 004 at $00E008E6 -handler 005 at $00E008EA -handler 006 at $00E008EE -handler 007 at $00E008F2 -handler 008 at $00E0054A -handler 009 at $00E008FA -handler 010 at $00000000 -handler 011 at $00000000 -handler 012 at $00E008FE -handler 013 at $00E00902 -handler 014 at $00E00906 -handler 015 at $00E0090A -handler 016 at $00E0090E -handler 017 at $00E00912 -handler 018 at $00E00916 -handler 019 at $00E0091A -handler 020 at $00E0091E -handler 021 at $00E00922 -handler 022 at $00E00926 -handler 023 at $00E0092A -handler 024 at $00E0092E -handler 025 at $00E0107A -handler 026 at $00E0107A -handler 027 at $00E0107A -handler 028 at $00E008DA -handler 029 at $00E0107A -handler 030 at $00E0107A -handler 031 at $00E0107A -handler 032 at $00000000 - -Let's try setting up the illegal instruction vector for a stubulated jaguar... -*/ -/* SET32(jaguar_mainRam, 0x08, 0x00E008DE); - SET32(jaguar_mainRam, 0x0C, 0x00E008E2); - SET32(jaguar_mainRam, 0x10, 0x00E008E6); // <-- Should be here (it is)... - SET32(jaguar_mainRam, 0x14, 0x00E008EA);//*/ - - // Try setting the vector to say, $1000 and putting an instruction there that loops forever: - // This kludge works! Yeah! - SET32(jaguar_mainRam, 0x10, 0x00001000); - SET16(jaguar_mainRam, 0x1000, 0x60FE); // Here: bra Here - } - else if (strcasecmp(ext, ".abs") == 0) - { - // File extension ".ABS": Atari linker output file with header (w/o is useless to us here) - -/* -ABS Format sleuthing (LBUGDEMO.ABS): - -000000 60 1B 00 00 05 0C 00 04 62 C0 00 00 04 28 00 00 -000010 12 A6 00 00 00 00 00 80 20 00 FF FF 00 80 25 0C -000020 00 00 40 00 - -DRI-format file detected... -Text segment size = 0x0000050c bytes -Data segment size = 0x000462c0 bytes -BSS Segment size = 0x00000428 bytes -Symbol Table size = 0x000012a6 bytes -Absolute Address for text segment = 0x00802000 -Absolute Address for data segment = 0x0080250c -Absolute Address for BSS segment = 0x00004000 - -(CRZDEMO.ABS): -000000 01 50 00 03 00 00 00 00 00 03 83 10 00 00 05 3b -000010 00 1c 00 03 00 00 01 07 00 00 1d d0 00 03 64 98 -000020 00 06 8b 80 00 80 20 00 00 80 20 00 00 80 3d d0 - -000030 2e 74 78 74 00 00 00 00 00 80 20 00 00 80 20 00 .txt (+36 bytes) -000040 00 00 1d d0 00 00 00 a8 00 00 00 00 00 00 00 00 -000050 00 00 00 00 00 00 00 20 -000058 2e 64 74 61 00 00 00 00 00 80 3d d0 00 80 3d d0 .dta (+36 bytes) -000068 00 03 64 98 00 00 1e 78 00 00 00 00 00 00 00 00 -000078 00 00 00 00 00 00 00 40 -000080 2e 62 73 73 00 00 00 00 00 00 50 00 00 00 50 00 .bss (+36 bytes) -000090 00 06 8b 80 00 03 83 10 00 00 00 00 00 00 00 00 -0000a0 00 00 00 00 00 00 00 80 - -Header size is $A8 bytes... - -BSD/COFF format file detected... -3 sections specified -Symbol Table offset = 230160 ($00038310) -Symbol Table contains 1339 symbol entries ($0000053B) -The additional header size is 28 bytes ($001C) -Magic Number for RUN_HDR = 0x00000107 -Text Segment Size = 7632 ($00001DD0) -Data Segment Size = 222360 ($00036498) -BSS Segment Size = 428928 ($00068B80) -Starting Address for executable = 0x00802000 -Start of Text Segment = 0x00802000 -Start of Data Segment = 0x00803dd0 -*/ - if (jaguar_mainRom[0] == 0x60 && jaguar_mainRom[1] == 0x1B) - { - uint32 loadAddress = GET32(jaguar_mainRom, 0x16), //runAddress = GET32(jaguar_mainRom, 0x2A), - codeSize = GET32(jaguar_mainRom, 0x02) + GET32(jaguar_mainRom, 0x06); - WriteLog("GUI: Setting up homebrew (ABS-1)... Run address: %08X, length: %08X\n", loadAddress, codeSize); - - if (loadAddress < 0x800000) - memcpy(jaguar_mainRam + loadAddress, jaguar_mainRom + 0x24, codeSize); - else - { - for(int i=codeSize-1; i>=0; i--) - jaguar_mainRom[(loadAddress - 0x800000) + i] = jaguar_mainRom[i + 0x24]; -/* memcpy(jaguar_mainRam, jaguar_mainRom + 0x24, codeSize); - memset(jaguar_mainRom, 0xFF, 0x600000); - memcpy(jaguar_mainRom + (loadAddress - 0x800000), jaguar_mainRam, codeSize); - memset(jaguar_mainRam, 0x00, 0x400000);*/ - } - - jaguarRunAddress = loadAddress; - } - else if (jaguar_mainRom[0] == 0x01 && jaguar_mainRom[1] == 0x50) - { - uint32 loadAddress = GET32(jaguar_mainRom, 0x28), runAddress = GET32(jaguar_mainRom, 0x24), - codeSize = GET32(jaguar_mainRom, 0x18) + GET32(jaguar_mainRom, 0x1C); - WriteLog("GUI: Setting up homebrew (ABS-2)... Run address: %08X, length: %08X\n", runAddress, codeSize); - - if (loadAddress < 0x800000) - memcpy(jaguar_mainRam + loadAddress, jaguar_mainRom + 0xA8, codeSize); - else - { - for(int i=codeSize-1; i>=0; i--) - jaguar_mainRom[(loadAddress - 0x800000) + i] = jaguar_mainRom[i + 0xA8]; -/* memcpy(jaguar_mainRam, jaguar_mainRom + 0xA8, codeSize); - memset(jaguar_mainRom, 0xFF, 0x600000); - memcpy(jaguar_mainRom + (loadAddress - 0x800000), jaguar_mainRam, codeSize); - memset(jaguar_mainRam, 0x00, 0x400000);*/ - } - - jaguarRunAddress = runAddress; - } - else - { - WriteLog("GUI: Couldn't find correct ABS format: %02X %02X\n", jaguar_mainRom[0], jaguar_mainRom[1]); - return false; - } - } - else if (strcasecmp(ext, ".jag") == 0) - { - // File extension ".JAG": Atari server file with header -//NOTE: The bytes 'JAGR' should also be at position $1C... -// Also, there's *always* a $601A header at position $00... - if (jaguar_mainRom[0] == 0x60 && jaguar_mainRom[1] == 0x1A) - { - uint32 loadAddress = GET32(jaguar_mainRom, 0x22), runAddress = GET32(jaguar_mainRom, 0x2A); -//This is not always right! Especially when converted via bin2jag1!!! -//We should have access to the length of the furshlumiger file that was loaded anyway! -//Now, we do! ;-) -// uint32 progLength = GET32(jaguar_mainRom, 0x02); -//jaguarRomSize -//jaguarRunAddress -// WriteLog("Jaguar: Setting up PD ROM... Run address: %08X, length: %08X\n", runAddress, progLength); -// memcpy(jaguar_mainRam + loadAddress, jaguar_mainRom + 0x2E, progLength); - WriteLog("GUI: Setting up homebrew (JAG)... Run address: %08X, length: %08X\n", runAddress, jaguarRomSize - 0x2E); - memcpy(jaguar_mainRam + loadAddress, jaguar_mainRom + 0x2E, jaguarRomSize - 0x2E); -// SET32(jaguar_mainRam, 4, runAddress); - jaguarRunAddress = runAddress; - } - else - return false; - } - // .J64 (Jaguar cartridge ROM image) is implied by the FileList object... - - return true; -} - -// -// Get the length of a (possibly) gzipped file -// -int gzfilelength(gzFile gd) -{ - int size = 0, length = 0; - unsigned char buffer[0x10000]; - - gzrewind(gd); - - do - { - // Read in chunks until EOF - size = gzread(gd, buffer, 0x10000); - - if (size <= 0) - break; - - length += size; - } - while (!gzeof(gd)); - - gzrewind(gd); - return length; -} diff --git a/src/gui.h b/src/gui.h index ebd04c9..512b6c7 100644 --- a/src/gui.h +++ b/src/gui.h @@ -7,8 +7,6 @@ #ifndef __GUI_H__ #define __GUI_H__ -#include "types.h" - #ifdef __cplusplus extern "C" { #endif @@ -17,10 +15,10 @@ void InitGUI(void); void GUIDone(void); bool GUIMain(char *); -// Not sure why these are in *this* file, but here they are... :-/ +// Exported vars -uint32 JaguarLoadROM(uint8 * rom, char * path); -bool JaguarLoadFile(char * path); +extern bool showGUI; +extern bool finished; #ifdef __cplusplus } diff --git a/src/jaguar.cpp b/src/jaguar.cpp index 82e9af8..d40d66c 100644 --- a/src/jaguar.cpp +++ b/src/jaguar.cpp @@ -6,7 +6,7 @@ // Cleanups and endian wrongness amelioration by James L. Hammons // Note: Endian wrongness probably stems from the MAME origins of this emu and // the braindead way in which MAME handles memory. :-) -// +// #include "jaguar.h" @@ -25,6 +25,7 @@ #include "gpu.h" #include "memory.h" #include "joystick.h" +#include "gui.h" #define CPU_DEBUG //Do this in makefile??? Yes! Could, but it's easier to define here... @@ -60,10 +61,12 @@ uint32 jaguar_active_memory_dumps = 0; uint32 jaguar_mainRom_crc32, jaguarRomSize, jaguarRunAddress; -/*static*/ uint8 * jaguar_mainRam = NULL; -/*static*/ uint8 * jaguar_mainRom = NULL; -/*static*/ uint8 * jaguar_bootRom = NULL; -/*static*/ uint8 * jaguar_CDBootROM = NULL; +uint8 * jaguar_mainRam = NULL; +uint8 * jaguar_mainRom = NULL; +uint8 * jaguar_bootRom = NULL; +uint8 * jaguar_CDBootROM = NULL; +bool BIOSLoaded = false; +bool CDBIOSLoaded = false; #ifdef CPU_DEBUG_MEMORY uint8 writeMemMax[0x400000], writeMemMin[0x400000]; @@ -701,9 +704,9 @@ void jaguar_unknown_writebyte(unsigned address, unsigned data, uint32 who/*=UNKN WriteLog("Jaguar: Unknown byte %02X written at %08X by %s (M68K PC=%06X)\n", data, address, whoName[who], m68k_get_reg(NULL, M68K_REG_PC)); #endif #ifdef ABORT_ON_UNMAPPED_MEMORY_ACCESS - extern bool finished; +// extern bool finished; finished = true; - extern bool doDSPDis; +// extern bool doDSPDis; if (who == DSP) doDSPDis = true; #endif @@ -715,9 +718,9 @@ void jaguar_unknown_writeword(unsigned address, unsigned data, uint32 who/*=UNKN WriteLog("Jaguar: Unknown word %04X written at %08X by %s (M68K PC=%06X)\n", data, address, whoName[who], m68k_get_reg(NULL, M68K_REG_PC)); #endif #ifdef ABORT_ON_UNMAPPED_MEMORY_ACCESS - extern bool finished; +// extern bool finished; finished = true; - extern bool doDSPDis; +// extern bool doDSPDis; if (who == DSP) doDSPDis = true; #endif @@ -729,9 +732,9 @@ unsigned jaguar_unknown_readbyte(unsigned address, uint32 who/*=UNKNOWN*/) WriteLog("Jaguar: Unknown byte read at %08X by %s (M68K PC=%06X)\n", address, whoName[who], m68k_get_reg(NULL, M68K_REG_PC)); #endif #ifdef ABORT_ON_UNMAPPED_MEMORY_ACCESS - extern bool finished; +// extern bool finished; finished = true; - extern bool doDSPDis; +// extern bool doDSPDis; if (who == DSP) doDSPDis = true; #endif @@ -744,9 +747,9 @@ unsigned jaguar_unknown_readword(unsigned address, uint32 who/*=UNKNOWN*/) WriteLog("Jaguar: Unknown word read at %08X by %s (M68K PC=%06X)\n", address, whoName[who], m68k_get_reg(NULL, M68K_REG_PC)); #endif #ifdef ABORT_ON_UNMAPPED_MEMORY_ACCESS - extern bool finished; +// extern bool finished; finished = true; - extern bool doDSPDis; +// extern bool doDSPDis; if (who == DSP) doDSPDis = true; #endif @@ -869,7 +872,7 @@ void JaguarWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/) JERRYWriteByte(offset, data, who); return; } - + jaguar_unknown_writebyte(offset, data, who); } @@ -1061,7 +1064,7 @@ void jaguar_init(void) //New timer based code stuffola... void ScanlineCallback(void); void RenderCallback(void); -extern uint32 * backbuffer; +//extern uint32 * backbuffer; void jaguar_reset(void) { //NOTE: This causes a (virtual) crash if this is set in the config but not found... !!! FIX !!! @@ -1449,7 +1452,7 @@ void ScanlineCallback(void) if (vc == 0) // if (vc == vbb) { - joystick_exec(); + JoystickExec(); RenderBackbuffer(); TOMResetBackbuffer(backbuffer); frameDone = true; diff --git a/src/jaguar.h b/src/jaguar.h index ecd7197..f6a6aec 100644 --- a/src/jaguar.h +++ b/src/jaguar.h @@ -3,35 +3,6 @@ #include "types.h" -#if 0 -#include // Why??? (for memset, etc... Lazy!) Dunno why, but this just strikes me as wrong... -#include // For exit() -#include "types.h" -#include "log.h" -#include "version.h" -#include "memory.h" -#include "m68k.h" -#include "tom.h" -#include "jerry.h" -#include "gpu.h" -#include "dsp.h" -#include "objectp.h" -#include "blitter.h" -#include "clock.h" -#include "joystick.h" -#include "dac.h" -#include "jagdasm.h" -#include "cdrom.h" -#include "eeprom.h" -#endif - -// Exports from JAGUAR.CPP - -extern int32 jaguar_cpu_in_exec; -extern uint32 jaguar_mainRom_crc32, jaguarRomSize, jaguarRunAddress; -extern char * jaguar_eeproms_path; -extern const char * whoName[9]; - void jaguar_init(void); void jaguar_reset(void); void jaguar_done(void); @@ -50,6 +21,19 @@ void JaguarExecute(uint32 * backbuffer, bool render); //For testing the new system... void JaguarExecuteNew(void); +// Exports from JAGUAR.CPP + +extern uint8 * jaguar_mainRam; +extern uint8 * jaguar_mainRom; +extern uint8 * jaguar_bootRom; +extern uint8 * jaguar_CDBootROM; +extern bool BIOSLoaded; +extern bool CDBIOSLoaded; +extern int32 jaguar_cpu_in_exec; +extern uint32 jaguar_mainRom_crc32, jaguarRomSize, jaguarRunAddress; +extern char * jaguar_eeproms_path; +extern const char * whoName[9]; + // Some handy macros to help converting native endian to big endian (jaguar native) // & vice versa diff --git a/src/jerry.cpp b/src/jerry.cpp index 742cfb2..eef8d01 100644 --- a/src/jerry.cpp +++ b/src/jerry.cpp @@ -415,7 +415,7 @@ void jerry_init(void) { // clock_init(); // anajoy_init(); - joystick_init(); + JoystickInit(); DACInit(); //This should be handled with the cart initialization... // eeprom_init(); @@ -432,7 +432,7 @@ void jerry_reset(void) { // clock_reset(); // anajoy_reset(); - joystick_reset(); + JoystickReset(); eeprom_reset(); JERRYResetI2S(); DACReset(); @@ -452,14 +452,14 @@ void jerry_done(void) // memory_free(jerry_ram_8); // clock_done(); // anajoy_done(); - joystick_done(); + JoystickDone(); DACDone(); eeprom_done(); } bool JERRYIRQEnabled(int irq) { - // Read the word @ $F10020 + // Read the word @ $F10020 return jerry_ram_8[0x21] & (1 << irq); } @@ -540,10 +540,10 @@ WriteLog("JERRY: Unhandled timer read (BYTE) at %08X...\n", offset); // else if (offset >= 0xF17C00 && offset <= 0xF17C01) // return anajoy_byte_read(offset); else if (offset >= 0xF14000 && offset <= 0xF14003) - return joystick_byte_read(offset) | eeprom_byte_read(offset); + return JoystickReadByte(offset) | eeprom_byte_read(offset); else if (offset >= 0xF14000 && offset <= 0xF1A0FF) return eeprom_byte_read(offset); - + return jerry_ram_8[offset & 0xFFFF]; } @@ -607,9 +607,9 @@ WriteLog("JERRY: Unhandled timer read (WORD) at %08X...\n", offset); // else if ((offset >= 0xF17C00) && (offset <= 0xF17C01)) // return anajoy_word_read(offset); else if (offset == 0xF14000) - return (joystick_word_read(offset) & 0xFFFE) | eeprom_word_read(offset); + return (JoystickReadWord(offset) & 0xFFFE) | eeprom_word_read(offset); else if ((offset >= 0xF14002) && (offset < 0xF14003)) - return joystick_word_read(offset); + return JoystickReadWord(offset); else if ((offset >= 0xF14000) && (offset <= 0xF1A0FF)) return eeprom_word_read(offset); @@ -659,9 +659,9 @@ void JERRYWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/) } // LTXD/RTXD/SCLK/SMODE $F1A148/4C/50/54 (really 16-bit registers...) else if (offset >= 0xF1A148 && offset <= 0xF1A157) - { + { DACWriteByte(offset, data, who); - return; + return; } else if (offset >= 0xF10000 && offset <= 0xF10007) { @@ -722,7 +722,7 @@ WriteLog("JERRY: (68K int en/lat - Unhandled!) Tried to write $%02X to $%08X!\n" }*/ else if ((offset >= 0xF14000) && (offset <= 0xF14003)) { - joystick_byte_write(offset, data); + JoystickWriteByte(offset, data); eeprom_byte_write(offset, data); return; } @@ -773,13 +773,13 @@ void JERRYWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/) #endif DACWriteWord(offset, data, who); - return; + return; } // LTXD/RTXD/SCLK/SMODE $F1A148/4C/50/54 (really 16-bit registers...) else if (offset >= 0xF1A148 && offset <= 0xF1A156) - { + { DACWriteWord(offset, data, who); - return; + return; } else if (offset >= 0xF10000 && offset <= 0xF10007) { @@ -827,7 +827,7 @@ WriteLog("JERRY: (68K int en/lat - Unhandled!) Tried to write $%04X to $%08X!\n" }*/ else if (offset >= 0xF14000 && offset < 0xF14003) { - joystick_word_write(offset, data); + JoystickWriteWord(offset, data); eeprom_word_write(offset, data); return; } diff --git a/src/joystick.cpp b/src/joystick.cpp index cd1bdca..5d969d0 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -11,10 +11,11 @@ #include #include #include "jaguar.h" -#include "video.h" -#include "settings.h" -#include "gpu.h" #include "log.h" +#include "gpu.h" +#include "gui.h" +#include "settings.h" +#include "video.h" #define BUTTON_U 0 #define BUTTON_D 1 @@ -44,8 +45,8 @@ static uint8 joystick_ram[4]; static uint8 joypad_0_buttons[21]; static uint8 joypad_1_buttons[21]; -extern bool finished; -extern bool showGUI; +//extern bool finished; +////extern bool showGUI; bool GUIKeyHeld = false; extern int start_logging; int gpu_start_log = 0; @@ -64,16 +65,16 @@ bool blitterSingleStep = false; bool bssGo = false; bool bssHeld = false; -void joystick_init(void) +void JoystickInit(void) { - joystick_reset(); + JoystickReset(); } -void joystick_exec(void) +void JoystickExec(void) { // extern bool useJoystick; uint8 * keystate = SDL_GetKeyState(NULL); - + memset(joypad_0_buttons, 0, 21); memset(joypad_1_buttons, 0, 21); gpu_start_log = 0; // Only log while key down! @@ -236,7 +237,7 @@ void joystick_exec(void) extern SDL_Joystick * joystick; int16 x = SDL_JoystickGetAxis(joystick, 0), y = SDL_JoystickGetAxis(joystick, 1); - + if (x > 16384) joypad_0_buttons[BUTTON_R] = 0x01; if (x < -16384) @@ -245,7 +246,7 @@ void joystick_exec(void) joypad_0_buttons[BUTTON_D] = 0x01; if (y < -16384) joypad_0_buttons[BUTTON_U] = 0x01; - + if (SDL_JoystickGetButton(joystick, 0) == SDL_PRESSED) joypad_0_buttons[BUTTON_A] = 0x01; if (SDL_JoystickGetButton(joystick, 1) == SDL_PRESSED) @@ -253,24 +254,25 @@ void joystick_exec(void) if (SDL_JoystickGetButton(joystick, 2) == SDL_PRESSED) joypad_0_buttons[BUTTON_C] = 0x01; } - + // Needed to ensure that the events queue is empty [nwagenaar] SDL_PumpEvents(); } -void joystick_reset(void) +void JoystickReset(void) { memset(joystick_ram, 0x00, 4); memset(joypad_0_buttons, 0, 21); memset(joypad_1_buttons, 0, 21); } -void joystick_done(void) +void JoystickDone(void) { } -uint8 joystick_byte_read(uint32 offset) +uint8 JoystickReadByte(uint32 offset) { +#warning No bounds checking done in JoystickReadByte! // extern bool hardwareTypeNTSC; offset &= 0x03; @@ -279,22 +281,22 @@ uint8 joystick_byte_read(uint32 offset) uint8 data = 0x00; int pad0Index = joystick_ram[1] & 0x0F; int pad1Index = (joystick_ram[1] >> 4) & 0x0F; - + // This is bad--we're assuming that a bit is set in the last case. Might not be so! - if (!(pad0Index & 0x01)) + if (!(pad0Index & 0x01)) pad0Index = 0; - else if (!(pad0Index & 0x02)) + else if (!(pad0Index & 0x02)) pad0Index = 1; - else if (!(pad0Index & 0x04)) + else if (!(pad0Index & 0x04)) pad0Index = 2; - else + else pad0Index = 3; - - if (!(pad1Index & 0x01)) + + if (!(pad1Index & 0x01)) pad1Index = 0; - else if (!(pad1Index & 0x02)) + else if (!(pad1Index & 0x02)) pad1Index = 1; - else if (!(pad1Index & 0x04)) + else if (!(pad1Index & 0x04)) pad1Index = 2; else pad1Index = 3; @@ -312,10 +314,11 @@ uint8 joystick_byte_read(uint32 offset) } else if (offset == 3) { + // Hardware ID returns NTSC/PAL identification bit here uint8 data = 0x2F | (vjs.hardwareTypeNTSC ? 0x10 : 0x00); int pad0Index = joystick_ram[1] & 0x0F; //unused int pad1Index = (joystick_ram[1] >> 4) & 0x0F; - + if (!(pad0Index & 0x01)) { if (joypad_0_buttons[BUTTON_PAUSE]) @@ -337,26 +340,27 @@ uint8 joystick_byte_read(uint32 offset) { if (joypad_0_buttons[BUTTON_OPTION]) data ^= 0x02; - } + } return data; } return joystick_ram[offset]; } -uint16 joystick_word_read(uint32 offset) +uint16 JoystickReadWord(uint32 offset) { - return ((uint16)joystick_byte_read((offset+0)&0x03) << 8) | joystick_byte_read((offset+1)&0x03); + return ((uint16)JoystickReadByte((offset + 0) & 0x03) << 8) | JoystickReadByte((offset + 1) & 0x03); } -void joystick_byte_write(uint32 offset, uint8 data) +void JoystickWriteByte(uint32 offset, uint8 data) { - joystick_ram[offset&0x03] = data; + joystick_ram[offset & 0x03] = data; } -void joystick_word_write(uint32 offset, uint16 data) +void JoystickWriteWord(uint32 offset, uint16 data) { +#warning No bounds checking done for JoystickWriteWord! offset &= 0x03; - joystick_ram[offset+0] = (data >> 8) & 0xFF; - joystick_ram[offset+1] = data & 0xFF; + joystick_ram[offset + 0] = (data >> 8) & 0xFF; + joystick_ram[offset + 1] = data & 0xFF; } diff --git a/src/joystick.h b/src/joystick.h index 8a37087..d56c080 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -1,15 +1,19 @@ +// +// Jaguar joystick handler +// + #ifndef __JOYSTICK_H__ #define __JOYSTICK_H__ #include "types.h" -void joystick_init(void); -void joystick_reset(void); -void joystick_done(void); -void joystick_byte_write(uint32, uint8); -void joystick_word_write(uint32, uint16); -uint8 joystick_byte_read(uint32); -uint16 joystick_word_read(uint32); -void joystick_exec(void); +void JoystickInit(void); +void JoystickReset(void); +void JoystickDone(void); +void JoystickWriteByte(uint32, uint8); +void JoystickWriteWord(uint32, uint16); +uint8 JoystickReadByte(uint32); +uint16 JoystickReadWord(uint32); +void JoystickExec(void); #endif diff --git a/src/sdlemu_opengl.c b/src/sdlemu_opengl.c index 7ea9faf..3489822 100644 --- a/src/sdlemu_opengl.c +++ b/src/sdlemu_opengl.c @@ -16,13 +16,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - + /* SDLEMU_OPENGL.C SDLEMU related sources for using OpenGL with SDL. By Niels Wagenaar | http://sdlemu.ngemu.com | shalafi@xs4all.nl - + Version 1.0.001 - 4-10-2004 - + - Added support for 16, 24 and 32 bit textures; - Added support for 16, 24 and 32 bit texture rendering; @@ -41,6 +41,11 @@ #include "sdlemu_opengl.h" +// We want alpha on our OpenGL contexts...! +// Or do we? Seems to kill performance on X... +// Or does it? Could it be bad blitter performance? +#define WANT_OPENGL_ALPHA + static SDL_Surface *texture = 0; static GLuint texid = 0; static GLfloat texcoord[4]; @@ -97,8 +102,8 @@ void sdlemu_draw_texture(SDL_Surface * dst, SDL_Surface * src, int texturetype) Be warned! This only works with the bpp of texture en *src set to 32. */ #ifdef WANT_OPENGL_ALPHA - Uint32 saved_flags; - Uint8 saved_alpha; + Uint32 saved_flags; + Uint8 saved_alpha; /* Save the alpha blending attributes */ saved_flags = src->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); @@ -126,7 +131,7 @@ pix[x+(y*1024)] = 0x800000FF;//*/ glBlendFunc(GL_ONE, GL_ZERO); glBindTexture(GL_TEXTURE_2D, texid); - // Texturemap complete texture to surface so we have free scaling + // Texturemap complete texture to surface so we have free scaling // and antialiasing switch (texturebpp) { @@ -143,7 +148,7 @@ glBindTexture(GL_TEXTURE_2D, texid); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h, GL_RGBA, GL_UNSIGNED_BYTE, texture->pixels); break; - } + } // Render the texture to the screen using OpenGL! switch (texturetype) @@ -200,7 +205,7 @@ glRasterPos2i(10, 10); glDrawPixels(5, 5, GL_RGBA, GL_UNSIGNED_INT, map);//*/ // glFlush(); - SDL_GL_SwapBuffers(); + SDL_GL_SwapBuffers(); // glFinish(); } @@ -227,12 +232,12 @@ void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp) // So, find the largest power of two that will contain both the width and height int w = power_of_two(dst->w); int h = power_of_two(dst->h); - + printf("OpenGL - Overlay size : %d x %d\n", w, h); - + // Setting bpp based upon src_bpp. int bpp = src_bpp; - + // We allow the developer to set its own texture bpp. But if the value is NULL or // not equal to 16, 24 or 32, we make the texturebpp the same as the BPP from src. if (bpp == 16 || bpp == 24 || bpp == 32) @@ -247,7 +252,7 @@ void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp) // This buffer is needed because we need to convert the SDL_Surface *src to an OpenGL // texture with a depth of 16, 24 or 32 bpp, before we can blit the pixels to *dst // using OpenGL. - // + // // NOTE: Seems the byte order here *is* important! switch (texturebpp) { @@ -255,11 +260,11 @@ void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp) /* According to information on the SDL mailinglist and on internet, the following rgba masks should be the ones to use. But somehow the screen gets f*cked up and - the RGB colours are incorrect (at least in Virtual Jaguar/SDL). - + the RGB colours are incorrect (at least in Virtual Jaguar/SDL). + Compile with -DOPENGL_16BPP_CORRECT_RGBA to use this RGBA values. -*/ -#ifdef OPENGL_16BPP_CORRECT_RGBA +*/ +#ifdef OPENGL_16BPP_CORRECT_RGBA rmask = 0x7C00; gmask = 0x03E0; bmask = 0x001F; @@ -302,7 +307,7 @@ void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp) // Creating SDL_Surface texture based upon the above settings. overlay = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask); - + // Setting up the texture coordinates. overlayCoord[0] = 0.0f; overlayCoord[1] = 0.0f; @@ -312,10 +317,10 @@ void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp) // create a RGB(A) texture for the texture surface glGenTextures(1, &overlayID); glBindTexture(GL_TEXTURE_2D, overlayID); - + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - + // Setting texture mode. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); @@ -332,16 +337,16 @@ void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp) // // IMPORTANT : If you don't use Alpha. Use textures with a depth of 16bpp. // If you use Alpha. Use textures with a depth of 32bpp. - // 24bpp textures are SLOW and avoid them at all costs! + // 24bpp textures are SLOW and avoid them at all costs! glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, overlay->w, overlay->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); break; case 32: default: // The 32bpp depth based textures consist out of GL_RGBA8 and has support for Alpha channels. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, overlay->w, overlay->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - break; - } -} + break; + } +} void * sdlemuGetOverlayPixels(void) { @@ -378,12 +383,12 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int // So, find the largest power of two that will contain both the width and height w = power_of_two(src->w); h = power_of_two(src->h); - + printf("OpenGL - Texture size : %d x %d\n", w, h); - + // Setting bpp based upon src_bpp. bpp = src_bpp; - + // We allow the developer to set its own texture bpp. But if the value is NULL or // not equal to 16, 24 or 32, we make the texturebpp the same as the BPP from src. if (bpp == 16 || bpp == 24 || bpp == 32) @@ -398,7 +403,7 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int // This buffer is needed because we need to convert the SDL_Surface *src to an OpenGL // texture with a depth of 16, 24 or 32 bpp, before we can blit the pixels to *dst // using OpenGL. - // + // // NOTE: Seems the byte order here *is* important! switch (texturebpp) { @@ -406,11 +411,11 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int /* According to information on the SDL mailinglist and on internet, the following rgba masks should be the ones to use. But somehow the screen gets f*cked up and - the RGB colours are incorrect (at least in Virtual Jaguar/SDL). + the RGB colours are incorrect (at least in Virtual Jaguar/SDL). Compile with -DOPENGL_16BPP_CORRECT_RGBA to use this RGBA values. -*/ -#ifdef OPENGL_16BPP_CORRECT_RGBA +*/ +#ifdef OPENGL_16BPP_CORRECT_RGBA rmask = 0x7C00; gmask = 0x03E0; bmask = 0x001F; @@ -453,7 +458,7 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int // Creating SDL_Surface texture based upon the above settings. texture = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask); - + // Setting up OpenGL glDisable(GL_FOG); glDisable(GL_LIGHTING); @@ -489,12 +494,12 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int // create a RGB(A) texture for the texture surface glGenTextures(1, &texid); glBindTexture(GL_TEXTURE_2D, texid); - + // Setting up the OpenGL Filters. These filters are important when we/you - // want to scale the texture. + // want to scale the texture. if (filter) { - // Textures are rendered in best quality. + // Textures are rendered in best quality. printf("OpenGL filters: enabled\n"); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -506,7 +511,7 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } - + // Setting texture mode. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); @@ -523,13 +528,13 @@ void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int // // IMPORTANT : If you don't use Alpha. Use textures with a depth of 16bpp. // If you use Alpha. Use textures with a depth of 32bpp. - // 24bpp textures are SLOW and avoid them at all costs! + // 24bpp textures are SLOW and avoid them at all costs! glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); break; case 32: default: // The 32bpp depth based textures consist out of GL_RGBA8 and has support for Alpha channels. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture->w, texture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - break; - } -} + break; + } +} diff --git a/src/video.cpp b/src/video.cpp index 4507363..b35cc1a 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -6,10 +6,11 @@ #include "video.h" +#include "gui.h" // For "finished" +#include "log.h" #include "tom.h" #include "sdlemu_opengl.h" #include "settings.h" -#include "log.h" // External global variables @@ -31,7 +32,7 @@ uint32 * backbuffer; // 60 FPS. But doing so will have some nasty side effects in some games. // You have been warned! -int frame_ticker = vjs.frameSkip; +int frame_ticker = 0; // // Create SDL/OpenGL surfaces @@ -53,7 +54,7 @@ bool InitVideo(void) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); mainSurfaceFlags = SDL_OPENGL; - + } else { @@ -104,14 +105,14 @@ bool InitVideo(void) (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL), 16, 0x7C00, 0x03E0, 0x001F, 0);//*/ - uint32 vsWidth = VIRTUAL_SCREEN_WIDTH; + uint32 vsWidth = (vjs.renderType == RT_TV ? 1280 : VIRTUAL_SCREEN_WIDTH), + vsHeight = (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL); - if (vjs.renderType == RT_TV) - vsWidth = 1280; +// if (vjs.renderType == RT_TV) +// vsWidth = 1280; //24BPP // surface = SDL_CreateRGBSurface(SDL_SWSURFACE, VIRTUAL_SCREEN_WIDTH, - surface = SDL_CreateRGBSurface(SDL_SWSURFACE, vsWidth, - (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL), 32, + surface = SDL_CreateRGBSurface(SDL_SWSURFACE, vsWidth, vsHeight, 32, #if SDL_BYTEORDER == SDL_BIG_ENDIAN 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); #else @@ -127,7 +128,7 @@ bool InitVideo(void) if (vjs.useOpenGL) // Let us setup OpenGL and our rendering texture. We give the src (surface) and the // dst (mainSurface) display as well as the automatic bpp selection as options so that - // our texture is automaticly created :) + // our texture is automatically created :) sdlemu_init_opengl(surface, mainSurface, 1 /*method*/, vjs.glFilter /*texture type (linear, nearest)*/, 0 /* Automatic bpp selection based upon src */); @@ -154,16 +155,8 @@ bool InitVideo(void) } // Set up the backbuffer -//To be safe, this should be 1280 * 625 * 2... -// backbuffer = (int16 *)malloc(845 * 525 * sizeof(int16)); -/* backbuffer = (int16 *)malloc(1280 * 625 * sizeof(int16)); -// memset(backbuffer, 0x44, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT_NTSC * sizeof(int16)); - memset(backbuffer, 0x44, VIRTUAL_SCREEN_WIDTH * - (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL) - * sizeof(int16));//*/ -//24BPP + // To be safe, this should be 1280 * 625 * 2... backbuffer = (uint32 *)malloc(1280 * 625 * sizeof(uint32)); -// memset(backbuffer, 0x44, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT_NTSC * sizeof(int16)); memset(backbuffer, 0x44, VIRTUAL_SCREEN_WIDTH * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL) * sizeof(uint32)); @@ -189,11 +182,22 @@ void VideoDone(void) // void RenderBackbuffer(void) { + // Handle frameskip *before* we do any heavy lifting here... + + if (frame_ticker > 0) + { + frame_ticker--; + return; + } + + frame_ticker = vjs.frameSkip; // Reset frame_ticker + if (SDL_MUSTLOCK(surface)) while (SDL_LockSurface(surface) < 0) SDL_Delay(10); // memcpy(surface->pixels, backbuffer, tom_getVideoModeWidth() * tom_getVideoModeHeight() * 2); +// This memcpy is expensive--do some profiling to see what the impact is! if (vjs.renderType == RT_NORMAL) memcpy(surface->pixels, backbuffer, tom_getVideoModeWidth() * tom_getVideoModeHeight() * 4); else if (vjs.renderType == RT_TV) @@ -203,19 +207,12 @@ void RenderBackbuffer(void) SDL_UnlockSurface(surface); if (vjs.useOpenGL) - { // One of the reasons why OpenGL is slower then normal SDL rendering, is because // the data is being pumped into the buffer every frame with a overflow as result. // So, we going to render every 1 fps instead of every 0 fps. // [Shamus] This is isn't why it's slower--see top of file for explanation... ;-) - if (frame_ticker == 0) - { - sdlemu_draw_texture(mainSurface, surface, 1/*1=GL_QUADS*/); - frame_ticker = vjs.frameSkip; // Reset frame_ticker - } - else - frame_ticker--; - } +//The problem lies in this function... + sdlemu_draw_texture(mainSurface, surface, 1/*1=GL_QUADS*/); else { SDL_Rect rect = { 0, 0, surface->w, surface->h }; @@ -229,11 +226,7 @@ void RenderBackbuffer(void) // void ResizeScreen(uint32 width, uint32 height) { - char window_title[256]; - SDL_FreeSurface(surface); -// surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 16, 0x7C00, 0x03E0, 0x001F, 0); -//24BPP surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, #if SDL_BYTEORDER == SDL_BIG_ENDIAN 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); @@ -246,12 +239,16 @@ void ResizeScreen(uint32 width, uint32 height) WriteLog("Video: Could not create primary SDL surface: %s", SDL_GetError()); //This is just crappy. We shouldn't exit this way--it leaves all kinds of memory leaks //as well as screwing up SDL... !!! FIX !!! - exit(1); +// exit(1); + // OK, this is cleaner. We can't continue if there is no surface created! + finished = true; } if (vjs.useOpenGL) { // Recreate the texture because of the NTSC <-> PAL screen resize. +//Not sure why this is here... +//Is it because of the resized surface up above? sdlemu_create_texture(surface, mainSurface, vjs.glFilter, 0); } else @@ -261,12 +258,15 @@ void ResizeScreen(uint32 width, uint32 height) if (mainSurface == NULL) { WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError()); - exit(1); +// Don't exit because we can't resize! +// exit(1); } } + char window_title[64]; + sprintf(window_title, "Virtual Jaguar (%i x %i)", (int)width, (int)height); - SDL_WM_SetCaption(window_title, window_title); + SDL_WM_SetCaption((vjs.useOpenGL ? "Virtual Jaguar (OpenGL)" : window_title), "Virtual Jaguar"); } // @@ -282,23 +282,44 @@ uint32 GetSDLScreenWidthInPixels(void) // void ToggleFullscreen(void) { -//NOTE: This does *NOT* work with OpenGL rendering! !!! FIX !!! - if (vjs.useOpenGL) - return; // Until we can fix it... - vjs.fullscreen = !vjs.fullscreen; mainSurfaceFlags &= ~SDL_FULLSCREEN; if (vjs.fullscreen) mainSurfaceFlags |= SDL_FULLSCREEN; - mainSurface = SDL_SetVideoMode(tom_width, tom_height, 32, mainSurfaceFlags); + if (vjs.useOpenGL) + { + // When OpenGL is used, we're going to use a standard resolution of 640x480. + // This way we have good scaling functionality and when the screen is resized + // because of the NTSC <-> PAL resize, we only have to re-create the texture + // instead of initializing the entire OpenGL texture en screens. + mainSurface = SDL_SetVideoMode(640, 480, 32, mainSurfaceFlags);//*/ + + // Reset viewport, etc. + glViewport(0, 0, mainSurface->w, mainSurface->h); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0.0, (GLdouble)mainSurface->w, (GLdouble)mainSurface->h, 0.0, 0.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + } + else + mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, + (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL), + 32, mainSurfaceFlags); if (mainSurface == NULL) { - WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError()); - exit(1); + WriteLog("Video: SDL was unable to switch the video to %s: %s\n", (vjs.fullscreen ? "fullscreen" : "windowed"), SDL_GetError()); +// Shouldn't exit because we can't switch! BAD!!! +// exit(1); + return; } - SDL_WM_SetCaption("Virtual Jaguar", "Virtual Jaguar"); + SDL_WM_SetCaption((vjs.useOpenGL ? "Virtual Jaguar (OpenGL)" : "Virtual Jaguar"), "Virtual Jaguar"); + + return; } diff --git a/src/video.h b/src/video.h index 6a67bce..5e47e0f 100644 --- a/src/video.h +++ b/src/video.h @@ -18,4 +18,8 @@ void ResizeScreen(uint32 width, uint32 height); uint32 GetSDLScreenWidthInPixels(void); void ToggleFullscreen(void); +// Exported vars + +extern uint32 * backbuffer; + #endif // __VIDEO_H__ diff --git a/src/vj.cpp b/src/vj.cpp index 2e2480e..3f82f83 100644 --- a/src/vj.cpp +++ b/src/vj.cpp @@ -6,11 +6,6 @@ // Cleanups/fixes/enhancements by James L. Hammons and Adam Green // -#ifdef __GCCUNIX__ -//#include // Is this necessary anymore? -//Looks like the answer is no... -#endif - #include #include #include "jaguar.h" @@ -21,6 +16,7 @@ #include "log.h" #include "version.h" #include "memory.h" +#include "file.h" // Uncomment this to use built-in BIOS/CD-ROM BIOS // You'll need a copy of jagboot.h & jagcd.h for this to work...! @@ -33,30 +29,12 @@ // Private function prototypes -// External variables - -extern uint8 * jaguar_mainRam; -extern uint8 * jaguar_mainRom; -extern uint8 * jaguar_bootRom; -extern uint8 * jaguar_CDBootROM; - -// Global variables (export capable) -//should these even be here anymore? prolly not... - -bool finished = false; -bool showGUI = false; -bool showMessage = false; -uint32 showMessageTimeout; -char messageBuffer[200]; -bool BIOSLoaded = false; -bool CDBIOSLoaded = false; - // // The main emulator loop (what else?) // //Maybe we should move the video stuff to TOM? Makes more sense to put it there... //Actually, it would probably be better served in VIDEO.CPP... !!! FIX !!! [DONE] -uint32 totalFrames;//temp, so we can grab this from elsewhere... +//uint32 totalFrames;//temp, so we can grab this from elsewhere... int main(int argc, char * argv[]) { //NOTE: This isn't actually used anywhere... !!! FIX !!! @@ -83,7 +61,7 @@ int main(int argc, char * argv[]) if (argv[i][0] != '-') haveCart = true; // It looks like we have a cartridge! - if (!strcmp(argv[i], "-joystick")) + if (!strcmp(argv[i], "-joystick")) vjs.useJoystick = true; if (!strcmp(argv[i], "-joyport")) @@ -124,10 +102,10 @@ int main(int argc, char * argv[]) if (!strcmp(argv[i], "-nogl")) vjs.useOpenGL = false; - if (!strcmp(argv[i], "-fullscreen")) + if (!strcmp(argv[i], "-fullscreen")) vjs.fullscreen = true; - if (!strcmp(argv[i], "-window")) + if (!strcmp(argv[i], "-window")) vjs.fullscreen = false; if (!strcmp(argv[i], "-pal")) @@ -186,7 +164,6 @@ WriteLog("Initializing jaguar subsystem...\n"); memcpy(jaguar_CDBootROM, jagCDROM, 0x40000); BIOSLoaded = CDBIOSLoaded = true; #else -// if (vjs.useJaguarBIOS) // What would be nice here would be a way to check if the BIOS was loaded so that we // could disable the pushbutton on the Misc Options menu... !!! FIX !!! [DONE here, but needs to be fixed in GUI as well!] WriteLog("About to attempt to load BIOSes...\n"); @@ -216,7 +193,7 @@ WriteLog("About to start GUI...\n"); VersionDone(); MemoryDone(); VideoDone(); - log_done(); + log_done(); // Free SDL components last...! SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER); diff --git a/vj.cfg b/vj.cfg index 045ccf4..c7a46c0 100644 --- a/vj.cfg +++ b/vj.cfg @@ -19,7 +19,7 @@ useOpenGL = 1 # OpenGL filtering type: 1 - blurry, 0 - sharp -glFilterType = 0 +glFilterType = 1 # Display options: 1 - fullscreen, 0 - windowed @@ -35,7 +35,7 @@ DSPEnabled = 0 # If DSP enabled, set whether or not to use the pipelined core: 1 - use, 0 - don't use -usePipelinedDSP = 1 +usePipelinedDSP = 0 # Joystick options: 1 - use joystick, 0 - don't use -- 2.37.2