diff --git a/Docs/smstech.txt b/Docs/smstech.txt index ed86d32..baa3486 100644 --- a/Docs/smstech.txt +++ b/Docs/smstech.txt @@ -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. diff --git a/History.txt b/History.txt index 9c9037b..07e50bf 100644 --- a/History.txt +++ b/History.txt @@ -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. diff --git a/README.md b/README.md index 142512d..b1e72a4 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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. diff --git a/source/Cart.s b/source/Cart.s index fe4f759..153b073 100644 --- a/source/Cart.s +++ b/source/Cart.s @@ -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 @@ -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 diff --git a/source/Gfx.s b/source/Gfx.s index c9e00b6..28991f0 100644 --- a/source/Gfx.s +++ b/source/Gfx.s @@ -163,7 +163,8 @@ ppi: adds r1,r1,#1 bne ppi - bl gfxReset + bl setupScaling + bl VDP0ApplyScaling ldmfd sp!,{lr} bx lr ;@---------------------------------------------------------------------------- diff --git a/source/Gui.c b/source/Gui.c index e5fac17..a2cc7a5 100644 --- a/source/Gui.c +++ b/source/Gui.c @@ -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 @@ -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); @@ -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}; @@ -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() { @@ -1505,6 +1507,10 @@ void glassesSet() { } +void biosSet() { + g_configSet ^= 0x80; +} + void countrySet() { int i; g_region = (g_region+1)&3; @@ -1530,8 +1536,8 @@ void machineSet() { } } -void biosSet() { - g_configSet ^= 0x80; +void ym2413Set() { + ym2413Enabled ^= 0x01; } diff --git a/source/Memory.s b/source/Memory.s index 8486751..615b559 100644 --- a/source/Memory.s +++ b/source/Memory.s @@ -145,8 +145,8 @@ 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: ;@---------------------------------------------------------------------------- @@ -154,7 +154,7 @@ LCDGlasses: 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] diff --git a/source/io.h b/source/io.h index 63aec01..b9888e5 100644 --- a/source/io.h +++ b/source/io.h @@ -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; diff --git a/source/io.s b/source/io.s index 3194027..19a93e0 100644 --- a/source/io.s +++ b/source/io.s @@ -10,6 +10,7 @@ .global Z80Out .global joyCfg .global inputHW + .global ym2413Enabled .global joy0State .global joy1State .global acExtra @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: ;@------------------------------------------------------------------------------ @@ -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? @@ -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