Skip to content

Commit

Permalink
Fixed OPL3 bug (timer, no IRQ)
Browse files Browse the repository at this point in the history
Fixed Franky PSG bug (was writing when reading its I/O port)
  • Loading branch information
ducasp committed Apr 14, 2022
1 parent 889ca2b commit 3a375b2
Show file tree
Hide file tree
Showing 83 changed files with 71,758 additions and 1,726 deletions.
63 changes: 45 additions & 18 deletions FPGA/ocm-pld v3.9a/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,26 @@

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R2BRGX6)

OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extensiong
OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extension
brings to the table:

- For regular SM-X, SM-X mini and SX-2:

- Fix: I've fixed OPL3, it had two issues that prevented it to work with
the latest VGMPlay version:

- IRQ was not connected, so timers programmed wouldn't trigger,
instead only the VDP interrupt, to slow, so music would play darn
slow with VGMPlay.

- Even after fixing that, playing speed was almost half of the correct
speed for VGMs. The timer scaler was not properly set causing it to
trigger slower than programmed.

Since VGMPlay 1.3 relies on OPL3 timer when present to drive a high speed
interrupt, not having IRQ and not having the proper scaler for timer
caused its timing to be slow, darn slow...

- Adds support to SMX-HB (as it has only initial support for OCM 3.7.1)

- Extra: I've allowed Joystick port debounce to be disabled, this perhaps
Expand All @@ -21,27 +38,37 @@ brings to the table:
is covered by KdL regular releases), that is handy when you want to use
an external keyboard.

- Extra: I've added partial support to a built-in Franky. SMX-HB FPGA has
less cells than other SM-X devices, and as it already did not support
OPL3, it apparently doesn't have space for SMS VDP implementation (I'm
still checking if somehow I can fit it). That partial support is good
enough to work with SG1000, COL4MMM (using COM\Franky versions) and
probably (did not test) Sofarun as well (remember to set it to use MSX
VDP, not Franky's). As Franky sound uses I/O ports 0x48 and 0x49, and
those ports are part of the switched I/O, it is usually disabled, as
OCM IPL loader will leave switched I/O selected. There are two ways to
enable Franky sound:
- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it
- Missing: SMX-HB FPGA has less cells than other SM-X devices as it uses
a FPGA with about 70% of the capacity of the other devices, so it doesn't
support OPL3 as it won't fit

- Adds to regular SMX-HB, SM-X, SM-X mini and SX-2 a frankysnd build:

- Extra: I've added partial support to a built-in Franky. That partial
support is good enough to work with SG1000, COL4MMM (using COM\Franky
versions) VGMPLAY and Sofarun (remember to set it to use MSX VDP and
Franky's PSG). As Franky sound uses I/O ports 0x48 and 0x49, and those
ports are part of the switched I/O, it is usually disabled, as OCM IPL
loader will leave switched I/O selected after booting. There are
different ways to enable Franky sound:

- VGMPLAY will automatically disable switched I/O, so you can play a
VGM song that uses SN76489 and after exiting VGMPLAY you can use other
software.

- De-select the internal switched I/O by sending the basic command
OUT &H40,0
It shouldn't work with VGMPLAY as VGMPLAY checks SMS VDP presence on I/O
0x88/0x89, which SMX-HB doesn't have, sorry :(

- SM-X, SM-X mini and SX-2 will have full Franky support:
- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it.

- Planned for the future SM-X, SM-X mini and SX-2 will have a franky build:

- Missing: FPGA in those devices can't fit OPL3 along with Franky VDP and
PSG, so that build won't have OPL3 support.

- Extra: this is a WIP, please wait :P
- Extra: this is a WIP, please wait, but it will have Franky VDP :P

All source code and binaries:
(c)2022 Oduvaldo Pavan Junior - ducasp@gmail.com
Expand Down
78 changes: 78 additions & 0 deletions FPGA/ocm-pld v3.9a/firmware/smx_frankysnd/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SMX_FRANKYSND

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R2BRGX6)

IMPORTANT! READ THIS AND BE CAREFUL! BRICKING SM-X ISN'T FUN! IT IS A PAIN TO
RESTORE IT USING JIC / USB BLASTER AS YOU WILL NEED TO CONNECT IT TO AN USB
BLASTER TO RESTORE IT. YOU HAVE BEEN WARNED! REALLY!

ONLY USE SMXFLASH.COM to update your SM-X. ONLY USE A FIRMWARE THAT IS MEANT TO
SM-X. NO, SMX-HB firmware IS NOT COMPATIBLE. SM-X MINI firmware IS NOT
COMPATIBLE. SX2 firmware IS NOT COMPATIBLE. IF THE FIRMWARE IS NOT SAYING IT
IS FOR SM-X STAY AWAY FROM IT.

The version of SMXFLASH.COM that is sent along with the firmware file also
works on NEXTOR. Older versions of SMXFLASH.COM requires MSX DOS 2 Kernel to be
loaded. Why would you use other version? I have no idea. Read this fully and
be carefull to not have any issues. Command line to update:

SMXFLASH OCM_SM.PLD

Wait until it quits to the dos prompt telling it is done. If there is an error
message after it started erasing or writing, try again until it works, as if
you power it down with an unfinished update, it will BRICK and you will need
to use an USB Blaster and JIC file to restore it, like said above, a pain!

Also, be aware that if power fails during update, you are most likely to end up
with a bricked unit and you will need to use an USB Blaster and JIC file to
restore it, again, a pain!

OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extension
brings to the table on this frankysnd version:

- Extra: I've added partial support to a built-in Franky. That partial
support is good enough to work with SG1000, COL4MMM (using COM\Franky
versions) VGMPLAY and Sofarun (remember to set it to use MSX VDP and
Franky's PSG). As Franky sound uses I/O ports 0x48 and 0x49, and those
ports are part of the switched I/O, it is usually disabled, as OCM IPL
loader will leave switched I/O selected after booting. There are
different ways to enable Franky sound:

- VGMPLAY will automatically disable switched I/O, so you can play a
VGM song that uses SN76489 and after exiting VGMPLAY you can use other
software.

- De-select the internal switched I/O by sending the basic command
OUT &H40,0

- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it.

- Fix: I've fixed OPL3, it had two issues that prevented it to work with
the latest VGMPlay version:

- IRQ was not connected, so timers programmed wouldn't trigger,
instead only the VDP interrupt, to slow, so music would play darn
slow with VGMPlay.

- Even after fixing that, playing speed was almost half of the correct
speed for VGMs. The timer scaler was not properly set causing it to
trigger slower than programmed.

Since VGMPlay 1.3 relies on OPL3 timer when present to drive a high speed
interrupt, not having IRQ and not having the proper scaler for timer
caused its timing to be slow, darn slow...

- Planned for the future SM-X, SM-X mini and SX-2 will have a franky build:

- Missing: FPGA in those devices can't fit OPL3 along with Franky VDP and
PSG, so that build won't have OPL3 support.

- Extra: this is a WIP, please wait, but it will have Franky VDP :P

All source code and binaries:
(c)2022 Oduvaldo Pavan Junior - ducasp@gmail.com

All code can be re-used, re-written, derivative work can be sold, as long as the
source code of changes is made public as well.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SMXHB_BR_LAYOUT
# SMXHB_FRANKYSND

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R2BRGX6)

Expand All @@ -17,7 +17,7 @@ IS FOR SMX-HB STAY AWAY FROM IT.
The version of SMXFLASH.COM that is sent along with the firmware file also
works on NEXTOR. Older versions of SMXFLASH.COM requires MSX DOS 2 Kernel to be
loaded. Why would you use other version? I have no idea. Read this fully and
be carefull to not have any issues. Command line to update:
be careful to not have any issues. Command line to update:

SMXFLASH OCM_SM.PLD

Expand All @@ -30,7 +30,7 @@ Also, be aware that if power fails during update, you are most likely to end up
with a bricked unit and you will need to use an USB Blaster and JIC file to
restore it, again, a pain!

OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extensiong
OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extension
brings to the table:

- Adds support to SMX-HB (as it has only initial support for OCM 3.7.1)
Expand All @@ -49,23 +49,30 @@ brings to the table:
is covered by KdL regular releases), that is handy when you want to use
an external keyboard.

- Extra: I've added partial support to a built-in Franky. SMX-HB FPGA has
less cells than other SM-X devices, and as it already did not support
OPL3, it apparently doesn't have space for SMS VDP implementation (I'm
still checking if somehow I can fit it). That partial support is good
enough to work with SG1000, COL4MMM (using COM\Franky versions) and
probably (did not test) Sofarun as well (remember to set it to use MSX
VDP, not Franky's). As Franky sound uses I/O ports 0x48 and 0x49, and
those ports are part of the switched I/O, it is usually disabled, as
OCM IPL loader will leave switched I/O selected. There are two ways to
enable Franky sound:
- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it
- Missing: SMX-HB FPGA has less cells than other SM-X devices as it uses
a FPGA with about 70% of the capacity of the other devices, so it doesn't
support OPL3 as it won't fit

- Adds to regular SMX-HB as a frankysnd build:

- Extra: I've added partial support to a built-in Franky. That partial
support is good enough to work with SG1000, COL4MMM (using COM\Franky
versions) VGMPLAY and Sofarun (remember to set it to use MSX VDP and
Franky's PSG). As Franky sound uses I/O ports 0x48 and 0x49, and those
ports are part of the switched I/O, it is usually disabled, as OCM IPL
loader will leave switched I/O selected after booting. There are
different ways to enable Franky sound:

- VGMPLAY will automatically disable switched I/O, so you can play a
VGM song that uses SN76489 and after exiting VGMPLAY you can use other
software.

- De-select the internal switched I/O by sending the basic command
OUT &H40,0
It shouldn't work with VGMPLAY as VGMPLAY checks SMS VDP presence on I/O
0x88/0x89, which SMX-HB doesn't have, sorry :(

- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it.

All source code and binaries:
(c)2022 Oduvaldo Pavan Junior - ducasp@gmail.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SMXHB_BR_LAYOUT
# SMXHB_FRANKYSND

Do you like what I do and want to pay me a Coffee as a thank you?
https://ko-fi.com/R6R2BRGX6
Expand All @@ -19,7 +19,7 @@ IS FOR SMX-HB STAY AWAY FROM IT.
The version of SMXFLASH.COM that is sent along with the firmware file also
works on NEXTOR. Older versions of SMXFLASH.COM requires MSX DOS 2 Kernel to be
loaded. Why would you use other version? I have no idea. Read this fully and
be carefull to not have any issues. Command line to update:
be careful to not have any issues. Command line to update:

SMXFLASH OCM_SM.PLD

Expand All @@ -32,7 +32,7 @@ Also, be aware that if power fails during update, you are most likely to end up
with a bricked unit and you will need to use an USB Blaster and JIC file to
restore it, again, a pain!

OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extensiong
OCM-PLD v3.9a is an extension on KdL OCM release v3.9. What this extension
brings to the table:

- Adds support to SMX-HB (as it has only initial support for OCM 3.7.1)
Expand All @@ -51,23 +51,30 @@ brings to the table:
is covered by KdL regular releases), that is handy when you want to use
an external keyboard.

- Extra: I've added partial support to a built-in Franky. SMX-HB FPGA has
less cells than other SM-X devices, and as it already did not support
OPL3, it apparently doesn't have space for SMS VDP implementation (I'm
still checking if somehow I can fit it). That partial support is good
enough to work with SG1000, COL4MMM (using COM\Franky versions) and
probably (did not test) Sofarun as well (remember to set it to use MSX
VDP, not Franky's). As Franky sound uses I/O ports 0x48 and 0x49, and
those ports are part of the switched I/O, it is usually disabled, as
OCM IPL loader will leave switched I/O selected. There are two ways to
enable Franky sound:
- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it
- Missing: SMX-HB FPGA has less cells than other SM-X devices as it uses
a FPGA with about 70% of the capacity of the other devices, so it doesn't
support OPL3 as it won't fit

- Adds to regular SMX-HB as a frankysnd build:

- Extra: I've added partial support to a built-in Franky. That partial
support is good enough to work with SG1000, COL4MMM (using COM\Franky
versions) VGMPLAY and Sofarun (remember to set it to use MSX VDP and
Franky's PSG). As Franky sound uses I/O ports 0x48 and 0x49, and those
ports are part of the switched I/O, it is usually disabled, as OCM IPL
loader will leave switched I/O selected after booting. There are
different ways to enable Franky sound:

- VGMPLAY will automatically disable switched I/O, so you can play a
VGM song that uses SN76489 and after exiting VGMPLAY you can use other
software.

- De-select the internal switched I/O by sending the basic command
OUT &H40,0
It shouldn't work with VGMPLAY as VGMPLAY checks SMS VDP presence on I/O
0x88/0x89, which SMX-HB doesn't have, sorry :(

- Use SETSMART -8C to enable the I/O ports 0x48 and 0x49 for that, so
any program relying on reading OCM information on those ports won't
get it.

All source code and binaries:
(c)2022 Oduvaldo Pavan Junior - ducasp@gmail.com
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion FPGA/ocm-pld v3.9a/ocm_sm/!!-cleanup.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
rem --- '!!-cleanup.cmd' v2.8 by KdL (2022.04.11)
rem --- '!!-cleanup.cmd' v2.8 by KdL (2022.04.14)

set PROJECT1=emsx_top
set PROJECT2=ocm_sm
Expand Down Expand Up @@ -30,6 +30,7 @@ set OUTPUT=output_files\
rd /S /Q %OUTPUT% >nul 2>nul
del src_addons\peripheral\sm_swioports.vhd* >nul 2>nul
del src_addons\sys\pll.vhd >nul 2>nul
del src_addons\sys\pll_franky.* >nul 2>nul
del src_addons\top.vhd >nul 2>nul
del src_addons\debounce_joy.vhd >nul 2>nul
del "__*__" >nul 2>nul
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@echo off
rem --- '!!-init-smx_franky.cmd' v2.7 by Ducasp (2022.04.11)
rem --- '!!-init-smx_frankysnd.cmd' v2.7 by Ducasp (2022.04.11)

set TIMEOUT=1
set FOLDER=init_
set DEVICE=smx_franky
if "%1"=="" color 4f&title INIT for SM-X Franky
set DEVICE=smx_frankysnd
if "%1"=="" color 4f&title INIT for SM-X w/ Franky Sound
if not exist "%FOLDER%%DEVICE%\" goto err_msg
rem ---------------cleanup----------------
call !!-cleanup.cmd --no-wait
Expand All @@ -13,7 +13,7 @@ rem --------------------------------------
:smx
rem.>"__%DEVICE%__"
xcopy /S /E /Y "%FOLDER%%DEVICE%\*.*" >nul 2>nul
echo.&echo SM-X Franky is ready to compile!
echo.&echo SM-X w/ Franky Sound is ready to compile!
goto timer

:err_msg
Expand Down
2 changes: 1 addition & 1 deletion FPGA/ocm-pld v3.9a/ocm_sm/!!-init-smxhb.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rem based on '!!-init-smx.cmd' v2.7 by KdL (2021.08.23)
set TIMEOUT=1
set FOLDER=init_
set DEVICE=smxhb
if "%1"=="" color 4f&title INIT for SMX-HB
if "%1"=="" color 71&title INIT for SMX-HB
if not exist "%FOLDER%%DEVICE%\" goto err_msg
rem ---------------cleanup----------------
call !!-cleanup.cmd --no-wait
Expand Down
27 changes: 27 additions & 0 deletions FPGA/ocm-pld v3.9a/ocm_sm/!!-init-smxhb_frankysnd.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@echo off
rem --- '!!-init-smxhb_frankysnd.cmd' v2.7 by Ducasp (2022.04.10)
rem based on '!!-init-smx.cmd' v2.7 by KdL (2021.08.23)

set TIMEOUT=1
set FOLDER=init_
set DEVICE=smxhb_frankysnd
if "%1"=="" color 71&title INIT for SMX-HB w/ Franky Sound
if not exist "%FOLDER%%DEVICE%\" goto err_msg
rem ---------------cleanup----------------
call !!-cleanup.cmd --no-wait
rem --------------------------------------

:smx
rem.>"__%DEVICE%__"
xcopy /S /E /Y "%FOLDER%%DEVICE%\*.*" >nul 2>nul
echo.&echo SMX-HB w/ Franky Sound is ready to compile!
goto timer

:err_msg
if "%1"=="" color f0
echo.&echo '%FOLDER%%DEVICE%\' not found!

:timer
if "%1"=="" waitfor /T %TIMEOUT% pause >nul 2>nul

:quit

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ set_global_assignment -name VERILOG_FILE src_addons/sys/i2c.v
set_global_assignment -name VERILOG_FILE src_addons/sys/i2s.v
set_global_assignment -name VERILOG_FILE ../esemsx3/src/sound/tr_pcm/tr_pcm.v
set_global_assignment -name QIP_FILE src_addons/sound/jt89/hdl/jt89.qip
set_global_assignment -name QIP_FILE src_addons/video/vdp_franky/vdp_franky.qip
set_global_assignment -name QIP_FILE src_addons/sound/opl3/opl3.qip
set_global_assignment -name QIP_FILE src_addons/sys/pll.qip
set_global_assignment -name SDC_FILE ocm_sm_constrains.sdc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ set_global_assignment -name VERILOG_FILE src_addons/sys/i2c.v
set_global_assignment -name VERILOG_FILE src_addons/sys/i2s.v
set_global_assignment -name VERILOG_FILE ../esemsx3/src/sound/tr_pcm/tr_pcm.v
set_global_assignment -name QIP_FILE src_addons/sound/jt89/hdl/jt89.qip
set_global_assignment -name QIP_FILE src_addons/video/vdp_franky/vdp_franky.qip
set_global_assignment -name QIP_FILE src_addons/sound/opl3/opl3.qip
set_global_assignment -name QIP_FILE src_addons/sys/pll.qip
set_global_assignment -name SDC_FILE ocm_sm_constrains.sdc

Expand Down

0 comments on commit 3a375b2

Please sign in to comment.