fstream tr; // Tracelog hook
uint16 pcx; // Where we at?
+static uint8 * keys; // SDL raw keyboard matrix
+
static char op_mat1[256] = {
1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,
0, 0, 5, 5, 0, 0, 4, 4, 0, 5, 8, 0, 8, 5, 6, 6,
// SDL_Surface * screen = NULL; // SDL screen pointer
SDL_Event event; // SDL "event"
// int keyPressed; // SDL key pressed...
- uint8 keys[256]; // Keyboard "switch-like" buffer
extern uint8 palette[768]; // Screen physical palette
uint32 ticks, oldTicks;
// tr.open("exe.log", ios::binary | ios::out); // Tracelog
cout << endl << "THUNDER v"THUNDER_VERSION" ";
- cout << "by James Hammmmons" << endl;
+ cout << "by James Hammons" << endl;
cout << "Serial #20090723 / Prerelease" << endl;
cout << "(C) 2003, 2009 Underground Software" << endl << endl;
SDL_WM_SetCaption("Thunder v"THUNDER_VERSION" ", "Thunder");
+ keys = SDL_GetKeyState(NULL); // Get the SDL keyboard matrix
+
cout << "Allocating memory..." << endl;
//Does this anyway... set_new_handler(0); // Make 'new' return NULL on failure...
gram1 = new uint8[0x10000];
// SDL key handling...
-#warning "MAKE REPOSITORY FOR THIS THING! !!! FIX !!!"
-#warning "AND USE THE OLD SOURCE FOR THE BASE!!!"
#warning "KEYS ARE FUCKED UP! !!! FIX !!!"
+ SDL_PumpEvents(); // Force key events into the buffer.
// keyPressed = 0; // Reset keypress
- while (SDL_PollEvent(&event) != 0) // Bleed out all pending key events...
- {
- if (event.type == SDL_KEYDOWN)
- keys[event.key.keysym.scancode] = 1;
- if (event.type == SDL_KEYUP)
- keys[event.key.keysym.scancode] = 0;
- }
+// while (SDL_PollEvent(&event) != 0) // Bleed out all pending key events...
+// {
+// if (event.type == SDL_KEYDOWN)
+// keys[event.key.keysym.scancode] = 1;
+// if (event.type == SDL_KEYUP)
+// keys[event.key.keysym.scancode] = 0;
+// }
// {
- if (keys[0x01])
+ if (keys[SDLK_ESCAPE])
running = false; // ESC to exit...
if (debounce)
debounce--; // Debounce toggle keys...
else
{
- if (keys[0x3B])
+ if (keys[SDLK_F1])
{
self_test = !self_test; // Self-test (F1-toggle)
debounce = 10; // Key debounce value...
}
- if (keys[0x3C])
+ if (keys[SDLK_F2])
{
gram1[0x4268] = 1; // Video test (F2)
debounce = 10; // Key debounce value...
}
- if (keys[0x58])
+ if (keys[SDLK_F12])
{
scr_type = !scr_type; // Toggle screen (F12)
debounce = 10; // Key debounce value...
}
- if (keys[0x3D])
+ if (keys[SDLK_F3])
{
show_scr = !show_scr; // Toggle bkgrnd (F3)
debounce = 10;
}
- if (keys[0x40])
+ if (keys[SDLK_F6])
{
enable_cpu = !enable_cpu; // Toggle CPUs (F6)
debounce = 10;
}
- if (keys[0x3F])
+ if (keys[SDLK_F5])
{
refresh2 = !refresh2; // Toggle 30/60Hz (F5)
SetRefreshRate(refresh2); // Inform GUI of refresh
SpawnMsg(M30FPS);
debounce = 10; // Key debounce value...
}
- if (keys[0x3E]) // Do PCX snapshot (F4)
+ if (keys[SDLK_F4]) // Do PCX snapshot (F4)
{
SpawnSound(USERSOUND, SCAMERA);
SnapPCX(screen);
debounce = 10;
}
- if (keys[0x0F]) // Tab active/deactivate GUI
+ if (keys[SDLK_TAB]) // Tab active/deactivate GUI
{
if (ShowGUI())
DeactivateGUI();
}
}
//if (keys[0x3E]) gram1[0x4247] = 1; // Screen hold DS (F4)
- if (keys[77+128]) // Right arrow
+ if (keys[SDLK_RIGHT]) // Right arrow
{
if (ShowGUI())
SelectRight(); // If GUI active...
else
{
- if (!keys[75+128]) // Disallow opposite directions @ same time
+ if (!keys[SDLK_LEFT]) // Disallow opposite directions @ same time
gram1[0x427F] = 1; // Stick right
}
}
- if (keys[75+128])
+ if (keys[SDLK_LEFT])
{
if (ShowGUI())
SelectLeft(); // If GUI active...
else
{
- if (!keys[77+128]) // Disallow opposite directions@same time
+ if (!keys[SDLK_RIGHT]) // Disallow opposite directions@same time
gram1[0x4281] = 1; // Left arrow
}
}
- if (keys[72+128])
+ if (keys[SDLK_UP])
{
if (ShowGUI())
SelectUp(); // If GUI active...
else
{
- if (!keys[80+128]) // Disallow opposite directions@same time
+ if (!keys[SDLK_DOWN]) // Disallow opposite directions@same time
gram1[0x427B] = 1; // Up arrow
}
}
- if (keys[80+128])
+ if (keys[SDLK_DOWN])
{
if (ShowGUI())
SelectDown(); // If GUI active...
else
{
- if (!keys[72+128]) // Disallow opposite directions@same time
+ if (!keys[SDLK_UP]) // Disallow opposite directions@same time
gram1[0x427D] = 1; // Down arrow
}
}
- if (keys[28]) // Return
+ if (keys[SDLK_RETURN]) // Return
{
uint8 retval = UserSelectedSomething();
if (retval == EXIT)
SetRefreshRate(refresh2);
}
}
- if (keys[0x02])
+ if (keys[SDLK_1])
gram1[0x427A] = 1; // (1)
- if (keys[0x03])
+ if (keys[SDLK_2])
gram1[0x427C] = 1; // (2)
- if (keys[0x04])
+ if (keys[SDLK_3])
gram1[0x427E] = 1; // (3)
- if (keys[0x06])
+ if (keys[SDLK_5])
gram1[0x4280] = 1; // (5)
if (keys[0x10]|keys[29])
gram1[0x4276] = 1; // (Q) Jump
gram1[0x4262] = 1; // (T)
if (keys[0x15])
gram1[0x4260] = 1; // (Y)
- if (keys[0x44])
+ if (keys[SDLK_F10])
gram1[0x41A5]++; // Coin? (F10)
- if (keys[0x2C])
+ if (keys[SDLK_z])
gram1[0x4189]++; // ? (Z) credits l dig
- if (keys[0x2D])
+ if (keys[SDLK_x])
gram1[0x418A]++; // ? (X) credits r dig
- if (keys[0x2E])
+ if (keys[SDLK_c])
gram1[0x418C]++; // ? (C) Start
- if (keys[0x2F])
+ if (keys[SDLK_v])
gram1[0x418D]++; // ? (V)
- if (keys[0x41])
+ if (keys[SDLK_F7])
SpawnSound(USERSOUND, 0); // Do user sound (F7)
// if (keys[0x42])
// {
// charbase = false; // Switch chars out...
// }
// if (keys[0x43]) gram1[0x4285] = 1; // (F9) strobe unknown loc
- if (keys[0x45]) // (F11)
+ if (keys[SDLK_F1]) // (F11)
{
Execute6809(&cpu1, 10);
Execute6809(&cpu2, 10);