Foenix IDE - Rev C
Re: Foenix IDE - Rev C
Grenouye - Can I help You with Tracker GUI, icons, also ideas? I own chipmusic forum. I am into 8bit/fm music almost 10 years. Also know author of Adlibtracker2.
Re: Foenix IDE - Rev C
Mouse interrupts are now supported in release 0.5.2.3 of the IDE. https://github.com/Trinity-11/FoenixIDE ... se-0.5.2.3frenchguy wrote: ↑Wed Sep 16, 2020 1:47 amOk, thanks!grenouye wrote: ↑Wed Sep 16, 2020 1:22 amThe mouse support in the IDE doesn't raise interrupts. The value of the X and Y positions are stored in the in Vicky addresses $AF:0702 and $AF:0704, respectively. This allowed for testing of the drawing of the mouse pointer.frenchguy wrote: ↑Mon Sep 14, 2020 1:57 pmHi,
Is there support for mouse implemented in the IDE ? I do not get break on mouse interrupt. I also do not see modification in the reg0 about the mouse interrupt. I am using the IDE with default provided Kernel, and start the kernel before load and running my program.
And is it compatible with 800x600 resolution of Vicky II ?
This was much simpler than imitating the SuperIO chip. Especially, since we need to raise 3 interrupts for each mouse movement.
So I guess that mouse clicks neither raise interrupts ? In that case I will have to find a workaround... maybe check buttons state on SOF
. Unless you can add this interrupt raise in the IDE ?
Update: I have just made a quick update to take new VickyII MCR and Bitmap Control Register into account for 800x600, and a quick test, and it works fine
You can check the ongoing work here : https://www.youtube.com/channel/UCYlxuo ... nc9if15xA/
Re: Foenix IDE - Rev C
Matej, sorry for the late approval of the post...
This is really awesome...
Do you want to join the Discord Server @ https://discord.gg/gBY3RCw
Sorry again!
Stefany
Mistress of All Villainy
Re: Foenix IDE - Rev C
Of course. I haven't worked on it in a while, as I've been busy with the IDE and Tetris.
We could create a new discussion thread for the C256 Tracker. I'm curious to hear what you're thinking about.
Re: Foenix IDE - Rev C
Great! Is the documentation up to date?grenouye wrote: ↑Wed Sep 30, 2020 2:27 am
Mouse interrupts are now supported in release 0.5.2.3 of the IDE. https://github.com/Trinity-11/FoenixIDE ... se-0.5.2.3
I'd like to use the interrupts to manage the mouse clicks but I have not yet found where to read button states (?)
In an other hand, I have implemented a trivial buffered drawing mechanism with the VDMA: drawing in off screen video memory (after 0xb0000 + screen size) and then copy this entire buffer (800x600) in the displayed video memory.
I am super happy, so far it works well and fast in the IDE. But a refined algorithm won't hurt, lol.
Re: Foenix IDE - Rev C
The mouse button data is provided in the first PS/2 byte written to the keyboard buffer. What you need to do is:frenchguy wrote: ↑Thu Oct 01, 2020 8:14 pm
Great! Is the documentation up to date?
I'd like to use the interrupts to manage the mouse clicks but I have not yet found where to read button states (?)
In an other hand, I have implemented a trivial buffered drawing mechanism with the VDMA: drawing in off screen video memory (after 0xb0000 + screen size) and then copy this entire buffer (800x600) in the displayed video memory.
I am super happy, so far it works well and fast in the IDE. But a refined algorithm won't hurt, lol.
* when the byte counter is 0, do an "AND $7" - this will give the you status of the buttons.
* store this for your program to use when appropriate.
4 = middle button
2 = right button
1 = left button.
Re: Foenix IDE - Rev C
Where is this keyboard buffer ? I have seen several addresses in the kernel sources that are labelled as something like keyboard buffer (KEY_BUFFER=000f00 , KBD_INPT_BUFF=AF1060) . I have not seen much changes at those addresses in the IDE, but maybe it's because of a refresh rate.grenouye wrote: ↑Sun Oct 04, 2020 8:38 pm
The mouse button data is provided in the first PS/2 byte written to the keyboard buffer. What you need to do is:
* when the byte counter is 0, do an "AND $7" - this will give the you status of the buttons.
* store this for your program to use when appropriate.
4 = middle button
2 = right button
1 = left button.
Re: Foenix IDE - Rev C
Keyboard buffer is: KBD_INPT_BUF = $AF1060 ; this is really the PS/2 address that SuperIO writes to.frenchguy wrote: ↑Fri Oct 09, 2020 5:10 pmWhere is this keyboard buffer ? I have seen several addresses in the kernel sources that are labelled as something like keyboard buffer (KEY_BUFFER=000f00 , KBD_INPT_BUFF=AF1060) . I have not seen much changes at those addresses in the IDE, but maybe it's because of a refresh rate.
Re: Foenix IDE - Rev C
I don't understand what/where is the byte counter you mentioned, neither the way to dectect if a button is pressed or released. I had a look in the IDE sources and saw no difference between gpu_MouseUp and gpu_MouseDown which generate the interrupt. I am reading some info about the PS/2 protocol to understand if there are missing stuff in my code, or in the IDE.frenchguy wrote: ↑Fri Oct 09, 2020 5:10 pmWhere is this keyboard buffer ? I have seen several addresses in the kernel sources that are labelled as something like keyboard buffer (KEY_BUFFER=000f00 , KBD_INPT_BUFF=AF1060) . I have not seen much changes at those addresses in the IDE, but maybe it's because of a refresh rate.grenouye wrote: ↑Sun Oct 04, 2020 8:38 pm
The mouse button data is provided in the first PS/2 byte written to the keyboard buffer. What you need to do is:
* when the byte counter is 0, do an "AND $7" - this will give the you status of the buttons.
* store this for your program to use when appropriate.
4 = middle button
2 = right button
1 = left button.
I have seen that on a wiki :
And if I understand the c# code of the IDE you store the absolute location of mouse, and a number for the button (4,2,1) either it's pressed or up. Am I wrong?bm Button Middle (Normally Off = 0)
br Button Right (Normally Off = 0)
bl Button Left (Normally Off = 0)
xm X-Axis Movement Value
ym Y-Axis Movement Value
Each X and Y axis value is relative. The mouse device does not track it's location in absolute coordinates. This should also be apparent by the 9-bit values. Instead, it sends back saying I moved this far to the left, to the right, down, or up. To keep track of a mouse position you need to accumulate these relative offsets into a absolute position offset in your code:
Re: Foenix IDE - Rev C
Right. Sorry about the confusion. The PS/2 protocol has two registers, one for data and one for control bytes.
When moving the mouse, three interrupts are generated, every time a byte is written to the data registry.
The first byte written contains the mouse buttons
The second byte contains the X delta.
The third byte contains the Y delta.
When the third byte is received, the interrupt handler recomposes the X and Y coordinates and writes them into MOUSE_POS_X_LO/HI and MOUSE_POS_Y_LO/HI.
The IDE generates the interrupts and writes the values in a similar fashion, when you move the mouse or click a button, "GenerateMouseInterrupt" is getting called.
My interrupt handler stores the Mouse Button value in a separate register named MOUSE_BUTTONS_REG, as shown here:
I hope this helps.
Dan
When moving the mouse, three interrupts are generated, every time a byte is written to the data registry.
The first byte written contains the mouse buttons
The second byte contains the X delta.
The third byte contains the Y delta.
When the third byte is received, the interrupt handler recomposes the X and Y coordinates and writes them into MOUSE_POS_X_LO/HI and MOUSE_POS_Y_LO/HI.
The IDE generates the interrupts and writes the values in a similar fashion, when you move the mouse or click a button, "GenerateMouseInterrupt" is getting called.
Code: Select all
private void GenerateMouseInterrupt(MouseEventArgs e)
{
Point size = gpu.GetScreenSize();
double ratioW = gpu.Width / (double)size.X;
double ratioH = gpu.Height / (double)size.Y;
int X = (int)(e.X / ratioW);
int Y = (int)(e.Y / ratioH);
bool middle = e.Button == MouseButtons.Middle;
bool left = e.Button == MouseButtons.Left;
bool right = e.Button == MouseButtons.Right;
kernel.MemMgr.VICKY.WriteWord(0x702, X);
kernel.MemMgr.VICKY.WriteWord(0x704, Y);
// Generate three interrupts - to emulate how the PS/2 controller works
byte mask = kernel.MemMgr.ReadByte(MemoryLocations.MemoryMap.INT_MASK_REG0);
// The PS/2 packet is byte0, xm, ym
if ((~mask & (byte)Register0.FNX0_INT07_MOUSE) == (byte)Register0.FNX0_INT07_MOUSE)
{
kernel.MemMgr.KEYBOARD.MousePackets((byte)(8+(middle?4:0)+ (right?2:0) + (left?1:0)) , (byte)(X & 0xFF), (byte)(Y & 0xFF));
}
}
Code: Select all
MOUSE_INTERRUPT
.as
LDA KBD_INPT_BUF
PHA
LDX #$0000
setxs
LDX MOUSE_PTR
BNE MOUSE_BYTE_GT1
; copy the buttons to another address
AND #%0111
STA MOUSE_BUTTONS_REG
MOUSE_BYTE_GT1
PLA
STA @lMOUSE_PTR_BYTE0, X
INX
CPX #$03
BNE EXIT_FOR_NEXT_VALUE
; Create Absolute Count from Relative Input
LDA @lMOUSE_PTR_X_POS_L
STA MOUSE_POS_X_LO
LDA @lMOUSE_PTR_X_POS_H
STA MOUSE_POS_X_HI
LDA @lMOUSE_PTR_Y_POS_L
STA MOUSE_POS_Y_LO
LDA @lMOUSE_PTR_Y_POS_H
STA MOUSE_POS_Y_HI
; print the character on the upper-right of the screen
; this is temporary
CLC
LDA MOUSE_BUTTONS_REG
setxl
LDY #60
JSR WRITE_HEX
setxs
JSR MOUSE_BUTTON_HANDLER
LDX #$00
EXIT_FOR_NEXT_VALUE
STX MOUSE_PTR
setxl
RTS
MOUSE_BUTTON_HANDLER
setas
LDA @lMOUSE_BUTTONS_REG
BEQ MOUSE_CLICK_DONE
; set the cursor position ( X/8 and Y/8 ) and enable blinking
setal
CLC
LDA @lMOUSE_PTR_X_POS_L
LSR
LSR
LSR
STA CURSORX
STA @lVKY_TXT_CURSOR_X_REG_L
CLC
LDA @lMOUSE_PTR_Y_POS_L
LSR
LSR
LSR
STA CURSORY
STA @lVKY_TXT_CURSOR_Y_REG_L
setas
LDA #$03 ;Set Cursor Enabled And Flash Rate @1Hz
STA @lVKY_TXT_CURSOR_CTRL_REG
MOUSE_CLICK_DONE
RTS
Dan