There's something surreal in talking about PC BIOS Interrupts in 2020; just let the damn things die.
Anyway, Steve has quoted the implementation of INTERRUPTX when he should have quoted INTERRUPT (the previous function in libqb), which has a check of the expected size.
In either case, both functions call the call_int() function: void call_int(int32 i){
if (i==0x33){
if (cpu.ax==0){
cpu.ax=0xFFFF;//mouse installed
cpu.bx=2;
return;
}
if (cpu.ax==1){sub__mouseshow(NULL,0); return;}
if (cpu.ax==2){sub__mousehide(); return;}
if (cpu.ax==3){
//return the current mouse status
//buttons
int32 handle;
handle=mouse_message_queue_default;
mouse_message_queue_struct *queue=(mouse_message_queue_struct*)list_get(mouse_message_queue_handles,handle);
//buttons
cpu.bx=queue->queue[queue->last].buttons&1;
if (queue->queue[queue->last].buttons&4) cpu.bx+=2;
//x,y offsets
static float mx,my;
//temp override current message index to the most recent event
static int32 current_mouse_message_backup;
current_mouse_message_backup=queue->current;
queue->current=queue->last;
mx=func__mousex(0,0); my=func__mousey(0,0);
//restore "current" message index
queue->current=current_mouse_message_backup;
cpu.cx=mx; cpu.dx=my;
//double x-axis value for modes 1,7,13
if ((display_page->compatible_mode==1)||(display_page->compatible_mode==7)||(display_page->compatible_mode==13)) cpu.cx*=2;
if (display_page->text){
//note: a range from 0 to columns*8-1 is returned regardless of the number of actual pixels
cpu.cx=(mx-0.5)*8.0;
if (cpu.cx>=(display_page->width*8)) cpu.cx=(display_page->width*8)-1;
//note: a range from 0 to rows*8-1 is returned regardless of the number of actual pixels
//obselete line of code: cpu.dx=(((float)cpu.dx)/((float)(display_page->height*fontheight[display_page->font])))*((float)(display_page->height*8));//(mouse_y/height_in_pixels)*(rows*8)
cpu.dx=(my-0.5)*8.0;
if (cpu.dx>=(display_page->height*8)) cpu.dx=(display_page->height*8)-1;
}
return;
}
if (cpu.ax==7){//horizontal min/max
return;
}
if (cpu.ax==8){//vertical min/max
return;
}
//MessageBox2(NULL,"Unknown MOUSE Sub-function","Call Interrupt Error",MB_OK|MB_SYSTEMMODAL);
//exit(cpu.ax);
return;
}
}
Note in particular:
- Only the mouse interrupt, 33h, is supported.
- Fetching the position is ultimately a call to func__mousex(), which is what _MOUSEX is behind the scenes.
To preempt further questions, call_int is also used to handle the INT opcode in CALL ABSOLUTE. The full set of opcodes handled is easily found by examining the call_absolute() function in libqb.
To reiterate: there is no good reason to be using PC BIOS interrupts in 2020. They are not some speed panacea, nor are they somehow "closer to the hardware". Just let them die already.