Skip to content

Commit

Permalink
Fixed crash at startup and added UI to turn off YM2413.
Browse files Browse the repository at this point in the history
  • Loading branch information
FluBBaOfWard committed Oct 12, 2021
1 parent 3018ca0 commit 4e8b800
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Docs/smstech.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
Writes to odd addresses go to the VDP control port.
Reads from even addresses return the VDP data port contents.
Reads from odd address return the VDP status flags.
$C0-$FF : Writes have no effect.
$C0-$FF : Writes have no effect, except 0xF2 which goes to the YM2413.
Reads from even addresses return the I/O port A/B register.
Reads from odd address return the I/O port B/misc. register.

Expand Down
4 changes: 4 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ S8DS revision history
-=-=-=-=-=-=-=-=-=-=-=-


V1.1.3 - 2021-10-12 (FluBBa)
Fixed crash at startup.
Added ui to enable/disable YM2413.

V1.1.2 - 2021-10-11 (FluBBa)
Fixed TV noise.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# S8DS V1.1.2
# S8DS V1.1.3

This is a SEGA 8Bit emulator for the NDS, it support the following systems:

Expand Down Expand Up @@ -96,6 +96,7 @@ better 3D effect, I have only tested with red/cyan glasses.
Select GameGear Bios: Browse for GameGear bios.
Select Coleco Bios: Browse for Coleco bios.
Select MSX Bios: Browse for MSX bios.
YM2413: Enable YM2413 emulation for SMS1 & Mark 3.

Settings:
Speed: Switch between speed modes, can also be toggled with L+START.
Expand Down
5 changes: 3 additions & 2 deletions source/Cart.s
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ loadCart: ;@ Called from C: r0=emuFlags

ldr z80optbl,=Z80OpTable

ldr r3,=rawBios
// ldr r3,=rawBios
// str r3,g_BIOSBASE_US
// str r3,g_BIOSBASE_JP
// str r3,g_BIOSBASE_COLECO
Expand Down Expand Up @@ -318,8 +318,9 @@ tbLoop1:
ldreq r1,g_BIOSBASE_GG ;@ GG
bicne r2,r2,#0x40 ;@ X as Start/Pause only on HW_GG
bicne r0,r0,#GG_MODE
cmpne r9,#HW_SMS2
cmpne r9,#HW_MEGADRIVE
biceq r2,r2,#0x20 ;@ Reset unavailable on HW_GG & HW_MD (& HW_SMS2)
biceq r2,r2,#0x20 ;@ Reset unavailable on HW_GG, HW_SMS2 & HW_MEGADRIVE
str r0,g_emuFlags
strb r2,g_config
cmp r1,#0
Expand Down
3 changes: 2 additions & 1 deletion source/Gfx.s
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ ppi:
adds r1,r1,#1
bne ppi

bl gfxReset
bl setupScaling
bl VDP0ApplyScaling
ldmfd sp!,{lr}
bx lr
;@----------------------------------------------------------------------------
Expand Down
14 changes: 10 additions & 4 deletions source/Gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "AY38910/Version.h"
#include "SCC/Version.h"

#define EMUVERSION "V1.1.2 2021-10-11"
#define EMUVERSION "V1.1.3 2021-10-12"

extern u8 sordM5Input; // SordM5.s

Expand Down Expand Up @@ -82,6 +82,7 @@ static void glassesSet(void);
static void countrySet(void);
static void machineSet(void);
static void biosSet(void);
static void ym2413Set(void);

static void dip0Set0_1(void);
static void dip0Set1_1(void);
Expand Down Expand Up @@ -149,7 +150,7 @@ static const fptr fnList2[] = {ui4, ui5, ui6, ui7, ui9};
static const fptr fnList3[] = {uiDummy};
static const fptr fnList4[] = {autoBSet, autoASet, controllerSet, swapABSet, joypadSet, selectSet, rffSet};
static const fptr fnList5[] = {scalingSet, flickSet, brightSet, colorSet, borderSet, spriteSet, glassesSet, bgrLayerSet, sprLayerSet};
static const fptr fnList6[] = {countrySet, machineSet, ui8};
static const fptr fnList6[] = {countrySet, machineSet, ui8, ym2413Set};
static const fptr fnList7[] = {speedSet, autoStateSet, autoSettingsSet, autoNVRAMSet, autoPauseGameSet, powerSaveSet, screenSwapSet, debugTextSet, sleepSet};
static const fptr fnList8[] = {biosSet, selectUSBios, selectJPBios, selectGGBios, selectCOLECOBios, selectMSXBios, selectSORDM5Bios};
static const fptr fnList9[] = {uiDummy};
Expand Down Expand Up @@ -401,6 +402,7 @@ static void uiMachine() {
drawSubItem("Region: ",cntrTxt[g_region]);
drawSubItem("Machine: ",machTxt[g_machineSet]);
drawMenuItem(" Bios Settings ->");
drawSubItem("YM2413: ",biosTxt[ym2413Enabled&1]);
}

static void uiSettings() {
Expand Down Expand Up @@ -1505,6 +1507,10 @@ void glassesSet() {
}


void biosSet() {
g_configSet ^= 0x80;
}

void countrySet() {
int i;
g_region = (g_region+1)&3;
Expand All @@ -1530,8 +1536,8 @@ void machineSet() {
}
}

void biosSet() {
g_configSet ^= 0x80;
void ym2413Set() {
ym2413Enabled ^= 0x01;
}


Expand Down
6 changes: 3 additions & 3 deletions source/Memory.s
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ ram1S_W: ;@ Write ram ($E000-$FFFF), mirror. Bankswitch
bhi BankSwitch2_W ;@ $FFFF
beq BankSwitch1_W ;@ $FFFE
bmi BankSwitch0_W ;@ $FFFD
; mov r11,r11
; bx lr
mov r11,r11
bx lr
;@----------------------------------------------------------------------------
LCDGlasses:
;@----------------------------------------------------------------------------
ldr r1,=g_machine
ldrb r1,[r1]
cmp r1,#HW_MARK3
cmpne r1,#HW_SMS1
cmpne r1,#HW_SMS2
cmpne r1,#HW_MEGADRIVE
bxne lr
ldr r1,=g_3DEnable
ldrb r1,[r1]
Expand Down
1 change: 1 addition & 0 deletions source/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern u8 colecoKey;
extern u8 sc3Keyboard;
extern u8 keyboardRows[8];
extern u8 inputHW;
extern u8 ym2413Enabled;
extern int coinCounter0;
extern int coinCounter1;
extern u8 dipSwitch0;
Expand Down
25 changes: 16 additions & 9 deletions source/io.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.global Z80Out
.global joyCfg
.global inputHW
.global ym2413Enabled
.global joy0State
.global joy1State
.global acExtra
Expand Down Expand Up @@ -58,7 +59,7 @@ IO_Params_SG1000_R:
.long 0x00410063, PPI1PortBR ;@ 0x41-0x5D, 0xC1-0xDD
.long 0x00420063, PPI1PortCR ;@ 0x42-0x5E, 0xC2-0xDE
.long 0x00430063, PPI1PortDR ;@ 0x43-0x5F, 0xC3-0xDF
.long 0x00000000, empty_R_SMS1 ;@ 0x00-0x9F, 0xE0-0xFF
.long 0x00000000, empty_R_SMS1 ;@ 0x00-0x1F, 0x60-0x9F, 0xE0-0xFF
IO_Params_SG1000_W:
.long 0x006000E0, SN76496_W ;@ 0x60-0x7F
.long 0x00A000E1, VDP0DataTMSW ;@ 0xA0-0xBE
Expand All @@ -81,7 +82,7 @@ IO_Params_OMV_R:
.long 0x00E100E7, OMVPort2_R ;@ 0xE1-0xF9
.long 0x00E200E7, OMVPort3_R ;@ 0xE2-0xFA
.long 0x00E300E7, OMVPort4_R ;@ 0xE3-0xFB
.long 0x00000000, empty_R_SMS1 ;@ 0x00-0x9F, 0xE0-0xFF
.long 0x00000000, empty_R_SMS1 ;@ 0x00-0x1F, 0x40-0x9F, 0xFC-0xFF
IO_Params_OMV_W:
.long 0x006000E0, SN76496_W ;@ 0x60-0x7F
.long 0x00A000E1, VDP0DataTMSW ;@ 0xA0-0xBE
Expand All @@ -96,17 +97,17 @@ IO_Params_Mark3_R:
.long 0x004100C1, VDP0HCounterR ;@ 0x41-0x7F
.long 0x008000C1, VDP0DataR ;@ 0x80-0xBE
.long 0x008100C1, VDP0StatR ;@ 0x81-0xBF
.long 0x00F000FC, ExternalIO_R ;@ 0xF0-0xF2
.long 0x00C000C1, ExtIO_0_SMS_R ;@ 0xC0-0xFE
.long 0x00C100C1, ExtIO_1_SMS_R ;@ 0xC1-0xFF
.long 0x00000000, empty_R_SMS1 ;@ 0x00-0x3F
IO_Params_Mark3_W:
// .long 0x000000C1, MemCtrl_SMS_W ;@ 0x00-0x3E
.long 0x004000C0, SN76496_W ;@ 0x40-0x7F
.long 0x008000C1, VDP0DataSMSW ;@ 0x80-0xBE
.long 0x008100C1, VDP0CtrlW ;@ 0x81-0xBF
.long 0x00FD00FF, SDSC_Debug_W ;@ 0xFD
.long 0x00C000C0, ExternalIO_W ;@ 0xC0-0xFF
.long 0x00000000, empty_W ;@ 0x01-0x3F
.long 0x00000000, empty_W ;@ 0x00-0x3F

;@----------------------------------------------------------------------------
;@ SMS1
Expand Down Expand Up @@ -608,7 +609,8 @@ joy1Extra: .byte 0
joyMode: .byte 0
colecoKey: .byte 0
inputHW: .byte 0
.byte 0
ym2413Enabled: .byte 1

sc3Keyboard:
keyboardRows:
keyboardRow0: .byte 0xFF
Expand Down Expand Up @@ -917,13 +919,12 @@ StereoCtrl_GG_W: ;@ GG stereo control, 0x06
;@------------------------------------------------------------------------------
IOCtrl_GG_W: ;@ GG com port stuff, 0x00-0x07
;@------------------------------------------------------------------------------
adr r1,GGIO
strb r0,[r1,addy]
strb r0,[pc,addy]
bx lr
GGIO_Default:
.byte 0xC0,0x7F,0xFF,0x00,0xFF,0x00,0xFF,0xFF
GGIO:
.byte 0xC0,0x7F,0xFF,0x00,0xFF,0x00,0xFF,0xFF
GGIO_Default:
.byte 0xC0,0x7F,0xFF,0x00,0xFF,0x00,0xFF,0xFF
;@------------------------------------------------------------------------------
IOCtrl_SMS_W:
;@------------------------------------------------------------------------------
Expand Down Expand Up @@ -963,6 +964,9 @@ IOCtrl_SMS_W:
;@----------------------------------------------------------------------------
ExternalIO_R:
;@----------------------------------------------------------------------------
ldrb r1,ym2413Enabled
cmp r1,#0
ldreq pc,emptyReadPtr
cmp addy,#0xF1 ;@ FM Unit
beq YM2413_0_StatusR
cmp addy,#0xF2 ;@ FM/PSG enable/disable?
Expand All @@ -971,6 +975,9 @@ ExternalIO_R:
;@----------------------------------------------------------------------------
ExternalIO_W:
;@----------------------------------------------------------------------------
ldrb r1,ym2413Enabled
cmp r1,#0
beq empty_W
cmp addy,#0xF0 ;@ FM Unit
beq YM2413_0_AddressW
cmp addy,#0xF1 ;@ FM Unit
Expand Down

0 comments on commit 4e8b800

Please sign in to comment.