Foenix IDE

Description of your first forum.
frenchguy
Posts: 32
Joined: Tue Oct 01, 2019 11:45 am

Re: Foenix IDE

Post by frenchguy » Fri Jan 24, 2020 11:45 am

Hi !
Still working on my graphic/UI library with the IDE and Simulator, I try to manage interrupts.
For the moment I deal with keyboard interrupts. If I understood well, when a keyboard event happens the INT_PENDING_REG1 ($000141) register should be $01 (bit 0 set). But when watching at $000141 in the emulator memory window I see no changes (always 0) when I press a key for example; Test done when just running the kernel, no other program.
Is it normal ?
immortalx
Posts: 7
Joined: Tue Apr 23, 2019 5:01 pm

Re: Foenix IDE

Post by immortalx » Tue Feb 04, 2020 1:14 pm

@frenchguy I just watched your graphics tests videos and they look awesome! If you don't mind, I've 2 questions for you:

1. Could you please do a short tutorial on developing for C256 in C? Like setting up the compiler and a hello-world example.
2. Will you be making your graphics library open-source sometimes in the future?
User avatar
PJW
Posts: 36
Joined: Wed Apr 24, 2019 12:44 am

Re: Foenix IDE

Post by PJW » Tue Feb 04, 2020 2:01 pm

frenchguy wrote:
Fri Jan 24, 2020 11:45 am
Hi !
Still working on my graphic/UI library with the IDE and Simulator, I try to manage interrupts.
For the moment I deal with keyboard interrupts. If I understood well, when a keyboard event happens the INT_PENDING_REG1 ($000141) register should be $01 (bit 0 set). But when watching at $000141 in the emulator memory window I see no changes (always 0) when I press a key for example; Test done when just running the kernel, no other program.
Is it normal ?
I missed this question somehow. Are you setting the edge and mask registers the way the kernel does (or are you letting the kernel initialize things as it usually does before you take over handling the IRQ)? The kernel sets initial values for the interrupt registers at the beginning, but then the INITKEYBOARD routine turns on the interrupts for the keyboard (and mouse):

Code: Select all

                ; Unmask the Keyboard interrupt
                ; Clear Any Pending Interrupt
                LDA @lINT_PENDING_REG0  ; Read the Pending Register &
                AND #FNX0_INT07_MOUSE
                STA @lINT_PENDING_REG0  ; Writing it back will clear the Active Bit

                LDA @lINT_PENDING_REG1  ; Read the Pending Register &
                AND #FNX1_INT00_KBD
                STA @lINT_PENDING_REG1  ; Writing it back will clear the Active Bit
                ; Disable the Mask
                LDA @lINT_MASK_REG1
                AND #~FNX1_INT00_KBD
                STA @lINT_MASK_REG1

                LDA @lINT_MASK_REG0
                AND #~FNX0_INT07_MOUSE
                STA @lINT_MASK_REG0
If you're replacing the kernel, and this isn't happening in your code, I wouldn't expect to see an interrupt for the keyboard. (Although the lines related to the mouse interrupt aren't necessary for the keyboard... it's just that the initialization for both the PS/2 serial devices is happening in that one routine in the kernel.)
frenchguy
Posts: 32
Joined: Tue Oct 01, 2019 11:45 am

Re: Foenix IDE

Post by frenchguy » Wed Feb 05, 2020 10:37 am

PJW wrote:
Tue Feb 04, 2020 2:01 pm
frenchguy wrote:
Fri Jan 24, 2020 11:45 am
Hi !
Still working on my graphic/UI library with the IDE and Simulator, I try to manage interrupts.
For the moment I deal with keyboard interrupts. If I understood well, when a keyboard event happens the INT_PENDING_REG1 ($000141) register should be $01 (bit 0 set). But when watching at $000141 in the emulator memory window I see no changes (always 0) when I press a key for example; Test done when just running the kernel, no other program.
Is it normal ?
I missed this question somehow. Are you setting the edge and mask registers the way the kernel does (or are you letting the kernel initialize things as it usually does before you take over handling the IRQ)? The kernel sets initial values for the interrupt registers at the beginning, but then the INITKEYBOARD routine turns on the interrupts for the keyboard (and mouse):

...

If you're replacing the kernel, and this isn't happening in your code, I wouldn't expect to see an interrupt for the keyboard. (Although the lines related to the mouse interrupt aren't necessary for the keyboard... it's just that the initialization for both the PS/2 serial devices is happening in that one routine in the kernel.)
Indeed I let the kernel initialize things then load, without zeroing memory, my code and run it. So I assume at this point that the kernel code is still there and that what it initialized is still ok.
For my code, the C compiler ( according to what I understood because there is not a very helpful documentation) has linked a library that set interrupts vector to call an IRQ handler (function). This function is well called, but when I check the keyboard register INT_PENDING_REG1 it's seems to be always 0 when I press a key for example. But I noticed that if I directly change the value in memory of INT_PENDING_REG1 to 0x01, my IRQ handling function is called and acts has it should.
I don't know if I did something, wrong, or if the C library has erased some intialisations, of if the kernel code has been broken when loading my code. I am investigating but debugging assembly code generated by the compilet, in the simulator is not very easy :-)
Anyway, thanks for you answer :-)
frenchguy
Posts: 32
Joined: Tue Oct 01, 2019 11:45 am

Re: Foenix IDE

Post by frenchguy » Wed Feb 05, 2020 10:44 am

immortalx wrote:
Tue Feb 04, 2020 1:14 pm
@frenchguy I just watched your graphics tests videos and they look awesome! If you don't mind, I've 2 questions for you:

1. Could you please do a short tutorial on developing for C256 in C? Like setting up the compiler and a hello-world example.
2. Will you be making your graphics library open-source sometimes in the future?
hi @immortalx ,

1. I should do this kiind of tutorial but I do not have enough of free time, lol, Seriously, yes I will try to do that, but I had to digg and investigate and guess a lot about how to set and use this C compiler, so maybe it would not be 100% accurate.

2. For the moment this code is a big mess and work in progress, It's a loooong time since I have'not write fun and useful code (doing devop and this kind os plumbing stuffs....), and especially C code then it's a playground for me; for example for the windowing system I try to mimic object oriented programming in C. So, yes at least I will put it on Github. I will tell it it this forum when it will be done.
immortalx
Posts: 7
Joined: Tue Apr 23, 2019 5:01 pm

Re: Foenix IDE

Post by immortalx » Wed Feb 05, 2020 11:47 am

Thank you very much frenchguy! Looking forward to seeing more of your C experiments.
The lack of C programming for the Foenix has been the only reason I didn't get the development version. I can't program in assembly and I feel that nowadays few people can. So I believe that what you do is really important and will draw more people to start tinkering with the platform.
The same thing happened with the SEGA Genesis/MegaDrive and the SGDK library, which made programming for the console more accessible, even if it sacrifices a bit of the performance.
User avatar
PJW
Posts: 36
Joined: Wed Apr 24, 2019 12:44 am

Re: Foenix IDE

Post by PJW » Wed Feb 05, 2020 4:37 pm

frenchguy wrote:
Wed Feb 05, 2020 10:37 am
Indeed I let the kernel initialize things then load, without zeroing memory, my code and run it. So I assume at this point that the kernel code is still there and that what it initialized is still ok.
For my code, the C compiler ( according to what I understood because there is not a very helpful documentation) has linked a library that set interrupts vector to call an IRQ handler (function). This function is well called, but when I check the keyboard register INT_PENDING_REG1 it's seems to be always 0 when I press a key for example. But I noticed that if I directly change the value in memory of INT_PENDING_REG1 to 0x01, my IRQ handling function is called and acts has it should.
I don't know if I did something, wrong, or if the C library has erased some intialisations, of if the kernel code has been broken when loading my code. I am investigating but debugging assembly code generated by the compilet, in the simulator is not very easy :-)
Anyway, thanks for you answer :-)
I can't offer any insight into what C might be doing, as I've done absolutely nothing with the C compiler for the 65816. My best guess though is that the interrupt controller is somehow not getting properly set up. Here's the section of code from the kernel that does the initial setup of the interrupt controller:

Code: Select all

                ; Setup the Interrupt Controller
                ; For Now all Interrupt are Falling Edge Detection (IRQ)
                LDA #$FF
                STA @lINT_EDGE_REG0
                STA @lINT_EDGE_REG1
                STA @lINT_EDGE_REG2
                STA @lINT_EDGE_REG3
                ; Mask all Interrupt @ This Point
                STA @lINT_MASK_REG0
                STA @lINT_MASK_REG1
                STA @lINT_MASK_REG2
                STA @lINT_MASK_REG3
That is then followed (eventually) by the keyboard initialization code I quoted earlier that turns on the mouse and keyboard interrupts.

Other possibilities are that the keyboard controller itself is getting reset and not raising an interrupt or that the pending interrupt is not getting cleared on a previous interrupt so that it gets set again later... like so:

Code: Select all

                ; Clear the Pending Flag
                LDA @lINT_PENDING_REG1
                AND #FNX1_INT00_KBD
                STA @lINT_PENDING_REG1
All the initialization of the keyboard controller is done through the INITKEYBOARD subroutine in kernel.asm, if that's helpful.
Post Reply