Skip to content

Commit f7732d8

Browse files
author
iss
committed
Adding option to enable 50/60 Hz proper aspect ratio in OpenGL render.
1 parent 24b3a4b commit f7732d8

10 files changed

+118
-34
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ endif
5959
#CFLAGS += -DDEBUG_CPU_TRACE=1000
6060
#CFLAGS += -DDEBUG_CPU_TRACE=200000
6161

62+
ifneq ($(DEBUG_VSYNC),)
63+
CFLAGS += -DDEBUG_VSYNC
64+
endif
65+
6266
CC = gcc
6367
CXX = g++
6468
AR = ar

ReadMe.txt

+17-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Here are all the options:
152152
"opengl" for OpenGL
153153

154154
-b / --debug = Start oricutron in the debugger
155-
-r / --breakpoint = Set a breakpoint
155+
-r / --breakpoint = Set a breakpoint (See NOTE2)
156156
-h / --help = Print command line help and quit
157157

158158
--turbotape on|off = Enable or disable turbotape
@@ -181,6 +181,10 @@ NOTE: If you are not sure what machine or drive type is required for a disk or
181181
tape image, just pass the filename without any options and Oricutron will
182182
try and autodetect for you.
183183

184+
NOTE2: List with many breakpoints can be loaded from command line. Use default switches -r or --breakpoint,
185+
but instead of an address, specify filename prefixed with ':'. The file is plain text file, which contains
186+
desired breakpoint-addresses - one per line using the same syntax as in the monitor. Breakpoints can be set
187+
with absolute addresses or with symbols (loaded with command line switches -s or --symbols).
184188

185189
Examples:
186190

@@ -191,7 +195,7 @@ oricutron -m1 -tBUILD/foo.tap -sBUILD/symbols -b
191195
oricutron --drive microdisc --disk demos/barbitoric.dsk --fullscreen
192196
oricutron -ddemos/barbitoric.dsk -f
193197
oricutron --turbotape off tapes/hobbit.tap
194-
198+
oricutron -s myproject.sym -r :myprojectbp.txt
195199

196200

197201
Keys
@@ -277,7 +281,7 @@ Commands:
277281
bcm <bp id> - Clear mem breakpoint
278282
bl - List breakpoints
279283
blm - List mem breakpoints
280-
bs <addr> - Set breakpoint
284+
bs <addr> [zc] - Set breakpoint
281285
bsm <addr> [rwc] - Set mem breakpoint
282286
bz - Zap breakpoints
283287
bzm - Zap mem breakpoints
@@ -309,6 +313,16 @@ There are two types of breakpoints. "Normal" breakpoints trigger when the CPU
309313
is about to execute an instruction at the breakpoint address. "Memory" breakpoints
310314
trigger when the breakpoint address is accessed or modified.
311315

316+
Normal breakpoints can use 'z' and/or 'c' modifiers.
317+
bs $0c00 <-- Break when the CPU is about to execute code at $0c00
318+
bs $0c00 z <-- Break when the CPU is about to execute code at $0c00
319+
and set cycles counter to 0
320+
bs $0c00 zc <-- Set cycles counter to 0 and continues
321+
bs $0c00 c <-- Continues execution (i.e. disabled breakpoint)
322+
323+
Main purpose of this modifiers is to make cycle counting easier.
324+
If symbols are loaded, they can be used instead of absolute addresses.
325+
312326
There are three ways a memory breakpoint can be triggered; when the CPU is about
313327
to read the address (r), and the CPU is about to write the address (w), or after the
314328
value at the address changes for any reason (c).

gui.c

+30-3
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ unsigned char sgpal[] = { 0x00, 0x00, 0x00, // 0 = black
138138
0xff, 0x66, 0x00, // 12 = Atmos sel
139139
0xff, 0x33, 0x33, // 13 = Telestrat sel
140140
0x99, 0x99, 0x66, // 14 = Pravetz bc
141-
0xcc, 0xcc, 0x99 // 15 = Pravetz sel
141+
0xcc, 0xcc, 0x99 // 15 = Pravetz sel
142142
};
143143

144144
// Colors for the menu, see sgpal for color index
145145
// MACH_ORIC1 = 0, MACH_ORIC1_16K, MACH_ATMOS, MACH_TELESTRAT, MACH_PRAVETZ
146146

147147
// Name = { OR TE PR Or
148-
// OR IC AT LE AV ig
148+
// OR IC AT LE AV ig
149149
// IC -1 MO ST ET in a$
150150
// -1, 16, S , RA, Z , al, c };
151151
static char g_foregroundc[] = { 0, 0, 1, 1, 0, 2, 1 };
@@ -194,6 +194,7 @@ void togglesymbolsauto( struct machine *oric, struct osdmenuitem *mitem, int dum
194194
void togglecasesyms( struct machine *oric, struct osdmenuitem *mitem, int dummy );
195195
void togglevsynchack( struct machine *oric, struct osdmenuitem *mitem, int dummy );
196196
void swap_render_mode( struct machine *oric, struct osdmenuitem *mitem, int newrendermode );
197+
void togglearatio( struct machine *oric, struct osdmenuitem *mitem, int dummy );
197198
void togglehstretch( struct machine *oric, struct osdmenuitem *mitem, int dummy );
198199
void togglepalghost( struct machine *oric, struct osdmenuitem *mitem, int dummy );
199200
void togglescanlines( struct machine *oric, struct osdmenuitem *mitem, int dummy );
@@ -306,7 +307,7 @@ struct osdmenuitem dbopitems[] = { { " Autoload symbols file", NULL, 0,
306307
struct osdmenuitem vdopitems[] = { { " OpenGL rendering", "O", 'o', swap_render_mode, RENDERMODE_GL, 0 },
307308
{ " Software rendering", "S", 's', swap_render_mode, RENDERMODE_SW, 0 },
308309
{ OSDMENUBAR, NULL, 0, NULL, 0, 0 },
309-
{ " Fullscreen", "[F8]", SDLK_F8, togglefullscreen, 0, 0 },
310+
{ " Fullscreen", "[F8]", SDLK_F8, togglefullscreen, 0, 0 },
310311
{ " Scanlines", "C", 'c', togglescanlines, 0, 0 },
311312
{ OSDMENUBAR, NULL, 0, NULL, 0, 0 },
312313
{ "Back", "\x17", SDLK_BACKSPACE,gotomenu, 0, 0 },
@@ -323,6 +324,7 @@ struct osdmenuitem glopitems[] = { { " OpenGL rendering", "O", 'o',
323324
{ " Software rendering", "S", 's', swap_render_mode, RENDERMODE_SW, 0 },
324325
{ OSDMENUBAR, NULL, 0, NULL, 0, 0 },
325326
{ " Fullscreen", "F", 'f', togglefullscreen, 0, 0 },
327+
{ " 50Hz/60Hz aspect ratio", "R", 'r', togglearatio, 0, 0 },
326328
{ " Horizontal stretch", "H", 'h', togglehstretch, 0, 0 },
327329
{ " Scanlines", "C", 'c', togglescanlines, 0, 0 },
328330
{ " PAL ghosting", "P", 'p', togglepalghost, 0, 0 },
@@ -607,7 +609,13 @@ void render( struct machine *oric )
607609
perc = 200000/(frametimeave?frametimeave:1);
608610
else
609611
perc = 166667/(frametimeave?frametimeave:1);
612+
613+
#ifdef DEBUG_VSYNC
614+
sprintf( oric->statusstr, "%4d.%02d%% - %4dFPS VSYNC:%3d", perc/100, perc%100, fps/100, oric->vid_offset );
615+
#else
610616
sprintf( oric->statusstr, "%4d.%02d%% - %4dFPS", perc/100, perc%100, fps/100 );
617+
#endif
618+
611619
oric->newstatusstr = SDL_TRUE;
612620
}
613621
if( oric->popuptime > 0 )
@@ -1563,6 +1571,20 @@ void togglefullscreen( struct machine *oric, struct osdmenuitem *mitem, int dumm
15631571
find_item_by_function(glopitems, togglefullscreen)->name = " Fullscreen";
15641572
}
15651573

1574+
// Toggle 50Hz/60Hz aspect ratio
1575+
void togglearatio( struct machine *oric, struct osdmenuitem *mitem, int dummy )
1576+
{
1577+
if( oric->aratio )
1578+
{
1579+
oric->aratio = SDL_FALSE;
1580+
mitem->name = " 50Hz/60Hz aspect ratio";
1581+
return;
1582+
}
1583+
1584+
oric->aratio = SDL_TRUE;
1585+
mitem->name = "\x0e""50Hz/60Hz aspect ratio";
1586+
}
1587+
15661588
// Toggle hstretch on/off
15671589
void togglehstretch( struct machine *oric, struct osdmenuitem *mitem, int dummy )
15681590
{
@@ -2245,6 +2267,11 @@ void setmenutoggles( struct machine *oric )
22452267
find_item_by_function(glopitems, togglefullscreen)->name = " Fullscreen";
22462268
}
22472269

2270+
if( oric->aratio )
2271+
find_item_by_function(glopitems, togglearatio)->name = "\x0e""50Hz/60Hz aspect ratio";
2272+
else
2273+
find_item_by_function(glopitems, togglearatio)->name = " 50Hz/60Hz aspect ratio";
2274+
22482275
if( oric->hstretch )
22492276
find_item_by_function(glopitems, togglehstretch)->name = "\x0e""Horizontal stretch";
22502277
else

keyboard.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <stdlib.h>
2424
#endif
2525

26-
#include <string.h>
26+
#include <string.h>
2727

2828
#include "system.h"
2929
#include "6502.h"

machine.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,16 @@ void move_lightpen( struct machine *oric, int x, int y )
10071007

10081008
if ((oric->rendermode == RENDERMODE_SW) || (!oric->hstretch))
10091009
{
1010-
x = (x-80)/2;
1011-
y = (y-14)/2;
1010+
if(oric->rendermode == RENDERMODE_GL && oric->aratio && oric->vid_freq)
1011+
{
1012+
x = (x-112)/2;
1013+
y = (y-48)/2;
1014+
}
1015+
else
1016+
{
1017+
x = (x-80)/2;
1018+
y = (y-14)/2;
1019+
}
10121020
}
10131021
else
10141022
{

machine.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct machine
111111
int vid_end; // Stop drawing video
112112
int vid_maxrast; // Number of raster lines
113113
int vid_raster; // Current rasterline
114+
int vid_offset; // Current T1 counter position
114115

115116
int vid_fg_col;
116117
int vid_bg_col;
@@ -201,7 +202,7 @@ struct machine
201202

202203
Sint32 keymap;
203204

204-
SDL_bool hstretch, scanlines, palghost;
205+
SDL_bool aratio, hstretch, scanlines, palghost;
205206
Sint32 sw_depth; // Bit depth of the emulator video mode
206207

207208
int rendermode;

main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ static void load_config( struct start_opts *sto, struct machine *oric )
395395
if( read_config_bool( &sto->lctmp[i], "fullscreen", &fullscreen ) ) continue;
396396
if( read_config_bool( &sto->lctmp[i], "hwsurface", &hwsurface ) ) continue;
397397
if( read_config_bool( &sto->lctmp[i], "scanlines", &oric->scanlines ) ) continue;
398+
if( read_config_bool( &sto->lctmp[i], "aratio", &oric->aratio ) ) continue;
398399
if( read_config_bool( &sto->lctmp[i], "hstretch", &oric->hstretch ) ) continue;
399400
if( read_config_bool( &sto->lctmp[i], "palghosting", &oric->palghost ) ) continue;
400401
if( read_config_string( &sto->lctmp[i], "diskimage", sto->start_disk, 1024 ) ) continue;
@@ -1136,7 +1137,7 @@ SDL_bool init( struct machine *oric, int argc, char *argv[] )
11361137
error_printf( "Invalid breakpoint file" );
11371138
free( sto );
11381139
return SDL_FALSE;
1139-
}
1140+
}
11401141
while( !feof( f ) )
11411142
{
11421143
char* p;
@@ -1161,7 +1162,7 @@ SDL_bool init( struct machine *oric, int argc, char *argv[] )
11611162
free( sto );
11621163
return SDL_FALSE;
11631164
}
1164-
1165+
11651166
oric->cpu.breakpoints[0] = addr;
11661167
oric->cpu.anybp = SDL_TRUE;
11671168
}

oricutron.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ rendermode = soft
9494
; Show scanlines? (yes/no)
9595
scanlines = no
9696

97+
; Maintain correct aspec ratio in 50Hz/60Hz modes
98+
aratio = yes
99+
97100
; Horizontal stretch? (yes/no) <-- opengl only
98101
hstretch = yes
99102

0 commit comments

Comments
 (0)