Compare commits

..

2 Commits

Author SHA1 Message Date
mark wallace
d0ea5f41be - Added static const int DUCK_DELAY_FRAMES = 30 to define the delay (1 second at 30 FPS).
- Added `int duckFrameCounter` to track frames the duck button is held.
  - Added `bool isDucking` to track crouch state and prevent re-triggering.
  - Updated `CPad` constructor to initialize `duckFrameCounter` and `isDucking`.
2025-03-30 18:37:55 +00:00
mark wallace
f7d23f3bb3 Modified CPad::DuckJustDown to use a frame counter for a 1-second delay. 2025-03-30 18:35:13 +00:00
8 changed files with 432 additions and 1112 deletions

View File

@@ -1,14 +1,14 @@
## Intro
dca3 is a port of GTA III/VC for the Dreamcast made by The Gang, using [re3](https://github.com/halpz/re3/tree/master/) as a base.
dca3 is a port of GTA III for the Dreamcast made by The Gang, using [re3](https://github.com/halpz/re3/tree/master/) as a base.
re3 a fully reversed source code for GTA III/VC.
re3 a fully reversed source code for GTA III.
This project was started by [Stefanos Kornilios Mitsis Poiitidis](https://x.com/poiitidis) and uses [KallistiOS](https://kos-docs.dreamcast.wiki/).
## Baking the CDI
### Prerequisites
You need Grand Theft Auto III or Grand Theft Auto: Vice City installed. This version has been tested and works: https://store.rockstargames.com/game/buy-grand-theft-auto-the-trilogy.
You need GTA 3 installed. This version has been tested and works: https://store.rockstargames.com/game/buy-grand-theft-auto-the-trilogy.
Please note that *SOME VERSIONS* of the game may not work. It has been reported that `d4_gta.mp3` is corrupted sometimes.
@@ -18,33 +18,28 @@ You will also need the following tools installed
- git-scm http://git-scm.com/downloads/win
- dreamsdk r3 https://github.com/dreamsdk/dreamsdk/releases
### Cloning the dca3-game repo (this is required once)
### Preparing the gta3 folder
- Open dreamsdk shell
- type `git clone --branch beta https://gitlab.com/skmp/dca3-game.git` (and press enter).
- It should take a moment and successfully clone the repo
- close the dreamsdk shell and proceed to the next step.
### Grand Theft Auto III build (liberty)
#### Preparing the liberty folder
- Open dreamsdk shell
- type `mkdir liberty` (and press enter)
- type `mkdir gta3` (and press enter)
- type `explorer .` (and press enter)
- This will open a folder named liberty. Copy your gta3 files in there.
- This will open a folder named gta3. Copy your gta3 files in there.
- If you use the 2cdrom version of the game, make sure to also copy the contents of the play disc to this folder.
- close the folder and the dreamsdk shell and proceed to the next step.
#### Downloading and extracting the prebuilt elf
### Cloning the dca3-game repo and downloading the prebuilt elf
- Open dreamsdk shell
- type `cd dca3-game/liberty` (and press enter)
- type `git clone --branch alpha https://gitlab.com/skmp/dca3-game.git` (and press enter)
- It should take a moment and successfully clone the repo
- type `cd dca3-game/dreamcast` (and press enter)
- type `explorer .` (and press enter).
- A folder named dreamcast with some files should be open. Keep it on the side.
- Download the *liberty* beta prebuilt elf from https://gitlab.com/skmp/dca3-game/-/releases/beta
- Open artifacts.zip and extract dca-liberty.elf to the folder that was kept open before.
- Download the Alpha Prebuilt Elf from https://gitlab.com/skmp/dca3-game/-/jobs/8725216645
- Open artifacts.zip and extract dca3.elf to the folder that was kept open before.
- Close the folder and dreamsdk shell
#### Repacking and making a prebuilt cdi FOR GD-EMU
### Repacking and making a prebuilt cdi FOR GD-EMU
- Open dreamsdk shell
- type `cd dca3-game/liberty` (and press enter)
- type `cd dca3-game/dreamcast` (and press enter)
- type `make cdi-prebuilt` (and press enter)
- This should take a while (5-15 mins)
- Due to an issue with dreamsdk, this won't fully complete the first time
@@ -52,80 +47,28 @@ You will also need the following tools installed
- It will continue where it left off before
- It should run to completion now and show "*** Repack Completed Successfully ***"
- type `explorer .` (and press enter)
- The dreamcast folder should open up, and it should contain dca-liberty.cdi for you (~ 900 megs)
- The dreamcast folder should open up, and it should contain dca3.cdi for you (~ 900 megs)
#### Repacking and making a prebuilt cdi FOR burning CD-ROM
### Repacking and making a prebuilt cdi FOR burning CD-ROM
- Open dreamsdk shell
- type `cd dca3-game/liberty` (and press enter)
- type `cd dca3-game/dreamcast` (and press enter)
- type `make FOR_DISC=1 cdi-prebuilt` (and press enter)
- This should take a while (5-15 mins)
- Due to an issue with dreamsdk, this won't fully complete the first time
- type `make FOR_DISC=1 cdi-prebuilt` (and press enter)
- It will continue where it left off before
- It should run to completion now and show "*** CDI Baked Successfully ***"
- It should run to completion now and show "*** Repack Completed Successfully ***"
- type `explorer .` (and press enter)
- The dreamcast folder should open up, and it should contain dca-liberty.cdi for you (~ 700 megs or ~260 megs)
- The dreamcast folder should open up, and it should contain dca3.cdi for you (~ 700 megs or ~260 megs)
- If the .cdi is not ~ 700 megs (linux/mkdcdisc) or ~260 megs (windows/cdi4dc), then you did something wrong.
- You can type `rm -rf repack-data` (and press enter)
- And then start this step from the beggining
### Grand Theft Auto Vice City build (miami)
#### Preparing the miami folder
- Open dreamsdk shell
- type `mkdir miami` (and press enter)
- type `explorer .` (and press enter)
- This will open a folder named liberty. Copy your gtavc files in there.
- close the folder and the dreamsdk shell and proceed to the next step.
#### Downloading and extracting the prebuilt elf
- Open dreamsdk shell
- type `cd dca3-game/miami` (and press enter)
- type `explorer .` (and press enter).
- A folder named dreamcast with some files should be open. Keep it on the side.
- Download the *miami* beta prebuilt elf from https://gitlab.com/skmp/dca3-game/-/releases/beta
- Open artifacts.zip and extract dca-miami.elf to the folder that was kept open before.
- Close the folder and dreamsdk shell
#### Repacking and making a prebuilt cdi FOR GD-EMU
- Open dreamsdk shell
- type `cd dca3-game/miami` (and press enter)
- type `FOR_DISC=2 make cdi-prebuilt` (and press enter)
- This should take a while (5-15 mins)
- Due to an issue with dreamsdk, this won't fully complete the first time
- type `FOR_DISC=2 make cdi-prebuilt` (and press enter)
- It will continue where it left off before
- You will have to close the dreamshell window a few times and restart this procesure a few times
- Eventually it should run to completion now and show "*** CDI Baked Successfully ***"
- type `explorer .` (and press enter)
- The dreamcast folder should open up, and it should contain dca-miami.cdi for you (~ 1.5 gigs)
#### Repacking and making a prebuilt cdi FOR burning CD-ROM
- Open dreamsdk shell
- type `cd dca3-game/miami` (and press enter)
- type `make FOR_DISC=1 cdi-prebuilt` (and press enter)
- This should take a while (5-15 mins)
- Due to an issue with dreamsdk, this won't fully complete the first time
- type `make FOR_DISC=1 cdi-prebuilt` (and press enter)
- It will continue where it left off before
- It should run to completion now and show "*** Repack Completed Successfully ***"
- type `explorer .` (and press enter)
- The dreamcast folder should open up, and it should contain dca-miami.cdi for you (~700 or ~550 megs)
## Running on emulators
You must have the 'trails' options turned off from the graphics settings, or a white overlay may appear over the 3d render
## Fine tuning settings
Two experimental modes, 24 bpp (640x480x24) and Anti Aliasing are provided in the Graphics settings.
- When using HDMI or VGA out, it is recommended to turn enable 24 bpp mode. Note that you also have to disable the 'trails' effect.
- Anti Aliasing will work with or without trails, however trails enabled will have a bigger performance hit in that mode.
Enabling any of those modes may result in some missing geometry under heavy scenes (more likely with AA mode).
They can also be combined.
## How to report issues
- Take a photo of your tv/monitor and vmu
- open a ticket via https://gitlab.com/skmp/dca3-game/-/issues/new
- state which elf you have used (eg, https://gitlab.com/skmp/dca3-game/-/jobs/8725216645)
- write something descriptive of what is/went wrong
## License

View File

@@ -160,7 +160,6 @@ clean:
-rm -f IP.BIN
-rm -f $(PROJECT_NAME).iso
-rm -f $(PROJECT_NAME).ds.iso
-rm -f $(PROJECT_NAME)-prebuilt.ds.iso
-rm -f $(PROJECT_NAME).cdi
-rm -f $(DEPS)
-rm -rf $(REPACK_DIR)
@@ -231,12 +230,6 @@ $(PROJECT_NAME).ds.iso: IP.BIN 1ST_READ.BIN $(REPACK_DIR)/repacked $(REPACK_GTA_
$(KOS_BASE)/utils/scramble/scramble $(TARGET)-prebuilt.bin 1ST_READ_PREBUILT.BIN
mkdir -p $(REPACK_GTA_DIR)
$(PROJECT_NAME)-prebuilt.ds.iso: IP.BIN 1ST_READ_PREBUILT.BIN $(REPACK_DIR)/repacked $(REPACK_GTA_DIR)/GTA3SF8.b $(REPACK_GTA_DIR)/0GDTEX.PVR $(REPACK_GTA_DIR)/settings.ico
rm -f $(PROJECT_NAME)-prebuilt.ds.iso
rm -f $(REPACK_GTA_DIR)/1ST_READ.BIN
cp 1ST_READ_PREBUILT.BIN $(REPACK_GTA_DIR)/1ST_READ.BIN
mkisofs -V $(PROJECT_NAME) -G IP.BIN -r -J -l -o $(PROJECT_NAME)-prebuilt.ds.iso $(REPACK_GTA_DIR)
$(PROJECT_NAME)-prebuilt.iso: IP.BIN 1ST_READ_PREBUILT.BIN $(REPACK_DIR)/repacked $(REPACK_GTA_DIR)/GTA3SF8.b $(REPACK_GTA_DIR)/0GDTEX.PVR $(REPACK_GTA_DIR)/settings.ico
rm -f $(REPACK_GTA_DIR)/1ST_READ.BIN
cp 1ST_READ_PREBUILT.BIN $(REPACK_GTA_DIR)/1ST_READ.BIN
@@ -275,8 +268,6 @@ cdi-no-repack: $(PROJECT_NAME)-no-repack.cdi
dsiso: $(PROJECT_NAME).ds.iso
dsiso-prebuilt: $(PROJECT_NAME)-prebuilt.ds.iso
cdi-prebuilt: $(PROJECT_NAME)-prebuilt.cdi
sim: $(REPACK_DIR)/repacked

View File

@@ -164,7 +164,6 @@ clean:
-rm -f IP.BIN
-rm -f $(PROJECT_NAME).iso
-rm -f $(PROJECT_NAME).ds.iso
-rm -f $(PROJECT_NAME)-prebuilt.ds.iso
-rm -f $(PROJECT_NAME).cdi
-rm -f $(DEPS)
-rm -rf $(REPACK_DIR)
@@ -235,12 +234,6 @@ $(PROJECT_NAME).ds.iso: IP.BIN 1ST_READ.BIN $(REPACK_DIR)/repacked $(REPACK_GTA_
$(KOS_BASE)/utils/scramble/scramble $(TARGET)-prebuilt.bin 1ST_READ_PREBUILT.BIN
mkdir -p $(REPACK_GTA_DIR)
$(PROJECT_NAME)-prebuilt.ds.iso: IP.BIN 1ST_READ_PREBUILT.BIN $(REPACK_DIR)/repacked $(REPACK_GTA_DIR)/GTAVCSF8.b $(REPACK_GTA_DIR)/0GDTEX.PVR $(REPACK_GTA_DIR)/settings.ico
rm -f $(PROJECT_NAME)-prebuilt.ds.iso
rm -f $(REPACK_GTA_DIR)/1ST_READ.BIN
cp 1ST_READ_PREBUILT.BIN $(REPACK_GTA_DIR)/1ST_READ.BIN
mkisofs -V $(PROJECT_NAME) -G IP.BIN -r -J -l -o $(PROJECT_NAME)-prebuilt.ds.iso $(REPACK_GTA_DIR)
$(PROJECT_NAME)-prebuilt.iso: IP.BIN 1ST_READ_PREBUILT.BIN $(REPACK_DIR)/repacked $(REPACK_GTA_DIR)/GTAVCSF8.b $(REPACK_GTA_DIR)/0GDTEX.PVR $(REPACK_GTA_DIR)/settings.ico
rm -f $(REPACK_GTA_DIR)/1ST_READ.BIN
cp 1ST_READ_PREBUILT.BIN $(REPACK_GTA_DIR)/1ST_READ.BIN
@@ -279,8 +272,6 @@ cdi-no-repack: $(PROJECT_NAME)-no-repack.cdi
dsiso: $(PROJECT_NAME).ds.iso
dsiso-prebuilt: $(PROJECT_NAME)-prebuilt.ds.iso
cdi-prebuilt: $(PROJECT_NAME)-prebuilt.cdi
sim: $(REPACK_DIR)/repacked

View File

@@ -2121,14 +2121,14 @@ wchar *CControllerConfigManager::GetControllerSettingTextWithOrderNumber(e_Contr
case VEHICLE_ACCELERATE:
for (int i = 0; (ActionText[i] = Dreamcast_RightTrigger[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_CHANGE_RADIO_STATION: // D-Pad Right to switch RADIO on Dreamcast
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Right[i]) != '\0' && i < iLimitCopy; i++);
case VEHICLE_CHANGE_RADIO_STATION:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Left[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_BRAKE:
for (int i = 0; (ActionText[i] = Dreamcast_LeftTrigger[i]) != '\0' && i < iLimitCopy; i++);
break;
case TOGGLE_SUBMISSIONS: // D-Pad Left to enable SUBMISSIONS on Dreamcast
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Left[i]) != '\0' && i < iLimitCopy; i++);
case TOGGLE_SUBMISSIONS:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Right[i]) != '\0' && i < iLimitCopy; i++);
break;
case GO_LEFT:
for (int i = 0; (ActionText[i] = Dreamcast_Stick_Left[i]) != '\0' && i < iLimitCopy; i++);
@@ -2199,11 +2199,11 @@ wchar *CControllerConfigManager::GetControllerSettingTextWithOrderNumber(e_Contr
case VEHICLE_TURRETRIGHT:
for (int i = 0; (ActionText[i] = Dreamcast_A[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_TURRETUP: // Remark: VEHICLE_TURRETUP and VEHICLE_TURRETDOWN are used to shift your weight on a bike in Vice City
for (int i = 0; (ActionText[i] = Dreamcast_Stick_Up[i]) != '\0' && i < iLimitCopy; i++);
case VEHICLE_TURRETUP:
for (int i = 0; (ActionText[i] = Dreamcast_A[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_TURRETDOWN: // Remark: VEHICLE_TURRETUP and VEHICLE_TURRETDOWN are used to shift your weight on a bike in Vice City
for (int i = 0; (ActionText[i] = Dreamcast_Stick_Down[i]) != '\0' && i < iLimitCopy; i++);
case VEHICLE_TURRETDOWN:
for (int i = 0; (ActionText[i] = Dreamcast_A[i]) != '\0' && i < iLimitCopy; i++);
break;
case CAMERA_CHANGE_VIEW_ALL_SITUATIONS:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Up[i]) != '\0' && i < iLimitCopy; i++);
@@ -2259,13 +2259,13 @@ wchar *CControllerConfigManager::GetControllerSettingTextWithOrderNumber(e_Contr
case VEHICLE_ACCELERATE:
for (int i = 0; (ActionText[i] = Dreamcast_RightTrigger[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_CHANGE_RADIO_STATION: // D-Pad Right to switch RADIO on Dreamcast
case VEHICLE_CHANGE_RADIO_STATION:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Right[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_BRAKE:
for (int i = 0; (ActionText[i] = Dreamcast_LeftTrigger[i]) != '\0' && i < iLimitCopy; i++);
break;
case TOGGLE_SUBMISSIONS: // D-Pad Left to enable SUBMISSIONS on Dreamcast
case TOGGLE_SUBMISSIONS:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Left[i]) != '\0' && i < iLimitCopy; i++);
break;
case GO_LEFT:
@@ -2397,14 +2397,14 @@ wchar *CControllerConfigManager::GetControllerSettingTextWithOrderNumber(e_Contr
case VEHICLE_ACCELERATE:
for (int i = 0; (ActionText[i] = Dreamcast_A[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_CHANGE_RADIO_STATION: // D-Pad Right to switch RADIO on Dreamcast
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Right[i]) != '\0' && i < iLimitCopy; i++);
case VEHICLE_CHANGE_RADIO_STATION:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Left[i]) != '\0' && i < iLimitCopy; i++);
break;
case VEHICLE_BRAKE:
for (int i = 0; (ActionText[i] = Dreamcast_X[i]) != '\0' && i < iLimitCopy; i++);
break;
case TOGGLE_SUBMISSIONS: // D-Pad Left to enable SUBMISSIONS on Dreamcast
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Left[i]) != '\0' && i < iLimitCopy; i++);
case TOGGLE_SUBMISSIONS:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Right[i]) != '\0' && i < iLimitCopy; i++);
break;
case GO_LEFT:
for (int i = 0; (ActionText[i] = Dreamcast_Stick_Left[i]) != '\0' && i < iLimitCopy; i++);
@@ -2542,8 +2542,8 @@ wchar *CControllerConfigManager::GetControllerSettingTextWithOrderNumber(e_Contr
case VEHICLE_BRAKE:
for (int i = 0; (ActionText[i] = PS2_Square[i]) != '\0' && i < iLimitCopy; i++);
break;
case TOGGLE_SUBMISSIONS: // D-Pad Left to enable SUBMISSIONS on Dreamcast
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Left[i]) != '\0' && i < iLimitCopy; i++);
case TOGGLE_SUBMISSIONS:
for (int i = 0; (ActionText[i] = Dreamcast_DPad_Right[i]) != '\0' && i < iLimitCopy; i++);
break;
case GO_LEFT:
for (int i = 0; (ActionText[i] = LefAnalog_Left[i]) != '\0' && i < iLimitCopy; i++);

File diff suppressed because it is too large Load Diff

View File

@@ -3881,36 +3881,49 @@ bool CPad::CollectPickupJustDown(void)
return false;
}
bool CPad::DuckJustDown(void)
bool CPad::DuckJustDown(void)
{
if (ArePlayerControlsDisabled())
if (ArePlayerControlsDisabled()) {
duckFrameCounter = 0;
return false;
}
#ifdef RW_DC
switch (CPad::GetPad(0)->Mode)
{
case 0: //Xbox Mode
if (CPad::GetPad(0)->IsDualAnalog)
{
return !!(NewState.X&& !OldState.X);
}
else
{
return !!(NewState.X&& !OldState.X);
}
case 1: //PS2 Mode
if (CPad::GetPad(0)->IsDualAnalog)
{
return !!(NewState.X&& !OldState.X);
}
else
{
return !!(NewState.X&& !OldState.X);
}
bool buttonPressed = false;
switch (CPad::GetPad(0)->Mode) {
case 0: // Xbox Mode
buttonPressed = NewState.X;
break;
case 1: // PS2 Mode
buttonPressed = NewState.X;
break;
}
if (buttonPressed) {
duckFrameCounter++;
if (duckFrameCounter >= DUCK_DELAY_FRAMES && !isDucking) {
isDucking = true;
return true; // Trigger ducking after delay
}
} else {
duckFrameCounter = 0;
isDucking = false;
}
return false;
#else
return !!(NewState.LeftShock && !OldState.LeftShock);
bool buttonPressed = NewState.Square;
if (buttonPressed) {
duckFrameCounter++;
if (duckFrameCounter >= DUCK_DELAY_FRAMES && !isDucking) {
isDucking = true;
return true;
}
} else {
duckFrameCounter = 0;
isDucking = false;
}
return false;
#endif
}

View File

@@ -173,11 +173,26 @@ public:
uint32 CameraJustUpTime;
uint32 CameraLastPressed;
bool CameraIsDoublePressed;
static const int DUCK_DELAY_FRAMES = 30; // 1 second at 30 FPS
int duckFrameCounter; // Frames the duck button has been held
bool isDucking; // Tracks if duck action is active
#ifdef DETECT_PAD_INPUT_SWITCH
static bool IsAffectedByController;
static bool IsAffectedByController;
#endif
CPad() { }
CPad() : duckFrameCounter(0), isDucking(false), // New variables initialized
SteeringLeftRightBuffer{0}, DrunkDrivingBufferUsed(0), Phase(0), Mode(0),
ShakeDur(0), DisablePlayerControls(0), ShakeFreq(0), iCurrHornHistory(0),
JustOutOfFrontend(0), bApplyBrakes(0), LastTimeTouched(0), AverageWeapon(0),
AverageEntries(0), IsKeyboardMouse(false), IsDualAnalog(false),
CameraJustDown(false), CameraJustUp(false), CameraJustUpTime(0),
CameraLastPressed(0), CameraIsDoublePressed(false) {
Clear(false);
memset(bHornHistory, 0, sizeof(bHornHistory));
memset(CheatString, 0, sizeof(CheatString));
}
~CPad() { }
static bool bDisplayNoControllerMessage;

View File

@@ -14,8 +14,8 @@ else
endif
MYFLAGS=-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Ilibavutil -I. -DCONFIG_MEMORY_POISONING=0 -DHAVE_FAST_UNALIGNED=0
MYCPPFLAGS=$(MYFLAGS) -std=gnu++17
MYCFLAGS=$(MYFLAGS) -Wno-pointer-sign -std=gnu17
MYCPPFLAGS=$(MYFLAGS)
MYCFLAGS=$(MYFLAGS) -Wno-pointer-sign
.PHONY: all clean