commit 188d239
zzo38
·
2022-11-21 01:05:20 +0000 UTC
parent 6d562d2
Implement scrolling.
2 files changed,
+17,
-1
M
main.c
+6,
-0
1@@ -59,6 +59,9 @@
2 -q
3 Disable standard I/O.
4
5+-s #
6+ Define scroll size.
7+
8 -t #
9 Set the frame rate, in milliseconds per frame.
10
11@@ -108,6 +111,9 @@ F10
12 PAUSE
13 Pause/unpause VM.
14
15+PAGE-UP / PAGE-DOWN
16+ Scroll up/down.
17+
18 Some programs use shortcut keys with control and letters. This does not
19 work in this program; therefore, END is an alias for the joypad A button
20 (the left control key also corresponds to the joypad A button, but if used
M
main.c
+11,
-1
1@@ -155,6 +155,7 @@ static Uint8 use_extension=0;
2 static Uint8 hide_cursor=0;
3 static Uint8 allow_write=0;
4 static Uint8 joypad_repeat=0;
5+static Uint16 scroll_size=1;
6 static Uint8 zoom=1;
7 static Sint16 default_width=512;
8 static Sint16 default_height=320;
9@@ -901,6 +902,8 @@ static int run_screen(void) {
10 case SDLK_DOWN: i=0x20; break;
11 case SDLK_LEFT: i=0x40; break;
12 case SDLK_RIGHT: i=0x80; break;
13+ case SDLK_PAGEUP: i=-scroll_size; goto scroll;
14+ case SDLK_PAGEDOWN: i=scroll_size; goto scroll;
15 case SDLK_F1: run(GET16(device[2].d)); timer_expired=0; break;
16 case SDLK_F2: if(audio_option) audio_option['m'-'a']^=1; break;
17 case SDLK_F3: use_mouse^=1; set_cursor(); break;
18@@ -924,6 +927,12 @@ static int run_screen(void) {
19 device[8].d[3]=0;
20 }
21 break;
22+ scroll:
23+ if(paused || !i) break;
24+ PUT16(device[9].d+12,i);
25+ run(GET16(device[9].d));
26+ PUT16(device[9].d+12,0);
27+ break;
28 case SDL_KEYUP:
29 i=0;
30 switch(e.key.keysym.sym) {
31@@ -1008,7 +1017,7 @@ int main(int argc,char**argv) {
32 device[10].aux=&uxnfile0;
33 device[11].aux=&uxnfile1;
34 device[12].in=datetime_in;
35- while((i=getopt(argc,argv,"+ABDFNQT:YZa:dh:ijnp:qt:w:xyz:"))>0) switch(i) {
36+ while((i=getopt(argc,argv,"+ABDFNQT:YZa:dh:ijnp:qs:t:w:xyz:"))>0) switch(i) {
37 case 'B': bicycle=1; device[0].in=default_in; break;
38 case 'D': scrflags|=SDL_DOUBLEBUF; break;
39 case 'F': scrflags|=SDL_FULLSCREEN; break;
40@@ -1025,6 +1034,7 @@ int main(int argc,char**argv) {
41 case 'n': use_screen=0; break;
42 case 'p': palet=strtol(optarg,0,10)&7; break;
43 case 'q': use_console=0; break;
44+ case 's': scroll_size=strtol(optarg,0,10); break;
45 case 't': timer_rate=strtol(optarg,0,10); break;
46 case 'w': default_width=strtol(optarg,0,10); break;
47 case 'x': use_extension=1; device[15].in=extension_in; device[15].out=extension_out; break;