bug in CBIOS?

By santiontanon

Paragon (1757)

santiontanon's picture

14-08-2017, 12:18

Hi guys, I was having a very weird bug in a little project I'm working on, and after a while tracing it back, I think it's due to a small issue with the RDPSG implementation in CBIOS. The current implementation looks like this (from: https://sourceforge.net/p/cbios/cbios/ci/master/tree/src/mai... ):

;--------------------------------
; $0096 RDPSG
; Function : Reads value from PSG-register
; Input    : A  - PSG-register read
; Output   : A  - value read
rdpsg:
                out     (PSG_REGS),a
                in      a,(PSG_STAT)
                ret

What was happening to me is that in between the "out" and the "in", an interrupt was triggered (used to play music), which messed up everything (took me forever to find, btw!! hahaha). So, I now need to surround every call to RDPSG in my code by di/ei. If instead of CBIOS, I use some other bios (e.g. Philips VG8020), everything works fine. I noticed that other bios calls, such as WRTPSG do call di/ei inside, and are thus safe. But RDPSG does not... I was just wondering if this was intended or if it is a bug :)

Login or register to post comments

By ARTRAG

Enlighted (6923)

ARTRAG's picture

14-08-2017, 12:50

It seems a bug, if the isr uses the psg you end reading something wrong

By Grauw

Ascended (10699)

Grauw's picture

14-08-2017, 12:54

There’s a "New issue" button at https://github.com/cbios/cbios/issues ;).

(Sourceforge is old btw, code is on Github nowadays.)

By santiontanon

Paragon (1757)

santiontanon's picture

14-08-2017, 15:46

oh! I thought it was weird to have it in sourceforge, but that was the first hit Google found Smile

I just checked and the github implementation is the same. So, I opened an issue! thanks!!