X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui.cpp;h=a84ab6f19124f932120095fcd48c5cd7b54298fc;hb=2fe4f4d3720583b59e0412d2a0cb72109db78573;hp=640b70fcf213f2572d1f16ead9939acfc65659be;hpb=27ad8041c00ff80e50ba0ad9022c3eaa7a05b8b0;p=thunder diff --git a/src/gui.cpp b/src/gui.cpp old mode 100755 new mode 100644 index 640b70f..a84ab6f --- a/src/gui.cpp +++ b/src/gui.cpp @@ -1,16 +1,22 @@ // // Thunder Graphic User Interface -// v1.0 (Last build: 8/1/1998) // -// by Jimmy Hamm -// (C) 1998 Underground Software +// by James Hammons +// (c) 2004, 2014 Underground Software // +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 07/23/2009 Added changelog ;-) +// + +#include "gui.h" #include #include // Needed for tracelog -#include "SDL.h" // Needed for screen.h +//#include "SDL.h" // Needed for screen.h #include "screen.h" -#include "gui.h" #include "resource.h" // Thunder graphics & sounds using namespace std; // Yes! @@ -19,34 +25,34 @@ using namespace std; // Yes! extern SDL_Surface * screen; -extern BYTE my_scr[0x14000]; // Screen buffer... -extern BYTE * gram1; // Game RAM (do here??) -extern BYTE hScrollOffset; // Horizontal scroll offset -extern BYTE vScrollOffset; // Vertical scroll offset -extern DWORD voffsets[8]; -extern BYTE * voice_rom; // PCM data pointer +extern uint8_t my_scr[0x14000]; // Screen buffer... +extern uint8_t gram1[]; // Game RAM (do here??) +extern uint8_t hScrollOffset; // Horizontal scroll offset +extern uint8_t vScrollOffset; // Vertical scroll offset +extern uint32_t voffsets[8]; +extern uint8_t voice_rom[]; // PCM data pointer extern fstream tr; // Tracelog // Global shit -WORD text_life; // How long text is visible +uint16_t text_life; // How long text is visible bool show_text; // Whether or not to show text -WORD show_which_msg; // Which message to show +uint16_t show_which_msg; // Which message to show bool show_gui; // Whether or not to show GUI -WORD selection; // Which GUI item currently selected -WORD snd_num; -WORD gui_debounce; // GUI key debounce value -WORD num_coins; // Number of coins dropped -WORD blink = 0; // Used to blink player 1 & 2 start buttons -WORD flash = 23; // Used to flash GUI lights -WORD iline = 0; // Used to roll line -WORD dcurcol = 179; // dipswitch cursor color +uint16_t selection; // Which GUI item currently selected +uint16_t snd_num; +uint16_t gui_debounce; // GUI key debounce value +uint16_t num_coins; // Number of coins dropped +uint16_t blink = 0; // Used to blink player 1 & 2 start buttons +uint16_t flash = 23; // Used to flash GUI lights +uint16_t iline = 0; // Used to roll line +uint16_t dcurcol = 179; // dipswitch cursor color int dcurdir = 1; // Initially going up... bool blink_on = false; bool game_refresh; // Refresh rate user set bool do_decrement; // Flag to handle decrement... bool user_selected_something; // Flag for well, you know... -WORD dswitch; // Which dipswitch is selected... +uint16_t dswitch; // Which dipswitch is selected... // The following are global for the sound routines... @@ -54,27 +60,27 @@ const float sampleBase = 22050.0/6000.0; // Btwn 5512.5 and 6000 bool snd_go = false; bool chan1_go = false, chan2_go = false, chan3_go = false; bool chan4_go = false, chan5_go = false, chan6_go = false; -BYTE * sndp1, * sndp2, * sndp3, * sndp4, * sndp5, * sndp6; -uint32 rom_pos, end_pos; -uint32 spos1, end_pos1; -uint32 spos2, end_pos2; -uint32 spos3, end_pos3; -uint32 spos4, end_pos4; -uint32 spos5, end_pos5; -uint32 spos6, end_pos6; +uint8_t * sndp1, * sndp2, * sndp3, * sndp4, * sndp5, * sndp6; +uint32_t rom_pos, end_pos; +uint32_t spos1, end_pos1; +uint32_t spos2, end_pos2; +uint32_t spos3, end_pos3; +uint32_t spos4, end_pos4; +uint32_t spos5, end_pos5; +uint32_t spos6, end_pos6; float sample1; -uint8 prevSamp1; -int8 delta_x1; +uint8_t prevSamp1; +int8_t delta_x1; float sample2; -uint8 prevSamp2; -int8 delta_x2; +uint8_t prevSamp2; +int8_t delta_x2; -BYTE * snd_array[3] = { sunknown, scya, scamera }; // From RESOURCE.H -DWORD snd_lens[3] = { sunknownlen, scyalen, scameralen }; +uint8_t * snd_array[3] = { sunknown, scya, scamera }; // From RESOURCE.H +uint32_t snd_lens[3] = { sunknownlen, scyalen, scameralen }; // Bitmaps -BYTE bmp1[] = { +uint8_t bmp1[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,1,0,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0, @@ -83,7 +89,7 @@ BYTE bmp1[] = { 0,0,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; -BYTE bmp2[] = { +uint8_t bmp2[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0, 0,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0, @@ -92,7 +98,7 @@ BYTE bmp2[] = { 0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; -BYTE bmp3[] = { +uint8_t bmp3[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,0,0,0,0,1,1,1,0,0,0,1,1,0,0,1,1,1,0,0, @@ -101,7 +107,7 @@ BYTE bmp3[] = { 0,1,1,1,0,0,1,0,0,1,0,0,1,1,1,0,1,1,1,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }; -BYTE boptions[] = { // 35x9 +uint8_t boptions[] = { // 35x9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,1,0,0,0,0,0,0,0,0,1,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0,0,0,0,0, 0,1,1,1,0,0, 0,1,0,0,1,0, 0,1,0,0,1,0, 0,1,0,0,1,0, 0,1,1,1,0,0, - 0,0,0,0,0,0 + 0,0,0,0,0,0 }; -BYTE bnE[] = { +uint8_t bnE[] = { 0,0,0,0,0,0, 0,1,1,1,1,0, 0,1,0,0,0,0, 0,1,1,1,1,0, 0,1,0,0,0,0, 0,1,1,1,1,0, - 0,0,0,0,0,0 + 0,0,0,0,0,0 }; -BYTE bnF[] = { +uint8_t bnF[] = { 0,0,0,0,0,0, 0,1,1,1,1,0, 0,1,0,0,0,0, 0,1,1,1,0,0, 0,1,0,0,0,0, 0,1,0,0,0,0, - 0,0,0,0,0,0 + 0,0,0,0,0,0 }; // @@ -316,16 +322,16 @@ void DeactivateGUI(void) { show_gui = false; } // // Draw the small icons... // -void DrawSmallIcons(WORD icon_not_to_draw) +void DrawSmallIcons(uint16_t icon_not_to_draw) { - BYTE * iconmem; - BYTE xl, yl; - BYTE * sIcons[12] = { inoguis, icoinus, ipl1sts, ipl2sts, ii30hzs, ii60hzs, + uint8_t * iconmem; + uint8_t xl, yl; + uint8_t * sIcons[12] = { inoguis, icoinus, ipl1sts, ipl2sts, ii30hzs, ii60hzs, idipsws, ichecks, ikeycns, isnapss, iresets, ibyebys }; - BYTE xlens[12] = { 31, 18, 32, 35, 37, 37, 29, 23, 28, 32, 19, 19 }; - BYTE ylens[12] = { 31, 18, 19, 19, 21, 21, 23, 20, 16, 17, 20, 23 }; - BYTE xpos[11] = { 33, 48, 63, 78, 104, 0, 184, 210, 225, 240, 255 }; - BYTE iconidx[11] = { 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 6 }; + uint8_t xlens[12] = { 31, 18, 32, 35, 37, 37, 29, 23, 28, 32, 19, 19 }; + uint8_t ylens[12] = { 31, 18, 19, 19, 21, 21, 23, 20, 16, 17, 20, 23 }; + uint8_t xpos[11] = { 33, 48, 63, 78, 104, 0, 184, 210, 225, 240, 255 }; + uint8_t iconidx[11] = { 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 6 }; if (game_refresh) iconidx[9] = 5; // 60 Hz... @@ -333,44 +339,44 @@ void DrawSmallIcons(WORD icon_not_to_draw) for(int i=0; i<5; i++) { - WORD idx = i + icon_not_to_draw; // Get correct start pos. + uint16_t idx = i + icon_not_to_draw; // Get correct start pos. if (idx > 10) idx -= 11; iconmem = sIcons[iconidx[idx]]; xl = xlens[iconidx[idx]]; yl = ylens[iconidx[idx]]; - DWORD scadr = hScrollOffset + voffsets[vScrollOffset]; + uint32_t scadr = hScrollOffset + voffsets[vScrollOffset]; scadr += 320*((224-yl)/2); // Center vertically scadr += xpos[i] - (xl/2); // Center around horiz. pos. - WORD bmpptr = 0; + uint16_t bmpptr = 0; for(int yy=0; yy5; i--) { - WORD idx = i + icon_not_to_draw; // Get correct start pos. + uint16_t idx = i + icon_not_to_draw; // Get correct start pos. if (idx > 10) idx -= 11; iconmem = sIcons[iconidx[idx]]; xl = xlens[iconidx[idx]]; yl = ylens[iconidx[idx]]; - DWORD scadr = hScrollOffset + voffsets[vScrollOffset]; + uint32_t scadr = hScrollOffset + voffsets[vScrollOffset]; scadr += 320*((224-yl)/2); // Center vertically scadr += xpos[i] - (xl/2); // Center around horiz. pos. - WORD bmpptr = 0; + uint16_t bmpptr = 0; for(int yy=0; yy7) scadr += 17*320; // Adjust for DSW #2 @@ -514,12 +520,12 @@ void DrawDipswitch(void) { for(int xx=0; xx<5; xx++) { - my_scr[scadr++] = idsbutton[bmpptr++]; + my_scr[scadr++] = idsbutton[bmpptr++]; } scadr += 315; // Adjust position... } } - BYTE dselected_text = dseloff[dswitch]; + uint8_t dselected_text = dseloff[dswitch]; for(int i=0; i<13; i++) { if (dselected_text != i) @@ -531,7 +537,7 @@ void DrawDipswitch(void) { for(int xx=0; xx>4, second_dig = number&0x0F; + uint8_t first_dig = number>>4, second_dig = number&0x0F; for(int y=0; y<7; y++) { for(int x=0; x<6; x++) @@ -796,7 +802,7 @@ void ShowNumbers(int number) // // Spawn a message // -void SpawnMsg(BYTE msg) +void SpawnMsg(uint8_t msg) { text_life = 60; // 1 second... show_text = true; // Show the damn thing... @@ -817,8 +823,8 @@ void DrawText(void) text_life--; // Your life force is running out... // Draw the message here... - DWORD scadr = hScrollOffset + voffsets[vScrollOffset] + 642; - WORD bmpptr = 0; + uint32_t scadr = hScrollOffset + voffsets[vScrollOffset] + 642; + uint16_t bmpptr = 0; for(int y=0; y<7; y++) { @@ -857,12 +863,12 @@ void DrawText(void) // void SpawnSound(int type, int snd, int channel/* = 0*/) { - extern DWORD psg_lens[16]; - extern BYTE * psg_adrs[16]; - extern DWORD voc_lens[32]; - extern BYTE * voc_adrs[32]; - extern DWORD fm_lens[14]; - extern BYTE * fm_adrs[14]; + extern uint32_t psg_lens[16]; + extern uint8_t * psg_adrs[16]; + extern uint32_t voc_lens[32]; + extern uint8_t * voc_adrs[32]; + extern uint32_t fm_lens[14]; + extern uint8_t * fm_adrs[14]; snd_num = snd; SpawnMsg(MSHOWNUMS); @@ -874,7 +880,7 @@ void SpawnSound(int type, int snd, int channel/* = 0*/) if (channel == 0) { // 00 nn ss (nn # of repeats of sample ss) - DWORD st = 0; + uint32_t st = 0; if (snd & 0x40) { @@ -890,7 +896,7 @@ void SpawnSound(int type, int snd, int channel/* = 0*/) } else { - DWORD st = 0; + uint32_t st = 0; if (snd & 0x40) { @@ -952,9 +958,9 @@ void SpawnSound(int type, int snd, int channel/* = 0*/) // void SoundFunc(void * userdata, Uint8 * buff, int num) { - uint16 cnt = 0, sample; // 0-22 different sounds... - uint8 start_samp1, end_samp1, start_samp2, end_samp2; - uint8 samp1 = 128, samp2 = 128, samp3 = 128, + uint16_t cnt = 0, sample; // 0-22 different sounds... + uint8_t start_samp1, end_samp1, start_samp2, end_samp2; + uint8_t samp1 = 128, samp2 = 128, samp3 = 128, samp4 = 128, samp5 = 128, samp6 = 128; // Zero samples... memset(buff, 128, num); // Kill sound...