Discussion Forum for all things Microbee
isr for sdcc - Printable Version

+- Discussion Forum for all things Microbee (https://microbeetechnology.com.au/forum)
+-- Forum: Microbee Forum (https://microbeetechnology.com.au/forum/forum-1.html)
+--- Forum: Microbee Software and Documentation (https://microbeetechnology.com.au/forum/forum-7.html)
+--- Thread: isr for sdcc (/thread-477.html)



isr for sdcc - Under4Mhz - 05-05-2022

I'm trying to get a game of mine working on Microbee.

I've got graphics working, but I need the vblank isr to work for timing.

The isr gets called once, but not a second time. For other platforms I've worked on, it's necessary to read from a port to clear the vsync for it to trigger an interrupt again. Is that the same for the Microbee?


RE: isr for sdcc - MbeeTech - 05-05-2022

Hello Under4Mhz

You may have to post your code for comment to start with.

Reading the status of the CRT controller at port 0x0c provides 3 bits of status information - one of these signifies that the CRT scan is in the
vertical blanking time. The Microbee doesn't normally have a way of generating an interrupt from this signal though. It's purely software polled.

There is however a link that can be done to the baseboard to generate an interrupt from the Z80 PIO when vertical Sync gets connected to one
of its port B I/O pins. This is how the psuedo real time clock operates in the ROM based Microbees.


RE: isr for sdcc - Under4Mhz - 05-05-2022

Thanks, I can work around that.

Do you know what the bits are?

It seems bit 5 is vsync and bit 6 is the keyboard press?


RE: isr for sdcc - someone - 05-05-2022

Connect up the VSYNC signal to PIO Port B bit #7, the bit that's used for StarNet).
Someone's guessing you're not using StarNet.

Someone will let you have the adventure of setting it up suffice it to say:

  • Configure the CPU to handle interrupts
  • Init the PIO to generate interrupts
  • Write the appropriate ISR (Interrupt Service Routine).
  • Use the RETI instruction for the PIO


An most importantly, remember to reenable interrupts as you exit your ISR.


RE: isr for sdcc - MbeeTech - 05-05-2022

(05-05-2022, 02:37 PM)Under4Mhz Wrote: Thanks, I can work around that.

Do you know what the bits are?

It seems bit 5 is vsync and bit 6 is the keyboard press?

Status register
bit 5 (Vertical Blanking)    : 0 - Scan not in vertical Blanking area, 1 - scan currently in vertical blanking area.
bit 6 (LPEN Register Full ) : 0 - Bit goes to '0' whenever Register 16 or Register 17 is read : 1 - Bit goes to '1' whenever a LPEN strobe occurs
bit 7 (Update Ready)        : 0 - Bit goes to '0' whenever Register 31 (dummy register) is read or written by the CPU
                                    : 1 - Bit goes to '1' whenever an Update Strobe occurs

If you are writing your game for your own use, it is probably easier to connect up VSync to the PIO as mentioned above.
However, if you are writing your game for general distribution, you don't want people to have to do this modification just so they
can play the game.  In this case, it would be better to find some other way of timing the game, or using polling somehow to use
detection of the blanking period for your timebase.


RE: isr for sdcc - someone - 05-05-2022

(05-05-2022, 04:42 PM)ejwords Wrote:
(05-05-2022, 02:37 PM)Under4Mhz Wrote: Thanks, I can work around that.

Do you know what the bits are?

It seems bit 5 is vsync and bit 6 is the keyboard press?

Status register
bit 5 (Vertical Blanking)    : 0 - Scan not in vertical Blanking area, 1 - scan currently in vertical blanking area.
bit 6 (LPEN Register Full ) : 0 - Bit goes to '0' whenever Register 16 or Register 17 is read : 1 - Bit goes to '1' whenever a LPEN strobe occurs
bit 7 (Update Ready)        : 0 - Bit goes to '0' whenever Register 31 (dummy register) is read or written by the CPU
                                    : 1 - Bit goes to '1' whenever an Update Strobe occurs

If you are writing your game for your own use, it is probably easier to connect up VSync to the PIO as mentioned above.
However, if you are writing your game for general distribution, you don't want people to have to do this modification just so they
can play the game.  In this case, it would be better to find some other way of timing the game, or using polling somehow to use
detection of the blanking period for your timebase.

The CRTC status register needs to be polled and is slow.
Robotman polls the abovementioned register as not to generate black flicks on the display.
(i.e. screen updates in VBLANK period)

This hassle was caused when the Z80 CTC was dropped from the original microbee design.
(i.e. Z80 CTC at PORT04.)

If you've got a Alpha Plus and you don't want to mod your microbee, you can connect its VSYNC or HSYNC pin from the colour port to one of the serial port or tape inputs with a piece of wire leaving the User Port free for game controllers.