2007-05-30 21:56:52 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
2006-07-09 11:47:17 +00:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2014-02-18 02:34:19 +01:00
*
2006-07-09 11:47:17 +00:00
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
2014-02-18 02:34:19 +01:00
*
2006-07-09 11:47:17 +00:00
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2010-07-05 16:11:11 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
2006-07-09 11:47:17 +00:00
*/
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
2006-11-03 23:16:29 +00:00
// - Remove scummconsole.c
// - Delete files
2006-12-01 22:36:54 +00:00
// - libcartreset
// - Alternative controls - tap for left click, double for right
// - Inherit the Earth?
// - Stereo audio?
// - Software scaler?
2007-10-13 15:40:11 +00:00
// - 100% scale
// - Arrow keys cause key events when keyboard enabled - Done
// - Mouse cursor display - Done
// - Disable scaler on options menu - Done
// - Fix scale icons on top screen - Done
// - Fseek optimisation? - No need
// - Fix agi hack to be cleaner - done
// - Fix not typing looong words - Done
// - Show keyboard by default in AGI games
// - Fix mouse moving when cursor on keyboard screen - Done
// - Fix 'fit' thingy always appearing - Done
// - check cine backbuffer code - Done
// - Add long filename support - Done
// - New icons
// - Add key config for gob engine: Start:F1, Shift-numbers: F keys - Done
// - Fix [ds] appearing in game menu
// - Find out what's going wrong when you turn the console off
// - enable console when asserting
2007-08-18 11:10:41 +00:00
// - Alternative controls?
2008-05-15 22:12:51 +00:00
// - Fix 512x256 backbuffer to 320x240 - Done
// - Fix keyboard appearing on wrong screen - Done
// - Volume amplify option
// - Make save/restore game screen use scaler buffer
2007-08-18 11:10:41 +00:00
2009-09-27 22:42:21 +00:00
// 1.0.0!
// - Fix text on tabs on config screen
// - Remove ini file debug msg
// - Memory size for ite
// - Try discworld?
2018-04-07 17:45:47 +01:00
// Allow use of stuff in <nds.h>
# define FORBIDDEN_SYMBOL_EXCEPTION_printf
# define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
2009-09-27 22:42:21 +00:00
2007-10-13 15:40:11 +00:00
2006-07-09 11:47:17 +00:00
# include <nds.h>
2020-06-01 22:47:20 +01:00
# include <filesystem.h>
2006-07-09 11:47:17 +00:00
# include <stdlib.h>
2010-07-05 10:07:54 +00:00
# include <string.h>
2006-07-09 11:47:17 +00:00
# include "dsmain.h"
# include "osystem_ds.h"
# include "dsoptions.h"
2006-10-05 22:44:11 +00:00
# include "blitters.h"
2020-05-10 23:45:08 +02:00
# include "engines/engine.h"
2010-07-05 10:07:54 +00:00
2010-08-06 06:03:34 +00:00
# include "backends/plugins/ds/ds-provider.h"
2020-07-23 18:53:41 +01:00
# include "base/main.h"
2010-05-31 18:28:26 +00:00
# include "base/version.h"
2010-07-05 10:07:54 +00:00
# include "common/util.h"
2006-07-09 11:47:17 +00:00
namespace DS {
// From console.c in NDSLib
// Defines
# define FRAME_TIME 17
# define SCUMM_GAME_HEIGHT 142
2006-11-03 23:16:29 +00:00
# define SCUMM_GAME_WIDTH 227
2006-07-09 11:47:17 +00:00
2010-07-05 10:07:54 +00:00
static int frameCount ;
static int currentTimeMillis ;
2006-07-09 11:47:17 +00:00
// Timer Callback
2010-07-05 10:07:54 +00:00
static int callbackInterval ;
static int callbackTimer ;
static OSystem_DS : : TimerProc callback ;
2006-07-09 11:47:17 +00:00
// Scaled
2010-07-05 10:07:54 +00:00
static bool scaledMode ;
static int scX ;
static int scY ;
2006-07-09 11:47:17 +00:00
2010-07-05 10:07:54 +00:00
static int subScX ;
static int subScY ;
static int subScTargetX ;
static int subScTargetY ;
static int subScreenWidth = SCUMM_GAME_WIDTH ;
static int subScreenHeight = SCUMM_GAME_HEIGHT ;
static int subScreenScale = 256 ;
2006-07-09 11:47:17 +00:00
// Saved buffers
2010-07-05 10:07:54 +00:00
static bool highBuffer ;
static bool displayModeIs8Bit = false ;
2006-07-09 11:47:17 +00:00
2010-07-05 10:07:54 +00:00
static bool consoleEnable = false ;
static bool gameScreenSwap = false ;
2006-11-03 23:16:29 +00:00
bool isCpuScalerEnabled ( ) ;
2006-11-25 20:35:34 +00:00
//#define HEAVY_LOGGING
2006-07-09 11:47:17 +00:00
2010-07-05 10:07:54 +00:00
static int storedMouseX = 0 ;
static int storedMouseY = 0 ;
2007-06-30 23:03:03 +00:00
2006-07-09 11:47:17 +00:00
// Sprites
2010-07-05 10:07:54 +00:00
static SpriteEntry sprites [ 128 ] ;
static SpriteEntry spritesMain [ 128 ] ;
2006-07-09 11:47:17 +00:00
// Shake
2019-11-15 01:38:21 -08:00
static int s_shakeXOffset = 0 ;
static int s_shakeYOffset = 0 ;
2006-07-09 11:47:17 +00:00
// Touch
2010-07-05 10:07:54 +00:00
static int touchScX , touchScY , touchX , touchY ;
static int mouseHotspotX , mouseHotspotY ;
static bool cursorEnable = false ;
static bool mouseCursorVisible = true ;
static bool touchPadStyle = false ;
2006-07-09 11:47:17 +00:00
// 8-bit surface size
2010-07-05 10:07:54 +00:00
static int gameWidth = 320 ;
static int gameHeight = 200 ;
2006-07-09 11:47:17 +00:00
2006-11-03 23:16:29 +00:00
// Scale
2010-07-05 10:07:54 +00:00
static bool twoHundredPercentFixedScale = false ;
static bool cpuScalerEnable = false ;
2008-09-15 22:43:20 +00:00
2010-07-05 10:07:54 +00:00
static u8 * scalerBackBuffer = NULL ;
2008-05-15 22:12:51 +00:00
2010-07-05 10:07:54 +00:00
static u16 savedPalEntry255 = RGB15 ( 31 , 31 , 31 ) ;
2006-07-09 11:47:17 +00:00
2007-04-06 18:34:53 +00:00
void setIcon ( int num , int x , int y , int imageNum , int flags , bool enable ) ;
2007-06-30 23:03:03 +00:00
void setIconMain ( int num , int x , int y , int imageNum , int flags , bool enable ) ;
2009-01-21 04:27:32 +00:00
bool isCpuScalerEnabled ( ) {
2008-05-15 22:12:51 +00:00
return cpuScalerEnable | | ! displayModeIs8Bit ;
2006-11-03 23:16:29 +00:00
}
2007-12-21 18:36:40 +00:00
void setCpuScalerEnable ( bool enable ) {
cpuScalerEnable = enable ;
}
2008-09-15 22:43:20 +00:00
void setTrackPadStyleEnable ( bool enable ) {
touchPadStyle = enable ;
}
void setGameScreenSwap ( bool enable ) {
gameScreenSwap = enable ;
}
2009-09-27 22:42:21 +00:00
void setGamma ( int gamma ) {
OSystem_DS : : instance ( ) - > setGammaValue ( gamma ) ;
}
2008-09-15 22:43:20 +00:00
void setTopScreenZoom ( int percentage ) {
s32 scale = ( percentage < < 8 ) / 100 ;
subScreenScale = ( 256 * 256 ) / scale ;
}
2007-12-21 18:36:40 +00:00
2006-07-09 11:47:17 +00:00
void updateOAM ( ) {
DC_FlushAll ( ) ;
2008-05-15 22:12:51 +00:00
if ( gameScreenSwap ) {
dmaCopy ( sprites , OAM , 128 * sizeof ( SpriteEntry ) ) ;
dmaCopy ( spritesMain , OAM_SUB , 128 * sizeof ( SpriteEntry ) ) ;
} else {
dmaCopy ( sprites , OAM_SUB , 128 * sizeof ( SpriteEntry ) ) ;
dmaCopy ( spritesMain , OAM , 128 * sizeof ( SpriteEntry ) ) ;
}
2006-07-09 11:47:17 +00:00
}
void setGameSize ( int width , int height ) {
gameWidth = width ;
gameHeight = height ;
}
int getGameWidth ( ) {
return gameWidth ;
}
int getGameHeight ( ) {
return gameHeight ;
}
void initSprites ( ) {
2007-09-18 20:16:33 +00:00
for ( int i = 0 ; i < 128 ; i + + ) {
2009-09-27 22:42:21 +00:00
sprites [ i ] . attribute [ 0 ] = ATTR0_DISABLED ;
sprites [ i ] . attribute [ 1 ] = 0 ;
sprites [ i ] . attribute [ 2 ] = 0 ;
sprites [ i ] . filler = 0 ;
}
2009-01-01 15:06:43 +00:00
2007-09-18 20:16:33 +00:00
for ( int i = 0 ; i < 128 ; i + + ) {
2009-09-27 22:42:21 +00:00
spritesMain [ i ] . attribute [ 0 ] = ATTR0_DISABLED ;
spritesMain [ i ] . attribute [ 1 ] = 0 ;
spritesMain [ i ] . attribute [ 2 ] = 0 ;
spritesMain [ i ] . filler = 0 ;
}
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
updateOAM ( ) ;
}
void saveGameBackBuffer ( ) {
2007-12-21 18:36:40 +00:00
2008-05-15 22:12:51 +00:00
// Sometimes the only copy of the game screen is in video memory.
// So, I lock the video memory here, as if I'm going to modify it. This
// forces OSystem_DS to create a system memory copy if one doesn't exist.
2009-01-21 04:27:32 +00:00
// This will be automatially restored by OSystem_DS::updateScreen().
2009-01-01 15:06:43 +00:00
2008-05-15 22:12:51 +00:00
OSystem_DS : : instance ( ) - > lockScreen ( ) ;
OSystem_DS : : instance ( ) - > unlockScreen ( ) ;
2006-07-09 11:47:17 +00:00
}
2006-11-03 23:16:29 +00:00
void set200PercentFixedScale ( bool on ) {
twoHundredPercentFixedScale = on ;
}
2006-07-09 11:47:17 +00:00
void setUnscaledMode ( bool enable ) {
scaledMode = ! enable ;
}
void displayMode8Bit ( ) {
2006-11-25 20:35:34 +00:00
# ifdef HEAVY_LOGGING
2020-07-23 18:29:59 +01:00
printf ( " displayMode8Bit... " ) ;
2006-11-25 20:35:34 +00:00
# endif
2006-07-09 11:47:17 +00:00
u16 buffer [ 32 * 32 ] ;
2009-01-01 15:06:43 +00:00
2020-08-06 15:04:24 +01:00
setOptions ( ) ;
2006-07-09 11:47:17 +00:00
if ( ! displayModeIs8Bit ) {
for ( int r = 0 ; r < 32 * 32 ; r + + ) {
buffer [ r ] = ( ( u16 * ) SCREEN_BASE_BLOCK_SUB ( 4 ) ) [ r ] ;
}
2009-03-19 09:51:40 +00:00
} else {
2008-05-15 22:12:51 +00:00
for ( int r = 0 ; r < 32 * 32 ; r + + ) {
2009-03-19 09:51:40 +00:00
buffer [ r ] = ( ( u16 * ) SCREEN_BASE_BLOCK ( 2 ) ) [ r ] ;
2008-05-15 22:12:51 +00:00
}
}
displayModeIs8Bit = true ;
2009-01-01 15:06:43 +00:00
2009-01-21 04:27:32 +00:00
if ( isCpuScalerEnabled ( ) ) {
2018-04-19 12:08:31 +02:00
videoSetMode ( MODE_5_2D | ( consoleEnable ? DISPLAY_BG0_ACTIVE : 0 ) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ;
2006-11-25 20:35:34 +00:00
videoSetModeSub ( MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ; //sub bg 0 will be used to print text
2009-01-01 15:06:43 +00:00
2007-04-06 18:34:53 +00:00
vramSetBankA ( VRAM_A_MAIN_BG_0x06000000 ) ;
vramSetBankB ( VRAM_B_MAIN_BG_0x06020000 ) ;
2009-01-01 15:06:43 +00:00
2007-04-06 18:34:53 +00:00
vramSetBankC ( VRAM_C_SUB_BG_0x06200000 ) ;
2008-05-15 22:12:51 +00:00
vramSetBankD ( VRAM_D_SUB_SPRITE ) ;
2009-01-01 15:06:43 +00:00
2006-11-25 20:35:34 +00:00
vramSetBankH ( VRAM_H_LCD ) ;
2009-01-01 15:06:43 +00:00
2020-08-05 20:28:16 +01:00
REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE ( 8 ) ;
2006-07-09 11:47:17 +00:00
2020-08-05 20:28:16 +01:00
REG_BG3PA = 256 ;
REG_BG3PB = 0 ;
REG_BG3PC = 0 ;
REG_BG3PD = ( int ) ( ( 200.0f / 192.0f ) * 256 ) ;
2008-05-15 22:12:51 +00:00
2009-01-21 04:27:32 +00:00
} else {
2018-04-19 12:08:31 +02:00
videoSetMode ( MODE_5_2D | ( consoleEnable ? DISPLAY_BG0_ACTIVE : 0 ) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ;
2006-11-25 20:35:34 +00:00
videoSetModeSub ( MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ; //sub bg 0 will be used to print text
2009-01-01 15:06:43 +00:00
2007-04-06 18:34:53 +00:00
vramSetBankA ( VRAM_A_MAIN_BG_0x06000000 ) ;
vramSetBankB ( VRAM_B_MAIN_BG_0x06020000 ) ;
2009-01-01 15:06:43 +00:00
2007-04-06 18:34:53 +00:00
vramSetBankC ( VRAM_C_SUB_BG_0x06200000 ) ;
2008-05-15 22:12:51 +00:00
vramSetBankD ( VRAM_D_SUB_SPRITE ) ;
2009-01-01 15:06:43 +00:00
2006-11-25 20:35:34 +00:00
vramSetBankH ( VRAM_H_LCD ) ;
2009-01-01 15:06:43 +00:00
2020-08-05 20:28:16 +01:00
REG_BG3CNT = BG_BMP8_512x256 | BG_BMP_BASE ( 8 ) ;
2009-01-01 15:06:43 +00:00
2020-08-05 20:28:16 +01:00
REG_BG3PA = ( int ) ( ( ( float ) ( gameWidth ) / 256.0f ) * 256 ) ;
REG_BG3PB = 0 ;
REG_BG3PC = 0 ;
REG_BG3PD = ( int ) ( ( 200.0f / 192.0f ) * 256 ) ;
2009-01-01 15:06:43 +00:00
}
2020-08-05 20:28:16 +01:00
REG_BG3CNT_SUB = BG_BMP8_512x256 ;
2009-01-01 15:06:43 +00:00
2020-08-05 20:28:16 +01:00
REG_BG3PA_SUB = ( int ) ( subScreenWidth / 256.0f * 256 ) ;
REG_BG3PB_SUB = 0 ;
REG_BG3PC_SUB = 0 ;
REG_BG3PD_SUB = ( int ) ( subScreenHeight / 192.0f * 256 ) ;
2009-03-19 09:51:40 +00:00
2010-05-29 20:30:54 +00:00
consoleInit ( NULL , 0 , BgType_Text4bpp , BgSize_T_256x256 , 2 , 0 , true , true ) ;
2009-09-27 22:42:21 +00:00
// Set this again because consoleinit resets it
2018-04-19 12:08:31 +02:00
videoSetMode ( MODE_5_2D | ( consoleEnable ? DISPLAY_BG0_ACTIVE : 0 ) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ;
2009-09-27 22:42:21 +00:00
// Move the cursor to the bottom of the screen using ANSI escape code
2020-07-23 18:29:59 +01:00
printf ( " \033 [23;0f " ) ;
2006-07-09 11:47:17 +00:00
2009-03-19 09:51:40 +00:00
for ( int r = 0 ; r < 32 * 32 ; r + + ) {
( ( u16 * ) SCREEN_BASE_BLOCK ( 2 ) ) [ r ] = buffer [ r ] ;
}
// ConsoleInit destroys the hardware palette :-(
2009-09-27 22:42:21 +00:00
if ( OSystem_DS : : instance ( ) ) {
OSystem_DS : : instance ( ) - > restoreHardwarePalette ( ) ;
}
2009-05-24 15:17:42 +00:00
2006-11-25 20:35:34 +00:00
# ifdef HEAVY_LOGGING
2020-07-23 18:29:59 +01:00
printf ( " done \n " ) ;
2006-11-25 20:35:34 +00:00
# endif
2008-05-15 22:12:51 +00:00
if ( gameScreenSwap ) {
2020-08-05 20:28:16 +01:00
lcdMainOnTop ( ) ;
2008-05-15 22:12:51 +00:00
} else {
2020-08-05 20:28:16 +01:00
lcdMainOnBottom ( ) ;
2008-05-15 22:12:51 +00:00
}
2006-07-09 11:47:17 +00:00
}
2009-01-21 04:27:32 +00:00
void setShowCursor ( bool enable ) {
2007-06-30 23:03:03 +00:00
cursorEnable = enable ;
2020-08-06 15:04:24 +01:00
updateMouse ( ) ;
2007-06-30 23:03:03 +00:00
}
2009-01-21 04:27:32 +00:00
void setMouseCursorVisible ( bool enable ) {
2007-06-30 23:03:03 +00:00
mouseCursorVisible = enable ;
2020-08-06 15:04:24 +01:00
updateMouse ( ) ;
2007-06-30 23:03:03 +00:00
}
2010-07-05 16:10:22 +00:00
void setCursorIcon ( const u8 * icon , uint w , uint h , byte keycolor , int hotspotX , int hotspotY ) {
2007-06-30 23:03:03 +00:00
2009-01-21 04:27:32 +00:00
int off ;
2007-06-30 23:03:03 +00:00
mouseHotspotX = hotspotX ;
mouseHotspotY = hotspotY ;
2009-01-21 04:27:32 +00:00
off = 128 * 64 ;
2009-01-01 15:06:43 +00:00
2009-01-21 04:27:32 +00:00
memset ( SPRITE_GFX + off , 0 , 32 * 32 * 2 ) ;
memset ( SPRITE_GFX_SUB + off , 0 , 32 * 32 * 2 ) ;
2008-09-15 22:43:20 +00:00
2009-01-01 15:06:43 +00:00
2009-01-21 04:27:32 +00:00
for ( uint y = 0 ; y < h ; y + + ) {
for ( uint x = 0 ; x < w ; x + + ) {
int color = icon [ y * w + x ] ;
2008-09-15 22:43:20 +00:00
2009-01-21 04:27:32 +00:00
if ( color = = keycolor ) {
SPRITE_GFX [ off + ( y ) * 32 + x ] = 0x0000 ; // black background
SPRITE_GFX_SUB [ off + ( y ) * 32 + x ] = 0x0000 ; // black background
} else {
SPRITE_GFX [ off + ( y ) * 32 + x ] = OSystem_DS : : instance ( ) - > getDSCursorPaletteEntry ( color ) | 0x8000 ;
SPRITE_GFX_SUB [ off + ( y ) * 32 + x ] = OSystem_DS : : instance ( ) - > getDSCursorPaletteEntry ( color ) | 0x8000 ;
2007-06-30 23:03:03 +00:00
}
}
}
2006-07-09 11:47:17 +00:00
}
void displayMode16Bit ( ) {
2006-11-25 20:35:34 +00:00
# ifdef HEAVY_LOGGING
2020-07-23 18:29:59 +01:00
printf ( " displayMode16Bit... " ) ;
2006-11-25 20:35:34 +00:00
# endif
2006-07-09 11:47:17 +00:00
u16 buffer [ 32 * 32 * 2 ] ;
2009-03-19 09:51:40 +00:00
if ( ! displayModeIs8Bit ) {
for ( int r = 0 ; r < 32 * 32 ; r + + ) {
buffer [ r ] = ( ( u16 * ) SCREEN_BASE_BLOCK_SUB ( 4 ) ) [ r ] ;
}
} else {
2006-07-09 11:47:17 +00:00
saveGameBackBuffer ( ) ;
for ( int r = 0 ; r < 32 * 32 ; r + + ) {
2007-12-21 18:36:40 +00:00
buffer [ r ] = ( ( u16 * ) SCREEN_BASE_BLOCK ( 2 ) ) [ r ] ;
2006-07-09 11:47:17 +00:00
}
}
2009-01-01 15:06:43 +00:00
videoSetMode ( MODE_5_2D | /*DISPLAY_BG0_ACTIVE |*/ DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ;
2020-08-06 15:04:24 +01:00
videoSetModeSub ( MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP ) ; //sub bg 0 will be used to print text
2006-07-09 11:47:17 +00:00
vramSetBankA ( VRAM_A_MAIN_BG ) ;
vramSetBankB ( VRAM_B_MAIN_BG ) ;
vramSetBankC ( VRAM_C_MAIN_BG ) ;
vramSetBankD ( VRAM_D_MAIN_BG ) ;
vramSetBankH ( VRAM_H_SUB_BG ) ;
2020-08-05 20:28:16 +01:00
REG_BG3CNT = BG_BMP16_512x256 ;
2006-07-09 11:47:17 +00:00
highBuffer = false ;
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
memset ( BG_GFX , 0 , 512 * 256 * 2 ) ;
2009-01-01 15:06:43 +00:00
2009-03-19 09:51:40 +00:00
savedPalEntry255 = BG_PALETTE_SUB [ 255 ] ;
BG_PALETTE_SUB [ 255 ] = RGB15 ( 31 , 31 , 31 ) ; //by default font will be rendered with color 255
2006-07-09 11:47:17 +00:00
// Do text stuff
2020-08-05 20:28:16 +01:00
REG_BG0CNT_SUB = BG_MAP_BASE ( 4 ) | BG_TILE_BASE ( 0 ) ;
REG_BG0VOFS_SUB = 0 ;
2006-07-09 11:47:17 +00:00
2010-05-29 20:30:54 +00:00
consoleInit ( NULL , 0 , BgType_Text4bpp , BgSize_T_256x256 , 4 , 0 , false , true ) ;
2006-07-09 11:47:17 +00:00
2009-03-19 09:51:40 +00:00
for ( int r = 0 ; r < 32 * 32 ; r + + ) {
( ( u16 * ) SCREEN_BASE_BLOCK_SUB ( 4 ) ) [ r ] = buffer [ r ] ;
2006-07-09 11:47:17 +00:00
}
2009-03-19 09:51:40 +00:00
consoleSetWindow ( NULL , 0 , 0 , 32 , 24 ) ;
2009-01-01 15:06:43 +00:00
2020-08-05 20:28:16 +01:00
lcdMainOnBottom ( ) ;
2006-07-09 11:47:17 +00:00
displayModeIs8Bit = false ;
2008-05-15 22:12:51 +00:00
2009-03-19 09:51:40 +00:00
// ConsoleInit destroys the hardware palette :-(
OSystem_DS : : instance ( ) - > restoreHardwarePalette ( ) ;
2020-08-05 20:28:16 +01:00
REG_BG3PA = isCpuScalerEnabled ( ) ? 256 : ( int ) ( 1.25f * 256 ) ;
REG_BG3PB = 0 ;
REG_BG3PC = 0 ;
REG_BG3PD = ( int ) ( ( 200.0f / 192.0f ) * 256 ) ;
2008-05-15 22:12:51 +00:00
2006-11-25 20:35:34 +00:00
# ifdef HEAVY_LOGGING
2020-07-23 18:29:59 +01:00
printf ( " done \n " ) ;
2006-11-25 20:35:34 +00:00
# endif
2009-03-19 09:51:40 +00:00
BG_PALETTE_SUB [ 255 ] = RGB15 ( 31 , 31 , 31 ) ; //by default font will be rendered with color 255
2006-07-09 11:47:17 +00:00
}
void displayMode16BitFlipBuffer ( ) {
2006-11-25 20:35:34 +00:00
# ifdef HEAVY_LOGGING
2020-07-23 18:29:59 +01:00
printf ( " Flip %s... " , displayModeIs8Bit ? " 8bpp " : " 16bpp " ) ;
2006-11-25 20:35:34 +00:00
# endif
2006-07-09 11:47:17 +00:00
if ( ! displayModeIs8Bit ) {
2010-07-05 16:10:22 +00:00
u16 * back = get16BitBackBuffer ( ) ;
2009-01-01 15:06:43 +00:00
2009-01-21 04:27:32 +00:00
if ( isCpuScalerEnabled ( ) ) {
2008-05-15 22:12:51 +00:00
Rescale_320x256x1555_To_256x256x1555 ( BG_GFX , back , 512 , 512 ) ;
2009-01-21 04:27:32 +00:00
} else {
2006-10-05 22:44:11 +00:00
for ( int r = 0 ; r < 512 * 256 ; r + + ) {
* ( BG_GFX + r ) = * ( back + r ) ;
}
2006-07-09 11:47:17 +00:00
}
2009-01-21 04:27:32 +00:00
} else if ( isCpuScalerEnabled ( ) ) {
2010-07-05 16:10:22 +00:00
const u8 * back = ( const u8 * ) get8BitBackBuffer ( ) ;
u16 * base = BG_GFX + 0x10000 ;
2009-01-01 15:06:43 +00:00
Rescale_320x256xPAL8_To_256x256x1555 (
2008-05-15 22:12:51 +00:00
base ,
back ,
256 ,
get8BitBackBufferStride ( ) ,
2009-01-01 15:06:43 +00:00
BG_PALETTE ,
2008-05-15 22:12:51 +00:00
getGameHeight ( ) ) ;
2006-11-25 20:35:34 +00:00
}
# ifdef HEAVY_LOGGING
2020-07-23 18:29:59 +01:00
printf ( " done \n " ) ;
2006-11-25 20:35:34 +00:00
# endif
2006-07-09 11:47:17 +00:00
}
2019-11-15 01:38:21 -08:00
void setShakePos ( int shakeXOffset , int shakeYOffset ) {
s_shakeXOffset = shakeXOffset ;
s_shakeYOffset = shakeYOffset ;
2006-07-09 11:47:17 +00:00
}
2010-07-05 10:07:54 +00:00
u16 * get16BitBackBuffer ( ) {
2006-07-09 11:47:17 +00:00
return BG_GFX + 0x20000 ;
}
2008-05-15 22:12:51 +00:00
s32 get8BitBackBufferStride ( ) {
2010-07-05 20:36:11 +00:00
// When the CPU scaler is enabled, the back buffer is in system RAM and is
// 320 pixels wide. When the CPU scaler is disabled, the back buffer is in
// video memory and therefore must have a 512 pixel stride.
2008-05-15 22:12:51 +00:00
if ( isCpuScalerEnabled ( ) ) {
return 320 ;
} else {
return 512 ;
}
}
2010-07-05 16:10:22 +00:00
u16 * getScalerBuffer ( ) {
2008-05-15 22:12:51 +00:00
return ( u16 * ) scalerBackBuffer ;
}
2010-07-05 16:10:22 +00:00
u16 * get8BitBackBuffer ( ) {
2007-02-13 21:04:31 +00:00
if ( isCpuScalerEnabled ( ) )
2008-05-15 22:12:51 +00:00
return ( u16 * ) scalerBackBuffer ;
2006-11-25 20:35:34 +00:00
else
return BG_GFX + 0x10000 ; // 16bit qty!
2006-07-09 11:47:17 +00:00
}
void doTimerCallback ( ) {
if ( callback ) {
if ( callbackTimer < = 0 ) {
callbackTimer + = callbackInterval ;
callback ( callbackInterval ) ;
2009-01-01 15:06:43 +00:00
}
2006-07-09 11:47:17 +00:00
}
}
2020-08-06 15:04:24 +01:00
bool getIsDisplayMode8Bit ( ) {
return displayModeIs8Bit ;
2006-07-09 11:47:17 +00:00
}
2020-08-06 15:04:24 +01:00
void setIcon ( int num , int x , int y , int imageNum , int flags , bool enable ) {
sprites [ num ] . attribute [ 0 ] = ATTR0_BMP | ( enable ? ( y & 0xFF ) : 192 ) | ( ! enable ? ATTR0_DISABLED : 0 ) ;
sprites [ num ] . attribute [ 1 ] = ATTR1_SIZE_32 | ( x & 0x1FF ) | flags ;
sprites [ num ] . attribute [ 2 ] = ATTR2_ALPHA ( 1 ) | ( imageNum * 16 ) ;
}
2006-07-09 11:47:17 +00:00
2020-08-06 15:04:24 +01:00
void setIconMain ( int num , int x , int y , int imageNum , int flags , bool enable ) {
spritesMain [ num ] . attribute [ 0 ] = ATTR0_BMP | ( y & 0xFF ) | ( ! enable ? ATTR0_DISABLED : 0 ) ;
spritesMain [ num ] . attribute [ 1 ] = ATTR1_SIZE_32 | ( x & 0x1FF ) | flags ;
spritesMain [ num ] . attribute [ 2 ] = ATTR2_ALPHA ( 1 ) | ( imageNum * 16 ) ;
}
2009-01-01 15:06:43 +00:00
2020-08-06 15:04:24 +01:00
void updateMouse ( ) {
if ( ( cursorEnable ) & & ( mouseCursorVisible ) ) {
if ( gameScreenSwap & & touchPadStyle ) {
setIcon ( 3 , storedMouseX - mouseHotspotX , storedMouseY - mouseHotspotY , 8 , 0 , true ) ;
setIconMain ( 3 , 0 , 0 , 0 , 0 , false ) ;
} else {
setIconMain ( 3 , storedMouseX - mouseHotspotX , storedMouseY - mouseHotspotY , 8 , 0 , true ) ;
setIcon ( 3 , 0 , 0 , 0 , 0 , false ) ;
2009-01-01 15:06:43 +00:00
}
2006-07-09 11:47:17 +00:00
} else {
2020-08-06 15:04:24 +01:00
setIconMain ( 3 , 0 , 0 , 0 , 0 , false ) ;
setIcon ( 3 , 0 , 0 , 0 , 0 , false ) ;
2006-07-09 11:47:17 +00:00
}
2009-01-01 15:06:43 +00:00
}
2006-07-09 11:47:17 +00:00
2020-08-06 15:04:24 +01:00
void warpMouse ( int penX , int penY ) {
storedMouseX = ( ( penX - touchX ) < < 8 ) / touchScX ;
storedMouseY = ( ( penY - touchY ) < < 8 ) / touchScY ;
updateMouse ( ) ;
}
2006-07-09 11:47:17 +00:00
2020-08-06 15:04:24 +01:00
void setMainScreenScroll ( int x , int y ) {
REG_BG3X = x + ( ( ( frameCount & 1 ) = = 0 ) ? 64 : 0 ) ;
REG_BG3Y = y ;
2009-01-01 15:06:43 +00:00
2020-08-06 15:04:24 +01:00
if ( ( ! gameScreenSwap ) | | ( touchPadStyle ) ) {
touchX = x > > 8 ;
touchY = y > > 8 ;
}
}
2006-07-09 11:47:17 +00:00
2020-08-06 15:04:24 +01:00
void setMainScreenScale ( int x , int y ) {
if ( isCpuScalerEnabled ( ) & & ( x = = 320 ) ) {
REG_BG3PA = 256 ;
REG_BG3PB = 0 ;
REG_BG3PC = 0 ;
REG_BG3PD = y ;
2006-07-09 11:47:17 +00:00
} else {
2020-08-06 15:04:24 +01:00
REG_BG3PA = x ;
REG_BG3PB = 0 ;
REG_BG3PC = 0 ;
REG_BG3PD = y ;
2006-07-09 11:47:17 +00:00
}
2008-05-15 22:12:51 +00:00
2020-08-06 15:04:24 +01:00
if ( ( ! gameScreenSwap ) | | ( touchPadStyle ) ) {
touchScX = x ;
touchScY = y ;
2006-07-09 11:47:17 +00:00
}
2020-08-06 15:04:24 +01:00
}
2009-01-01 15:06:43 +00:00
2020-08-06 15:04:24 +01:00
void setZoomedScreenScroll ( int x , int y , bool shake ) {
if ( ( gameScreenSwap ) & & ( ! touchPadStyle ) ) {
touchX = x > > 8 ;
touchY = y > > 8 ;
2006-07-09 11:47:17 +00:00
}
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
2020-08-06 15:04:24 +01:00
REG_BG3X_SUB = x + ( ( shake & & ( frameCount & 1 ) = = 0 ) ? 64 : 0 ) ;
REG_BG3Y_SUB = y ;
2006-07-09 11:47:17 +00:00
}
2020-08-06 15:04:24 +01:00
void setZoomedScreenScale ( int x , int y ) {
if ( ( gameScreenSwap ) & & ( ! touchPadStyle ) ) {
touchScX = x ;
touchScY = y ;
}
REG_BG3PA_SUB = x ;
REG_BG3PB_SUB = 0 ;
REG_BG3PC_SUB = 0 ;
REG_BG3PD_SUB = y ;
2006-07-09 11:47:17 +00:00
}
2020-08-06 15:04:24 +01:00
Common : : Point transformPoint ( uint16 x , uint16 y ) {
x = ( ( x * touchScX ) > > 8 ) + touchX ;
x = CLIP < uint16 > ( x , 0 , gameWidth - 1 ) ;
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
y = ( ( y * touchScY ) > > 8 ) + touchY ;
y = CLIP < uint16 > ( y , 0 , gameHeight - 1 ) ;
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
return Common : : Point ( x , y ) ;
}
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
void VBlankHandler ( void ) {
frameCount + + ;
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
if ( callback ) {
callbackTimer - = FRAME_TIME ;
2008-09-15 22:43:20 +00:00
}
2020-08-06 15:04:24 +01:00
int xCenter = subScTargetX + ( ( subScreenWidth > > 1 ) < < 8 ) ;
int yCenter = subScTargetY + ( ( subScreenHeight > > 1 ) < < 8 ) ;
2010-04-16 20:49:16 +00:00
2020-08-06 15:04:24 +01:00
if ( twoHundredPercentFixedScale ) {
subScreenWidth = 256 > > 1 ;
subScreenHeight = 192 > > 1 ;
} else {
subScreenWidth = ( 256 * subScreenScale ) > > 8 ;
subScreenHeight = ( 192 * subScreenScale ) > > 8 ;
2010-04-16 20:49:16 +00:00
2020-08-06 15:04:24 +01:00
if ( ( ( subScreenWidth ) > 256 - 8 ) & & ( ( subScreenWidth ) < 256 + 8 ) ) {
subScreenWidth = 256 ;
subScreenHeight = 192 ;
} else if ( ( ( subScreenWidth ) > 128 - 8 ) & & ( ( subScreenWidth ) < 128 + 8 ) ) {
subScreenWidth = 128 ;
subScreenHeight = 96 ;
} else if ( subScreenWidth > 256 ) {
subScreenWidth = 320 ;
subScreenHeight = 200 ;
2010-02-26 17:29:18 +00:00
}
2008-09-15 22:43:20 +00:00
}
2010-04-16 20:49:16 +00:00
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
subScTargetX = xCenter - ( ( subScreenWidth > > 1 ) < < 8 ) ;
subScTargetY = yCenter - ( ( subScreenHeight > > 1 ) < < 8 ) ;
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
subScTargetX = CLIP ( subScTargetX , 0 , ( gameWidth - subScreenWidth ) < < 8 ) ;
subScTargetY = CLIP ( subScTargetY , 0 , ( gameHeight - subScreenHeight ) < < 8 ) ;
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
subScX + = ( subScTargetX - subScX ) > > 2 ;
subScY + = ( subScTargetY - subScY ) > > 2 ;
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
if ( displayModeIs8Bit ) {
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
if ( ! scaledMode ) {
2008-09-15 22:43:20 +00:00
2020-08-06 15:04:24 +01:00
if ( scX + 256 > gameWidth - 1 ) {
scX = gameWidth - 1 - 256 ;
2008-09-15 22:43:20 +00:00
}
2020-08-06 15:04:24 +01:00
if ( scX < 0 ) {
scX = 0 ;
2008-09-15 22:43:20 +00:00
}
2020-08-06 15:04:24 +01:00
if ( scY + 192 > gameHeight - 1 ) {
scY = gameHeight - 1 - 192 ;
2008-09-15 22:43:20 +00:00
}
2020-08-06 15:04:24 +01:00
if ( scY < 0 ) {
scY = 0 ;
2008-09-15 22:43:20 +00:00
}
2009-01-01 15:06:43 +00:00
2020-08-06 15:04:24 +01:00
setZoomedScreenScroll ( subScX , subScY , ( subScreenWidth ! = 256 ) & & ( subScreenWidth ! = 128 ) ) ;
setZoomedScreenScale ( subScreenWidth , ( ( subScreenHeight * ( 256 < < 8 ) ) / 192 ) > > 8 ) ;
2009-01-01 15:06:43 +00:00
2019-11-16 03:12:55 -08:00
setMainScreenScroll ( ( scX < < 8 ) + ( s_shakeXOffset < < 8 ) , ( scY < < 8 ) + ( s_shakeYOffset < < 8 ) ) ;
2006-07-09 11:47:17 +00:00
setMainScreenScale ( 256 , 256 ) ; // 1:1 scale
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
} else {
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
if ( scY > gameHeight - 192 - 1 ) {
scY = gameHeight - 192 - 1 ;
}
if ( scY < 0 ) {
scY = 0 ;
}
2009-01-01 15:06:43 +00:00
2007-04-06 18:34:53 +00:00
setZoomedScreenScroll ( subScX , subScY , ( subScreenWidth ! = 256 ) & & ( subScreenWidth ! = 128 ) ) ;
setZoomedScreenScale ( subScreenWidth , ( ( subScreenHeight * ( 256 < < 8 ) ) / 192 ) > > 8 ) ;
2009-01-01 15:06:43 +00:00
2019-11-16 03:12:55 -08:00
setMainScreenScroll ( 64 + ( s_shakeXOffset < < 8 ) , ( scY < < 8 ) + ( s_shakeYOffset < < 8 ) ) ;
2006-07-09 11:47:17 +00:00
setMainScreenScale ( 320 , 256 ) ; // 1:1 scale
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
}
} else {
2007-04-06 18:34:53 +00:00
setZoomedScreenScroll ( 0 , 0 , true ) ;
2006-07-09 11:47:17 +00:00
setZoomedScreenScale ( 320 , 256 ) ;
setMainScreenScroll ( 0 , 0 ) ;
setMainScreenScale ( 320 , 256 ) ; // 1:1 scale
}
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
updateOAM ( ) ;
}
2013-05-17 00:18:09 +03:00
int getMillis ( bool skipRecord ) {
2006-07-09 11:47:17 +00:00
return currentTimeMillis ;
}
2006-10-25 19:18:38 +00:00
void setTimerCallback ( OSystem_DS : : TimerProc proc , int interval ) {
2006-07-09 11:47:17 +00:00
callback = proc ;
callbackInterval = interval ;
callbackTimer = interval ;
}
void timerTickHandler ( ) {
if ( ( callback ) & & ( callbackTimer > 0 ) ) {
callbackTimer - - ;
}
currentTimeMillis + + ;
}
2009-03-19 09:51:40 +00:00
2006-07-09 11:47:17 +00:00
void setTalkPos ( int x , int y ) {
2020-07-23 13:35:11 +01:00
setTopScreenTarget ( x , y ) ;
2006-07-09 11:47:17 +00:00
}
void setTopScreenTarget ( int x , int y ) {
subScTargetX = ( x - ( subScreenWidth > > 1 ) ) ;
subScTargetY = ( y - ( subScreenHeight > > 1 ) ) ;
if ( subScTargetX < 0 ) subScTargetX = 0 ;
if ( subScTargetX > gameWidth - subScreenWidth ) subScTargetX = gameWidth - subScreenWidth ;
if ( subScTargetY < 0 ) subScTargetY = 0 ;
if ( subScTargetY > gameHeight - subScreenHeight ) subScTargetY = gameHeight - subScreenHeight ;
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
subScTargetX < < = 8 ;
subScTargetY < < = 8 ;
}
void initHardware ( ) {
2009-03-19 09:51:40 +00:00
powerOn ( POWER_ALL ) ;
2009-01-01 15:06:43 +00:00
vramSetBankD ( VRAM_D_SUB_SPRITE ) ;
vramSetBankE ( VRAM_E_MAIN_SPRITE ) ;
2006-11-03 23:16:29 +00:00
for ( int r = 0 ; r < 255 ; r + + ) {
2009-03-19 09:51:40 +00:00
BG_PALETTE [ r ] = 0 ;
2006-11-03 23:16:29 +00:00
}
2006-07-09 11:47:17 +00:00
2009-03-19 09:51:40 +00:00
BG_PALETTE [ 255 ] = RGB15 ( 0 , 31 , 0 ) ;
2006-07-09 11:47:17 +00:00
2006-11-03 23:16:29 +00:00
for ( int r = 0 ; r < 255 ; r + + ) {
2009-03-19 09:51:40 +00:00
BG_PALETTE_SUB [ r ] = 0 ;
2006-11-03 23:16:29 +00:00
}
2009-03-19 09:51:40 +00:00
BG_PALETTE_SUB [ 255 ] = RGB15 ( 0 , 31 , 0 ) ;
2006-11-03 23:16:29 +00:00
2006-07-09 11:47:17 +00:00
// Allocate save buffer for game screen
displayMode16Bit ( ) ;
2009-01-01 15:06:43 +00:00
memset ( BG_GFX , 0 , 512 * 256 * 2 ) ;
2006-07-09 11:47:17 +00:00
scaledMode = true ;
scX = 0 ;
scY = 0 ;
subScX = 0 ;
subScY = 0 ;
subScTargetX = 0 ;
subScTargetY = 0 ;
2009-01-01 15:06:43 +00:00
2020-08-05 20:28:16 +01:00
lcdMainOnBottom ( ) ;
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
frameCount = 0 ;
callback = NULL ;
2009-01-01 15:06:43 +00:00
2009-03-19 09:51:40 +00:00
BG_PALETTE [ 255 ] = RGB15 ( 31 , 31 , 31 ) ; //by default font will be rendered with color 255
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
//irqs are nice
irqSet ( IRQ_VBLANK , VBlankHandler ) ;
irqEnable ( IRQ_VBLANK ) ;
2009-01-01 15:06:43 +00:00
2006-07-09 11:47:17 +00:00
// Set up a millisecond timer
2020-08-05 20:28:16 +01:00
currentTimeMillis = 0 ;
timerStart ( 0 , ClockDivider_1 , ( u16 ) TIMER_FREQ ( 1000 ) , timerTickHandler ) ;
2006-07-09 11:47:17 +00:00
REG_IME = 1 ;
2009-03-19 09:51:40 +00:00
BG_PALETTE [ 255 ] = RGB15 ( 0 , 0 , 31 ) ;
2006-07-09 11:47:17 +00:00
initSprites ( ) ;
2009-01-01 15:06:43 +00:00
2008-05-15 22:12:51 +00:00
// If the software scaler's back buffer has not been allocated, do it now
scalerBackBuffer = ( u8 * ) malloc ( 320 * 256 ) ;
2007-06-30 23:03:03 +00:00
// This is a bodge to get around the fact that the cursor is turned on before it's image is set
// during startup in Sam & Max. This bodge moves the cursor offscreen so it is not seen.
sprites [ 1 ] . attribute [ 1 ] = ATTR1_SIZE_64 | 192 ;
2006-07-09 11:47:17 +00:00
}
2007-04-06 18:34:53 +00:00
///////////////////
// Fast Ram
///////////////////
2010-11-18 17:01:30 +00:00
# define FAST_RAM_SIZE (22500)
2010-07-05 16:11:34 +00:00
# define ITCM_DATA __attribute__((section(".itcm")))
2010-07-05 16:10:22 +00:00
u8 * fastRamPointer ;
2007-04-06 18:34:53 +00:00
u8 fastRamData [ FAST_RAM_SIZE ] ITCM_DATA ;
2010-07-05 16:10:22 +00:00
void * fastRamAlloc ( int size ) {
void * result = ( void * ) fastRamPointer ;
2007-04-06 18:34:53 +00:00
fastRamPointer + = size ;
2008-05-15 08:50:47 +00:00
if ( fastRamPointer > fastRamData + FAST_RAM_SIZE ) {
2020-07-23 18:29:59 +01:00
printf ( " FastRam (ITCM) allocation failed! \n " ) ;
2009-03-19 09:51:40 +00:00
return malloc ( size ) ;
2009-01-01 15:06:43 +00:00
}
2008-05-15 08:50:47 +00:00
return result ;
2007-04-06 18:34:53 +00:00
}
void fastRamReset ( ) {
2007-06-30 23:03:03 +00:00
fastRamPointer = & fastRamData [ 0 ] ;
2007-04-06 18:34:53 +00:00
}
2020-07-23 18:53:41 +01:00
} // End of namespace DS
2007-04-06 18:34:53 +00:00
2006-07-09 11:47:17 +00:00
/////////////////
// Main
/////////////////
2020-07-23 18:53:41 +01:00
int main ( int argc , char * * argv ) {
# ifndef DISABLE_TEXT_CONSOLE
consoleDebugInit ( DebugDevice_NOCASH ) ;
nocashMessage ( " startup \n " ) ;
# endif
2006-07-09 11:47:17 +00:00
2020-07-23 18:53:41 +01:00
DS : : initHardware ( ) ;
2008-09-15 22:43:20 +00:00
2020-07-23 18:53:41 +01:00
defaultExceptionHandler ( ) ;
2009-01-01 15:06:43 +00:00
2020-06-01 22:47:20 +01:00
if ( ! nitroFSInit ( NULL ) ) {
2020-07-23 18:29:59 +01:00
printf ( " nitroFSInit failure: terminating \n " ) ;
2020-06-01 22:47:20 +01:00
return ( 1 ) ;
2006-11-03 23:16:29 +00:00
}
2006-07-09 11:47:17 +00:00
g_system = new OSystem_DS ( ) ;
assert ( g_system ) ;
2010-07-03 04:01:39 +00:00
# ifdef DYNAMIC_MODULES
2010-08-06 06:03:34 +00:00
PluginManager : : instance ( ) . addPluginProvider ( new DSPluginProvider ( ) ) ;
2010-07-03 04:01:39 +00:00
# endif
2010-02-26 17:29:18 +00:00
2020-07-23 18:53:41 +01:00
// Invoke the actual ScummVM main entry point:
int res = scummvm_main ( argc , argv ) ;
2010-02-26 17:29:18 +00:00
2020-07-23 18:53:41 +01:00
// Free OSystem
g_system - > destroy ( ) ;
2006-07-09 11:47:17 +00:00
2020-07-23 18:53:41 +01:00
return res ;
2006-07-09 11:47:17 +00:00
}