Skip to content

Commit f7b59d1

Browse files
author
Hugh Robinson
committed
Redraw menu screens properly in response to expose events (Peter de Wachter).
1 parent 9a86cc2 commit f7b59d1

File tree

5 files changed

+80
-54
lines changed

5 files changed

+80
-54
lines changed

asylum.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int game()
173173
bonusplot();
174174
scoreadd();
175175
update_show_strength();
176-
texthandler();
176+
texthandler(1);
177177
seeifdead();
178178
//makesounds();
179179
wakeupal(xpos, ypos);
@@ -217,7 +217,7 @@ int game()
217217

218218
void showtext()
219219
{
220-
texthandler();
220+
texthandler(0);
221221
switchbank();
222222
}
223223

@@ -426,7 +426,6 @@ void setup()
426426
initweapon();
427427
initprojtab();
428428
initbultab();
429-
setfullclip();
430429
initrockettab();
431430
getvars();
432431
prepstrength();
@@ -523,7 +522,6 @@ char deathmusicpath[] = "./Resources/Music2";
523522
int getfiles()
524523
{
525524
getvitalfiles();
526-
setfullclip();
527525
showloading();
528526
init_sounds();
529527
getmusicfiles();

asylum.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int game();
150150
void switchcolch();
151151
void switchbank();
152152
void showtext();
153-
void texthandler();
153+
void texthandler(int do_animation);
154154
void deathmessage();
155155
void endgamemessage();
156156
void alfire();
@@ -359,7 +359,6 @@ void loselife();
359359
void rejoin();
360360
void adjustopt();
361361
void copyscreen();
362-
void setfullclip();
363362
void set_player_clip();
364363
void writeclip();
365364
void releaseclip();
@@ -545,3 +544,5 @@ void init_chunk_bullet();
545544
void init_chunk_maze();
546545
void init_chunk_alien();
547546
void init_chunk_player();
547+
548+
int need_redraw();

keyboard.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static char keyboard[512];
2323
static int keybuf;
2424
static int unibuf;
2525
static int mouse;
26+
static int exposed;
2627

2728
#define ESC_VALUE 27
2829

@@ -132,6 +133,9 @@ void update_keyboard()
132133
case SDL_BUTTON_RIGHT: mouse &= ~1; break;
133134
}
134135
break;
136+
case SDL_VIDEOEXPOSE:
137+
exposed = 1;
138+
break;
135139
case SDL_QUIT:
136140
exithandler();
137141
break;
@@ -213,3 +217,9 @@ void keyread(key_state* ks)
213217
ks->keypressed = 1;
214218
}
215219

220+
int need_redraw()
221+
{
222+
int e = exposed;
223+
exposed = 0;
224+
return e;
225+
}

menus.c

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ int escapehandler()
3232
{
3333
//frameinc = 1;
3434
showchatscreen();
35-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
3635
swi_fastspr_clearwindow();
3736
wipetexttab();
3837
message(36, 40-256, 0, 4, "¤ Game Interrupted ¤");
@@ -52,7 +51,12 @@ int escapehandler()
5251
r9--;
5352
switchbank();
5453
swi_fastspr_clearwindow();
55-
texthandler();
54+
texthandler(1);
55+
}
56+
else if (need_redraw())
57+
{
58+
showchatscreen();
59+
showtext();
5660
}
5761
switch (osbyte_79_unicode(1))
5862
{
@@ -90,7 +94,6 @@ int options_menu(int gameon)
9094
clearkeybuf();
9195
wipetexttab();
9296
showchatscreen();
93-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
9497
swi_fastspr_clearwindow();
9598
message(128, 48, 0, 0, "Options");
9699
message(32, 96, 0, 0, "1. Define Controls");
@@ -266,7 +269,6 @@ char sound7[] = "-7. Overdrive";
266269
void tunesound()
267270
{
268271
showchatscreen();
269-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
270272
for (;; /*tunesoundloop:*/ soundupdate(), swi_stasis_link(1, 1), swi_sound_control(1, -15, 0x20, 0xfe))
271273
{
272274
tunesoundins:
@@ -319,7 +321,6 @@ void tunevolume()
319321
wipetexttab();
320322
if (sound_available && (options.soundtype == 2)) swi_bodgemusic_start(1, 0);
321323
swi_bodgemusic_volume(options.musicvol);
322-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
323324
message(80, 32, 0, 0, "Change volume");
324325
message(48, 96, 0, 0, "1. Louder effects");
325326
message(48, 116, 0, 0, "2. Quieter effects");
@@ -384,7 +385,6 @@ void tunespeed()
384385
do
385386
{
386387
showchatscreen();
387-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
388388
do
389389
{
390390
tunespeedloop:
@@ -462,11 +462,12 @@ int selectkey(int x, int y, int xv, int yv, const char* a)
462462
showtext();
463463
do
464464
{
465-
//do choosekeyloop:; // read key
466-
//while (osbyte_79(0)!=0xff); //no key pressed
467-
//if ((r4=osbyte_81(1))==ESC_VALUE) // read key
468-
//{ chooseescape: osbyte_7c();
469-
//return 0;} //early exit
465+
if (need_redraw())
466+
{
467+
showchatscreen();
468+
showtext();
469+
}
470+
swi_blitz_wait(1);
470471
}
471472
while ((r1 = osbyte_79(0)) == -1); // scan keyboard
472473
if (swi_readescapestate()) return 0;
@@ -498,6 +499,12 @@ int readopt(int maxopt)
498499
return r1 - '0';
499500
if (osbyte_81(options.firekey) == 0xff)
500501
return 0;
502+
if (need_redraw())
503+
{
504+
showchatscreen();
505+
showtext();
506+
}
507+
swi_blitz_wait(1);
501508
}
502509
}
503510

@@ -508,9 +515,7 @@ int prelude()
508515
{
509516
int cheatpermit = 0;
510517
//frameinc = 1;
511-
setfullclip();
512518
showchatscreen();
513-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
514519
swi_fastspr_clearwindow();
515520
wipetexttab();
516521
message(2048, _x, 0, _v, "Digital Psychosis");
@@ -539,7 +544,12 @@ int prelude()
539544
scroll--;
540545
switchbank();
541546
swi_fastspr_clearwindow();
542-
texthandler();
547+
texthandler(1);
548+
}
549+
else if (need_redraw())
550+
{
551+
showchatscreen();
552+
showtext();
543553
}
544554
preludetextstop:;
545555
int r1 = osbyte_7a();
@@ -630,7 +640,6 @@ void showerror()
630640
{
631641
//frameinc = 1;
632642
showchatscreen();
633-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
634643
swi_fastspr_clearwindow();
635644
wipetexttab();
636645
message(72, 200, 0, 0, "RET - Try Again");
@@ -641,7 +650,6 @@ void showerrorok()
641650
{
642651
//frameinc = 1;
643652
showchatscreen();
644-
swi_fastspr_setclipwindow(20, 20, 319-20, 255-20);
645653
swi_fastspr_clearwindow();
646654
wipetexttab();
647655
message(72, 200, 0, 0, "RET - OK");
@@ -682,7 +690,6 @@ int showhighscore()
682690
loadscores(highscorearea, options.mentalzone);
683691
updatehst();
684692
showhst();
685-
wipetexttab();
686693
message(96, 224, 0, 0, "press fire");
687694
releaseclip();
688695
showtext();
@@ -781,20 +788,20 @@ void showhst()
781788
showchatscores();
782789
wipetexttab();
783790
message(64, 32, 0, 0, "Zone High Scores");
784-
texthandler();
785-
char* r10 = highscorearea;
786-
int x = 32, y = 64;
787-
for (int r3 = 5; r3 > 0; r3--)
791+
792+
int x = 32, y = 64, i, j;
793+
char * ptr = highscorearea;
794+
for (i = 0; i < 5; ++i)
788795
{
789-
for (; *r10 > 0xa; r10++)
790-
{
791-
showhstloop:
792-
if (*r10 != ' ') fspplot(charsadr, *r10-'0', x, y);
793-
x += 16;
794-
}
795-
showhstnewline:
796-
x = 32; y += 32; r10++;
796+
char line[13];
797+
for (j = 0; j < 12 && *ptr > 0xa; ++j, ++ptr)
798+
line[j] = *ptr;
799+
line[j] = 0;
800+
message(x, y, 0, 0, line);
801+
y += 32;
802+
++ptr; /*skip over newline*/
797803
}
798-
if (hstindex == 5) return;
799-
fspplot(charsadr, 13, 280, (hstindex+2)<<5);
804+
if (hstindex < 5)
805+
message(280, (hstindex+2)<<5, 0, 0, "=");
806+
texthandler(0);
800807
}

vdu.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,24 +261,27 @@ void wipetexttab()
261261
*(r10++) = 0;
262262
}
263263

264-
void texthandler()
264+
void texthandler(int do_animation)
265265
{
266266
textinfo* r11 = texttabofs;
267267
int r9 = _textno;
268268

269269
for (; r9 > 0; r11++, r9--)
270270
{
271-
loopa6: if (r11->count == 0) continue;
272-
textproc:;
273-
int r4 = (frameinc > 4) ? 4 : frameinc;
274-
r11->count -= r4; if (r11->count < 0) r11->count = 0;
271+
if (r11->count == 0) continue;
275272

276-
for (; r4 > 0; r4--)
273+
if (do_animation)
277274
{
278-
loopb1:
279-
r11->x += r11->dx;
280-
r11->y += r11->dy;
275+
int r4 = (frameinc > 4) ? 4 : frameinc;
276+
r11->count -= r4; if (r11->count < 0) r11->count = 0;
277+
278+
for (; r4 > 0; r4--)
279+
{
280+
r11->x += r11->dx;
281+
r11->y += r11->dy;
282+
}
281283
}
284+
282285
int XxX = r11->x>>8;
283286
int YyY = r11->y>>8;
284287
for (char* r10 = r11->text; *r10 != 0; r10++)
@@ -542,14 +545,6 @@ void showscore(char plscore[8])
542545
}
543546
}
544547

545-
void setfullclip()
546-
{
547-
clip.x = vduvar.gamex; clip.y = vduvar.gamey;
548-
clip.w = vduvar.gamew;
549-
clip.h = vduvar.gameh;
550-
writeclip();
551-
}
552-
553548
void writeclip()
554549
{
555550
swi_fastspr_setclipwindow(clip.x, clip.y, clip.x+clip.w, clip.y+clip.h);
@@ -589,8 +584,16 @@ void showgamescreen()
589584
releaseclip();
590585
//SDL_BlitSurface(GameScreen, NULL, ArcScreen, NULL);
591586
fspplot(&GameScreen, 0, 0, 0);
587+
#if 0
592588
if (!vduvar.opengl) switchbank();
589+
#endif
590+
591+
clip.x = vduvar.gamex;
592+
clip.y = vduvar.gamey;
593+
clip.w = vduvar.gamew;
594+
clip.h = vduvar.gameh;
593595
writeclip();
596+
594597
scorewiperead();
595598
showlives();
596599
}
@@ -600,8 +603,15 @@ void showchatscreen()
600603
releaseclip();
601604
//SDL_BlitSurface(ChatScreen, NULL, ArcScreen, NULL);
602605
fspplot(&ChatScreen, 0, 0, 0);
606+
#if 0
603607
switchbank();
604608
if (vduvar.opengl) fspplot(&ChatScreen, 0, 0, 0);
609+
#endif
610+
611+
clip.x = 20;
612+
clip.y = 20;
613+
clip.w = 319 - 20*2;
614+
clip.h = 255 - 20*2;
605615
writeclip();
606616
}
607617

0 commit comments

Comments
 (0)